@subwallet/extension-base 1.0.8-0 → 1.0.9-0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/koni/api/dotsama/balance.js +3 -1
- package/cjs/koni/api/dotsama/transfer.js +17 -3
- package/cjs/koni/api/tokens/wasm/index.js +7 -0
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +6 -4
- package/cjs/services/history-service/constants/index.js +13 -0
- package/cjs/services/history-service/subsquid-multi-chain-history.js +38 -3
- package/cjs/utils/eth/parseTransaction/index.js +69 -59
- package/koni/api/dotsama/balance.js +2 -1
- package/koni/api/dotsama/transfer.js +17 -3
- package/koni/api/tokens/wasm/index.js +7 -0
- package/package.json +11 -6
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.d.ts +2 -0
- package/services/chain-service/constants.js +6 -4
- package/services/history-service/constants/index.d.ts +2 -0
- package/services/history-service/constants/index.js +5 -0
- package/services/history-service/subsquid-multi-chain-history.d.ts +1 -1
- package/services/history-service/subsquid-multi-chain-history.js +36 -3
- package/utils/eth/parseTransaction/index.js +69 -59
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
@@ -17,6 +18,7 @@ var _handlers = require("@subwallet/extension-base/koni/background/handlers");
|
|
|
17
18
|
var _constants2 = require("@subwallet/extension-base/services/chain-service/constants");
|
|
18
19
|
var _utils2 = require("@subwallet/extension-base/services/chain-service/utils");
|
|
19
20
|
var _utils3 = require("@subwallet/extension-base/utils");
|
|
21
|
+
var _bignumber = _interopRequireDefault(require("bignumber.js"));
|
|
20
22
|
var _util = require("@polkadot/util");
|
|
21
23
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
22
24
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -241,7 +243,7 @@ async function subscribeEquilibriumTokenBalance(addresses, chain, api, callBack,
|
|
|
241
243
|
|
|
242
244
|
// @ts-ignore
|
|
243
245
|
const freeTokenBalance = balanceList.find(data => data[0] === parseInt(assetId));
|
|
244
|
-
const bnFreeTokenBalance = freeTokenBalance ? new _util.BN(freeTokenBalance[1].positive.toString()) : _util.BN_ZERO;
|
|
246
|
+
const bnFreeTokenBalance = freeTokenBalance ? new _util.BN(new _bignumber.default(freeTokenBalance[1].positive).toString()) : _util.BN_ZERO;
|
|
245
247
|
tokenFreeBalance = tokenFreeBalance.add(bnFreeTokenBalance);
|
|
246
248
|
}
|
|
247
249
|
const tokenBalance = {
|
|
@@ -90,7 +90,14 @@ async function checkSupportTransfer(networkKey, tokenInfo, substrateApiMap, chai
|
|
|
90
90
|
} else if (_constants._TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo)) {
|
|
91
91
|
result.supportTransfer = true;
|
|
92
92
|
result.supportTransferAll = true;
|
|
93
|
+
} else if (_constants._TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey)) {
|
|
94
|
+
result.supportTransfer = true;
|
|
95
|
+
result.supportTransferAll = true;
|
|
96
|
+
// } else if (_TRANSFER_CHAIN_GROUP.riochain.includes(networkKey) && _isNativeToken(tokenInfo)) {
|
|
97
|
+
// result.supportTransfer = true;
|
|
98
|
+
// result.supportTransferAll = true;
|
|
93
99
|
}
|
|
100
|
+
|
|
94
101
|
return result;
|
|
95
102
|
}
|
|
96
103
|
const createTransferExtrinsic = async _ref => {
|
|
@@ -111,6 +118,7 @@ const createTransferExtrinsic = async _ref => {
|
|
|
111
118
|
const isTxBalancesSupported = !!api && !!api.tx && !!api.tx.balances;
|
|
112
119
|
const isTxTokensSupported = !!api && !!api.tx && !!api.tx.tokens;
|
|
113
120
|
const isTxEqBalancesSupported = !!api && !!api.tx && !!api.tx.eqBalances;
|
|
121
|
+
const isTxAssetsSupported = !!api && !!api.tx && !!api.tx.assets;
|
|
114
122
|
let transferAmount; // for PSP-22 tokens, might be deprecated in the future
|
|
115
123
|
|
|
116
124
|
if ((0, _utils2._isTokenWasmSmartContract)(tokenInfo) && api.query.contracts) {
|
|
@@ -125,14 +133,14 @@ const createTransferExtrinsic = async _ref => {
|
|
|
125
133
|
transferAmount = value;
|
|
126
134
|
} else if (_constants._TRANSFER_CHAIN_GROUP.acala.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo) && isTxCurrenciesSupported) {
|
|
127
135
|
transfer = api.tx.currencies.transfer(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo), value);
|
|
128
|
-
} else if (_constants._TRANSFER_CHAIN_GROUP.kintsugi.includes(networkKey) &&
|
|
136
|
+
} else if (_constants._TRANSFER_CHAIN_GROUP.kintsugi.includes(networkKey) && isTxTokensSupported) {
|
|
129
137
|
if (transferAll) {
|
|
130
138
|
transfer = api.tx.tokens.transferAll(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo) || (0, _utils2._getTokenOnChainAssetId)(tokenInfo), false);
|
|
131
139
|
} else if (value) {
|
|
132
140
|
transfer = api.tx.tokens.transfer(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo) || (0, _utils2._getTokenOnChainAssetId)(tokenInfo), new _util.BN(value));
|
|
133
141
|
}
|
|
134
|
-
} else if (_constants._TRANSFER_CHAIN_GROUP.genshiro.includes(networkKey) &&
|
|
135
|
-
transfer = api.tx.eqBalances.transfer(
|
|
142
|
+
} else if (_constants._TRANSFER_CHAIN_GROUP.genshiro.includes(networkKey) && isTxEqBalancesSupported) {
|
|
143
|
+
transfer = api.tx.eqBalances.transfer((0, _utils2._getTokenOnChainAssetId)(tokenInfo), to, value);
|
|
136
144
|
} else if (!(0, _utils2._isNativeToken)(tokenInfo) && (_constants._TRANSFER_CHAIN_GROUP.crab.includes(networkKey) || _constants._BALANCE_TOKEN_GROUP.crab.includes(tokenInfo.symbol))) {
|
|
137
145
|
if (transferAll) {
|
|
138
146
|
transfer = api.tx.kton.transferAll(to, false);
|
|
@@ -143,6 +151,12 @@ const createTransferExtrinsic = async _ref => {
|
|
|
143
151
|
transfer = api.tx.currencies.transfer(to, (0, _utils2._getTokenOnChainInfo)(tokenInfo), value);
|
|
144
152
|
} else if (_constants._TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !(0, _utils2._isNativeToken)(tokenInfo)) {
|
|
145
153
|
transfer = api.tx.assets.transfer((0, _utils2._getTokenOnChainAssetId)(tokenInfo), to, value);
|
|
154
|
+
// } else if (_TRANSFER_CHAIN_GROUP.riochain.includes(networkKey)) {
|
|
155
|
+
// if (_isNativeToken(tokenInfo)) {
|
|
156
|
+
// transfer = api.tx.currencies.transferNativeCurrency(to, value);
|
|
157
|
+
// }
|
|
158
|
+
} else if (_constants._TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey) && isTxAssetsSupported) {
|
|
159
|
+
transfer = api.tx.assets.transfer((0, _utils2._getTokenOnChainAssetId)(tokenInfo), to, value);
|
|
146
160
|
} else if (isTxBalancesSupported && (0, _utils2._isNativeToken)(tokenInfo)) {
|
|
147
161
|
if (transferAll) {
|
|
148
162
|
transfer = api.tx.balances.transferAll(to, false);
|
|
@@ -18,9 +18,15 @@ function getPSP22ContractPromise(apiPromise, contractAddress) {
|
|
|
18
18
|
function getPSP34ContractPromise(apiPromise, contractAddress) {
|
|
19
19
|
return new _apiContract.ContractPromise(apiPromise, _helper._PSP34_ABI, contractAddress);
|
|
20
20
|
}
|
|
21
|
+
const mustFormatNumberReg = /^-?[0-9][0-9,.]+$/;
|
|
21
22
|
async function getPSP34TransferExtrinsic(networkKey, substrateApi, senderAddress, recipientAddress, params) {
|
|
22
23
|
const contractAddress = params.contractAddress;
|
|
23
24
|
const onChainOption = params.onChainOption;
|
|
25
|
+
for (const [key, value] of Object.entries(onChainOption)) {
|
|
26
|
+
if (mustFormatNumberReg.test(value)) {
|
|
27
|
+
onChainOption[key] = value.replaceAll(',', '');
|
|
28
|
+
}
|
|
29
|
+
}
|
|
24
30
|
try {
|
|
25
31
|
const contractPromise = getPSP34ContractPromise(substrateApi.api, contractAddress);
|
|
26
32
|
// @ts-ignore
|
|
@@ -31,6 +37,7 @@ async function getPSP34TransferExtrinsic(networkKey, substrateApi, senderAddress
|
|
|
31
37
|
gasLimit
|
|
32
38
|
}, recipientAddress, onChainOption, {});
|
|
33
39
|
} catch (e) {
|
|
40
|
+
console.debug(e);
|
|
34
41
|
return null;
|
|
35
42
|
}
|
|
36
43
|
}
|
package/cjs/packageInfo.js
CHANGED
|
@@ -32,7 +32,7 @@ const _PURE_EVM_CHAINS = ['binance', 'binance_test', 'ethereum', 'ethereum_goerl
|
|
|
32
32
|
// Get balance----------------------------------------------------------------------------------------------------------
|
|
33
33
|
exports._PURE_EVM_CHAINS = _PURE_EVM_CHAINS;
|
|
34
34
|
const _BALANCE_CHAIN_GROUP = {
|
|
35
|
-
kintsugi: ['kintsugi', 'interlay', 'kintsugi_test'],
|
|
35
|
+
kintsugi: ['kintsugi', 'interlay', 'kintsugi_test', 'mangatax_para'],
|
|
36
36
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
37
37
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
38
38
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main'],
|
|
@@ -192,11 +192,13 @@ const _TRANSFER_NOT_SUPPORTED_CHAINS = ['subspace_gemini_3a', 'kulupu', 'joystre
|
|
|
192
192
|
exports._TRANSFER_NOT_SUPPORTED_CHAINS = _TRANSFER_NOT_SUPPORTED_CHAINS;
|
|
193
193
|
const _TRANSFER_CHAIN_GROUP = {
|
|
194
194
|
acala: ['karura', 'acala', 'acala_testnet'],
|
|
195
|
-
kintsugi: ['kintsugi', 'kintsugi_test', 'interlay', 'bifrost_dot', 'hydradx_main'],
|
|
195
|
+
kintsugi: ['kintsugi', 'kintsugi_test', 'interlay', 'bifrost_dot', 'hydradx_main', 'mangatax_para'],
|
|
196
196
|
genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
|
|
197
197
|
crab: ['crab', 'pangolin'],
|
|
198
|
-
bitcountry: ['pioneer', 'bitcountry'],
|
|
199
|
-
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'parallel']
|
|
198
|
+
bitcountry: ['pioneer', 'bitcountry', 'bifrost'],
|
|
199
|
+
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel'],
|
|
200
|
+
riochain: ['riochain'],
|
|
201
|
+
sora_substrate: ['sora_substrate']
|
|
200
202
|
};
|
|
201
203
|
exports._TRANSFER_CHAIN_GROUP = _TRANSFER_CHAIN_GROUP;
|
|
202
204
|
const _BALANCE_PARSING_CHAIN_GROUP = {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.MIN__NUM_HISTORY_PER_ACCOUNT = exports.MAX_FETCH_PAGE_PER_SESSION = void 0;
|
|
7
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
8
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
9
|
+
|
|
10
|
+
const MAX_FETCH_PAGE_PER_SESSION = 25;
|
|
11
|
+
exports.MAX_FETCH_PAGE_PER_SESSION = MAX_FETCH_PAGE_PER_SESSION;
|
|
12
|
+
const MIN__NUM_HISTORY_PER_ACCOUNT = 50;
|
|
13
|
+
exports.MIN__NUM_HISTORY_PER_ACCOUNT = MIN__NUM_HISTORY_PER_ACCOUNT;
|
|
@@ -9,7 +9,9 @@ exports.fetchMultiChainHistories = fetchMultiChainHistories;
|
|
|
9
9
|
exports.parseSubsquidTransactionData = parseSubsquidTransactionData;
|
|
10
10
|
var _client = require("@apollo/client");
|
|
11
11
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
12
|
+
var _constants = require("@subwallet/extension-base/services/history-service/constants");
|
|
12
13
|
var _crossFetch = _interopRequireDefault(require("cross-fetch"));
|
|
14
|
+
var _util = require("@polkadot/util");
|
|
13
15
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
14
16
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
15
17
|
// SPDX-License-Identifier: Apache-2.0
|
|
@@ -81,6 +83,17 @@ function generateSignature(input) {
|
|
|
81
83
|
const vHex = parseInt(v).toString(16);
|
|
82
84
|
return `0x${rHex}${sHex}${vHex}`;
|
|
83
85
|
}
|
|
86
|
+
const parseArgs = args => {
|
|
87
|
+
if ((0, _util.isArray)(args)) {
|
|
88
|
+
return {
|
|
89
|
+
from: args[0],
|
|
90
|
+
to: args[1],
|
|
91
|
+
amount: args[2]
|
|
92
|
+
};
|
|
93
|
+
} else {
|
|
94
|
+
return args;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
84
97
|
function parseSubsquidTransactionData(address, type, historyItem, chainInfo, args, data) {
|
|
85
98
|
var _chainInfo$substrateI, _chainInfo$evmInfo, _chainInfo$substrateI2, _chainInfo$evmInfo2;
|
|
86
99
|
const chainType = chainInfo.substrateInfo ? _KoniTypes.ChainType.SUBSTRATE : _KoniTypes.ChainType.EVM;
|
|
@@ -101,7 +114,7 @@ function parseSubsquidTransactionData(address, type, historyItem, chainInfo, arg
|
|
|
101
114
|
{
|
|
102
115
|
transactionType = _KoniTypes.ExtrinsicType.TRANSFER_BALANCE;
|
|
103
116
|
const extrinsic = data.extrinsic;
|
|
104
|
-
const parsedArgs = args;
|
|
117
|
+
const parsedArgs = parseArgs(args);
|
|
105
118
|
to = autoFormatAddress(parsedArgs.to);
|
|
106
119
|
from = autoFormatAddress(parsedArgs.from);
|
|
107
120
|
amount = parsedArgs.amount;
|
|
@@ -207,10 +220,12 @@ function parseSubsquidTransactionData(address, type, historyItem, chainInfo, arg
|
|
|
207
220
|
};
|
|
208
221
|
}
|
|
209
222
|
async function fetchMultiChainHistories(addresses, chainMap) {
|
|
210
|
-
let maxPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] :
|
|
223
|
+
let maxPage = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : _constants.MAX_FETCH_PAGE_PER_SESSION;
|
|
224
|
+
let countMap = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
|
225
|
+
let _lastId = arguments.length > 4 ? arguments[4] : undefined;
|
|
211
226
|
const responseData = [];
|
|
212
227
|
let currentPage = 0;
|
|
213
|
-
let lastId;
|
|
228
|
+
let lastId = _lastId;
|
|
214
229
|
while (true) {
|
|
215
230
|
try {
|
|
216
231
|
if (maxPage) {
|
|
@@ -239,6 +254,9 @@ async function fetchMultiChainHistories(addresses, chainMap) {
|
|
|
239
254
|
}
|
|
240
255
|
const histories = [];
|
|
241
256
|
const lowerAddresses = addresses.map(a => a.toLowerCase());
|
|
257
|
+
for (const lowerAddress of lowerAddresses) {
|
|
258
|
+
countMap[lowerAddress] = countMap[lowerAddress] || 0;
|
|
259
|
+
}
|
|
242
260
|
responseData.forEach(historyItem => {
|
|
243
261
|
const {
|
|
244
262
|
_data,
|
|
@@ -259,6 +277,10 @@ async function fetchMultiChainHistories(addresses, chainMap) {
|
|
|
259
277
|
|
|
260
278
|
return;
|
|
261
279
|
}
|
|
280
|
+
usedAddresses.forEach(address => {
|
|
281
|
+
const adr = address.toLowerCase();
|
|
282
|
+
countMap[adr] = (countMap[adr] || 0) + 1;
|
|
283
|
+
});
|
|
262
284
|
usedAddresses.forEach(address => {
|
|
263
285
|
try {
|
|
264
286
|
const transactionData = parseSubsquidTransactionData(address, name, historyItem, chainInfo, parseData(args), parseData(_data));
|
|
@@ -268,5 +290,18 @@ async function fetchMultiChainHistories(addresses, chainMap) {
|
|
|
268
290
|
}
|
|
269
291
|
});
|
|
270
292
|
});
|
|
293
|
+
if (currentPage > 1) {
|
|
294
|
+
const retryAddresses = [];
|
|
295
|
+
for (const [address, number] of Object.entries(countMap)) {
|
|
296
|
+
if (number < _constants.MIN__NUM_HISTORY_PER_ACCOUNT) {
|
|
297
|
+
retryAddresses.push(address);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
const _addresses = addresses.filter(add => retryAddresses.includes(add.toLowerCase()));
|
|
301
|
+
if (_addresses.length > 0) {
|
|
302
|
+
const retryHistories = await fetchMultiChainHistories(_addresses, chainMap, maxPage, countMap, lastId);
|
|
303
|
+
histories.push(...retryHistories);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
271
306
|
return histories;
|
|
272
307
|
}
|
|
@@ -107,44 +107,59 @@ const isContractAddress = async (address, evmApi) => {
|
|
|
107
107
|
}
|
|
108
108
|
};
|
|
109
109
|
exports.isContractAddress = isContractAddress;
|
|
110
|
+
const parseInputWithAbi = (input, abi) => {
|
|
111
|
+
const decoder = new _base.InputDataDecoder(abi);
|
|
112
|
+
const raw = decoder.decodeData(input);
|
|
113
|
+
if (raw.method && raw.methodName) {
|
|
114
|
+
const temp = {
|
|
115
|
+
method: raw.method,
|
|
116
|
+
methodName: raw.methodName,
|
|
117
|
+
args: []
|
|
118
|
+
};
|
|
119
|
+
raw.types.forEach((type, index) => {
|
|
120
|
+
temp.args.push(parseResult(type, raw.inputs[index], raw.names[index]));
|
|
121
|
+
});
|
|
122
|
+
return temp;
|
|
123
|
+
} else {
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
};
|
|
110
127
|
const parseContractInput = async (input, contractAddress, network) => {
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
128
|
+
for (const abi of ABIs) {
|
|
129
|
+
const temp = parseInputWithAbi(input, abi);
|
|
130
|
+
if (temp) {
|
|
131
|
+
return {
|
|
132
|
+
result: temp
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
}
|
|
115
136
|
if (contractAddress && network) {
|
|
137
|
+
console.log('parseOnline');
|
|
116
138
|
if ((0, _utils._getEvmAbiExplorer)(network)) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
139
|
+
try {
|
|
140
|
+
const res = await _axios.default.get((0, _utils._getEvmAbiExplorer)(network), {
|
|
141
|
+
params: {
|
|
142
|
+
address: contractAddress
|
|
143
|
+
},
|
|
144
|
+
timeout: 3000
|
|
145
|
+
});
|
|
122
146
|
|
|
123
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
124
|
-
if (res.status === 200 && res.data.status === '1') {
|
|
125
147
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
args: []
|
|
138
|
-
};
|
|
139
|
-
raw.types.forEach((type, index) => {
|
|
140
|
-
temp.args.push(parseResult(type, raw.inputs[index], raw.names[index]));
|
|
141
|
-
});
|
|
142
|
-
result = temp;
|
|
143
|
-
break;
|
|
148
|
+
if (res.status === 200 && res.data.status === '1') {
|
|
149
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
150
|
+
const abi = res.data.result;
|
|
151
|
+
const temp = parseInputWithAbi(input, abi);
|
|
152
|
+
if (temp) {
|
|
153
|
+
return {
|
|
154
|
+
result: temp
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
} catch (e) {}
|
|
144
159
|
}
|
|
145
160
|
}
|
|
146
161
|
return {
|
|
147
|
-
result
|
|
162
|
+
result: input
|
|
148
163
|
};
|
|
149
164
|
};
|
|
150
165
|
exports.parseContractInput = parseContractInput;
|
|
@@ -187,43 +202,38 @@ const parseEvmRlp = async (data, networkMap, evmApiMap) => {
|
|
|
187
202
|
nonce: new _bignumber.default(tx.nonce).toNumber()
|
|
188
203
|
};
|
|
189
204
|
const network = getChainInfoByChainId(networkMap, parseInt(tx.ethereumChainId));
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
205
|
+
for (const abi of ABIs) {
|
|
206
|
+
const temp = parseInputWithAbi(tx.data, abi);
|
|
207
|
+
if (temp) {
|
|
208
|
+
result.data = temp;
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
}
|
|
193
212
|
if (tx.action && network) {
|
|
194
213
|
if (await isContractAddress(tx.action, evmApiMap[network.slug])) {
|
|
195
214
|
if ((0, _utils._getEvmAbiExplorer)(network) !== '') {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
215
|
+
try {
|
|
216
|
+
const res = await _axios.default.get((0, _utils._getEvmAbiExplorer)(network), {
|
|
217
|
+
params: {
|
|
218
|
+
address: tx.action
|
|
219
|
+
},
|
|
220
|
+
timeout: 2000
|
|
221
|
+
});
|
|
201
222
|
|
|
202
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
203
|
-
if (res.status === 200 && res.data.status === '1') {
|
|
204
223
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
205
|
-
|
|
206
|
-
|
|
224
|
+
if (res.status === 200 && res.data.status === '1') {
|
|
225
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
226
|
+
const abi = res.data.result;
|
|
227
|
+
const temp = parseInputWithAbi(tx.data, abi);
|
|
228
|
+
if (temp) {
|
|
229
|
+
result.data = temp;
|
|
230
|
+
return result;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
} catch (e) {}
|
|
207
234
|
}
|
|
208
235
|
}
|
|
209
236
|
}
|
|
210
|
-
for (const abi of _ABIs) {
|
|
211
|
-
const decoder = new _base.InputDataDecoder(abi);
|
|
212
|
-
const raw = decoder.decodeData(tx.data);
|
|
213
|
-
if (raw.method && raw.methodName) {
|
|
214
|
-
const temp = {
|
|
215
|
-
method: raw.method,
|
|
216
|
-
methodName: raw.methodName,
|
|
217
|
-
args: []
|
|
218
|
-
};
|
|
219
|
-
raw.types.forEach((type, index) => {
|
|
220
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
221
|
-
temp.args.push(parseResult(type, raw.inputs[index], raw.names[index]));
|
|
222
|
-
});
|
|
223
|
-
result.data = temp;
|
|
224
|
-
break;
|
|
225
|
-
}
|
|
226
|
-
}
|
|
227
237
|
return result;
|
|
228
238
|
};
|
|
229
239
|
exports.parseEvmRlp = parseEvmRlp;
|
|
@@ -12,6 +12,7 @@ import { state } from '@subwallet/extension-base/koni/background/handlers';
|
|
|
12
12
|
import { _BALANCE_CHAIN_GROUP, _PURE_EVM_CHAINS } from '@subwallet/extension-base/services/chain-service/constants';
|
|
13
13
|
import { _checkSmartContractSupportByChain, _getChainNativeTokenSlug, _getContractAddressOfToken, _getTokenOnChainAssetId, _getTokenOnChainInfo, _isChainEvmCompatible, _isPureEvmChain, _isSubstrateRelayChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
14
14
|
import { categoryAddresses, sumBN } from '@subwallet/extension-base/utils';
|
|
15
|
+
import BigN from 'bignumber.js';
|
|
15
16
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
16
17
|
// main subscription
|
|
17
18
|
export function subscribeBalance(addresses, chainInfoMap, substrateApiMap, evmApiMap, callback) {
|
|
@@ -229,7 +230,7 @@ async function subscribeEquilibriumTokenBalance(addresses, chain, api, callBack,
|
|
|
229
230
|
|
|
230
231
|
// @ts-ignore
|
|
231
232
|
const freeTokenBalance = balanceList.find(data => data[0] === parseInt(assetId));
|
|
232
|
-
const bnFreeTokenBalance = freeTokenBalance ? new BN(freeTokenBalance[1].positive.toString()) : BN_ZERO;
|
|
233
|
+
const bnFreeTokenBalance = freeTokenBalance ? new BN(new BigN(freeTokenBalance[1].positive).toString()) : BN_ZERO;
|
|
233
234
|
tokenFreeBalance = tokenFreeBalance.add(bnFreeTokenBalance);
|
|
234
235
|
}
|
|
235
236
|
const tokenBalance = {
|
|
@@ -82,7 +82,14 @@ export async function checkSupportTransfer(networkKey, tokenInfo, substrateApiMa
|
|
|
82
82
|
} else if (_TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
83
83
|
result.supportTransfer = true;
|
|
84
84
|
result.supportTransferAll = true;
|
|
85
|
+
} else if (_TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey)) {
|
|
86
|
+
result.supportTransfer = true;
|
|
87
|
+
result.supportTransferAll = true;
|
|
88
|
+
// } else if (_TRANSFER_CHAIN_GROUP.riochain.includes(networkKey) && _isNativeToken(tokenInfo)) {
|
|
89
|
+
// result.supportTransfer = true;
|
|
90
|
+
// result.supportTransferAll = true;
|
|
85
91
|
}
|
|
92
|
+
|
|
86
93
|
return result;
|
|
87
94
|
}
|
|
88
95
|
export const createTransferExtrinsic = async ({
|
|
@@ -102,6 +109,7 @@ export const createTransferExtrinsic = async ({
|
|
|
102
109
|
const isTxBalancesSupported = !!api && !!api.tx && !!api.tx.balances;
|
|
103
110
|
const isTxTokensSupported = !!api && !!api.tx && !!api.tx.tokens;
|
|
104
111
|
const isTxEqBalancesSupported = !!api && !!api.tx && !!api.tx.eqBalances;
|
|
112
|
+
const isTxAssetsSupported = !!api && !!api.tx && !!api.tx.assets;
|
|
105
113
|
let transferAmount; // for PSP-22 tokens, might be deprecated in the future
|
|
106
114
|
|
|
107
115
|
if (_isTokenWasmSmartContract(tokenInfo) && api.query.contracts) {
|
|
@@ -116,14 +124,14 @@ export const createTransferExtrinsic = async ({
|
|
|
116
124
|
transferAmount = value;
|
|
117
125
|
} else if (_TRANSFER_CHAIN_GROUP.acala.includes(networkKey) && !_isNativeToken(tokenInfo) && isTxCurrenciesSupported) {
|
|
118
126
|
transfer = api.tx.currencies.transfer(to, _getTokenOnChainInfo(tokenInfo), value);
|
|
119
|
-
} else if (_TRANSFER_CHAIN_GROUP.kintsugi.includes(networkKey) &&
|
|
127
|
+
} else if (_TRANSFER_CHAIN_GROUP.kintsugi.includes(networkKey) && isTxTokensSupported) {
|
|
120
128
|
if (transferAll) {
|
|
121
129
|
transfer = api.tx.tokens.transferAll(to, _getTokenOnChainInfo(tokenInfo) || _getTokenOnChainAssetId(tokenInfo), false);
|
|
122
130
|
} else if (value) {
|
|
123
131
|
transfer = api.tx.tokens.transfer(to, _getTokenOnChainInfo(tokenInfo) || _getTokenOnChainAssetId(tokenInfo), new BN(value));
|
|
124
132
|
}
|
|
125
|
-
} else if (_TRANSFER_CHAIN_GROUP.genshiro.includes(networkKey) &&
|
|
126
|
-
transfer = api.tx.eqBalances.transfer(
|
|
133
|
+
} else if (_TRANSFER_CHAIN_GROUP.genshiro.includes(networkKey) && isTxEqBalancesSupported) {
|
|
134
|
+
transfer = api.tx.eqBalances.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
|
|
127
135
|
} else if (!_isNativeToken(tokenInfo) && (_TRANSFER_CHAIN_GROUP.crab.includes(networkKey) || _BALANCE_TOKEN_GROUP.crab.includes(tokenInfo.symbol))) {
|
|
128
136
|
if (transferAll) {
|
|
129
137
|
transfer = api.tx.kton.transferAll(to, false);
|
|
@@ -134,6 +142,12 @@ export const createTransferExtrinsic = async ({
|
|
|
134
142
|
transfer = api.tx.currencies.transfer(to, _getTokenOnChainInfo(tokenInfo), value);
|
|
135
143
|
} else if (_TRANSFER_CHAIN_GROUP.statemine.includes(networkKey) && !_isNativeToken(tokenInfo)) {
|
|
136
144
|
transfer = api.tx.assets.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
|
|
145
|
+
// } else if (_TRANSFER_CHAIN_GROUP.riochain.includes(networkKey)) {
|
|
146
|
+
// if (_isNativeToken(tokenInfo)) {
|
|
147
|
+
// transfer = api.tx.currencies.transferNativeCurrency(to, value);
|
|
148
|
+
// }
|
|
149
|
+
} else if (_TRANSFER_CHAIN_GROUP.sora_substrate.includes(networkKey) && isTxAssetsSupported) {
|
|
150
|
+
transfer = api.tx.assets.transfer(_getTokenOnChainAssetId(tokenInfo), to, value);
|
|
137
151
|
} else if (isTxBalancesSupported && _isNativeToken(tokenInfo)) {
|
|
138
152
|
if (transferAll) {
|
|
139
153
|
transfer = api.tx.balances.transferAll(to, false);
|
|
@@ -10,9 +10,15 @@ export function getPSP22ContractPromise(apiPromise, contractAddress) {
|
|
|
10
10
|
export function getPSP34ContractPromise(apiPromise, contractAddress) {
|
|
11
11
|
return new ContractPromise(apiPromise, _PSP34_ABI, contractAddress);
|
|
12
12
|
}
|
|
13
|
+
const mustFormatNumberReg = /^-?[0-9][0-9,.]+$/;
|
|
13
14
|
export async function getPSP34TransferExtrinsic(networkKey, substrateApi, senderAddress, recipientAddress, params) {
|
|
14
15
|
const contractAddress = params.contractAddress;
|
|
15
16
|
const onChainOption = params.onChainOption;
|
|
17
|
+
for (const [key, value] of Object.entries(onChainOption)) {
|
|
18
|
+
if (mustFormatNumberReg.test(value)) {
|
|
19
|
+
onChainOption[key] = value.replaceAll(',', '');
|
|
20
|
+
}
|
|
21
|
+
}
|
|
16
22
|
try {
|
|
17
23
|
const contractPromise = getPSP34ContractPromise(substrateApi.api, contractAddress);
|
|
18
24
|
// @ts-ignore
|
|
@@ -23,6 +29,7 @@ export async function getPSP34TransferExtrinsic(networkKey, substrateApi, sender
|
|
|
23
29
|
gasLimit
|
|
24
30
|
}, recipientAddress, onChainOption, {});
|
|
25
31
|
} catch (e) {
|
|
32
|
+
console.debug(e);
|
|
26
33
|
return null;
|
|
27
34
|
}
|
|
28
35
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.0.
|
|
20
|
+
"version": "1.0.9-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -1190,6 +1190,11 @@
|
|
|
1190
1190
|
"require": "./cjs/services/history-service/index.js",
|
|
1191
1191
|
"default": "./services/history-service/index.js"
|
|
1192
1192
|
},
|
|
1193
|
+
"./services/history-service/constants": {
|
|
1194
|
+
"types": "./services/history-service/constants/index.d.ts",
|
|
1195
|
+
"require": "./cjs/services/history-service/constants/index.js",
|
|
1196
|
+
"default": "./services/history-service/constants/index.js"
|
|
1197
|
+
},
|
|
1193
1198
|
"./services/history-service/helpers/recoverHistoryStatus": {
|
|
1194
1199
|
"types": "./services/history-service/helpers/recoverHistoryStatus.d.ts",
|
|
1195
1200
|
"require": "./cjs/services/history-service/helpers/recoverHistoryStatus.js",
|
|
@@ -1702,11 +1707,11 @@
|
|
|
1702
1707
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1703
1708
|
"@subsocial/types": "^0.6.8",
|
|
1704
1709
|
"@substrate/connect": "^0.7.26",
|
|
1705
|
-
"@subwallet/chain-list": "0.1.
|
|
1706
|
-
"@subwallet/extension-base": "^1.0.
|
|
1707
|
-
"@subwallet/extension-chains": "^1.0.
|
|
1708
|
-
"@subwallet/extension-dapp": "^1.0.
|
|
1709
|
-
"@subwallet/extension-inject": "^1.0.
|
|
1710
|
+
"@subwallet/chain-list": "0.1.11-beta.1",
|
|
1711
|
+
"@subwallet/extension-base": "^1.0.9-0",
|
|
1712
|
+
"@subwallet/extension-chains": "^1.0.9-0",
|
|
1713
|
+
"@subwallet/extension-dapp": "^1.0.9-0",
|
|
1714
|
+
"@subwallet/extension-inject": "^1.0.9-0",
|
|
1710
1715
|
"@subwallet/keyring": "^0.0.10",
|
|
1711
1716
|
"@subwallet/ui-keyring": "^0.0.10",
|
|
1712
1717
|
"@unique-nft/types": "^0.6.0-4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.0.
|
|
10
|
+
version: '1.0.9-0'
|
|
11
11
|
};
|
|
@@ -22,7 +22,7 @@ export const _PURE_EVM_CHAINS = ['binance', 'binance_test', 'ethereum', 'ethereu
|
|
|
22
22
|
// Get balance----------------------------------------------------------------------------------------------------------
|
|
23
23
|
|
|
24
24
|
export const _BALANCE_CHAIN_GROUP = {
|
|
25
|
-
kintsugi: ['kintsugi', 'interlay', 'kintsugi_test'],
|
|
25
|
+
kintsugi: ['kintsugi', 'interlay', 'kintsugi_test', 'mangatax_para'],
|
|
26
26
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
27
27
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
28
28
|
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main'],
|
|
@@ -176,11 +176,13 @@ export const _KNOWN_CHAIN_INFLATION_PARAMS = {
|
|
|
176
176
|
export const _TRANSFER_NOT_SUPPORTED_CHAINS = ['subspace_gemini_3a', 'kulupu', 'joystream', 'equilibrium_parachain', 'genshiro_testnet', 'genshiro'];
|
|
177
177
|
export const _TRANSFER_CHAIN_GROUP = {
|
|
178
178
|
acala: ['karura', 'acala', 'acala_testnet'],
|
|
179
|
-
kintsugi: ['kintsugi', 'kintsugi_test', 'interlay', 'bifrost_dot', 'hydradx_main'],
|
|
179
|
+
kintsugi: ['kintsugi', 'kintsugi_test', 'interlay', 'bifrost_dot', 'hydradx_main', 'mangatax_para'],
|
|
180
180
|
genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
|
|
181
181
|
crab: ['crab', 'pangolin'],
|
|
182
|
-
bitcountry: ['pioneer', 'bitcountry'],
|
|
183
|
-
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'parallel']
|
|
182
|
+
bitcountry: ['pioneer', 'bitcountry', 'bifrost'],
|
|
183
|
+
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel'],
|
|
184
|
+
riochain: ['riochain'],
|
|
185
|
+
sora_substrate: ['sora_substrate']
|
|
184
186
|
};
|
|
185
187
|
export const _BALANCE_PARSING_CHAIN_GROUP = {
|
|
186
188
|
bobabeam: ['bobabeam', 'bobabase']
|
|
@@ -27,4 +27,4 @@ export interface ParseInputType {
|
|
|
27
27
|
export declare type TransactionBasicData = Pick<TransactionHistoryItem, 'address' | 'origin' | 'time' | 'chainType' | 'from' | 'direction' | 'blockNumber' | 'blockHash' | 'chain' | 'data'>;
|
|
28
28
|
export declare type TransactionSpecifyType = Pick<TransactionHistoryItem, 'to' | 'type' | 'status' | 'fee' | 'amount' | 'tip' | 'signature' | 'extrinsicHash'>;
|
|
29
29
|
export declare function parseSubsquidTransactionData(address: string, type: SubsquidTransactionType, historyItem: MultiHistoryData, chainInfo: _ChainInfo, args: any, data: any): TransactionHistoryItem;
|
|
30
|
-
export declare function fetchMultiChainHistories(addresses: string[], chainMap: Record<string, _ChainInfo>, maxPage?: number): Promise<TransactionHistoryItem<ExtrinsicType.TRANSFER_BALANCE>[]>;
|
|
30
|
+
export declare function fetchMultiChainHistories(addresses: string[], chainMap: Record<string, _ChainInfo>, maxPage?: number, countMap?: Record<string, number>, _lastId?: string): Promise<TransactionHistoryItem<ExtrinsicType.TRANSFER_BALANCE>[]>;
|
|
@@ -3,7 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
import { ApolloClient, createHttpLink, gql, InMemoryCache } from '@apollo/client';
|
|
5
5
|
import { ChainType, ExtrinsicStatus, ExtrinsicType, TransactionDirection } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
|
+
import { MAX_FETCH_PAGE_PER_SESSION, MIN__NUM_HISTORY_PER_ACCOUNT } from '@subwallet/extension-base/services/history-service/constants';
|
|
6
7
|
import fetch from 'cross-fetch';
|
|
8
|
+
import { isArray } from '@polkadot/util';
|
|
7
9
|
import { decodeAddress, encodeAddress, isEthereumAddress } from '@polkadot/util-crypto';
|
|
8
10
|
const MULTI_CHAIN_URL = 'https://squid.subsquid.io/multi-chain-tx/v/v1/graphql';
|
|
9
11
|
const MultiChainTxClient = new ApolloClient({
|
|
@@ -71,6 +73,17 @@ function generateSignature(input) {
|
|
|
71
73
|
const vHex = parseInt(v).toString(16);
|
|
72
74
|
return `0x${rHex}${sHex}${vHex}`;
|
|
73
75
|
}
|
|
76
|
+
const parseArgs = args => {
|
|
77
|
+
if (isArray(args)) {
|
|
78
|
+
return {
|
|
79
|
+
from: args[0],
|
|
80
|
+
to: args[1],
|
|
81
|
+
amount: args[2]
|
|
82
|
+
};
|
|
83
|
+
} else {
|
|
84
|
+
return args;
|
|
85
|
+
}
|
|
86
|
+
};
|
|
74
87
|
export function parseSubsquidTransactionData(address, type, historyItem, chainInfo, args, data) {
|
|
75
88
|
var _chainInfo$substrateI, _chainInfo$evmInfo, _chainInfo$substrateI2, _chainInfo$evmInfo2;
|
|
76
89
|
const chainType = chainInfo.substrateInfo ? ChainType.SUBSTRATE : ChainType.EVM;
|
|
@@ -91,7 +104,7 @@ export function parseSubsquidTransactionData(address, type, historyItem, chainIn
|
|
|
91
104
|
{
|
|
92
105
|
transactionType = ExtrinsicType.TRANSFER_BALANCE;
|
|
93
106
|
const extrinsic = data.extrinsic;
|
|
94
|
-
const parsedArgs = args;
|
|
107
|
+
const parsedArgs = parseArgs(args);
|
|
95
108
|
to = autoFormatAddress(parsedArgs.to);
|
|
96
109
|
from = autoFormatAddress(parsedArgs.from);
|
|
97
110
|
amount = parsedArgs.amount;
|
|
@@ -196,10 +209,10 @@ export function parseSubsquidTransactionData(address, type, historyItem, chainIn
|
|
|
196
209
|
status: success ? ExtrinsicStatus.SUCCESS : ExtrinsicStatus.FAIL
|
|
197
210
|
};
|
|
198
211
|
}
|
|
199
|
-
export async function fetchMultiChainHistories(addresses, chainMap, maxPage =
|
|
212
|
+
export async function fetchMultiChainHistories(addresses, chainMap, maxPage = MAX_FETCH_PAGE_PER_SESSION, countMap = {}, _lastId) {
|
|
200
213
|
const responseData = [];
|
|
201
214
|
let currentPage = 0;
|
|
202
|
-
let lastId;
|
|
215
|
+
let lastId = _lastId;
|
|
203
216
|
while (true) {
|
|
204
217
|
try {
|
|
205
218
|
if (maxPage) {
|
|
@@ -228,6 +241,9 @@ export async function fetchMultiChainHistories(addresses, chainMap, maxPage = 25
|
|
|
228
241
|
}
|
|
229
242
|
const histories = [];
|
|
230
243
|
const lowerAddresses = addresses.map(a => a.toLowerCase());
|
|
244
|
+
for (const lowerAddress of lowerAddresses) {
|
|
245
|
+
countMap[lowerAddress] = countMap[lowerAddress] || 0;
|
|
246
|
+
}
|
|
231
247
|
responseData.forEach(historyItem => {
|
|
232
248
|
const {
|
|
233
249
|
_data,
|
|
@@ -248,6 +264,10 @@ export async function fetchMultiChainHistories(addresses, chainMap, maxPage = 25
|
|
|
248
264
|
|
|
249
265
|
return;
|
|
250
266
|
}
|
|
267
|
+
usedAddresses.forEach(address => {
|
|
268
|
+
const adr = address.toLowerCase();
|
|
269
|
+
countMap[adr] = (countMap[adr] || 0) + 1;
|
|
270
|
+
});
|
|
251
271
|
usedAddresses.forEach(address => {
|
|
252
272
|
try {
|
|
253
273
|
const transactionData = parseSubsquidTransactionData(address, name, historyItem, chainInfo, parseData(args), parseData(_data));
|
|
@@ -257,5 +277,18 @@ export async function fetchMultiChainHistories(addresses, chainMap, maxPage = 25
|
|
|
257
277
|
}
|
|
258
278
|
});
|
|
259
279
|
});
|
|
280
|
+
if (currentPage > 1) {
|
|
281
|
+
const retryAddresses = [];
|
|
282
|
+
for (const [address, number] of Object.entries(countMap)) {
|
|
283
|
+
if (number < MIN__NUM_HISTORY_PER_ACCOUNT) {
|
|
284
|
+
retryAddresses.push(address);
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
const _addresses = addresses.filter(add => retryAddresses.includes(add.toLowerCase()));
|
|
288
|
+
if (_addresses.length > 0) {
|
|
289
|
+
const retryHistories = await fetchMultiChainHistories(_addresses, chainMap, maxPage, countMap, lastId);
|
|
290
|
+
histories.push(...retryHistories);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
260
293
|
return histories;
|
|
261
294
|
}
|
|
@@ -100,44 +100,59 @@ export const isContractAddress = async (address, evmApi) => {
|
|
|
100
100
|
return code !== '0x';
|
|
101
101
|
}
|
|
102
102
|
};
|
|
103
|
+
const parseInputWithAbi = (input, abi) => {
|
|
104
|
+
const decoder = new InputDataDecoder(abi);
|
|
105
|
+
const raw = decoder.decodeData(input);
|
|
106
|
+
if (raw.method && raw.methodName) {
|
|
107
|
+
const temp = {
|
|
108
|
+
method: raw.method,
|
|
109
|
+
methodName: raw.methodName,
|
|
110
|
+
args: []
|
|
111
|
+
};
|
|
112
|
+
raw.types.forEach((type, index) => {
|
|
113
|
+
temp.args.push(parseResult(type, raw.inputs[index], raw.names[index]));
|
|
114
|
+
});
|
|
115
|
+
return temp;
|
|
116
|
+
} else {
|
|
117
|
+
return null;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
103
120
|
export const parseContractInput = async (input, contractAddress, network) => {
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
121
|
+
for (const abi of ABIs) {
|
|
122
|
+
const temp = parseInputWithAbi(input, abi);
|
|
123
|
+
if (temp) {
|
|
124
|
+
return {
|
|
125
|
+
result: temp
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
}
|
|
108
129
|
if (contractAddress && network) {
|
|
130
|
+
console.log('parseOnline');
|
|
109
131
|
if (_getEvmAbiExplorer(network)) {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
132
|
+
try {
|
|
133
|
+
const res = await axios.get(_getEvmAbiExplorer(network), {
|
|
134
|
+
params: {
|
|
135
|
+
address: contractAddress
|
|
136
|
+
},
|
|
137
|
+
timeout: 3000
|
|
138
|
+
});
|
|
115
139
|
|
|
116
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
117
|
-
if (res.status === 200 && res.data.status === '1') {
|
|
118
140
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
args: []
|
|
131
|
-
};
|
|
132
|
-
raw.types.forEach((type, index) => {
|
|
133
|
-
temp.args.push(parseResult(type, raw.inputs[index], raw.names[index]));
|
|
134
|
-
});
|
|
135
|
-
result = temp;
|
|
136
|
-
break;
|
|
141
|
+
if (res.status === 200 && res.data.status === '1') {
|
|
142
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
143
|
+
const abi = res.data.result;
|
|
144
|
+
const temp = parseInputWithAbi(input, abi);
|
|
145
|
+
if (temp) {
|
|
146
|
+
return {
|
|
147
|
+
result: temp
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
} catch (e) {}
|
|
137
152
|
}
|
|
138
153
|
}
|
|
139
154
|
return {
|
|
140
|
-
result
|
|
155
|
+
result: input
|
|
141
156
|
};
|
|
142
157
|
};
|
|
143
158
|
const getChainInfoByChainId = (networkMap, chainId) => {
|
|
@@ -179,42 +194,37 @@ export const parseEvmRlp = async (data, networkMap, evmApiMap) => {
|
|
|
179
194
|
nonce: new BigN(tx.nonce).toNumber()
|
|
180
195
|
};
|
|
181
196
|
const network = getChainInfoByChainId(networkMap, parseInt(tx.ethereumChainId));
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
197
|
+
for (const abi of ABIs) {
|
|
198
|
+
const temp = parseInputWithAbi(tx.data, abi);
|
|
199
|
+
if (temp) {
|
|
200
|
+
result.data = temp;
|
|
201
|
+
return result;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
185
204
|
if (tx.action && network) {
|
|
186
205
|
if (await isContractAddress(tx.action, evmApiMap[network.slug])) {
|
|
187
206
|
if (_getEvmAbiExplorer(network) !== '') {
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
207
|
+
try {
|
|
208
|
+
const res = await axios.get(_getEvmAbiExplorer(network), {
|
|
209
|
+
params: {
|
|
210
|
+
address: tx.action
|
|
211
|
+
},
|
|
212
|
+
timeout: 2000
|
|
213
|
+
});
|
|
193
214
|
|
|
194
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
195
|
-
if (res.status === 200 && res.data.status === '1') {
|
|
196
215
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
197
|
-
|
|
198
|
-
|
|
216
|
+
if (res.status === 200 && res.data.status === '1') {
|
|
217
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
218
|
+
const abi = res.data.result;
|
|
219
|
+
const temp = parseInputWithAbi(tx.data, abi);
|
|
220
|
+
if (temp) {
|
|
221
|
+
result.data = temp;
|
|
222
|
+
return result;
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
} catch (e) {}
|
|
199
226
|
}
|
|
200
227
|
}
|
|
201
228
|
}
|
|
202
|
-
for (const abi of _ABIs) {
|
|
203
|
-
const decoder = new InputDataDecoder(abi);
|
|
204
|
-
const raw = decoder.decodeData(tx.data);
|
|
205
|
-
if (raw.method && raw.methodName) {
|
|
206
|
-
const temp = {
|
|
207
|
-
method: raw.method,
|
|
208
|
-
methodName: raw.methodName,
|
|
209
|
-
args: []
|
|
210
|
-
};
|
|
211
|
-
raw.types.forEach((type, index) => {
|
|
212
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
|
|
213
|
-
temp.args.push(parseResult(type, raw.inputs[index], raw.names[index]));
|
|
214
|
-
});
|
|
215
|
-
result.data = temp;
|
|
216
|
-
break;
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
229
|
return result;
|
|
220
230
|
};
|