@subwallet/extension-base 1.3.44-0 → 1.3.45-1
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/logic-validation/recipientAddress.js +2 -8
- package/cjs/core/utils.js +3 -3
- package/cjs/packageInfo.js +1 -1
- package/cjs/utils/account/common.js +4 -0
- package/cjs/utils/index.js +7 -6
- package/core/logic-validation/recipientAddress.js +2 -8
- package/core/utils.js +3 -3
- package/package.json +6 -6
- package/packageInfo.js +1 -1
- package/utils/account/common.d.ts +1 -1
- package/utils/account/common.js +4 -1
- package/utils/index.js +9 -8
|
@@ -117,13 +117,7 @@ function runValidationFunctions(validateRecipientParams, validationFunctions) {
|
|
|
117
117
|
return Promise.resolve();
|
|
118
118
|
}
|
|
119
119
|
function validateRecipientAddress(validateRecipientParams) {
|
|
120
|
-
|
|
121
|
-
// Re-enable after related issues are fixed.
|
|
122
|
-
const prams = {
|
|
123
|
-
...validateRecipientParams,
|
|
124
|
-
autoFormatValue: false
|
|
125
|
-
};
|
|
126
|
-
const conditions = getConditions(prams);
|
|
120
|
+
const conditions = getConditions(validateRecipientParams);
|
|
127
121
|
const validationFunctions = getValidationFunctions(conditions);
|
|
128
|
-
return runValidationFunctions(
|
|
122
|
+
return runValidationFunctions(validateRecipientParams, validationFunctions);
|
|
129
123
|
}
|
package/cjs/core/utils.js
CHANGED
|
@@ -76,7 +76,7 @@ function _isValidAddressForEcosystem(validateRecipientParams) {
|
|
|
76
76
|
} = validateRecipientParams;
|
|
77
77
|
if (!(0, _utils3.isAddressAndChainCompatible)(toAddress, destChainInfo)) {
|
|
78
78
|
if ((0, _utils2._isChainEvmCompatible)(destChainInfo) || (0, _utils2._isChainSubstrateCompatible)(destChainInfo) || (0, _utils2._isChainTonCompatible)(destChainInfo) || (0, _utils2._isChainCardanoCompatible)(destChainInfo) || (0, _utils2._isChainBitcoinCompatible)(destChainInfo)) {
|
|
79
|
-
return
|
|
79
|
+
return `Recipient address must be a valid ${destChainInfo.name} address`;
|
|
80
80
|
}
|
|
81
81
|
return 'Unknown chain type';
|
|
82
82
|
}
|
|
@@ -89,8 +89,8 @@ function _isValidSubstrateAddressFormat(validateRecipientParams) {
|
|
|
89
89
|
toAddress
|
|
90
90
|
} = validateRecipientParams;
|
|
91
91
|
const addressPrefix = (_destChainInfo$substr = destChainInfo === null || destChainInfo === void 0 ? void 0 : (_destChainInfo$substr2 = destChainInfo.substrateInfo) === null || _destChainInfo$substr2 === void 0 ? void 0 : _destChainInfo$substr2.addressPrefix) !== null && _destChainInfo$substr !== void 0 ? _destChainInfo$substr : 42;
|
|
92
|
-
const toAddressFormatted = (0, _utils3.reformatAddress)(toAddress, addressPrefix);
|
|
93
|
-
if (toAddressFormatted !== toAddress) {
|
|
92
|
+
const toAddressFormatted = (0, _utils3.reformatAddress)(toAddress, addressPrefix, undefined, false);
|
|
93
|
+
if (toAddressFormatted && toAddressFormatted !== toAddress) {
|
|
94
94
|
return `Recipient address must be a valid ${destChainInfo.name} address`;
|
|
95
95
|
}
|
|
96
96
|
return '';
|
package/cjs/packageInfo.js
CHANGED
|
@@ -26,6 +26,7 @@ function isAccountAll(address) {
|
|
|
26
26
|
function reformatAddress(address) {
|
|
27
27
|
let networkPrefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 42;
|
|
28
28
|
let isEthereum = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
29
|
+
let ignoreError = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
|
29
30
|
try {
|
|
30
31
|
if (!address || address === '') {
|
|
31
32
|
return '';
|
|
@@ -47,6 +48,9 @@ function reformatAddress(address) {
|
|
|
47
48
|
return (0, _keyring.encodeAddress)(publicKey, networkPrefix, type);
|
|
48
49
|
} catch (e) {
|
|
49
50
|
console.warn('Get error while reformat address', address, e);
|
|
51
|
+
if (!ignoreError) {
|
|
52
|
+
return '';
|
|
53
|
+
}
|
|
50
54
|
return address;
|
|
51
55
|
}
|
|
52
56
|
}
|
package/cjs/utils/index.js
CHANGED
|
@@ -74,7 +74,7 @@ var _config = require("@subwallet/extension-base/koni/api/nft/config");
|
|
|
74
74
|
var _utils = require("@subwallet/extension-base/services/chain-service/utils");
|
|
75
75
|
var _account = require("@subwallet/extension-base/utils/account");
|
|
76
76
|
var _keyring = require("@subwallet/keyring");
|
|
77
|
-
var
|
|
77
|
+
var _types = require("@subwallet/keyring/types");
|
|
78
78
|
var _i18next = require("i18next");
|
|
79
79
|
var _util = require("@polkadot/util");
|
|
80
80
|
var _utilCrypto = require("@polkadot/util-crypto");
|
|
@@ -599,11 +599,12 @@ function isSameAddressType(address1, address2) {
|
|
|
599
599
|
return isSameEvmAddress || isSameTonAddress || isSameSubstrateAddress;
|
|
600
600
|
}
|
|
601
601
|
function isAddressAndChainCompatible(address, chain) {
|
|
602
|
-
const
|
|
603
|
-
const
|
|
604
|
-
const
|
|
605
|
-
const
|
|
606
|
-
const
|
|
602
|
+
const keypairType = (0, _keyring.getKeypairTypeByAddress)(address);
|
|
603
|
+
const isEvmCompatible = (0, _utils._isChainEvmCompatible)(chain) && _types.EthereumKeypairTypes.includes(keypairType); // some chains compatible to substrate and evm, and use evm-address
|
|
604
|
+
const isTonCompatible = (0, _utils._isPureTonChain)(chain) && _types.TonKeypairTypes.includes(keypairType);
|
|
605
|
+
const isSubstrateCompatible = (0, _utils._isPureSubstrateChain)(chain) && _types.SubstrateKeypairTypes.includes(keypairType);
|
|
606
|
+
const isCardanoCompatible = (0, _utils._isPureCardanoChain)(chain) && _types.CardanoKeypairTypes.includes(keypairType);
|
|
607
|
+
const isBitcoinCompatible = (0, _utils._isPureBitcoinChain)(chain) && _types.BitcoinKeypairTypes.includes(keypairType);
|
|
607
608
|
return isEvmCompatible || isSubstrateCompatible || isTonCompatible || isCardanoCompatible || isBitcoinCompatible;
|
|
608
609
|
}
|
|
609
610
|
function getDomainFromUrl(url) {
|
|
@@ -111,13 +111,7 @@ function runValidationFunctions(validateRecipientParams, validationFunctions) {
|
|
|
111
111
|
return Promise.resolve();
|
|
112
112
|
}
|
|
113
113
|
export function validateRecipientAddress(validateRecipientParams) {
|
|
114
|
-
|
|
115
|
-
// Re-enable after related issues are fixed.
|
|
116
|
-
const prams = {
|
|
117
|
-
...validateRecipientParams,
|
|
118
|
-
autoFormatValue: false
|
|
119
|
-
};
|
|
120
|
-
const conditions = getConditions(prams);
|
|
114
|
+
const conditions = getConditions(validateRecipientParams);
|
|
121
115
|
const validationFunctions = getValidationFunctions(conditions);
|
|
122
|
-
return runValidationFunctions(
|
|
116
|
+
return runValidationFunctions(validateRecipientParams, validationFunctions);
|
|
123
117
|
}
|
package/core/utils.js
CHANGED
|
@@ -57,7 +57,7 @@ export function _isValidAddressForEcosystem(validateRecipientParams) {
|
|
|
57
57
|
} = validateRecipientParams;
|
|
58
58
|
if (!isAddressAndChainCompatible(toAddress, destChainInfo)) {
|
|
59
59
|
if (_isChainEvmCompatible(destChainInfo) || _isChainSubstrateCompatible(destChainInfo) || _isChainTonCompatible(destChainInfo) || _isChainCardanoCompatible(destChainInfo) || _isChainBitcoinCompatible(destChainInfo)) {
|
|
60
|
-
return
|
|
60
|
+
return `Recipient address must be a valid ${destChainInfo.name} address`;
|
|
61
61
|
}
|
|
62
62
|
return 'Unknown chain type';
|
|
63
63
|
}
|
|
@@ -70,8 +70,8 @@ export function _isValidSubstrateAddressFormat(validateRecipientParams) {
|
|
|
70
70
|
toAddress
|
|
71
71
|
} = validateRecipientParams;
|
|
72
72
|
const addressPrefix = (_destChainInfo$substr = destChainInfo === null || destChainInfo === void 0 ? void 0 : (_destChainInfo$substr2 = destChainInfo.substrateInfo) === null || _destChainInfo$substr2 === void 0 ? void 0 : _destChainInfo$substr2.addressPrefix) !== null && _destChainInfo$substr !== void 0 ? _destChainInfo$substr : 42;
|
|
73
|
-
const toAddressFormatted = reformatAddress(toAddress, addressPrefix);
|
|
74
|
-
if (toAddressFormatted !== toAddress) {
|
|
73
|
+
const toAddressFormatted = reformatAddress(toAddress, addressPrefix, undefined, false);
|
|
74
|
+
if (toAddressFormatted && toAddressFormatted !== toAddress) {
|
|
75
75
|
return `Recipient address must be a valid ${destChainInfo.name} address`;
|
|
76
76
|
}
|
|
77
77
|
return '';
|
package/package.json
CHANGED
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
"./cjs/detectPackage.js"
|
|
18
18
|
],
|
|
19
19
|
"type": "module",
|
|
20
|
-
"version": "1.3.
|
|
20
|
+
"version": "1.3.45-1",
|
|
21
21
|
"main": "./cjs/index.js",
|
|
22
22
|
"module": "./index.js",
|
|
23
23
|
"types": "./index.d.ts",
|
|
@@ -2855,12 +2855,12 @@
|
|
|
2855
2855
|
"@sora-substrate/type-definitions": "^1.17.7",
|
|
2856
2856
|
"@substrate/connect": "^0.8.9",
|
|
2857
2857
|
"@subwallet/chain-list": "0.2.107",
|
|
2858
|
-
"@subwallet/extension-base": "^1.3.
|
|
2859
|
-
"@subwallet/extension-chains": "^1.3.
|
|
2860
|
-
"@subwallet/extension-dapp": "^1.3.
|
|
2861
|
-
"@subwallet/extension-inject": "^1.3.
|
|
2858
|
+
"@subwallet/extension-base": "^1.3.45-1",
|
|
2859
|
+
"@subwallet/extension-chains": "^1.3.45-1",
|
|
2860
|
+
"@subwallet/extension-dapp": "^1.3.45-1",
|
|
2861
|
+
"@subwallet/extension-inject": "^1.3.45-1",
|
|
2862
2862
|
"@subwallet/keyring": "^0.1.12",
|
|
2863
|
-
"@subwallet/subwallet-api-sdk": "^1.3.
|
|
2863
|
+
"@subwallet/subwallet-api-sdk": "^1.3.45-1",
|
|
2864
2864
|
"@subwallet/ui-keyring": "^0.1.12",
|
|
2865
2865
|
"@ton/core": "^0.56.3",
|
|
2866
2866
|
"@ton/crypto": "^3.2.0",
|
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.3.
|
|
10
|
+
version: '1.3.45-1'
|
|
11
11
|
};
|
|
@@ -3,7 +3,7 @@ import { ChainType } from '@subwallet/extension-base/background/KoniTypes';
|
|
|
3
3
|
import { AccountChainType } from '@subwallet/extension-base/types';
|
|
4
4
|
import { KeypairType } from '@subwallet/keyring/types';
|
|
5
5
|
export declare function isAccountAll(address?: string): boolean;
|
|
6
|
-
export declare function reformatAddress(address: string, networkPrefix?: number, isEthereum?: boolean): string;
|
|
6
|
+
export declare function reformatAddress(address: string, networkPrefix?: number, isEthereum?: boolean, ignoreError?: boolean): string;
|
|
7
7
|
export declare const _reformatAddressWithChain: (address: string, chainInfo: _ChainInfo) => string;
|
|
8
8
|
export declare const getAccountChainTypeForAddress: (address: string) => AccountChainType;
|
|
9
9
|
declare type AddressesByChainType = {
|
package/utils/account/common.js
CHANGED
|
@@ -11,7 +11,7 @@ import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
|
11
11
|
export function isAccountAll(address) {
|
|
12
12
|
return address === ALL_ACCOUNT_KEY;
|
|
13
13
|
}
|
|
14
|
-
export function reformatAddress(address, networkPrefix = 42, isEthereum = false) {
|
|
14
|
+
export function reformatAddress(address, networkPrefix = 42, isEthereum = false, ignoreError = true) {
|
|
15
15
|
try {
|
|
16
16
|
if (!address || address === '') {
|
|
17
17
|
return '';
|
|
@@ -33,6 +33,9 @@ export function reformatAddress(address, networkPrefix = 42, isEthereum = false)
|
|
|
33
33
|
return encodeAddress(publicKey, networkPrefix, type);
|
|
34
34
|
} catch (e) {
|
|
35
35
|
console.warn('Get error while reformat address', address, e);
|
|
36
|
+
if (!ignoreError) {
|
|
37
|
+
return '';
|
|
38
|
+
}
|
|
36
39
|
return address;
|
|
37
40
|
}
|
|
38
41
|
}
|
package/utils/index.js
CHANGED
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
|
|
4
4
|
import { CrowdloanParaState } from '@subwallet/extension-base/background/KoniTypes';
|
|
5
5
|
import { getRandomIpfsGateway, SUBWALLET_IPFS } from '@subwallet/extension-base/koni/api/nft/config';
|
|
6
|
-
import {
|
|
6
|
+
import { _isChainEvmCompatible, _isPureBitcoinChain, _isPureCardanoChain, _isPureSubstrateChain, _isPureTonChain } from '@subwallet/extension-base/services/chain-service/utils';
|
|
7
7
|
import { reformatAddress } from '@subwallet/extension-base/utils/account';
|
|
8
|
-
import { decodeAddress, encodeAddress,
|
|
9
|
-
import {
|
|
8
|
+
import { decodeAddress, encodeAddress, getKeypairTypeByAddress, isTonAddress } from '@subwallet/keyring';
|
|
9
|
+
import { BitcoinKeypairTypes, CardanoKeypairTypes, EthereumKeypairTypes, SubstrateKeypairTypes, TonKeypairTypes } from '@subwallet/keyring/types';
|
|
10
10
|
import { t } from 'i18next';
|
|
11
11
|
import { assert, BN, hexToU8a, isHex } from '@polkadot/util';
|
|
12
12
|
import { ethereumEncode, isEthereumAddress } from '@polkadot/util-crypto';
|
|
@@ -253,11 +253,12 @@ export function isSameAddressType(address1, address2) {
|
|
|
253
253
|
return isSameEvmAddress || isSameTonAddress || isSameSubstrateAddress;
|
|
254
254
|
}
|
|
255
255
|
export function isAddressAndChainCompatible(address, chain) {
|
|
256
|
-
const
|
|
257
|
-
const
|
|
258
|
-
const
|
|
259
|
-
const
|
|
260
|
-
const
|
|
256
|
+
const keypairType = getKeypairTypeByAddress(address);
|
|
257
|
+
const isEvmCompatible = _isChainEvmCompatible(chain) && EthereumKeypairTypes.includes(keypairType); // some chains compatible to substrate and evm, and use evm-address
|
|
258
|
+
const isTonCompatible = _isPureTonChain(chain) && TonKeypairTypes.includes(keypairType);
|
|
259
|
+
const isSubstrateCompatible = _isPureSubstrateChain(chain) && SubstrateKeypairTypes.includes(keypairType);
|
|
260
|
+
const isCardanoCompatible = _isPureCardanoChain(chain) && CardanoKeypairTypes.includes(keypairType);
|
|
261
|
+
const isBitcoinCompatible = _isPureBitcoinChain(chain) && BitcoinKeypairTypes.includes(keypairType);
|
|
261
262
|
return isEvmCompatible || isSubstrateCompatible || isTonCompatible || isCardanoCompatible || isBitcoinCompatible;
|
|
262
263
|
}
|
|
263
264
|
export function getDomainFromUrl(url) {
|