ccxt 4.2.60 → 4.2.62
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/README.md +6 -5
- package/build.sh +1 -1
- package/dist/ccxt.browser.js +11280 -3407
- package/dist/ccxt.browser.min.js +7 -7
- package/dist/cjs/ccxt.js +4 -1
- package/dist/cjs/src/abstract/hyperliquid.js +9 -0
- package/dist/cjs/src/base/Exchange.js +22 -1
- package/dist/cjs/src/base/functions/encode.js +5 -0
- package/dist/cjs/src/base/functions.js +1 -0
- package/dist/cjs/src/bitfinex2.js +1 -1
- package/dist/cjs/src/bitget.js +74 -23
- package/dist/cjs/src/coinbase.js +108 -103
- package/dist/cjs/src/coinex.js +61 -1
- package/dist/cjs/src/hyperliquid.js +2035 -0
- package/dist/cjs/src/kraken.js +8 -2
- package/dist/cjs/src/krakenfutures.js +28 -0
- package/dist/cjs/src/kucoinfutures.js +2 -2
- package/dist/cjs/src/okx.js +1 -1
- package/dist/cjs/src/phemex.js +2 -2
- package/dist/cjs/src/pro/bingx.js +1 -0
- package/dist/cjs/src/static_dependencies/ethers/abi-coder.js +158 -0
- package/dist/cjs/src/static_dependencies/ethers/address/address.js +144 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/abstract-coder.js +407 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/address.js +45 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/anonymous.js +28 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/array.js +176 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/boolean.js +27 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/bytes.js +52 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/fixed-bytes.js +45 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/null.js +30 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/number.js +60 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/string.js +27 -0
- package/dist/cjs/src/static_dependencies/ethers/coders/tuple.js +68 -0
- package/dist/cjs/src/static_dependencies/ethers/fragments.js +614 -0
- package/dist/cjs/src/static_dependencies/ethers/hash/typed-data.js +492 -0
- package/dist/cjs/src/static_dependencies/ethers/index.js +35 -0
- package/dist/cjs/src/static_dependencies/ethers/interface.js +44 -0
- package/dist/cjs/src/static_dependencies/ethers/typed.js +618 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/base58.js +20 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/data.js +134 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/errors.js +228 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/events.js +13 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/fixednumber.js +29 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/index.js +53 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/maths.js +231 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/properties.js +47 -0
- package/dist/cjs/src/static_dependencies/ethers/utils/utf8.js +218 -0
- package/dist/cjs/src/static_dependencies/messagepack/msgpack.js +292 -0
- package/dist/cjs/src/tokocrypto.js +22 -2
- package/dist/cjs/src/wazirx.js +308 -3
- package/js/ccxt.d.ts +5 -2
- package/js/ccxt.js +4 -2
- package/js/src/abstract/coinbase.d.ts +3 -3
- package/js/src/abstract/hyperliquid.d.ts +9 -0
- package/js/src/abstract/hyperliquid.js +11 -0
- package/js/src/base/Exchange.d.ts +4 -0
- package/js/src/base/Exchange.js +13 -1
- package/js/src/base/functions/encode.d.ts +2 -1
- package/js/src/base/functions/encode.js +5 -1
- package/js/src/bitfinex2.js +1 -1
- package/js/src/bitget.js +74 -23
- package/js/src/coinbase.js +108 -103
- package/js/src/coinex.d.ts +3 -1
- package/js/src/coinex.js +61 -1
- package/js/src/hyperliquid.d.ts +83 -0
- package/js/src/hyperliquid.js +2036 -0
- package/js/src/kraken.js +8 -2
- package/js/src/krakenfutures.d.ts +2 -1
- package/js/src/krakenfutures.js +28 -0
- package/js/src/kucoinfutures.js +2 -2
- package/js/src/okx.js +1 -1
- package/js/src/phemex.js +2 -2
- package/js/src/pro/bingx.js +1 -0
- package/js/src/static_dependencies/ethers/abi-coder.d.ts +50 -0
- package/js/src/static_dependencies/ethers/abi-coder.js +148 -0
- package/js/src/static_dependencies/ethers/address/address.d.ts +55 -0
- package/js/src/static_dependencies/ethers/address/address.js +162 -0
- package/js/src/static_dependencies/ethers/address/checks.d.ts +80 -0
- package/js/src/static_dependencies/ethers/address/checks.js +119 -0
- package/js/src/static_dependencies/ethers/address/contract-address.d.ts +47 -0
- package/js/src/static_dependencies/ethers/address/contract-address.js +73 -0
- package/js/src/static_dependencies/ethers/address/index.d.ts +48 -0
- package/js/src/static_dependencies/ethers/address/index.js +24 -0
- package/js/src/static_dependencies/ethers/bytes32.d.ts +14 -0
- package/js/src/static_dependencies/ethers/bytes32.js +45 -0
- package/js/src/static_dependencies/ethers/coders/abstract-coder.d.ts +120 -0
- package/js/src/static_dependencies/ethers/coders/abstract-coder.js +424 -0
- package/js/src/static_dependencies/ethers/coders/address.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/address.js +34 -0
- package/js/src/static_dependencies/ethers/coders/anonymous.d.ts +14 -0
- package/js/src/static_dependencies/ethers/coders/anonymous.js +27 -0
- package/js/src/static_dependencies/ethers/coders/array.d.ts +24 -0
- package/js/src/static_dependencies/ethers/coders/array.js +162 -0
- package/js/src/static_dependencies/ethers/coders/boolean.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/boolean.js +26 -0
- package/js/src/static_dependencies/ethers/coders/bytes.d.ts +18 -0
- package/js/src/static_dependencies/ethers/coders/bytes.js +39 -0
- package/js/src/static_dependencies/ethers/coders/fixed-bytes.d.ts +14 -0
- package/js/src/static_dependencies/ethers/coders/fixed-bytes.js +32 -0
- package/js/src/static_dependencies/ethers/coders/null.d.ts +11 -0
- package/js/src/static_dependencies/ethers/coders/null.js +29 -0
- package/js/src/static_dependencies/ethers/coders/number.d.ts +15 -0
- package/js/src/static_dependencies/ethers/coders/number.js +48 -0
- package/js/src/static_dependencies/ethers/coders/string.d.ts +12 -0
- package/js/src/static_dependencies/ethers/coders/string.js +26 -0
- package/js/src/static_dependencies/ethers/coders/tuple.d.ts +15 -0
- package/js/src/static_dependencies/ethers/coders/tuple.js +67 -0
- package/js/src/static_dependencies/ethers/fragments.d.ts +458 -0
- package/js/src/static_dependencies/ethers/fragments.js +1252 -0
- package/js/src/static_dependencies/ethers/hash/index.d.ts +10 -0
- package/js/src/static_dependencies/ethers/hash/index.js +15 -0
- package/js/src/static_dependencies/ethers/hash/solidity.d.ts +30 -0
- package/js/src/static_dependencies/ethers/hash/solidity.js +107 -0
- package/js/src/static_dependencies/ethers/hash/typed-data.d.ts +144 -0
- package/js/src/static_dependencies/ethers/hash/typed-data.js +490 -0
- package/js/src/static_dependencies/ethers/index.d.ts +19 -0
- package/js/src/static_dependencies/ethers/index.js +22 -0
- package/js/src/static_dependencies/ethers/interface.d.ts +380 -0
- package/js/src/static_dependencies/ethers/interface.js +990 -0
- package/js/src/static_dependencies/ethers/typed.d.ts +569 -0
- package/js/src/static_dependencies/ethers/typed.js +608 -0
- package/js/src/static_dependencies/ethers/utils/base58.d.ts +22 -0
- package/js/src/static_dependencies/ethers/utils/base58.js +68 -0
- package/js/src/static_dependencies/ethers/utils/base64-browser.d.ts +3 -0
- package/js/src/static_dependencies/ethers/utils/base64-browser.js +24 -0
- package/js/src/static_dependencies/ethers/utils/base64.d.ts +39 -0
- package/js/src/static_dependencies/ethers/utils/base64.js +58 -0
- package/js/src/static_dependencies/ethers/utils/data.d.ts +92 -0
- package/js/src/static_dependencies/ethers/utils/data.js +175 -0
- package/js/src/static_dependencies/ethers/utils/errors.d.ts +509 -0
- package/js/src/static_dependencies/ethers/utils/errors.js +227 -0
- package/js/src/static_dependencies/ethers/utils/events.d.ts +76 -0
- package/js/src/static_dependencies/ethers/utils/events.js +52 -0
- package/js/src/static_dependencies/ethers/utils/fixednumber.d.ts +251 -0
- package/js/src/static_dependencies/ethers/utils/fixednumber.js +529 -0
- package/js/src/static_dependencies/ethers/utils/index.d.ts +30 -0
- package/js/src/static_dependencies/ethers/utils/index.js +38 -0
- package/js/src/static_dependencies/ethers/utils/maths.d.ts +65 -0
- package/js/src/static_dependencies/ethers/utils/maths.js +220 -0
- package/js/src/static_dependencies/ethers/utils/properties.d.ts +22 -0
- package/js/src/static_dependencies/ethers/utils/properties.js +59 -0
- package/js/src/static_dependencies/ethers/utils/rlp-decode.d.ts +5 -0
- package/js/src/static_dependencies/ethers/utils/rlp-decode.js +84 -0
- package/js/src/static_dependencies/ethers/utils/rlp-encode.d.ts +5 -0
- package/js/src/static_dependencies/ethers/utils/rlp-encode.js +54 -0
- package/js/src/static_dependencies/ethers/utils/rlp.d.ts +16 -0
- package/js/src/static_dependencies/ethers/utils/rlp.js +14 -0
- package/js/src/static_dependencies/ethers/utils/units.d.ts +23 -0
- package/js/src/static_dependencies/ethers/utils/units.js +88 -0
- package/js/src/static_dependencies/ethers/utils/utf8.d.ts +95 -0
- package/js/src/static_dependencies/ethers/utils/utf8.js +225 -0
- package/js/src/static_dependencies/ethers/utils/uuid.d.ts +7 -0
- package/js/src/static_dependencies/ethers/utils/uuid.js +35 -0
- package/js/src/static_dependencies/messagepack/msgpack.d.ts +2 -0
- package/js/src/static_dependencies/messagepack/msgpack.js +572 -0
- package/js/src/tokocrypto.js +22 -2
- package/js/src/wazirx.d.ts +12 -1
- package/js/src/wazirx.js +308 -3
- package/package.json +1 -1
- package/skip-tests.json +18 -0
package/js/src/kraken.js
CHANGED
|
@@ -1550,8 +1550,14 @@ export default class kraken extends Exchange {
|
|
|
1550
1550
|
// }
|
|
1551
1551
|
// }
|
|
1552
1552
|
//
|
|
1553
|
-
const description = this.
|
|
1554
|
-
|
|
1553
|
+
const description = this.safeDict(order, 'descr', {});
|
|
1554
|
+
let orderDescription = undefined;
|
|
1555
|
+
if (description !== undefined) {
|
|
1556
|
+
orderDescription = this.safeString(description, 'order');
|
|
1557
|
+
}
|
|
1558
|
+
else {
|
|
1559
|
+
orderDescription = this.safeString(order, 'descr');
|
|
1560
|
+
}
|
|
1555
1561
|
let side = undefined;
|
|
1556
1562
|
let type = undefined;
|
|
1557
1563
|
let marketId = undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Exchange from './abstract/krakenfutures.js';
|
|
2
|
-
import type { TransferEntry, Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OrderRequest, Order, Balances, Str, Ticker, OrderBook, Tickers, Strings, Market, Currency, Leverage } from './base/types.js';
|
|
2
|
+
import type { TransferEntry, Int, OrderSide, OrderType, OHLCV, Trade, FundingRateHistory, OrderRequest, Order, Balances, Str, Ticker, OrderBook, Tickers, Strings, Market, Currency, Leverage, Leverages } from './base/types.js';
|
|
3
3
|
/**
|
|
4
4
|
* @class krakenfutures
|
|
5
5
|
* @augments Exchange
|
|
@@ -94,6 +94,7 @@ export default class krakenfutures extends Exchange {
|
|
|
94
94
|
transferOut(code: string, amount: any, params?: {}): Promise<TransferEntry>;
|
|
95
95
|
transfer(code: string, amount: number, fromAccount: string, toAccount: string, params?: {}): Promise<TransferEntry>;
|
|
96
96
|
setLeverage(leverage: Int, symbol?: Str, params?: {}): Promise<any>;
|
|
97
|
+
fetchLeverages(symbols?: string[], params?: {}): Promise<Leverages>;
|
|
97
98
|
fetchLeverage(symbol: string, params?: {}): Promise<Leverage>;
|
|
98
99
|
parseLeverage(leverage: any, market?: any): Leverage;
|
|
99
100
|
handleErrors(code: any, reason: any, url: any, method: any, headers: any, body: any, response: any, requestHeaders: any, requestBody: any): any;
|
package/js/src/krakenfutures.js
CHANGED
|
@@ -58,6 +58,7 @@ export default class krakenfutures extends Exchange {
|
|
|
58
58
|
'fetchIsolatedBorrowRates': false,
|
|
59
59
|
'fetchIsolatedPositions': false,
|
|
60
60
|
'fetchLeverage': true,
|
|
61
|
+
'fetchLeverages': true,
|
|
61
62
|
'fetchLeverageTiers': true,
|
|
62
63
|
'fetchMarketLeverageTiers': 'emulated',
|
|
63
64
|
'fetchMarkets': true,
|
|
@@ -2459,6 +2460,33 @@ export default class krakenfutures extends Exchange {
|
|
|
2459
2460
|
//
|
|
2460
2461
|
return await this.privatePutLeveragepreferences(this.extend(request, params));
|
|
2461
2462
|
}
|
|
2463
|
+
async fetchLeverages(symbols = undefined, params = {}) {
|
|
2464
|
+
/**
|
|
2465
|
+
* @method
|
|
2466
|
+
* @name krakenfutures#fetchLeverages
|
|
2467
|
+
* @description fetch the set leverage for all contract and margin markets
|
|
2468
|
+
* @see https://docs.futures.kraken.com/#http-api-trading-v3-api-multi-collateral-get-the-leverage-setting-for-a-market
|
|
2469
|
+
* @param {string[]} [symbols] a list of unified market symbols
|
|
2470
|
+
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
2471
|
+
* @returns {object} a list of [leverage structures]{@link https://docs.ccxt.com/#/?id=leverage-structure}
|
|
2472
|
+
*/
|
|
2473
|
+
await this.loadMarkets();
|
|
2474
|
+
const response = await this.privateGetLeveragepreferences(params);
|
|
2475
|
+
//
|
|
2476
|
+
// {
|
|
2477
|
+
// "result": "success",
|
|
2478
|
+
// "serverTime": "2024-03-06T02:35:46.336Z",
|
|
2479
|
+
// "leveragePreferences": [
|
|
2480
|
+
// {
|
|
2481
|
+
// "symbol": "PF_ETHUSD",
|
|
2482
|
+
// "maxLeverage": 30.00
|
|
2483
|
+
// },
|
|
2484
|
+
// ]
|
|
2485
|
+
// }
|
|
2486
|
+
//
|
|
2487
|
+
const leveragePreferences = this.safeList(response, 'leveragePreferences', []);
|
|
2488
|
+
return this.parseLeverages(leveragePreferences, symbols, 'symbol');
|
|
2489
|
+
}
|
|
2462
2490
|
async fetchLeverage(symbol, params = {}) {
|
|
2463
2491
|
/**
|
|
2464
2492
|
* @method
|
package/js/src/kucoinfutures.js
CHANGED
|
@@ -2074,8 +2074,8 @@ export default class kucoinfutures extends kucoin {
|
|
|
2074
2074
|
// }
|
|
2075
2075
|
// }
|
|
2076
2076
|
//
|
|
2077
|
-
const data = this.
|
|
2078
|
-
const trades = this.
|
|
2077
|
+
const data = this.safeDict(response, 'data', {});
|
|
2078
|
+
const trades = this.safeList(data, 'items', []);
|
|
2079
2079
|
return this.parseTrades(trades, market, since, limit);
|
|
2080
2080
|
}
|
|
2081
2081
|
async fetchTrades(symbol, since = undefined, limit = undefined, params = {}) {
|
package/js/src/okx.js
CHANGED
|
@@ -5671,7 +5671,7 @@ export default class okx extends Exchange {
|
|
|
5671
5671
|
const fromAccountId = this.safeString(transfer, 'from');
|
|
5672
5672
|
const toAccountId = this.safeString(transfer, 'to');
|
|
5673
5673
|
const accountsById = this.safeValue(this.options, 'accountsById', {});
|
|
5674
|
-
const timestamp = this.safeInteger(transfer, 'ts'
|
|
5674
|
+
const timestamp = this.safeInteger(transfer, 'ts');
|
|
5675
5675
|
const balanceChange = this.safeString(transfer, 'sz');
|
|
5676
5676
|
if (balanceChange !== undefined) {
|
|
5677
5677
|
amount = this.parseNumber(Precise.stringAbs(balanceChange));
|
package/js/src/phemex.js
CHANGED
|
@@ -3361,7 +3361,7 @@ export default class phemex extends Exchange {
|
|
|
3361
3361
|
// ]
|
|
3362
3362
|
// }
|
|
3363
3363
|
//
|
|
3364
|
-
const data = this.
|
|
3364
|
+
const data = this.safeList(response, 'data', []);
|
|
3365
3365
|
return this.parseTransactions(data, currency, since, limit);
|
|
3366
3366
|
}
|
|
3367
3367
|
async fetchWithdrawals(code = undefined, since = undefined, limit = undefined, params = {}) {
|
|
@@ -3401,7 +3401,7 @@ export default class phemex extends Exchange {
|
|
|
3401
3401
|
// ]
|
|
3402
3402
|
// }
|
|
3403
3403
|
//
|
|
3404
|
-
const data = this.
|
|
3404
|
+
const data = this.safeList(response, 'data', []);
|
|
3405
3405
|
return this.parseTransactions(data, currency, since, limit);
|
|
3406
3406
|
}
|
|
3407
3407
|
parseTransactionStatus(status) {
|
package/js/src/pro/bingx.js
CHANGED
|
@@ -559,6 +559,7 @@ export default class bingx extends bingxRest {
|
|
|
559
559
|
* @param {object} [params] extra parameters specific to the exchange API endpoint
|
|
560
560
|
* @returns {int[][]} A list of candles ordered as timestamp, open, high, low, close, volume
|
|
561
561
|
*/
|
|
562
|
+
await this.loadMarkets();
|
|
562
563
|
const market = this.market(symbol);
|
|
563
564
|
const [marketType, query] = this.handleMarketTypeAndParams('watchOHLCV', market, params);
|
|
564
565
|
const url = this.safeValue(this.urls['api']['ws'], marketType);
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* When sending values to or receiving values from a [[Contract]], the
|
|
3
|
+
* data is generally encoded using the [ABI standard](link-solc-abi).
|
|
4
|
+
*
|
|
5
|
+
* The AbiCoder provides a utility to encode values to ABI data and
|
|
6
|
+
* decode values from ABI data.
|
|
7
|
+
*
|
|
8
|
+
* Most of the time, developers should favour the [[Contract]] class,
|
|
9
|
+
* which further abstracts a lot of the finer details of ABI data.
|
|
10
|
+
*
|
|
11
|
+
* @_section api/abi/abi-coder:ABI Encoding
|
|
12
|
+
*/
|
|
13
|
+
import { Result } from "./coders/abstract-coder.js";
|
|
14
|
+
import { ParamType } from "./fragments.js";
|
|
15
|
+
import type { BytesLike } from "./utils/index.js";
|
|
16
|
+
/**
|
|
17
|
+
* The **AbiCoder** is a low-level class responsible for encoding JavaScript
|
|
18
|
+
* values into binary data and decoding binary data into JavaScript values.
|
|
19
|
+
*/
|
|
20
|
+
export declare class AbiCoder {
|
|
21
|
+
#private;
|
|
22
|
+
/**
|
|
23
|
+
* Get the default values for the given %%types%%.
|
|
24
|
+
*
|
|
25
|
+
* For example, a ``uint`` is by default ``0`` and ``bool``
|
|
26
|
+
* is by default ``false``.
|
|
27
|
+
*/
|
|
28
|
+
getDefaultValue(types: ReadonlyArray<string | ParamType>): Result;
|
|
29
|
+
/**
|
|
30
|
+
* Encode the %%values%% as the %%types%% into ABI data.
|
|
31
|
+
*
|
|
32
|
+
* @returns DataHexstring
|
|
33
|
+
*/
|
|
34
|
+
encode(types: ReadonlyArray<string | ParamType>, values: ReadonlyArray<any>): string;
|
|
35
|
+
/**
|
|
36
|
+
* Decode the ABI %%data%% as the %%types%% into values.
|
|
37
|
+
*
|
|
38
|
+
* If %%loose%% decoding is enabled, then strict padding is
|
|
39
|
+
* not enforced. Some older versions of Solidity incorrectly
|
|
40
|
+
* padded event data emitted from ``external`` functions.
|
|
41
|
+
*/
|
|
42
|
+
decode(types: ReadonlyArray<string | ParamType>, data: BytesLike, loose?: boolean): Result;
|
|
43
|
+
static _setDefaultMaxInflation(value: number): void;
|
|
44
|
+
/**
|
|
45
|
+
* Returns the shared singleton instance of a default [[AbiCoder]].
|
|
46
|
+
*
|
|
47
|
+
* On the first call, the instance is created internally.
|
|
48
|
+
*/
|
|
49
|
+
static defaultAbiCoder(): AbiCoder;
|
|
50
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* When sending values to or receiving values from a [[Contract]], the
|
|
9
|
+
* data is generally encoded using the [ABI standard](link-solc-abi).
|
|
10
|
+
*
|
|
11
|
+
* The AbiCoder provides a utility to encode values to ABI data and
|
|
12
|
+
* decode values from ABI data.
|
|
13
|
+
*
|
|
14
|
+
* Most of the time, developers should favour the [[Contract]] class,
|
|
15
|
+
* which further abstracts a lot of the finer details of ABI data.
|
|
16
|
+
*
|
|
17
|
+
* @_section api/abi/abi-coder:ABI Encoding
|
|
18
|
+
*/
|
|
19
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
20
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
21
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
22
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
23
|
+
};
|
|
24
|
+
var _AbiCoder_instances, _AbiCoder_getCoder;
|
|
25
|
+
// See: https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
|
|
26
|
+
import { assertArgumentCount, assertArgument } from "./utils/index.js";
|
|
27
|
+
import { Reader, Writer } from "./coders/abstract-coder.js";
|
|
28
|
+
import { AddressCoder } from "./coders/address.js";
|
|
29
|
+
import { ArrayCoder } from "./coders/array.js";
|
|
30
|
+
import { BooleanCoder } from "./coders/boolean.js";
|
|
31
|
+
import { BytesCoder } from "./coders/bytes.js";
|
|
32
|
+
import { FixedBytesCoder } from "./coders/fixed-bytes.js";
|
|
33
|
+
import { NullCoder } from "./coders/null.js";
|
|
34
|
+
import { NumberCoder } from "./coders/number.js";
|
|
35
|
+
import { StringCoder } from "./coders/string.js";
|
|
36
|
+
import { TupleCoder } from "./coders/tuple.js";
|
|
37
|
+
import { ParamType } from "./fragments.js";
|
|
38
|
+
// https://docs.soliditylang.org/en/v0.8.17/control-structures.html
|
|
39
|
+
const PanicReasons = new Map();
|
|
40
|
+
PanicReasons.set(0x00, "GENERIC_PANIC");
|
|
41
|
+
PanicReasons.set(0x01, "ASSERT_FALSE");
|
|
42
|
+
PanicReasons.set(0x11, "OVERFLOW");
|
|
43
|
+
PanicReasons.set(0x12, "DIVIDE_BY_ZERO");
|
|
44
|
+
PanicReasons.set(0x21, "ENUM_RANGE_ERROR");
|
|
45
|
+
PanicReasons.set(0x22, "BAD_STORAGE_DATA");
|
|
46
|
+
PanicReasons.set(0x31, "STACK_UNDERFLOW");
|
|
47
|
+
PanicReasons.set(0x32, "ARRAY_RANGE_ERROR");
|
|
48
|
+
PanicReasons.set(0x41, "OUT_OF_MEMORY");
|
|
49
|
+
PanicReasons.set(0x51, "UNINITIALIZED_FUNCTION_CALL");
|
|
50
|
+
const paramTypeBytes = new RegExp(/^bytes([0-9]*)$/);
|
|
51
|
+
const paramTypeNumber = new RegExp(/^(u?int)([0-9]*)$/);
|
|
52
|
+
let defaultCoder = null;
|
|
53
|
+
let defaultMaxInflation = 1024;
|
|
54
|
+
/**
|
|
55
|
+
* The **AbiCoder** is a low-level class responsible for encoding JavaScript
|
|
56
|
+
* values into binary data and decoding binary data into JavaScript values.
|
|
57
|
+
*/
|
|
58
|
+
export class AbiCoder {
|
|
59
|
+
constructor() {
|
|
60
|
+
_AbiCoder_instances.add(this);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Get the default values for the given %%types%%.
|
|
64
|
+
*
|
|
65
|
+
* For example, a ``uint`` is by default ``0`` and ``bool``
|
|
66
|
+
* is by default ``false``.
|
|
67
|
+
*/
|
|
68
|
+
getDefaultValue(types) {
|
|
69
|
+
const coders = types.map((type) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, ParamType.from(type)));
|
|
70
|
+
const coder = new TupleCoder(coders, "_");
|
|
71
|
+
return coder.defaultValue();
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Encode the %%values%% as the %%types%% into ABI data.
|
|
75
|
+
*
|
|
76
|
+
* @returns DataHexstring
|
|
77
|
+
*/
|
|
78
|
+
encode(types, values) {
|
|
79
|
+
assertArgumentCount(values.length, types.length, "types/values length mismatch");
|
|
80
|
+
const coders = types.map((type) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, ParamType.from(type)));
|
|
81
|
+
const coder = (new TupleCoder(coders, "_"));
|
|
82
|
+
const writer = new Writer();
|
|
83
|
+
coder.encode(writer, values);
|
|
84
|
+
return writer.data;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Decode the ABI %%data%% as the %%types%% into values.
|
|
88
|
+
*
|
|
89
|
+
* If %%loose%% decoding is enabled, then strict padding is
|
|
90
|
+
* not enforced. Some older versions of Solidity incorrectly
|
|
91
|
+
* padded event data emitted from ``external`` functions.
|
|
92
|
+
*/
|
|
93
|
+
decode(types, data, loose) {
|
|
94
|
+
const coders = types.map((type) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, ParamType.from(type)));
|
|
95
|
+
const coder = new TupleCoder(coders, "_");
|
|
96
|
+
return coder.decode(new Reader(data, loose, defaultMaxInflation));
|
|
97
|
+
}
|
|
98
|
+
static _setDefaultMaxInflation(value) {
|
|
99
|
+
assertArgument(typeof (value) === "number" && Number.isInteger(value), "invalid defaultMaxInflation factor", "value", value);
|
|
100
|
+
defaultMaxInflation = value;
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Returns the shared singleton instance of a default [[AbiCoder]].
|
|
104
|
+
*
|
|
105
|
+
* On the first call, the instance is created internally.
|
|
106
|
+
*/
|
|
107
|
+
static defaultAbiCoder() {
|
|
108
|
+
if (defaultCoder == null) {
|
|
109
|
+
defaultCoder = new AbiCoder();
|
|
110
|
+
}
|
|
111
|
+
return defaultCoder;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
_AbiCoder_instances = new WeakSet(), _AbiCoder_getCoder = function _AbiCoder_getCoder(param) {
|
|
115
|
+
if (param.isArray()) {
|
|
116
|
+
return new ArrayCoder(__classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, param.arrayChildren), param.arrayLength, param.name);
|
|
117
|
+
}
|
|
118
|
+
if (param.isTuple()) {
|
|
119
|
+
return new TupleCoder(param.components.map((c) => __classPrivateFieldGet(this, _AbiCoder_instances, "m", _AbiCoder_getCoder).call(this, c)), param.name);
|
|
120
|
+
}
|
|
121
|
+
switch (param.baseType) {
|
|
122
|
+
case "address":
|
|
123
|
+
return new AddressCoder(param.name);
|
|
124
|
+
case "bool":
|
|
125
|
+
return new BooleanCoder(param.name);
|
|
126
|
+
case "string":
|
|
127
|
+
return new StringCoder(param.name);
|
|
128
|
+
case "bytes":
|
|
129
|
+
return new BytesCoder(param.name);
|
|
130
|
+
case "":
|
|
131
|
+
return new NullCoder(param.name);
|
|
132
|
+
}
|
|
133
|
+
// u?int[0-9]*
|
|
134
|
+
let match = param.type.match(paramTypeNumber);
|
|
135
|
+
if (match) {
|
|
136
|
+
let size = parseInt(match[2] || "256");
|
|
137
|
+
assertArgument(size !== 0 && size <= 256 && (size % 8) === 0, "invalid " + match[1] + " bit length", "param", param);
|
|
138
|
+
return new NumberCoder(size / 8, (match[1] === "int"), param.name);
|
|
139
|
+
}
|
|
140
|
+
// bytes[0-9]+
|
|
141
|
+
match = param.type.match(paramTypeBytes);
|
|
142
|
+
if (match) {
|
|
143
|
+
let size = parseInt(match[1]);
|
|
144
|
+
assertArgument(size !== 0 && size <= 32, "invalid bytes length", "param", param);
|
|
145
|
+
return new FixedBytesCoder(size, param.name);
|
|
146
|
+
}
|
|
147
|
+
assertArgument(false, "invalid type", "type", param.type);
|
|
148
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Returns a normalized and checksumed address for %%address%%.
|
|
3
|
+
* This accepts non-checksum addresses, checksum addresses and
|
|
4
|
+
* [[getIcapAddress]] formats.
|
|
5
|
+
*
|
|
6
|
+
* The checksum in Ethereum uses the capitalization (upper-case
|
|
7
|
+
* vs lower-case) of the characters within an address to encode
|
|
8
|
+
* its checksum, which offers, on average, a checksum of 15-bits.
|
|
9
|
+
*
|
|
10
|
+
* If %%address%% contains both upper-case and lower-case, it is
|
|
11
|
+
* assumed to already be a checksum address and its checksum is
|
|
12
|
+
* validated, and if the address fails its expected checksum an
|
|
13
|
+
* error is thrown.
|
|
14
|
+
*
|
|
15
|
+
* If you wish the checksum of %%address%% to be ignore, it should
|
|
16
|
+
* be converted to lower-case (i.e. ``.toLowercase()``) before
|
|
17
|
+
* being passed in. This should be a very rare situation though,
|
|
18
|
+
* that you wish to bypass the safegaurds in place to protect
|
|
19
|
+
* against an address that has been incorrectly copied from another
|
|
20
|
+
* source.
|
|
21
|
+
*
|
|
22
|
+
* @example:
|
|
23
|
+
* // Adds the checksum (via upper-casing specific letters)
|
|
24
|
+
* getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
|
|
25
|
+
* //_result:
|
|
26
|
+
*
|
|
27
|
+
* // Converts ICAP address and adds checksum
|
|
28
|
+
* getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
29
|
+
* //_result:
|
|
30
|
+
*
|
|
31
|
+
* // Throws an error if an address contains mixed case,
|
|
32
|
+
* // but the checksum fails
|
|
33
|
+
* getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
34
|
+
* //_error:
|
|
35
|
+
*/
|
|
36
|
+
export declare function getAddress(address: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* The [ICAP Address format](link-icap) format is an early checksum
|
|
39
|
+
* format which attempts to be compatible with the banking
|
|
40
|
+
* industry [IBAN format](link-wiki-iban) for bank accounts.
|
|
41
|
+
*
|
|
42
|
+
* It is no longer common or a recommended format.
|
|
43
|
+
*
|
|
44
|
+
* @example:
|
|
45
|
+
* getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
|
|
46
|
+
* //_result:
|
|
47
|
+
*
|
|
48
|
+
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
49
|
+
* //_result:
|
|
50
|
+
*
|
|
51
|
+
* // Throws an error if the ICAP checksum is wrong
|
|
52
|
+
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
|
|
53
|
+
* //_error:
|
|
54
|
+
*/
|
|
55
|
+
export declare function getIcapAddress(address: string): string;
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
// ----------------------------------------------------------------------------
|
|
2
|
+
|
|
3
|
+
// PLEASE DO NOT EDIT THIS FILE, IT IS GENERATED AND WILL BE OVERWRITTEN:
|
|
4
|
+
// https://github.com/ccxt/ccxt/blob/master/CONTRIBUTING.md#how-to-contribute-code
|
|
5
|
+
// EDIT THE CORRESPONDENT .ts FILE INSTEAD
|
|
6
|
+
|
|
7
|
+
// TODO: unify address functions in other language? or remove it?
|
|
8
|
+
import { keccak_256 as keccak256 } from '../../noble-hashes/sha3.js';
|
|
9
|
+
import { assertArgument } from "../utils/index.js";
|
|
10
|
+
const BN_0 = BigInt(0);
|
|
11
|
+
const BN_36 = BigInt(36);
|
|
12
|
+
function getChecksumAddress(address) {
|
|
13
|
+
// if (!isHexString(address, 20)) {
|
|
14
|
+
// logger.throwArgumentError("invalid address", "address", address);
|
|
15
|
+
// }
|
|
16
|
+
address = address.toLowerCase();
|
|
17
|
+
const chars = address.substring(2).split("");
|
|
18
|
+
const expanded = new Uint8Array(40);
|
|
19
|
+
for (let i = 0; i < 40; i++) {
|
|
20
|
+
expanded[i] = chars[i].charCodeAt(0);
|
|
21
|
+
}
|
|
22
|
+
const hashed = keccak256(expanded);
|
|
23
|
+
for (let i = 0; i < 40; 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
|
+
return "0x" + chars.join("");
|
|
32
|
+
}
|
|
33
|
+
// See: https://en.wikipedia.org/wiki/International_Bank_Account_Number
|
|
34
|
+
// Create lookup table
|
|
35
|
+
const ibanLookup = {};
|
|
36
|
+
for (let i = 0; i < 10; i++) {
|
|
37
|
+
ibanLookup[String(i)] = String(i);
|
|
38
|
+
}
|
|
39
|
+
for (let i = 0; i < 26; i++) {
|
|
40
|
+
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
|
+
function ibanChecksum(address) {
|
|
46
|
+
address = address.toUpperCase();
|
|
47
|
+
address = address.substring(4) + address.substring(0, 2) + "00";
|
|
48
|
+
let expanded = address.split("").map((c) => { return ibanLookup[c]; }).join("");
|
|
49
|
+
// Javascript can handle integers safely up to 15 (decimal) digits
|
|
50
|
+
while (expanded.length >= safeDigits) {
|
|
51
|
+
let block = expanded.substring(0, safeDigits);
|
|
52
|
+
expanded = parseInt(block, 10) % 97 + expanded.substring(block.length);
|
|
53
|
+
}
|
|
54
|
+
let checksum = String(98 - (parseInt(expanded, 10) % 97));
|
|
55
|
+
while (checksum.length < 2) {
|
|
56
|
+
checksum = "0" + checksum;
|
|
57
|
+
}
|
|
58
|
+
return checksum;
|
|
59
|
+
}
|
|
60
|
+
;
|
|
61
|
+
const Base36 = (function () {
|
|
62
|
+
;
|
|
63
|
+
const result = {};
|
|
64
|
+
for (let i = 0; i < 36; i++) {
|
|
65
|
+
const key = "0123456789abcdefghijklmnopqrstuvwxyz"[i];
|
|
66
|
+
result[key] = BigInt(i);
|
|
67
|
+
}
|
|
68
|
+
return result;
|
|
69
|
+
})();
|
|
70
|
+
function fromBase36(value) {
|
|
71
|
+
value = value.toLowerCase();
|
|
72
|
+
let result = BN_0;
|
|
73
|
+
for (let i = 0; i < value.length; i++) {
|
|
74
|
+
result = result * BN_36 + Base36[value[i]];
|
|
75
|
+
}
|
|
76
|
+
return result;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Returns a normalized and checksumed address for %%address%%.
|
|
80
|
+
* This accepts non-checksum addresses, checksum addresses and
|
|
81
|
+
* [[getIcapAddress]] formats.
|
|
82
|
+
*
|
|
83
|
+
* The checksum in Ethereum uses the capitalization (upper-case
|
|
84
|
+
* vs lower-case) of the characters within an address to encode
|
|
85
|
+
* its checksum, which offers, on average, a checksum of 15-bits.
|
|
86
|
+
*
|
|
87
|
+
* If %%address%% contains both upper-case and lower-case, it is
|
|
88
|
+
* assumed to already be a checksum address and its checksum is
|
|
89
|
+
* validated, and if the address fails its expected checksum an
|
|
90
|
+
* error is thrown.
|
|
91
|
+
*
|
|
92
|
+
* If you wish the checksum of %%address%% to be ignore, it should
|
|
93
|
+
* be converted to lower-case (i.e. ``.toLowercase()``) before
|
|
94
|
+
* being passed in. This should be a very rare situation though,
|
|
95
|
+
* that you wish to bypass the safegaurds in place to protect
|
|
96
|
+
* against an address that has been incorrectly copied from another
|
|
97
|
+
* source.
|
|
98
|
+
*
|
|
99
|
+
* @example:
|
|
100
|
+
* // Adds the checksum (via upper-casing specific letters)
|
|
101
|
+
* getAddress("0x8ba1f109551bd432803012645ac136ddd64dba72")
|
|
102
|
+
* //_result:
|
|
103
|
+
*
|
|
104
|
+
* // Converts ICAP address and adds checksum
|
|
105
|
+
* getAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
106
|
+
* //_result:
|
|
107
|
+
*
|
|
108
|
+
* // Throws an error if an address contains mixed case,
|
|
109
|
+
* // but the checksum fails
|
|
110
|
+
* getAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
111
|
+
* //_error:
|
|
112
|
+
*/
|
|
113
|
+
export function getAddress(address) {
|
|
114
|
+
assertArgument(typeof (address) === "string", "invalid address", "address", address);
|
|
115
|
+
if (address.match(/^(0x)?[0-9a-fA-F]{40}$/)) {
|
|
116
|
+
// Missing the 0x prefix
|
|
117
|
+
if (!address.startsWith("0x")) {
|
|
118
|
+
address = "0x" + address;
|
|
119
|
+
}
|
|
120
|
+
const result = getChecksumAddress(address);
|
|
121
|
+
// It is a checksummed address with a bad checksum
|
|
122
|
+
assertArgument(!address.match(/([A-F].*[a-f])|([a-f].*[A-F])/) || result === address, "bad address checksum", "address", address);
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
// Maybe ICAP? (we only support direct mode)
|
|
126
|
+
if (address.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)) {
|
|
127
|
+
// It is an ICAP address with a bad checksum
|
|
128
|
+
assertArgument(address.substring(2, 4) === ibanChecksum(address), "bad icap checksum", "address", address);
|
|
129
|
+
let result = fromBase36(address.substring(4)).toString(16);
|
|
130
|
+
while (result.length < 40) {
|
|
131
|
+
result = "0" + result;
|
|
132
|
+
}
|
|
133
|
+
return getChecksumAddress("0x" + result);
|
|
134
|
+
}
|
|
135
|
+
assertArgument(false, "invalid address", "address", address);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* The [ICAP Address format](link-icap) format is an early checksum
|
|
139
|
+
* format which attempts to be compatible with the banking
|
|
140
|
+
* industry [IBAN format](link-wiki-iban) for bank accounts.
|
|
141
|
+
*
|
|
142
|
+
* It is no longer common or a recommended format.
|
|
143
|
+
*
|
|
144
|
+
* @example:
|
|
145
|
+
* getIcapAddress("0x8ba1f109551bd432803012645ac136ddd64dba72");
|
|
146
|
+
* //_result:
|
|
147
|
+
*
|
|
148
|
+
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36");
|
|
149
|
+
* //_result:
|
|
150
|
+
*
|
|
151
|
+
* // Throws an error if the ICAP checksum is wrong
|
|
152
|
+
* getIcapAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK37");
|
|
153
|
+
* //_error:
|
|
154
|
+
*/
|
|
155
|
+
export function getIcapAddress(address) {
|
|
156
|
+
//let base36 = _base16To36(getAddress(address).substring(2)).toUpperCase();
|
|
157
|
+
let base36 = BigInt(getAddress(address)).toString(36).toUpperCase();
|
|
158
|
+
while (base36.length < 30) {
|
|
159
|
+
base36 = "0" + base36;
|
|
160
|
+
}
|
|
161
|
+
return "XE" + ibanChecksum("XE00" + base36) + base36;
|
|
162
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import type { Addressable, AddressLike, NameResolver } from "./index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Returns true if %%value%% is an object which implements the
|
|
4
|
+
* [[Addressable]] interface.
|
|
5
|
+
*
|
|
6
|
+
* @example:
|
|
7
|
+
* // Wallets and AbstractSigner sub-classes
|
|
8
|
+
* isAddressable(Wallet.createRandom())
|
|
9
|
+
* //_result:
|
|
10
|
+
*
|
|
11
|
+
* // Contracts
|
|
12
|
+
* contract = new Contract("dai.tokens.ethers.eth", [ ], provider)
|
|
13
|
+
* isAddressable(contract)
|
|
14
|
+
* //_result:
|
|
15
|
+
*/
|
|
16
|
+
export declare function isAddressable(value: any): value is Addressable;
|
|
17
|
+
/**
|
|
18
|
+
* Returns true if %%value%% is a valid address.
|
|
19
|
+
*
|
|
20
|
+
* @example:
|
|
21
|
+
* // Valid address
|
|
22
|
+
* isAddress("0x8ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
23
|
+
* //_result:
|
|
24
|
+
*
|
|
25
|
+
* // Valid ICAP address
|
|
26
|
+
* isAddress("XE65GB6LDNXYOFTX0NSV3FUWKOWIXAMJK36")
|
|
27
|
+
* //_result:
|
|
28
|
+
*
|
|
29
|
+
* // Invalid checksum
|
|
30
|
+
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBa72")
|
|
31
|
+
* //_result:
|
|
32
|
+
*
|
|
33
|
+
* // Invalid ICAP checksum
|
|
34
|
+
* isAddress("0x8Ba1f109551bD432803012645Ac136ddd64DBA72")
|
|
35
|
+
* //_result:
|
|
36
|
+
*
|
|
37
|
+
* // Not an address (an ENS name requires a provided and an
|
|
38
|
+
* // asynchronous API to access)
|
|
39
|
+
* isAddress("ricmoo.eth")
|
|
40
|
+
* //_result:
|
|
41
|
+
*/
|
|
42
|
+
export declare function isAddress(value: any): value is string;
|
|
43
|
+
/**
|
|
44
|
+
* Resolves to an address for the %%target%%, which may be any
|
|
45
|
+
* supported address type, an [[Addressable]] or a Promise which
|
|
46
|
+
* resolves to an address.
|
|
47
|
+
*
|
|
48
|
+
* If an ENS name is provided, but that name has not been correctly
|
|
49
|
+
* configured a [[UnconfiguredNameError]] is thrown.
|
|
50
|
+
*
|
|
51
|
+
* @example:
|
|
52
|
+
* addr = "0x6B175474E89094C44Da98b954EedeAC495271d0F"
|
|
53
|
+
*
|
|
54
|
+
* // Addresses are return synchronously
|
|
55
|
+
* resolveAddress(addr, provider)
|
|
56
|
+
* //_result:
|
|
57
|
+
*
|
|
58
|
+
* // Address promises are resolved asynchronously
|
|
59
|
+
* resolveAddress(Promise.resolve(addr))
|
|
60
|
+
* //_result:
|
|
61
|
+
*
|
|
62
|
+
* // ENS names are resolved asynchronously
|
|
63
|
+
* resolveAddress("dai.tokens.ethers.eth", provider)
|
|
64
|
+
* //_result:
|
|
65
|
+
*
|
|
66
|
+
* // Addressable objects are resolved asynchronously
|
|
67
|
+
* contract = new Contract(addr, [ ])
|
|
68
|
+
* resolveAddress(contract, provider)
|
|
69
|
+
* //_result:
|
|
70
|
+
*
|
|
71
|
+
* // Unconfigured ENS names reject
|
|
72
|
+
* resolveAddress("nothing-here.ricmoo.eth", provider)
|
|
73
|
+
* //_error:
|
|
74
|
+
*
|
|
75
|
+
* // ENS names require a NameResolver object passed in
|
|
76
|
+
* // (notice the provider was omitted)
|
|
77
|
+
* resolveAddress("nothing-here.ricmoo.eth")
|
|
78
|
+
* //_error:
|
|
79
|
+
*/
|
|
80
|
+
export declare function resolveAddress(target: AddressLike, resolver?: null | NameResolver): string | Promise<string>;
|