Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@33cn/game-cashier-react

Package Overview
Dependencies
Maintainers
8
Versions
77
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@33cn/game-cashier-react - npm Package Compare versions

Comparing version 1.9.15 to 1.9.16

4

lib/api/cashierAPI/index.d.ts

@@ -39,4 +39,4 @@ /**

export declare function rechargeParaStep1(gameNodeURL: string, amount: number, address: string): Promise<any>;
export declare function rechargeParaStep2(gameNodeURL: string, amount: number): Promise<string>;
export declare function withdrawParaStep1(gameNodeURL: string, amount: number): Promise<string>;
export declare function rechargeParaStep2(gameNodeURL: string, amount: number, contractAddr: string, contractName: string): Promise<string>;
export declare function withdrawParaStep1(gameNodeURL: string, amount: number, contractAddr: string, contractName: string): Promise<string>;
export declare function withdrawParaStep2(gameNodeURL: string, amount: number, address: string): Promise<any>;

@@ -172,8 +172,16 @@ import * as tslib_1 from "tslib";

}
function coinsToGame(url, amount, contractAddr, contractName, isWithdraw) {
return callPromiseAPI('CreateRawTransaction', {
to: contractAddr,
amount: amount * 1e8,
execName: contractName,
isWithdraw: isWithdraw
}, url);
}
export function rechargeParaStep1(gameNodeURL, amount, address) {
return paracrossAssetTransfer(gameNodeURL, address, amount, false);
}
export function rechargeParaStep2(gameNodeURL, amount) {
export function rechargeParaStep2(gameNodeURL, amount, contractAddr, contractName) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var tx2, tx3, tx4;
var tx2, tx3, tx4, tx5;
return tslib_1.__generator(this, function (_a) {

@@ -194,3 +202,6 @@ switch (_a.label) {

tx4 = _a.sent();
return [2 /*return*/, tx2 + "," + tx3 + "," + tx4];
return [4 /*yield*/, coinsToGame(gameNodeURL, amount, contractAddr, contractName, false)];
case 4:
tx5 = _a.sent();
return [2 /*return*/, tx2 + "," + tx3 + "," + tx4 + "," + tx5];
}

@@ -200,20 +211,23 @@ });

}
export function withdrawParaStep1(gameNodeURL, amount) {
export function withdrawParaStep1(gameNodeURL, amount, contractAddr, contractName) {
return tslib_1.__awaiter(this, void 0, void 0, function () {
var tx1, tx2, tx3;
var tx1, tx2, tx3, tx4;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, tradeToCoins(gameNodeURL, amount, false)];
case 0: return [4 /*yield*/, coinsToGame(gameNodeURL, amount, contractAddr, contractName, true)];
case 1:
tx1 = _a.sent();
return [4 /*yield*/, buyParacross(gameNodeURL, amount)];
return [4 /*yield*/, tradeToCoins(gameNodeURL, amount, false)];
case 2:
tx2 = _a.sent();
return [4 /*yield*/, buyParacross(gameNodeURL, amount)];
case 3:
tx3 = _a.sent();
return [4 /*yield*/, paracrossToTrade(gameNodeURL, amount, true)
// const tx4 = await paracrossAssetTransfer(gameNodeURL, address, amount , true)
];
case 3:
tx3 = _a.sent();
case 4:
tx4 = _a.sent();
// const tx4 = await paracrossAssetTransfer(gameNodeURL, address, amount , true)
return [2 /*return*/, tx1 + "," + tx2 + "," + tx3];
return [2 /*return*/, tx1 + "," + tx2 + "," + tx3 + "," + tx4];
}

@@ -220,0 +234,0 @@ });

@@ -56,16 +56,17 @@ import * as tslib_1 from "tslib";

