@subwallet/extension-base 1.3.71-0 → 1.3.73-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 +13 -2
- package/background/KoniTypes.js +3 -1
- package/cjs/background/KoniTypes.js +3 -1
- package/cjs/core/logic-validation/recipientAddress.js +1 -1
- package/cjs/core/logic-validation/transfer.js +33 -10
- package/cjs/core/types.js +1 -0
- package/cjs/koni/background/handlers/Extension.js +81 -10
- package/cjs/koni/background/handlers/State.js +2 -4
- package/cjs/koni/background/subscription.js +2 -22
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +46 -2
- package/cjs/services/balance-service/transfer/token.js +13 -35
- package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
- package/cjs/services/balance-service/transfer/xcm/utils.js +1 -1
- package/cjs/services/chain-service/constants.js +6 -5
- package/cjs/services/chain-service/index.js +1 -0
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +17 -2
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +55 -0
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +41 -0
- package/cjs/services/migration-service/scripts/index.js +17 -13
- package/cjs/services/substrate-proxy-service/constant.js +26 -0
- package/cjs/services/substrate-proxy-service/index.js +170 -0
- package/cjs/services/transaction-service/index.js +78 -10
- package/cjs/services/transaction-service/utils.js +8 -5
- package/cjs/types/index.js +11 -0
- package/cjs/types/substrateProxyAccount/actions/index.js +1 -0
- package/cjs/types/substrateProxyAccount/index.js +16 -0
- package/cjs/utils/account/transform.js +5 -4
- package/cjs/utils/fee/transfer.js +4 -2
- package/core/logic-validation/recipientAddress.js +1 -1
- package/core/logic-validation/transfer.d.ts +3 -3
- package/core/logic-validation/transfer.js +34 -11
- package/core/types.d.ts +2 -1
- package/core/types.js +1 -0
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +81 -10
- package/koni/background/handlers/State.d.ts +2 -1
- package/koni/background/handlers/State.js +2 -4
- package/koni/background/subscription.js +2 -22
- package/package.json +37 -7
- package/packageInfo.js +1 -1
- package/services/balance-service/helpers/subscribe/substrate/index.js +47 -3
- package/services/balance-service/transfer/token.d.ts +0 -4
- package/services/balance-service/transfer/token.js +12 -33
- package/services/balance-service/transfer/xcm/index.js +3 -8
- package/services/balance-service/transfer/xcm/utils.d.ts +0 -2
- package/services/balance-service/transfer/xcm/utils.js +1 -1
- package/services/chain-service/constants.d.ts +1 -1
- package/services/chain-service/constants.js +4 -4
- package/services/chain-service/index.js +1 -0
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/native-staking/para-chain.js +17 -2
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.d.ts +4 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251223.js +46 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.d.ts +4 -0
- package/services/migration-service/scripts/databases/MigrateAssetSetting20251223.js +33 -0
- package/services/migration-service/scripts/index.js +8 -4
- package/services/open-gov/interface.d.ts +4 -3
- package/services/substrate-proxy-service/constant.d.ts +3 -0
- package/services/substrate-proxy-service/constant.js +19 -0
- package/services/substrate-proxy-service/index.d.ts +13 -0
- package/services/substrate-proxy-service/index.js +159 -0
- package/services/transaction-service/index.js +79 -11
- package/services/transaction-service/types.d.ts +2 -2
- package/services/transaction-service/utils.js +8 -5
- package/types/balance/transfer.d.ts +1 -0
- package/types/index.d.ts +1 -0
- package/types/index.js +1 -0
- package/types/substrateProxyAccount/actions/index.d.ts +17 -0
- package/types/substrateProxyAccount/actions/index.js +1 -0
- package/types/substrateProxyAccount/index.d.ts +23 -0
- package/types/substrateProxyAccount/index.js +8 -0
- package/types/transaction/request.d.ts +1 -0
- package/types/yield/actions/join/submit.d.ts +1 -1
- package/types/yield/info/pallet.d.ts +1 -1
- package/utils/account/transform.js +5 -4
- package/utils/fee/transfer.js +4 -2
|
@@ -81,8 +81,8 @@ export declare const _TRANSFER_CHAIN_GROUP: {
|
|
|
81
81
|
centrifuge: string[];
|
|
82
82
|
disable_transfer: string[];
|
|
83
83
|
truth: string[];
|
|
84
|
-
bittensor: string[];
|
|
85
84
|
};
|
|
85
|
+
export declare const USE_MULTILOCATION_INDEX: string[];
|
|
86
86
|
export declare const _MANTA_ZK_CHAIN_GROUP: string[];
|
|
87
87
|
export declare const _ZK_ASSET_PREFIX = "zk";
|
|
88
88
|
export declare const _DEFAULT_MANTA_ZK_CHAIN = "calamari";
|
|
@@ -36,7 +36,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
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', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network', 'truth_network', 'jamton', 'hydradx_hollarnet'],
|
|
39
|
-
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub'],
|
|
39
|
+
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub', 'energy_web_x'],
|
|
40
40
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
41
41
|
// perhaps there are some runtime updates
|
|
42
42
|
centrifuge: ['centrifuge'],
|
|
@@ -289,16 +289,16 @@ export const _TRANSFER_CHAIN_GROUP = {
|
|
|
289
289
|
kintsugi: ['kintsugi', 'kintsugi_test', 'interlay', 'mangatax_para'],
|
|
290
290
|
genshiro: ['genshiro_testnet', 'genshiro', 'equilibrium_parachain'],
|
|
291
291
|
bitcountry: ['pioneer', 'bitcountry'],
|
|
292
|
-
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub'],
|
|
292
|
+
statemine: ['statemint', 'statemine', 'darwinia2', 'astar', 'shiden', 'shibuya', 'parallel', 'liberland', 'liberlandTest', 'dentnet', 'dbcchain', 'westend_assethub', 'chainflip_assethub', 'origintrail', 'xode', 'paseo_assethub', 'energy_web_x'],
|
|
293
293
|
riochain: ['riochain'],
|
|
294
294
|
sora_substrate: ['sora_substrate'],
|
|
295
295
|
avail: ['kate', 'goldberg_testnet'],
|
|
296
296
|
pendulum: ['pendulum', 'amplitude', 'amplitude_test', 'hydradx_main', 'bifrost', 'bifrost_dot', 'jamton', 'hydradx_hollarnet'],
|
|
297
297
|
centrifuge: ['centrifuge'],
|
|
298
298
|
disable_transfer: ['crab', 'pangolin'],
|
|
299
|
-
truth: ['truth_network']
|
|
300
|
-
bittensor: ['bittensor']
|
|
299
|
+
truth: ['truth_network']
|
|
301
300
|
};
|
|
301
|
+
export const USE_MULTILOCATION_INDEX = ['energy_web_x'];
|
|
302
302
|
export const _MANTA_ZK_CHAIN_GROUP = ['calamari'];
|
|
303
303
|
export const _ZK_ASSET_PREFIX = 'zk';
|
|
304
304
|
export const _DEFAULT_MANTA_ZK_CHAIN = 'calamari';
|
|
@@ -1421,6 +1421,7 @@ export class ChainService {
|
|
|
1421
1421
|
relaySlug: null,
|
|
1422
1422
|
hasNativeNft: false,
|
|
1423
1423
|
supportStaking: params.chainSpec.paraId === null,
|
|
1424
|
+
supportProxy: false,
|
|
1424
1425
|
supportSmartContract: null
|
|
1425
1426
|
};
|
|
1426
1427
|
} else if (params.chainSpec.evmChainId !== null) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { _ChainAsset, _ChainInfo, _MultiChainAsset } from '@subwallet/chain-list/types';
|
|
2
|
-
export declare const ChainListVersion = "0.2.
|
|
2
|
+
export declare const ChainListVersion = "0.2.123";
|
|
3
3
|
export interface PatchInfo {
|
|
4
4
|
patchVersion: string;
|
|
5
5
|
appliedVersion: string;
|
|
@@ -5,7 +5,7 @@ const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
|
5
5
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
6
6
|
const fetchDomain = process.env.PATCH_CHAIN_LIST_URL || (PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev');
|
|
7
7
|
const fetchFile = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'list.json' : 'preview.json';
|
|
8
|
-
export const ChainListVersion = '0.2.
|
|
8
|
+
export const ChainListVersion = '0.2.123'; // update this when build chain-list
|
|
9
9
|
|
|
10
10
|
// todo: move this interface to chainlist
|
|
11
11
|
|
|
@@ -12,6 +12,17 @@ import { balanceFormatter, formatNumber, parseRawNumber, reformatAddress } from
|
|
|
12
12
|
import BigN from 'bignumber.js';
|
|
13
13
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
14
14
|
import BaseParaNativeStakingPoolHandler from "./base-para.js";
|
|
15
|
+
async function queryDelegationScheduledRequestsFallback(api, delegator, collator) {
|
|
16
|
+
const query = api.query.parachainStaking.delegationScheduledRequests;
|
|
17
|
+
const key = await query.keys();
|
|
18
|
+
if (key[0].args.length === 1) {
|
|
19
|
+
return await query(collator);
|
|
20
|
+
} else if (key[0].args.length === 2) {
|
|
21
|
+
return await query(collator, delegator);
|
|
22
|
+
} else {
|
|
23
|
+
throw new TransactionError(BasicTxErrorType.INVALID_PARAMS, 'More args than 2 and 1');
|
|
24
|
+
}
|
|
25
|
+
}
|
|
15
26
|
function calculateMantaNominatorReturn(decimal, commission, totalActiveCollators, bnAnnualInflation, blocksPreviousRound, bnCollatorExpectedBlocksPerRound, bnCollatorTotalStaked, isCountCommission) {
|
|
16
27
|
const MIN_DELEGATION = new BigN(MANTA_MIN_DELEGATION);
|
|
17
28
|
const factor = new BigN(10).pow(decimal);
|
|
@@ -141,7 +152,10 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
141
152
|
const roundInfo = _roundInfo.toPrimitive();
|
|
142
153
|
const currentRound = roundInfo.current;
|
|
143
154
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
144
|
-
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([
|
|
155
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([queryDelegationScheduledRequestsFallback(substrateApi.api, address,
|
|
156
|
+
// delegator
|
|
157
|
+
delegation.owner // collator
|
|
158
|
+
), parseIdentity(substrateIdentityApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner), substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
|
|
145
159
|
const currentBlock = _currentBlock.toPrimitive();
|
|
146
160
|
const currentTimestamp = _currentTimestamp.toPrimitive();
|
|
147
161
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
@@ -153,7 +167,8 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
153
167
|
// parse unstaking info
|
|
154
168
|
if (delegationScheduledRequests) {
|
|
155
169
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
156
|
-
|
|
170
|
+
const requestDelegator = scheduledRequest.delegator ? scheduledRequest.delegator : address;
|
|
171
|
+
if (reformatAddress(requestDelegator, 0) === reformatAddress(address, 0)) {
|
|
157
172
|
// add network prefix
|
|
158
173
|
const isClaimable = scheduledRequest.whenExecutable - parseInt(currentRound) <= 0;
|
|
159
174
|
const remainingEra = scheduledRequest.whenExecutable - parseInt(currentRound);
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateTransactionHistoryBySymbol20251223 extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
const state = this.state;
|
|
8
|
+
try {
|
|
9
|
+
const changeSlugsMap = {
|
|
10
|
+
'gnosis-NATIVE-xDAI': 'gnosis-NATIVE-XDAI',
|
|
11
|
+
'stable-ERC20-USD₮0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736': 'stable-ERC20-USDT0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736',
|
|
12
|
+
'polygon-ERC20-USD₮0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F': 'polygon-ERC20-USDT0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
|
|
13
|
+
'ethereum-ERC20-TON-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1': 'ethereum-ERC20-TONCOIN-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1',
|
|
14
|
+
'moonbeam-ERC20-USDC.axl-0xCa01a1D0993565291051daFF390892518ACfAD3A': 'moonbeam-ERC20-axlUSDC-0xCa01a1D0993565291051daFF390892518ACfAD3A'
|
|
15
|
+
};
|
|
16
|
+
const allTxs = [];
|
|
17
|
+
await Promise.all(Object.entries(changeSlugsMap).map(async ([oldSlug, newSlug], i) => {
|
|
18
|
+
const oldSlugSplit = oldSlug.split('-');
|
|
19
|
+
const oldChainSlug = oldSlugSplit[0];
|
|
20
|
+
const oldSymbolSlug = oldSlugSplit[2];
|
|
21
|
+
const newSlugSplit = newSlug.split('-');
|
|
22
|
+
const newSymbolSlug = newSlugSplit[2];
|
|
23
|
+
const filterTransactions = await state.dbService.stores.transaction.table.where({
|
|
24
|
+
chain: oldChainSlug
|
|
25
|
+
}).and(tx => {
|
|
26
|
+
var _tx$amount;
|
|
27
|
+
return ((_tx$amount = tx.amount) === null || _tx$amount === void 0 ? void 0 : _tx$amount.symbol) === oldSymbolSlug;
|
|
28
|
+
}).toArray();
|
|
29
|
+
if (filterTransactions.length > 0) {
|
|
30
|
+
for (const transaction of filterTransactions) {
|
|
31
|
+
if (transaction.amount && transaction.amount.symbol === oldSymbolSlug) {
|
|
32
|
+
transaction.amount.symbol = newSymbolSlug;
|
|
33
|
+
}
|
|
34
|
+
if (transaction.fee && transaction.fee.symbol === oldSymbolSlug) {
|
|
35
|
+
transaction.fee.symbol = newSymbolSlug;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
allTxs.push(...filterTransactions);
|
|
40
|
+
}));
|
|
41
|
+
await state.dbService.stores.transaction.table.bulkPut(allTxs);
|
|
42
|
+
} catch (e) {
|
|
43
|
+
this.logger.error(e);
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import BaseMigrationJob from '@subwallet/extension-base/services/migration-service/Base';
|
|
5
|
+
export default class MigrateAssetSetting20251223 extends BaseMigrationJob {
|
|
6
|
+
async run() {
|
|
7
|
+
try {
|
|
8
|
+
const changeSlugsMap = {
|
|
9
|
+
'gnosis-NATIVE-xDAI': 'gnosis-NATIVE-XDAI',
|
|
10
|
+
'stable-ERC20-USD₮0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736': 'stable-ERC20-USDT0-0x779Ded0c9e1022225f8E0630b35a9b54bE713736',
|
|
11
|
+
'polygon-ERC20-USD₮0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F': 'polygon-ERC20-USDT0-0xc2132D05D31c914a87C6611C10748AEb04B58e8F',
|
|
12
|
+
'ethereum-ERC20-TON-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1': 'ethereum-ERC20-TONCOIN-0x582d872A1B094FC48F5DE31D3B73F2D9bE47def1',
|
|
13
|
+
'moonbeam-ERC20-USDC.axl-0xCa01a1D0993565291051daFF390892518ACfAD3A': 'moonbeam-ERC20-axlUSDC-0xCa01a1D0993565291051daFF390892518ACfAD3A'
|
|
14
|
+
};
|
|
15
|
+
const assetSetting = await this.state.chainService.getAssetSettings();
|
|
16
|
+
const migratedAssetSetting = {};
|
|
17
|
+
for (const [oldSlug, newSlug] of Object.entries(changeSlugsMap)) {
|
|
18
|
+
if (Object.keys(assetSetting).includes(oldSlug)) {
|
|
19
|
+
const isVisible = assetSetting[oldSlug].visible;
|
|
20
|
+
migratedAssetSetting[newSlug] = {
|
|
21
|
+
visible: isVisible
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
this.state.chainService.setAssetSettings({
|
|
26
|
+
...assetSetting,
|
|
27
|
+
...migratedAssetSetting
|
|
28
|
+
});
|
|
29
|
+
} catch (e) {
|
|
30
|
+
console.error(e);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
-
import MigrateAssetSetting20251107 from '@subwallet/extension-base/services/migration-service/scripts/databases/MigrateAssetSetting20251107';
|
|
5
|
-
import MigrateChainPatrol from '@subwallet/extension-base/services/migration-service/scripts/MigrateChainPatrol';
|
|
6
|
-
import MigrateTransactionHistoryBySymbol20251107 from '@subwallet/extension-base/services/migration-service/scripts/MigrateTransactionHistoryBySymbol20251107';
|
|
7
4
|
import ClearMetadataDatabase from "./databases/ClearMetadataDatabase.js";
|
|
8
5
|
import ClearMetadataForMythos from "./databases/ClearMetadataForMythos.js";
|
|
9
6
|
import MigrateAssetSetting from "./databases/MigrateAssetSetting.js";
|
|
10
7
|
import MigrateAssetSetting20251027 from "./databases/MigrateAssetSetting20251027.js";
|
|
8
|
+
import MigrateAssetSetting20251107 from "./databases/MigrateAssetSetting20251107.js";
|
|
9
|
+
import MigrateAssetSetting20251223 from "./databases/MigrateAssetSetting20251223.js";
|
|
11
10
|
import MigrateEarningVersion from "./databases/MigrateEarningVersion.js";
|
|
12
11
|
import ReloadMetadata from "./databases/ReloadMetadata.js";
|
|
13
12
|
import MigrateLedgerAccount from "./keyring/MigrateLedgerAccount.js";
|
|
@@ -26,6 +25,7 @@ import DeleteEarningData20251105 from "./DeleteEarningData20251105.js";
|
|
|
26
25
|
import DisableZeroBalanceTokens from "./DisableZeroBalanceTokens.js";
|
|
27
26
|
import EnableVaraChain from "./EnableVaraChain.js";
|
|
28
27
|
import MigrateAuthUrls from "./MigrateAuthUrls.js";
|
|
28
|
+
import MigrateChainPatrol from "./MigrateChainPatrol.js";
|
|
29
29
|
import MigrateImportedToken from "./MigrateImportedToken.js";
|
|
30
30
|
import MigrateNetworkSettings from "./MigrateNetworkSettings.js";
|
|
31
31
|
import MigrateNewUnifiedAccount from "./MigrateNewUnifiedAccount.js";
|
|
@@ -34,6 +34,8 @@ import MigrateTransactionHistory from "./MigrateTransactionHistory.js";
|
|
|
34
34
|
import MigrateTransactionHistoryBridge from "./MigrateTransactionHistoryBridge.js";
|
|
35
35
|
import MigrateTransactionHistoryBySymbol from "./MigrateTransactionHistoryBySymbol.js";
|
|
36
36
|
import MigrateTransactionHistoryBySymbol20251027 from "./MigrateTransactionHistoryBySymbol20251027.js";
|
|
37
|
+
import MigrateTransactionHistoryBySymbol20251107 from "./MigrateTransactionHistoryBySymbol20251107.js";
|
|
38
|
+
import MigrateTransactionHistoryBySymbol20251223 from "./MigrateTransactionHistoryBySymbol20251223.js";
|
|
37
39
|
import MigrateWalletReference from "./MigrateWalletReference.js";
|
|
38
40
|
import OptimizeEnableToken from "./OptimizeEnableToken.js";
|
|
39
41
|
export const EVERYTIME = '__everytime__';
|
|
@@ -81,5 +83,7 @@ export default {
|
|
|
81
83
|
'1.3.64-02': MigrateTransactionHistoryBySymbol20251027,
|
|
82
84
|
'1.3.65-01': DeleteEarningData20251105,
|
|
83
85
|
'1.3.66-01': MigrateAssetSetting20251107,
|
|
84
|
-
'1.3.66-02': MigrateTransactionHistoryBySymbol20251107
|
|
86
|
+
'1.3.66-02': MigrateTransactionHistoryBySymbol20251107,
|
|
87
|
+
'1.3.72-01': MigrateAssetSetting20251223,
|
|
88
|
+
'1.3.72-02': MigrateTransactionHistoryBySymbol20251223
|
|
85
89
|
};
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
import { BaseRequestSign } from '@subwallet/extension-base/types';
|
|
1
2
|
export declare enum GovVoteType {
|
|
2
3
|
AYE = "aye",
|
|
3
4
|
NAY = "nay",
|
|
4
5
|
SPLIT = "split",
|
|
5
6
|
ABSTAIN = "abstain"
|
|
6
7
|
}
|
|
7
|
-
interface BaseVoteRequest {
|
|
8
|
+
interface BaseVoteRequest extends BaseRequestSign {
|
|
8
9
|
chain: string;
|
|
9
10
|
address: string;
|
|
10
11
|
referendumIndex: string;
|
|
@@ -27,7 +28,7 @@ export interface SplitAbstainVoteRequest extends BaseVoteRequest {
|
|
|
27
28
|
nayAmount: string;
|
|
28
29
|
}
|
|
29
30
|
export declare type GovVoteRequest = StandardVoteRequest | SplitVoteRequest | SplitAbstainVoteRequest;
|
|
30
|
-
export interface RemoveVoteRequest {
|
|
31
|
+
export interface RemoveVoteRequest extends BaseRequestSign {
|
|
31
32
|
address: string;
|
|
32
33
|
chain: string;
|
|
33
34
|
trackId: number;
|
|
@@ -131,7 +132,7 @@ export interface GovDelegationDetail {
|
|
|
131
132
|
target: string;
|
|
132
133
|
conviction: Conviction;
|
|
133
134
|
}
|
|
134
|
-
export interface UnlockVoteRequest {
|
|
135
|
+
export interface UnlockVoteRequest extends BaseRequestSign {
|
|
135
136
|
address: string;
|
|
136
137
|
chain: string;
|
|
137
138
|
trackIds?: number[];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
|
+
import { SubstrateProxyType } from '@subwallet/extension-base/types/substrateProxyAccount';
|
|
3
|
+
export declare const txTypeToSubstrateProxyMap: Partial<Record<ExtrinsicType, SubstrateProxyType[]>>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
|
+
const SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS = {
|
|
6
|
+
STAKING: [ExtrinsicType.STAKING_BOND, ExtrinsicType.STAKING_UNBOND, ExtrinsicType.STAKING_WITHDRAW, ExtrinsicType.STAKING_JOIN_POOL, ExtrinsicType.STAKING_LEAVE_POOL, ExtrinsicType.CHANGE_EARNING_VALIDATOR, ExtrinsicType.STAKING_CANCEL_UNSTAKE, ExtrinsicType.STAKING_CLAIM_REWARD],
|
|
7
|
+
GOV: [ExtrinsicType.GOV_VOTE, ExtrinsicType.GOV_UNVOTE, ExtrinsicType.GOV_UNLOCK_VOTE],
|
|
8
|
+
PROXY: [
|
|
9
|
+
// only type any can add proxy
|
|
10
|
+
ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT]
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
// Map extrinsic type to possible substrate proxy types that can be used
|
|
14
|
+
// The governance proxy type will be support later
|
|
15
|
+
export const txTypeToSubstrateProxyMap = {
|
|
16
|
+
...Object.fromEntries(SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS.STAKING.map(t => [t, ['Staking', 'NonTransfer']])),
|
|
17
|
+
...Object.fromEntries(SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS.GOV.map(t => [t, ['Governance', 'NonTransfer']])),
|
|
18
|
+
...Object.fromEntries(SUBSTRATE_PROXY_ACCOUNT_EXTRINSIC_GROUPS.PROXY.map(t => [t, ['NonTransfer']]))
|
|
19
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
2
|
+
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
3
|
+
import { TransactionData } from '@subwallet/extension-base/types';
|
|
4
|
+
import { AddSubstrateProxyAccountParams, RemoveSubstrateProxyAccountParams, RequestGetSubstrateProxyAccountGroup, SubstrateProxyAccountGroup } from '@subwallet/extension-base/types/substrateProxyAccount';
|
|
5
|
+
export default class SubstrateProxyAccountService {
|
|
6
|
+
protected readonly state: KoniState;
|
|
7
|
+
constructor(state: KoniState);
|
|
8
|
+
private getSubstrateApi;
|
|
9
|
+
getSubstrateProxyAccountGroup(request: RequestGetSubstrateProxyAccountGroup): Promise<SubstrateProxyAccountGroup>;
|
|
10
|
+
addSubstrateProxyAccounts(data: AddSubstrateProxyAccountParams): Promise<TransactionData>;
|
|
11
|
+
validateAddSubstrateProxyAccount(params: AddSubstrateProxyAccountParams, signerSubstrateProxyAddress?: string): Promise<TransactionError[]>;
|
|
12
|
+
removeSubstrateProxyAccounts(data: RemoveSubstrateProxyAccountParams): Promise<TransactionData>;
|
|
13
|
+
}
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
+
|
|
4
|
+
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
|
+
import { BasicTxErrorType } from '@subwallet/extension-base/types';
|
|
6
|
+
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
7
|
+
import BigN from 'bignumber.js';
|
|
8
|
+
import { txTypeToSubstrateProxyMap } from "./constant.js";
|
|
9
|
+
export default class SubstrateProxyAccountService {
|
|
10
|
+
constructor(state) {
|
|
11
|
+
this.state = state;
|
|
12
|
+
}
|
|
13
|
+
getSubstrateApi(chain) {
|
|
14
|
+
return this.state.getSubstrateApi(chain);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Get proxied accounts for a main account
|
|
18
|
+
// Get when view details or perform transaction
|
|
19
|
+
async getSubstrateProxyAccountGroup(request) {
|
|
20
|
+
var _substrateApi$api$con, _substrateApi$api$con2;
|
|
21
|
+
const {
|
|
22
|
+
address,
|
|
23
|
+
chain,
|
|
24
|
+
excludedSubstrateProxyAccounts,
|
|
25
|
+
type
|
|
26
|
+
} = request;
|
|
27
|
+
const substrateApi = this.getSubstrateApi(chain);
|
|
28
|
+
await substrateApi.isReady;
|
|
29
|
+
|
|
30
|
+
// Get proxied accounts from on-chain data
|
|
31
|
+
const result = await substrateApi.api.query.proxy.proxies(address);
|
|
32
|
+
const baseDeposit = ((_substrateApi$api$con = substrateApi.api.consts.proxy.proxyDepositBase) === null || _substrateApi$api$con === void 0 ? void 0 : _substrateApi$api$con.toString()) || '0';
|
|
33
|
+
const factorDeposit = ((_substrateApi$api$con2 = substrateApi.api.consts.proxy.proxyDepositFactor) === null || _substrateApi$api$con2 === void 0 ? void 0 : _substrateApi$api$con2.toString()) || '0';
|
|
34
|
+
const deposit = new BigN(baseDeposit).plus(factorDeposit);
|
|
35
|
+
const [_substrateProxyAccounts, currentSubstrateProxyDeposit] = result.toPrimitive();
|
|
36
|
+
|
|
37
|
+
// Mapping on-chain data to our defined type
|
|
38
|
+
let substrateProxyAccounts = (_substrateProxyAccounts || []).map(account => {
|
|
39
|
+
const proxyId = this.state.keyringService.context.belongUnifiedAccount(account.delegate) || reformatAddress(account.delegate);
|
|
40
|
+
return {
|
|
41
|
+
substrateProxyAddress: account.delegate,
|
|
42
|
+
substrateProxyType: account.proxyType,
|
|
43
|
+
delay: account.delay,
|
|
44
|
+
proxyId
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
if (type) {
|
|
48
|
+
const allowedSet = new Set([...(txTypeToSubstrateProxyMap[type] || []), 'Any']);
|
|
49
|
+
substrateProxyAccounts = substrateProxyAccounts.filter(p => allowedSet.has(p.substrateProxyType));
|
|
50
|
+
}
|
|
51
|
+
if (excludedSubstrateProxyAccounts && excludedSubstrateProxyAccounts.length > 0) {
|
|
52
|
+
substrateProxyAccounts = substrateProxyAccounts.filter(p => {
|
|
53
|
+
return !excludedSubstrateProxyAccounts.some(excluded => excluded.address === p.substrateProxyAddress && excluded.substrateProxyType === p.substrateProxyType);
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
const estimateSubstrateProxyDeposit = new BigN(currentSubstrateProxyDeposit).plus(factorDeposit);
|
|
57
|
+
return {
|
|
58
|
+
substrateProxyAccounts,
|
|
59
|
+
substrateProxyDeposit: new BigN(currentSubstrateProxyDeposit).gt(0) ? estimateSubstrateProxyDeposit.toFixed() : deposit.toFixed()
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// Linking proxy account with main account
|
|
64
|
+
async addSubstrateProxyAccounts(data) {
|
|
65
|
+
const {
|
|
66
|
+
address,
|
|
67
|
+
chain,
|
|
68
|
+
substrateProxyAddress,
|
|
69
|
+
substrateProxyType
|
|
70
|
+
} = data;
|
|
71
|
+
if (address === substrateProxyAddress) {
|
|
72
|
+
return Promise.reject(new TransactionError(BasicTxErrorType.INVALID_PARAMS));
|
|
73
|
+
}
|
|
74
|
+
const substrateApi = this.getSubstrateApi(chain);
|
|
75
|
+
await substrateApi.isReady;
|
|
76
|
+
|
|
77
|
+
// Currently we not support delay time
|
|
78
|
+
return substrateApi.api.tx.proxy.addProxy(substrateProxyAddress, substrateProxyType, 0);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// Validate adding proxy account
|
|
82
|
+
async validateAddSubstrateProxyAccount(params, signerSubstrateProxyAddress) {
|
|
83
|
+
var _substrateApi$api$con3, _substrateApi$api$con4, _substrateApi$api$con5, _substrateApi$api$con6;
|
|
84
|
+
const {
|
|
85
|
+
address,
|
|
86
|
+
chain,
|
|
87
|
+
substrateProxyType
|
|
88
|
+
} = params;
|
|
89
|
+
const substrateApi = this.getSubstrateApi(chain);
|
|
90
|
+
await substrateApi.isReady;
|
|
91
|
+
const addProxyTx = substrateApi.api.tx.proxy.addProxy;
|
|
92
|
+
const proxyTypeArg = addProxyTx.meta.args.find(arg => arg.name.toString() === 'proxyType');
|
|
93
|
+
if (proxyTypeArg) {
|
|
94
|
+
const typeName = proxyTypeArg.type.toString();
|
|
95
|
+
const proxyTypeEnum = substrateApi.api.registry.createType(typeName);
|
|
96
|
+
const variants = proxyTypeEnum.defKeys;
|
|
97
|
+
if (!variants.includes(substrateProxyType)) {
|
|
98
|
+
return [new TransactionError(BasicTxErrorType.UNSUPPORTED, 'This proxy type is not supported on the chosen network. Select another one and try again')];
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
if (!substrateApi.api.tx.proxy || !substrateApi.api.tx.proxy.addProxy) {
|
|
102
|
+
return [new TransactionError(BasicTxErrorType.UNSUPPORTED)];
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
// Validate max proxies accounts limit
|
|
106
|
+
const maxSubstrateProxies = ((_substrateApi$api$con3 = substrateApi.api.consts.proxy.maxProxies) === null || _substrateApi$api$con3 === void 0 ? void 0 : (_substrateApi$api$con4 = _substrateApi$api$con3.toNumber) === null || _substrateApi$api$con4 === void 0 ? void 0 : _substrateApi$api$con4.call(_substrateApi$api$con3)) || 0;
|
|
107
|
+
const currentProxiesRaw = await substrateApi.api.query.proxy.proxies(address);
|
|
108
|
+
const [proxyList] = currentProxiesRaw.toPrimitive();
|
|
109
|
+
if (proxyList.length >= maxSubstrateProxies) {
|
|
110
|
+
return [new TransactionError(BasicTxErrorType.INVALID_PARAMS, `Maximum number of proxies reached: ${maxSubstrateProxies}`)];
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Ensure enough balance for deposit + fee
|
|
114
|
+
const transferableBalance = await this.state.balanceService.getTransferableBalance(address, chain);
|
|
115
|
+
const bnTransferableBalance = new BigN(transferableBalance.value);
|
|
116
|
+
const feeInfo = await substrateApi.api.tx.proxy.addProxy(params.substrateProxyAddress, params.substrateProxyType, 0).paymentInfo(address);
|
|
117
|
+
const estimatedFee = new BigN(feeInfo.partialFee.toString());
|
|
118
|
+
const baseDeposit = ((_substrateApi$api$con5 = substrateApi.api.consts.proxy.proxyDepositBase) === null || _substrateApi$api$con5 === void 0 ? void 0 : _substrateApi$api$con5.toString()) || '0';
|
|
119
|
+
const factorDeposit = ((_substrateApi$api$con6 = substrateApi.api.consts.proxy.proxyDepositFactor) === null || _substrateApi$api$con6 === void 0 ? void 0 : _substrateApi$api$con6.toString()) || '0';
|
|
120
|
+
const requiredDeposit = proxyList.length === 0 ? new BigN(baseDeposit).plus(factorDeposit) : new BigN(factorDeposit);
|
|
121
|
+
const totalRequired = new BigN(requiredDeposit).plus(!signerSubstrateProxyAddress ? estimatedFee : 0);
|
|
122
|
+
if (bnTransferableBalance.lt(totalRequired)) {
|
|
123
|
+
return [new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE)];
|
|
124
|
+
}
|
|
125
|
+
return [];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
// Removing linked proxy accounts from main account
|
|
129
|
+
async removeSubstrateProxyAccounts(data) {
|
|
130
|
+
const {
|
|
131
|
+
chain,
|
|
132
|
+
isRemoveAll,
|
|
133
|
+
selectedSubstrateProxyAccounts
|
|
134
|
+
} = data;
|
|
135
|
+
const substrateApi = this.getSubstrateApi(chain);
|
|
136
|
+
await substrateApi.isReady;
|
|
137
|
+
const api = substrateApi.api;
|
|
138
|
+
if (isRemoveAll) {
|
|
139
|
+
return api.tx.proxy.removeProxies();
|
|
140
|
+
}
|
|
141
|
+
if (!selectedSubstrateProxyAccounts.length) {
|
|
142
|
+
return Promise.reject(new TransactionError(BasicTxErrorType.INVALID_PARAMS));
|
|
143
|
+
}
|
|
144
|
+
if (selectedSubstrateProxyAccounts.length === 1) {
|
|
145
|
+
const {
|
|
146
|
+
delay,
|
|
147
|
+
substrateProxyAddress,
|
|
148
|
+
substrateProxyType
|
|
149
|
+
} = selectedSubstrateProxyAccounts[0];
|
|
150
|
+
return api.tx.proxy.removeProxy(substrateProxyAddress, substrateProxyType, delay);
|
|
151
|
+
}
|
|
152
|
+
const removeProxies = selectedSubstrateProxyAccounts.map(({
|
|
153
|
+
delay,
|
|
154
|
+
substrateProxyAddress,
|
|
155
|
+
substrateProxyType
|
|
156
|
+
}) => api.tx.proxy.removeProxy(substrateProxyAddress, substrateProxyType, delay));
|
|
157
|
+
return api.tx.utility.batchAll(removeProxies);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
@@ -15,7 +15,7 @@ import { getBaseTransactionInfo, getTransactionId, isBitcoinTransaction, isCarda
|
|
|
15
15
|
import { getExplorerLink, parseTransactionData } from '@subwallet/extension-base/services/transaction-service/utils';
|
|
16
16
|
import { isWalletConnectRequest } from '@subwallet/extension-base/services/wallet-connect-service/helpers';
|
|
17
17
|
import { BasicTxErrorType, StepStatus, YieldPoolType } from '@subwallet/extension-base/types';
|
|
18
|
-
import { anyNumberToBN, pairToAccount, reformatAddress } from '@subwallet/extension-base/utils';
|
|
18
|
+
import { anyNumberToBN, isSameAddress, pairToAccount, reformatAddress } from '@subwallet/extension-base/utils';
|
|
19
19
|
import { mergeTransactionAndSignature } from '@subwallet/extension-base/utils/eth/mergeTransactionAndSignature';
|
|
20
20
|
import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
21
21
|
import { getId } from '@subwallet/extension-base/utils/getId';
|
|
@@ -120,18 +120,26 @@ export default class TransactionService {
|
|
|
120
120
|
const isNonNativeTokenPayFee = tokenPayFeeSlug && !_isNativeTokenBySlug(tokenPayFeeSlug);
|
|
121
121
|
const nonNativeTokenPayFeeInfo = isNonNativeTokenPayFee ? this.state.chainService.getAssetBySlug(tokenPayFeeSlug) : undefined;
|
|
122
122
|
const priceMap = (await this.state.priceService.getPrice()).priceMap;
|
|
123
|
+
|
|
124
|
+
// Get signer account
|
|
125
|
+
let signer = address;
|
|
126
|
+
const signerSubstrateProxyAddress = transactionInput.signerSubstrateProxyAddress;
|
|
123
127
|
if (!transactionInput.skipFeeRecalculation) {
|
|
124
|
-
validationResponse.estimateFee = await estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, transactionInput.isTransferLocalTokenAndPayThatTokenAsFee);
|
|
128
|
+
validationResponse.estimateFee = await estimateFeeForTransaction(validationResponse, transaction, chainInfo, evmApi, substrateApi, priceMap, feeInfo, nativeTokenInfo, nonNativeTokenPayFeeInfo, transactionInput.isTransferLocalTokenAndPayThatTokenAsFee, signerSubstrateProxyAddress);
|
|
125
129
|
}
|
|
126
130
|
const chainInfoMap = this.state.chainService.getChainInfoMap();
|
|
131
|
+
let substrateProxyAccountNativeTokenAvailable;
|
|
132
|
+
if (signerSubstrateProxyAddress && !isSameAddress(signerSubstrateProxyAddress, address)) {
|
|
133
|
+
signer = signerSubstrateProxyAddress;
|
|
134
|
+
substrateProxyAccountNativeTokenAvailable = await this.state.balanceService.getTransferableBalance(signerSubstrateProxyAddress, chain, nativeTokenInfo.slug, extrinsicType);
|
|
135
|
+
}
|
|
127
136
|
|
|
128
137
|
// Check account signing transaction
|
|
129
|
-
|
|
130
|
-
checkSigningAccountForTransaction(validationResponse, chainInfoMap);
|
|
138
|
+
checkSigningAccountForTransaction(validationResponse, chainInfoMap, signer);
|
|
131
139
|
const nativeTokenAvailable = await this.state.balanceService.getBalanceByType(address, chain, nativeTokenInfo.slug, transactionInput.balanceType, extrinsicType);
|
|
132
140
|
|
|
133
141
|
// Check available balance against transaction fee
|
|
134
|
-
checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable);
|
|
142
|
+
checkBalanceWithTransactionFee(validationResponse, transactionInput, nativeTokenInfo, nativeTokenAvailable, substrateProxyAccountNativeTokenAvailable);
|
|
135
143
|
|
|
136
144
|
// Warnings Ton address if bounceable and not active
|
|
137
145
|
// if (transaction && isTonTransaction(transaction) && tonApi) {
|
|
@@ -746,8 +754,10 @@ export default class TransactionService {
|
|
|
746
754
|
// Will be added in next step
|
|
747
755
|
nonce: nonce !== null && nonce !== void 0 ? nonce : 0,
|
|
748
756
|
startBlock: startBlock || 0,
|
|
749
|
-
processId: (_transaction$step3 = transaction.step) === null || _transaction$step3 === void 0 ? void 0 : _transaction$step3.processId
|
|
757
|
+
processId: (_transaction$step3 = transaction.step) === null || _transaction$step3 === void 0 ? void 0 : _transaction$step3.processId,
|
|
758
|
+
substrateProxyAddresses: []
|
|
750
759
|
};
|
|
760
|
+
const substrateProxyHistories = [];
|
|
751
761
|
const nativeAsset = _getChainNativeTokenBasicInfo(chainInfo);
|
|
752
762
|
const baseNativeAmount = {
|
|
753
763
|
value: '0',
|
|
@@ -1114,6 +1124,55 @@ export default class TransactionService {
|
|
|
1114
1124
|
};
|
|
1115
1125
|
break;
|
|
1116
1126
|
}
|
|
1127
|
+
case ExtrinsicType.ADD_SUBSTRATE_PROXY_ACCOUNT:
|
|
1128
|
+
{
|
|
1129
|
+
const data = parseTransactionData(transaction.data);
|
|
1130
|
+
const substrateProxyAddress = data.substrateProxyAddress;
|
|
1131
|
+
historyItem.substrateProxyAddresses = [substrateProxyAddress];
|
|
1132
|
+
substrateProxyHistories.push({
|
|
1133
|
+
...historyItem,
|
|
1134
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1135
|
+
});
|
|
1136
|
+
try {
|
|
1137
|
+
const substrateProxyAccount = keyring.getPair(substrateProxyAddress);
|
|
1138
|
+
if (substrateProxyAccount) {
|
|
1139
|
+
substrateProxyHistories.push({
|
|
1140
|
+
...historyItem,
|
|
1141
|
+
address: substrateProxyAccount.address,
|
|
1142
|
+
direction: TransactionDirection.RECEIVED,
|
|
1143
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
} catch (e) {
|
|
1147
|
+
// skip
|
|
1148
|
+
}
|
|
1149
|
+
break;
|
|
1150
|
+
}
|
|
1151
|
+
case ExtrinsicType.REMOVE_SUBSTRATE_PROXY_ACCOUNT:
|
|
1152
|
+
{
|
|
1153
|
+
const data = parseTransactionData(transaction.data);
|
|
1154
|
+
for (const substrateProxyItem of data.selectedSubstrateProxyAccounts || []) {
|
|
1155
|
+
const substrateProxyAddress = substrateProxyItem.substrateProxyAddress;
|
|
1156
|
+
substrateProxyHistories.push({
|
|
1157
|
+
...historyItem,
|
|
1158
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1159
|
+
});
|
|
1160
|
+
try {
|
|
1161
|
+
const substrateProxyAccount = keyring.getPair(substrateProxyAddress);
|
|
1162
|
+
if (substrateProxyAccount) {
|
|
1163
|
+
substrateProxyHistories.push({
|
|
1164
|
+
...historyItem,
|
|
1165
|
+
address: substrateProxyAccount.address,
|
|
1166
|
+
direction: TransactionDirection.RECEIVED,
|
|
1167
|
+
substrateProxyAddresses: [substrateProxyAddress]
|
|
1168
|
+
});
|
|
1169
|
+
}
|
|
1170
|
+
} catch (e) {
|
|
1171
|
+
// skip
|
|
1172
|
+
}
|
|
1173
|
+
}
|
|
1174
|
+
break;
|
|
1175
|
+
}
|
|
1117
1176
|
case ExtrinsicType.UNKNOWN:
|
|
1118
1177
|
break;
|
|
1119
1178
|
}
|
|
@@ -1141,7 +1200,7 @@ export default class TransactionService {
|
|
|
1141
1200
|
} catch (e) {
|
|
1142
1201
|
console.warn(e);
|
|
1143
1202
|
}
|
|
1144
|
-
return [historyItem];
|
|
1203
|
+
return [historyItem, ...substrateProxyHistories];
|
|
1145
1204
|
}
|
|
1146
1205
|
onSigned({
|
|
1147
1206
|
id
|
|
@@ -1721,12 +1780,13 @@ export default class TransactionService {
|
|
|
1721
1780
|
});
|
|
1722
1781
|
return emitter;
|
|
1723
1782
|
}
|
|
1724
|
-
signAndSendSubstrateTransaction({
|
|
1783
|
+
async signAndSendSubstrateTransaction({
|
|
1725
1784
|
address,
|
|
1726
1785
|
chain,
|
|
1727
1786
|
feeCustom,
|
|
1728
1787
|
id,
|
|
1729
1788
|
signAfterCreate,
|
|
1789
|
+
signerSubstrateProxyAddress,
|
|
1730
1790
|
step,
|
|
1731
1791
|
tokenPayFeeSlug,
|
|
1732
1792
|
transaction,
|
|
@@ -1743,7 +1803,15 @@ export default class TransactionService {
|
|
|
1743
1803
|
extrinsicHash: id,
|
|
1744
1804
|
processId: step === null || step === void 0 ? void 0 : step.processId
|
|
1745
1805
|
};
|
|
1746
|
-
|
|
1806
|
+
let extrinsic = transaction;
|
|
1807
|
+
let signer = address;
|
|
1808
|
+
if (signerSubstrateProxyAddress && signerSubstrateProxyAddress !== address) {
|
|
1809
|
+
const substrateApi = this.state.chainService.getSubstrateApi(chain);
|
|
1810
|
+
await substrateApi.isReady;
|
|
1811
|
+
signer = signerSubstrateProxyAddress;
|
|
1812
|
+
extrinsic = substrateApi.api.tx.proxy.proxy(address, null, transaction);
|
|
1813
|
+
}
|
|
1814
|
+
|
|
1747
1815
|
// const registry = extrinsic.registry;
|
|
1748
1816
|
// const signedExtensions = registry.signedExtensions;
|
|
1749
1817
|
|
|
@@ -1753,7 +1821,7 @@ export default class TransactionService {
|
|
|
1753
1821
|
const {
|
|
1754
1822
|
signature,
|
|
1755
1823
|
signedTransaction
|
|
1756
|
-
} = await this.state.requestService.signInternalTransaction(id,
|
|
1824
|
+
} = await this.state.requestService.signInternalTransaction(id, signer, url || EXTENSION_REQUEST_URL, payload, signAfterCreate);
|
|
1757
1825
|
return {
|
|
1758
1826
|
id: new Date().getTime(),
|
|
1759
1827
|
signature,
|
|
@@ -1775,7 +1843,7 @@ export default class TransactionService {
|
|
|
1775
1843
|
// }
|
|
1776
1844
|
// }
|
|
1777
1845
|
|
|
1778
|
-
extrinsic.signAsync(
|
|
1846
|
+
extrinsic.signAsync(signer, signerOption).then(async rs => {
|
|
1779
1847
|
// Emit signed event
|
|
1780
1848
|
emitter.emit('signed', eventData);
|
|
1781
1849
|
|