@subwallet/extension-base 1.2.24-1 → 1.2.25-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/cjs/core/substrate/ormlTokens-pallet.js +1 -1
- package/cjs/core/substrate/system-pallet.js +5 -3
- package/cjs/core/substrate/tokens-pallet.js +1 -1
- package/cjs/core/utils.js +4 -10
- package/cjs/packageInfo.js +1 -1
- package/cjs/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
- package/cjs/services/earning-service/handlers/native-staking/relay-chain.js +1 -1
- package/core/substrate/ormlTokens-pallet.js +2 -2
- package/core/substrate/system-pallet.js +6 -4
- package/core/substrate/tokens-pallet.js +2 -2
- package/core/utils.d.ts +1 -1
- package/core/utils.js +3 -9
- package/package.json +5 -5
- package/packageInfo.js +1 -1
- package/services/earning-service/handlers/liquid-staking/bifrost.js +1 -1
- package/services/earning-service/handlers/native-staking/relay-chain.js +1 -1
|
@@ -15,7 +15,7 @@ function _getOrmlTokensPalletTransferable(accountInfo, existentialDeposit, extri
|
|
|
15
15
|
const bnAppliedExistentialDeposit = (0, _utils._getAppliedExistentialDeposit)(existentialDeposit, strictMode);
|
|
16
16
|
const bnFrozen = BigInt(accountInfo.frozen);
|
|
17
17
|
const bnFree = BigInt(accountInfo.free);
|
|
18
|
-
return bnFree - (0, _utils.
|
|
18
|
+
return bnFree - (0, _utils.getMaxBigInt)(bnFrozen, bnAppliedExistentialDeposit);
|
|
19
19
|
}
|
|
20
20
|
function _getOrmlTokensPalletLockedBalance(accountInfo) {
|
|
21
21
|
const bnFrozen = BigInt(accountInfo.frozen);
|
|
@@ -60,15 +60,17 @@ function _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMo
|
|
|
60
60
|
function _getSystemPalletTransferableV2(accountInfo, existentialDeposit, strictMode) {
|
|
61
61
|
const bnLocked = BigInt(accountInfo.data.frozen) - BigInt(accountInfo.data.reserved); // locked can go below 0 but this shouldn't matter
|
|
62
62
|
const bnAppliedExistentialDeposit = _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMode);
|
|
63
|
-
|
|
63
|
+
const bnTransferable = BigInt(accountInfo.data.free) - (0, _utils.getMaxBigInt)(bnLocked, bnAppliedExistentialDeposit);
|
|
64
|
+
return (0, _utils.getMaxBigInt)(bnTransferable, BigInt(0));
|
|
64
65
|
}
|
|
65
66
|
function _getSystemPalletTotalBalanceV2(accountInfo) {
|
|
66
67
|
return BigInt(accountInfo.data.free) + BigInt(accountInfo.data.reserved);
|
|
67
68
|
}
|
|
68
69
|
function _getSystemPalletTransferableV1(accountInfo, existentialDeposit, strictMode) {
|
|
69
70
|
const bnAppliedExistentialDeposit = BigInt(_getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMode));
|
|
70
|
-
const bnAppliedFrozen = (0, _utils.
|
|
71
|
-
|
|
71
|
+
const bnAppliedFrozen = (0, _utils.getMaxBigInt)(BigInt(accountInfo.data.feeFrozen), BigInt(accountInfo.data.miscFrozen));
|
|
72
|
+
const bnTransferable = BigInt(accountInfo.data.free) - (0, _utils.getMaxBigInt)(bnAppliedFrozen, bnAppliedExistentialDeposit);
|
|
73
|
+
return (0, _utils.getMaxBigInt)(bnTransferable, BigInt(0));
|
|
72
74
|
}
|
|
73
75
|
function _getSystemPalletTotalBalanceV1(accountInfo) {
|
|
74
76
|
return BigInt(accountInfo.data.free) + BigInt(accountInfo.data.reserved);
|
|
@@ -14,7 +14,7 @@ var _utils = require("@subwallet/extension-base/core/utils");
|
|
|
14
14
|
function _getTokensPalletTransferable(accountInfo, existentialDeposit, extrinsicType) {
|
|
15
15
|
const strictMode = (0, _utils.getStrictMode)(_types.BalanceAccountType.OrmlTokensAccountData, extrinsicType);
|
|
16
16
|
const bnAppliedExistentialDeposit = (0, _utils._getAppliedExistentialDeposit)(existentialDeposit, strictMode);
|
|
17
|
-
return BigInt(accountInfo.free) - (0, _utils.
|
|
17
|
+
return BigInt(accountInfo.free) - (0, _utils.getMaxBigInt)(BigInt(accountInfo.frozen), bnAppliedExistentialDeposit);
|
|
18
18
|
}
|
|
19
19
|
function _getTokensPalletLocked(accountInfo) {
|
|
20
20
|
return BigInt(accountInfo.reserved) + BigInt(accountInfo.frozen);
|
package/cjs/core/utils.js
CHANGED
|
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports._getAppliedExistentialDeposit = _getAppliedExistentialDeposit;
|
|
7
|
-
exports.
|
|
7
|
+
exports.getMaxBigInt = getMaxBigInt;
|
|
8
8
|
exports.getStrictMode = getStrictMode;
|
|
9
9
|
var _KoniTypes = require("@subwallet/extension-base/background/KoniTypes");
|
|
10
10
|
var _types = require("@subwallet/extension-base/core/substrate/types");
|
|
@@ -12,20 +12,14 @@ var _types = require("@subwallet/extension-base/core/substrate/types");
|
|
|
12
12
|
// SPDX-License-Identifier: Apache-2.0
|
|
13
13
|
|
|
14
14
|
function getStrictMode(type, extrinsicType) {
|
|
15
|
-
if (!extrinsicType) {
|
|
16
|
-
return true;
|
|
17
|
-
}
|
|
18
15
|
if (type === _types.BalanceAccountType.FrameSystemAccountInfo) {
|
|
19
|
-
return ![_KoniTypes.ExtrinsicType.TRANSFER_BALANCE].includes(extrinsicType);
|
|
20
|
-
}
|
|
21
|
-
if (type === _types.BalanceAccountType.OrmlTokensAccountData || type === _types.BalanceAccountType.PalletAssetsAssetAccount) {
|
|
22
|
-
return ![_KoniTypes.ExtrinsicType.TRANSFER_TOKEN, _KoniTypes.ExtrinsicType.TRANSFER_BALANCE].includes(extrinsicType);
|
|
16
|
+
return !extrinsicType || ![_KoniTypes.ExtrinsicType.TRANSFER_BALANCE].includes(extrinsicType);
|
|
23
17
|
}
|
|
24
|
-
return
|
|
18
|
+
return false;
|
|
25
19
|
}
|
|
26
20
|
function _getAppliedExistentialDeposit(existentialDeposit, strictMode) {
|
|
27
21
|
return strictMode ? BigInt(existentialDeposit) : BigInt(0);
|
|
28
22
|
}
|
|
29
|
-
function
|
|
23
|
+
function getMaxBigInt(a, b) {
|
|
30
24
|
return a > b ? a : b;
|
|
31
25
|
}
|
package/cjs/packageInfo.js
CHANGED
|
@@ -17,7 +17,7 @@ var _base = _interopRequireDefault(require("./base"));
|
|
|
17
17
|
// Copyright 2019-2022 @subwallet/extension-base
|
|
18
18
|
// SPDX-License-Identifier: Apache-2.0
|
|
19
19
|
|
|
20
|
-
const STATS_URL = 'https://
|
|
20
|
+
const STATS_URL = 'https://dapi.bifrost.io/api/site';
|
|
21
21
|
const BIFROST_GRAPHQL_ENDPOINT = 'https://bifrost-subsql.liebi.com/v1/graphql';
|
|
22
22
|
const BIFROST_EXCHANGE_RATE_REQUEST = 'query MyQuery{slp_polkadot_ratio(limit:1 where:{key:{_eq:"0"}} order_by:{timestamp:desc_nulls_first}){ratio key timestamp total_issuance token_pool}}';
|
|
23
23
|
class BifrostLiquidStakingPoolHandler extends _base.default {
|
|
@@ -143,7 +143,7 @@ class RelayNativeStakingPoolHandler extends _base.default {
|
|
|
143
143
|
const addressFormatted = (0, _utils4.reformatAddress)(address, (0, _utils2._getChainSubstrateAddressPrefix)(chainInfo));
|
|
144
144
|
const activeStake = ledger.active.toString();
|
|
145
145
|
const totalStake = ledger.total.toString();
|
|
146
|
-
const unstakingBalance = (ledger.total
|
|
146
|
+
const unstakingBalance = new _bignumber.default(ledger.total).minus(ledger.active).toString();
|
|
147
147
|
const unstakingList = [];
|
|
148
148
|
const nominationList = (await this.handleNominationsList(substrateApi, chain, nominations, currentEra, addressFormatted, maxNominatorRewardedPerValidator)) || [];
|
|
149
149
|
let stakingStatus = _types.EarningStatus.NOT_EARNING;
|
|
@@ -2,13 +2,13 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
|
|
5
|
-
import { _getAppliedExistentialDeposit,
|
|
5
|
+
import { _getAppliedExistentialDeposit, getMaxBigInt, getStrictMode } from '@subwallet/extension-base/core/utils';
|
|
6
6
|
export function _getOrmlTokensPalletTransferable(accountInfo, existentialDeposit, extrinsicType) {
|
|
7
7
|
const strictMode = getStrictMode(BalanceAccountType.OrmlTokensAccountData, extrinsicType);
|
|
8
8
|
const bnAppliedExistentialDeposit = _getAppliedExistentialDeposit(existentialDeposit, strictMode);
|
|
9
9
|
const bnFrozen = BigInt(accountInfo.frozen);
|
|
10
10
|
const bnFree = BigInt(accountInfo.free);
|
|
11
|
-
return bnFree -
|
|
11
|
+
return bnFree - getMaxBigInt(bnFrozen, bnAppliedExistentialDeposit);
|
|
12
12
|
}
|
|
13
13
|
export function _getOrmlTokensPalletLockedBalance(accountInfo) {
|
|
14
14
|
const bnFrozen = BigInt(accountInfo.frozen);
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
|
|
5
|
-
import {
|
|
5
|
+
import { getMaxBigInt, getStrictMode } from '@subwallet/extension-base/core/utils';
|
|
6
6
|
function isV1(accountInfo) {
|
|
7
7
|
return accountInfo.data.miscFrozen !== undefined && accountInfo.data.feeFrozen !== undefined;
|
|
8
8
|
}
|
|
@@ -50,15 +50,17 @@ function _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMo
|
|
|
50
50
|
function _getSystemPalletTransferableV2(accountInfo, existentialDeposit, strictMode) {
|
|
51
51
|
const bnLocked = BigInt(accountInfo.data.frozen) - BigInt(accountInfo.data.reserved); // locked can go below 0 but this shouldn't matter
|
|
52
52
|
const bnAppliedExistentialDeposit = _getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMode);
|
|
53
|
-
|
|
53
|
+
const bnTransferable = BigInt(accountInfo.data.free) - getMaxBigInt(bnLocked, bnAppliedExistentialDeposit);
|
|
54
|
+
return getMaxBigInt(bnTransferable, BigInt(0));
|
|
54
55
|
}
|
|
55
56
|
function _getSystemPalletTotalBalanceV2(accountInfo) {
|
|
56
57
|
return BigInt(accountInfo.data.free) + BigInt(accountInfo.data.reserved);
|
|
57
58
|
}
|
|
58
59
|
function _getSystemPalletTransferableV1(accountInfo, existentialDeposit, strictMode) {
|
|
59
60
|
const bnAppliedExistentialDeposit = BigInt(_getAppliedExistentialDeposit(accountInfo, existentialDeposit, strictMode));
|
|
60
|
-
const bnAppliedFrozen =
|
|
61
|
-
|
|
61
|
+
const bnAppliedFrozen = getMaxBigInt(BigInt(accountInfo.data.feeFrozen), BigInt(accountInfo.data.miscFrozen));
|
|
62
|
+
const bnTransferable = BigInt(accountInfo.data.free) - getMaxBigInt(bnAppliedFrozen, bnAppliedExistentialDeposit);
|
|
63
|
+
return getMaxBigInt(bnTransferable, BigInt(0));
|
|
62
64
|
}
|
|
63
65
|
function _getSystemPalletTotalBalanceV1(accountInfo) {
|
|
64
66
|
return BigInt(accountInfo.data.free) + BigInt(accountInfo.data.reserved);
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
3
|
|
|
4
4
|
import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
|
|
5
|
-
import { _getAppliedExistentialDeposit,
|
|
5
|
+
import { _getAppliedExistentialDeposit, getMaxBigInt, getStrictMode } from '@subwallet/extension-base/core/utils';
|
|
6
6
|
export function _getTokensPalletTransferable(accountInfo, existentialDeposit, extrinsicType) {
|
|
7
7
|
const strictMode = getStrictMode(BalanceAccountType.OrmlTokensAccountData, extrinsicType);
|
|
8
8
|
const bnAppliedExistentialDeposit = _getAppliedExistentialDeposit(existentialDeposit, strictMode);
|
|
9
|
-
return BigInt(accountInfo.free) -
|
|
9
|
+
return BigInt(accountInfo.free) - getMaxBigInt(BigInt(accountInfo.frozen), bnAppliedExistentialDeposit);
|
|
10
10
|
}
|
|
11
11
|
export function _getTokensPalletLocked(accountInfo) {
|
|
12
12
|
return BigInt(accountInfo.reserved) + BigInt(accountInfo.frozen);
|
package/core/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
2
2
|
export declare function getStrictMode(type: string, extrinsicType?: ExtrinsicType): boolean;
|
|
3
3
|
export declare function _getAppliedExistentialDeposit(existentialDeposit: string, strictMode?: boolean): bigint;
|
|
4
|
-
export declare function
|
|
4
|
+
export declare function getMaxBigInt(a: bigint, b: bigint): bigint;
|
package/core/utils.js
CHANGED
|
@@ -4,20 +4,14 @@
|
|
|
4
4
|
import { ExtrinsicType } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { BalanceAccountType } from '@subwallet/extension-base/core/substrate/types';
|
|
6
6
|
export function getStrictMode(type, extrinsicType) {
|
|
7
|
-
if (!extrinsicType) {
|
|
8
|
-
return true;
|
|
9
|
-
}
|
|
10
7
|
if (type === BalanceAccountType.FrameSystemAccountInfo) {
|
|
11
|
-
return ![ExtrinsicType.TRANSFER_BALANCE].includes(extrinsicType);
|
|
12
|
-
}
|
|
13
|
-
if (type === BalanceAccountType.OrmlTokensAccountData || type === BalanceAccountType.PalletAssetsAssetAccount) {
|
|
14
|
-
return ![ExtrinsicType.TRANSFER_TOKEN, ExtrinsicType.TRANSFER_BALANCE].includes(extrinsicType);
|
|
8
|
+
return !extrinsicType || ![ExtrinsicType.TRANSFER_BALANCE].includes(extrinsicType);
|
|
15
9
|
}
|
|
16
|
-
return
|
|
10
|
+
return false;
|
|
17
11
|
}
|
|
18
12
|
export function _getAppliedExistentialDeposit(existentialDeposit, strictMode) {
|
|
19
13
|
return strictMode ? BigInt(existentialDeposit) : BigInt(0);
|
|
20
14
|
}
|
|
21
|
-
export function
|
|
15
|
+
export function getMaxBigInt(a, b) {
|
|
22
16
|
return a > b ? a : b;
|
|
23
17
|
}
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.2.
|
|
20
|
+
"version": "1.2.25-0",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -2060,10 +2060,10 @@
|
|
|
2060
2060
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2061
2061
|
"@substrate/connect": "^0.8.9",
|
|
2062
2062
|
"@subwallet/chain-list": "0.2.81",
|
|
2063
|
-
"@subwallet/extension-base": "^1.2.
|
|
2064
|
-
"@subwallet/extension-chains": "^1.2.
|
|
2065
|
-
"@subwallet/extension-dapp": "^1.2.
|
|
2066
|
-
"@subwallet/extension-inject": "^1.2.
|
|
2063
|
+
"@subwallet/extension-base": "^1.2.25-0",
|
|
2064
|
+
"@subwallet/extension-chains": "^1.2.25-0",
|
|
2065
|
+
"@subwallet/extension-dapp": "^1.2.25-0",
|
|
2066
|
+
"@subwallet/extension-inject": "^1.2.25-0",
|
|
2067
2067
|
"@subwallet/keyring": "^0.1.5",
|
|
2068
2068
|
"@subwallet/ui-keyring": "^0.1.5",
|
|
2069
2069
|
"@walletconnect/keyvaluestorage": "^1.1.1",
|
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.2.
|
|
10
|
+
version: '1.2.25-0'
|
|
11
11
|
};
|
|
@@ -10,7 +10,7 @@ import { reformatAddress } from '@subwallet/extension-base/utils';
|
|
|
10
10
|
import BigNumber from 'bignumber.js';
|
|
11
11
|
import { BN, BN_ZERO } from '@polkadot/util';
|
|
12
12
|
import BaseLiquidStakingPoolHandler from "./base.js";
|
|
13
|
-
const STATS_URL = 'https://
|
|
13
|
+
const STATS_URL = 'https://dapi.bifrost.io/api/site';
|
|
14
14
|
const BIFROST_GRAPHQL_ENDPOINT = 'https://bifrost-subsql.liebi.com/v1/graphql';
|
|
15
15
|
const BIFROST_EXCHANGE_RATE_REQUEST = 'query MyQuery{slp_polkadot_ratio(limit:1 where:{key:{_eq:"0"}} order_by:{timestamp:desc_nulls_first}){ratio key timestamp total_issuance token_pool}}';
|
|
16
16
|
export default class BifrostLiquidStakingPoolHandler extends BaseLiquidStakingPoolHandler {
|
|
@@ -136,7 +136,7 @@ export default class RelayNativeStakingPoolHandler extends BaseNativeStakingPool
|
|
|
136
136
|
const addressFormatted = reformatAddress(address, _getChainSubstrateAddressPrefix(chainInfo));
|
|
137
137
|
const activeStake = ledger.active.toString();
|
|
138
138
|
const totalStake = ledger.total.toString();
|
|
139
|
-
const unstakingBalance = (ledger.total
|
|
139
|
+
const unstakingBalance = new BigN(ledger.total).minus(ledger.active).toString();
|
|
140
140
|
const unstakingList = [];
|
|
141
141
|
const nominationList = (await this.handleNominationsList(substrateApi, chain, nominations, currentEra, addressFormatted, maxNominatorRewardedPerValidator)) || [];
|
|
142
142
|
let stakingStatus = EarningStatus.NOT_EARNING;
|