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.14 to 1.9.15

deploy2TestServer.sh

1

lib/api/chain33API/index.d.ts

@@ -85,2 +85,3 @@ /**

export declare function queryTransaction(hash: string, url: string): Promise<any>;
export declare function queryTransactionGroup(hash: string, url: string): Promise<boolean>;
export {};

@@ -0,1 +1,2 @@

import * as tslib_1 from "tslib";
import callPromiseAPI from '../callPromiseAPI';

@@ -53,2 +54,38 @@ /**

}
export function queryTransactionGroup(hash, url) {
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) {
case 0:
currentHash = hash;
_a.label = 1;
case 1:
_a.trys.push([1, 5, , 6]);
_a.label = 2;
case 2:
if (!currentHash) return [3 /*break*/, 4];
return [4 /*yield*/, queryTransaction(currentHash, url)];
case 3:
res = _a.sent();
// none交易跳过判断
if (res.actionName === 'unknown') {
currentHash = res.tx.next;
}
else if (res.receipt.ty === 2) {
currentHash = res.tx.next;
}
else {
return [2 /*return*/, false];
}
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*/];
}
});
});
}
//# sourceMappingURL=index.js.map

4

lib/Cashier.d.ts

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

currentTx: string;
amount: number;
};

@@ -76,2 +77,3 @@ widthdrawState: {

currentTx: string;
amount: number;
};

@@ -89,5 +91,5 @@ }

resetPathOnClose(): void;
setRWStart(type: 'recharge' | 'widthdraw', step: RWStep, tx: string): void;
setRWStart(type: 'recharge' | 'widthdraw', step: RWStep, tx: string, amount: number): void;
private queryTransactions;
}
export default App;

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

import { getCurrentBTYAddress } from '@33cn/wallet-api';
import { getAddrBalance, queryTransaction, sendTransaction } from './api/chain33API';
import { getAddrBalance, queryTransaction, sendTransaction, queryTransactionGroup } from './api/chain33API';
import { mainnetURL } from './api/config';

@@ -46,7 +46,9 @@ import { getUnfinishTransactions, TransactionStorageName, removeTransaction, insertTransaction } from './lib/unfinishedBlockTransaction';

step: RWStep.unStart,
currentTx: ''
currentTx: '',
amount: 0,
},
widthdrawState: {
step: RWStep.unStart,
currentTx: ''
currentTx: '',
amount: 0,
}

@@ -148,3 +150,3 @@ };

};
App.prototype.setRWStart = function (type, step, tx) {
App.prototype.setRWStart = function (type, step, tx, amount) {
if (type === 'recharge') {

@@ -154,3 +156,4 @@ this.setState({

step: step,
currentTx: tx
currentTx: tx,
amount: amount,
}

@@ -163,3 +166,4 @@ });

step: step,
currentTx: tx
currentTx: tx,
amount: amount,
}

@@ -178,3 +182,4 @@ });

step: RWStep.sendingOne,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}

@@ -191,3 +196,4 @@ });

step: RWStep.sendingTwo,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -207,3 +213,4 @@ });

step: RWStep.twoFail,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -218,3 +225,4 @@ });

step: RWStep.oneFail,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}

@@ -231,3 +239,4 @@ });

step: RWStep.sendingTwo,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}

@@ -244,3 +253,4 @@ });

step: RWStep.sendingThree,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -260,3 +270,4 @@ });

step: RWStep.ThreeFail,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -270,3 +281,4 @@ });

step: RWStep.twoFail,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}

@@ -283,7 +295,8 @@ });