return tslib_1.__awaiter(this, void 0, void 0, function () {
var currentHash, res, error_1;
return tslib_1.__generator(this, function (_a) {
switch (_a.label) {
var currentHash, res, _a, promise;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
currentHash = hash;
_a.label = 1;
_b.label = 1;
case 1:
_a.trys.push([1, 5, , 6]);
_a.label = 2;
if (!currentHash) return [3 /*break*/, 7];
console.log('currentHash', currentHash);
_b.label = 2;
case 2:
if (!currentHash) return [3 /*break*/, 4];
_b.trys.push([2, 4, , 6]);
return [4 /*yield*/, queryTransaction(currentHash, url)];
case 3:
res = _a.sent();
res = _b.sent();
// none交易跳过判断

@@ -81,8 +82,14 @@ if (res.actionName === 'unknown') {

}
return [3 /*break*/, 2];
case 4: return [2 /*return*/, true];
case 5:
error_1 = _a.sent();
return [2 /*return*/, false];
case 6: return [2 /*return*/];
return [3 /*break*/, 6];
case 4:
_a = _b.sent();
promise = new Promise(function (resolve, reject) {
setTimeout(function () {
queryTransactionGroup(currentHash, url).then(function (result) { return resolve(result); });
}, 2000);
});
return [4 /*yield*/, promise];
case 5: return [2 /*return*/, _b.sent()];
case 6: return [3 /*break*/, 1];
case 7: return [2 /*return*/, true];
}

@@ -89,0 +96,0 @@ });

@@ -67,3 +67,3 @@ import * as React from 'react';

path: string;
usedCoinsBalance: number;
usedGameBalance: number;
rechargeState: {

@@ -70,0 +70,0 @@ step: RWStep;

@@ -42,3 +42,3 @@ import * as tslib_1 from "tslib";

path: 'home',
usedCoinsBalance: 0,
usedGameBalance: 0,
rechargeState: {

@@ -100,3 +100,3 @@ step: RWStep.unStart,

return balance -= item.amount;
}, this.state.usedCoinsBalance);
}, this.state.usedGameBalance);
if (finalBalance < 0) {

@@ -110,3 +110,3 @@ finalBalance = 0;

btyBalance: +(finalBalance).toFixed(2),
usedCoinsBalance: used
usedGameBalance: used
});

@@ -119,3 +119,3 @@ };

