@subwallet/extension-base 1.0.2-1 → 1.0.2-1b
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 +16 -34
- package/background/KoniTypes.js +6 -7
- package/background/errors/TransactionError.js +21 -1
- package/cjs/background/KoniTypes.js +6 -7
- package/cjs/background/errors/TransactionError.js +20 -0
- package/cjs/constants/index.js +8 -26
- package/cjs/koni/api/dotsama/balance.js +49 -224
- package/cjs/koni/api/dotsama/transfer.js +30 -29
- package/cjs/koni/api/nft/acala_nft/index.js +4 -1
- package/cjs/koni/api/nft/bit.country/index.js +4 -1
- package/cjs/koni/api/nft/evm_nft/index.js +7 -3
- package/cjs/koni/api/nft/index.js +3 -6
- package/cjs/koni/api/nft/karura_nft/index.js +4 -1
- package/cjs/koni/api/nft/rmrk_nft/index.js +8 -1
- package/cjs/koni/api/nft/statemine_nft/index.js +4 -1
- package/cjs/koni/api/nft/unique_nft/index.js +6 -1
- package/cjs/koni/api/nft/wasm_nft/index.js +169 -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 +119 -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 +150 -47
- package/cjs/koni/background/handlers/Extension.js +106 -64
- package/cjs/koni/background/handlers/State.js +19 -21
- package/cjs/koni/background/handlers/Tabs.js +8 -1
- package/cjs/koni/background/subscription.js +32 -29
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/handler/light-client/index.js +2 -0
- package/cjs/services/chain-service/index.js +6 -7
- 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 +16 -10
- package/cjs/services/history-service/subsquid-multi-chain-history.js +12 -9
- 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 +6 -2
- package/cjs/services/storage-service/DatabaseService.js +52 -33
- package/cjs/services/storage-service/db-stores/Nft.js +4 -17
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +23 -14
- package/cjs/utils/index.js +7 -14
- 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 +5 -4
- package/koni/api/nft/acala_nft/index.js +3 -1
- package/koni/api/nft/bit.country/index.js +3 -1
- package/koni/api/nft/evm_nft/index.js +6 -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 +3 -1
- package/koni/api/nft/nft.d.ts +1 -0
- package/koni/api/nft/rmrk_nft/index.js +8 -1
- package/koni/api/nft/statemine_nft/index.js +3 -1
- 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 +167 -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 +118 -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 +151 -48
- package/koni/background/handlers/Extension.d.ts +2 -2
- package/koni/background/handlers/Extension.js +108 -67
- package/koni/background/handlers/State.d.ts +5 -6
- package/koni/background/handlers/State.js +19 -21
- package/koni/background/handlers/Tabs.js +8 -1
- package/koni/background/subscription.js +31 -30
- package/package.json +9 -4
- package/services/chain-service/handler/SubstrateChainHandler.js +14 -9
- package/services/chain-service/handler/light-client/index.d.ts +17 -1
- package/services/chain-service/handler/light-client/index.js +1 -1
- 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.js +6 -7
- 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 +1 -1
- package/services/history-service/index.js +16 -10
- package/services/history-service/subsquid-multi-chain-history.js +15 -11
- package/services/price-service/coingecko.js +0 -1
- package/services/price-service/index.js +2 -3
- package/services/request-service/handler/AuthRequestHandler.js +6 -2
- package/services/storage-service/DatabaseService.d.ts +1 -0
- package/services/storage-service/DatabaseService.js +52 -33
- package/services/storage-service/db-stores/Nft.d.ts +1 -2
- package/services/storage-service/db-stores/Nft.js +4 -16
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.js +23 -14
- package/utils/index.d.ts +1 -1
- package/utils/index.js +6 -12
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.0.2-
|
|
20
|
+
"version": "1.0.2-1b",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -369,6 +369,11 @@
|
|
|
369
369
|
"require": "./cjs/koni/api/tokens/wasm/index.js",
|
|
370
370
|
"default": "./koni/api/tokens/wasm/index.js"
|
|
371
371
|
},
|
|
372
|
+
"./koni/api/tokens/wasm/utils": {
|
|
373
|
+
"types": "./koni/api/tokens/wasm/utils.d.ts",
|
|
374
|
+
"require": "./cjs/koni/api/tokens/wasm/utils.js",
|
|
375
|
+
"default": "./koni/api/tokens/wasm/utils.js"
|
|
376
|
+
},
|
|
372
377
|
"./koni/api/xcm": {
|
|
373
378
|
"types": "./koni/api/xcm/index.d.ts",
|
|
374
379
|
"require": "./cjs/koni/api/xcm/index.js",
|
|
@@ -1651,12 +1656,12 @@
|
|
|
1651
1656
|
"@sora-substrate/type-definitions": "^1.12.4",
|
|
1652
1657
|
"@subsocial/types": "^0.6.8",
|
|
1653
1658
|
"@substrate/connect": "^0.7.18",
|
|
1654
|
-
"@subwallet/chain-list": "^0.0.
|
|
1659
|
+
"@subwallet/chain-list": "^0.0.30",
|
|
1655
1660
|
"@subwallet/extension-base": "^1.0.2-1",
|
|
1656
1661
|
"@subwallet/extension-chains": "^1.0.2-1",
|
|
1657
1662
|
"@subwallet/extension-dapp": "^1.0.2-1",
|
|
1658
1663
|
"@subwallet/extension-inject": "^1.0.2-1",
|
|
1659
|
-
"@subwallet/keyring": "^0.0.
|
|
1664
|
+
"@subwallet/keyring": "^0.0.5",
|
|
1660
1665
|
"@subwallet/ui-keyring": "^0.0.3",
|
|
1661
1666
|
"@unique-nft/types": "^0.6.0-4",
|
|
1662
1667
|
"@zeitgeistpm/type-defs": "^0.10.0",
|
|
@@ -1693,4 +1698,4 @@
|
|
|
1693
1698
|
"web3-eth-contract": "^1.8.1",
|
|
1694
1699
|
"web3-utils": "^1.8.1"
|
|
1695
1700
|
}
|
|
1696
|
-
}
|
|
1701
|
+
}
|
|
@@ -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) {
|
|
@@ -1,4 +1,20 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ScProvider } from '@polkadot/rpc-provider';
|
|
2
|
+
import { ProviderInterface, ProviderInterfaceCallback, ProviderInterfaceEmitCb, ProviderInterfaceEmitted } from '@polkadot/rpc-provider/types';
|
|
2
3
|
export declare const relayChainSpecs: Record<string, string>;
|
|
3
4
|
export declare const paraChainSpecs: Record<string, string>;
|
|
5
|
+
export declare class ProviderPlaceholder implements ProviderInterface {
|
|
6
|
+
private readonly providerPromise;
|
|
7
|
+
private provider?;
|
|
8
|
+
constructor(providerPromise: Promise<ScProvider>);
|
|
9
|
+
get hasSubscriptions(): boolean;
|
|
10
|
+
get isClonable(): boolean;
|
|
11
|
+
get isConnected(): boolean;
|
|
12
|
+
clone(): ProviderInterface;
|
|
13
|
+
connect(): Promise<void>;
|
|
14
|
+
disconnect(): Promise<void>;
|
|
15
|
+
on(type: ProviderInterfaceEmitted, sub: ProviderInterfaceEmitCb): () => void;
|
|
16
|
+
send<T = any>(method: string, params: unknown[], isCacheable?: boolean): Promise<T>;
|
|
17
|
+
subscribe(type: string, method: string, params: unknown[], cb: ProviderInterfaceCallback): Promise<number | string>;
|
|
18
|
+
unsubscribe(type: string, method: string, id: number | string): Promise<boolean>;
|
|
19
|
+
}
|
|
4
20
|
export declare function getSubstrateConnectProvider(specLink: string): ProviderInterface;
|
|
@@ -16,7 +16,7 @@ export const paraChainSpecs = {
|
|
|
16
16
|
'kusama/tinkernet': `${sourceFolderUrl}kusama/tinkernet.json`,
|
|
17
17
|
'polkadot/astar': `${sourceFolderUrl}polkadot/astar.json`
|
|
18
18
|
};
|
|
19
|
-
class ProviderPlaceholder {
|
|
19
|
+
export class ProviderPlaceholder {
|
|
20
20
|
constructor(providerPromise) {
|
|
21
21
|
this.providerPromise = providerPromise;
|
|
22
22
|
providerPromise.then(provider => {
|