-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetTxResult.js
33 lines (28 loc) · 990 Bytes
/
getTxResult.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const AElf = require('aelf-sdk');
const { getTxResult } =require('@portkey/contracts');
function getAElf(rpcUrl) {
const rpc = rpcUrl || '';
const httpProviders = {};
if (!httpProviders[rpc]) {
httpProviders[rpc] = new AElf(new AElf.providers.HttpProvider(rpc));
}
return httpProviders[rpc];
}
const getRpcUrls = () => {
return {
AELF: 'https://aelf-test-node.aelf.io',
tDVV: 'https://tdvv-test-node.aelf.io',
tDVW: 'https://tdvw-test-node.aelf.io',
};
};
async function getTxRs(TransactionId, chainId = 'tDVW', reGetCount = -280, notExistedReGetCount = -5) {
const rpcUrl = getRpcUrls()[chainId];
const instance = getAElf(rpcUrl);
const txResult = await getTxResult(instance, TransactionId, reGetCount, notExistedReGetCount);
console.log('TransactionId-----------',TransactionId, txResult)
if (txResult.Status.toLowerCase() === 'mined') {
return txResult;
}
throw Error('Transaction error:' + TransactionId);
}
module.exports = getTxRs