@subwallet/extension-base 1.0.2-2 → 1.0.2-3
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/background/KoniTypes.d.ts +46 -38
- package/background/KoniTypes.js +8 -8
- package/background/errors/TransactionError.js +25 -1
- package/background/types.d.ts +10 -5
- package/cjs/background/KoniTypes.js +8 -8
- package/cjs/background/errors/TransactionError.js +24 -0
- package/cjs/constants/index.js +8 -26
- package/cjs/koni/api/dotsama/balance.js +49 -224
- package/cjs/koni/api/dotsama/transfer.js +34 -39
- package/cjs/koni/api/nft/acala_nft/index.js +7 -7
- package/cjs/koni/api/nft/bit.country/index.js +7 -6
- package/cjs/koni/api/nft/evm_nft/index.js +8 -3
- package/cjs/koni/api/nft/index.js +3 -6
- package/cjs/koni/api/nft/karura_nft/index.js +7 -6
- package/cjs/koni/api/nft/rmrk_nft/index.js +11 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +7 -6
- package/cjs/koni/api/nft/unique_nft/index.js +5 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +170 -111
- package/cjs/koni/api/nft/wasm_nft/utils.js +11 -7
- package/cjs/koni/api/staking/bonding/amplitude.js +13 -9
- package/cjs/koni/api/staking/bonding/astar.js +15 -13
- package/cjs/koni/api/staking/bonding/index.js +22 -10
- package/cjs/koni/api/staking/bonding/paraChain.js +85 -2
- package/cjs/koni/api/staking/bonding/relayChain.js +122 -16
- package/cjs/koni/api/staking/bonding/utils.js +27 -8
- package/cjs/koni/api/tokens/wasm/index.js +5 -4
- package/cjs/koni/api/tokens/wasm/utils.js +63 -0
- package/cjs/koni/api/xcm/polkadotXcm.js +1 -1
- package/cjs/koni/api/xcm/utils.js +18 -13
- package/cjs/koni/api/xcm/xTokens.js +1 -1
- package/cjs/koni/api/xcm/xcmPallet.js +9 -6
- package/cjs/koni/background/cron.js +171 -61
- package/cjs/koni/background/handlers/Extension.js +382 -207
- package/cjs/koni/background/handlers/State.js +41 -33
- package/cjs/koni/background/handlers/Tabs.js +50 -17
- package/cjs/koni/background/subscription.js +32 -29
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/index.js +59 -45
- package/cjs/services/event-service/index.js +5 -1
- package/cjs/services/event-service/types.js +11 -1
- package/cjs/services/history-service/index.js +19 -13
- package/cjs/services/history-service/subsquid-multi-chain-history.js +13 -10
- package/cjs/services/keyring-service/index.js +11 -13
- package/cjs/services/price-service/coingecko.js +0 -1
- package/cjs/services/price-service/index.js +2 -3
- package/cjs/services/request-service/handler/AuthRequestHandler.js +13 -7
- package/cjs/services/request-service/handler/EvmRequestHandler.js +8 -12
- package/cjs/services/request-service/index.js +14 -5
- package/cjs/services/storage-service/DatabaseService.js +56 -34
- package/cjs/services/storage-service/db-stores/Nft.js +7 -15
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +26 -15
- package/cjs/utils/address.js +10 -1
- package/cjs/utils/index.js +9 -15
- package/constants/index.d.ts +7 -13
- package/constants/index.js +7 -13
- package/koni/api/dotsama/balance.d.ts +0 -1
- package/koni/api/dotsama/balance.js +22 -197
- package/koni/api/dotsama/transfer.js +11 -16
- package/koni/api/nft/acala_nft/index.js +7 -7
- package/koni/api/nft/bit.country/index.js +7 -6
- package/koni/api/nft/evm_nft/index.js +7 -3
- package/koni/api/nft/index.d.ts +1 -2
- package/koni/api/nft/index.js +3 -6
- package/koni/api/nft/karura_nft/index.js +7 -6
- package/koni/api/nft/nft.d.ts +1 -0
- package/koni/api/nft/rmrk_nft/index.js +11 -1
- package/koni/api/nft/statemine_nft/index.js +7 -6
- package/koni/api/nft/unique_nft/index.js +5 -1
- package/koni/api/nft/wasm_nft/index.d.ts +0 -2
- package/koni/api/nft/wasm_nft/index.js +168 -109
- package/koni/api/nft/wasm_nft/utils.d.ts +7 -5
- package/koni/api/nft/wasm_nft/utils.js +7 -5
- package/koni/api/staking/bonding/amplitude.d.ts +0 -1
- package/koni/api/staking/bonding/amplitude.js +15 -10
- package/koni/api/staking/bonding/astar.js +8 -6
- package/koni/api/staking/bonding/index.d.ts +4 -1
- package/koni/api/staking/bonding/index.js +23 -13
- package/koni/api/staking/bonding/paraChain.d.ts +3 -0
- package/koni/api/staking/bonding/paraChain.js +86 -5
- package/koni/api/staking/bonding/relayChain.d.ts +5 -1
- package/koni/api/staking/bonding/relayChain.js +121 -18
- package/koni/api/staking/bonding/utils.d.ts +3 -2
- package/koni/api/staking/bonding/utils.js +27 -9
- package/koni/api/tokens/wasm/index.js +5 -4
- package/koni/api/tokens/wasm/utils.d.ts +6 -0
- package/koni/api/tokens/wasm/utils.js +54 -0
- package/koni/api/xcm/polkadotXcm.js +2 -2
- package/koni/api/xcm/utils.d.ts +5 -6
- package/koni/api/xcm/utils.js +15 -10
- package/koni/api/xcm/xTokens.js +2 -2
- package/koni/api/xcm/xcmPallet.js +10 -9
- package/koni/background/cron.d.ts +6 -1
- package/koni/background/cron.js +172 -62
- package/koni/background/handlers/Extension.d.ts +8 -3
- package/koni/background/handlers/Extension.js +297 -126
- package/koni/background/handlers/State.d.ts +5 -6
- package/koni/background/handlers/State.js +43 -33
- package/koni/background/handlers/Tabs.js +50 -17
- package/koni/background/subscription.js +31 -30
- package/package.json +18 -13
- package/packageInfo.js +1 -1
- package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
- package/services/chain-service/helper/psp22_abi.json +1041 -881
- package/services/chain-service/helper/psp34_abi.json +2963 -1807
- package/services/chain-service/index.d.ts +3 -2
- package/services/chain-service/index.js +53 -40
- package/services/chain-service/types.d.ts +1 -0
- package/services/event-service/index.js +5 -1
- package/services/event-service/types.d.ts +5 -9
- package/services/event-service/types.js +4 -1
- package/services/history-service/index.d.ts +4 -2
- package/services/history-service/index.js +19 -13
- package/services/history-service/subsquid-multi-chain-history.js +16 -12
- package/services/keyring-service/index.d.ts +4 -2
- package/services/keyring-service/index.js +11 -13
- package/services/price-service/coingecko.js +0 -1
- package/services/price-service/index.js +2 -3
- package/services/request-service/handler/AuthRequestHandler.d.ts +3 -1
- package/services/request-service/handler/AuthRequestHandler.js +13 -7
- package/services/request-service/handler/EvmRequestHandler.js +8 -12
- package/services/request-service/index.d.ts +3 -1
- package/services/request-service/index.js +14 -5
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +56 -34
- package/services/storage-service/db-stores/Nft.d.ts +2 -2
- package/services/storage-service/db-stores/Nft.js +7 -14
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.js +26 -15
- package/utils/address.d.ts +3 -0
- package/utils/address.js +8 -1
- package/utils/index.d.ts +2 -2
- package/utils/index.js +7 -13
|
@@ -4,11 +4,12 @@
|
|
|
4
4
|
import { options as acalaOptions } from '@acala-network/api';
|
|
5
5
|
import { rpc as oakRpc, types as oakTypes } from '@oak-foundation/types';
|
|
6
6
|
import { _AssetType } from '@subwallet/chain-list/types';
|
|
7
|
+
import { getDefaultWeightV2 } from '@subwallet/extension-base/koni/api/tokens/wasm/utils';
|
|
7
8
|
import { getSubstrateConnectProvider } from '@subwallet/extension-base/services/chain-service/handler/light-client';
|
|
8
9
|
import { ApiPromise, WsProvider } from '@polkadot/api';
|
|
9
10
|
import { ContractPromise } from '@polkadot/api-contract';
|
|
10
11
|
import { TypeRegistry } from '@polkadot/types/create';
|
|
11
|
-
import { formatBalance, isTestChain, objectSpread, stringify } from '@polkadot/util';
|
|
12
|
+
import { BN, formatBalance, isTestChain, objectSpread, stringify } from '@polkadot/util';
|
|
12
13
|
import { logger as createLogger } from '@polkadot/util/logger';
|
|
13
14
|
import { defaults as addressDefaults } from '@polkadot/util-crypto/address/defaults';
|
|
14
15
|
import { _API_OPTIONS_CHAIN_GROUP, API_AUTO_CONNECT_MS, API_MAX_RETRY } from "../constants.js";
|
|
@@ -87,13 +88,13 @@ export class SubstrateChainHandler {
|
|
|
87
88
|
if (tokenType === _AssetType.PSP22) {
|
|
88
89
|
tokenContract = new ContractPromise(substrateApi.api, _PSP22_ABI, contractAddress);
|
|
89
90
|
const [nameResp, symbolResp, decimalsResp] = await Promise.all([tokenContract.query['psp22Metadata::tokenName'](contractCaller || contractAddress, {
|
|
90
|
-
gasLimit:
|
|
91
|
+
gasLimit: getDefaultWeightV2(substrateApi.api)
|
|
91
92
|
}),
|
|
92
93
|
// read-only operation so no gas limit
|
|
93
94
|
tokenContract.query['psp22Metadata::tokenSymbol'](contractCaller || contractAddress, {
|
|
94
|
-
gasLimit:
|
|
95
|
+
gasLimit: getDefaultWeightV2(substrateApi.api)
|
|
95
96
|
}), tokenContract.query['psp22Metadata::tokenDecimals'](contractCaller || contractAddress, {
|
|
96
|
-
gasLimit:
|
|
97
|
+
gasLimit: getDefaultWeightV2(substrateApi.api)
|
|
97
98
|
})]);
|
|
98
99
|
if (!(nameResp.result.isOk && symbolResp.result.isOk && decimalsResp.result.isOk) || !nameResp.output || !decimalsResp.output || !symbolResp.output) {
|
|
99
100
|
this.logger.error('Error response while validating WASM contract');
|
|
@@ -104,18 +105,22 @@ export class SubstrateChainHandler {
|
|
|
104
105
|
contractError: true
|
|
105
106
|
};
|
|
106
107
|
} else {
|
|
107
|
-
var _symbolResp$output, _decimalsResp$output,
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
108
|
+
var _symbolResp$output, _decimalsResp$output, _nameResp$output;
|
|
109
|
+
const symbolObj = (_symbolResp$output = symbolResp.output) === null || _symbolResp$output === void 0 ? void 0 : _symbolResp$output.toHuman();
|
|
110
|
+
const decimalsObj = (_decimalsResp$output = decimalsResp.output) === null || _decimalsResp$output === void 0 ? void 0 : _decimalsResp$output.toHuman();
|
|
111
|
+
const nameObj = (_nameResp$output = nameResp.output) === null || _nameResp$output === void 0 ? void 0 : _nameResp$output.toHuman();
|
|
112
|
+
name = nameResp.output ? nameObj.Ok || nameObj.ok : '';
|
|
113
|
+
decimals = decimalsResp.output ? new BN(decimalsObj.Ok || decimalsObj.ok).toNumber() : 0;
|
|
114
|
+
symbol = decimalsResp.output ? symbolObj.Ok || symbolObj.ok : '';
|
|
111
115
|
if (name === '' || symbol === '') {
|
|
112
116
|
contractError = true;
|
|
113
117
|
}
|
|
118
|
+
console.log('validate PSP22', name, symbol, decimals);
|
|
114
119
|
}
|
|
115
120
|
} else {
|
|
116
121
|
tokenContract = new ContractPromise(substrateApi.api, _PSP34_ABI, contractAddress);
|
|
117
122
|
const collectionIdResp = await tokenContract.query['psp34::collectionId'](contractCaller || contractAddress, {
|
|
118
|
-
gasLimit:
|
|
123
|
+
gasLimit: getDefaultWeightV2(substrateApi.api)
|
|
119
124
|
}); // read-only operation so no gas limit
|
|
120
125
|
|
|
121
126
|
if (!collectionIdResp.result.isOk || !collectionIdResp.output) {
|