@subwallet/extension-base 1.3.70-2 → 1.3.71-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.js +65 -8
- package/cjs/background/KoniTypes.js +65 -8
- package/cjs/constants/blocked-actions.js +3 -0
- package/cjs/core/logic-validation/swap.js +0 -3
- package/cjs/core/substrate/system-pallet.js +0 -2
- 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 +154 -158
- package/cjs/koni/background/handlers/State.js +54 -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 +2 -3
- 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 +0 -2
- package/cjs/services/balance-service/transfer/ton-transfer.js +0 -1
- package/cjs/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- 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 +18 -26
- package/cjs/services/chain-service/utils/index.js +21 -25
- 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/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/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 +28 -28
- 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/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 +5 -1
- 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 +1 -2
- package/cjs/utils/index.js +1 -2
- package/constants/blocked-actions.js +3 -0
- package/core/logic-validation/swap.js +0 -3
- package/core/substrate/system-pallet.js +0 -2
- 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.js +8 -11
- package/koni/background/handlers/State.js +41 -38
- package/koni/background/handlers/Tabs.js +9 -3
- package/package.json +19 -20
- 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 +0 -1
- 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.js +0 -2
- package/services/balance-service/transfer/ton-transfer.js +0 -1
- package/services/balance-service/transfer/xcm/snowBridge.js +0 -1
- 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 +15 -23
- package/services/chain-service/utils/index.js +22 -26
- 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/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.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/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/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/swap/index.js +2 -1
- package/types/transaction/process.js +3 -1
- package/types/yield/actions/join/step.js +17 -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 +5 -1
- package/utils/auth.js +2 -2
- package/utils/bitcoin/utxo-management.js +0 -1
- package/utils/index.js +2 -5
|
@@ -39,7 +39,6 @@ async function fetchCheckApproval(request) {
|
|
|
39
39
|
if (!output) {
|
|
40
40
|
return undefined; // todo: recheck
|
|
41
41
|
}
|
|
42
|
-
|
|
43
42
|
chainId = dutchQuote.orderInfo.chainId;
|
|
44
43
|
tokenIn = dutchQuote.orderInfo.input.token;
|
|
45
44
|
tokenOut = output.token;
|
|
@@ -60,7 +59,6 @@ async function fetchCheckApproval(request) {
|
|
|
60
59
|
tokenOutChainId: chainId // swap in-chain
|
|
61
60
|
})
|
|
62
61
|
});
|
|
63
|
-
|
|
64
62
|
return await response.json();
|
|
65
63
|
}
|
|
66
64
|
export class UniswapHandler {
|
|
@@ -802,7 +800,6 @@ export class UniswapHandler {
|
|
|
802
800
|
if (swap) {
|
|
803
801
|
return this.swapBaseHandler.validateSwapOnlyProcess(params, swapIndex); // todo: create interface for input request
|
|
804
802
|
}
|
|
805
|
-
|
|
806
803
|
if (swapXcm) {
|
|
807
804
|
return this.swapBaseHandler.validateSwapXcmProcess(params, swapIndex, bridgeIndex);
|
|
808
805
|
}
|
|
@@ -87,10 +87,10 @@ export function parseLiquidStakingEvents(historyItem, eventLogs, inputTokenInfo,
|
|
|
87
87
|
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
88
88
|
var _record$event$data$9;
|
|
89
89
|
if ((_record$event$data$9 = record.event.data[2]) !== null && _record$event$data$9 !== void 0 && _record$event$data$9.toString()) {
|
|
90
|
-
var _record$event$data$
|
|
90
|
+
var _record$event$data$0;
|
|
91
91
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
92
92
|
historyItem.fee = {
|
|
93
|
-
value: ((_record$event$data$
|
|
93
|
+
value: ((_record$event$data$0 = record.event.data[2]) === null || _record$event$data$0 === void 0 ? void 0 : _record$event$data$0.toString()) || '0',
|
|
94
94
|
symbol: nativeSymbol,
|
|
95
95
|
decimals: nativeDecimals
|
|
96
96
|
};
|
|
@@ -109,12 +109,12 @@ export function parseLiquidStakingFastUnstakeEvents(historyItem, eventLogs, chai
|
|
|
109
109
|
const section = extrinsicType === ExtrinsicType.REDEEM_QDOT ? 'tokens' : 'balances';
|
|
110
110
|
const eventMethod = extrinsicType === ExtrinsicType.REDEEM_QDOT ? 'withdrawn' : 'withdraw';
|
|
111
111
|
if (record.event.section === section && record.event.method.toLowerCase() === eventMethod) {
|
|
112
|
-
var _record$event$data$
|
|
113
|
-
if ((_record$event$data$
|
|
114
|
-
var _record$event$data$
|
|
112
|
+
var _record$event$data$1;
|
|
113
|
+
if ((_record$event$data$1 = record.event.data[2]) !== null && _record$event$data$1 !== void 0 && _record$event$data$1.toString()) {
|
|
114
|
+
var _record$event$data$10;
|
|
115
115
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
116
116
|
historyItem.fee = {
|
|
117
|
-
value: ((_record$event$data$
|
|
117
|
+
value: ((_record$event$data$10 = record.event.data[2]) === null || _record$event$data$10 === void 0 ? void 0 : _record$event$data$10.toString()) || '0',
|
|
118
118
|
symbol: nativeSymbol,
|
|
119
119
|
decimals: nativeDecimals
|
|
120
120
|
};
|
|
@@ -138,6 +138,9 @@ export default class WalletConnectService {
|
|
|
138
138
|
var _classPrivateFieldLoo;
|
|
139
139
|
return ((_classPrivateFieldLoo = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo === void 0 ? void 0 : _classPrivateFieldLoo.session.values) || [];
|
|
140
140
|
}
|
|
141
|
+
|
|
142
|
+
// Remove old listener
|
|
143
|
+
|
|
141
144
|
getSession(topic) {
|
|
142
145
|
var _classPrivateFieldLoo2;
|
|
143
146
|
const session = (_classPrivateFieldLoo2 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo2 === void 0 ? void 0 : _classPrivateFieldLoo2.session.get(topic);
|
|
@@ -191,7 +194,7 @@ export default class WalletConnectService {
|
|
|
191
194
|
await ((_classPrivateFieldLoo7 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo7 === void 0 ? void 0 : _classPrivateFieldLoo7.respond(response));
|
|
192
195
|
}
|
|
193
196
|
async resetWallet(resetAll) {
|
|
194
|
-
var _classPrivateFieldLoo8,
|
|
197
|
+
var _classPrivateFieldLoo8, _classPrivateFieldLoo0, _classPrivateFieldLoo10;
|
|
195
198
|
_classPrivateFieldLooseBase(this, _removeListener)[_removeListener]();
|
|
196
199
|
|
|
197
200
|
// Disconnect session
|
|
@@ -209,11 +212,11 @@ export default class WalletConnectService {
|
|
|
209
212
|
}
|
|
210
213
|
|
|
211
214
|
// Disconnect pair
|
|
212
|
-
const pairs = ((
|
|
215
|
+
const pairs = ((_classPrivateFieldLoo0 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo0 === void 0 ? void 0 : _classPrivateFieldLoo0.pairing.values) || [];
|
|
213
216
|
for (const pair of pairs) {
|
|
214
217
|
try {
|
|
215
|
-
var
|
|
216
|
-
await ((
|
|
218
|
+
var _classPrivateFieldLoo1;
|
|
219
|
+
await ((_classPrivateFieldLoo1 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo1 === void 0 ? void 0 : _classPrivateFieldLoo1.disconnect({
|
|
217
220
|
topic: pair.topic,
|
|
218
221
|
reason: getSdkError('USER_DISCONNECTED')
|
|
219
222
|
}));
|
|
@@ -221,12 +224,12 @@ export default class WalletConnectService {
|
|
|
221
224
|
console.error(e);
|
|
222
225
|
}
|
|
223
226
|
}
|
|
224
|
-
const keys = (await ((
|
|
227
|
+
const keys = (await ((_classPrivateFieldLoo10 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo10 === void 0 ? void 0 : _classPrivateFieldLoo10.core.storage.getKeys())) || [];
|
|
225
228
|
const deleteKeys = resetAll ? keys : keys.filter(key => key.startsWith('wc@'));
|
|
226
229
|
for (const key of deleteKeys) {
|
|
227
230
|
try {
|
|
228
|
-
var
|
|
229
|
-
await ((
|
|
231
|
+
var _classPrivateFieldLoo11;
|
|
232
|
+
await ((_classPrivateFieldLoo11 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo11 === void 0 ? void 0 : _classPrivateFieldLoo11.core.storage.removeItem(key));
|
|
230
233
|
} catch (e) {
|
|
231
234
|
console.error(e);
|
|
232
235
|
}
|
|
@@ -235,8 +238,8 @@ export default class WalletConnectService {
|
|
|
235
238
|
_classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions]();
|
|
236
239
|
}
|
|
237
240
|
async disconnect(topic) {
|
|
238
|
-
var
|
|
239
|
-
await ((
|
|
241
|
+
var _classPrivateFieldLoo12;
|
|
242
|
+
await ((_classPrivateFieldLoo12 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo12 === void 0 ? void 0 : _classPrivateFieldLoo12.disconnect({
|
|
240
243
|
topic: topic,
|
|
241
244
|
reason: getSdkError('USER_DISCONNECTED')
|
|
242
245
|
}));
|
|
@@ -343,18 +346,18 @@ async function _onPingReply2({
|
|
|
343
346
|
}
|
|
344
347
|
}
|
|
345
348
|
function _createListener2() {
|
|
346
|
-
var _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18
|
|
347
|
-
(
|
|
348
|
-
(
|
|
349
|
-
(
|
|
350
|
-
(
|
|
351
|
-
(
|
|
352
|
-
(
|
|
349
|
+
var _classPrivateFieldLoo13, _classPrivateFieldLoo14, _classPrivateFieldLoo15, _classPrivateFieldLoo16, _classPrivateFieldLoo17, _classPrivateFieldLoo18;
|
|
350
|
+
(_classPrivateFieldLoo13 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo13 === void 0 ? void 0 : _classPrivateFieldLoo13.on('session_proposal', _classPrivateFieldLooseBase(this, _onSessionProposal)[_onSessionProposal].bind(this));
|
|
351
|
+
(_classPrivateFieldLoo14 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo14 === void 0 ? void 0 : _classPrivateFieldLoo14.on('session_request', _classPrivateFieldLooseBase(this, _onSessionRequest)[_onSessionRequest].bind(this));
|
|
352
|
+
(_classPrivateFieldLoo15 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo15 === void 0 ? void 0 : _classPrivateFieldLoo15.on('session_ping', _classPrivateFieldLooseBase(this, _onPingReply)[_onPingReply].bind(this));
|
|
353
|
+
(_classPrivateFieldLoo16 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo16 === void 0 ? void 0 : _classPrivateFieldLoo16.on('session_event', data => console.log('event', data));
|
|
354
|
+
(_classPrivateFieldLoo17 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo17 === void 0 ? void 0 : _classPrivateFieldLoo17.on('session_update', data => console.log('update', data));
|
|
355
|
+
(_classPrivateFieldLoo18 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo18 === void 0 ? void 0 : _classPrivateFieldLoo18.on('session_delete', _classPrivateFieldLooseBase(this, _updateSessions)[_updateSessions].bind(this));
|
|
353
356
|
}
|
|
354
357
|
function _removeListener2() {
|
|
355
358
|
ALL_WALLET_CONNECT_EVENT.forEach(event => {
|
|
356
|
-
var
|
|
357
|
-
(
|
|
359
|
+
var _classPrivateFieldLoo19;
|
|
360
|
+
(_classPrivateFieldLoo19 = _classPrivateFieldLooseBase(this, _client)[_client]) === null || _classPrivateFieldLoo19 === void 0 ? void 0 : _classPrivateFieldLoo19.removeAllListeners(event);
|
|
358
361
|
});
|
|
359
362
|
}
|
|
360
363
|
function _checkClient2() {
|
|
@@ -17,4 +17,4 @@ export let POLKADOT_SIGNING_METHODS;
|
|
|
17
17
|
(function (POLKADOT_SIGNING_METHODS) {
|
|
18
18
|
POLKADOT_SIGNING_METHODS["POLKADOT_SIGN_TRANSACTION"] = "polkadot_signTransaction";
|
|
19
19
|
POLKADOT_SIGNING_METHODS["POLKADOT_SIGN_MESSAGE"] = "polkadot_signMessage";
|
|
20
|
-
})(POLKADOT_SIGNING_METHODS || (POLKADOT_SIGNING_METHODS = {}));
|
|
20
|
+
})(POLKADOT_SIGNING_METHODS || (POLKADOT_SIGNING_METHODS = {})); // payload and address
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { SeedLengths } from '@subwallet/extension-base/background/types';
|
|
2
2
|
import { KeypairType } from '@subwallet/keyring/types';
|
|
3
|
-
export declare type MnemonicType = 'general' | 'ton';
|
|
3
|
+
export declare type MnemonicType = 'general' | 'trust-wallet' | 'ton';
|
|
4
4
|
/**
|
|
5
5
|
* @interface RequestMnemonicCreateV2
|
|
6
6
|
* @description Represents a request to create a new mnemonic phrase.
|
|
@@ -36,6 +36,7 @@ export interface ResponseMnemonicCreateV2 {
|
|
|
36
36
|
*/
|
|
37
37
|
export interface RequestMnemonicValidateV2 {
|
|
38
38
|
mnemonic: string;
|
|
39
|
+
mnemonicType: MnemonicType;
|
|
39
40
|
}
|
|
40
41
|
/**
|
|
41
42
|
* @interface ResponseMnemonicValidateV2
|
|
@@ -67,7 +68,7 @@ export interface RequestAccountCreateSuriV2 {
|
|
|
67
68
|
name: string;
|
|
68
69
|
password?: string;
|
|
69
70
|
suri: string;
|
|
70
|
-
|
|
71
|
+
types: KeypairType[];
|
|
71
72
|
isAllowed: boolean;
|
|
72
73
|
}
|
|
73
74
|
/**
|
|
@@ -95,4 +95,12 @@ export let AccountActions;
|
|
|
95
95
|
AccountActions["EXPORT_JSON"] = "EXPORT_JSON";
|
|
96
96
|
AccountActions["EXPORT_QR"] = "EXPORT_QR";
|
|
97
97
|
AccountActions["TON_CHANGE_WALLET_CONTRACT_VERSION"] = "TON_CHANGE_WALLET_CONTRACT_VERSION";
|
|
98
|
-
})(AccountActions || (AccountActions = {}));
|
|
98
|
+
})(AccountActions || (AccountActions = {}));
|
|
99
|
+
/**
|
|
100
|
+
* @interface AccountJson
|
|
101
|
+
* @extends AbstractAddressJson
|
|
102
|
+
* @extends AccountMetadataData
|
|
103
|
+
* @extends AccountActionData
|
|
104
|
+
* @prop {boolean} [isSubWallet] - Import from SubWallet
|
|
105
|
+
* @prop {boolean} [pendingMigrate] - Pending migrate password
|
|
106
|
+
* */
|
package/types/balance/index.js
CHANGED
|
@@ -18,4 +18,8 @@ export let BalanceType;
|
|
|
18
18
|
BalanceType["TOTAL"] = "total";
|
|
19
19
|
BalanceType["TOTAL_MINUS_RESERVED"] = "totalMinusReserved";
|
|
20
20
|
BalanceType["KEEP_ALIVE"] = "keepAlive";
|
|
21
|
-
})(BalanceType || (BalanceType = {}));
|
|
21
|
+
})(BalanceType || (BalanceType = {}));
|
|
22
|
+
/** Balance info of all tokens on an address */
|
|
23
|
+
// Key is tokenSlug
|
|
24
|
+
/** Balance info of all addresses */
|
|
25
|
+
// Key is address
|
package/types/swap/index.js
CHANGED
|
@@ -50,7 +50,8 @@ export let SwapFeeType;
|
|
|
50
50
|
SwapFeeType["PLATFORM_FEE"] = "PLATFORM_FEE";
|
|
51
51
|
SwapFeeType["NETWORK_FEE"] = "NETWORK_FEE";
|
|
52
52
|
SwapFeeType["WALLET_FEE"] = "WALLET_FEE";
|
|
53
|
-
})(SwapFeeType || (SwapFeeType = {}));
|
|
53
|
+
})(SwapFeeType || (SwapFeeType = {})); // todo: will be more
|
|
54
|
+
// parameters & responses
|
|
54
55
|
export let DynamicSwapType;
|
|
55
56
|
(function (DynamicSwapType) {
|
|
56
57
|
DynamicSwapType["SWAP"] = "SWAP";
|
|
@@ -17,4 +17,6 @@ export let StepStatus;
|
|
|
17
17
|
StepStatus["CANCELLED"] = "CANCELLED";
|
|
18
18
|
StepStatus["TIMEOUT"] = "TIMEOUT";
|
|
19
19
|
})(StepStatus || (StepStatus = {}));
|
|
20
|
-
export const PROCESSING_STEP_STATUS = [StepStatus.PREPARE, StepStatus.SUBMITTING, StepStatus.PROCESSING];
|
|
20
|
+
export const PROCESSING_STEP_STATUS = [StepStatus.PREPARE, StepStatus.SUBMITTING, StepStatus.PROCESSING];
|
|
21
|
+
|
|
22
|
+
// temp for avoid conflict // todo: recheck to refactor BriefXcmStepV2 and BriefSwapStepV2 later;
|
|
@@ -44,4 +44,20 @@ export let YieldStepType;
|
|
|
44
44
|
YieldStepType["MINT_SDOT"] = "MINT_SDOT";
|
|
45
45
|
YieldStepType["MINT_STDOT"] = "MINT_STDOT";
|
|
46
46
|
YieldStepType["TOKEN_APPROVAL"] = "TOKEN_APPROVAL";
|
|
47
|
-
})(YieldStepType || (YieldStepType = {}));
|
|
47
|
+
})(YieldStepType || (YieldStepType = {}));
|
|
48
|
+
/**
|
|
49
|
+
* @interface YieldStepDetail
|
|
50
|
+
* @extends BaseYieldStepDetail
|
|
51
|
+
* @description Detail of a step
|
|
52
|
+
* @prop {number} id - Step's id
|
|
53
|
+
* */
|
|
54
|
+
/**
|
|
55
|
+
* @interface YieldTokenBaseInfo
|
|
56
|
+
* @prop {string} slug - Token's slug
|
|
57
|
+
* @prop {string} [amount] - Token's amount
|
|
58
|
+
* */
|
|
59
|
+
/** Base info and fee of a step */
|
|
60
|
+
/**
|
|
61
|
+
* @interface OptimalYieldPath
|
|
62
|
+
* @description Result after generate steps
|
|
63
|
+
* */
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _ChainInfo } from '@subwallet/chain-list/types';
|
|
2
2
|
import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
|
|
3
3
|
import { AccountChainType, AccountJson } from '@subwallet/extension-base/types';
|
|
4
|
-
import { KeypairType } from '@subwallet/keyring/types';
|
|
5
4
|
export declare function isAccountAll(address?: string): boolean;
|
|
6
5
|
export declare function reformatAddress(address: string, networkPrefix?: number, isEthereum?: boolean, ignoreError?: boolean): string;
|
|
7
6
|
export declare const _reformatAddressWithChain: (address: string, chainInfo: _ChainInfo) => string;
|
|
@@ -15,8 +14,6 @@ interface ExtendAddressesByChainType extends AddressesByChainType {
|
|
|
15
14
|
export declare function getAddressesByChainType(addresses: string[], chainTypes: ChainType[], chainInfo?: _ChainInfo): string[];
|
|
16
15
|
export declare function getAddressesByChainTypeMap(addresses: string[], chainInfo?: _ChainInfo): ExtendAddressesByChainType;
|
|
17
16
|
export declare function quickFormatAddressToCompare(address?: string): string | undefined;
|
|
18
|
-
/** @deprecated */
|
|
19
|
-
export declare const modifyAccountName: (type: KeypairType, name: string, modify: boolean) => string;
|
|
20
17
|
/**
|
|
21
18
|
* @function getAccountJsonByAddress
|
|
22
19
|
* @desc Get account info by address
|
package/utils/account/common.js
CHANGED
|
@@ -63,7 +63,6 @@ export function getAddressesByChainType(addresses, chainTypes, chainInfo) {
|
|
|
63
63
|
return addressByChainTypeMap[chainType];
|
|
64
64
|
}).flat(); // todo: recheck
|
|
65
65
|
}
|
|
66
|
-
|
|
67
66
|
export function getAddressesByChainTypeMap(addresses, chainInfo) {
|
|
68
67
|
const addressByChainType = {
|
|
69
68
|
substrate: [],
|
|
@@ -103,29 +102,6 @@ export function quickFormatAddressToCompare(address) {
|
|
|
103
102
|
return reformatAddress(address, 42).toLowerCase();
|
|
104
103
|
}
|
|
105
104
|
|
|
106
|
-
/** @deprecated */
|
|
107
|
-
export const modifyAccountName = (type, name, modify) => {
|
|
108
|
-
if (!modify) {
|
|
109
|
-
return name;
|
|
110
|
-
}
|
|
111
|
-
let network = '';
|
|
112
|
-
switch (type) {
|
|
113
|
-
case 'sr25519':
|
|
114
|
-
case 'ed25519':
|
|
115
|
-
case 'ecdsa':
|
|
116
|
-
network = 'Substrate';
|
|
117
|
-
break;
|
|
118
|
-
case 'ethereum':
|
|
119
|
-
network = 'EVM';
|
|
120
|
-
break;
|
|
121
|
-
case 'ton':
|
|
122
|
-
case 'ton-native':
|
|
123
|
-
network = 'Ton';
|
|
124
|
-
break;
|
|
125
|
-
}
|
|
126
|
-
return network ? [name, network].join(' - ') : name;
|
|
127
|
-
};
|
|
128
|
-
|
|
129
105
|
/**
|
|
130
106
|
* @function getAccountJsonByAddress
|
|
131
107
|
* @desc Get account info by address
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { getDerivePath } from '@subwallet/keyring';
|
|
5
|
-
import { BitcoinKeypairTypes,
|
|
5
|
+
import { BitcoinKeypairTypes, DefaultSubstrateKeypairTypes, EthereumKeypairTypes } from '@subwallet/keyring/types';
|
|
6
6
|
import { keyring } from '@subwallet/ui-keyring';
|
|
7
7
|
import { t } from 'i18next';
|
|
8
8
|
import { assert } from '@polkadot/util';
|
|
@@ -53,7 +53,7 @@ export const parseUnifiedSuriToDerivationPath = (suri, type) => {
|
|
|
53
53
|
return path.replace('{firstIndex}', firstIndex);
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
|
-
if (
|
|
56
|
+
if (DefaultSubstrateKeypairTypes.includes(type)) {
|
|
57
57
|
return suri;
|
|
58
58
|
}
|
|
59
59
|
}
|
|
@@ -112,7 +112,7 @@ export const getSoloDerivationInfo = (type, metadata = {}) => {
|
|
|
112
112
|
};
|
|
113
113
|
}
|
|
114
114
|
} else {
|
|
115
|
-
if (
|
|
115
|
+
if (DefaultSubstrateKeypairTypes.includes(type)) {
|
|
116
116
|
const _type = type;
|
|
117
117
|
const validateTypeFunc = _type === 'sr25519' ? validateSr25519DerivationPath : raw => validateOtherSubstrateDerivationPath(raw, _type);
|
|
118
118
|
const validateTypeRs = validateTypeFunc(suri);
|
|
@@ -243,7 +243,7 @@ export const findSoloNextDerive = parentAddress => {
|
|
|
243
243
|
break;
|
|
244
244
|
}
|
|
245
245
|
}
|
|
246
|
-
const isSubstrate =
|
|
246
|
+
const isSubstrate = DefaultSubstrateKeypairTypes.includes(parentPair.type);
|
|
247
247
|
const indexes = currentDepth > 0 ? deriveInfo.autoIndexes || [] : [];
|
|
248
248
|
indexes.push(index);
|
|
249
249
|
const suri = isSubstrate ? [deriveInfo.suri || '', index].join('//') : '//'.concat(indexes.join('//'));
|
|
@@ -281,6 +281,9 @@ export const derivePair = (parentPair, name, suri, derivationPath) => {
|
|
|
281
281
|
}
|
|
282
282
|
};
|
|
283
283
|
export const getSuri = (seed, type) => {
|
|
284
|
-
|
|
284
|
+
if (!type) {
|
|
285
|
+
return seed;
|
|
286
|
+
}
|
|
287
|
+
const extraPath = getDerivePath(type)(0);
|
|
285
288
|
return seed + (extraPath ? '/' + extraPath : '');
|
|
286
289
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { DerivePathInfo, IDerivePathInfo_ } from '@subwallet/extension-base/types';
|
|
2
|
-
import { KeypairType,
|
|
2
|
+
import { DefaultSubstrateKeypairType, KeypairType, TrustWalletSubstrateKeypairType } from '@subwallet/keyring/types';
|
|
3
3
|
export declare const validateUnifiedDerivationPath: (raw: string) => DerivePathInfo | undefined;
|
|
4
4
|
export declare const validateEvmDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
5
5
|
export declare const validateTonDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
6
6
|
export declare const validateBitcoinDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
7
7
|
export declare const validateCardanoDerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
8
8
|
export declare const validateSr25519DerivationPath: (raw: string) => IDerivePathInfo_ | undefined;
|
|
9
|
-
export declare const validateOtherSubstrateDerivationPath: (raw: string, type: Exclude<
|
|
9
|
+
export declare const validateOtherSubstrateDerivationPath: (raw: string, type: Exclude<DefaultSubstrateKeypairType | TrustWalletSubstrateKeypairType, 'sr25519'>) => IDerivePathInfo_ | undefined;
|
|
10
10
|
export declare const validateDerivationPath: (raw: string, type?: KeypairType) => DerivePathInfo | undefined;
|
|
@@ -246,7 +246,7 @@ export const validateDerivationPath = (raw, type) => {
|
|
|
246
246
|
return validateTonDerivationPath(raw);
|
|
247
247
|
} else if (type === 'sr25519') {
|
|
248
248
|
return validateSr25519DerivationPath(raw);
|
|
249
|
-
} else if (type === 'ed25519' || type === 'ecdsa') {
|
|
249
|
+
} else if (type === 'ed25519' || type === 'ed25519-tw' || type === 'ecdsa') {
|
|
250
250
|
return validateOtherSubstrateDerivationPath(raw, type);
|
|
251
251
|
} else if (type === 'cardano') {
|
|
252
252
|
return validateCardanoDerivationPath(raw);
|
|
@@ -105,7 +105,10 @@ export const getAccountActions = (signMode, networkType, type, _meta, parentAcco
|
|
|
105
105
|
// QR
|
|
106
106
|
if (signMode === AccountSignMode.PASSWORD) {
|
|
107
107
|
if (networkType === AccountChainType.ETHEREUM || networkType === AccountChainType.SUBSTRATE) {
|
|
108
|
-
|
|
108
|
+
if (type !== 'ed25519-tw') {
|
|
109
|
+
// todo: recheck if can export this account type
|
|
110
|
+
result.push(AccountActions.EXPORT_QR);
|
|
111
|
+
}
|
|
109
112
|
}
|
|
110
113
|
}
|
|
111
114
|
|
|
@@ -247,6 +250,7 @@ export const getAccountTokenTypes = type => {
|
|
|
247
250
|
return [_AssetType.NATIVE, _AssetType.LOCAL, _AssetType.ERC20, _AssetType.ERC721];
|
|
248
251
|
case 'sr25519':
|
|
249
252
|
case 'ed25519':
|
|
253
|
+
case 'ed25519-tw':
|
|
250
254
|
case 'ecdsa':
|
|
251
255
|
return [_AssetType.NATIVE, _AssetType.LOCAL, _AssetType.PSP22, _AssetType.PSP34, _AssetType.GRC20, _AssetType.ERC721, _AssetType.VFT];
|
|
252
256
|
case 'ton':
|
package/utils/auth.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { getKeypairTypeByAddress } from '@subwallet/keyring';
|
|
5
|
-
import { BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes,
|
|
5
|
+
import { AllSubstrateKeypairTypes, BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
6
6
|
export const isAddressValidWithAuthType = (address, accountAuthTypes) => {
|
|
7
7
|
const keypairType = getKeypairTypeByAddress(address);
|
|
8
8
|
const validTypes = {
|
|
9
9
|
evm: EthereumKeypairTypes,
|
|
10
|
-
substrate:
|
|
10
|
+
substrate: AllSubstrateKeypairTypes,
|
|
11
11
|
ton: TonKeypairTypes,
|
|
12
12
|
cardano: CardanoKeypairTypes,
|
|
13
13
|
bitcoin: BitcoinKeypairTypes
|
package/utils/index.js
CHANGED
|
@@ -6,7 +6,7 @@ import { getRandomIpfsGateway, SUBWALLET_IPFS } from '@subwallet/extension-base/
|
|
|
6
6
|
import { _isChainEvmCompatible, _isPureBitcoinChain, _isPureCardanoChain, _isPureSubstrateChain, _isPureTonChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
7
|
import { reformatAddress } from '@subwallet/extension-base/utils/account';
|
|
8
8
|
import { decodeAddress, encodeAddress, getKeypairTypeByAddress, isTonAddress } from '@subwallet/keyring';
|
|
9
|
-
import { BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes,
|
|
9
|
+
import { AllSubstrateKeypairTypes, BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
10
10
|
import { t } from 'i18next';
|
|
11
11
|
import { assert, BN, hexToU8a, isHex } from '@polkadot/util';
|
|
12
12
|
import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -244,7 +244,6 @@ export function isSameAddress(address1, address2) {
|
|
|
244
244
|
}
|
|
245
245
|
return reformatAddress(address1, 0) === reformatAddress(address2, 0); // TODO: maybe there's a better way
|
|
246
246
|
}
|
|
247
|
-
|
|
248
247
|
export function isSameAddressType(address1, address2) {
|
|
249
248
|
const isSameEvmAddress = isEthereumAddress(address1) && isEthereumAddress(address2);
|
|
250
249
|
const isSameTonAddress = isTonAddress(address1) && isTonAddress(address2);
|
|
@@ -256,7 +255,7 @@ export function isAddressAndChainCompatible(address, chain) {
|
|
|
256
255
|
const keypairType = getKeypairTypeByAddress(address);
|
|
257
256
|
const isEvmCompatible = _isChainEvmCompatible(chain) && EthereumKeypairTypes.includes(keypairType); // some chains compatible to substrate and evm, and use evm-address
|
|
258
257
|
const isTonCompatible = _isPureTonChain(chain) && TonKeypairTypes.includes(keypairType);
|
|
259
|
-
const isSubstrateCompatible = _isPureSubstrateChain(chain) &&
|
|
258
|
+
const isSubstrateCompatible = _isPureSubstrateChain(chain) && AllSubstrateKeypairTypes.includes(keypairType);
|
|
260
259
|
const isCardanoCompatible = _isPureCardanoChain(chain) && CardanoKeypairTypes.includes(keypairType);
|
|
261
260
|
const isBitcoinCompatible = _isPureBitcoinChain(chain) && BitcoinKeypairTypes.includes(keypairType);
|
|
262
261
|
return isEvmCompatible || isSubstrateCompatible || isTonCompatible || isCardanoCompatible || isBitcoinCompatible;
|
|
@@ -319,7 +318,6 @@ export const baseParseIPFSUrl = (input, customDomain) => {
|
|
|
319
318
|
}
|
|
320
319
|
return selectedDomain + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
321
320
|
};
|
|
322
|
-
|
|
323
321
|
export const swParseIPFSUrl = input => {
|
|
324
322
|
if (!input || input.length === 0) {
|
|
325
323
|
return undefined;
|
|
@@ -343,7 +341,6 @@ export const swParseIPFSUrl = input => {
|
|
|
343
341
|
}
|
|
344
342
|
return SUBWALLET_IPFS + input.split('ipfs://ipfs/')[1]; // starts with ipfs://ipfs/
|
|
345
343
|
};
|
|
346
|
-
|
|
347
344
|
export function wait(milliseconds) {
|
|
348
345
|
return new Promise(resolve => {
|
|
349
346
|
setTimeout(() => {
|