step: RWStep.sendingThree,
currentTx: transaction.payload
currentTx: transaction.payload,
amount: transaction.amount
}
});
queryTransaction(transaction.hash, _this.props.gameNodeURL).then(function (result) {
if (result.receipt.ty === 2) {
queryTransactionGroup(transaction.hash, _this.props.gameNodeURL).then(function (result) {
if (result) {
// 充值的第三步

@@ -293,3 +306,4 @@ _this.setState({

step: RWStep.unStart,
currentTx: ''
currentTx: '',
amount: transaction.amount
}

@@ -307,3 +321,4 @@ });

step: RWStep.ThreeFail,
currentTx: transaction.payload
currentTx: transaction.payload,
amount: transaction.amount
}

@@ -320,8 +335,9 @@ });

step: RWStep.sendingOne,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}
});
queryTransaction(transaction.hash, _this.props.gameNodeURL).then(function (result) {
queryTransactionGroup(transaction.hash, _this.props.gameNodeURL).then(function (result) {
// 交易执行成功
if (result.receipt.ty === 2) {
if (result) {
sendTransaction(transaction.payload[1], _this.props.gameNodeURL)

@@ -332,3 +348,4 @@ .then(function (hash) {

step: RWStep.sendingTwo,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -348,3 +365,4 @@ });

step: RWStep.twoFail,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -359,3 +377,4 @@ });

step: RWStep.oneFail,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}

@@ -372,3 +391,4 @@ });

step: RWStep.sendingTwo,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}

@@ -384,3 +404,4 @@ });

step: RWStep.sendingThree,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -400,3 +421,4 @@ });

step: RWStep.ThreeFail,
currentTx: transaction.payload[1]
currentTx: transaction.payload[1],
amount: transaction.amount
}

@@ -410,3 +432,4 @@ });

step: RWStep.twoFail,
currentTx: transaction.payload[0]
currentTx: transaction.payload[0],
amount: transaction.amount
}

@@ -423,3 +446,4 @@ });

step: RWStep.sendingThree,
currentTx: transaction.payload
currentTx: transaction.payload,
amount: transaction.amount
}

@@ -433,3 +457,4 @@ });

step: RWStep.unStart,
currentTx: ''
currentTx: '',
amount: transaction.amount
}

@@ -447,3 +472,4 @@ });

step: RWStep.ThreeFail,
currentTx: transaction.payload
currentTx: transaction.payload,
amount: transaction.amount
}

@@ -450,0 +476,0 @@ });

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

currentTx: string;
amount: number;
};

@@ -24,4 +25,5 @@ widthdrawState: {

currentTx: string;
amount: number;
};
onTransactionStart: (type: 'recharge' | 'widthdraw', step: RWStep, tx: string) => void;
onTransactionStart: (type: 'recharge' | 'widthdraw', step: RWStep, tx: string, amount: number) => void;
}

@@ -38,6 +40,6 @@ interface IState {

onInputChange(e: React.ChangeEvent<HTMLInputElement>): void;
onCircleClick: (index: number) => () => void;
sendAndNotify: (step: RWStep, tx: string, url: string) => void;
onCircleClick: (index: number) => () => Promise<void>;
sendAndNotify: (step: RWStep, tx: string, url: string, amount: number) => Promise<any>;
submit(): Promise<void>;
}
export default Recharge;

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

import notification from 'antd/lib/notification';
import { insertTransaction, TransactionStorageName } from '../../lib/unfinishedBlockTransaction';
import { insertTransaction, TransactionStorageName, getUnfinishTransactionsByTx } from '../../lib/unfinishedBlockTransaction';
import { mainnetURL } from '../../api/config';

@@ -57,20 +57,110 @@ import { signTxGroup, signTx } from '@33cn/wallet-api';