React.createElement(MasterFolio, { btyBalance: this.state.btyBalance, onPathChange: this.changePath }),
React.createElement(Content, { gameBalance: this.props.gameBalance, coinsBalance: this.props.coinsBalance - this.state.usedCoinsBalance, gameName: this.props.gameName, gameIcon: this.props.gameIcon, contractName: this.props.contractName, contractAddr: this.props.contractAddr, onPathChange: this.changePath })));
React.createElement(Content, { gameBalance: this.props.gameBalance - this.state.usedGameBalance, coinsBalance: this.props.coinsBalance, gameName: this.props.gameName, gameIcon: this.props.gameIcon, contractName: this.props.contractName, contractAddr: this.props.contractAddr, onPathChange: this.changePath })));
switch (this.state.path) {

@@ -125,12 +125,12 @@ case 'home':

case 'recharge':
matchElem = (React.createElement(Recharge, { needWithhold: this.props.needWithhold, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, type: "recharge", contractName: this.props.contractName, onCloseClick: this.resetPathOnClose, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, btyBalance: this.state.btyBalance, coinsBalance: this.props.coinsBalance - this.state.usedCoinsBalance, rechargeState: this.state.rechargeState, widthdrawState: this.state.widthdrawState, onTransactionStart: this.setRWStart, exercerName: this.props.exercerName }));
matchElem = (React.createElement(Recharge, { needWithhold: this.props.needWithhold, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, type: "recharge", contractName: this.props.contractName, contractAddr: this.props.contractAddr, onCloseClick: this.resetPathOnClose, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, btyBalance: this.state.btyBalance, gameBalance: this.props.gameBalance - this.state.usedGameBalance, rechargeState: this.state.rechargeState, widthdrawState: this.state.widthdrawState, onTransactionStart: this.setRWStart, exercerName: this.props.exercerName }));
break;
case 'widthdraw':
matchElem = (React.createElement(Recharge, { needWithhold: this.props.needWithhold, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, type: "widthdraw", contractName: this.props.contractName, onCloseClick: this.resetPathOnClose, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, btyBalance: this.state.btyBalance, coinsBalance: this.props.coinsBalance - this.state.usedCoinsBalance, rechargeState: this.state.rechargeState, widthdrawState: this.state.widthdrawState, onTransactionStart: this.setRWStart, exercerName: this.props.exercerName }));
matchElem = (React.createElement(Recharge, { needWithhold: this.props.needWithhold, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, type: "widthdraw", contractName: this.props.contractName, contractAddr: this.props.contractAddr, onCloseClick: this.resetPathOnClose, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, btyBalance: this.state.btyBalance, gameBalance: this.props.gameBalance - this.state.usedGameBalance, rechargeState: this.state.rechargeState, widthdrawState: this.state.widthdrawState, onTransactionStart: this.setRWStart, exercerName: this.props.exercerName }));
break;
case 'to-contract':
matchElem = (React.createElement(DoTransfer, { gameBalance: this.props.gameBalance, coinsBalance: this.props.coinsBalance - this.state.usedCoinsBalance, onCloseClick: this.resetPathOnClose, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, gameName: this.props.gameName, gameIcon: this.props.gameIcon, contractName: this.props.contractName, contractAddr: this.props.contractAddr, toContract: true, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, needWithhold: this.props.needWithhold, exercerName: this.props.exercerName }));
matchElem = (React.createElement(DoTransfer, { gameBalance: this.props.gameBalance - this.state.usedGameBalance, coinsBalance: this.props.coinsBalance, onCloseClick: this.resetPathOnClose, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, gameName: this.props.gameName, gameIcon: this.props.gameIcon, contractName: this.props.contractName, contractAddr: this.props.contractAddr, toContract: true, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, needWithhold: this.props.needWithhold, exercerName: this.props.exercerName }));
break;
case 'to-coins':
matchElem = (React.createElement(DoTransfer, { gameBalance: this.props.gameBalance, coinsBalance: this.props.coinsBalance - this.state.usedCoinsBalance, onCloseClick: this.resetPathOnClose, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, gameName: this.props.gameName, contractName: this.props.contractName, gameIcon: this.props.gameIcon, contractAddr: this.props.contractAddr, toContract: false, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, needWithhold: this.props.needWithhold, exercerName: this.props.exercerName }));
matchElem = (React.createElement(DoTransfer, { gameBalance: this.props.gameBalance - this.state.usedGameBalance, coinsBalance: this.props.coinsBalance, onCloseClick: this.resetPathOnClose, gameNodeURL: this.props.gameNodeURL, address: this.state.myAddress, gameName: this.props.gameName, contractName: this.props.contractName, gameIcon: this.props.gameIcon, contractAddr: this.props.contractAddr, toContract: false, onPathChange: this.changePath, onNewTransactionSend: this.props.onNewTransactionSend, needWithhold: this.props.needWithhold, exercerName: this.props.exercerName }));
break;

@@ -292,2 +292,4 @@ }

