quantumcoin 6.14.2 → 6.14.5
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/CHANGELOG.md +442 -442
- package/FUNDING.json +10 -10
- package/LICENSE.md +21 -21
- package/README.md +132 -142
- package/SECURITY.md +34 -34
- package/dist/README.md +22 -22
- package/dist/quantumcoin.js +1127 -1324
- package/dist/quantumcoin.js.map +1 -1
- package/dist/quantumcoin.min.js +1 -1
- package/dist/quantumcoin.umd.js +1128 -1327
- package/dist/quantumcoin.umd.js.map +1 -1
- package/dist/quantumcoin.umd.min.js +1 -1
- package/dist/wordlists-extra.js +1 -1
- package/dist/wordlists-extra.js.map +1 -1
- package/dist/wordlists-extra.min.js +1 -1
- package/lib.commonjs/README.md +16 -16
- package/lib.commonjs/_version.js +1 -1
- package/lib.commonjs/crypto/signature.d.ts +3 -76
- package/lib.commonjs/crypto/signature.d.ts.map +1 -1
- package/lib.commonjs/crypto/signature.js +15 -199
- package/lib.commonjs/crypto/signature.js.map +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts +1 -1
- package/lib.commonjs/crypto/signing-key.d.ts.map +1 -1
- package/lib.commonjs/crypto/signing-key.js +19 -10
- package/lib.commonjs/crypto/signing-key.js.map +1 -1
- package/lib.commonjs/package.json +12 -12
- package/lib.commonjs/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.commonjs/providers/provider-jsonrpc.js +0 -1
- package/lib.commonjs/providers/provider-jsonrpc.js.map +1 -1
- package/lib.commonjs/quantumcoin.d.ts +2 -0
- package/lib.commonjs/quantumcoin.d.ts.map +1 -1
- package/lib.commonjs/quantumcoin.js +11 -5
- package/lib.commonjs/quantumcoin.js.map +1 -1
- package/lib.commonjs/transaction/address.d.ts.map +1 -1
- package/lib.commonjs/transaction/address.js +8 -3
- package/lib.commonjs/transaction/address.js.map +1 -1
- package/lib.commonjs/transaction/transaction.d.ts.map +1 -1
- package/lib.commonjs/transaction/transaction.js +7 -40
- package/lib.commonjs/transaction/transaction.js.map +1 -1
- package/lib.commonjs/wallet/json-keystore.d.ts.map +1 -1
- package/lib.commonjs/wallet/json-keystore.js +7 -7
- package/lib.commonjs/wallet/json-keystore.js.map +1 -1
- package/lib.commonjs/wallet/wallet.d.ts.map +1 -1
- package/lib.commonjs/wallet/wallet.js +2 -2
- package/lib.commonjs/wallet/wallet.js.map +1 -1
- package/lib.esm/README.md +16 -16
- package/lib.esm/_version.js +1 -1
- package/lib.esm/crypto/signature.d.ts +3 -76
- package/lib.esm/crypto/signature.d.ts.map +1 -1
- package/lib.esm/crypto/signature.js +16 -202
- package/lib.esm/crypto/signature.js.map +1 -1
- package/lib.esm/crypto/signing-key.d.ts +1 -1
- package/lib.esm/crypto/signing-key.d.ts.map +1 -1
- package/lib.esm/crypto/signing-key.js +20 -9
- package/lib.esm/crypto/signing-key.js.map +1 -1
- package/lib.esm/package.json +12 -12
- package/lib.esm/providers/provider-jsonrpc.d.ts +0 -1
- package/lib.esm/providers/provider-jsonrpc.d.ts.map +1 -1
- package/lib.esm/providers/provider-jsonrpc.js +0 -1
- package/lib.esm/providers/provider-jsonrpc.js.map +1 -1
- package/lib.esm/quantumcoin.d.ts +2 -0
- package/lib.esm/quantumcoin.d.ts.map +1 -1
- package/lib.esm/quantumcoin.js +6 -0
- package/lib.esm/quantumcoin.js.map +1 -1
- package/lib.esm/transaction/address.d.ts.map +1 -1
- package/lib.esm/transaction/address.js +8 -2
- package/lib.esm/transaction/address.js.map +1 -1
- package/lib.esm/transaction/transaction.d.ts.map +1 -1
- package/lib.esm/transaction/transaction.js +7 -40
- package/lib.esm/transaction/transaction.js.map +1 -1
- package/lib.esm/wallet/json-keystore.d.ts.map +1 -1
- package/lib.esm/wallet/json-keystore.js +11 -5
- package/lib.esm/wallet/json-keystore.js.map +1 -1
- package/lib.esm/wallet/wallet.d.ts.map +1 -1
- package/lib.esm/wallet/wallet.js +3 -1
- package/lib.esm/wallet/wallet.js.map +1 -1
- package/package.json +6 -5
- package/rollup.config.mjs +50 -50
- package/src.ts/_version.ts +1 -1
- package/src.ts/abi/abi-coder.ts +237 -237
- package/src.ts/abi/bytes32.ts +45 -45
- package/src.ts/abi/coders/abstract-coder.ts +541 -541
- package/src.ts/abi/coders/address.ts +36 -36
- package/src.ts/abi/coders/anonymous.ts +29 -29
- package/src.ts/abi/coders/array.ts +199 -199
- package/src.ts/abi/coders/boolean.ts +27 -27
- package/src.ts/abi/coders/bytes.ts +43 -43
- package/src.ts/abi/coders/fixed-bytes.ts +37 -37
- package/src.ts/abi/coders/null.ts +28 -28
- package/src.ts/abi/coders/number.ts +63 -63
- package/src.ts/abi/coders/string.ts +29 -29
- package/src.ts/abi/coders/tuple.ts +69 -69
- package/src.ts/abi/fragments.ts +1617 -1617
- package/src.ts/abi/index.ts +41 -41
- package/src.ts/abi/interface.ts +1271 -1271
- package/src.ts/abi/typed.ts +796 -796
- package/src.ts/address/address.ts +148 -148
- package/src.ts/address/checks.ts +123 -123
- package/src.ts/address/contract-address.ts +80 -80
- package/src.ts/address/index.ts +57 -57
- package/src.ts/constants/addresses.ts +8 -8
- package/src.ts/constants/hashes.ts +7 -7
- package/src.ts/constants/index.ts +16 -16
- package/src.ts/constants/numbers.ts +35 -35
- package/src.ts/constants/strings.ts +16 -16
- package/src.ts/contract/contract.ts +1120 -1120
- package/src.ts/contract/factory.ts +143 -143
- package/src.ts/contract/index.ts +31 -31
- package/src.ts/contract/types.ts +236 -236
- package/src.ts/contract/wrappers.ts +225 -225
- package/src.ts/crypto/crypto-browser.ts +64 -64
- package/src.ts/crypto/crypto.ts +4 -4
- package/src.ts/crypto/hmac.ts +51 -51
- package/src.ts/crypto/index.ts +59 -59
- package/src.ts/crypto/keccak.ts +54 -54
- package/src.ts/crypto/pbkdf2.ts +55 -55
- package/src.ts/crypto/random.ts +36 -36
- package/src.ts/crypto/ripemd160.ts +43 -43
- package/src.ts/crypto/scrypt.ts +114 -114
- package/src.ts/crypto/sha2.ts +78 -78
- package/src.ts/crypto/signature.ts +145 -349
- package/src.ts/crypto/signing-key.ts +126 -118
- package/src.ts/hash/authorization.ts +38 -38
- package/src.ts/hash/id.ts +17 -17
- package/src.ts/hash/index.ts +18 -18
- package/src.ts/hash/message.ts +51 -51
- package/src.ts/hash/namehash.ts +101 -101
- package/src.ts/hash/solidity.ts +117 -117
- package/src.ts/hash/typed-data.ts +658 -658
- package/src.ts/index.ts +12 -12
- package/src.ts/providers/abstract-provider.ts +1761 -1761
- package/src.ts/providers/abstract-signer.ts +314 -314
- package/src.ts/providers/community.ts +49 -49
- package/src.ts/providers/contracts.ts +42 -42
- package/src.ts/providers/default-provider.ts +96 -96
- package/src.ts/providers/ens-resolver.ts +606 -606
- package/src.ts/providers/format.ts +320 -320
- package/src.ts/providers/formatting.ts +418 -418
- package/src.ts/providers/index.ts +125 -125
- package/src.ts/providers/network.ts +327 -327
- package/src.ts/providers/pagination.ts +8 -8
- package/src.ts/providers/plugin-fallback.ts +35 -35
- package/src.ts/providers/plugins-network.ts +281 -281
- package/src.ts/providers/provider-browser.ts +334 -334
- package/src.ts/providers/provider-fallback.ts +801 -801
- package/src.ts/providers/provider-ipcsocket-browser.ts +3 -3
- package/src.ts/providers/provider-ipcsocket.ts +81 -81
- package/src.ts/providers/provider-jsonrpc.ts +1334 -1335
- package/src.ts/providers/provider-socket.ts +352 -352
- package/src.ts/providers/provider-websocket.ts +103 -103
- package/src.ts/providers/provider.ts +2136 -2136
- package/src.ts/providers/signer-noncemanager.ts +98 -98
- package/src.ts/providers/signer.ts +166 -166
- package/src.ts/providers/subscriber-connection.ts +74 -74
- package/src.ts/providers/subscriber-filterid.ts +199 -199
- package/src.ts/providers/subscriber-polling.ts +321 -321
- package/src.ts/providers/ws-browser.ts +11 -11
- package/src.ts/providers/ws.ts +3 -3
- package/src.ts/quantumcoin.ts +219 -211
- package/src.ts/thirdparty.d.ts +16 -16
- package/src.ts/transaction/accesslist.ts +43 -43
- package/src.ts/transaction/address.ts +35 -31
- package/src.ts/transaction/authorization.ts +14 -14
- package/src.ts/transaction/index.ts +51 -51
- package/src.ts/transaction/transaction.ts +1349 -1379
- package/src.ts/utils/base58.ts +73 -73
- package/src.ts/utils/base64-browser.ts +25 -25
- package/src.ts/utils/base64.ts +56 -56
- package/src.ts/utils/data.ts +199 -199
- package/src.ts/utils/errors.ts +793 -793
- package/src.ts/utils/events.ts +105 -105
- package/src.ts/utils/fetch.ts +970 -970
- package/src.ts/utils/fixednumber.ts +643 -643
- package/src.ts/utils/geturl-browser.ts +81 -81
- package/src.ts/utils/geturl.ts +134 -134
- package/src.ts/utils/index.ts +95 -95
- package/src.ts/utils/maths.ts +240 -240
- package/src.ts/utils/properties.ts +60 -60
- package/src.ts/utils/rlp-decode.ts +104 -104
- package/src.ts/utils/rlp-encode.ts +64 -64
- package/src.ts/utils/rlp.ts +20 -20
- package/src.ts/utils/units.ts +91 -91
- package/src.ts/utils/utf8.ts +325 -325
- package/src.ts/utils/uuid.ts +36 -36
- package/src.ts/wallet/base-wallet.ts +160 -160
- package/src.ts/wallet/index.ts +32 -32
- package/src.ts/wallet/json-keystore.ts +108 -106
- package/src.ts/wallet/utils.ts +147 -147
- package/src.ts/wallet/wallet.ts +138 -139
- package/src.ts/wordlists/bit-reader.ts +35 -35
- package/src.ts/wordlists/decode-owl.ts +58 -58
- package/src.ts/wordlists/decode-owla.ts +33 -33
- package/src.ts/wordlists/generation/encode-latin.ts +370 -370
- package/src.ts/wordlists/index.ts +26 -26
- package/src.ts/wordlists/lang-cz.ts +33 -33
- package/src.ts/wordlists/lang-en.ts +33 -33
- package/src.ts/wordlists/lang-es.ts +35 -35
- package/src.ts/wordlists/lang-fr.ts +34 -34
- package/src.ts/wordlists/lang-it.ts +33 -33
- package/src.ts/wordlists/lang-ja.ts +181 -181
- package/src.ts/wordlists/lang-ko.ts +104 -104
- package/src.ts/wordlists/lang-pt.ts +34 -34
- package/src.ts/wordlists/lang-zh.ts +112 -112
- package/src.ts/wordlists/wordlist-owl.ts +77 -77
- package/src.ts/wordlists/wordlist-owla.ts +41 -41
- package/src.ts/wordlists/wordlist.ts +59 -59
- package/src.ts/wordlists/wordlists-browser.ts +8 -8
- package/src.ts/wordlists/wordlists-extra.ts +9 -9
- package/src.ts/wordlists/wordlists.ts +38 -38
- package/dist/quantumcoin.min.js'.gz' +0 -0
- package/dist/quantumcoin.umd.min.js'.gz' +0 -0
- package/dist/wordlists-extra.min.js'.gz' +0 -0
- package/lib.commonjs/providers/provider-alchemy.d.ts +0 -50
- package/lib.commonjs/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-alchemy.js +0 -151
- package/lib.commonjs/providers/provider-alchemy.js.map +0 -1
- package/lib.commonjs/providers/provider-ankr.d.ts +0 -61
- package/lib.commonjs/providers/provider-ankr.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-ankr.js +0 -137
- package/lib.commonjs/providers/provider-ankr.js.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.d.ts +0 -59
- package/lib.commonjs/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-blockscout.js +0 -145
- package/lib.commonjs/providers/provider-blockscout.js.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.d.ts +0 -46
- package/lib.commonjs/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-chainstack.js +0 -102
- package/lib.commonjs/providers/provider-chainstack.js.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.d.ts +0 -14
- package/lib.commonjs/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-cloudflare.js +0 -26
- package/lib.commonjs/providers/provider-cloudflare.js.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.d.ts +0 -147
- package/lib.commonjs/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-etherscan.js +0 -587
- package/lib.commonjs/providers/provider-etherscan.js.map +0 -1
- package/lib.commonjs/providers/provider-infura.d.ts +0 -101
- package/lib.commonjs/providers/provider-infura.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-infura.js +0 -206
- package/lib.commonjs/providers/provider-infura.js.map +0 -1
- package/lib.commonjs/providers/provider-pocket.d.ts +0 -54
- package/lib.commonjs/providers/provider-pocket.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-pocket.js +0 -109
- package/lib.commonjs/providers/provider-pocket.js.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.d.ts +0 -59
- package/lib.commonjs/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.commonjs/providers/provider-quicknode.js +0 -163
- package/lib.commonjs/providers/provider-quicknode.js.map +0 -1
- package/lib.commonjs/wallet/hdwallet.d.ts +0 -248
- package/lib.commonjs/wallet/hdwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/hdwallet.js +0 -505
- package/lib.commonjs/wallet/hdwallet.js.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.d.ts +0 -27
- package/lib.commonjs/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.commonjs/wallet/json-crowdsale.js +0 -60
- package/lib.commonjs/wallet/json-crowdsale.js.map +0 -1
- package/lib.commonjs/wallet/mnemonic.d.ts +0 -65
- package/lib.commonjs/wallet/mnemonic.d.ts.map +0 -1
- package/lib.commonjs/wallet/mnemonic.js +0 -169
- package/lib.commonjs/wallet/mnemonic.js.map +0 -1
- package/lib.commonjs/wallet/seedwallet.d.ts +0 -4
- package/lib.commonjs/wallet/seedwallet.d.ts.map +0 -1
- package/lib.commonjs/wallet/seedwallet.js +0 -8
- package/lib.commonjs/wallet/seedwallet.js.map +0 -1
- package/lib.esm/providers/provider-alchemy.d.ts +0 -50
- package/lib.esm/providers/provider-alchemy.d.ts.map +0 -1
- package/lib.esm/providers/provider-alchemy.js +0 -147
- package/lib.esm/providers/provider-alchemy.js.map +0 -1
- package/lib.esm/providers/provider-ankr.d.ts +0 -61
- package/lib.esm/providers/provider-ankr.d.ts.map +0 -1
- package/lib.esm/providers/provider-ankr.js +0 -133
- package/lib.esm/providers/provider-ankr.js.map +0 -1
- package/lib.esm/providers/provider-blockscout.d.ts +0 -59
- package/lib.esm/providers/provider-blockscout.d.ts.map +0 -1
- package/lib.esm/providers/provider-blockscout.js +0 -141
- package/lib.esm/providers/provider-blockscout.js.map +0 -1
- package/lib.esm/providers/provider-chainstack.d.ts +0 -46
- package/lib.esm/providers/provider-chainstack.d.ts.map +0 -1
- package/lib.esm/providers/provider-chainstack.js +0 -98
- package/lib.esm/providers/provider-chainstack.js.map +0 -1
- package/lib.esm/providers/provider-cloudflare.d.ts +0 -14
- package/lib.esm/providers/provider-cloudflare.d.ts.map +0 -1
- package/lib.esm/providers/provider-cloudflare.js +0 -22
- package/lib.esm/providers/provider-cloudflare.js.map +0 -1
- package/lib.esm/providers/provider-etherscan.d.ts +0 -147
- package/lib.esm/providers/provider-etherscan.d.ts.map +0 -1
- package/lib.esm/providers/provider-etherscan.js +0 -584
- package/lib.esm/providers/provider-etherscan.js.map +0 -1
- package/lib.esm/providers/provider-infura.d.ts +0 -101
- package/lib.esm/providers/provider-infura.d.ts.map +0 -1
- package/lib.esm/providers/provider-infura.js +0 -201
- package/lib.esm/providers/provider-infura.js.map +0 -1
- package/lib.esm/providers/provider-pocket.d.ts +0 -54
- package/lib.esm/providers/provider-pocket.d.ts.map +0 -1
- package/lib.esm/providers/provider-pocket.js +0 -105
- package/lib.esm/providers/provider-pocket.js.map +0 -1
- package/lib.esm/providers/provider-quicknode.d.ts +0 -59
- package/lib.esm/providers/provider-quicknode.d.ts.map +0 -1
- package/lib.esm/providers/provider-quicknode.js +0 -159
- package/lib.esm/providers/provider-quicknode.js.map +0 -1
- package/lib.esm/wallet/hdwallet.d.ts +0 -248
- package/lib.esm/wallet/hdwallet.d.ts.map +0 -1
- package/lib.esm/wallet/hdwallet.js +0 -498
- package/lib.esm/wallet/hdwallet.js.map +0 -1
- package/lib.esm/wallet/json-crowdsale.d.ts +0 -27
- package/lib.esm/wallet/json-crowdsale.d.ts.map +0 -1
- package/lib.esm/wallet/json-crowdsale.js +0 -55
- package/lib.esm/wallet/json-crowdsale.js.map +0 -1
- package/lib.esm/wallet/mnemonic.d.ts +0 -65
- package/lib.esm/wallet/mnemonic.d.ts.map +0 -1
- package/lib.esm/wallet/mnemonic.js +0 -165
- package/lib.esm/wallet/mnemonic.js.map +0 -1
- package/lib.esm/wallet/seedwallet.d.ts +0 -4
- package/lib.esm/wallet/seedwallet.d.ts.map +0 -1
- package/lib.esm/wallet/seedwallet.js +0 -4
- package/lib.esm/wallet/seedwallet.js.map +0 -1
|
@@ -1,148 +1,148 @@
|
|
|
1
|
-
import { keccak256 } from "../crypto/index.js";
|
|
2
|
-
import { getBytes, assertArgument } from "../utils/index.js";
|
|
3
|
-
|
|
4
|
-
const BN_0 = BigInt(0);
|
|
5
|
-
const BN_36 = BigInt(36);
|
|
6
|
-
|
|
7
|
-
function getChecksumAddress(address: string): string {
|
|
8
|
-
// if (!isHexString(address, 32)) {
|
|
9
|
-
// logger.throwArgumentError("invalid address", "address", address);
|
|
10
|
-
// }
|
|
11
|
-
|
|
12
|
-
address = address.toLowerCase();
|
|
13
|
-
|
|
14
|
-
const chars = address.substring(2).split("");
|
|
15
|
-
|
|
16
|
-
const expanded = new Uint8Array(64);
|
|
17
|
-
for (let i = 0; i < 64; i++) {
|
|
18
|
-
expanded[i] = chars[i].charCodeAt(0);
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const hashed = getBytes(keccak256(expanded));
|
|
22
|
-
|
|
23
|
-
for (let i = 0; i < 64; i += 2) {
|
|
24
|
-
if ((hashed[i >> 1] >> 4) >= 8) {
|
|
25
|
-
chars[i] = chars[i].toUpperCase();
|
|
26
|
-
}
|
|
27
|
-
if ((hashed[i >> 1] & 0x0f) >= 8) {
|
|
28
|
-
chars[i + 1] = chars[i + 1].toUpperCase();
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
return "0x" + chars.join("");
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number
|
|
36
|
-
|
|
37
|
-
// Create lookup table
|
|
38
|
-
const ibanLookup: { [character: string]: string } = { };
|
|
39
|
-
for (let i = 0; i < 10; i++) { ibanLookup[String(i)] = String(i); }
|
|
40
|
-
for (let i = 0; i < 26; i++) { ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); }
|
|
41
|
-
|
|
42
|
-
// How many decimal digits can we process? (for 64-bit float, this is 15)
|
|
43
|
-
// i.e. Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));
|
|
44
|
-
const safeDigits = 15;
|
|
45
|
-
|
|
46
|
-
function ibanChecksum(address: string): string {
|
|
47
|
-
address = address.toUpperCase();
|
|
48
|
-
address = address.substring(4) + address.substring(0, 2) + "00";
|
|
49
|
-
|
|
50
|
-
let expanded = address.split("").map((c) => { return ibanLookup[c]; }).join("");
|
|
51
|
-
|
|
52
|
-
// Javascript can handle integers safely up to 15 (decimal) digits
|
|
53
|
-
while (expanded.length >= safeDigits){
|
|
54
|
-
let block = expanded.substring(0, safeDigits);
|
|
55
|
-
expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
let checksum = String(98 - (parseInt(expanded, 10) % 97));
|
|
59
|
-
while (checksum.length < 2) { checksum = "0" + checksum; }
|
|
60
|
-
|
|
61
|
-
return checksum;
|
|
62
|
-
};
|
|
63
|
-
|
|
64
|
-
const Base36 = (function() {;
|
|
65
|
-
const result: Record<string, bigint> = { };
|
|
66
|
-
for (let i = 0; i < 36; i++) {
|
|
67
|
-
const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i];
|
|
68
|
-
result[key] = BigInt(i);
|
|
69
|
-
}
|
|
70
|
-
return result;
|
|
71
|
-
})();
|
|
72
|
-
|
|
73
|
-
function fromBase36(value: string): bigint {
|
|
74
|
-
value = value.toLowerCase();
|
|
75
|
-
|
|
76
|
-
let result = BN_0;
|
|
77
|
-
for (let i = 0; i < value.length; i++) {
|
|
78
|
-
result = result * BN_36 + Base36[value[i]];
|
|
79
|
-
}
|
|
80
|
-
return result;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
/**
|
|
84
|
-
* Returns a normalized and checksumed address for %%address%%.
|
|
85
|
-
* This accepts non-checksum addresses, checksum addresses formats.
|
|
86
|
-
*
|
|
87
|
-
* The checksum in Ethereum uses the capitalization (upper-case
|
|
88
|
-
* vs lower-case) of the characters within an address to encode
|
|
89
|
-
* its checksum, which offers, on average, a checksum of 15-bits.
|
|
90
|
-
*
|
|
91
|
-
* If %%address%% contains both upper-case and lower-case, it is
|
|
92
|
-
* assumed to already be a checksum address and its checksum is
|
|
93
|
-
* validated, and if the address fails its expected checksum an
|
|
94
|
-
* error is thrown.
|
|
95
|
-
*
|
|
96
|
-
* If you wish the checksum of %%address%% to be ignore, it should
|
|
97
|
-
* be converted to lower-case (i.e. ``.toLowercase()``) before
|
|
98
|
-
* being passed in. This should be a very rare situation though,
|
|
99
|
-
* that you wish to bypass the safegaurds in place to protect
|
|
100
|
-
* against an address that has been incorrectly copied from another
|
|
101
|
-
* source.
|
|
102
|
-
*
|
|
103
|
-
* @example:
|
|
104
|
-
* // Adds the checksum (via upper-casing specific letters)
|
|
105
|
-
* getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
|
|
106
|
-
* //_result:
|
|
107
|
-
*
|
|
108
|
-
* // Converts ICAP address and adds checksum
|
|
109
|
-
* getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
110
|
-
* //_result:
|
|
111
|
-
*
|
|
112
|
-
* // Throws an error if an address contains mixed case,
|
|
113
|
-
* // but the checksum fails
|
|
114
|
-
* getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
115
|
-
* //_error:
|
|
116
|
-
*/
|
|
117
|
-
export function getAddress(address: string): string {
|
|
118
|
-
|
|
119
|
-
assertArgument(typeof(address) === "string", "invalid address", "address", address);
|
|
120
|
-
|
|
121
|
-
if (address.match(/^(0x)?[0-9a-fA-F]{64}$/)) {
|
|
122
|
-
|
|
123
|
-
// Missing the 0x prefix
|
|
124
|
-
if (!address.startsWith("0x")) { address = "0x" + address; }
|
|
125
|
-
|
|
126
|
-
const result = getChecksumAddress(address);
|
|
127
|
-
|
|
128
|
-
// It is a checksummed address with a bad checksum
|
|
129
|
-
assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address,
|
|
130
|
-
"bad address checksum", "address", address);
|
|
131
|
-
|
|
132
|
-
return result;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
// Maybe ICAP? (we only support direct mode)
|
|
136
|
-
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
137
|
-
// It is an ICAP address with a bad checksum
|
|
138
|
-
assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address);
|
|
139
|
-
|
|
140
|
-
let result = fromBase36(address.substring(4)).toString(16);
|
|
141
|
-
while (result.length < 64) { result = "0" + result; }
|
|
142
|
-
return getChecksumAddress("0x" + result);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
assertArgument(false, "invalid address", "address", address);
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
|
|
1
|
+
import { keccak256 } from "../crypto/index.js";
|
|
2
|
+
import { getBytes, assertArgument } from "../utils/index.js";
|
|
3
|
+
|
|
4
|
+
const BN_0 = BigInt(0);
|
|
5
|
+
const BN_36 = BigInt(36);
|
|
6
|
+
|
|
7
|
+
function getChecksumAddress(address: string): string {
|
|
8
|
+
// if (!isHexString(address, 32)) {
|
|
9
|
+
// logger.throwArgumentError("invalid address", "address", address);
|
|
10
|
+
// }
|
|
11
|
+
|
|
12
|
+
address = address.toLowerCase();
|
|
13
|
+
|
|
14
|
+
const chars = address.substring(2).split("");
|
|
15
|
+
|
|
16
|
+
const expanded = new Uint8Array(64);
|
|
17
|
+
for (let i = 0; i < 64; i++) {
|
|
18
|
+
expanded[i] = chars[i].charCodeAt(0);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const hashed = getBytes(keccak256(expanded));
|
|
22
|
+
|
|
23
|
+
for (let i = 0; i < 64; i += 2) {
|
|
24
|
+
if ((hashed[i >> 1] >> 4) >= 8) {
|
|
25
|
+
chars[i] = chars[i].toUpperCase();
|
|
26
|
+
}
|
|
27
|
+
if ((hashed[i >> 1] & 0x0f) >= 8) {
|
|
28
|
+
chars[i + 1] = chars[i + 1].toUpperCase();
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return "0x" + chars.join("");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number
|
|
36
|
+
|
|
37
|
+
// Create lookup table
|
|
38
|
+
const ibanLookup: { [character: string]: string } = { };
|
|
39
|
+
for (let i = 0; i < 10; i++) { ibanLookup[String(i)] = String(i); }
|
|
40
|
+
for (let i = 0; i < 26; i++) { ibanLookup[String.fromCharCode(65 + i)] = String(10 + i); }
|
|
41
|
+
|
|
42
|
+
// How many decimal digits can we process? (for 64-bit float, this is 15)
|
|
43
|
+
// i.e. Math.floor(Math.log10(Number.MAX_SAFE_INTEGER));
|
|
44
|
+
const safeDigits = 15;
|
|
45
|
+
|
|
46
|
+
function ibanChecksum(address: string): string {
|
|
47
|
+
address = address.toUpperCase();
|
|
48
|
+
address = address.substring(4) + address.substring(0, 2) + "00";
|
|
49
|
+
|
|
50
|
+
let expanded = address.split("").map((c) => { return ibanLookup[c]; }).join("");
|
|
51
|
+
|
|
52
|
+
// Javascript can handle integers safely up to 15 (decimal) digits
|
|
53
|
+
while (expanded.length >= safeDigits){
|
|
54
|
+
let block = expanded.substring(0, safeDigits);
|
|
55
|
+
expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
let checksum = String(98 - (parseInt(expanded, 10) % 97));
|
|
59
|
+
while (checksum.length < 2) { checksum = "0" + checksum; }
|
|
60
|
+
|
|
61
|
+
return checksum;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const Base36 = (function() {;
|
|
65
|
+
const result: Record<string, bigint> = { };
|
|
66
|
+
for (let i = 0; i < 36; i++) {
|
|
67
|
+
const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i];
|
|
68
|
+
result[key] = BigInt(i);
|
|
69
|
+
}
|
|
70
|
+
return result;
|
|
71
|
+
})();
|
|
72
|
+
|
|
73
|
+
function fromBase36(value: string): bigint {
|
|
74
|
+
value = value.toLowerCase();
|
|
75
|
+
|
|
76
|
+
let result = BN_0;
|
|
77
|
+
for (let i = 0; i < value.length; i++) {
|
|
78
|
+
result = result * BN_36 + Base36[value[i]];
|
|
79
|
+
}
|
|
80
|
+
return result;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Returns a normalized and checksumed address for %%address%%.
|
|
85
|
+
* This accepts non-checksum addresses, checksum addresses formats.
|
|
86
|
+
*
|
|
87
|
+
* The checksum in Ethereum uses the capitalization (upper-case
|
|
88
|
+
* vs lower-case) of the characters within an address to encode
|
|
89
|
+
* its checksum, which offers, on average, a checksum of 15-bits.
|
|
90
|
+
*
|
|
91
|
+
* If %%address%% contains both upper-case and lower-case, it is
|
|
92
|
+
* assumed to already be a checksum address and its checksum is
|
|
93
|
+
* validated, and if the address fails its expected checksum an
|
|
94
|
+
* error is thrown.
|
|
95
|
+
*
|
|
96
|
+
* If you wish the checksum of %%address%% to be ignore, it should
|
|
97
|
+
* be converted to lower-case (i.e. ``.toLowercase()``) before
|
|
98
|
+
* being passed in. This should be a very rare situation though,
|
|
99
|
+
* that you wish to bypass the safegaurds in place to protect
|
|
100
|
+
* against an address that has been incorrectly copied from another
|
|
101
|
+
* source.
|
|
102
|
+
*
|
|
103
|
+
* @example:
|
|
104
|
+
* // Adds the checksum (via upper-casing specific letters)
|
|
105
|
+
* getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
|
|
106
|
+
* //_result:
|
|
107
|
+
*
|
|
108
|
+
* // Converts ICAP address and adds checksum
|
|
109
|
+
* getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
110
|
+
* //_result:
|
|
111
|
+
*
|
|
112
|
+
* // Throws an error if an address contains mixed case,
|
|
113
|
+
* // but the checksum fails
|
|
114
|
+
* getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
115
|
+
* //_error:
|
|
116
|
+
*/
|
|
117
|
+
export function getAddress(address: string): string {
|
|
118
|
+
|
|
119
|
+
assertArgument(typeof(address) === "string", "invalid address", "address", address);
|
|
120
|
+
|
|
121
|
+
if (address.match(/^(0x)?[0-9a-fA-F]{64}$/)) {
|
|
122
|
+
|
|
123
|
+
// Missing the 0x prefix
|
|
124
|
+
if (!address.startsWith("0x")) { address = "0x" + address; }
|
|
125
|
+
|
|
126
|
+
const result = getChecksumAddress(address);
|
|
127
|
+
|
|
128
|
+
// It is a checksummed address with a bad checksum
|
|
129
|
+
assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address,
|
|
130
|
+
"bad address checksum", "address", address);
|
|
131
|
+
|
|
132
|
+
return result;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
// Maybe ICAP? (we only support direct mode)
|
|
136
|
+
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
137
|
+
// It is an ICAP address with a bad checksum
|
|
138
|
+
assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address);
|
|
139
|
+
|
|
140
|
+
let result = fromBase36(address.substring(4)).toString(16);
|
|
141
|
+
while (result.length < 64) { result = "0" + result; }
|
|
142
|
+
return getChecksumAddress("0x" + result);
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
assertArgument(false, "invalid address", "address", address);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
|
package/src.ts/address/checks.ts
CHANGED
|
@@ -1,123 +1,123 @@
|
|
|
1
|
-
import { assert, assertArgument } from "../utils/index.js";
|
|
2
|
-
|
|
3
|
-
import { getAddress } from "./address.js";
|
|
4
|
-
|
|
5
|
-
import type { Addressable, AddressLike, NameResolver } from "./index.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Returns true if %%value%% is an object which implements the
|
|
10
|
-
* [[Addressable]] interface.
|
|
11
|
-
*
|
|
12
|
-
* @example:
|
|
13
|
-
* // Wallets and AbstractSigner sub-classes
|
|
14
|
-
* isAddressable(Wallet.createRandom())
|
|
15
|
-
* //_result:
|
|
16
|
-
*
|
|
17
|
-
* // Contracts
|
|
18
|
-
* contract = new Contract("dai.tokens.ethers.eth", [ ], provider)
|
|
19
|
-
* isAddressable(contract)
|
|
20
|
-
* //_result:
|
|
21
|
-
*/
|
|
22
|
-
export function isAddressable(value: any): value is Addressable {
|
|
23
|
-
return (value && typeof(value.getAddress) === "function");
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Returns true if %%value%% is a valid address.
|
|
28
|
-
*
|
|
29
|
-
* @example:
|
|
30
|
-
* // Valid address
|
|
31
|
-
* isAddress("0x8ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
32
|
-
* //_result:
|
|
33
|
-
*
|
|
34
|
-
* // Valid ICAP address
|
|
35
|
-
* isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36")
|
|
36
|
-
* //_result:
|
|
37
|
-
*
|
|
38
|
-
* // Invalid checksum
|
|
39
|
-
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBa72")
|
|
40
|
-
* //_result:
|
|
41
|
-
*
|
|
42
|
-
* // Invalid ICAP checksum
|
|
43
|
-
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
44
|
-
* //_result:
|
|
45
|
-
*
|
|
46
|
-
* // Not an address (an ENS name requires a provided and an
|
|
47
|
-
* // asynchronous API to access)
|
|
48
|
-
* isAddress("ricmoo.eth")
|
|
49
|
-
* //_result:
|
|
50
|
-
*/
|
|
51
|
-
export function isAddress(value: any): value is string {
|
|
52
|
-
try {
|
|
53
|
-
getAddress(value);
|
|
54
|
-
return true;
|
|
55
|
-
} catch (error) { }
|
|
56
|
-
return false;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
async function checkAddress(target: any, promise: Promise<null | string>): Promise<string> {
|
|
60
|
-
const result = await promise;
|
|
61
|
-
if (result == null || result === "0x0000000000000000000000000000000000000000") {
|
|
62
|
-
assert(typeof(target) !== "string", "unconfigured name", "UNCONFIGURED_NAME", { value: target });
|
|
63
|
-
assertArgument(false, "invalid AddressLike value; did not resolve to a value address", "target", target);
|
|
64
|
-
}
|
|
65
|
-
return getAddress(result);
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* Resolves to an address for the %%target%%, which may be any
|
|
70
|
-
* supported address type, an [[Addressable]] or a Promise which
|
|
71
|
-
* resolves to an address.
|
|
72
|
-
*
|
|
73
|
-
* If an ENS name is provided, but that name has not been correctly
|
|
74
|
-
* configured a [[UnconfiguredNameError]] is thrown.
|
|
75
|
-
*
|
|
76
|
-
* @example:
|
|
77
|
-
* addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
78
|
-
*
|
|
79
|
-
* // Addresses are return synchronously
|
|
80
|
-
* resolveAddress(addr, provider)
|
|
81
|
-
* //_result:
|
|
82
|
-
*
|
|
83
|
-
* // Address promises are resolved asynchronously
|
|
84
|
-
* resolveAddress(Promise.resolve(addr))
|
|
85
|
-
* //_result:
|
|
86
|
-
*
|
|
87
|
-
* // ENS names are resolved asynchronously
|
|
88
|
-
* resolveAddress("dai.tokens.ethers.eth", provider)
|
|
89
|
-
* //_result:
|
|
90
|
-
*
|
|
91
|
-
* // Addressable objects are resolved asynchronously
|
|
92
|
-
* contract = new Contract(addr, [ ])
|
|
93
|
-
* resolveAddress(contract, provider)
|
|
94
|
-
* //_result:
|
|
95
|
-
*
|
|
96
|
-
* // Unconfigured ENS names reject
|
|
97
|
-
* resolveAddress("nothing-here.ricmoo.eth", provider)
|
|
98
|
-
* //_error:
|
|
99
|
-
*
|
|
100
|
-
* // ENS names require a NameResolver object passed in
|
|
101
|
-
* // (notice the provider was omitted)
|
|
102
|
-
* resolveAddress("nothing-here.ricmoo.eth")
|
|
103
|
-
* //_error:
|
|
104
|
-
*/
|
|
105
|
-
export function resolveAddress(target: AddressLike, resolver?: null | NameResolver): string | Promise<string> {
|
|
106
|
-
|
|
107
|
-
if (typeof(target) === "string") {
|
|
108
|
-
if (target.match(/^0x[0-9a-f]{64}$/i)) { return getAddress(target); }
|
|
109
|
-
|
|
110
|
-
assert(resolver != null, "ENS resolution requires a provider",
|
|
111
|
-
"UNSUPPORTED_OPERATION", { operation: "resolveName" });
|
|
112
|
-
|
|
113
|
-
return checkAddress(target, resolver.resolveName(target));
|
|
114
|
-
|
|
115
|
-
} else if (isAddressable(target)) {
|
|
116
|
-
return checkAddress(target, target.getAddress());
|
|
117
|
-
|
|
118
|
-
} else if (target && typeof(target.then) === "function") {
|
|
119
|
-
return checkAddress(target, target);
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
assertArgument(false, "unsupported addressable value", "target", target);
|
|
123
|
-
}
|
|
1
|
+
import { assert, assertArgument } from "../utils/index.js";
|
|
2
|
+
|
|
3
|
+
import { getAddress } from "./address.js";
|
|
4
|
+
|
|
5
|
+
import type { Addressable, AddressLike, NameResolver } from "./index.js";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Returns true if %%value%% is an object which implements the
|
|
10
|
+
* [[Addressable]] interface.
|
|
11
|
+
*
|
|
12
|
+
* @example:
|
|
13
|
+
* // Wallets and AbstractSigner sub-classes
|
|
14
|
+
* isAddressable(Wallet.createRandom())
|
|
15
|
+
* //_result:
|
|
16
|
+
*
|
|
17
|
+
* // Contracts
|
|
18
|
+
* contract = new Contract("dai.tokens.ethers.eth", [ ], provider)
|
|
19
|
+
* isAddressable(contract)
|
|
20
|
+
* //_result:
|
|
21
|
+
*/
|
|
22
|
+
export function isAddressable(value: any): value is Addressable {
|
|
23
|
+
return (value && typeof(value.getAddress) === "function");
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Returns true if %%value%% is a valid address.
|
|
28
|
+
*
|
|
29
|
+
* @example:
|
|
30
|
+
* // Valid address
|
|
31
|
+
* isAddress("0x8ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
32
|
+
* //_result:
|
|
33
|
+
*
|
|
34
|
+
* // Valid ICAP address
|
|
35
|
+
* isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36")
|
|
36
|
+
* //_result:
|
|
37
|
+
*
|
|
38
|
+
* // Invalid checksum
|
|
39
|
+
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBa72")
|
|
40
|
+
* //_result:
|
|
41
|
+
*
|
|
42
|
+
* // Invalid ICAP checksum
|
|
43
|
+
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
44
|
+
* //_result:
|
|
45
|
+
*
|
|
46
|
+
* // Not an address (an ENS name requires a provided and an
|
|
47
|
+
* // asynchronous API to access)
|
|
48
|
+
* isAddress("ricmoo.eth")
|
|
49
|
+
* //_result:
|
|
50
|
+
*/
|
|
51
|
+
export function isAddress(value: any): value is string {
|
|
52
|
+
try {
|
|
53
|
+
getAddress(value);
|
|
54
|
+
return true;
|
|
55
|
+
} catch (error) { }
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async function checkAddress(target: any, promise: Promise<null | string>): Promise<string> {
|
|
60
|
+
const result = await promise;
|
|
61
|
+
if (result == null || result === "0x0000000000000000000000000000000000000000") {
|
|
62
|
+
assert(typeof(target) !== "string", "unconfigured name", "UNCONFIGURED_NAME", { value: target });
|
|
63
|
+
assertArgument(false, "invalid AddressLike value; did not resolve to a value address", "target", target);
|
|
64
|
+
}
|
|
65
|
+
return getAddress(result);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Resolves to an address for the %%target%%, which may be any
|
|
70
|
+
* supported address type, an [[Addressable]] or a Promise which
|
|
71
|
+
* resolves to an address.
|
|
72
|
+
*
|
|
73
|
+
* If an ENS name is provided, but that name has not been correctly
|
|
74
|
+
* configured a [[UnconfiguredNameError]] is thrown.
|
|
75
|
+
*
|
|
76
|
+
* @example:
|
|
77
|
+
* addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
78
|
+
*
|
|
79
|
+
* // Addresses are return synchronously
|
|
80
|
+
* resolveAddress(addr, provider)
|
|
81
|
+
* //_result:
|
|
82
|
+
*
|
|
83
|
+
* // Address promises are resolved asynchronously
|
|
84
|
+
* resolveAddress(Promise.resolve(addr))
|
|
85
|
+
* //_result:
|
|
86
|
+
*
|
|
87
|
+
* // ENS names are resolved asynchronously
|
|
88
|
+
* resolveAddress("dai.tokens.ethers.eth", provider)
|
|
89
|
+
* //_result:
|
|
90
|
+
*
|
|
91
|
+
* // Addressable objects are resolved asynchronously
|
|
92
|
+
* contract = new Contract(addr, [ ])
|
|
93
|
+
* resolveAddress(contract, provider)
|
|
94
|
+
* //_result:
|
|
95
|
+
*
|
|
96
|
+
* // Unconfigured ENS names reject
|
|
97
|
+
* resolveAddress("nothing-here.ricmoo.eth", provider)
|
|
98
|
+
* //_error:
|
|
99
|
+
*
|
|
100
|
+
* // ENS names require a NameResolver object passed in
|
|
101
|
+
* // (notice the provider was omitted)
|
|
102
|
+
* resolveAddress("nothing-here.ricmoo.eth")
|
|
103
|
+
* //_error:
|
|
104
|
+
*/
|
|
105
|
+
export function resolveAddress(target: AddressLike, resolver?: null | NameResolver): string | Promise<string> {
|
|
106
|
+
|
|
107
|
+
if (typeof(target) === "string") {
|
|
108
|
+
if (target.match(/^0x[0-9a-f]{64}$/i)) { return getAddress(target); }
|
|
109
|
+
|
|
110
|
+
assert(resolver != null, "ENS resolution requires a provider",
|
|
111
|
+
"UNSUPPORTED_OPERATION", { operation: "resolveName" });
|
|
112
|
+
|
|
113
|
+
return checkAddress(target, resolver.resolveName(target));
|
|
114
|
+
|
|
115
|
+
} else if (isAddressable(target)) {
|
|
116
|
+
return checkAddress(target, target.getAddress());
|
|
117
|
+
|
|
118
|
+
} else if (target && typeof(target.then) === "function") {
|
|
119
|
+
return checkAddress(target, target);
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
assertArgument(false, "unsupported addressable value", "target", target);
|
|
123
|
+
}
|