@subwallet/extension-base 1.0.2-2 → 1.0.3-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/background/KoniTypes.d.ts +56 -40
- package/background/KoniTypes.js +11 -9
- package/background/errors/TransactionError.js +25 -1
- package/background/types.d.ts +10 -5
- package/cjs/background/KoniTypes.js +11 -9
- 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 +391 -207
- package/cjs/koni/background/handlers/State.js +49 -34
- package/cjs/koni/background/handlers/Tabs.js +50 -17
- package/cjs/koni/background/subscription.js +53 -28
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/base/types.js +20 -0
- package/cjs/services/chain-service/handler/SubstrateChainHandler.js +13 -8
- package/cjs/services/chain-service/index.js +73 -49
- 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 +101 -50
- package/cjs/services/history-service/subsquid-multi-chain-history.js +13 -10
- package/cjs/services/keyring-service/index.js +11 -13
- package/cjs/services/migration-service/scripts/MigrateImportedToken.js +2 -1
- package/cjs/services/price-service/coingecko.js +0 -1
- package/cjs/services/price-service/index.js +71 -24
- 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 +66 -34
- package/cjs/services/storage-service/db-stores/Nft.js +7 -15
- package/cjs/services/storage-service/db-stores/Transaction.js +6 -10
- package/cjs/services/transaction-service/event-parser/index.js +20 -48
- package/cjs/services/transaction-service/index.js +104 -48
- package/cjs/services/transaction-service/utils.js +10 -8
- package/cjs/utils/address.js +10 -1
- package/cjs/utils/index.js +9 -15
- package/cjs/utils/promise.js +26 -0
- 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 +9 -3
- package/koni/background/handlers/Extension.js +306 -126
- package/koni/background/handlers/State.d.ts +5 -6
- package/koni/background/handlers/State.js +51 -34
- package/koni/background/handlers/Tabs.js +50 -17
- package/koni/background/subscription.d.ts +2 -0
- package/koni/background/subscription.js +51 -29
- package/package.json +29 -14
- package/packageInfo.js +1 -1
- package/services/base/types.d.ts +34 -0
- package/services/base/types.js +15 -0
- 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 +5 -2
- package/services/chain-service/index.js +68 -45
- 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 +28 -7
- package/services/history-service/index.js +101 -50
- 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/migration-service/scripts/MigrateImportedToken.js +2 -1
- package/services/price-service/coingecko.js +0 -1
- package/services/price-service/index.d.ts +22 -1
- package/services/price-service/index.js +71 -24
- 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 +2 -0
- package/services/storage-service/DatabaseService.js +66 -34
- package/services/storage-service/db-stores/Nft.d.ts +2 -2
- package/services/storage-service/db-stores/Nft.js +7 -14
- package/services/storage-service/db-stores/Transaction.d.ts +2 -0
- package/services/storage-service/db-stores/Transaction.js +6 -10
- package/services/transaction-service/event-parser/index.js +21 -49
- package/services/transaction-service/index.d.ts +2 -0
- package/services/transaction-service/index.js +86 -32
- package/services/transaction-service/types.d.ts +2 -0
- package/services/transaction-service/utils.js +10 -8
- 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
- package/utils/promise.d.ts +6 -0
- package/utils/promise.js +20 -0
|
@@ -9,15 +9,17 @@ export function parseTransactionData(data) {
|
|
|
9
9
|
return data;
|
|
10
10
|
}
|
|
11
11
|
export function getTransactionLink(chainInfo, extrinsicHash) {
|
|
12
|
-
|
|
13
|
-
if (_isPureEvmChain(chainInfo)) {
|
|
14
|
-
if (explorerLink) {
|
|
15
|
-
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}tx/${extrinsicHash}`;
|
|
16
|
-
}
|
|
17
|
-
} else {
|
|
12
|
+
if (extrinsicHash.startsWith('0x')) {
|
|
18
13
|
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
19
|
-
if (
|
|
20
|
-
|
|
14
|
+
if (_isPureEvmChain(chainInfo)) {
|
|
15
|
+
if (explorerLink) {
|
|
16
|
+
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}tx/${extrinsicHash}`;
|
|
17
|
+
}
|
|
18
|
+
} else {
|
|
19
|
+
const explorerLink = _getBlockExplorerFromChain(chainInfo);
|
|
20
|
+
if (explorerLink) {
|
|
21
|
+
return `${explorerLink}${explorerLink.endsWith('/') ? '' : '/'}extrinsic/${extrinsicHash}`;
|
|
22
|
+
}
|
|
21
23
|
}
|
|
22
24
|
}
|
|
23
25
|
return undefined;
|
package/utils/address.d.ts
CHANGED
|
@@ -1,2 +1,5 @@
|
|
|
1
|
+
import { AddressJson } from '@subwallet/extension-base/background/types';
|
|
2
|
+
import { SubjectInfo } from '@subwallet/ui-keyring/observable/types';
|
|
1
3
|
export declare const simpleAddress: (address: string) => string;
|
|
2
4
|
export declare function quickFormatAddressToCompare(address?: string): string | undefined;
|
|
5
|
+
export declare const convertSubjectInfoToAddresses: (subjectInfo: SubjectInfo) => AddressJson[];
|
package/utils/address.js
CHANGED
|
@@ -14,4 +14,11 @@ export function quickFormatAddressToCompare(address) {
|
|
|
14
14
|
return address;
|
|
15
15
|
}
|
|
16
16
|
return reformatAddress(address, 42).toLowerCase();
|
|
17
|
-
}
|
|
17
|
+
}
|
|
18
|
+
export const convertSubjectInfoToAddresses = subjectInfo => {
|
|
19
|
+
return Object.values(subjectInfo).map(info => ({
|
|
20
|
+
address: info.json.address,
|
|
21
|
+
type: info.type,
|
|
22
|
+
...info.json.meta
|
|
23
|
+
}));
|
|
24
|
+
};
|
package/utils/index.d.ts
CHANGED
|
@@ -8,7 +8,7 @@ export declare const isDef: (x: any) => boolean;
|
|
|
8
8
|
export declare const nonEmptyArr: (x: any) => boolean;
|
|
9
9
|
export declare const isEmptyArray: (x: any) => boolean;
|
|
10
10
|
export declare function isAccountAll(address?: string): boolean;
|
|
11
|
-
export declare function reformatAddress(address: string, networkPrefix
|
|
11
|
+
export declare function reformatAddress(address: string, networkPrefix?: number, isEthereum?: boolean): string;
|
|
12
12
|
export declare function filterAddressByNetworkKey(addresses: string[], networkKey: string, isEthereum?: boolean): string[];
|
|
13
13
|
export declare function categoryAddresses(addresses: string[]): string[][];
|
|
14
14
|
export declare function categoryNetworks(networks: NetworkJson[]): string[][];
|
|
@@ -34,6 +34,6 @@ export declare function mergeNetworkProviders(customNetwork: NetworkJson, predef
|
|
|
34
34
|
};
|
|
35
35
|
export declare const filterAndSortingAccountByAuthType: (accounts: AccountJson[], accountAuthType: AccountAuthType, sorting?: boolean) => AccountJson[];
|
|
36
36
|
export declare function parseRawNumber(value: string): number;
|
|
37
|
-
export declare function parseNumberToDisplay(amount: BN, decimals: number | undefined): string;
|
|
38
37
|
export declare function isSameAddress(address1: string, address2: string): boolean;
|
|
39
38
|
export declare function getDomainFromUrl(url: string): string;
|
|
39
|
+
export declare function waitTimeout(ms: number): Promise<void>;
|
package/utils/index.js
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
import { CrowdloanParaState } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
6
|
-
import BigNumber from 'bignumber.js';
|
|
7
6
|
import { BN, hexToU8a, isHex } from '@polkadot/util';
|
|
8
7
|
import { decodeAddress, encodeAddress, ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
9
8
|
export { canDerive } from "./canDerive.js";
|
|
@@ -14,7 +13,7 @@ export const isEmptyArray = x => !Array.isArray(x) || Array.isArray(x) && x.leng
|
|
|
14
13
|
export function isAccountAll(address) {
|
|
15
14
|
return address === ALL_ACCOUNT_KEY;
|
|
16
15
|
}
|
|
17
|
-
export function reformatAddress(address, networkPrefix, isEthereum = false) {
|
|
16
|
+
export function reformatAddress(address, networkPrefix = 42, isEthereum = false) {
|
|
18
17
|
try {
|
|
19
18
|
if (isEthereumAddress(address)) {
|
|
20
19
|
return address;
|
|
@@ -264,21 +263,16 @@ export const filterAndSortingAccountByAuthType = (accounts, accountAuthType, sor
|
|
|
264
263
|
export function parseRawNumber(value) {
|
|
265
264
|
return parseFloat(value.replaceAll(',', ''));
|
|
266
265
|
}
|
|
267
|
-
export function parseNumberToDisplay(amount, decimals) {
|
|
268
|
-
if (!decimals) {
|
|
269
|
-
return '0';
|
|
270
|
-
}
|
|
271
|
-
const parsedAmount = parseRawNumber(amount.toString());
|
|
272
|
-
const bigN = new BigNumber(parsedAmount / 10 ** decimals);
|
|
273
|
-
const roundedString = bigN.toFixed(9);
|
|
274
|
-
const formattedString = parseFloat(roundedString); // remove excess zeros at the end
|
|
275
|
-
|
|
276
|
-
return formattedString.toString();
|
|
277
|
-
}
|
|
278
266
|
export function isSameAddress(address1, address2) {
|
|
267
|
+
if (isEthereumAddress(address1)) {
|
|
268
|
+
return address1.toLowerCase() === address2.toLowerCase();
|
|
269
|
+
}
|
|
279
270
|
return reformatAddress(address1, 0) === reformatAddress(address2, 0); // TODO: maybe there's a better way
|
|
280
271
|
}
|
|
281
272
|
|
|
282
273
|
export function getDomainFromUrl(url) {
|
|
283
274
|
return url.replace(/^(https?:\/\/)?(www\.)?/, '').split('/')[0];
|
|
275
|
+
}
|
|
276
|
+
export async function waitTimeout(ms) {
|
|
277
|
+
return new Promise(resolve => setTimeout(resolve, ms));
|
|
284
278
|
}
|
package/utils/promise.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
export function createPromiseHandler() {
|
|
5
|
+
let _resolve = () => {
|
|
6
|
+
console.warn('This promise handler is not implemented');
|
|
7
|
+
};
|
|
8
|
+
let _reject = () => {
|
|
9
|
+
console.warn('This promise handler is not implemented');
|
|
10
|
+
};
|
|
11
|
+
const promise = new Promise((resolve, reject) => {
|
|
12
|
+
_resolve = resolve;
|
|
13
|
+
_reject = reject;
|
|
14
|
+
});
|
|
15
|
+
return {
|
|
16
|
+
resolve: _resolve,
|
|
17
|
+
reject: _reject,
|
|
18
|
+
promise
|
|
19
|
+
};
|
|
20
|
+
}
|