// TODO 而不是用原来已经构造好的,因为可能是原来构造的交易出了问题
_this.onCircleClick = function (index) { return function () {
var _a = _this.props, type = _a.type, widthdrawState = _a.widthdrawState, rechargeState = _a.rechargeState;
var isRecharge = type === 'recharge';
var rwState = isRecharge ? rechargeState : widthdrawState;
if (index === 1 && rwState.step === RWStep.oneFail) {
_this.sendAndNotify(rwState.step, rwState.currentTx, isRecharge ? mainnetURL : _this.props.gameNodeURL);
}
if (index === 2 && rwState.step === RWStep.twoFail) {
_this.sendAndNotify(rwState.step, rwState.currentTx, _this.props.gameNodeURL);
}
if (index === 3 && rwState.step === RWStep.ThreeFail) {
_this.sendAndNotify(rwState.step, rwState.currentTx, isRecharge ? _this.props.gameNodeURL : mainnetURL);
}
}; };
_this.sendAndNotify = function (step, tx, url) {
sendTransaction(tx, url).then(function (hash) {
_this.onCircleClick = function (index) { return function () { return tslib_1.__awaiter(_this, void 0, void 0, function () {
var _a, type, widthdrawState, rechargeState, isRecharge, rwState, signedTx1, tx1, tx1, hash1, transactionStorageName, transaction, signedTx2, tx2, tx2, hash2, transactionStorageName, transaction, signedTx3, tx3, tx3, hash3, transactionStorageName, transaction;
return tslib_1.__generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = this.props, type = _a.type, widthdrawState = _a.widthdrawState, rechargeState = _a.rechargeState;
isRecharge = type === 'recharge';
rwState = isRecharge ? rechargeState : widthdrawState;
if (!(index === 1 && rwState.step === RWStep.oneFail)) return [3 /*break*/, 8];
signedTx1 = '';
if (!isRecharge) return [3 /*break*/, 3];
return [4 /*yield*/, toParacross(mainnetURL, +rwState.amount, false)];
case 1:
tx1 = _b.sent();
return [4 /*yield*/, signTx(tx1, 'title', '')];
case 2:
signedTx1 = _b.sent();
return [3 /*break*/, 6];
case 3: return [4 /*yield*/, withdrawParaStep1(this.props.gameNodeURL, +rwState.amount)];
case 4:
tx1 = _b.sent();
return [4 /*yield*/, signTxGroup(tx1, this.props.exercerName)];
case 5:
signedTx1 = _b.sent();
_b.label = 6;
case 6: return [4 /*yield*/, this.sendAndNotify(rwState.step, signedTx1, isRecharge ? mainnetURL : this.props.gameNodeURL, rwState.amount)];
case 7:
hash1 = _b.sent();
transactionStorageName = isRecharge ? TransactionStorageName.maincross : TransactionStorageName.paracross;
transaction = getUnfinishTransactionsByTx(transactionStorageName, rwState.currentTx);
insertTransaction({
desc: transaction.desc,
hash: hash1,
amount: +rwState.amount,
sendTime: Date.now(),
payload: [signedTx1, transaction.payload[1], transaction.payload[2]]
}, transactionStorageName);
_b.label = 8;
case 8:
if (!(index === 2 && rwState.step === RWStep.twoFail)) return [3 /*break*/, 16];
signedTx2 = '';
if (!isRecharge) return [3 /*break*/, 11];
return [4 /*yield*/, rechargeParaStep1(this.props.gameNodeURL, +this.state.amount, this.props.address)];
case 9:
tx2 = _b.sent();
return [4 /*yield*/, signTx(tx2, '', '')];
case 10:
signedTx2 = _b.sent();
return [3 /*break*/, 14];
case 11: return [4 /*yield*/, withdrawParaStep2(this.props.gameNodeURL, +this.state.amount, this.props.address)];
case 12:
tx2 = _b.sent();
return [4 /*yield*/, signTx(tx2, '', '')];
case 13:
signedTx2 = _b.sent();
_b.label = 14;
case 14: return [4 /*yield*/, this.sendAndNotify(rwState.step, signedTx2, this.props.gameNodeURL, rwState.amount)];
case 15:
hash2 = _b.sent();
transactionStorageName = isRecharge ? TransactionStorageName.recharge2 : TransactionStorageName.withdraw2;
transaction = getUnfinishTransactionsByTx(transactionStorageName, rwState.currentTx);
insertTransaction({
desc: transaction.desc,
hash: hash2,
amount: +rwState.amount,
sendTime: Date.now(),
payload: [signedTx2, transaction.payload[1]]
}, transactionStorageName);
_b.label = 16;
case 16:
if (!(index === 3 && rwState.step === RWStep.ThreeFail)) return [3 /*break*/, 24];
signedTx3 = '';
if (!isRecharge) return [3 /*break*/, 19];
return [4 /*yield*/, rechargeParaStep2(this.props.gameNodeURL, rwState.amount)];
case 17:
tx3 = _b.sent();
return [4 /*yield*/, signTxGroup(tx3, this.props.exercerName)];
case 18:
signedTx3 = _b.sent();
return [3 /*break*/, 22];
case 19: return [4 /*yield*/, toParacross(mainnetURL, +this.state.amount, true)];
case 20:
tx3 = _b.sent();
return [4 /*yield*/, signTx(tx3, '', '')];
case 21:
signedTx3 = _b.sent();
_b.label = 22;
case 22: return [4 /*yield*/, this.sendAndNotify(rwState.step, signedTx3, isRecharge ? this.props.gameNodeURL : mainnetURL, rwState.amount)];
case 23:
hash3 = _b.sent();
transactionStorageName = isRecharge ? TransactionStorageName.recharge3 : TransactionStorageName.withdraw3;
transaction = getUnfinishTransactionsByTx(transactionStorageName, rwState.currentTx);
insertTransaction({
desc: transaction.desc,
hash: hash3,
amount: +rwState.amount,
sendTime: Date.now(),
payload: signedTx3
}, transactionStorageName);
_b.label = 24;
case 24: return [2 /*return*/];
}
});
}); }; };
_this.sendAndNotify = function (step, tx, url, amount) {
return sendTransaction(tx, url).then(function (hash) {
console.log(hash);
_this.props.onTransactionStart(_this.props.type, step, tx);
_this.props.onTransactionStart(_this.props.type, step, tx, amount);
notification.success({

@@ -80,2 +170,3 @@ message: '交易发送成功,请等待区块链确认',

});
return hash;
}).catch(function (e) {

@@ -86,2 +177,3 @@ notification.error({

});
return '';
});

@@ -211,3 +303,3 @@ };

