@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
|
@@ -427,11 +427,11 @@ export default class TransactionService {
|
|
|
427
427
|
}
|
|
428
428
|
try {
|
|
429
429
|
// Return one more history record if transaction send to account in the wallets
|
|
430
|
-
const toAccount = (historyItem === null || historyItem === void 0 ? void 0 : historyItem.to) && keyring.
|
|
430
|
+
const toAccount = (historyItem === null || historyItem === void 0 ? void 0 : historyItem.to) && keyring.getPair(historyItem.to);
|
|
431
431
|
if (toAccount) {
|
|
432
432
|
return [historyItem, {
|
|
433
433
|
...historyItem,
|
|
434
|
-
address:
|
|
434
|
+
address: toAccount.address,
|
|
435
435
|
direction: TransactionDirection.RECEIVED
|
|
436
436
|
}];
|
|
437
437
|
}
|
|
@@ -456,18 +456,27 @@ export default class TransactionService {
|
|
|
456
456
|
handlePostProcessing(id) {
|
|
457
457
|
// must be done after success/failure to make sure the transaction is finalized
|
|
458
458
|
const transaction = this.getTransaction(id);
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
459
|
+
if (transaction.extrinsicType === ExtrinsicType.SEND_NFT) {
|
|
460
|
+
const inputData = parseTransactionData(transaction.data);
|
|
461
|
+
try {
|
|
462
|
+
const sender = keyring.getPair(inputData.senderAddress);
|
|
463
|
+
sender && this.databaseService.handleNftTransfer(transaction.chain, [sender.address, ALL_ACCOUNT_KEY], inputData.nftItem).then(() => {
|
|
464
|
+
this.eventService.emit('transaction.transferNft', undefined);
|
|
465
|
+
}).catch(console.error);
|
|
466
|
+
} catch (e) {
|
|
467
|
+
console.error(e);
|
|
468
|
+
}
|
|
469
|
+
try {
|
|
470
|
+
const recipient = keyring.getPair(inputData.recipientAddress);
|
|
471
|
+
recipient && this.databaseService.addNft(recipient.address, {
|
|
472
|
+
...inputData.nftItem,
|
|
473
|
+
owner: recipient.address
|
|
474
|
+
}).catch(console.error);
|
|
475
|
+
} catch (e) {
|
|
476
|
+
console.error(e);
|
|
477
|
+
}
|
|
478
|
+
} else if ([ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_POOL_WITHDRAW, ExtrinsicType.STAKING_LEAVE_POOL].includes(transaction.extrinsicType)) {
|
|
479
|
+
this.eventService.emit('transaction.submitStaking', transaction.chain);
|
|
471
480
|
}
|
|
472
481
|
}
|
|
473
482
|
onSuccess({
|
package/utils/index.d.ts
CHANGED
|
@@ -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";
|
|
@@ -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
|
}
|