@subwallet/extension-base 1.1.54-0 → 1.1.56-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 +30 -2
- package/background/KoniTypes.js +6 -0
- package/background/errors/SwapError.d.ts +6 -0
- package/background/errors/SwapError.js +57 -0
- package/background/errors/TransactionError.js +9 -0
- package/background/types.d.ts +2 -0
- package/cjs/background/KoniTypes.js +8 -1
- package/cjs/background/errors/SwapError.js +64 -0
- package/cjs/background/errors/TransactionError.js +9 -0
- package/cjs/koni/api/nft/{statemint_nft → assethub_nft}/index.js +5 -3
- package/cjs/koni/api/nft/{statemine_nft → assethub_unique}/index.js +5 -3
- package/cjs/koni/api/nft/index.js +13 -13
- package/cjs/koni/api/nft/nft.js +1 -1
- package/cjs/koni/api/nft/transfer.js +11 -15
- package/cjs/koni/api/staking/bonding/utils.js +35 -6
- package/cjs/koni/background/handlers/Extension.js +214 -102
- package/cjs/koni/background/handlers/State.js +5 -2
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/balance-service/index.js +6 -3
- package/cjs/services/chain-service/constants.js +18 -4
- package/cjs/services/chain-service/index.js +39 -18
- package/cjs/services/chain-service/utils/index.js +15 -4
- package/cjs/services/chain-service/utils/patch.js +1 -1
- package/cjs/services/earning-service/constants/chains.js +4 -2
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +7 -9
- package/cjs/services/earning-service/handlers/native-staking/astar.js +4 -3
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +11 -8
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +22 -3
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +19 -5
- package/cjs/services/earning-service/service.js +0 -1
- package/cjs/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +4 -17
- package/cjs/services/migration-service/scripts/databases/MigrateAssetSetting.js +4 -17
- package/cjs/services/migration-service/scripts/index.js +3 -3
- package/cjs/services/swap-service/handler/base-handler.js +189 -0
- package/cjs/services/swap-service/handler/chainflip-handler.js +407 -0
- package/cjs/services/swap-service/handler/hydradx-handler.js +531 -0
- package/cjs/services/swap-service/index.js +250 -0
- package/cjs/services/swap-service/utils.js +126 -0
- package/cjs/services/transaction-service/index.js +20 -0
- package/cjs/services/transaction-service/utils.js +6 -0
- package/cjs/types/fee/evm.js +1 -0
- package/cjs/types/fee/fee.js +70 -0
- package/cjs/types/fee/index.js +27 -1
- package/cjs/types/service-base.js +1 -0
- package/cjs/types/swap/index.js +50 -0
- package/cjs/utils/index.js +12 -0
- package/cjs/utils/swap.js +78 -0
- package/koni/api/nft/{statemint_nft → assethub_nft}/index.d.ts +1 -1
- package/koni/api/nft/{statemint_nft → assethub_nft}/index.js +4 -2
- package/koni/api/nft/{statemine_nft → assethub_unique}/index.d.ts +1 -1
- package/koni/api/nft/{statemine_nft → assethub_unique}/index.js +4 -2
- package/koni/api/nft/index.js +13 -13
- package/koni/api/nft/nft.js +1 -1
- package/koni/api/nft/transfer.d.ts +1 -2
- package/koni/api/nft/transfer.js +10 -13
- package/koni/api/staking/bonding/utils.d.ts +3 -1
- package/koni/api/staking/bonding/utils.js +32 -6
- package/koni/background/handlers/Extension.d.ts +6 -0
- package/koni/background/handlers/Extension.js +111 -0
- package/koni/background/handlers/State.d.ts +2 -0
- package/koni/background/handlers/State.js +5 -2
- package/package.json +85 -28
- package/packageInfo.js +1 -1
- package/services/balance-service/index.js +6 -3
- package/services/base/types.d.ts +4 -0
- package/services/chain-service/constants.js +18 -4
- package/services/chain-service/index.d.ts +4 -0
- package/services/chain-service/index.js +21 -1
- package/services/chain-service/utils/index.d.ts +7 -5
- package/services/chain-service/utils/index.js +9 -2
- package/services/chain-service/utils/patch.js +1 -1
- package/services/earning-service/constants/chains.d.ts +1 -0
- package/services/earning-service/constants/chains.js +1 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +7 -9
- package/services/earning-service/handlers/native-staking/astar.js +4 -3
- package/services/earning-service/handlers/native-staking/para-chain.js +12 -9
- package/services/earning-service/handlers/native-staking/relay-chain.js +24 -5
- package/services/earning-service/handlers/nomination-pool/index.js +19 -5
- package/services/earning-service/service.js +0 -1
- package/services/event-service/types.d.ts +1 -0
- package/services/migration-service/scripts/MigrateTransactionHistoryBySymbol.js +4 -17
- package/services/migration-service/scripts/databases/MigrateAssetSetting.js +4 -17
- package/services/migration-service/scripts/index.js +3 -3
- package/services/swap-service/handler/base-handler.d.ts +38 -0
- package/services/swap-service/handler/base-handler.js +180 -0
- package/services/swap-service/handler/chainflip-handler.d.ts +30 -0
- package/services/swap-service/handler/chainflip-handler.js +399 -0
- package/services/swap-service/handler/hydradx-handler.d.ts +36 -0
- package/services/swap-service/handler/hydradx-handler.js +522 -0
- package/services/swap-service/index.d.ts +32 -0
- package/services/swap-service/index.js +241 -0
- package/services/swap-service/utils.d.ts +18 -0
- package/services/swap-service/utils.js +105 -0
- package/services/transaction-service/index.js +20 -0
- package/services/transaction-service/utils.d.ts +2 -0
- package/services/transaction-service/utils.js +6 -2
- package/types/fee/evm.d.ts +49 -0
- package/types/fee/evm.js +1 -0
- package/types/fee/fee.d.ts +32 -0
- package/types/fee/fee.js +63 -0
- package/types/fee/index.d.ts +2 -49
- package/types/fee/index.js +5 -1
- package/types/service-base.d.ts +10 -0
- package/types/service-base.js +1 -0
- package/types/swap/index.d.ts +168 -0
- package/types/swap/index.js +41 -0
- package/types/yield/info/chain/target.d.ts +2 -0
- package/types/yield/info/pallet.d.ts +8 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.js +2 -1
- package/utils/swap.d.ts +3 -0
- package/utils/swap.js +70 -0
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.1.
|
|
20
|
+
"version": "1.1.56-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -44,6 +44,11 @@
|
|
|
44
44
|
"require": "./cjs/background/errors/ProviderError.js",
|
|
45
45
|
"default": "./background/errors/ProviderError.js"
|
|
46
46
|
},
|
|
47
|
+
"./background/errors/SwapError": {
|
|
48
|
+
"types": "./background/errors/SwapError.d.ts",
|
|
49
|
+
"require": "./cjs/background/errors/SwapError.js",
|
|
50
|
+
"default": "./background/errors/SwapError.js"
|
|
51
|
+
},
|
|
47
52
|
"./background/errors/SWError": {
|
|
48
53
|
"types": "./background/errors/SWError.d.ts",
|
|
49
54
|
"require": "./cjs/background/errors/SWError.js",
|
|
@@ -199,6 +204,16 @@
|
|
|
199
204
|
"require": "./cjs/koni/api/nft/acala_nft/index.js",
|
|
200
205
|
"default": "./koni/api/nft/acala_nft/index.js"
|
|
201
206
|
},
|
|
207
|
+
"./koni/api/nft/assethub_nft": {
|
|
208
|
+
"types": "./koni/api/nft/assethub_nft/index.d.ts",
|
|
209
|
+
"require": "./cjs/koni/api/nft/assethub_nft/index.js",
|
|
210
|
+
"default": "./koni/api/nft/assethub_nft/index.js"
|
|
211
|
+
},
|
|
212
|
+
"./koni/api/nft/assethub_unique": {
|
|
213
|
+
"types": "./koni/api/nft/assethub_unique/index.d.ts",
|
|
214
|
+
"require": "./cjs/koni/api/nft/assethub_unique/index.js",
|
|
215
|
+
"default": "./koni/api/nft/assethub_unique/index.js"
|
|
216
|
+
},
|
|
202
217
|
"./koni/api/nft/bit.country": {
|
|
203
218
|
"types": "./koni/api/nft/bit.country/index.d.ts",
|
|
204
219
|
"require": "./cjs/koni/api/nft/bit.country/index.js",
|
|
@@ -249,16 +264,6 @@
|
|
|
249
264
|
"require": "./cjs/koni/api/nft/rmrk_nft/index.js",
|
|
250
265
|
"default": "./koni/api/nft/rmrk_nft/index.js"
|
|
251
266
|
},
|
|
252
|
-
"./koni/api/nft/statemine_nft": {
|
|
253
|
-
"types": "./koni/api/nft/statemine_nft/index.d.ts",
|
|
254
|
-
"require": "./cjs/koni/api/nft/statemine_nft/index.js",
|
|
255
|
-
"default": "./koni/api/nft/statemine_nft/index.js"
|
|
256
|
-
},
|
|
257
|
-
"./koni/api/nft/statemint_nft": {
|
|
258
|
-
"types": "./koni/api/nft/statemint_nft/index.d.ts",
|
|
259
|
-
"require": "./cjs/koni/api/nft/statemint_nft/index.js",
|
|
260
|
-
"default": "./koni/api/nft/statemint_nft/index.js"
|
|
261
|
-
},
|
|
262
267
|
"./koni/api/nft/transfer": {
|
|
263
268
|
"types": "./koni/api/nft/transfer.d.ts",
|
|
264
269
|
"require": "./cjs/koni/api/nft/transfer.js",
|
|
@@ -1355,6 +1360,31 @@
|
|
|
1355
1360
|
"require": "./cjs/services/subscan-service/types.js",
|
|
1356
1361
|
"default": "./services/subscan-service/types.js"
|
|
1357
1362
|
},
|
|
1363
|
+
"./services/swap-service": {
|
|
1364
|
+
"types": "./services/swap-service/index.d.ts",
|
|
1365
|
+
"require": "./cjs/services/swap-service/index.js",
|
|
1366
|
+
"default": "./services/swap-service/index.js"
|
|
1367
|
+
},
|
|
1368
|
+
"./services/swap-service/handler/base-handler": {
|
|
1369
|
+
"types": "./services/swap-service/handler/base-handler.d.ts",
|
|
1370
|
+
"require": "./cjs/services/swap-service/handler/base-handler.js",
|
|
1371
|
+
"default": "./services/swap-service/handler/base-handler.js"
|
|
1372
|
+
},
|
|
1373
|
+
"./services/swap-service/handler/chainflip-handler": {
|
|
1374
|
+
"types": "./services/swap-service/handler/chainflip-handler.d.ts",
|
|
1375
|
+
"require": "./cjs/services/swap-service/handler/chainflip-handler.js",
|
|
1376
|
+
"default": "./services/swap-service/handler/chainflip-handler.js"
|
|
1377
|
+
},
|
|
1378
|
+
"./services/swap-service/handler/hydradx-handler": {
|
|
1379
|
+
"types": "./services/swap-service/handler/hydradx-handler.d.ts",
|
|
1380
|
+
"require": "./cjs/services/swap-service/handler/hydradx-handler.js",
|
|
1381
|
+
"default": "./services/swap-service/handler/hydradx-handler.js"
|
|
1382
|
+
},
|
|
1383
|
+
"./services/swap-service/utils": {
|
|
1384
|
+
"types": "./services/swap-service/utils.d.ts",
|
|
1385
|
+
"require": "./cjs/services/swap-service/utils.js",
|
|
1386
|
+
"default": "./services/swap-service/utils.js"
|
|
1387
|
+
},
|
|
1358
1388
|
"./services/transaction-service": {
|
|
1359
1389
|
"types": "./services/transaction-service/index.d.ts",
|
|
1360
1390
|
"require": "./cjs/services/transaction-service/index.js",
|
|
@@ -1560,11 +1590,31 @@
|
|
|
1560
1590
|
"require": "./cjs/types/fee/index.js",
|
|
1561
1591
|
"default": "./types/fee/index.js"
|
|
1562
1592
|
},
|
|
1593
|
+
"./types/fee/evm": {
|
|
1594
|
+
"types": "./types/fee/evm.d.ts",
|
|
1595
|
+
"require": "./cjs/types/fee/evm.js",
|
|
1596
|
+
"default": "./types/fee/evm.js"
|
|
1597
|
+
},
|
|
1598
|
+
"./types/fee/fee": {
|
|
1599
|
+
"types": "./types/fee/fee.d.ts",
|
|
1600
|
+
"require": "./cjs/types/fee/fee.js",
|
|
1601
|
+
"default": "./types/fee/fee.js"
|
|
1602
|
+
},
|
|
1563
1603
|
"./types/ordinal": {
|
|
1564
1604
|
"types": "./types/ordinal.d.ts",
|
|
1565
1605
|
"require": "./cjs/types/ordinal.js",
|
|
1566
1606
|
"default": "./types/ordinal.js"
|
|
1567
1607
|
},
|
|
1608
|
+
"./types/service-base": {
|
|
1609
|
+
"types": "./types/service-base.d.ts",
|
|
1610
|
+
"require": "./cjs/types/service-base.js",
|
|
1611
|
+
"default": "./types/service-base.js"
|
|
1612
|
+
},
|
|
1613
|
+
"./types/swap": {
|
|
1614
|
+
"types": "./types/swap/index.d.ts",
|
|
1615
|
+
"require": "./cjs/types/swap/index.js",
|
|
1616
|
+
"default": "./types/swap/index.js"
|
|
1617
|
+
},
|
|
1568
1618
|
"./types/transaction": {
|
|
1569
1619
|
"types": "./types/transaction.d.ts",
|
|
1570
1620
|
"require": "./cjs/types/transaction.js",
|
|
@@ -1781,6 +1831,11 @@
|
|
|
1781
1831
|
"./utils/staticData/crowdloanFunds.json": "./utils/staticData/crowdloanFunds.json",
|
|
1782
1832
|
"./utils/staticData/marketingCampaigns.json": "./utils/staticData/marketingCampaigns.json",
|
|
1783
1833
|
"./utils/staticData/termAndCondition.json": "./utils/staticData/termAndCondition.json",
|
|
1834
|
+
"./utils/swap": {
|
|
1835
|
+
"types": "./utils/swap.d.ts",
|
|
1836
|
+
"require": "./cjs/utils/swap.js",
|
|
1837
|
+
"default": "./utils/swap.js"
|
|
1838
|
+
},
|
|
1784
1839
|
"./utils/translate": {
|
|
1785
1840
|
"types": "./utils/translate.d.ts",
|
|
1786
1841
|
"require": "./cjs/utils/translate.js",
|
|
@@ -1791,38 +1846,40 @@
|
|
|
1791
1846
|
"@acala-network/api": "^5.0.2",
|
|
1792
1847
|
"@apollo/client": "^3.7.14",
|
|
1793
1848
|
"@azns/resolver-core": "^1.4.0",
|
|
1849
|
+
"@chainflip/sdk": "^1.3.0",
|
|
1794
1850
|
"@equilab/api": "~1.14.25",
|
|
1795
1851
|
"@ethereumjs/common": "^4.1.0",
|
|
1796
1852
|
"@ethereumjs/tx": "^5.1.0",
|
|
1797
1853
|
"@ethersproject/abi": "^5.7.0",
|
|
1854
|
+
"@galacticcouncil/sdk": "^2.1.0",
|
|
1798
1855
|
"@json-rpc-tools/utils": "^1.7.6",
|
|
1799
1856
|
"@metamask/safe-event-emitter": "^2.0.0",
|
|
1800
1857
|
"@metaverse-network-sdk/type-definitions": "^0.0.1-13",
|
|
1801
1858
|
"@oak-foundation/types": "^0.0.23",
|
|
1802
|
-
"@polkadot/api": "^10.
|
|
1859
|
+
"@polkadot/api": "^10.12.4",
|
|
1803
1860
|
"@polkadot/api-base": "^10.11.2",
|
|
1804
|
-
"@polkadot/api-contract": "^10.
|
|
1805
|
-
"@polkadot/api-derive": "^10.
|
|
1806
|
-
"@polkadot/apps-config": "^0.
|
|
1861
|
+
"@polkadot/api-contract": "^10.12.4",
|
|
1862
|
+
"@polkadot/api-derive": "^10.12.4",
|
|
1863
|
+
"@polkadot/apps-config": "^0.135.1",
|
|
1807
1864
|
"@polkadot/hw-ledger": "^12.6.2",
|
|
1808
1865
|
"@polkadot/networks": "^12.6.2",
|
|
1809
|
-
"@polkadot/phishing": "^0.22.
|
|
1810
|
-
"@polkadot/rpc-provider": "^10.
|
|
1811
|
-
"@polkadot/types": "^10.
|
|
1812
|
-
"@polkadot/types-augment": "^10.
|
|
1813
|
-
"@polkadot/ui-settings": "^3.6.
|
|
1866
|
+
"@polkadot/phishing": "^0.22.4",
|
|
1867
|
+
"@polkadot/rpc-provider": "^10.12.4",
|
|
1868
|
+
"@polkadot/types": "^10.12.4",
|
|
1869
|
+
"@polkadot/types-augment": "^10.12.4",
|
|
1870
|
+
"@polkadot/ui-settings": "^3.6.5",
|
|
1814
1871
|
"@polkadot/util": "^12.6.2",
|
|
1815
1872
|
"@polkadot/util-crypto": "^12.6.2",
|
|
1816
1873
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1817
1874
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1818
|
-
"@substrate/connect": "^0.
|
|
1819
|
-
"@subwallet/chain-list": "0.2.
|
|
1820
|
-
"@subwallet/extension-base": "^1.1.
|
|
1821
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1822
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1823
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1824
|
-
"@subwallet/keyring": "^0.1.
|
|
1825
|
-
"@subwallet/ui-keyring": "^0.1.
|
|
1875
|
+
"@substrate/connect": "^0.8.9",
|
|
1876
|
+
"@subwallet/chain-list": "0.2.56",
|
|
1877
|
+
"@subwallet/extension-base": "^1.1.56-0",
|
|
1878
|
+
"@subwallet/extension-chains": "^1.1.56-0",
|
|
1879
|
+
"@subwallet/extension-dapp": "^1.1.56-0",
|
|
1880
|
+
"@subwallet/extension-inject": "^1.1.56-0",
|
|
1881
|
+
"@subwallet/keyring": "^0.1.5",
|
|
1882
|
+
"@subwallet/ui-keyring": "^0.1.5",
|
|
1826
1883
|
"@walletconnect/sign-client": "^2.8.4",
|
|
1827
1884
|
"@walletconnect/types": "^2.8.4",
|
|
1828
1885
|
"@walletconnect/utils": "^2.8.4",
|
package/packageInfo.js
CHANGED
|
@@ -7,5 +7,5 @@ export const packageInfo = {
|
|
|
7
7
|
name: '@subwallet/extension-base',
|
|
8
8
|
path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto',
|
|
9
9
|
type: 'esm',
|
|
10
|
-
version: '1.1.
|
|
10
|
+
version: '1.1.56-0'
|
|
11
11
|
};
|
|
@@ -185,7 +185,8 @@ export class BalanceService {
|
|
|
185
185
|
const chainInfoMap = this.state.chainService.getChainInfoMap();
|
|
186
186
|
const evmApiMap = this.state.chainService.getEvmApiMap();
|
|
187
187
|
const substrateApiMap = this.state.chainService.getSubstrateApiMap();
|
|
188
|
-
|
|
188
|
+
let unsub = noop;
|
|
189
|
+
unsub = subscribeBalance([address], [chain], [tSlug], assetMap, chainInfoMap, substrateApiMap, evmApiMap, result => {
|
|
189
190
|
const rs = result[0];
|
|
190
191
|
if (rs.tokenSlug === tSlug) {
|
|
191
192
|
hasError = false;
|
|
@@ -197,15 +198,17 @@ export class BalanceService {
|
|
|
197
198
|
if (callback) {
|
|
198
199
|
callback(balance);
|
|
199
200
|
} else {
|
|
201
|
+
var _unsub;
|
|
200
202
|
// Auto unsubscribe if no callback
|
|
201
|
-
unsub();
|
|
203
|
+
(_unsub = unsub) === null || _unsub === void 0 ? void 0 : _unsub();
|
|
202
204
|
}
|
|
203
205
|
resolve([unsub, balance]);
|
|
204
206
|
}
|
|
205
207
|
});
|
|
206
208
|
setTimeout(() => {
|
|
207
209
|
if (hasError) {
|
|
208
|
-
|
|
210
|
+
var _unsub2;
|
|
211
|
+
(_unsub2 = unsub) === null || _unsub2 === void 0 ? void 0 : _unsub2();
|
|
209
212
|
reject(new Error(t('Failed to get balance. Please check your internet connection or change your network endpoint')));
|
|
210
213
|
}
|
|
211
214
|
}, 9999);
|
package/services/base/types.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { OptimalProcessParams, OptimalProcessResult } from '@subwallet/extension-base/types/service-base';
|
|
1
2
|
import { PromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
2
3
|
export declare enum ServiceStatus {
|
|
3
4
|
NOT_INITIALIZED = "not_initialized",
|
|
@@ -32,3 +33,6 @@ export interface CronServiceInterface {
|
|
|
32
33
|
startCron: () => Promise<void>;
|
|
33
34
|
stopCron: () => Promise<void>;
|
|
34
35
|
}
|
|
36
|
+
export interface ServiceWithProcessInterface {
|
|
37
|
+
generateOptimalProcess(params: OptimalProcessParams): Promise<OptimalProcessResult>;
|
|
38
|
+
}
|
|
@@ -28,7 +28,7 @@ export const _BALANCE_CHAIN_GROUP = {
|
|
|
28
28
|
kintsugi: ['kintsugi', 'interlay', 'kintsugi_test', 'mangatax_para'],
|
|
29
29
|
genshiro: ['genshiro_testnet', 'genshiro'],
|
|
30
30
|
equilibrium_parachain: ['equilibrium_parachain'],
|
|
31
|
-
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'pendulum', 'amplitude', 'continuum_network'],
|
|
31
|
+
bifrost: ['bifrost', 'acala', 'karura', 'acala_testnet', 'pioneer', 'bitcountry', 'bifrost_dot', 'hydradx_main', 'hydradx_rococo', 'pendulum', 'amplitude', 'continuum_network'],
|
|
32
32
|
statemine: ['statemine', 'astar', 'shiden', 'statemint', 'moonbeam', 'moonbase', 'moonriver', 'crabParachain', 'darwinia2', 'parallel', 'calamari', 'manta_network', 'rococo_assethub', 'liberlandTest', 'liberland', 'dentnet', 'pangolin', 'crust', 'phala', 'shibuya'],
|
|
33
33
|
kusama: ['kusama', 'kintsugi', 'kintsugi_test', 'interlay', 'acala', 'statemint', 'karura', 'bifrost'],
|
|
34
34
|
// perhaps there are some runtime updates
|
|
@@ -71,7 +71,8 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
71
71
|
shiden: 24,
|
|
72
72
|
shibuya: 24,
|
|
73
73
|
bifrost_testnet: 0.5,
|
|
74
|
-
bifrost:
|
|
74
|
+
bifrost: 13 * 600 / 3600,
|
|
75
|
+
// real blocktime of bifros ksm = 13s
|
|
75
76
|
bifrost_dot: 24,
|
|
76
77
|
ternoa: 24,
|
|
77
78
|
calamari: 6,
|
|
@@ -88,7 +89,8 @@ export const _STAKING_ERA_LENGTH_MAP = {
|
|
|
88
89
|
goldberg_testnet: 24,
|
|
89
90
|
manta_network: 6,
|
|
90
91
|
krest_network: 4,
|
|
91
|
-
polimec: 6
|
|
92
|
+
polimec: 6,
|
|
93
|
+
enjin_relaychain: 24
|
|
92
94
|
};
|
|
93
95
|
export const _EXPECTED_BLOCK_TIME = {
|
|
94
96
|
// in seconds
|
|
@@ -105,7 +107,19 @@ export const _EXPECTED_BLOCK_TIME = {
|
|
|
105
107
|
creditcoin: 12,
|
|
106
108
|
vara_network: 3,
|
|
107
109
|
goldberg_testnet: 20,
|
|
108
|
-
polimec: 12
|
|
110
|
+
polimec: 12,
|
|
111
|
+
bifrost: 13,
|
|
112
|
+
// expect 12 but actual 13
|
|
113
|
+
moonbeam: 12,
|
|
114
|
+
moonriver: 12,
|
|
115
|
+
moonbase: 6,
|
|
116
|
+
turing: 12,
|
|
117
|
+
turingStaging: 12,
|
|
118
|
+
bifrost_testnet: 3,
|
|
119
|
+
calamari: 12,
|
|
120
|
+
calamari_test: 12,
|
|
121
|
+
manta_network: 12,
|
|
122
|
+
enjin_relaychain: 6
|
|
109
123
|
};
|
|
110
124
|
export const _PARACHAIN_INFLATION_DISTRIBUTION = {
|
|
111
125
|
moonbeam: {
|
|
@@ -23,6 +23,7 @@ export declare class ChainService {
|
|
|
23
23
|
private assetRegistrySubject;
|
|
24
24
|
private multiChainAssetMapSubject;
|
|
25
25
|
private xcmRefMapSubject;
|
|
26
|
+
private swapRefMapSubject;
|
|
26
27
|
private assetLogoMapSubject;
|
|
27
28
|
private chainLogoMapSubject;
|
|
28
29
|
private assetMapPatch;
|
|
@@ -31,7 +32,9 @@ export declare class ChainService {
|
|
|
31
32
|
private assetSettingSubject;
|
|
32
33
|
private logger;
|
|
33
34
|
constructor(dbService: DatabaseService, eventService: EventService);
|
|
35
|
+
subscribeSwapRefMap(): Subject<Record<string, _AssetRef>>;
|
|
34
36
|
get xcmRefMap(): Record<string, _AssetRef>;
|
|
37
|
+
get swapRefMap(): Record<string, _AssetRef>;
|
|
35
38
|
getEvmApi(slug: string): import("./handler/EvmApi").EvmApi;
|
|
36
39
|
getEvmApiMap(): Record<string, import("./handler/EvmApi").EvmApi>;
|
|
37
40
|
getSubstrateApiMap(): Record<string, import("./handler/SubstrateApi").SubstrateApi>;
|
|
@@ -139,4 +142,5 @@ export declare class ChainService {
|
|
|
139
142
|
getMetadataByHash(hash: string): import("dexie").PromiseExtended<IMetadataItem | undefined>;
|
|
140
143
|
getSubscanChainMap(reverse?: boolean): Record<string, string>;
|
|
141
144
|
get detectBalanceChainSlugMap(): Record<string, string>;
|
|
145
|
+
getFeeTokensByChain(chainSlug: string): string[];
|
|
142
146
|
}
|
|
@@ -9,7 +9,7 @@ import { MantaPrivateHandler } from '@subwallet/extension-base/services/chain-se
|
|
|
9
9
|
import { SubstrateChainHandler } from '@subwallet/extension-base/services/chain-service/handler/SubstrateChainHandler';
|
|
10
10
|
import { _CHAIN_VALIDATION_ERROR } from '@subwallet/extension-base/services/chain-service/handler/types';
|
|
11
11
|
import { _ChainConnectionStatus, _CUSTOM_PREFIX, _NFT_CONTRACT_STANDARDS, _SMART_CONTRACT_STANDARDS } from '@subwallet/extension-base/services/chain-service/types';
|
|
12
|
-
import { _isAssetAutoEnable, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, fetchPatchData, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
12
|
+
import { _isAssetAutoEnable, _isAssetCanPayTxFee, _isAssetFungibleToken, _isChainEnabled, _isCustomAsset, _isCustomChain, _isCustomProvider, _isEqualContractAddress, _isEqualSmartContractAsset, _isMantaZkAsset, _isPureEvmChain, _isPureSubstrateChain, _parseAssetRefKey, fetchPatchData, randomizeProvider, updateLatestChainInfo } from '@subwallet/extension-base/services/chain-service/utils';
|
|
13
13
|
import AssetSettingStore from '@subwallet/extension-base/stores/AssetSetting';
|
|
14
14
|
import { addLazy, fetchStaticData, filterAssetsByChainAndType, MODULE_SUPPORT } from '@subwallet/extension-base/utils';
|
|
15
15
|
import { BehaviorSubject, Subject } from 'rxjs';
|
|
@@ -35,6 +35,7 @@ export class ChainService {
|
|
|
35
35
|
assetRegistrySubject = new Subject();
|
|
36
36
|
multiChainAssetMapSubject = new Subject();
|
|
37
37
|
xcmRefMapSubject = new Subject();
|
|
38
|
+
swapRefMapSubject = new Subject();
|
|
38
39
|
assetLogoMapSubject = new BehaviorSubject(AssetLogoMap);
|
|
39
40
|
chainLogoMapSubject = new BehaviorSubject(ChainLogoMap);
|
|
40
41
|
assetMapPatch = JSON.stringify({});
|
|
@@ -50,6 +51,7 @@ export class ChainService {
|
|
|
50
51
|
this.chainStateMapSubject.next(this.dataMap.chainStateMap);
|
|
51
52
|
this.assetRegistrySubject.next(this.dataMap.assetRegistry);
|
|
52
53
|
this.xcmRefMapSubject.next(this.xcmRefMap);
|
|
54
|
+
this.swapRefMapSubject.next(this.swapRefMap);
|
|
53
55
|
if (MODULE_SUPPORT.MANTA_ZK) {
|
|
54
56
|
console.log('Init Manta ZK');
|
|
55
57
|
this.mantaChainHandler = new MantaPrivateHandler(dbService);
|
|
@@ -58,6 +60,9 @@ export class ChainService {
|
|
|
58
60
|
this.evmChainHandler = new EvmChainHandler(this);
|
|
59
61
|
this.logger = createLogger('chain-service');
|
|
60
62
|
}
|
|
63
|
+
subscribeSwapRefMap() {
|
|
64
|
+
return this.swapRefMapSubject;
|
|
65
|
+
}
|
|
61
66
|
|
|
62
67
|
// Getter
|
|
63
68
|
get xcmRefMap() {
|
|
@@ -69,6 +74,15 @@ export class ChainService {
|
|
|
69
74
|
});
|
|
70
75
|
return result;
|
|
71
76
|
}
|
|
77
|
+
get swapRefMap() {
|
|
78
|
+
const result = {};
|
|
79
|
+
Object.entries(this.dataMap.assetRefMap).forEach(([key, assetRef]) => {
|
|
80
|
+
if (assetRef.path === _AssetRefPath.SWAP) {
|
|
81
|
+
result[key] = assetRef;
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
72
86
|
getEvmApi(slug) {
|
|
73
87
|
return this.evmChainHandler.getEvmApiByChain(slug);
|
|
74
88
|
}
|
|
@@ -481,6 +495,7 @@ export class ChainService {
|
|
|
481
495
|
});
|
|
482
496
|
this.dataMap.assetRefMap = updatedAssetRefMap;
|
|
483
497
|
this.xcmRefMapSubject.next(this.xcmRefMap);
|
|
498
|
+
this.swapRefMapSubject.next(this.swapRefMap);
|
|
484
499
|
this.logger.log('Finished updating latest asset ref');
|
|
485
500
|
}
|
|
486
501
|
handleLatestPriceId(latestPriceIds) {
|
|
@@ -1610,4 +1625,9 @@ export class ChainService {
|
|
|
1610
1625
|
}
|
|
1611
1626
|
return result;
|
|
1612
1627
|
}
|
|
1628
|
+
getFeeTokensByChain(chainSlug) {
|
|
1629
|
+
return Object.values(this.getAssetRegistry()).filter(chainAsset => {
|
|
1630
|
+
return chainAsset.originChain === chainSlug && (chainAsset.assetType === _AssetType.NATIVE || _isAssetCanPayTxFee(chainAsset));
|
|
1631
|
+
}).map(chainAsset => chainAsset.slug);
|
|
1632
|
+
}
|
|
1613
1633
|
}
|
|
@@ -51,14 +51,15 @@ export declare function _isSubstrateRelayChain(chainInfo: _ChainInfo): boolean;
|
|
|
51
51
|
export declare function _isSubstrateParaChain(chainInfo: _ChainInfo): boolean;
|
|
52
52
|
export declare function _getEvmAbiExplorer(chainInfo: _ChainInfo): string;
|
|
53
53
|
export declare function _isAssetValuable(assetInfo: _ChainAsset): boolean;
|
|
54
|
-
export declare function _getMultiChainAsset(assetInfo
|
|
55
|
-
export declare function _getAssetPriceId(assetInfo
|
|
54
|
+
export declare function _getMultiChainAsset(assetInfo?: _ChainAsset): string;
|
|
55
|
+
export declare function _getAssetPriceId(assetInfo?: _ChainAsset): string;
|
|
56
|
+
export declare function _getAssetName(assetInfo?: _ChainAsset): string;
|
|
56
57
|
export declare function _getMultiChainAssetPriceId(multiChainAsset: _MultiChainAsset): string;
|
|
57
|
-
export declare function _getAssetSymbol(assetInfo
|
|
58
|
+
export declare function _getAssetSymbol(assetInfo?: _ChainAsset): string;
|
|
58
59
|
export declare function _getMultiChainAssetSymbol(multiChainAsset: _MultiChainAsset): string;
|
|
59
|
-
export declare function _getAssetOriginChain(assetInfo
|
|
60
|
+
export declare function _getAssetOriginChain(assetInfo?: _ChainAsset): string;
|
|
60
61
|
export declare function _getChainName(chainInfo: _ChainInfo): string;
|
|
61
|
-
export declare function _getAssetDecimals(assetInfo
|
|
62
|
+
export declare function _getAssetDecimals(assetInfo?: _ChainAsset): number;
|
|
62
63
|
export declare function _getBlockExplorerFromChain(chainInfo: _ChainInfo): string | undefined;
|
|
63
64
|
export declare function _parseMetadataForSmartContractAsset(contractAddress: string): Record<string, string>;
|
|
64
65
|
export declare function _isChainTestNet(chainInfo: _ChainInfo): boolean;
|
|
@@ -74,6 +75,7 @@ export declare function randomizeProvider(providers: Record<string, string>, exc
|
|
|
74
75
|
providerKey: string;
|
|
75
76
|
providerValue: string;
|
|
76
77
|
};
|
|
78
|
+
export declare function _isAssetCanPayTxFee(chainAsset: _ChainAsset): boolean;
|
|
77
79
|
export declare function updateLatestChainInfo(currentDataMap: _DataMap, latestChainInfoList: _ChainInfo[]): {
|
|
78
80
|
storedChainInfoList: IChain[];
|
|
79
81
|
needUpdateChainApiList: _ChainInfo[];
|
|
@@ -280,6 +280,9 @@ export function _getMultiChainAsset(assetInfo) {
|
|
|
280
280
|
export function _getAssetPriceId(assetInfo) {
|
|
281
281
|
return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.priceId) || '';
|
|
282
282
|
}
|
|
283
|
+
export function _getAssetName(assetInfo) {
|
|
284
|
+
return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.name) || '';
|
|
285
|
+
}
|
|
283
286
|
export function _getMultiChainAssetPriceId(multiChainAsset) {
|
|
284
287
|
return (multiChainAsset === null || multiChainAsset === void 0 ? void 0 : multiChainAsset.priceId) || '';
|
|
285
288
|
}
|
|
@@ -290,13 +293,13 @@ export function _getMultiChainAssetSymbol(multiChainAsset) {
|
|
|
290
293
|
return multiChainAsset.symbol;
|
|
291
294
|
}
|
|
292
295
|
export function _getAssetOriginChain(assetInfo) {
|
|
293
|
-
return assetInfo.originChain;
|
|
296
|
+
return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.originChain) || '';
|
|
294
297
|
}
|
|
295
298
|
export function _getChainName(chainInfo) {
|
|
296
299
|
return chainInfo.name;
|
|
297
300
|
}
|
|
298
301
|
export function _getAssetDecimals(assetInfo) {
|
|
299
|
-
return assetInfo.decimals || 0;
|
|
302
|
+
return (assetInfo === null || assetInfo === void 0 ? void 0 : assetInfo.decimals) || 0;
|
|
300
303
|
}
|
|
301
304
|
export function _getBlockExplorerFromChain(chainInfo) {
|
|
302
305
|
let blockExplorer;
|
|
@@ -395,6 +398,10 @@ export function randomizeProvider(providers, excludedKeys) {
|
|
|
395
398
|
providerValue: selectedProviderValue
|
|
396
399
|
};
|
|
397
400
|
}
|
|
401
|
+
export function _isAssetCanPayTxFee(chainAsset) {
|
|
402
|
+
var _ref, _chainAsset$metadata;
|
|
403
|
+
return (_ref = (_chainAsset$metadata = chainAsset.metadata) === null || _chainAsset$metadata === void 0 ? void 0 : _chainAsset$metadata.canPayTxFee) !== null && _ref !== void 0 ? _ref : false;
|
|
404
|
+
}
|
|
398
405
|
export function updateLatestChainInfo(currentDataMap, latestChainInfoList) {
|
|
399
406
|
const currentChainInfoMap = currentDataMap.chainInfoMap;
|
|
400
407
|
const currentChainStateMap = currentDataMap.chainStateMap;
|
|
@@ -5,7 +5,7 @@ import fetch from 'cross-fetch';
|
|
|
5
5
|
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
6
|
const branchName = process.env.BRANCH_NAME || 'subwallet-dev';
|
|
7
7
|
const fetchDomain = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://chain-list-assets.subwallet.app' : 'https://dev.sw-chain-list-assets.pages.dev';
|
|
8
|
-
const ChainListVersion = '0.2.
|
|
8
|
+
const ChainListVersion = '0.2.55';
|
|
9
9
|
export async function fetchPatchData(slug) {
|
|
10
10
|
try {
|
|
11
11
|
const fetchPromise = fetch(`${fetchDomain}/patch/${ChainListVersion}/${slug}`);
|
|
@@ -13,6 +13,7 @@ export declare const _STAKING_CHAIN_GROUP: {
|
|
|
13
13
|
krest_network: string[];
|
|
14
14
|
manta: string[];
|
|
15
15
|
};
|
|
16
|
+
export declare const MaxEraRewardPointsEras = 14;
|
|
16
17
|
export declare const ST_LIQUID_TOKEN_ABI: Record<string, any>;
|
|
17
18
|
export declare const MANTA_VALIDATOR_POINTS_PER_BLOCK = 20;
|
|
18
19
|
export declare const MANTA_MIN_DELEGATION = 500;
|
|
@@ -18,6 +18,7 @@ export const _STAKING_CHAIN_GROUP = {
|
|
|
18
18
|
krest_network: ['krest_network'],
|
|
19
19
|
manta: ['manta_network']
|
|
20
20
|
};
|
|
21
|
+
export const MaxEraRewardPointsEras = 14;
|
|
21
22
|
|
|
22
23
|
// eslint-disable-next-line @typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment
|
|
23
24
|
export const ST_LIQUID_TOKEN_ABI = require("./abis/st_liquid_token_abi.json");
|
|
@@ -130,27 +130,25 @@ export default class AmplitudeNativeStakingPoolHandler extends BaseParaNativeSta
|
|
|
130
130
|
});
|
|
131
131
|
}
|
|
132
132
|
if (hasUnstakingInfo) {
|
|
133
|
-
const
|
|
134
|
-
const
|
|
135
|
-
const
|
|
133
|
+
const [_currentBlock, _currentTimestamp] = await Promise.all([substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
|
|
134
|
+
const currentBlock = _currentBlock.toPrimitive();
|
|
135
|
+
const currentTimestamp = _currentTimestamp.toPrimitive();
|
|
136
136
|
const _blockPerRound = substrateApi.api.consts.parachainStaking.defaultBlocksPerRound.toString();
|
|
137
137
|
const blockPerRound = parseFloat(_blockPerRound);
|
|
138
138
|
for (const [unstakingBlock, unstakingAmount] of Object.entries(unstakingInfo)) {
|
|
139
139
|
const blockDuration = (_STAKING_ERA_LENGTH_MAP[chainInfo.slug] || _STAKING_ERA_LENGTH_MAP.default) / blockPerRound; // in hours
|
|
140
140
|
|
|
141
|
-
const isClaimable = parseInt(unstakingBlock) -
|
|
142
|
-
const remainingBlock = parseInt(unstakingBlock) -
|
|
141
|
+
const isClaimable = parseInt(unstakingBlock) - currentBlock <= 0;
|
|
142
|
+
const remainingBlock = parseInt(unstakingBlock) - currentBlock;
|
|
143
143
|
const waitingTime = remainingBlock * blockDuration;
|
|
144
|
-
|
|
145
|
-
// const targetTimestampMs = currentTimestampMs + waitingTime * 60 * 60 * 1000;
|
|
146
|
-
|
|
144
|
+
const targetTimestampMs = remainingBlock * blockDuration * 3600 * 1000 + currentTimestamp;
|
|
147
145
|
unstakingBalance = unstakingAmount.toString();
|
|
148
146
|
unstakingList.push({
|
|
149
147
|
chain: chainInfo.slug,
|
|
150
148
|
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
151
149
|
claimable: unstakingAmount.toString(),
|
|
152
150
|
waitingTime,
|
|
153
|
-
|
|
151
|
+
targetTimestampMs: targetTimestampMs,
|
|
154
152
|
validatorAddress: undefined
|
|
155
153
|
});
|
|
156
154
|
}
|
|
@@ -242,11 +242,12 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
|
|
|
242
242
|
};
|
|
243
243
|
}
|
|
244
244
|
async subscribePoolPosition(useAddresses, resultCallback) {
|
|
245
|
+
var _substrateApi$api$que;
|
|
245
246
|
let cancel = false;
|
|
246
247
|
const substrateApi = await this.substrateApi.isReady;
|
|
247
248
|
const defaultInfo = this.baseInfo;
|
|
248
249
|
const chainInfo = this.chainInfo;
|
|
249
|
-
const unsub = await substrateApi.api.query.dappsStaking.ledger.multi(useAddresses, async ledgers => {
|
|
250
|
+
const unsub = await ((_substrateApi$api$que = substrateApi.api.query.dappsStaking) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.ledger.multi(useAddresses, async ledgers => {
|
|
250
251
|
if (cancel) {
|
|
251
252
|
unsub();
|
|
252
253
|
return;
|
|
@@ -280,10 +281,10 @@ export default class AstarNativeStakingPoolHandler extends BaseParaNativeStaking
|
|
|
280
281
|
}
|
|
281
282
|
}));
|
|
282
283
|
}
|
|
283
|
-
});
|
|
284
|
+
}));
|
|
284
285
|
return () => {
|
|
285
286
|
cancel = true;
|
|
286
|
-
unsub();
|
|
287
|
+
unsub && unsub();
|
|
287
288
|
};
|
|
288
289
|
}
|
|
289
290
|
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import { TransactionError } from '@subwallet/extension-base/background/errors/TransactionError';
|
|
5
5
|
import { BasicTxErrorType, ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
6
6
|
import { getBondedValidators, getEarningStatusByNominations, getParaCurrentInflation, isUnstakeAll } from '@subwallet/extension-base/koni/api/staking/bonding/utils';
|
|
7
|
-
import { _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
7
|
+
import { _EXPECTED_BLOCK_TIME, _STAKING_ERA_LENGTH_MAP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
8
8
|
import { _STAKING_CHAIN_GROUP, MANTA_MIN_DELEGATION, MANTA_VALIDATOR_POINTS_PER_BLOCK } from '@subwallet/extension-base/services/earning-service/constants';
|
|
9
9
|
import { parseIdentity } from '@subwallet/extension-base/services/earning-service/utils';
|
|
10
10
|
import { EarningStatus, UnstakingStatus } from '@subwallet/extension-base/types';
|
|
@@ -137,7 +137,9 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
137
137
|
const roundInfo = _roundInfo.toPrimitive();
|
|
138
138
|
const currentRound = roundInfo.current;
|
|
139
139
|
await Promise.all(delegatorState.delegations.map(async delegation => {
|
|
140
|
-
const [_delegationScheduledRequests, [identity], _collatorInfo] = await Promise.all([substrateApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), parseIdentity(substrateApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner)]);
|
|
140
|
+
const [_delegationScheduledRequests, [identity], _collatorInfo, _currentBlock, _currentTimestamp] = await Promise.all([substrateApi.api.query.parachainStaking.delegationScheduledRequests(delegation.owner), parseIdentity(substrateApi, delegation.owner), substrateApi.api.query.parachainStaking.candidateInfo(delegation.owner), substrateApi.api.query.system.number(), substrateApi.api.query.timestamp.now()]);
|
|
141
|
+
const currentBlock = _currentBlock.toPrimitive();
|
|
142
|
+
const currentTimestamp = _currentTimestamp.toPrimitive();
|
|
141
143
|
const collatorInfo = _collatorInfo.toPrimitive();
|
|
142
144
|
const minDelegation = collatorInfo === null || collatorInfo === void 0 ? void 0 : collatorInfo.lowestTopDelegationAmount.toString();
|
|
143
145
|
const delegationScheduledRequests = _delegationScheduledRequests.toPrimitive();
|
|
@@ -149,22 +151,23 @@ export default class ParaNativeStakingPoolHandler extends BaseParaNativeStakingP
|
|
|
149
151
|
for (const scheduledRequest of delegationScheduledRequests) {
|
|
150
152
|
if (reformatAddress(scheduledRequest.delegator, 0) === reformatAddress(address, 0)) {
|
|
151
153
|
// add network prefix
|
|
152
|
-
const isClaimable = scheduledRequest.whenExecutable - currentRound <= 0;
|
|
153
|
-
const remainingEra = scheduledRequest.whenExecutable - currentRound;
|
|
154
|
+
const isClaimable = scheduledRequest.whenExecutable - parseInt(currentRound) <= 0;
|
|
155
|
+
const remainingEra = scheduledRequest.whenExecutable - parseInt(currentRound);
|
|
154
156
|
const waitingTime = remainingEra * _STAKING_ERA_LENGTH_MAP[chainInfo.slug];
|
|
155
157
|
const claimable = Object.values(scheduledRequest.action)[0];
|
|
156
|
-
// const currentTimestampMs = Date.now();
|
|
157
|
-
// const targetTimestampMs = currentTimestampMs + waitingTime * 60 * 60 * 1000;
|
|
158
158
|
|
|
159
|
+
// noted: target timestamp in parachainStaking easily volatile if block time volatile
|
|
160
|
+
const targetBlock = remainingEra * parseInt(roundInfo.length) + parseInt(roundInfo.first);
|
|
161
|
+
const remainingBlock = targetBlock - currentBlock;
|
|
162
|
+
const targetTimestampMs = remainingBlock * _EXPECTED_BLOCK_TIME[chainInfo.slug] * 1000 + currentTimestamp;
|
|
159
163
|
unstakingMap[delegation.owner] = {
|
|
160
164
|
chain: chainInfo.slug,
|
|
161
165
|
status: isClaimable ? UnstakingStatus.CLAIMABLE : UnstakingStatus.UNLOCKING,
|
|
162
166
|
validatorAddress: delegation.owner,
|
|
163
167
|
claimable: claimable.toString(),
|
|
164
|
-
waitingTime
|
|
165
|
-
|
|
168
|
+
waitingTime,
|
|
169
|
+
targetTimestampMs: targetTimestampMs
|
|
166
170
|
};
|
|
167
|
-
|
|
168
171
|
hasUnstaking = true;
|
|
169
172
|
break; // only handle 1 scheduledRequest per collator
|
|
170
173
|
}
|