@openocean.finance/openocean-sdk 1.2.2 → 1.2.3
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/lib/api/index.js +139 -0
- package/lib/api/vo/RequestVo.js +411 -0
- package/lib/asset/abi/ERC20_abi.js +119 -0
- package/lib/asset/abi/aggregator.js +391 -0
- package/lib/config/index.js +33 -0
- package/lib/index.d.ts +7 -1
- package/lib/index.js +50 -2
- package/lib/swapSdk/Approve.js +342 -0
- package/lib/swapSdk/NotoMobile.js +141 -0
- package/lib/swapSdk/RequestVo.js +94 -0
- package/lib/swapSdk/Swap.js +1123 -0
- package/lib/swapSdk/getAllowance.js +97 -0
- package/lib/swapSdk/getBalance.js +280 -0
- package/lib/swapSdk/index.js +257 -0
- package/lib/swapSdk/qrcode.d.ts +6 -0
- package/lib/swapSdk/qrcode.js +969 -0
- package/lib/utils/ajx.js +150 -0
- package/lib/utils/index.js +369 -0
- package/lib/utils/web3.js +9 -0
- package/lib/v1/abis/ERC20.d.ts +16 -0
- package/lib/v1/abis/ERC20.js +22 -0
- package/lib/v1/abis/IUniswapV2Pair.d.ts +83 -0
- package/lib/v1/abis/IUniswapV2Pair.js +1434 -0
- package/lib/v1/constants.d.ts +58 -0
- package/lib/v1/constants.js +71 -0
- package/lib/v1/entities/currency.d.ts +27 -0
- package/lib/v1/entities/currency.js +39 -0
- package/lib/v1/entities/fractions/currencyAmount.d.ts +19 -0
- package/lib/v1/entities/fractions/currencyAmount.js +83 -0
- package/lib/v1/entities/fractions/fraction.d.ts +19 -0
- package/lib/v1/entities/fractions/fraction.js +109 -0
- package/lib/v1/entities/fractions/index.d.ts +5 -0
- package/lib/v1/entities/fractions/index.js +21 -0
- package/lib/v1/entities/fractions/percent.d.ts +6 -0
- package/lib/v1/entities/fractions/percent.js +37 -0
- package/lib/v1/entities/fractions/price.d.ts +18 -0
- package/lib/v1/entities/fractions/price.js +90 -0
- package/lib/v1/entities/fractions/tokenAmount.d.ts +9 -0
- package/lib/v1/entities/fractions/tokenAmount.js +43 -0
- package/lib/v1/entities/index.d.ts +6 -0
- package/lib/v1/entities/index.js +22 -0
- package/lib/v1/entities/pair.d.ts +41 -0
- package/lib/v1/entities/pair.js +210 -0
- package/lib/v1/entities/route.d.ts +14 -0
- package/lib/v1/entities/route.js +43 -0
- package/lib/v1/entities/token.d.ts +27 -0
- package/lib/v1/entities/token.js +87 -0
- package/lib/v1/entities/trade.d.ts +106 -0
- package/lib/v1/entities/trade.js +336 -0
- package/lib/v1/errors.d.ts +16 -0
- package/lib/v1/errors.js +56 -0
- package/lib/v1/fetcher.d.ts +28 -0
- package/lib/v1/fetcher.js +140 -0
- package/lib/v1/router.d.ts +56 -0
- package/lib/v1/router.js +97 -0
- package/lib/v1/utils.d.ts +7 -0
- package/lib/v1/utils.js +87 -0
- package/package.json +4 -1
- package/lib/index.js.LICENSE.txt +0 -279
package/lib/v1/router.js
ADDED
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Router = void 0;
|
|
7
|
+
var constants_1 = require("./constants");
|
|
8
|
+
var tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
9
|
+
var utils_1 = require("./utils");
|
|
10
|
+
var entities_1 = require("./entities");
|
|
11
|
+
function toHex(currencyAmount) {
|
|
12
|
+
return "0x".concat(currencyAmount.raw.toString(16));
|
|
13
|
+
}
|
|
14
|
+
var ZERO_HEX = '0x0';
|
|
15
|
+
/**
|
|
16
|
+
* Represents the Uniswap V2 Router, and has static methods for helping execute trades.
|
|
17
|
+
*/
|
|
18
|
+
var Router = /** @class */ (function () {
|
|
19
|
+
/**
|
|
20
|
+
* Cannot be constructed.
|
|
21
|
+
*/
|
|
22
|
+
function Router() {
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Produces the on-chain method name to call and the hex encoded parameters to pass as arguments for a given trade.
|
|
26
|
+
* @param trade to produce call parameters for
|
|
27
|
+
* @param options options for the call parameters
|
|
28
|
+
*/
|
|
29
|
+
Router.swapCallParameters = function (trade, options) {
|
|
30
|
+
var etherIn = trade.inputAmount.currency === entities_1.ETHER;
|
|
31
|
+
var etherOut = trade.outputAmount.currency === entities_1.ETHER;
|
|
32
|
+
// the router does not support both ether in and out
|
|
33
|
+
(0, tiny_invariant_1.default)(!(etherIn && etherOut), 'ETHER_IN_OUT');
|
|
34
|
+
(0, tiny_invariant_1.default)(options.ttl > 0, 'TTL');
|
|
35
|
+
var to = (0, utils_1.validateAndParseAddress)(options.recipient);
|
|
36
|
+
var amountIn = toHex(trade.maximumAmountIn(options.allowedSlippage));
|
|
37
|
+
var amountOut = toHex(trade.minimumAmountOut(options.allowedSlippage));
|
|
38
|
+
var path = trade.route.path.map(function (token) { return token.address; });
|
|
39
|
+
var deadline = "0x".concat((Math.floor(new Date().getTime() / 1000) + options.ttl).toString(16));
|
|
40
|
+
var useFeeOnTransfer = Boolean(options.feeOnTransfer);
|
|
41
|
+
var methodName;
|
|
42
|
+
var args;
|
|
43
|
+
var value;
|
|
44
|
+
switch (trade.tradeType) {
|
|
45
|
+
case constants_1.TradeType.EXACT_INPUT:
|
|
46
|
+
if (etherIn) {
|
|
47
|
+
methodName = useFeeOnTransfer ? 'swapExactETHForTokensSupportingFeeOnTransferTokens' : 'swapExactETHForTokens';
|
|
48
|
+
// (uint amountOutMin, address[] calldata path, address to, uint deadline)
|
|
49
|
+
args = [amountOut, path, to, deadline];
|
|
50
|
+
value = amountIn;
|
|
51
|
+
}
|
|
52
|
+
else if (etherOut) {
|
|
53
|
+
methodName = useFeeOnTransfer ? 'swapExactTokensForETHSupportingFeeOnTransferTokens' : 'swapExactTokensForETH';
|
|
54
|
+
// (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
|
|
55
|
+
args = [amountIn, amountOut, path, to, deadline];
|
|
56
|
+
value = ZERO_HEX;
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
methodName = useFeeOnTransfer
|
|
60
|
+
? 'swapExactTokensForTokensSupportingFeeOnTransferTokens'
|
|
61
|
+
: 'swapExactTokensForTokens';
|
|
62
|
+
// (uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
|
|
63
|
+
args = [amountIn, amountOut, path, to, deadline];
|
|
64
|
+
value = ZERO_HEX;
|
|
65
|
+
}
|
|
66
|
+
break;
|
|
67
|
+
case constants_1.TradeType.EXACT_OUTPUT:
|
|
68
|
+
(0, tiny_invariant_1.default)(!useFeeOnTransfer, 'EXACT_OUT_FOT');
|
|
69
|
+
if (etherIn) {
|
|
70
|
+
methodName = 'swapETHForExactTokens';
|
|
71
|
+
// (uint amountOut, address[] calldata path, address to, uint deadline)
|
|
72
|
+
args = [amountOut, path, to, deadline];
|
|
73
|
+
value = amountIn;
|
|
74
|
+
}
|
|
75
|
+
else if (etherOut) {
|
|
76
|
+
methodName = 'swapTokensForExactETH';
|
|
77
|
+
// (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
|
|
78
|
+
args = [amountOut, amountIn, path, to, deadline];
|
|
79
|
+
value = ZERO_HEX;
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
methodName = 'swapTokensForExactTokens';
|
|
83
|
+
// (uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
|
|
84
|
+
args = [amountOut, amountIn, path, to, deadline];
|
|
85
|
+
value = ZERO_HEX;
|
|
86
|
+
}
|
|
87
|
+
break;
|
|
88
|
+
}
|
|
89
|
+
return {
|
|
90
|
+
methodName: methodName,
|
|
91
|
+
args: args,
|
|
92
|
+
value: value
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
return Router;
|
|
96
|
+
}());
|
|
97
|
+
exports.Router = Router;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import JSBI from 'jsbi';
|
|
2
|
+
import { BigintIsh, SolidityType } from './constants';
|
|
3
|
+
export declare function validateSolidityTypeInstance(value: JSBI, solidityType: SolidityType): void;
|
|
4
|
+
export declare function validateAndParseAddress(address: string): string;
|
|
5
|
+
export declare function parseBigintIsh(bigintIsh: BigintIsh): JSBI;
|
|
6
|
+
export declare function sqrt(y: JSBI): JSBI;
|
|
7
|
+
export declare function sortedInsert<T>(items: T[], add: T, maxSize: number, comparator: (a: T, b: T) => number): T | null;
|
package/lib/v1/utils.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.sortedInsert = exports.sqrt = exports.parseBigintIsh = exports.validateAndParseAddress = exports.validateSolidityTypeInstance = void 0;
|
|
7
|
+
var tiny_invariant_1 = __importDefault(require("tiny-invariant"));
|
|
8
|
+
var tiny_warning_1 = __importDefault(require("tiny-warning"));
|
|
9
|
+
var jsbi_1 = __importDefault(require("jsbi"));
|
|
10
|
+
var address_1 = require("@ethersproject/address");
|
|
11
|
+
var constants_1 = require("./constants");
|
|
12
|
+
function validateSolidityTypeInstance(value, solidityType) {
|
|
13
|
+
(0, tiny_invariant_1.default)(jsbi_1.default.greaterThanOrEqual(value, constants_1.ZERO), "".concat(value, " is not a ").concat(solidityType, "."));
|
|
14
|
+
(0, tiny_invariant_1.default)(jsbi_1.default.lessThanOrEqual(value, constants_1.SOLIDITY_TYPE_MAXIMA[solidityType]), "".concat(value, " is not a ").concat(solidityType, "."));
|
|
15
|
+
}
|
|
16
|
+
exports.validateSolidityTypeInstance = validateSolidityTypeInstance;
|
|
17
|
+
// warns if addresses are not checksummed
|
|
18
|
+
function validateAndParseAddress(address) {
|
|
19
|
+
try {
|
|
20
|
+
var checksummedAddress = (0, address_1.getAddress)(address);
|
|
21
|
+
(0, tiny_warning_1.default)(address === checksummedAddress, "".concat(address, " is not checksummed."));
|
|
22
|
+
return checksummedAddress;
|
|
23
|
+
}
|
|
24
|
+
catch (error) {
|
|
25
|
+
(0, tiny_invariant_1.default)(false, "".concat(address, " is not a valid address."));
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.validateAndParseAddress = validateAndParseAddress;
|
|
29
|
+
function parseBigintIsh(bigintIsh) {
|
|
30
|
+
return bigintIsh instanceof jsbi_1.default
|
|
31
|
+
? bigintIsh
|
|
32
|
+
: typeof bigintIsh === 'bigint'
|
|
33
|
+
? jsbi_1.default.BigInt(bigintIsh.toString())
|
|
34
|
+
: jsbi_1.default.BigInt(bigintIsh);
|
|
35
|
+
}
|
|
36
|
+
exports.parseBigintIsh = parseBigintIsh;
|
|
37
|
+
// mock the on-chain sqrt function
|
|
38
|
+
function sqrt(y) {
|
|
39
|
+
validateSolidityTypeInstance(y, constants_1.SolidityType.uint256);
|
|
40
|
+
var z = constants_1.ZERO;
|
|
41
|
+
var x;
|
|
42
|
+
if (jsbi_1.default.greaterThan(y, constants_1.THREE)) {
|
|
43
|
+
z = y;
|
|
44
|
+
x = jsbi_1.default.add(jsbi_1.default.divide(y, constants_1.TWO), constants_1.ONE);
|
|
45
|
+
while (jsbi_1.default.lessThan(x, z)) {
|
|
46
|
+
z = x;
|
|
47
|
+
x = jsbi_1.default.divide(jsbi_1.default.add(jsbi_1.default.divide(y, x), x), constants_1.TWO);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
else if (jsbi_1.default.notEqual(y, constants_1.ZERO)) {
|
|
51
|
+
z = constants_1.ONE;
|
|
52
|
+
}
|
|
53
|
+
return z;
|
|
54
|
+
}
|
|
55
|
+
exports.sqrt = sqrt;
|
|
56
|
+
// given an array of items sorted by `comparator`, insert an item into its sort index and constrain the size to
|
|
57
|
+
// `maxSize` by removing the last item
|
|
58
|
+
function sortedInsert(items, add, maxSize, comparator) {
|
|
59
|
+
(0, tiny_invariant_1.default)(maxSize > 0, 'MAX_SIZE_ZERO');
|
|
60
|
+
// this is an invariant because the interface cannot return multiple removed items if items.length exceeds maxSize
|
|
61
|
+
(0, tiny_invariant_1.default)(items.length <= maxSize, 'ITEMS_SIZE');
|
|
62
|
+
// short circuit first item add
|
|
63
|
+
if (items.length === 0) {
|
|
64
|
+
items.push(add);
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
var isFull = items.length === maxSize;
|
|
69
|
+
// short circuit if full and the additional item does not come before the last item
|
|
70
|
+
if (isFull && comparator(items[items.length - 1], add) <= 0) {
|
|
71
|
+
return add;
|
|
72
|
+
}
|
|
73
|
+
var lo = 0, hi = items.length;
|
|
74
|
+
while (lo < hi) {
|
|
75
|
+
var mid = (lo + hi) >>> 1;
|
|
76
|
+
if (comparator(items[mid], add) <= 0) {
|
|
77
|
+
lo = mid + 1;
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
hi = mid;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
items.splice(lo, 0, add);
|
|
84
|
+
return isFull ? items.pop() : null;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
exports.sortedInsert = sortedInsert;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openocean.finance/openocean-sdk",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.3",
|
|
4
4
|
"description": "Openocean sdk",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
"@looksrare/sdk": "^0.12.1",
|
|
51
51
|
"@openocean.finance/wallet": "^1.2.1",
|
|
52
52
|
"@solana/buffer-layout": "^4.0.0",
|
|
53
|
+
"@uniswap/v2-core": "^1.0.1",
|
|
53
54
|
"@walletconnect/web3-provider": "^1.7.8",
|
|
54
55
|
"aptos": "^1.3.17",
|
|
55
56
|
"bs58": "^4.0.1",
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
"class-validator": "^0.13.2",
|
|
59
60
|
"eth-sig-util": "^3.0.1",
|
|
60
61
|
"fs": "^0.0.1-security",
|
|
62
|
+
"jsbi": "^4.3.0",
|
|
61
63
|
"json-loader": "^0.5.7",
|
|
62
64
|
"nifty-protocol": "^1.0.62",
|
|
63
65
|
"node-polyfill-webpack-plugin": "^1.1.4",
|
|
@@ -65,6 +67,7 @@
|
|
|
65
67
|
"path-browserify": "^1.0.1",
|
|
66
68
|
"prompts": "^2.4.1",
|
|
67
69
|
"reflect-metadata": "^0.1.13",
|
|
70
|
+
"tiny-warning": "^1.0.3",
|
|
68
71
|
"vconsole": "^3.14.6",
|
|
69
72
|
"web3": "^1.7.4",
|
|
70
73
|
"yargs": "^17.0.1"
|
package/lib/index.js.LICENSE.txt
DELETED
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
object-assign
|
|
3
|
-
(c) Sindre Sorhus
|
|
4
|
-
@license MIT
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/*!
|
|
8
|
-
* mustache.js - Logic-less {{mustache}} templates with JavaScript
|
|
9
|
-
* http://github.com/janl/mustache.js
|
|
10
|
-
*/
|
|
11
|
-
|
|
12
|
-
/*!
|
|
13
|
-
* Fast "async" scrypt implementation in JavaScript.
|
|
14
|
-
* Copyright (c) 2013-2016 Dmitry Chestnykh | BSD License
|
|
15
|
-
* https://github.com/dchest/scrypt-async-js
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
/*!
|
|
19
|
-
* The buffer module from node.js, for the browser.
|
|
20
|
-
*
|
|
21
|
-
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
|
|
22
|
-
* @license MIT
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
/*!
|
|
26
|
-
* The buffer module from node.js, for the browser.
|
|
27
|
-
*
|
|
28
|
-
* @author Feross Aboukhadijeh <https://feross.org>
|
|
29
|
-
* @license MIT
|
|
30
|
-
*/
|
|
31
|
-
|
|
32
|
-
/*!
|
|
33
|
-
* depd
|
|
34
|
-
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
35
|
-
* MIT Licensed
|
|
36
|
-
*/
|
|
37
|
-
|
|
38
|
-
/*!
|
|
39
|
-
* http-errors
|
|
40
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
41
|
-
* Copyright(c) 2016 Douglas Christopher Wilson
|
|
42
|
-
* MIT Licensed
|
|
43
|
-
*/
|
|
44
|
-
|
|
45
|
-
/*!
|
|
46
|
-
* statuses
|
|
47
|
-
* Copyright(c) 2014 Jonathan Ong
|
|
48
|
-
* Copyright(c) 2016 Douglas Christopher Wilson
|
|
49
|
-
* MIT Licensed
|
|
50
|
-
*/
|
|
51
|
-
|
|
52
|
-
/*!
|
|
53
|
-
* toidentifier
|
|
54
|
-
* Copyright(c) 2016 Douglas Christopher Wilson
|
|
55
|
-
* MIT Licensed
|
|
56
|
-
*/
|
|
57
|
-
|
|
58
|
-
/*!
|
|
59
|
-
* v2.1.4-104-gc868b3a
|
|
60
|
-
*
|
|
61
|
-
*/
|
|
62
|
-
|
|
63
|
-
/*! *****************************************************************************
|
|
64
|
-
Copyright (C) Microsoft. All rights reserved.
|
|
65
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
66
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
67
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
68
|
-
|
|
69
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
70
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
71
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
72
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
73
|
-
|
|
74
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
75
|
-
and limitations under the License.
|
|
76
|
-
***************************************************************************** */
|
|
77
|
-
|
|
78
|
-
/*! *****************************************************************************
|
|
79
|
-
Copyright (c) Microsoft Corporation.
|
|
80
|
-
|
|
81
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
82
|
-
purpose with or without fee is hereby granted.
|
|
83
|
-
|
|
84
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
85
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
86
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
87
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
88
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
89
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
90
|
-
PERFORMANCE OF THIS SOFTWARE.
|
|
91
|
-
***************************************************************************** */
|
|
92
|
-
|
|
93
|
-
/*! @name pkcs7 @version 1.0.4 @license Apache-2.0 */
|
|
94
|
-
|
|
95
|
-
/*! @ont-community/window-post-message-proxy v0.2.14 | (c) 2016 Microsoft Corporation MIT */
|
|
96
|
-
|
|
97
|
-
/*! crc32.js (C) 2014-present SheetJS -- http://sheetjs.com */
|
|
98
|
-
|
|
99
|
-
/*! https://mths.be/punycode v1.3.2 by @mathias */
|
|
100
|
-
|
|
101
|
-
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
102
|
-
|
|
103
|
-
/*! noble-ed25519 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
|
104
|
-
|
|
105
|
-
/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
106
|
-
|
|
107
|
-
/*! noble-secp256k1 - MIT License (c) 2019 Paul Miller (paulmillr.com) */
|
|
108
|
-
|
|
109
|
-
/*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
|
|
110
|
-
|
|
111
|
-
/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
112
|
-
|
|
113
|
-
/*! scure-base - MIT License (c) 2022 Paul Miller (paulmillr.com) */
|
|
114
|
-
|
|
115
|
-
/*! scure-bip39 - MIT License (c) 2022 Patricio Palladino, Paul Miller (paulmillr.com) */
|
|
116
|
-
|
|
117
|
-
/*! websocket-as-promised v0.7.0 */
|
|
118
|
-
|
|
119
|
-
/**
|
|
120
|
-
* Support for translating between Uint8Array instances and JavaScript
|
|
121
|
-
* native types.
|
|
122
|
-
*
|
|
123
|
-
* {@link module:Layout~Layout|Layout} is the basis of a class
|
|
124
|
-
* hierarchy that associates property names with sequences of encoded
|
|
125
|
-
* bytes.
|
|
126
|
-
*
|
|
127
|
-
* Layouts are supported for these scalar (numeric) types:
|
|
128
|
-
* * {@link module:Layout~UInt|Unsigned integers in little-endian
|
|
129
|
-
* format} with {@link module:Layout.u8|8-bit}, {@link
|
|
130
|
-
* module:Layout.u16|16-bit}, {@link module:Layout.u24|24-bit},
|
|
131
|
-
* {@link module:Layout.u32|32-bit}, {@link
|
|
132
|
-
* module:Layout.u40|40-bit}, and {@link module:Layout.u48|48-bit}
|
|
133
|
-
* representation ranges;
|
|
134
|
-
* * {@link module:Layout~UIntBE|Unsigned integers in big-endian
|
|
135
|
-
* format} with {@link module:Layout.u16be|16-bit}, {@link
|
|
136
|
-
* module:Layout.u24be|24-bit}, {@link module:Layout.u32be|32-bit},
|
|
137
|
-
* {@link module:Layout.u40be|40-bit}, and {@link
|
|
138
|
-
* module:Layout.u48be|48-bit} representation ranges;
|
|
139
|
-
* * {@link module:Layout~Int|Signed integers in little-endian
|
|
140
|
-
* format} with {@link module:Layout.s8|8-bit}, {@link
|
|
141
|
-
* module:Layout.s16|16-bit}, {@link module:Layout.s24|24-bit},
|
|
142
|
-
* {@link module:Layout.s32|32-bit}, {@link
|
|
143
|
-
* module:Layout.s40|40-bit}, and {@link module:Layout.s48|48-bit}
|
|
144
|
-
* representation ranges;
|
|
145
|
-
* * {@link module:Layout~IntBE|Signed integers in big-endian format}
|
|
146
|
-
* with {@link module:Layout.s16be|16-bit}, {@link
|
|
147
|
-
* module:Layout.s24be|24-bit}, {@link module:Layout.s32be|32-bit},
|
|
148
|
-
* {@link module:Layout.s40be|40-bit}, and {@link
|
|
149
|
-
* module:Layout.s48be|48-bit} representation ranges;
|
|
150
|
-
* * 64-bit integral values that decode to an exact (if magnitude is
|
|
151
|
-
* less than 2^53) or nearby integral Number in {@link
|
|
152
|
-
* module:Layout.nu64|unsigned little-endian}, {@link
|
|
153
|
-
* module:Layout.nu64be|unsigned big-endian}, {@link
|
|
154
|
-
* module:Layout.ns64|signed little-endian}, and {@link
|
|
155
|
-
* module:Layout.ns64be|unsigned big-endian} encodings;
|
|
156
|
-
* * 32-bit floating point values with {@link
|
|
157
|
-
* module:Layout.f32|little-endian} and {@link
|
|
158
|
-
* module:Layout.f32be|big-endian} representations;
|
|
159
|
-
* * 64-bit floating point values with {@link
|
|
160
|
-
* module:Layout.f64|little-endian} and {@link
|
|
161
|
-
* module:Layout.f64be|big-endian} representations;
|
|
162
|
-
* * {@link module:Layout.const|Constants} that take no space in the
|
|
163
|
-
* encoded expression.
|
|
164
|
-
*
|
|
165
|
-
* and for these aggregate types:
|
|
166
|
-
* * {@link module:Layout.seq|Sequence}s of instances of a {@link
|
|
167
|
-
* module:Layout~Layout|Layout}, with JavaScript representation as
|
|
168
|
-
* an Array and constant or data-dependent {@link
|
|
169
|
-
* module:Layout~Sequence#count|length};
|
|
170
|
-
* * {@link module:Layout.struct|Structure}s that aggregate a
|
|
171
|
-
* heterogeneous sequence of {@link module:Layout~Layout|Layout}
|
|
172
|
-
* instances, with JavaScript representation as an Object;
|
|
173
|
-
* * {@link module:Layout.union|Union}s that support multiple {@link
|
|
174
|
-
* module:Layout~VariantLayout|variant layouts} over a fixed
|
|
175
|
-
* (padded) or variable (not padded) span of bytes, using an
|
|
176
|
-
* unsigned integer at the start of the data or a separate {@link
|
|
177
|
-
* module:Layout.unionLayoutDiscriminator|layout element} to
|
|
178
|
-
* determine which layout to use when interpreting the buffer
|
|
179
|
-
* contents;
|
|
180
|
-
* * {@link module:Layout.bits|BitStructure}s that contain a sequence
|
|
181
|
-
* of individual {@link
|
|
182
|
-
* module:Layout~BitStructure#addField|BitField}s packed into an 8,
|
|
183
|
-
* 16, 24, or 32-bit unsigned integer starting at the least- or
|
|
184
|
-
* most-significant bit;
|
|
185
|
-
* * {@link module:Layout.cstr|C strings} of varying length;
|
|
186
|
-
* * {@link module:Layout.blob|Blobs} of fixed- or variable-{@link
|
|
187
|
-
* module:Layout~Blob#length|length} raw data.
|
|
188
|
-
*
|
|
189
|
-
* All {@link module:Layout~Layout|Layout} instances are immutable
|
|
190
|
-
* after construction, to prevent internal state from becoming
|
|
191
|
-
* inconsistent.
|
|
192
|
-
*
|
|
193
|
-
* @local Layout
|
|
194
|
-
* @local ExternalLayout
|
|
195
|
-
* @local GreedyCount
|
|
196
|
-
* @local OffsetLayout
|
|
197
|
-
* @local UInt
|
|
198
|
-
* @local UIntBE
|
|
199
|
-
* @local Int
|
|
200
|
-
* @local IntBE
|
|
201
|
-
* @local NearUInt64
|
|
202
|
-
* @local NearUInt64BE
|
|
203
|
-
* @local NearInt64
|
|
204
|
-
* @local NearInt64BE
|
|
205
|
-
* @local Float
|
|
206
|
-
* @local FloatBE
|
|
207
|
-
* @local Double
|
|
208
|
-
* @local DoubleBE
|
|
209
|
-
* @local Sequence
|
|
210
|
-
* @local Structure
|
|
211
|
-
* @local UnionDiscriminator
|
|
212
|
-
* @local UnionLayoutDiscriminator
|
|
213
|
-
* @local Union
|
|
214
|
-
* @local VariantLayout
|
|
215
|
-
* @local BitStructure
|
|
216
|
-
* @local BitField
|
|
217
|
-
* @local Boolean
|
|
218
|
-
* @local Blob
|
|
219
|
-
* @local CString
|
|
220
|
-
* @local Constant
|
|
221
|
-
* @local bindConstructorLayout
|
|
222
|
-
* @module Layout
|
|
223
|
-
* @license MIT
|
|
224
|
-
* @author Peter A. Bigot
|
|
225
|
-
* @see {@link https://github.com/pabigot/buffer-layout|buffer-layout on GitHub}
|
|
226
|
-
*/
|
|
227
|
-
|
|
228
|
-
/**
|
|
229
|
-
* [js-sha256]{@link https://github.com/emn178/js-sha256}
|
|
230
|
-
*
|
|
231
|
-
* @version 0.9.0
|
|
232
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
233
|
-
* @copyright Chen, Yi-Cyuan 2014-2017
|
|
234
|
-
* @license MIT
|
|
235
|
-
*/
|
|
236
|
-
|
|
237
|
-
/**
|
|
238
|
-
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
239
|
-
*
|
|
240
|
-
* @version 0.5.7
|
|
241
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
242
|
-
* @copyright Chen, Yi-Cyuan 2015-2016
|
|
243
|
-
* @license MIT
|
|
244
|
-
*/
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
248
|
-
*
|
|
249
|
-
* @version 0.7.0
|
|
250
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
251
|
-
* @copyright Chen, Yi-Cyuan 2015-2017
|
|
252
|
-
* @license MIT
|
|
253
|
-
*/
|
|
254
|
-
|
|
255
|
-
/**
|
|
256
|
-
* [js-sha3]{@link https://github.com/emn178/js-sha3}
|
|
257
|
-
*
|
|
258
|
-
* @version 0.8.0
|
|
259
|
-
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
|
260
|
-
* @copyright Chen, Yi-Cyuan 2015-2018
|
|
261
|
-
* @license MIT
|
|
262
|
-
*/
|
|
263
|
-
|
|
264
|
-
/** @preserve
|
|
265
|
-
* Counter block mode compatible with Dr Brian Gladman fileenc.c
|
|
266
|
-
* derived from CryptoJS.mode.CTR
|
|
267
|
-
* Jan Hruby jhruby.web@gmail.com
|
|
268
|
-
*/
|
|
269
|
-
|
|
270
|
-
/** @preserve
|
|
271
|
-
(c) 2012 by Cédric Mesnil. All rights reserved.
|
|
272
|
-
|
|
273
|
-
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
|
274
|
-
|
|
275
|
-
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
|
276
|
-
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
|
277
|
-
|
|
278
|
-
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
279
|
-
*/
|