@subwallet/extension-base 1.2.24-1 → 1.2.24-2
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/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
|
@@ -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
|
@@ -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.24-
|
|
20
|
+
"version": "1.2.24-2",
|
|
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.24-
|
|
2064
|
-
"@subwallet/extension-chains": "^1.2.24-
|
|
2065
|
-
"@subwallet/extension-dapp": "^1.2.24-
|
|
2066
|
-
"@subwallet/extension-inject": "^1.2.24-
|
|
2063
|
+
"@subwallet/extension-base": "^1.2.24-2",
|
|
2064
|
+
"@subwallet/extension-chains": "^1.2.24-2",
|
|
2065
|
+
"@subwallet/extension-dapp": "^1.2.24-2",
|
|
2066
|
+
"@subwallet/extension-inject": "^1.2.24-2",
|
|
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.24-
|
|
10
|
+
version: '1.2.24-2'
|
|
11
11
|
};
|