this.setState({ loading: false });
this.props.onTransactionStart(this.props.type, RWStep.sendingOne, signedTx1);
this.props.onTransactionStart(this.props.type, RWStep.sendingOne, signedTx1, +this.state.amount);
notification.success({

@@ -262,3 +354,3 @@ message: '充值交易发送成功,请等待区块链确认',

this.setState({ loading: false });
this.props.onTransactionStart(this.props.type, RWStep.sendingOne, signedTx1);
this.props.onTransactionStart(this.props.type, RWStep.sendingOne, signedTx1, +this.state.amount);
notification.success({

@@ -265,0 +357,0 @@ message: '充值交易发送成功,请等待区块链确认',

@@ -11,3 +11,3 @@ export declare enum TransactionStorageName {

}
interface UnfinishTransaction {
export interface UnfinishTransaction {
desc: string;

@@ -22,2 +22,2 @@ amount: number;

export declare function getUnfinishTransactions(STORAGE_NAME: TransactionStorageName): UnfinishTransaction[];
export {};
export declare function getUnfinishTransactionsByTx(STORAGE_NAME: TransactionStorageName, tx: string): UnfinishTransaction;

@@ -47,2 +47,7 @@ export var TransactionStorageName;

}
export function getUnfinishTransactionsByTx(STORAGE_NAME, tx) {
var transactions = getObj(STORAGE_NAME) || [];
var matched = transactions.filter(function (transaction) { return transaction.payload.length ? transaction.payload[0] === tx : transaction.payload === tx; });
return matched[0];
}
//# sourceMappingURL=unfinishedBlockTransaction.js.map
{
"name": "@33cn/game-cashier-react",
"version": "1.9.14",
"version": "1.9.15",
"main": "lib/Cashier.js",

@@ -5,0 +5,0 @@ "publishConfig": {

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