queryTransactionGroup(transaction.hash, _this.props.gameNodeURL).then(function (result) {
console.log('queryTransactionGroup result', result);
console.log('queryTransactionGroup hash', transaction.hash);
if (result) {

@@ -294,0 +296,0 @@ // 充值的第三步

@@ -8,2 +8,3 @@ import * as React from 'react';

contractName: string;
contractAddr: string;
type: 'recharge' | 'widthdraw';

@@ -16,3 +17,3 @@ onPathChange: (path: string) => void;

btyBalance: number;
coinsBalance: number;
gameBalance: number;
rechargeState: {

@@ -19,0 +20,0 @@ step: RWStep;

@@ -74,3 +74,3 @@ import * as tslib_1 from "tslib";

return [3 /*break*/, 6];
case 3: return [4 /*yield*/, withdrawParaStep1(this.props.gameNodeURL, +rwState.amount)];
case 3: return [4 /*yield*/, withdrawParaStep1(this.props.gameNodeURL, +rwState.amount, this.props.contractAddr, this.props.contractName)];
case 4:

@@ -130,3 +130,3 @@ tx1 = _b.sent();

if (!isRecharge) return [3 /*break*/, 19];
return [4 /*yield*/, rechargeParaStep2(this.props.gameNodeURL, rwState.amount)];
return [4 /*yield*/, rechargeParaStep2(this.props.gameNodeURL, rwState.amount, this.props.contractAddr, this.props.contractName)];
case 17:

@@ -191,5 +191,7 @@ tx3 = _b.sent();

Recharge.prototype.render = function () {
var _this = this;
var _a = this.props, type = _a.type, widthdrawState = _a.widthdrawState, rechargeState = _a.rechargeState;
var actionName = type === 'recharge' ? '充值' : '提现';
var rwState = type === 'recharge' ? rechargeState : widthdrawState;
var isRecharge = type === 'recharge';
return (React.createElement("div", { className: "recharge-box" },

@@ -211,5 +213,9 @@ React.createElement(Header, { canBack: true, onPathChange: this.props.onPathChange, title: actionName, onCloseClick: this.props.onCloseClick }),

React.createElement(GlobalContext.Consumer, null, function (val) { return (React.createElement("p", { className: "tip" },
"1 ",
val.coinName,
"\u7B49\u4E8E1 BTY")); })),
React.createElement("span", null,
"1 ",
val.coinName,
"\u7B49\u4E8E1 BTY"),
React.createElement("span", { className: "right" },
"\u8D44\u4EA7\uFF1A",
isRecharge ? _this.props.btyBalance + "BTY" : "" + _this.props.gameBalance + val.coinName))); })),
React.createElement(Button, { className: "btn-blue", loading: this.state.loading, onClick: this.submit }, actionName)) :

@@ -262,3 +268,3 @@ React.createElement("div", { className: "process-box clearfix" },

}
if (this.props.type === 'widthdraw' && +this.state.amount > this.props.coinsBalance) {
if (this.props.type === 'widthdraw' && +this.state.amount > this.props.gameBalance) {
notification.warning({

@@ -287,3 +293,3 @@ message: '余额不足',

signedTx2 = _a.sent();
return [4 /*yield*/, rechargeParaStep2(this.props.gameNodeURL, +this.state.amount)];
return [4 /*yield*/, rechargeParaStep2(this.props.gameNodeURL, +this.state.amount, this.props.contractAddr, this.props.contractName)];
case 6:

@@ -325,3 +331,3 @@ tx3 = _a.sent();

_a.trys.push([11, 19, , 20]);
return [4 /*yield*/, withdrawParaStep1(this.props.gameNodeURL, +this.state.amount)];
return [4 /*yield*/, withdrawParaStep1(this.props.gameNodeURL, +this.state.amount, this.props.contractAddr, this.props.contractName)];
case 12:

@@ -328,0 +334,0 @@ tx1 = _a.sent();

@@ -8,3 +8,9 @@ /* import './index.css';

import { App } from './App';
/* import { queryTransactionGroup } from './api/chain33API';
queryTransactionGroup('0x5bbc6e1b73d03d2e7a83f9f17e59448b42027e36b2153d6c008e06909009d1ac','http://47.98.245.85:8901')
.then(res => console.log('queryTransactionGroup', res)); */
import Vconsole from 'vconsole';
var res = new Vconsole();
console.log(res);
ReactDOM.render(React.createElement(App, null), document.getElementById('root'));
//# sourceMappingURL=index.js.map
{
"name": "@33cn/game-cashier-react",
"version": "1.9.15",
"version": "1.9.16",
"main": "lib/Cashier.js",

@@ -14,3 +14,4 @@ "publishConfig": {

"react-dom": "^16.8.4",
"react-scripts-ts": "3.1.0"
"react-scripts-ts": "3.1.0",
"vconsole": "^3.3.2"
},

@@ -17,0 +18,0 @@ "scripts": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc