@subwallet/extension-base 1.3.70-2 → 1.3.72-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 +68 -9
- package/cjs/background/KoniTypes.js +68 -9
- package/cjs/constants/blocked-actions.js +3 -0
- package/cjs/core/logic-validation/recipientAddress.js +1 -1
- package/cjs/core/logic-validation/swap.js +0 -3
- package/cjs/core/logic-validation/transfer.js +33 -10
- package/cjs/core/substrate/system-pallet.js +0 -2
- package/cjs/core/types.js +1 -0
- package/cjs/koni/api/nft/wasm_nft/index.js +0 -1
- package/cjs/koni/api/staking/bonding/astar.js +0 -2
- package/cjs/koni/api/staking/bonding/paraChain.js +0 -3
- package/cjs/koni/api/staking/bonding/relayChain.js +2 -4
- package/cjs/koni/api/staking/bonding/utils.js +0 -4
- package/cjs/koni/background/cron.js +0 -1
- package/cjs/koni/background/handlers/Extension.js +235 -166
- package/cjs/koni/background/handlers/State.js +56 -52
- package/cjs/koni/background/handlers/Tabs.js +39 -34
- package/cjs/packageInfo.js +1 -1
- package/cjs/page/index.js +7 -0
- package/cjs/page/substrate/PostMessageProvider.js +3 -0
- package/cjs/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/cjs/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/cjs/services/balance-service/helpers/subscribe/substrate/index.js +48 -5
- package/cjs/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/cjs/services/balance-service/index.js +103 -7
- package/cjs/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/cardano-transfer.js +1 -2
- package/cjs/services/balance-service/transfer/smart-contract.js +0 -1
- package/cjs/services/balance-service/transfer/token.js +13 -37
- package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/index.js +3 -8
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- 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/handler/CardanoApi.js +3 -1
- package/cjs/services/chain-service/handler/SubstrateApi.js +0 -2
- package/cjs/services/chain-service/handler/light-client/index.js +1 -2
- package/cjs/services/chain-service/health-check/index.js +0 -1
- package/cjs/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/cjs/services/chain-service/index.js +19 -26
- package/cjs/services/chain-service/utils/index.js +21 -25
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/handlers/base.js +32 -0
- package/cjs/services/earning-service/handlers/lending/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/cjs/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/cjs/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/dtao.js +43 -2
- package/cjs/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/cjs/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/cjs/services/earning-service/handlers/special.js +7 -0
- package/cjs/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/cjs/services/keyring-service/context/handlers/Derive.js +1 -1
- package/cjs/services/keyring-service/context/handlers/Migration.js +11 -9
- package/cjs/services/keyring-service/context/handlers/Mnemonic.js +18 -13
- package/cjs/services/keyring-service/context/state.js +21 -3
- package/cjs/services/keyring-service/utils.js +12 -2
- package/cjs/services/migration-service/index.js +1 -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/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/cjs/services/nft-service/index.js +5 -0
- package/cjs/services/open-gov/handler.js +0 -2
- package/cjs/services/open-gov/interface.js +4 -1
- package/cjs/services/request-service/handler/BitcoinRequestHandler.js +1 -2
- package/cjs/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/cjs/services/request-service/handler/TonRequestHandler.js +0 -1
- package/cjs/services/request-service/helper/index.js +1 -2
- package/cjs/services/storage-service/DatabaseService.js +0 -2
- package/cjs/services/storage-service/databases/index.js +2 -0
- package/cjs/services/substrate-proxy-service/constant.js +26 -0
- package/cjs/services/substrate-proxy-service/index.js +170 -0
- package/cjs/services/swap-service/handler/asset-hub/handler.js +0 -1
- package/cjs/services/swap-service/handler/asset-hub/router.js +0 -1
- package/cjs/services/swap-service/handler/chainflip-handler.js +1 -4
- package/cjs/services/swap-service/handler/hydradx-handler.js +0 -1
- package/cjs/services/swap-service/handler/kyber-handler.js +0 -1
- package/cjs/services/swap-service/handler/optimex-handler.js +1 -2
- package/cjs/services/swap-service/handler/simpleswap-handler.js +1 -3
- package/cjs/services/swap-service/handler/uniswap-handler.js +0 -3
- package/cjs/services/transaction-service/event-parser/index.js +6 -6
- package/cjs/services/transaction-service/index.js +105 -37
- package/cjs/services/transaction-service/utils.js +8 -5
- package/cjs/services/wallet-connect-service/index.js +21 -18
- package/cjs/services/wallet-connect-service/types.js +1 -1
- package/cjs/types/account/info/keyring.js +9 -1
- package/cjs/types/balance/index.js +5 -1
- 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/types/swap/index.js +2 -1
- package/cjs/types/transaction/process.js +2 -0
- package/cjs/types/yield/actions/join/step.js +17 -1
- package/cjs/utils/account/common.js +0 -26
- package/cjs/utils/account/derive/info/solo.js +7 -4
- package/cjs/utils/account/derive/validate.js +1 -1
- package/cjs/utils/account/transform.js +10 -5
- package/cjs/utils/auth.js +1 -1
- package/cjs/utils/bitcoin/utxo-management.js +0 -1
- package/cjs/utils/environment.js +2 -1
- package/cjs/utils/fee/transfer.js +5 -4
- package/cjs/utils/index.js +1 -2
- package/constants/blocked-actions.js +3 -0
- package/core/logic-validation/recipientAddress.js +1 -1
- package/core/logic-validation/swap.js +0 -3
- package/core/logic-validation/transfer.d.ts +3 -3
- package/core/logic-validation/transfer.js +34 -11
- package/core/substrate/system-pallet.js +0 -2
- package/core/types.d.ts +2 -1
- package/core/types.js +1 -0
- package/koni/api/nft/wasm_nft/index.js +0 -1
- package/koni/api/staking/bonding/astar.js +0 -2
- package/koni/api/staking/bonding/paraChain.js +0 -3
- package/koni/api/staking/bonding/relayChain.js +2 -4
- package/koni/api/staking/bonding/utils.js +0 -4
- package/koni/background/cron.js +0 -1
- package/koni/background/handlers/Extension.d.ts +3 -0
- package/koni/background/handlers/Extension.js +89 -19
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +43 -38
- package/koni/background/handlers/Tabs.js +9 -3
- package/package.json +50 -21
- package/packageInfo.js +1 -1
- package/page/substrate/PostMessageProvider.js +3 -0
- package/services/balance-service/helpers/subscribe/cardano/utils.js +0 -1
- package/services/balance-service/helpers/subscribe/substrate/gear.js +0 -2
- package/services/balance-service/helpers/subscribe/substrate/index.js +47 -4
- package/services/balance-service/helpers/subscribe/ton/utils.js +0 -3
- package/services/balance-service/index.d.ts +8 -0
- package/services/balance-service/index.js +105 -9
- package/services/balance-service/transfer/bitcoin-transfer.js +0 -1
- package/services/balance-service/transfer/smart-contract.js +0 -1
- package/services/balance-service/transfer/token.d.ts +0 -4
- package/services/balance-service/transfer/token.js +12 -35
- package/services/balance-service/transfer/ton-transfer.js +0 -1
- package/services/balance-service/transfer/xcm/index.js +3 -8
- package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- 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/handler/CardanoApi.js +3 -1
- package/services/chain-service/handler/SubstrateApi.js +0 -2
- package/services/chain-service/health-check/index.js +0 -1
- package/services/chain-service/health-check/utils/new-utils/chain-asset-validate.js +0 -1
- package/services/chain-service/index.d.ts +0 -1
- package/services/chain-service/index.js +16 -23
- package/services/chain-service/utils/index.js +22 -26
- package/services/chain-service/utils/patch.d.ts +1 -1
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/handlers/base.js +32 -0
- package/services/earning-service/handlers/lending/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/acala.js +0 -1
- package/services/earning-service/handlers/liquid-staking/base.js +0 -2
- package/services/earning-service/handlers/liquid-staking/bifrost.js +0 -2
- package/services/earning-service/handlers/liquid-staking/parallel.js +0 -1
- package/services/earning-service/handlers/native-staking/astar.js +0 -2
- package/services/earning-service/handlers/native-staking/dtao.js +43 -0
- package/services/earning-service/handlers/native-staking/energy.js +0 -1
- package/services/earning-service/handlers/native-staking/mythos.js +0 -2
- package/services/earning-service/handlers/native-staking/para-chain.js +0 -2
- package/services/earning-service/handlers/native-staking/relay-chain.js +8 -9
- package/services/earning-service/handlers/special.js +7 -0
- package/services/history-service/subsquid-multi-chain-history.js +0 -1
- package/services/keyring-service/context/handlers/Derive.js +2 -2
- package/services/keyring-service/context/handlers/Migration.js +3 -1
- package/services/keyring-service/context/handlers/Mnemonic.d.ts +1 -1
- package/services/keyring-service/context/handlers/Mnemonic.js +16 -10
- package/services/keyring-service/context/state.d.ts +3 -0
- package/services/keyring-service/context/state.js +21 -3
- package/services/keyring-service/utils.d.ts +1 -0
- package/services/keyring-service/utils.js +9 -0
- 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/mint-campaign-service/campaigns/UnlockDotCampaign.js +0 -1
- package/services/nft-service/index.js +6 -0
- package/services/open-gov/handler.js +0 -2
- package/services/open-gov/interface.d.ts +4 -3
- package/services/open-gov/interface.js +4 -1
- package/services/request-service/handler/CardanoRequestHandler.js +0 -1
- package/services/request-service/handler/EvmRequestHandler.js +0 -1
- package/services/request-service/handler/TonRequestHandler.js +0 -1
- package/services/setting-service/constants.js +0 -1
- package/services/storage-service/DatabaseService.js +0 -2
- package/services/storage-service/databases/index.js +3 -0
- 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/swap-service/handler/asset-hub/handler.js +0 -1
- package/services/swap-service/handler/asset-hub/router.js +0 -1
- package/services/swap-service/handler/chainflip-handler.js +0 -2
- package/services/swap-service/handler/hydradx-handler.js +0 -1
- package/services/swap-service/handler/kyber-handler.js +0 -1
- package/services/swap-service/handler/simpleswap-handler.js +0 -1
- package/services/swap-service/handler/uniswap-handler.js +0 -3
- package/services/transaction-service/event-parser/index.js +6 -6
- 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/services/wallet-connect-service/index.js +21 -18
- package/services/wallet-connect-service/types.js +1 -1
- package/types/account/action/add/mnemonic.d.ts +3 -2
- package/types/account/info/keyring.js +9 -1
- package/types/balance/index.js +5 -1
- 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/swap/index.js +2 -1
- package/types/transaction/process.js +3 -1
- package/types/transaction/request.d.ts +1 -0
- package/types/yield/actions/join/step.js +17 -1
- package/types/yield/actions/join/submit.d.ts +1 -1
- package/utils/account/common.d.ts +0 -3
- package/utils/account/common.js +0 -24
- package/utils/account/derive/info/solo.js +8 -5
- package/utils/account/derive/validate.d.ts +2 -2
- package/utils/account/derive/validate.js +1 -1
- package/utils/account/transform.js +10 -5
- package/utils/auth.js +2 -2
- package/utils/bitcoin/utxo-management.js +0 -1
- package/utils/fee/transfer.js +4 -2
- package/utils/index.js +2 -5
|
@@ -134,9 +134,9 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
134
134
|
/* Subscribe pool position */
|
|
135
135
|
|
|
136
136
|
async parseNominatorMetadata(chainInfo, address, substrateApi, ledger, currentEra, minStake) {
|
|
137
|
-
var _substrateApi$api$que7, _substrateApi$api$que8, _substrateApi$api$que9, _substrateApi$api$
|
|
137
|
+
var _substrateApi$api$que7, _substrateApi$api$que8, _substrateApi$api$que9, _substrateApi$api$que0, _substrateApi$api$que1, _substrateApi$api$que10;
|
|
138
138
|
const chain = chainInfo.slug;
|
|
139
|
-
const [_nominations, _bonded, _activeEra] = await Promise.all([(_substrateApi$api$que7 = substrateApi.api.query) === null || _substrateApi$api$que7 === void 0 ? void 0 : (_substrateApi$api$que8 = _substrateApi$api$que7.staking) === null || _substrateApi$api$que8 === void 0 ? void 0 : _substrateApi$api$que8.nominators(address), (_substrateApi$api$que9 = substrateApi.api.query) === null || _substrateApi$api$que9 === void 0 ? void 0 : (_substrateApi$api$
|
|
139
|
+
const [_nominations, _bonded, _activeEra] = await Promise.all([(_substrateApi$api$que7 = substrateApi.api.query) === null || _substrateApi$api$que7 === void 0 ? void 0 : (_substrateApi$api$que8 = _substrateApi$api$que7.staking) === null || _substrateApi$api$que8 === void 0 ? void 0 : _substrateApi$api$que8.nominators(address), (_substrateApi$api$que9 = substrateApi.api.query) === null || _substrateApi$api$que9 === void 0 ? void 0 : (_substrateApi$api$que0 = _substrateApi$api$que9.staking) === null || _substrateApi$api$que0 === void 0 ? void 0 : _substrateApi$api$que0.bonded(address), (_substrateApi$api$que1 = substrateApi.api.query) === null || _substrateApi$api$que1 === void 0 ? void 0 : (_substrateApi$api$que10 = _substrateApi$api$que1.staking) === null || _substrateApi$api$que10 === void 0 ? void 0 : _substrateApi$api$que10.activeEra()]);
|
|
140
140
|
const unlimitedNominatorRewarded = substrateApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
141
141
|
const _maxNominatorRewardedPerValidator = (substrateApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
142
142
|
const maxNominatorRewardedPerValidator = unlimitedNominatorRewarded ? undefined : parseInt(_maxNominatorRewardedPerValidator);
|
|
@@ -236,23 +236,22 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
236
236
|
activeStake: '0' // relaychain allocates stake accordingly
|
|
237
237
|
});
|
|
238
238
|
}));
|
|
239
|
-
|
|
240
239
|
return nominationList;
|
|
241
240
|
}
|
|
242
241
|
async subscribePoolPosition(useAddresses, resultCallback) {
|
|
243
|
-
var _substrateApi$api$
|
|
242
|
+
var _substrateApi$api$que11;
|
|
244
243
|
let cancel = false;
|
|
245
244
|
const substrateApi = await this.substrateApi.isReady;
|
|
246
245
|
const defaultInfo = this.baseInfo;
|
|
247
246
|
const chainInfo = this.chainInfo;
|
|
248
|
-
const unsub = await ((_substrateApi$api$
|
|
247
|
+
const unsub = await ((_substrateApi$api$que11 = substrateApi.api.query.staking) === null || _substrateApi$api$que11 === void 0 ? void 0 : _substrateApi$api$que11.ledger.multi(useAddresses, async ledgers => {
|
|
249
248
|
if (cancel) {
|
|
250
249
|
unsub === null || unsub === void 0 ? void 0 : unsub();
|
|
251
250
|
return;
|
|
252
251
|
}
|
|
253
252
|
if (ledgers) {
|
|
254
|
-
var _substrateApi$api$
|
|
255
|
-
const [_currentEra, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_substrateApi$api$
|
|
253
|
+
var _substrateApi$api$que12, _substrateApi$api$que13, _substrateApi$api$que14, _substrateApi$api$que15, _substrateApi$api$que16, _substrateApi$api$que17, _substrateApi$api$que18, _substrateApi$api$que19, _substrateApi$api$der, _substrateApi$api$der2;
|
|
254
|
+
const [_currentEra, _minimumActiveStake, _minNominatorBond] = await Promise.all([(_substrateApi$api$que12 = substrateApi.api.query) === null || _substrateApi$api$que12 === void 0 ? void 0 : (_substrateApi$api$que13 = _substrateApi$api$que12.staking) === null || _substrateApi$api$que13 === void 0 ? void 0 : _substrateApi$api$que13.currentEra(), ((_substrateApi$api$que14 = substrateApi.api.query) === null || _substrateApi$api$que14 === void 0 ? void 0 : (_substrateApi$api$que15 = _substrateApi$api$que14.staking) === null || _substrateApi$api$que15 === void 0 ? void 0 : _substrateApi$api$que15.minimumActiveStake) && ((_substrateApi$api$que16 = substrateApi.api.query) === null || _substrateApi$api$que16 === void 0 ? void 0 : (_substrateApi$api$que17 = _substrateApi$api$que16.staking) === null || _substrateApi$api$que17 === void 0 ? void 0 : _substrateApi$api$que17.minimumActiveStake()), (_substrateApi$api$que18 = substrateApi.api.query) === null || _substrateApi$api$que18 === void 0 ? void 0 : (_substrateApi$api$que19 = _substrateApi$api$que18.staking) === null || _substrateApi$api$que19 === void 0 ? void 0 : _substrateApi$api$que19.minNominatorBond(), (_substrateApi$api$der = substrateApi.api.derive) === null || _substrateApi$api$der === void 0 ? void 0 : (_substrateApi$api$der2 = _substrateApi$api$der.session) === null || _substrateApi$api$der2 === void 0 ? void 0 : _substrateApi$api$der2.progress()]);
|
|
256
255
|
const currentEra = _currentEra.toString();
|
|
257
256
|
const minActiveStake = (_minimumActiveStake === null || _minimumActiveStake === void 0 ? void 0 : _minimumActiveStake.toString()) || '0';
|
|
258
257
|
const minNominatorBond = _minNominatorBond.toString();
|
|
@@ -294,10 +293,10 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
294
293
|
};
|
|
295
294
|
}
|
|
296
295
|
async checkAccountHaveStake(useAddresses) {
|
|
297
|
-
var _substrateApi$api$
|
|
296
|
+
var _substrateApi$api$que20, _substrateApi$api$que21, _substrateApi$api$que22;
|
|
298
297
|
const result = [];
|
|
299
298
|
const substrateApi = await this.substrateApi.isReady;
|
|
300
|
-
const ledgers = await ((_substrateApi$api$
|
|
299
|
+
const ledgers = await ((_substrateApi$api$que20 = substrateApi.api.query.staking) === null || _substrateApi$api$que20 === void 0 ? void 0 : (_substrateApi$api$que21 = _substrateApi$api$que20.ledger) === null || _substrateApi$api$que21 === void 0 ? void 0 : (_substrateApi$api$que22 = _substrateApi$api$que21.multi) === null || _substrateApi$api$que22 === void 0 ? void 0 : _substrateApi$api$que22.call(_substrateApi$api$que21, useAddresses));
|
|
301
300
|
if (ledgers) {
|
|
302
301
|
for (let i = 0; i < useAddresses.length; i++) {
|
|
303
302
|
const address = useAddresses[i];
|
|
@@ -274,6 +274,13 @@ export default class BaseSpecialStakingPoolHandler extends BasePoolHandler {
|
|
|
274
274
|
* @return Fee of the submitting step
|
|
275
275
|
* */
|
|
276
276
|
|
|
277
|
+
/**
|
|
278
|
+
* @async
|
|
279
|
+
* @function getSubmitStepFee
|
|
280
|
+
* @description Get submit step fee
|
|
281
|
+
* @return {Promise<YieldTokenBaseInfo>} Fee of the submitting step
|
|
282
|
+
* */
|
|
283
|
+
|
|
277
284
|
async getSubmitStep(params) {
|
|
278
285
|
const fee = await this.getSubmitStepFee(params);
|
|
279
286
|
return [this.submitJoinStepInfo, fee];
|
|
@@ -38,7 +38,6 @@ export let SubsquidTransactionType;
|
|
|
38
38
|
const HISTORY_SUPPORT_TYPES = [SubsquidTransactionType.BalanceTransfer, SubsquidTransactionType.EthereumExecuted, SubsquidTransactionType.StakingBonded
|
|
39
39
|
// SubsquidTransactionType.CrowdloanContributed // Not support because data indexer not enough data
|
|
40
40
|
];
|
|
41
|
-
|
|
42
41
|
function parseData(anyData) {
|
|
43
42
|
try {
|
|
44
43
|
return JSON.parse(anyData);
|
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
import { ALL_ACCOUNT_KEY } from '@subwallet/extension-base/constants';
|
|
5
5
|
import { CommonAccountErrorType, DeriveErrorType, SWCommonAccountError, SWDeriveError } from '@subwallet/extension-base/types';
|
|
6
6
|
import { createAccountProxyId, derivePair, findSoloNextDerive, findUnifiedNextDerive, getSoloDerivationInfo, parseUnifiedSuriToDerivationPath, validateDerivationPath } from '@subwallet/extension-base/utils';
|
|
7
|
-
import { BitcoinKeypairTypes,
|
|
7
|
+
import { BitcoinKeypairTypes, DefaultSubstrateKeypairTypes, EthereumKeypairTypes } from '@subwallet/keyring/types';
|
|
8
8
|
import { keyring } from '@subwallet/ui-keyring';
|
|
9
9
|
import { t } from 'i18next';
|
|
10
10
|
import { assert } from '@polkadot/util';
|
|
11
11
|
import { AccountBaseHandler } from "./Base.js";
|
|
12
|
-
const validDeriveKeypairTypes = [...
|
|
12
|
+
const validDeriveKeypairTypes = [...DefaultSubstrateKeypairTypes, ...EthereumKeypairTypes, 'ton', 'cardano', ...BitcoinKeypairTypes];
|
|
13
13
|
|
|
14
14
|
/**
|
|
15
15
|
* @class AccountDeriveHandler
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { AccountBaseHandler } from '@subwallet/extension-base/services/keyring-service/context/handlers/Base';
|
|
5
|
+
import { isTWAccount } from '@subwallet/extension-base/services/keyring-service/utils';
|
|
5
6
|
import { AccountChainType, SUPPORTED_ACCOUNT_CHAIN_TYPES } from '@subwallet/extension-base/types';
|
|
6
7
|
import { createAccountProxyId, getDefaultKeypairTypeFromAccountChainType, getSuri } from '@subwallet/extension-base/utils';
|
|
7
8
|
import { generateRandomString } from '@subwallet/extension-base/utils/getId';
|
|
@@ -26,7 +27,8 @@ export class AccountMigrationHandler extends AccountBaseHandler {
|
|
|
26
27
|
async migrateUnifiedAndFetchEligibleSoloAccounts(request, setMigratingModeFn) {
|
|
27
28
|
// Migrate unified -> unified
|
|
28
29
|
const password = request.password;
|
|
29
|
-
const
|
|
30
|
+
const _allAccountProxies = Object.values(this.state.accounts);
|
|
31
|
+
const allAccountProxies = _allAccountProxies.filter(acc => !isTWAccount(acc)); // Prevent migrate TrustWallet solo account
|
|
30
32
|
const UACanBeMigrated = this.getUACanBeMigrated(allAccountProxies);
|
|
31
33
|
const UACanBeMigratedSortedByParent = this.sortUAByParent(UACanBeMigrated); // master account must be migrated before derived account
|
|
32
34
|
const migratedUnifiedAccountIds = await this.migrateUnifiedToUnifiedAccount(password, UACanBeMigratedSortedByParent, setMigratingModeFn);
|
|
@@ -9,7 +9,7 @@ export declare const SEED_LENGTHS: number[];
|
|
|
9
9
|
* */
|
|
10
10
|
export declare class AccountMnemonicHandler extends AccountBaseHandler {
|
|
11
11
|
mnemonicCreateV2({ length, mnemonic: _seed, type }: RequestMnemonicCreateV2): Promise<ResponseMnemonicCreateV2>;
|
|
12
|
-
mnemonicValidateV2(
|
|
12
|
+
mnemonicValidateV2(request: RequestMnemonicValidateV2): ResponseMnemonicValidateV2;
|
|
13
13
|
accountsCreateSuriV2(request: RequestAccountCreateSuriV2): ResponseAccountCreateSuriV2;
|
|
14
14
|
exportAccountProxyMnemonic({ password, proxyId }: RequestExportAccountProxyMnemonic): ResponseExportAccountProxyMnemonic;
|
|
15
15
|
}
|
|
@@ -41,9 +41,11 @@ export class AccountMnemonicHandler extends AccountBaseHandler {
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
/* Validate seed */
|
|
44
|
-
mnemonicValidateV2({
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
mnemonicValidateV2(request) {
|
|
45
|
+
const {
|
|
46
|
+
mnemonic,
|
|
47
|
+
mnemonicType
|
|
48
|
+
} = request;
|
|
47
49
|
const {
|
|
48
50
|
phrase
|
|
49
51
|
} = keyExtractSuri(mnemonic);
|
|
@@ -60,8 +62,13 @@ export class AccountMnemonicHandler extends AccountBaseHandler {
|
|
|
60
62
|
}));
|
|
61
63
|
try {
|
|
62
64
|
assert(mnemonicValidate(phrase), t('bg.ACCOUNT.services.keyring.handler.Mnemonic.invalidSeedPhraseTryAgain'));
|
|
63
|
-
|
|
64
|
-
|
|
65
|
+
if (mnemonicType === 'trust-wallet') {
|
|
66
|
+
mnemonicTypes = 'trust-wallet';
|
|
67
|
+
pairTypes = ['ed25519-tw'];
|
|
68
|
+
} else {
|
|
69
|
+
mnemonicTypes = 'general';
|
|
70
|
+
pairTypes = ['sr25519', ...EthereumKeypairTypes, 'ton', ...CardanoKeypairTypes, ...BitcoinKeypairTypes];
|
|
71
|
+
}
|
|
65
72
|
} catch (e) {
|
|
66
73
|
assert(tonMnemonicValidate(phrase), t('bg.ACCOUNT.services.keyring.handler.Mnemonic.invalidSeedPhraseTryAgain'));
|
|
67
74
|
mnemonicTypes = 'ton';
|
|
@@ -77,10 +84,10 @@ export class AccountMnemonicHandler extends AccountBaseHandler {
|
|
|
77
84
|
pairTypes.forEach(type => {
|
|
78
85
|
rs.addressMap[type] = keyring.createFromUri(getSuri(mnemonic, type), {}, type).address;
|
|
79
86
|
});
|
|
80
|
-
const
|
|
81
|
-
assert(!
|
|
87
|
+
const existingAccount = this.state.checkAddressExists(Object.values(rs.addressMap));
|
|
88
|
+
assert(!existingAccount, t('bg.ACCOUNT.services.keyring.handler.Mnemonic.accountAlreadyExistsWithName', {
|
|
82
89
|
replace: {
|
|
83
|
-
name: (
|
|
90
|
+
name: (existingAccount === null || existingAccount === void 0 ? void 0 : existingAccount.name) || (existingAccount === null || existingAccount === void 0 ? void 0 : existingAccount.address) || ''
|
|
84
91
|
}
|
|
85
92
|
}));
|
|
86
93
|
return rs;
|
|
@@ -93,12 +100,11 @@ export class AccountMnemonicHandler extends AccountBaseHandler {
|
|
|
93
100
|
name,
|
|
94
101
|
password,
|
|
95
102
|
suri: _suri,
|
|
96
|
-
|
|
103
|
+
types
|
|
97
104
|
} = request;
|
|
98
105
|
const addressDict = {};
|
|
99
106
|
let changedAccount = false;
|
|
100
107
|
const hasMasterPassword = keyring.keyring.hasMasterPassword;
|
|
101
|
-
const types = type ? [type] : ['sr25519', ...EthereumKeypairTypes, 'ton', ...CardanoKeypairTypes, ...BitcoinKeypairTypes];
|
|
102
108
|
if (!hasMasterPassword) {
|
|
103
109
|
if (!password) {
|
|
104
110
|
throw Error(t('bg.ACCOUNT.services.keyring.handler.Mnemonic.eachAccountPasswordNeeded'));
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import KoniState from '@subwallet/extension-base/koni/background/handlers/State';
|
|
2
2
|
import { AccountProxy, AccountProxyData, AccountProxyMap, AccountProxyStoreData, CurrentAccountInfo, ModifyPairStoreData } from '@subwallet/extension-base/types';
|
|
3
|
+
import { KeypairType } from '@subwallet/keyring/types';
|
|
3
4
|
import { SubjectInfo } from '@subwallet/ui-keyring/observable/types';
|
|
4
5
|
interface ExistsAccount {
|
|
5
6
|
address: string;
|
|
6
7
|
name: string;
|
|
8
|
+
relatedAccountTypes: KeypairType[];
|
|
7
9
|
}
|
|
8
10
|
export declare class AccountState {
|
|
9
11
|
private readonly koniState;
|
|
@@ -70,6 +72,7 @@ export declare class AccountState {
|
|
|
70
72
|
getAllAddresses(): string[];
|
|
71
73
|
getProxyId(): string | null;
|
|
72
74
|
getDecodedAddresses(accountProxy?: string, allowGetAllAccount?: boolean): string[];
|
|
75
|
+
getDecodedAccountTypes(accountProxyId: string): KeypairType[];
|
|
73
76
|
/**
|
|
74
77
|
* Account ref
|
|
75
78
|
* @deprecated
|
|
@@ -279,15 +279,19 @@ export class AccountState {
|
|
|
279
279
|
const belongsTo = this.belongUnifiedAccount(address);
|
|
280
280
|
if (belongsTo) {
|
|
281
281
|
const accountProxy = this.accountProxies[belongsTo];
|
|
282
|
+
const allAccountTypes = this.getDecodedAccountTypes(belongsTo); // get allAccountTypes of unified account of the account address
|
|
283
|
+
|
|
282
284
|
return {
|
|
283
285
|
address,
|
|
284
|
-
name: accountProxy.name
|
|
286
|
+
name: accountProxy.name,
|
|
287
|
+
relatedAccountTypes: allAccountTypes
|
|
285
288
|
};
|
|
286
289
|
} else {
|
|
287
290
|
var _pair$meta;
|
|
288
291
|
return {
|
|
289
292
|
address,
|
|
290
|
-
name: ((_pair$meta = pair.meta) === null || _pair$meta === void 0 ? void 0 : _pair$meta.name) || address
|
|
293
|
+
name: ((_pair$meta = pair.meta) === null || _pair$meta === void 0 ? void 0 : _pair$meta.name) || address,
|
|
294
|
+
relatedAccountTypes: [pair.type]
|
|
291
295
|
};
|
|
292
296
|
}
|
|
293
297
|
}
|
|
@@ -449,6 +453,20 @@ export class AccountState {
|
|
|
449
453
|
return accountProxies[proxyId].accounts.map(account => account.address);
|
|
450
454
|
}
|
|
451
455
|
}
|
|
456
|
+
getDecodedAccountTypes(accountProxyId) {
|
|
457
|
+
if (!accountProxyId) {
|
|
458
|
+
return [];
|
|
459
|
+
}
|
|
460
|
+
if (accountProxyId === ALL_ACCOUNT_KEY) {
|
|
461
|
+
return []; // todo
|
|
462
|
+
}
|
|
463
|
+
const accountProxies = this.accounts;
|
|
464
|
+
if (!accountProxies[accountProxyId]) {
|
|
465
|
+
return [];
|
|
466
|
+
} else {
|
|
467
|
+
return accountProxies[accountProxyId].accounts.map(account => account.type);
|
|
468
|
+
}
|
|
469
|
+
}
|
|
452
470
|
|
|
453
471
|
/* Get address for another service */
|
|
454
472
|
|
|
@@ -563,7 +581,7 @@ export class AccountState {
|
|
|
563
581
|
metadata.suri = _parentSuri;
|
|
564
582
|
needUpdateSet.add(address);
|
|
565
583
|
}
|
|
566
|
-
const hasSuri =
|
|
584
|
+
const hasSuri = 'suri' in metadata;
|
|
567
585
|
const lacksDerivationPath = !('derivationPath' in metadata);
|
|
568
586
|
const isEthereumType = EthereumKeypairTypes.includes(pair.type);
|
|
569
587
|
const isTonType = pair.type === 'ton';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { AccountProxyType } from '@subwallet/extension-base/types';
|
|
4
5
|
export const hasAnyAccountForMigration = allAccountProxies => {
|
|
5
6
|
for (const account of allAccountProxies) {
|
|
6
7
|
if (account.isNeedMigrateUnifiedAccount) {
|
|
@@ -8,4 +9,12 @@ export const hasAnyAccountForMigration = allAccountProxies => {
|
|
|
8
9
|
}
|
|
9
10
|
}
|
|
10
11
|
return false;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
// Check if account is TrustWallet account
|
|
15
|
+
export const isTWAccount = account => {
|
|
16
|
+
const isTWDerivation = account.suri === "m/44'/354'/0'/0'/0'";
|
|
17
|
+
const isTWSolo = account.accountType === AccountProxyType.SOLO;
|
|
18
|
+
const isTWKeyPairType = account.accounts[0].type === 'ed25519-tw';
|
|
19
|
+
return isTWDerivation && isTWSolo && isTWKeyPairType;
|
|
11
20
|
};
|
|
@@ -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
|
};
|
|
@@ -7,6 +7,12 @@ import { baseParseIPFSUrl } from '@subwallet/extension-base/utils';
|
|
|
7
7
|
import { getKeypairTypeByAddress } from '@subwallet/keyring';
|
|
8
8
|
import { EthereumKeypairTypes } from '@subwallet/keyring/types';
|
|
9
9
|
import subwalletApiSdk from '@subwallet-monorepos/subwallet-services-sdk';
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* NFT detection service
|
|
13
|
+
* Responsible for managing NFT detection jobs per address
|
|
14
|
+
*/
|
|
15
|
+
|
|
10
16
|
function mapSdkToNftItem(rawInstance, chain, collectionId, owner) {
|
|
11
17
|
var _rawInstance$token_ty, _rawInstance$token_ty2, _rawInstance$id;
|
|
12
18
|
const metadata = rawInstance.metadata || {};
|
|
@@ -178,7 +178,6 @@ export default class BaseOpenGovHandler {
|
|
|
178
178
|
const decimals = Number(_getAssetDecimals(this.nativeToken));
|
|
179
179
|
estimatedFee = new BigN(0.001).multipliedBy(new BigN(10).pow(decimals)); // fallback 0.001
|
|
180
180
|
}
|
|
181
|
-
|
|
182
181
|
const availableBalance = new BigN(totalBalance.value).minus(estimatedFee);
|
|
183
182
|
if (availableBalance.lte(0)) {
|
|
184
183
|
return new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE, "You don't have enough tokens to proceed");
|
|
@@ -225,7 +224,6 @@ export default class BaseOpenGovHandler {
|
|
|
225
224
|
estimatedFee = new BigN(0.001 * 10 ** _getAssetDecimals(this.nativeToken)); // fallback 0.001
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
|
-
|
|
229
227
|
const availableBalance = new BigN(totalBalance.value).minus(estimatedFee);
|
|
230
228
|
if (availableBalance.lte(0)) {
|
|
231
229
|
return new TransactionError(BasicTxErrorType.NOT_ENOUGH_BALANCE, "You don't have enough tokens to proceed");
|
|
@@ -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[];
|
|
@@ -18,4 +18,7 @@ export let Conviction;
|
|
|
18
18
|
Conviction["Locked4x"] = "Locked4x";
|
|
19
19
|
Conviction["Locked5x"] = "Locked5x";
|
|
20
20
|
Conviction["Locked6x"] = "Locked6x";
|
|
21
|
-
})(Conviction || (Conviction = {}));
|
|
21
|
+
})(Conviction || (Conviction = {})); // ----- Casting -----
|
|
22
|
+
// ----- Delegating -----
|
|
23
|
+
// ----- VotingFor -----
|
|
24
|
+
// Unlock Vote
|
|
@@ -201,7 +201,6 @@ export default class EvmRequestHandler {
|
|
|
201
201
|
maxPriorityFeePerGas: anyNumberToBN(maxPriorityFeePerGas).toNumber()
|
|
202
202
|
// nonce: await web3.eth.getTransactionCount(from) // Todo: fill this value from transaction service
|
|
203
203
|
};
|
|
204
|
-
|
|
205
204
|
const tx = this.configToTransaction(params);
|
|
206
205
|
await Promise.resolve();
|
|
207
206
|
if (pair.isLocked) {
|
|
@@ -29,7 +29,6 @@ export const DEFAULT_NOTIFICATION_SETUP = {
|
|
|
29
29
|
// isHideAnnouncement: false
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
|
|
33
32
|
export const DEFAULT_ACKNOWLEDGED_MIGRATION_STATUS = false;
|
|
34
33
|
export const DEFAULT_UNIFIED_ACCOUNT_MIGRATION_IN_PROGRESS = false;
|
|
35
34
|
export const DEFAULT_UNIFIED_ACCOUNT_MIGRATION_IN_DONE = false;
|
|
@@ -461,11 +461,9 @@ export default class DatabaseService {
|
|
|
461
461
|
async setMantaPayData(data) {
|
|
462
462
|
await this._db.mantaPay.put(data); // just override if exist
|
|
463
463
|
}
|
|
464
|
-
|
|
465
464
|
async updateMantaPayData(key, data) {
|
|
466
465
|
await this._db.mantaPay.update(key, data); // just override if exist
|
|
467
466
|
}
|
|
468
|
-
|
|
469
467
|
async getMantaPayData(key) {
|
|
470
468
|
return this._db.mantaPay.get({
|
|
471
469
|
key
|
|
@@ -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
|
+
}
|