@subwallet/extension-base 1.1.55-0 → 1.1.57-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 +9 -1
- package/background/KoniTypes.js +5 -0
- package/cjs/background/KoniTypes.js +7 -1
- 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/background/handlers/State.js +20 -3
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/chain-service/constants.js +17 -3
- package/cjs/services/chain-service/index.js +9 -0
- package/cjs/services/earning-service/handlers/native-staking/amplitude.js +7 -9
- package/cjs/services/earning-service/handlers/native-staking/para-chain.js +11 -8
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +28 -7
- package/cjs/services/earning-service/handlers/nomination-pool/index.js +11 -3
- package/cjs/services/earning-service/service.js +0 -1
- package/cjs/services/earning-service/utils/index.js +2 -2
- package/cjs/utils/fetchStaticCache.js +4 -1
- 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/background/handlers/State.js +21 -4
- package/package.json +26 -26
- package/packageInfo.js +1 -1
- package/services/chain-service/constants.js +17 -3
- package/services/chain-service/index.d.ts +1 -0
- package/services/chain-service/index.js +9 -0
- package/services/earning-service/handlers/native-staking/amplitude.js +7 -9
- package/services/earning-service/handlers/native-staking/para-chain.js +12 -9
- package/services/earning-service/handlers/native-staking/relay-chain.js +28 -7
- package/services/earning-service/handlers/nomination-pool/index.js +11 -3
- package/services/earning-service/service.js +0 -1
- package/services/earning-service/utils/index.js +2 -2
- package/types/yield/info/pallet.d.ts +4 -0
- package/utils/fetchStaticCache.js +4 -1
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { AssetHubNftType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
5
|
import { BaseNftApi } from '@subwallet/extension-base/koni/api/nft/nft';
|
|
5
6
|
import { isUrl } from '@subwallet/extension-base/utils';
|
|
6
7
|
import fetch from 'cross-fetch';
|
|
7
|
-
export default class
|
|
8
|
+
export default class AssetHubUniquesPalletApi extends BaseNftApi {
|
|
8
9
|
// eslint-disable-next-line no-useless-constructor
|
|
9
10
|
constructor(api, addresses, chain) {
|
|
10
11
|
super(chain, api, addresses);
|
|
@@ -105,7 +106,8 @@ export default class StatemineNftApi extends BaseNftApi {
|
|
|
105
106
|
image: tokenInfo && tokenInfo.image ? this.parseUrl(tokenInfo === null || tokenInfo === void 0 ? void 0 : tokenInfo.image) : undefined,
|
|
106
107
|
collectionId: this.parseTokenId(parsedClassId),
|
|
107
108
|
chain: this.chain,
|
|
108
|
-
owner: address
|
|
109
|
+
owner: address,
|
|
110
|
+
assetHubType: AssetHubNftType.UNIQUES
|
|
109
111
|
};
|
|
110
112
|
params.updateItem(this.chain, parsedNft, address);
|
|
111
113
|
const parsedCollection = {
|
package/koni/api/nft/index.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { AcalaNftApi } from '@subwallet/extension-base/koni/api/nft/acala_nft';
|
|
5
|
+
import AssetHubUniquesPalletApi from '@subwallet/extension-base/koni/api/nft/assethub_unique';
|
|
5
6
|
import { BitCountryNftApi } from '@subwallet/extension-base/koni/api/nft/bit.country';
|
|
6
7
|
import { EvmNftApi } from '@subwallet/extension-base/koni/api/nft/evm_nft';
|
|
7
8
|
import { KaruraNftApi } from '@subwallet/extension-base/koni/api/nft/karura_nft';
|
|
8
9
|
import OrdinalNftApi from '@subwallet/extension-base/koni/api/nft/ordinal_nft';
|
|
9
10
|
import { RmrkNftApi } from '@subwallet/extension-base/koni/api/nft/rmrk_nft';
|
|
10
|
-
import StatemineNftApi from '@subwallet/extension-base/koni/api/nft/statemine_nft';
|
|
11
11
|
import { UniqueNftApi } from '@subwallet/extension-base/koni/api/nft/unique_network_nft';
|
|
12
12
|
// import UniqueNftApi from '@subwallet/extension-base/koni/api/nft/unique_nft';
|
|
13
13
|
import { VaraNftApi } from '@subwallet/extension-base/koni/api/nft/vara_nft';
|
|
@@ -15,25 +15,25 @@ import { WasmNftApi } from '@subwallet/extension-base/koni/api/nft/wasm_nft';
|
|
|
15
15
|
import { _NFT_CHAIN_GROUP } from '@subwallet/extension-base/services/chain-service/constants';
|
|
16
16
|
import { _isChainSupportEvmNft, _isChainSupportNativeNft, _isChainSupportWasmNft, _isSupportOrdinal } from '@subwallet/extension-base/services/chain-service/utils';
|
|
17
17
|
import { categoryAddresses, targetIsWeb } from '@subwallet/extension-base/utils';
|
|
18
|
-
import
|
|
18
|
+
import AssetHubNftsPalletApi from "./assethub_nft/index.js";
|
|
19
19
|
function createSubstrateNftApi(chain, substrateApi, addresses) {
|
|
20
20
|
const [substrateAddresses] = categoryAddresses(addresses);
|
|
21
21
|
if (_NFT_CHAIN_GROUP.acala.includes(chain)) {
|
|
22
|
-
return new AcalaNftApi(substrateApi, substrateAddresses, chain);
|
|
22
|
+
return [new AcalaNftApi(substrateApi, substrateAddresses, chain)];
|
|
23
23
|
} else if (_NFT_CHAIN_GROUP.karura.includes(chain)) {
|
|
24
|
-
return new KaruraNftApi(substrateApi, substrateAddresses, chain);
|
|
24
|
+
return [new KaruraNftApi(substrateApi, substrateAddresses, chain)];
|
|
25
25
|
} else if (_NFT_CHAIN_GROUP.rmrk.includes(chain)) {
|
|
26
|
-
return new RmrkNftApi(substrateAddresses, chain);
|
|
26
|
+
return [new RmrkNftApi(substrateAddresses, chain)];
|
|
27
27
|
} else if (_NFT_CHAIN_GROUP.statemine.includes(chain)) {
|
|
28
|
-
return new
|
|
28
|
+
return [new AssetHubUniquesPalletApi(substrateApi, substrateAddresses, chain), new AssetHubNftsPalletApi(substrateApi, substrateAddresses, chain)];
|
|
29
29
|
} else if (_NFT_CHAIN_GROUP.statemint.includes(chain)) {
|
|
30
|
-
return new
|
|
30
|
+
return [new AssetHubUniquesPalletApi(substrateApi, substrateAddresses, chain), new AssetHubNftsPalletApi(substrateApi, substrateAddresses, chain)];
|
|
31
31
|
} else if (_NFT_CHAIN_GROUP.unique_network.includes(chain)) {
|
|
32
|
-
return new UniqueNftApi(chain, substrateAddresses);
|
|
32
|
+
return [new UniqueNftApi(chain, substrateAddresses)];
|
|
33
33
|
} else if (_NFT_CHAIN_GROUP.bitcountry.includes(chain)) {
|
|
34
|
-
return new BitCountryNftApi(substrateApi, substrateAddresses, chain);
|
|
34
|
+
return [new BitCountryNftApi(substrateApi, substrateAddresses, chain)];
|
|
35
35
|
} else if (_NFT_CHAIN_GROUP.vara.includes(chain)) {
|
|
36
|
-
return new VaraNftApi(chain, substrateAddresses);
|
|
36
|
+
return [new VaraNftApi(chain, substrateAddresses)];
|
|
37
37
|
}
|
|
38
38
|
return null;
|
|
39
39
|
}
|
|
@@ -105,9 +105,9 @@ export class NftHandler {
|
|
|
105
105
|
Object.entries(this.chainInfoMap).forEach(([chain, chainInfo]) => {
|
|
106
106
|
if (_isChainSupportNativeNft(chainInfo)) {
|
|
107
107
|
if (this.substrateApiMap[chain]) {
|
|
108
|
-
const
|
|
109
|
-
if (
|
|
110
|
-
this.handlers.push(
|
|
108
|
+
const handlers = createSubstrateNftApi(chain, this.substrateApiMap[chain], substrateAddresses);
|
|
109
|
+
if (handlers && !!handlers.length) {
|
|
110
|
+
this.handlers.push(...handlers);
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
113
|
}
|
package/koni/api/nft/nft.js
CHANGED
|
@@ -3,6 +3,5 @@ export declare function isRecipientSelf(currentAddress: string, recipientAddress
|
|
|
3
3
|
export declare function acalaGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
4
4
|
export declare function rmrkGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
5
5
|
export declare function uniqueGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null>;
|
|
6
|
-
export declare function
|
|
7
|
-
export declare function statemintGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
6
|
+
export declare function assetHubGetExtrinsic(substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null;
|
|
8
7
|
export declare function getNftTransferExtrinsic(networkKey: string, substrateApi: _SubstrateApi, senderAddress: string, recipientAddress: string, params: Record<string, any>): Promise<import("@polkadot/api-base/types").SubmittableExtrinsic<"promise", import("@polkadot/types/types").ISubmittableResult> | null>;
|
package/koni/api/nft/transfer.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2019-2022 @subwallet/extension-koni authors & contributors
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
|
+
import { AssetHubNftType } from '@subwallet/extension-base/background/KoniTypes';
|
|
4
5
|
import { SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME } from '@subwallet/extension-base/koni/api/nft/config';
|
|
5
6
|
import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
6
7
|
export function isRecipientSelf(currentAddress, recipientAddress) {
|
|
@@ -52,21 +53,17 @@ export async function uniqueGetExtrinsic(substrateApi, senderAddress, recipientA
|
|
|
52
53
|
return null;
|
|
53
54
|
}
|
|
54
55
|
}
|
|
55
|
-
export function
|
|
56
|
+
export function assetHubGetExtrinsic(substrateApi, senderAddress, recipientAddress, params) {
|
|
56
57
|
try {
|
|
57
58
|
const itemId = params.itemId;
|
|
58
59
|
const collectionId = params.collectionId;
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
60
|
+
const nftType = params.assetHubType;
|
|
61
|
+
if (nftType === AssetHubNftType.NFTS) {
|
|
62
|
+
return substrateApi.api.tx.nfts.transfer(collectionId, itemId, recipientAddress);
|
|
63
|
+
} else if (nftType === AssetHubNftType.UNIQUES) {
|
|
64
|
+
return substrateApi.api.tx.uniques.transfer(collectionId, itemId, recipientAddress);
|
|
65
|
+
}
|
|
62
66
|
return null;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
export function statemintGetExtrinsic(substrateApi, senderAddress, recipientAddress, params) {
|
|
66
|
-
try {
|
|
67
|
-
const itemId = params.itemId;
|
|
68
|
-
const collectionId = params.collectionId;
|
|
69
|
-
return substrateApi.api.tx.nfts.transfer(collectionId, itemId, recipientAddress);
|
|
70
67
|
} catch (e) {
|
|
71
68
|
console.error(e);
|
|
72
69
|
return null;
|
|
@@ -87,9 +84,9 @@ export async function getNftTransferExtrinsic(networkKey, substrateApi, senderAd
|
|
|
87
84
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.opal:
|
|
88
85
|
return await uniqueGetExtrinsic(substrateApi, senderAddress, recipientAddress, params);
|
|
89
86
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.statemine:
|
|
90
|
-
return
|
|
87
|
+
return assetHubGetExtrinsic(substrateApi, senderAddress, recipientAddress, params);
|
|
91
88
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.statemint:
|
|
92
|
-
return
|
|
89
|
+
return assetHubGetExtrinsic(substrateApi, senderAddress, recipientAddress, params);
|
|
93
90
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.bitcountry:
|
|
94
91
|
return acalaGetExtrinsic(substrateApi, senderAddress, recipientAddress, params);
|
|
95
92
|
case SUPPORTED_TRANSFER_SUBSTRATE_CHAIN_NAME.pioneer:
|
|
@@ -32,7 +32,7 @@ import { SwapService } from '@subwallet/extension-base/services/swap-service';
|
|
|
32
32
|
import TransactionService from '@subwallet/extension-base/services/transaction-service';
|
|
33
33
|
import WalletConnectService from '@subwallet/extension-base/services/wallet-connect-service';
|
|
34
34
|
import AccountRefStore from '@subwallet/extension-base/stores/AccountRef';
|
|
35
|
-
import { isAccountAll, stripUrl, TARGET_ENV } from '@subwallet/extension-base/utils';
|
|
35
|
+
import { isAccountAll, stripUrl, TARGET_ENV, wait } from '@subwallet/extension-base/utils';
|
|
36
36
|
import { isContractAddress, parseContractInput } from '@subwallet/extension-base/utils/eth/parseTransaction';
|
|
37
37
|
import { createPromiseHandler } from '@subwallet/extension-base/utils/promise';
|
|
38
38
|
import { decodePair } from '@subwallet/keyring/pair/decode';
|
|
@@ -1204,17 +1204,34 @@ export default class KoniState {
|
|
|
1204
1204
|
maxFeePerGas: autoFormatNumber(transactionParams.maxFeePerGas),
|
|
1205
1205
|
data: transactionParams.data
|
|
1206
1206
|
};
|
|
1207
|
+
const getTransactionGas = async () => {
|
|
1208
|
+
try {
|
|
1209
|
+
transaction.gas = await web3.eth.estimateGas({
|
|
1210
|
+
...transaction
|
|
1211
|
+
});
|
|
1212
|
+
} catch (e) {
|
|
1213
|
+
// @ts-ignore
|
|
1214
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1215
|
+
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, e === null || e === void 0 ? void 0 : e.message);
|
|
1216
|
+
}
|
|
1217
|
+
};
|
|
1207
1218
|
|
|
1208
1219
|
// Calculate transaction data
|
|
1209
1220
|
try {
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1221
|
+
await Promise.race([getTransactionGas(), wait(3000).then(async () => {
|
|
1222
|
+
if (!transaction.gas) {
|
|
1223
|
+
await this.chainService.initSingleApi(networkKey);
|
|
1224
|
+
await getTransactionGas();
|
|
1225
|
+
}
|
|
1226
|
+
})]);
|
|
1213
1227
|
} catch (e) {
|
|
1214
1228
|
// @ts-ignore
|
|
1215
1229
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
|
|
1216
1230
|
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS, e === null || e === void 0 ? void 0 : e.message);
|
|
1217
1231
|
}
|
|
1232
|
+
if (!transaction.gas) {
|
|
1233
|
+
throw new EvmProviderError(EvmProviderErrorType.INVALID_PARAMS);
|
|
1234
|
+
}
|
|
1218
1235
|
let estimateGas;
|
|
1219
1236
|
|
|
1220
1237
|
// TODO: Review, If not override, transaction maybe fail because fee too low
|
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.57-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -204,6 +204,16 @@
|
|
|
204
204
|
"require": "./cjs/koni/api/nft/acala_nft/index.js",
|
|
205
205
|
"default": "./koni/api/nft/acala_nft/index.js"
|
|
206
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
|
+
},
|
|
207
217
|
"./koni/api/nft/bit.country": {
|
|
208
218
|
"types": "./koni/api/nft/bit.country/index.d.ts",
|
|
209
219
|
"require": "./cjs/koni/api/nft/bit.country/index.js",
|
|
@@ -254,16 +264,6 @@
|
|
|
254
264
|
"require": "./cjs/koni/api/nft/rmrk_nft/index.js",
|
|
255
265
|
"default": "./koni/api/nft/rmrk_nft/index.js"
|
|
256
266
|
},
|
|
257
|
-
"./koni/api/nft/statemine_nft": {
|
|
258
|
-
"types": "./koni/api/nft/statemine_nft/index.d.ts",
|
|
259
|
-
"require": "./cjs/koni/api/nft/statemine_nft/index.js",
|
|
260
|
-
"default": "./koni/api/nft/statemine_nft/index.js"
|
|
261
|
-
},
|
|
262
|
-
"./koni/api/nft/statemint_nft": {
|
|
263
|
-
"types": "./koni/api/nft/statemint_nft/index.d.ts",
|
|
264
|
-
"require": "./cjs/koni/api/nft/statemint_nft/index.js",
|
|
265
|
-
"default": "./koni/api/nft/statemint_nft/index.js"
|
|
266
|
-
},
|
|
267
267
|
"./koni/api/nft/transfer": {
|
|
268
268
|
"types": "./koni/api/nft/transfer.d.ts",
|
|
269
269
|
"require": "./cjs/koni/api/nft/transfer.js",
|
|
@@ -1856,28 +1856,28 @@
|
|
|
1856
1856
|
"@metamask/safe-event-emitter": "^2.0.0",
|
|
1857
1857
|
"@metaverse-network-sdk/type-definitions": "^0.0.1-13",
|
|
1858
1858
|
"@oak-foundation/types": "^0.0.23",
|
|
1859
|
-
"@polkadot/api": "^10.
|
|
1859
|
+
"@polkadot/api": "^10.12.4",
|
|
1860
1860
|
"@polkadot/api-base": "^10.11.2",
|
|
1861
|
-
"@polkadot/api-contract": "^10.
|
|
1862
|
-
"@polkadot/api-derive": "^10.
|
|
1863
|
-
"@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",
|
|
1864
1864
|
"@polkadot/hw-ledger": "^12.6.2",
|
|
1865
1865
|
"@polkadot/networks": "^12.6.2",
|
|
1866
|
-
"@polkadot/phishing": "^0.22.
|
|
1867
|
-
"@polkadot/rpc-provider": "^10.
|
|
1868
|
-
"@polkadot/types": "^10.
|
|
1869
|
-
"@polkadot/types-augment": "^10.
|
|
1870
|
-
"@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",
|
|
1871
1871
|
"@polkadot/util": "^12.6.2",
|
|
1872
1872
|
"@polkadot/util-crypto": "^12.6.2",
|
|
1873
1873
|
"@reduxjs/toolkit": "^1.9.1",
|
|
1874
1874
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
1875
|
-
"@substrate/connect": "^0.
|
|
1876
|
-
"@subwallet/chain-list": "0.2.
|
|
1877
|
-
"@subwallet/extension-base": "^1.1.
|
|
1878
|
-
"@subwallet/extension-chains": "^1.1.
|
|
1879
|
-
"@subwallet/extension-dapp": "^1.1.
|
|
1880
|
-
"@subwallet/extension-inject": "^1.1.
|
|
1875
|
+
"@substrate/connect": "^0.8.9",
|
|
1876
|
+
"@subwallet/chain-list": "0.2.56",
|
|
1877
|
+
"@subwallet/extension-base": "^1.1.57-0",
|
|
1878
|
+
"@subwallet/extension-chains": "^1.1.57-0",
|
|
1879
|
+
"@subwallet/extension-dapp": "^1.1.57-0",
|
|
1880
|
+
"@subwallet/extension-inject": "^1.1.57-0",
|
|
1881
1881
|
"@subwallet/keyring": "^0.1.5",
|
|
1882
1882
|
"@subwallet/ui-keyring": "^0.1.5",
|
|
1883
1883
|
"@walletconnect/sign-client": "^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.57-0'
|
|
11
11
|
};
|
|
@@ -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: {
|
|
@@ -93,6 +93,7 @@ export declare class ChainService {
|
|
|
93
93
|
autoEnableTokens(): Promise<void>;
|
|
94
94
|
handleLatestData(): void;
|
|
95
95
|
private initApis;
|
|
96
|
+
initSingleApi(slug: string): Promise<boolean>;
|
|
96
97
|
private initApiForChain;
|
|
97
98
|
private destroyApiForChain;
|
|
98
99
|
enableChain(chainSlug: string): Promise<boolean>;
|
|
@@ -609,6 +609,15 @@ export class ChainService {
|
|
|
609
609
|
}
|
|
610
610
|
}));
|
|
611
611
|
}
|
|
612
|
+
async initSingleApi(slug) {
|
|
613
|
+
const chainInfoMap = this.getChainInfoMap();
|
|
614
|
+
const chainStateMap = this.getChainStateMap();
|
|
615
|
+
if (!chainStateMap[slug].active) {
|
|
616
|
+
return false;
|
|
617
|
+
}
|
|
618
|
+
await this.initApiForChain(chainInfoMap[slug]);
|
|
619
|
+
return true;
|
|
620
|
+
}
|
|
612
621
|
async initApiForChain(chainInfo) {
|
|
613
622
|
const {
|
|
614
623
|
endpoint,
|
|
@@ -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
|
}
|
|
@@ -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
|
}
|
|
@@ -44,13 +44,16 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
44
44
|
await defaultCallback();
|
|
45
45
|
await substrateApi.isReady;
|
|
46
46
|
const unsub = await ((_substrateApi$api$que = substrateApi.api.query.staking) === null || _substrateApi$api$que === void 0 ? void 0 : _substrateApi$api$que.currentEra(async _currentEra => {
|
|
47
|
-
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$que2, _substrateApi$api$que3, _substrateApi$api$que4, _substrateApi$api$que5, _substrateApi$api$que6;
|
|
47
|
+
var _substrateApi$api$con, _substrateApi$api$con2, _substrateApi$api$cal, _substrateApi$api$que2, _substrateApi$api$que3, _substrateApi$api$que4, _substrateApi$api$que5, _substrateApi$api$que6;
|
|
48
48
|
if (cancel) {
|
|
49
49
|
unsub();
|
|
50
50
|
return;
|
|
51
51
|
}
|
|
52
|
+
let maxNominations = ((_substrateApi$api$con = substrateApi.api.consts.staking) === null || _substrateApi$api$con === void 0 ? void 0 : (_substrateApi$api$con2 = _substrateApi$api$con.maxNominations) === null || _substrateApi$api$con2 === void 0 ? void 0 : _substrateApi$api$con2.toString()) || '16';
|
|
53
|
+
const _maxNominationsByNominationQuota = await ((_substrateApi$api$cal = substrateApi.api.call.stakingApi) === null || _substrateApi$api$cal === void 0 ? void 0 : _substrateApi$api$cal.nominationsQuota(0)); // todo: review param. Currently return constant for all param.
|
|
54
|
+
const maxNominationsByNominationQuota = _maxNominationsByNominationQuota === null || _maxNominationsByNominationQuota === void 0 ? void 0 : _maxNominationsByNominationQuota.toString();
|
|
55
|
+
maxNominations = maxNominationsByNominationQuota !== null && maxNominationsByNominationQuota !== void 0 ? maxNominationsByNominationQuota : maxNominations;
|
|
52
56
|
const currentEra = _currentEra.toString();
|
|
53
|
-
const maxNominations = ((_substrateApi$api$con = substrateApi.api.consts.staking) === null || _substrateApi$api$con === void 0 ? void 0 : (_substrateApi$api$con2 = _substrateApi$api$con.maxNominations) === null || _substrateApi$api$con2 === void 0 ? void 0 : _substrateApi$api$con2.toString()) || '16'; // TODO
|
|
54
57
|
const maxUnlockingChunks = substrateApi.api.consts.staking.maxUnlockingChunks.toString();
|
|
55
58
|
const unlockingEras = substrateApi.api.consts.staking.bondingDuration.toString();
|
|
56
59
|
const maxSupportedEras = substrateApi.api.consts.staking.historyDepth.toString();
|
|
@@ -139,9 +142,20 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
139
142
|
const validatorList = nominations.targets;
|
|
140
143
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
141
144
|
let nominationStatus = EarningStatus.NOT_EARNING;
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
+
let eraStakerOtherList = [];
|
|
146
|
+
let identity;
|
|
147
|
+
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
148
|
+
// todo: review all relaychains later
|
|
149
|
+
const [[_identity], _eraStaker] = await Promise.all([parseIdentity(substrateApi, validatorAddress), substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress)]);
|
|
150
|
+
identity = _identity;
|
|
151
|
+
eraStakerOtherList = _eraStaker.flatMap(paged => paged[1].toPrimitive().others);
|
|
152
|
+
} else {
|
|
153
|
+
const [[_identity], _eraStaker] = await Promise.all([parseIdentity(substrateApi, validatorAddress), substrateApi.api.query.staking.erasStakers(currentEra, validatorAddress)]);
|
|
154
|
+
identity = _identity;
|
|
155
|
+
const eraStaker = _eraStaker.toPrimitive();
|
|
156
|
+
eraStakerOtherList = eraStaker.others;
|
|
157
|
+
}
|
|
158
|
+
const sortedNominators = eraStakerOtherList.sort((a, b) => {
|
|
145
159
|
return new BigN(b.value).minus(a.value).toNumber();
|
|
146
160
|
});
|
|
147
161
|
const topNominators = sortedNominators.map(nominator => {
|
|
@@ -283,7 +297,14 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
283
297
|
const maxEraRewardPointsEras = MaxEraRewardPointsEras;
|
|
284
298
|
const endEraForPoints = parseInt(activeEra) - 1;
|
|
285
299
|
let startEraForPoints = endEraForPoints - maxEraRewardPointsEras + 1;
|
|
286
|
-
|
|
300
|
+
let _eraStakersPromise;
|
|
301
|
+
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
302
|
+
// todo: review all relaychains later
|
|
303
|
+
_eraStakersPromise = chainApi.api.query.staking.erasStakersOverview.entries(parseInt(currentEra));
|
|
304
|
+
} else {
|
|
305
|
+
_eraStakersPromise = chainApi.api.query.staking.erasStakers.entries(parseInt(currentEra));
|
|
306
|
+
}
|
|
307
|
+
const [_totalEraStake, _eraStakers, _minBond, _stakingRewards, _validators, ..._eraRewardPoints] = await Promise.all([chainApi.api.query.staking.erasTotalStake(parseInt(currentEra)), _eraStakersPromise, chainApi.api.query.staking.minNominatorBond(), ((_chainApi$api$query$s = chainApi.api.query.stakingRewards) === null || _chainApi$api$query$s === void 0 ? void 0 : _chainApi$api$query$s.data) && chainApi.api.query.stakingRewards.data(), chainApi.api.query.staking.validators.entries(), chainApi.api.query.staking.erasRewardPoints.multi([...Array(maxEraRewardPointsEras).keys()].map(i => i + startEraForPoints))]);
|
|
287
308
|
const eraRewardMap = {};
|
|
288
309
|
for (const item of _eraRewardPoints[0]) {
|
|
289
310
|
eraRewardMap[startEraForPoints] = item.toHuman();
|
|
@@ -309,11 +330,11 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
309
330
|
const unlimitedNominatorRewarded = chainApi.api.consts.staking.maxExposurePageSize !== undefined;
|
|
310
331
|
const maxNominatorRewarded = (chainApi.api.consts.staking.maxNominatorRewardedPerValidator || 0).toString();
|
|
311
332
|
const bnTotalEraStake = new BN(_totalEraStake.toString());
|
|
312
|
-
const eraStakers = _eraStakers;
|
|
313
333
|
const rawMinBond = _minBond.toHuman();
|
|
314
334
|
const minBond = rawMinBond.replaceAll(',', '');
|
|
315
335
|
const totalStakeMap = {};
|
|
316
336
|
const bnDecimals = new BN((10 ** decimals).toString());
|
|
337
|
+
const eraStakers = _eraStakers;
|
|
317
338
|
for (const item of eraStakers) {
|
|
318
339
|
// eslint-disable-next-line @typescript-eslint/no-unsafe-call,@typescript-eslint/no-unsafe-member-access
|
|
319
340
|
const rawValidatorInfo = item[0].toHuman();
|
|
@@ -158,9 +158,17 @@ export default class NominationPoolHandler extends BasePoolHandler {
|
|
|
158
158
|
if (nominations) {
|
|
159
159
|
const validatorList = nominations.targets;
|
|
160
160
|
await Promise.all(validatorList.map(async validatorAddress => {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
161
|
+
let eraStakerOtherList = [];
|
|
162
|
+
if (['kusama', 'polkadot', 'westend'].includes(this.chain)) {
|
|
163
|
+
// todo: review all relaychains later
|
|
164
|
+
const _eraStaker = await substrateApi.api.query.staking.erasStakersPaged.entries(currentEra, validatorAddress);
|
|
165
|
+
eraStakerOtherList = _eraStaker.flatMap(paged => paged[1].toPrimitive().others);
|
|
166
|
+
} else {
|
|
167
|
+
const _eraStaker = await substrateApi.api.query.staking.erasStakers(currentEra, validatorAddress);
|
|
168
|
+
const eraStaker = _eraStaker.toPrimitive();
|
|
169
|
+
eraStakerOtherList = eraStaker.others;
|
|
170
|
+
}
|
|
171
|
+
const sortedNominators = eraStakerOtherList.sort((a, b) => {
|
|
164
172
|
return new BigN(b.value).minus(a.value).toNumber();
|
|
165
173
|
});
|
|
166
174
|
const topNominators = sortedNominators.map(nominator => {
|
|
@@ -396,7 +396,6 @@ export default class EarningService {
|
|
|
396
396
|
async removeYieldPositions(chains, addresses) {
|
|
397
397
|
const removeKeys = [];
|
|
398
398
|
chains && chains.length > 0 && Object.entries(this.yieldPositionSubject.getValue()).forEach(([key, value]) => {
|
|
399
|
-
console.log('removeYieldPositions', key, value.chain, chains.indexOf(value.chain) > -1);
|
|
400
399
|
if (chains.indexOf(value.chain) > -1 && !removeKeys.includes(key)) {
|
|
401
400
|
removeKeys.push(key);
|
|
402
401
|
}
|
|
@@ -69,12 +69,12 @@ export async function parseIdentity(substrateApi, address, children) {
|
|
|
69
69
|
const _identity = await substrateApi.api.query.identity.identityOf(address);
|
|
70
70
|
const identityInfo = _identity.toHuman();
|
|
71
71
|
if (identityInfo) {
|
|
72
|
-
var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t;
|
|
72
|
+
var _identityInfo$info, _identityInfo$info$di, _identityInfo$info2, _identityInfo$info2$w, _identityInfo$info3, _identityInfo$info3$r, _identityInfo$info4, _identityInfo$info4$t, _identityInfo$judgeme;
|
|
73
73
|
const displayName = (_identityInfo$info = identityInfo.info) === null || _identityInfo$info === void 0 ? void 0 : (_identityInfo$info$di = _identityInfo$info.display) === null || _identityInfo$info$di === void 0 ? void 0 : _identityInfo$info$di.Raw;
|
|
74
74
|
const web = (_identityInfo$info2 = identityInfo.info) === null || _identityInfo$info2 === void 0 ? void 0 : (_identityInfo$info2$w = _identityInfo$info2.web) === null || _identityInfo$info2$w === void 0 ? void 0 : _identityInfo$info2$w.Raw;
|
|
75
75
|
const riot = (_identityInfo$info3 = identityInfo.info) === null || _identityInfo$info3 === void 0 ? void 0 : (_identityInfo$info3$r = _identityInfo$info3.riot) === null || _identityInfo$info3$r === void 0 ? void 0 : _identityInfo$info3$r.Raw;
|
|
76
76
|
const twitter = (_identityInfo$info4 = identityInfo.info) === null || _identityInfo$info4 === void 0 ? void 0 : (_identityInfo$info4$t = _identityInfo$info4.twitter) === null || _identityInfo$info4$t === void 0 ? void 0 : _identityInfo$info4$t.Raw;
|
|
77
|
-
const isReasonable = identityInfo.judgements.length > 0;
|
|
77
|
+
const isReasonable = ((_identityInfo$judgeme = identityInfo.judgements) === null || _identityInfo$judgeme === void 0 ? void 0 : _identityInfo$judgeme.length) > 0;
|
|
78
78
|
if (displayName) {
|
|
79
79
|
identity = isHex(displayName) ? hexToString(displayName) : displayName;
|
|
80
80
|
} else {
|
|
@@ -9,6 +9,10 @@ export interface PalletStakingExposureItem {
|
|
|
9
9
|
who: string;
|
|
10
10
|
value: number;
|
|
11
11
|
}
|
|
12
|
+
export interface SpStakingExposurePage {
|
|
13
|
+
pageTotal: number;
|
|
14
|
+
others: PalletStakingExposureItem[];
|
|
15
|
+
}
|
|
12
16
|
export interface PalletStakingExposure {
|
|
13
17
|
total: number;
|
|
14
18
|
own: number;
|
|
@@ -2,9 +2,12 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import axios from 'axios';
|
|
5
|
+
const PRODUCTION_BRANCHES = ['master', 'webapp', 'webapp-dev'];
|
|
6
|
+
const branchName = process.env.BRANCH_NAME || 'koni-dev';
|
|
7
|
+
const fetchTarget = PRODUCTION_BRANCHES.indexOf(branchName) > -1 ? 'https://static-cache.subwallet.app' : 'https://dev.sw-static-cache.pages.dev';
|
|
5
8
|
export async function fetchStaticCache(slug, defaultData, timeout = 9000) {
|
|
6
9
|
try {
|
|
7
|
-
const rs = await axios.get(
|
|
10
|
+
const rs = await axios.get(`${fetchTarget}/${slug}`, {
|
|
8
11
|
timeout
|
|
9
12
|
});
|
|
10
13
|
return rs.data;
|