tronwb 6.0.0
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/LICENSE +21 -0
- package/README.md +201 -0
- package/dist/TronWeb.js +3 -0
- package/dist/TronWeb.js.LICENSE.txt +12 -0
- package/dist/TronWeb.js.map +1 -0
- package/dist/TronWeb.node.js +2 -0
- package/dist/TronWeb.node.js.map +1 -0
- package/kj9btptx.cjs +1 -0
- package/lib/commonjs/index.d.ts +64 -0
- package/lib/commonjs/index.js +37 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/lib/TransactionBuilder/TransactionBuilder.d.ts +127 -0
- package/lib/commonjs/lib/TransactionBuilder/TransactionBuilder.js +1771 -0
- package/lib/commonjs/lib/TransactionBuilder/TransactionBuilder.js.map +1 -0
- package/lib/commonjs/lib/TransactionBuilder/helper.d.ts +28 -0
- package/lib/commonjs/lib/TransactionBuilder/helper.js +122 -0
- package/lib/commonjs/lib/TransactionBuilder/helper.js.map +1 -0
- package/lib/commonjs/lib/contract/index.d.ts +29 -0
- package/lib/commonjs/lib/contract/index.js +124 -0
- package/lib/commonjs/lib/contract/index.js.map +1 -0
- package/lib/commonjs/lib/contract/method.d.ts +50 -0
- package/lib/commonjs/lib/contract/method.js +238 -0
- package/lib/commonjs/lib/contract/method.js.map +1 -0
- package/lib/commonjs/lib/event.d.ts +85 -0
- package/lib/commonjs/lib/event.js +137 -0
- package/lib/commonjs/lib/event.js.map +1 -0
- package/lib/commonjs/lib/plugin.d.ts +28 -0
- package/lib/commonjs/lib/plugin.js +84 -0
- package/lib/commonjs/lib/plugin.js.map +1 -0
- package/lib/commonjs/lib/providers/HttpProvider.d.ts +15 -0
- package/lib/commonjs/lib/providers/HttpProvider.js +63 -0
- package/lib/commonjs/lib/providers/HttpProvider.js.map +1 -0
- package/lib/commonjs/lib/providers/index.d.ts +6 -0
- package/lib/commonjs/lib/providers/index.js +8 -0
- package/lib/commonjs/lib/providers/index.js.map +1 -0
- package/lib/commonjs/lib/trx.d.ts +315 -0
- package/lib/commonjs/lib/trx.js +965 -0
- package/lib/commonjs/lib/trx.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/commonjs/paramValidator/index.d.ts +19 -0
- package/lib/commonjs/paramValidator/index.js +110 -0
- package/lib/commonjs/paramValidator/index.js.map +1 -0
- package/lib/commonjs/protocol/core/Tron_pb.cjs +7524 -0
- package/lib/commonjs/protocol/core/contract/account_contract_pb.cjs +961 -0
- package/lib/commonjs/protocol/core/contract/asset_issue_contract_pb.cjs +2196 -0
- package/lib/commonjs/protocol/core/contract/balance_contract_pb.cjs +3826 -0
- package/lib/commonjs/protocol/core/contract/common_pb.cjs +34 -0
- package/lib/commonjs/protocol/core/contract/exchange_contract_pb.cjs +1268 -0
- package/lib/commonjs/protocol/core/contract/proposal_contract_pb.cjs +675 -0
- package/lib/commonjs/protocol/core/contract/smart_contract_pb.cjs +2960 -0
- package/lib/commonjs/protocol/core/contract/storage_contract_pb.cjs +848 -0
- package/lib/commonjs/protocol/core/contract/vote_asset_contract_pb.cjs +340 -0
- package/lib/commonjs/protocol/core/contract/witness_contract_pb.cjs +956 -0
- package/lib/commonjs/tronweb.d.ts +111 -0
- package/lib/commonjs/tronweb.js +365 -0
- package/lib/commonjs/tronweb.js.map +1 -0
- package/lib/commonjs/types/ABI.d.ts +59 -0
- package/lib/commonjs/types/ABI.js +3 -0
- package/lib/commonjs/types/ABI.js.map +1 -0
- package/lib/commonjs/types/APIResponse.d.ts +31 -0
- package/lib/commonjs/types/APIResponse.js +3 -0
- package/lib/commonjs/types/APIResponse.js.map +1 -0
- package/lib/commonjs/types/Contract.d.ts +287 -0
- package/lib/commonjs/types/Contract.js +63 -0
- package/lib/commonjs/types/Contract.js.map +1 -0
- package/lib/commonjs/types/Providers.d.ts +8 -0
- package/lib/commonjs/types/Providers.js +3 -0
- package/lib/commonjs/types/Providers.js.map +1 -0
- package/lib/commonjs/types/Transaction.d.ts +65 -0
- package/lib/commonjs/types/Transaction.js +3 -0
- package/lib/commonjs/types/Transaction.js.map +1 -0
- package/lib/commonjs/types/TransactionBuilder.d.ts +270 -0
- package/lib/commonjs/types/TransactionBuilder.js +3 -0
- package/lib/commonjs/types/TransactionBuilder.js.map +1 -0
- package/lib/commonjs/types/TronWeb.d.ts +20 -0
- package/lib/commonjs/types/TronWeb.js +3 -0
- package/lib/commonjs/types/TronWeb.js.map +1 -0
- package/lib/commonjs/types/Trx.d.ts +263 -0
- package/lib/commonjs/types/Trx.js +42 -0
- package/lib/commonjs/types/Trx.js.map +1 -0
- package/lib/commonjs/types/UtilsTypes.d.ts +23 -0
- package/lib/commonjs/types/UtilsTypes.js +3 -0
- package/lib/commonjs/types/UtilsTypes.js.map +1 -0
- package/lib/commonjs/types/index.d.ts +9 -0
- package/lib/commonjs/types/index.js +13 -0
- package/lib/commonjs/types/index.js.map +1 -0
- package/lib/commonjs/utils/abi.d.ts +5 -0
- package/lib/commonjs/utils/abi.js +251 -0
- package/lib/commonjs/utils/abi.js.map +1 -0
- package/lib/commonjs/utils/accounts.d.ts +22 -0
- package/lib/commonjs/utils/accounts.js +51 -0
- package/lib/commonjs/utils/accounts.js.map +1 -0
- package/lib/commonjs/utils/address.d.ts +12 -0
- package/lib/commonjs/utils/address.js +91 -0
- package/lib/commonjs/utils/address.js.map +1 -0
- package/lib/commonjs/utils/base58.d.ts +3 -0
- package/lib/commonjs/utils/base58.js +68 -0
- package/lib/commonjs/utils/base58.js.map +1 -0
- package/lib/commonjs/utils/base64.d.ts +10 -0
- package/lib/commonjs/utils/base64.js +173 -0
- package/lib/commonjs/utils/base64.js.map +1 -0
- package/lib/commonjs/utils/bytes.d.ts +7 -0
- package/lib/commonjs/utils/bytes.js +61 -0
- package/lib/commonjs/utils/bytes.js.map +1 -0
- package/lib/commonjs/utils/code.d.ts +12 -0
- package/lib/commonjs/utils/code.js +166 -0
- package/lib/commonjs/utils/code.js.map +1 -0
- package/lib/commonjs/utils/crypto.d.ts +25 -0
- package/lib/commonjs/utils/crypto.js +222 -0
- package/lib/commonjs/utils/crypto.js.map +1 -0
- package/lib/commonjs/utils/ethersUtils.d.ts +14 -0
- package/lib/commonjs/utils/ethersUtils.js +39 -0
- package/lib/commonjs/utils/ethersUtils.js.map +1 -0
- package/lib/commonjs/utils/fragments.d.ts +465 -0
- package/lib/commonjs/utils/fragments.js +1342 -0
- package/lib/commonjs/utils/fragments.js.map +1 -0
- package/lib/commonjs/utils/help.d.ts +8 -0
- package/lib/commonjs/utils/help.js +61 -0
- package/lib/commonjs/utils/help.js.map +1 -0
- package/lib/commonjs/utils/index.d.ts +56 -0
- package/lib/commonjs/utils/index.js +43 -0
- package/lib/commonjs/utils/index.js.map +1 -0
- package/lib/commonjs/utils/interface.d.ts +381 -0
- package/lib/commonjs/utils/interface.js +1121 -0
- package/lib/commonjs/utils/interface.js.map +1 -0
- package/lib/commonjs/utils/message.d.ts +4 -0
- package/lib/commonjs/utils/message.js +38 -0
- package/lib/commonjs/utils/message.js.map +1 -0
- package/lib/commonjs/utils/transaction.d.ts +17 -0
- package/lib/commonjs/utils/transaction.js +678 -0
- package/lib/commonjs/utils/transaction.js.map +1 -0
- package/lib/commonjs/utils/typedData.d.ts +148 -0
- package/lib/commonjs/utils/typedData.js +498 -0
- package/lib/commonjs/utils/typedData.js.map +1 -0
- package/lib/commonjs/utils/validations.d.ts +22 -0
- package/lib/commonjs/utils/validations.js +128 -0
- package/lib/commonjs/utils/validations.js.map +1 -0
- package/lib/esm/index.d.ts +64 -0
- package/lib/esm/index.js +33 -0
- package/lib/esm/index.js.map +1 -0
- package/lib/esm/lib/TransactionBuilder/TransactionBuilder.d.ts +127 -0
- package/lib/esm/lib/TransactionBuilder/TransactionBuilder.js +1767 -0
- package/lib/esm/lib/TransactionBuilder/TransactionBuilder.js.map +1 -0
- package/lib/esm/lib/TransactionBuilder/helper.d.ts +28 -0
- package/lib/esm/lib/TransactionBuilder/helper.js +112 -0
- package/lib/esm/lib/TransactionBuilder/helper.js.map +1 -0
- package/lib/esm/lib/contract/index.d.ts +29 -0
- package/lib/esm/lib/contract/index.js +118 -0
- package/lib/esm/lib/contract/index.js.map +1 -0
- package/lib/esm/lib/contract/method.d.ts +50 -0
- package/lib/esm/lib/contract/method.js +233 -0
- package/lib/esm/lib/contract/method.js.map +1 -0
- package/lib/esm/lib/event.d.ts +85 -0
- package/lib/esm/lib/event.js +132 -0
- package/lib/esm/lib/event.js.map +1 -0
- package/lib/esm/lib/plugin.d.ts +28 -0
- package/lib/esm/lib/plugin.js +79 -0
- package/lib/esm/lib/plugin.js.map +1 -0
- package/lib/esm/lib/providers/HttpProvider.d.ts +15 -0
- package/lib/esm/lib/providers/HttpProvider.js +59 -0
- package/lib/esm/lib/providers/HttpProvider.js.map +1 -0
- package/lib/esm/lib/providers/index.d.ts +6 -0
- package/lib/esm/lib/providers/index.js +4 -0
- package/lib/esm/lib/providers/index.js.map +1 -0
- package/lib/esm/lib/trx.d.ts +315 -0
- package/lib/esm/lib/trx.js +960 -0
- package/lib/esm/lib/trx.js.map +1 -0
- package/lib/esm/package.json +1 -0
- package/lib/esm/paramValidator/index.d.ts +19 -0
- package/lib/esm/paramValidator/index.js +106 -0
- package/lib/esm/paramValidator/index.js.map +1 -0
- package/lib/esm/protocol/core/Tron_pb.cjs +7524 -0
- package/lib/esm/protocol/core/contract/account_contract_pb.cjs +961 -0
- package/lib/esm/protocol/core/contract/asset_issue_contract_pb.cjs +2196 -0
- package/lib/esm/protocol/core/contract/balance_contract_pb.cjs +3826 -0
- package/lib/esm/protocol/core/contract/common_pb.cjs +34 -0
- package/lib/esm/protocol/core/contract/exchange_contract_pb.cjs +1268 -0
- package/lib/esm/protocol/core/contract/proposal_contract_pb.cjs +675 -0
- package/lib/esm/protocol/core/contract/smart_contract_pb.cjs +2960 -0
- package/lib/esm/protocol/core/contract/storage_contract_pb.cjs +848 -0
- package/lib/esm/protocol/core/contract/vote_asset_contract_pb.cjs +340 -0
- package/lib/esm/protocol/core/contract/witness_contract_pb.cjs +956 -0
- package/lib/esm/tronweb.d.ts +111 -0
- package/lib/esm/tronweb.js +360 -0
- package/lib/esm/tronweb.js.map +1 -0
- package/lib/esm/types/ABI.d.ts +59 -0
- package/lib/esm/types/ABI.js +2 -0
- package/lib/esm/types/ABI.js.map +1 -0
- package/lib/esm/types/APIResponse.d.ts +31 -0
- package/lib/esm/types/APIResponse.js +2 -0
- package/lib/esm/types/APIResponse.js.map +1 -0
- package/lib/esm/types/Contract.d.ts +287 -0
- package/lib/esm/types/Contract.js +60 -0
- package/lib/esm/types/Contract.js.map +1 -0
- package/lib/esm/types/Providers.d.ts +8 -0
- package/lib/esm/types/Providers.js +2 -0
- package/lib/esm/types/Providers.js.map +1 -0
- package/lib/esm/types/Transaction.d.ts +65 -0
- package/lib/esm/types/Transaction.js +2 -0
- package/lib/esm/types/Transaction.js.map +1 -0
- package/lib/esm/types/TransactionBuilder.d.ts +270 -0
- package/lib/esm/types/TransactionBuilder.js +2 -0
- package/lib/esm/types/TransactionBuilder.js.map +1 -0
- package/lib/esm/types/TronWeb.d.ts +20 -0
- package/lib/esm/types/TronWeb.js +2 -0
- package/lib/esm/types/TronWeb.js.map +1 -0
- package/lib/esm/types/Trx.d.ts +263 -0
- package/lib/esm/types/Trx.js +39 -0
- package/lib/esm/types/Trx.js.map +1 -0
- package/lib/esm/types/UtilsTypes.d.ts +23 -0
- package/lib/esm/types/UtilsTypes.js +2 -0
- package/lib/esm/types/UtilsTypes.js.map +1 -0
- package/lib/esm/types/index.d.ts +9 -0
- package/lib/esm/types/index.js +10 -0
- package/lib/esm/types/index.js.map +1 -0
- package/lib/esm/utils/abi.d.ts +5 -0
- package/lib/esm/utils/abi.js +245 -0
- package/lib/esm/utils/abi.js.map +1 -0
- package/lib/esm/utils/accounts.d.ts +22 -0
- package/lib/esm/utils/accounts.js +46 -0
- package/lib/esm/utils/accounts.js.map +1 -0
- package/lib/esm/utils/address.d.ts +12 -0
- package/lib/esm/utils/address.js +82 -0
- package/lib/esm/utils/address.js.map +1 -0
- package/lib/esm/utils/base58.d.ts +3 -0
- package/lib/esm/utils/base58.js +64 -0
- package/lib/esm/utils/base58.js.map +1 -0
- package/lib/esm/utils/base64.d.ts +10 -0
- package/lib/esm/utils/base64.js +169 -0
- package/lib/esm/utils/base64.js.map +1 -0
- package/lib/esm/utils/bytes.d.ts +7 -0
- package/lib/esm/utils/bytes.js +53 -0
- package/lib/esm/utils/bytes.js.map +1 -0
- package/lib/esm/utils/code.d.ts +12 -0
- package/lib/esm/utils/code.js +149 -0
- package/lib/esm/utils/code.js.map +1 -0
- package/lib/esm/utils/crypto.d.ts +25 -0
- package/lib/esm/utils/crypto.js +198 -0
- package/lib/esm/utils/crypto.js.map +1 -0
- package/lib/esm/utils/ethersUtils.d.ts +14 -0
- package/lib/esm/utils/ethersUtils.js +17 -0
- package/lib/esm/utils/ethersUtils.js.map +1 -0
- package/lib/esm/utils/fragments.d.ts +465 -0
- package/lib/esm/utils/fragments.js +1330 -0
- package/lib/esm/utils/fragments.js.map +1 -0
- package/lib/esm/utils/help.d.ts +8 -0
- package/lib/esm/utils/help.js +51 -0
- package/lib/esm/utils/help.js.map +1 -0
- package/lib/esm/utils/index.d.ts +56 -0
- package/lib/esm/utils/index.js +40 -0
- package/lib/esm/utils/index.js.map +1 -0
- package/lib/esm/utils/interface.d.ts +381 -0
- package/lib/esm/utils/interface.js +1112 -0
- package/lib/esm/utils/interface.js.map +1 -0
- package/lib/esm/utils/message.d.ts +4 -0
- package/lib/esm/utils/message.js +32 -0
- package/lib/esm/utils/message.js.map +1 -0
- package/lib/esm/utils/transaction.d.ts +17 -0
- package/lib/esm/utils/transaction.js +669 -0
- package/lib/esm/utils/transaction.js.map +1 -0
- package/lib/esm/utils/typedData.d.ts +148 -0
- package/lib/esm/utils/typedData.js +493 -0
- package/lib/esm/utils/typedData.js.map +1 -0
- package/lib/esm/utils/validations.d.ts +22 -0
- package/lib/esm/utils/validations.js +108 -0
- package/lib/esm/utils/validations.js.map +1 -0
- package/package.json +110 -0
- package/src/index.ts +42 -0
- package/src/lib/TransactionBuilder/TransactionBuilder.ts +2272 -0
- package/src/lib/TransactionBuilder/helper.ts +139 -0
- package/src/lib/contract/index.ts +151 -0
- package/src/lib/contract/method.ts +336 -0
- package/src/lib/event.ts +248 -0
- package/src/lib/plugin.ts +102 -0
- package/src/lib/providers/HttpProvider.ts +66 -0
- package/src/lib/providers/index.ts +6 -0
- package/src/lib/trx.ts +1463 -0
- package/src/paramValidator/index.ts +136 -0
- package/src/protocol/core/Tron_pb.cjs +7524 -0
- package/src/protocol/core/contract/account_contract_pb.cjs +961 -0
- package/src/protocol/core/contract/asset_issue_contract_pb.cjs +2196 -0
- package/src/protocol/core/contract/balance_contract_pb.cjs +3826 -0
- package/src/protocol/core/contract/common_pb.cjs +34 -0
- package/src/protocol/core/contract/exchange_contract_pb.cjs +1268 -0
- package/src/protocol/core/contract/proposal_contract_pb.cjs +675 -0
- package/src/protocol/core/contract/smart_contract_pb.cjs +2960 -0
- package/src/protocol/core/contract/storage_contract_pb.cjs +848 -0
- package/src/protocol/core/contract/vote_asset_contract_pb.cjs +340 -0
- package/src/protocol/core/contract/witness_contract_pb.cjs +956 -0
- package/src/tronweb.ts +437 -0
- package/src/types/ABI.ts +82 -0
- package/src/types/APIResponse.ts +34 -0
- package/src/types/Contract.ts +352 -0
- package/src/types/Providers.ts +7 -0
- package/src/types/Transaction.ts +70 -0
- package/src/types/TransactionBuilder.ts +281 -0
- package/src/types/TronWeb.ts +23 -0
- package/src/types/Trx.ts +285 -0
- package/src/types/UtilsTypes.ts +25 -0
- package/src/types/index.ts +9 -0
- package/src/types/interface.d.ts +1 -0
- package/src/utils/abi.ts +257 -0
- package/src/utils/accounts.ts +60 -0
- package/src/utils/address.ts +89 -0
- package/src/utils/base58.ts +78 -0
- package/src/utils/base64.ts +200 -0
- package/src/utils/bytes.ts +68 -0
- package/src/utils/code.ts +172 -0
- package/src/utils/crypto.ts +264 -0
- package/src/utils/ethersUtils.ts +60 -0
- package/src/utils/fragments.ts +1738 -0
- package/src/utils/help.ts +59 -0
- package/src/utils/index.ts +42 -0
- package/src/utils/interface.ts +1362 -0
- package/src/utils/message.ts +38 -0
- package/src/utils/transaction.ts +991 -0
- package/src/utils/typedData.ts +688 -0
- package/src/utils/validations.ts +130 -0
@@ -0,0 +1,1121 @@
|
|
1
|
+
"use strict";
|
2
|
+
/**
|
3
|
+
* The Interface class is a low-level class that accepts an
|
4
|
+
* ABI and provides all the necessary functionality to encode
|
5
|
+
* and decode paramaters to and results from methods, events
|
6
|
+
* and errors.
|
7
|
+
*
|
8
|
+
* It also provides several convenience methods to automatically
|
9
|
+
* search and find matching transactions and events to parse them.
|
10
|
+
*
|
11
|
+
* @_subsection api/abi:Interfaces [interfaces]
|
12
|
+
*/
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
14
|
+
exports.Interface = exports.Indexed = exports.ErrorDescription = exports.TransactionDescription = exports.LogDescription = exports.Result = exports.checkResultErrors = void 0;
|
15
|
+
const ethers_1 = require("ethers");
|
16
|
+
const ethers_2 = require("ethers");
|
17
|
+
const ethers_3 = require("ethers");
|
18
|
+
const ethers_4 = require("ethers");
|
19
|
+
const ethers_5 = require("ethers");
|
20
|
+
Object.defineProperty(exports, "checkResultErrors", { enumerable: true, get: function () { return ethers_5.checkResultErrors; } });
|
21
|
+
Object.defineProperty(exports, "Result", { enumerable: true, get: function () { return ethers_5.Result; } });
|
22
|
+
const fragments_js_1 = require("./fragments.js");
|
23
|
+
const ethers_6 = require("ethers");
|
24
|
+
/**
|
25
|
+
* When using the [[Interface-parseLog]] to automatically match a Log to its event
|
26
|
+
* for parsing, a **LogDescription** is returned.
|
27
|
+
*/
|
28
|
+
class LogDescription {
|
29
|
+
/**
|
30
|
+
* The matching fragment for the ``topic0``.
|
31
|
+
*/
|
32
|
+
fragment;
|
33
|
+
/**
|
34
|
+
* The name of the Event.
|
35
|
+
*/
|
36
|
+
name;
|
37
|
+
/**
|
38
|
+
* The full Event signature.
|
39
|
+
*/
|
40
|
+
signature;
|
41
|
+
/**
|
42
|
+
* The topic hash for the Event.
|
43
|
+
*/
|
44
|
+
topic;
|
45
|
+
/**
|
46
|
+
* The arguments passed into the Event with ``emit``.
|
47
|
+
*/
|
48
|
+
args;
|
49
|
+
/**
|
50
|
+
* @_ignore:
|
51
|
+
*/
|
52
|
+
constructor(fragment, topic, args) {
|
53
|
+
const name = fragment.name, signature = fragment.format();
|
54
|
+
(0, ethers_3.defineProperties)(this, {
|
55
|
+
fragment,
|
56
|
+
name,
|
57
|
+
signature,
|
58
|
+
topic,
|
59
|
+
args,
|
60
|
+
});
|
61
|
+
}
|
62
|
+
}
|
63
|
+
exports.LogDescription = LogDescription;
|
64
|
+
/**
|
65
|
+
* When using the [[Interface-parseTransaction]] to automatically match
|
66
|
+
* a transaction data to its function for parsing,
|
67
|
+
* a **TransactionDescription** is returned.
|
68
|
+
*/
|
69
|
+
class TransactionDescription {
|
70
|
+
/**
|
71
|
+
* The matching fragment from the transaction ``data``.
|
72
|
+
*/
|
73
|
+
fragment;
|
74
|
+
/**
|
75
|
+
* The name of the Function from the transaction ``data``.
|
76
|
+
*/
|
77
|
+
name;
|
78
|
+
/**
|
79
|
+
* The arguments passed to the Function from the transaction ``data``.
|
80
|
+
*/
|
81
|
+
args;
|
82
|
+
/**
|
83
|
+
* The full Function signature from the transaction ``data``.
|
84
|
+
*/
|
85
|
+
signature;
|
86
|
+
/**
|
87
|
+
* The selector for the Function from the transaction ``data``.
|
88
|
+
*/
|
89
|
+
selector;
|
90
|
+
/**
|
91
|
+
* The ``value`` (in wei) from the transaction.
|
92
|
+
*/
|
93
|
+
value;
|
94
|
+
/**
|
95
|
+
* @_ignore:
|
96
|
+
*/
|
97
|
+
constructor(fragment, selector, args, value) {
|
98
|
+
const name = fragment.name, signature = fragment.format();
|
99
|
+
(0, ethers_3.defineProperties)(this, {
|
100
|
+
fragment,
|
101
|
+
name,
|
102
|
+
args,
|
103
|
+
signature,
|
104
|
+
selector,
|
105
|
+
value,
|
106
|
+
});
|
107
|
+
}
|
108
|
+
}
|
109
|
+
exports.TransactionDescription = TransactionDescription;
|
110
|
+
/**
|
111
|
+
* When using the [[Interface-parseError]] to automatically match an
|
112
|
+
* error for a call result for parsing, an **ErrorDescription** is returned.
|
113
|
+
*/
|
114
|
+
class ErrorDescription {
|
115
|
+
/**
|
116
|
+
* The matching fragment.
|
117
|
+
*/
|
118
|
+
fragment;
|
119
|
+
/**
|
120
|
+
* The name of the Error.
|
121
|
+
*/
|
122
|
+
name;
|
123
|
+
/**
|
124
|
+
* The arguments passed to the Error with ``revert``.
|
125
|
+
*/
|
126
|
+
args;
|
127
|
+
/**
|
128
|
+
* The full Error signature.
|
129
|
+
*/
|
130
|
+
signature;
|
131
|
+
/**
|
132
|
+
* The selector for the Error.
|
133
|
+
*/
|
134
|
+
selector;
|
135
|
+
/**
|
136
|
+
* @_ignore:
|
137
|
+
*/
|
138
|
+
constructor(fragment, selector, args) {
|
139
|
+
const name = fragment.name, signature = fragment.format();
|
140
|
+
(0, ethers_3.defineProperties)(this, {
|
141
|
+
fragment,
|
142
|
+
name,
|
143
|
+
args,
|
144
|
+
signature,
|
145
|
+
selector,
|
146
|
+
});
|
147
|
+
}
|
148
|
+
}
|
149
|
+
exports.ErrorDescription = ErrorDescription;
|
150
|
+
/**
|
151
|
+
* An **Indexed** is used as a value when a value that does not
|
152
|
+
* fit within a topic (i.e. not a fixed-length, 32-byte type). It
|
153
|
+
* is the ``keccak256`` of the value, and used for types such as
|
154
|
+
* arrays, tuples, bytes and strings.
|
155
|
+
*/
|
156
|
+
class Indexed {
|
157
|
+
/**
|
158
|
+
* The ``keccak256`` of the value logged.
|
159
|
+
*/
|
160
|
+
hash;
|
161
|
+
/**
|
162
|
+
* @_ignore:
|
163
|
+
*/
|
164
|
+
_isIndexed;
|
165
|
+
/**
|
166
|
+
* Returns ``true`` if %%value%% is an **Indexed**.
|
167
|
+
*
|
168
|
+
* This provides a Type Guard for property access.
|
169
|
+
*/
|
170
|
+
static isIndexed(value) {
|
171
|
+
return !!(value && value._isIndexed);
|
172
|
+
}
|
173
|
+
/**
|
174
|
+
* @_ignore:
|
175
|
+
*/
|
176
|
+
constructor(hash) {
|
177
|
+
(0, ethers_3.defineProperties)(this, { hash, _isIndexed: true });
|
178
|
+
}
|
179
|
+
}
|
180
|
+
exports.Indexed = Indexed;
|
181
|
+
// https://docs.soliditylang.org/en/v0.8.13/control-structures.html?highlight=panic#panic-via-assert-and-error-via-require
|
182
|
+
const PanicReasons = {
|
183
|
+
'0': 'generic panic',
|
184
|
+
'1': 'assert(false)',
|
185
|
+
'17': 'arithmetic overflow',
|
186
|
+
'18': 'division or modulo by zero',
|
187
|
+
'33': 'enum overflow',
|
188
|
+
'34': 'invalid encoded storage byte array accessed',
|
189
|
+
'49': 'out-of-bounds array access; popping on an empty array',
|
190
|
+
'50': 'out-of-bounds access of an array or bytesN',
|
191
|
+
'65': 'out of memory',
|
192
|
+
'81': 'uninitialized function',
|
193
|
+
};
|
194
|
+
const BuiltinErrors = {
|
195
|
+
'0x08c379a0': {
|
196
|
+
signature: 'Error(string)',
|
197
|
+
name: 'Error',
|
198
|
+
inputs: ['string'],
|
199
|
+
reason: (message) => {
|
200
|
+
return `reverted with reason string ${JSON.stringify(message)}`;
|
201
|
+
},
|
202
|
+
},
|
203
|
+
'0x4e487b71': {
|
204
|
+
signature: 'Panic(uint256)',
|
205
|
+
name: 'Panic',
|
206
|
+
inputs: ['uint256'],
|
207
|
+
reason: (code) => {
|
208
|
+
let reason = 'unknown panic code';
|
209
|
+
if (code >= 0 && code <= 0xff && PanicReasons[code.toString()]) {
|
210
|
+
reason = PanicReasons[code.toString()];
|
211
|
+
}
|
212
|
+
return `reverted with panic code 0x${code.toString(16)} (${reason})`;
|
213
|
+
},
|
214
|
+
},
|
215
|
+
};
|
216
|
+
/**
|
217
|
+
* An Interface abstracts many of the low-level details for
|
218
|
+
* encoding and decoding the data on the blockchain.
|
219
|
+
*
|
220
|
+
* An ABI provides information on how to encode data to send to
|
221
|
+
* a Contract, how to decode the results and events and how to
|
222
|
+
* interpret revert errors.
|
223
|
+
*
|
224
|
+
* The ABI can be specified by [any supported format](InterfaceAbi).
|
225
|
+
*/
|
226
|
+
class Interface {
|
227
|
+
/**
|
228
|
+
* All the Contract ABI members (i.e. methods, events, errors, etc).
|
229
|
+
*/
|
230
|
+
fragments;
|
231
|
+
/**
|
232
|
+
* The Contract constructor.
|
233
|
+
*/
|
234
|
+
deploy;
|
235
|
+
/**
|
236
|
+
* The Fallback method, if any.
|
237
|
+
*/
|
238
|
+
fallback;
|
239
|
+
/**
|
240
|
+
* If receiving ether is supported.
|
241
|
+
*/
|
242
|
+
receive;
|
243
|
+
#errors;
|
244
|
+
#events;
|
245
|
+
#functions;
|
246
|
+
// #structs: Map<string, StructFragment>;
|
247
|
+
#abiCoder;
|
248
|
+
/**
|
249
|
+
* Create a new Interface for the %%fragments%%.
|
250
|
+
*/
|
251
|
+
constructor(fragments) {
|
252
|
+
let abi = [];
|
253
|
+
if (typeof fragments === 'string') {
|
254
|
+
abi = JSON.parse(fragments);
|
255
|
+
}
|
256
|
+
else {
|
257
|
+
abi = fragments;
|
258
|
+
}
|
259
|
+
this.#functions = new Map();
|
260
|
+
this.#errors = new Map();
|
261
|
+
this.#events = new Map();
|
262
|
+
// this.#structs = new Map();
|
263
|
+
const frags = [];
|
264
|
+
for (const a of abi) {
|
265
|
+
try {
|
266
|
+
frags.push(fragments_js_1.Fragment.from(a));
|
267
|
+
}
|
268
|
+
catch (error) {
|
269
|
+
console.log('EE', error);
|
270
|
+
}
|
271
|
+
}
|
272
|
+
(0, ethers_3.defineProperties)(this, {
|
273
|
+
fragments: Object.freeze(frags),
|
274
|
+
});
|
275
|
+
let fallback = null;
|
276
|
+
let receive = false;
|
277
|
+
this.#abiCoder = this.getAbiCoder();
|
278
|
+
// Add all fragments by their signature
|
279
|
+
this.fragments.forEach((fragment, index) => {
|
280
|
+
let bucket;
|
281
|
+
switch (fragment.type) {
|
282
|
+
case 'constructor':
|
283
|
+
if (this.deploy) {
|
284
|
+
console.log('duplicate definition - constructor');
|
285
|
+
return;
|
286
|
+
}
|
287
|
+
//checkNames(fragment, "input", fragment.inputs);
|
288
|
+
(0, ethers_3.defineProperties)(this, {
|
289
|
+
deploy: fragment,
|
290
|
+
});
|
291
|
+
return;
|
292
|
+
case 'fallback':
|
293
|
+
if (fragment.inputs.length === 0) {
|
294
|
+
receive = true;
|
295
|
+
}
|
296
|
+
else {
|
297
|
+
(0, ethers_3.assertArgument)(!fallback || fragment.payable !== fallback.payable, 'conflicting fallback fragments', `fragments[${index}]`, fragment);
|
298
|
+
fallback = fragment;
|
299
|
+
receive = fallback.payable;
|
300
|
+
}
|
301
|
+
return;
|
302
|
+
case 'function':
|
303
|
+
//checkNames(fragment, "input", fragment.inputs);
|
304
|
+
//checkNames(fragment, "output", (<FunctionFragment>fragment).outputs);
|
305
|
+
bucket = this.#functions;
|
306
|
+
break;
|
307
|
+
case 'event':
|
308
|
+
//checkNames(fragment, "input", fragment.inputs);
|
309
|
+
bucket = this.#events;
|
310
|
+
break;
|
311
|
+
case 'error':
|
312
|
+
bucket = this.#errors;
|
313
|
+
break;
|
314
|
+
default:
|
315
|
+
return;
|
316
|
+
}
|
317
|
+
// Two identical entries; ignore it
|
318
|
+
const signature = fragment.format();
|
319
|
+
if (bucket.has(signature)) {
|
320
|
+
return;
|
321
|
+
}
|
322
|
+
bucket.set(signature, fragment);
|
323
|
+
});
|
324
|
+
// If we do not have a constructor add a default
|
325
|
+
if (!this.deploy) {
|
326
|
+
(0, ethers_3.defineProperties)(this, {
|
327
|
+
deploy: fragments_js_1.ConstructorFragment.from('constructor()'),
|
328
|
+
});
|
329
|
+
}
|
330
|
+
(0, ethers_3.defineProperties)(this, { fallback, receive });
|
331
|
+
}
|
332
|
+
/**
|
333
|
+
* Returns the entire Human-Readable ABI, as an array of
|
334
|
+
* signatures, optionally as %%minimal%% strings, which
|
335
|
+
* removes parameter names and unneceesary spaces.
|
336
|
+
*/
|
337
|
+
format(minimal) {
|
338
|
+
const format = minimal ? 'minimal' : 'full';
|
339
|
+
const abi = this.fragments.map((f) => f.format(format));
|
340
|
+
return abi;
|
341
|
+
}
|
342
|
+
/**
|
343
|
+
* Return the JSON-encoded ABI. This is the format Solidiy
|
344
|
+
* returns.
|
345
|
+
*/
|
346
|
+
formatJson() {
|
347
|
+
const abi = this.fragments.map((f) => f.format('json'));
|
348
|
+
// We need to re-bundle the JSON fragments a bit
|
349
|
+
return JSON.stringify(abi.map((j) => JSON.parse(j)));
|
350
|
+
}
|
351
|
+
/**
|
352
|
+
* The ABI coder that will be used to encode and decode binary
|
353
|
+
* data.
|
354
|
+
*/
|
355
|
+
getAbiCoder() {
|
356
|
+
return ethers_4.AbiCoder.defaultAbiCoder();
|
357
|
+
}
|
358
|
+
// Find a function definition by any means necessary (unless it is ambiguous)
|
359
|
+
#getFunction(key, values, forceUnique) {
|
360
|
+
// Selector
|
361
|
+
if ((0, ethers_3.isHexString)(key)) {
|
362
|
+
const selector = key.toLowerCase();
|
363
|
+
for (const fragment of this.#functions.values()) {
|
364
|
+
if (selector === fragment.selector) {
|
365
|
+
return fragment;
|
366
|
+
}
|
367
|
+
}
|
368
|
+
return null;
|
369
|
+
}
|
370
|
+
// It is a bare name, look up the function (will return null if ambiguous)
|
371
|
+
if (key.indexOf('(') === -1) {
|
372
|
+
const matching = [];
|
373
|
+
for (const [name, fragment] of this.#functions) {
|
374
|
+
if (name.split('(' /* fix:) */)[0] === key) {
|
375
|
+
matching.push(fragment);
|
376
|
+
}
|
377
|
+
}
|
378
|
+
if (values) {
|
379
|
+
const lastValue = values.length > 0 ? values[values.length - 1] : null;
|
380
|
+
let valueLength = values.length;
|
381
|
+
let allowOptions = true;
|
382
|
+
if (ethers_6.Typed.isTyped(lastValue) && lastValue.type === 'overrides') {
|
383
|
+
allowOptions = false;
|
384
|
+
valueLength--;
|
385
|
+
}
|
386
|
+
// Remove all matches that don't have a compatible length. The args
|
387
|
+
// may contain an overrides, so the match may have n or n - 1 parameters
|
388
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
389
|
+
const inputs = matching[i].inputs.length;
|
390
|
+
if (inputs !== valueLength && (!allowOptions || inputs !== valueLength - 1)) {
|
391
|
+
matching.splice(i, 1);
|
392
|
+
}
|
393
|
+
}
|
394
|
+
// Remove all matches that don't match the Typed signature
|
395
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
396
|
+
const inputs = matching[i].inputs;
|
397
|
+
for (let j = 0; j < values.length; j++) {
|
398
|
+
// Not a typed value
|
399
|
+
if (!ethers_6.Typed.isTyped(values[j])) {
|
400
|
+
continue;
|
401
|
+
}
|
402
|
+
// We are past the inputs
|
403
|
+
if (j >= inputs.length) {
|
404
|
+
if (values[j].type === 'overrides') {
|
405
|
+
continue;
|
406
|
+
}
|
407
|
+
matching.splice(i, 1);
|
408
|
+
break;
|
409
|
+
}
|
410
|
+
// Make sure the value type matches the input type
|
411
|
+
if (values[j].type !== inputs[j].baseType) {
|
412
|
+
matching.splice(i, 1);
|
413
|
+
break;
|
414
|
+
}
|
415
|
+
}
|
416
|
+
}
|
417
|
+
}
|
418
|
+
// We found a single matching signature with an overrides, but the
|
419
|
+
// last value is something that cannot possibly be an options
|
420
|
+
if (matching.length === 1 && values && values.length !== matching[0].inputs.length) {
|
421
|
+
const lastArg = values[values.length - 1];
|
422
|
+
if (lastArg == null || Array.isArray(lastArg) || typeof lastArg !== 'object') {
|
423
|
+
matching.splice(0, 1);
|
424
|
+
}
|
425
|
+
}
|
426
|
+
if (matching.length === 0) {
|
427
|
+
return null;
|
428
|
+
}
|
429
|
+
if (matching.length > 1 && forceUnique) {
|
430
|
+
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(', ');
|
431
|
+
(0, ethers_3.assertArgument)(false, `ambiguous function description (i.e. matches ${matchStr})`, 'key', key);
|
432
|
+
}
|
433
|
+
return matching[0];
|
434
|
+
}
|
435
|
+
// Normalize the signature and lookup the function
|
436
|
+
const result = this.#functions.get(fragments_js_1.FunctionFragment.from(key).format());
|
437
|
+
if (result) {
|
438
|
+
return result;
|
439
|
+
}
|
440
|
+
return null;
|
441
|
+
}
|
442
|
+
/**
|
443
|
+
* Get the function name for %%key%%, which may be a function selector,
|
444
|
+
* function name or function signature that belongs to the ABI.
|
445
|
+
*/
|
446
|
+
getFunctionName(key) {
|
447
|
+
const fragment = this.#getFunction(key, null, false);
|
448
|
+
(0, ethers_3.assertArgument)(fragment, 'no matching function', 'key', key);
|
449
|
+
return fragment.name;
|
450
|
+
}
|
451
|
+
/**
|
452
|
+
* Returns true if %%key%% (a function selector, function name or
|
453
|
+
* function signature) is present in the ABI.
|
454
|
+
*
|
455
|
+
* In the case of a function name, the name may be ambiguous, so
|
456
|
+
* accessing the [[FunctionFragment]] may require refinement.
|
457
|
+
*/
|
458
|
+
hasFunction(key) {
|
459
|
+
return !!this.#getFunction(key, null, false);
|
460
|
+
}
|
461
|
+
/**
|
462
|
+
* Get the [[FunctionFragment]] for %%key%%, which may be a function
|
463
|
+
* selector, function name or function signature that belongs to the ABI.
|
464
|
+
*
|
465
|
+
* If %%values%% is provided, it will use the Typed API to handle
|
466
|
+
* ambiguous cases where multiple functions match by name.
|
467
|
+
*
|
468
|
+
* If the %%key%% and %%values%% do not refine to a single function in
|
469
|
+
* the ABI, this will throw.
|
470
|
+
*/
|
471
|
+
getFunction(key, values) {
|
472
|
+
return this.#getFunction(key, values || null, true);
|
473
|
+
}
|
474
|
+
/**
|
475
|
+
* Iterate over all functions, calling %%callback%%, sorted by their name.
|
476
|
+
*/
|
477
|
+
forEachFunction(callback) {
|
478
|
+
const names = Array.from(this.#functions.keys());
|
479
|
+
names.sort((a, b) => a.localeCompare(b));
|
480
|
+
for (let i = 0; i < names.length; i++) {
|
481
|
+
const name = names[i];
|
482
|
+
callback(this.#functions.get(name), i);
|
483
|
+
}
|
484
|
+
}
|
485
|
+
// Find an event definition by any means necessary (unless it is ambiguous)
|
486
|
+
#getEvent(key, values, forceUnique) {
|
487
|
+
// EventTopic
|
488
|
+
if ((0, ethers_3.isHexString)(key)) {
|
489
|
+
const eventTopic = key.toLowerCase();
|
490
|
+
for (const fragment of this.#events.values()) {
|
491
|
+
if (eventTopic === fragment.topicHash) {
|
492
|
+
return fragment;
|
493
|
+
}
|
494
|
+
}
|
495
|
+
return null;
|
496
|
+
}
|
497
|
+
// It is a bare name, look up the function (will return null if ambiguous)
|
498
|
+
if (key.indexOf('(') === -1) {
|
499
|
+
const matching = [];
|
500
|
+
for (const [name, fragment] of this.#events) {
|
501
|
+
if (name.split('(' /* fix:) */)[0] === key) {
|
502
|
+
matching.push(fragment);
|
503
|
+
}
|
504
|
+
}
|
505
|
+
if (values) {
|
506
|
+
// Remove all matches that don't have a compatible length.
|
507
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
508
|
+
if (matching[i].inputs.length < values.length) {
|
509
|
+
matching.splice(i, 1);
|
510
|
+
}
|
511
|
+
}
|
512
|
+
// Remove all matches that don't match the Typed signature
|
513
|
+
for (let i = matching.length - 1; i >= 0; i--) {
|
514
|
+
const inputs = matching[i].inputs;
|
515
|
+
for (let j = 0; j < values.length; j++) {
|
516
|
+
// Not a typed value
|
517
|
+
if (!ethers_6.Typed.isTyped(values[j])) {
|
518
|
+
continue;
|
519
|
+
}
|
520
|
+
// Make sure the value type matches the input type
|
521
|
+
if (values[j].type !== inputs[j].baseType) {
|
522
|
+
matching.splice(i, 1);
|
523
|
+
break;
|
524
|
+
}
|
525
|
+
}
|
526
|
+
}
|
527
|
+
}
|
528
|
+
if (matching.length === 0) {
|
529
|
+
return null;
|
530
|
+
}
|
531
|
+
if (matching.length > 1 && forceUnique) {
|
532
|
+
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(', ');
|
533
|
+
(0, ethers_3.assertArgument)(false, `ambiguous event description (i.e. matches ${matchStr})`, 'key', key);
|
534
|
+
}
|
535
|
+
return matching[0];
|
536
|
+
}
|
537
|
+
// Normalize the signature and lookup the function
|
538
|
+
const result = this.#events.get(fragments_js_1.EventFragment.from(key).format());
|
539
|
+
if (result) {
|
540
|
+
return result;
|
541
|
+
}
|
542
|
+
return null;
|
543
|
+
}
|
544
|
+
/**
|
545
|
+
* Get the event name for %%key%%, which may be a topic hash,
|
546
|
+
* event name or event signature that belongs to the ABI.
|
547
|
+
*/
|
548
|
+
getEventName(key) {
|
549
|
+
const fragment = this.#getEvent(key, null, false);
|
550
|
+
(0, ethers_3.assertArgument)(fragment, 'no matching event', 'key', key);
|
551
|
+
return fragment.name;
|
552
|
+
}
|
553
|
+
/**
|
554
|
+
* Returns true if %%key%% (an event topic hash, event name or
|
555
|
+
* event signature) is present in the ABI.
|
556
|
+
*
|
557
|
+
* In the case of an event name, the name may be ambiguous, so
|
558
|
+
* accessing the [[EventFragment]] may require refinement.
|
559
|
+
*/
|
560
|
+
hasEvent(key) {
|
561
|
+
return !!this.#getEvent(key, null, false);
|
562
|
+
}
|
563
|
+
/**
|
564
|
+
* Get the [[EventFragment]] for %%key%%, which may be a topic hash,
|
565
|
+
* event name or event signature that belongs to the ABI.
|
566
|
+
*
|
567
|
+
* If %%values%% is provided, it will use the Typed API to handle
|
568
|
+
* ambiguous cases where multiple events match by name.
|
569
|
+
*
|
570
|
+
* If the %%key%% and %%values%% do not refine to a single event in
|
571
|
+
* the ABI, this will throw.
|
572
|
+
*/
|
573
|
+
getEvent(key, values) {
|
574
|
+
return this.#getEvent(key, values || null, true);
|
575
|
+
}
|
576
|
+
/**
|
577
|
+
* Iterate over all events, calling %%callback%%, sorted by their name.
|
578
|
+
*/
|
579
|
+
forEachEvent(callback) {
|
580
|
+
const names = Array.from(this.#events.keys());
|
581
|
+
names.sort((a, b) => a.localeCompare(b));
|
582
|
+
for (let i = 0; i < names.length; i++) {
|
583
|
+
const name = names[i];
|
584
|
+
callback(this.#events.get(name), i);
|
585
|
+
}
|
586
|
+
}
|
587
|
+
/**
|
588
|
+
* Get the [[ErrorFragment]] for %%key%%, which may be an error
|
589
|
+
* selector, error name or error signature that belongs to the ABI.
|
590
|
+
*
|
591
|
+
* If %%values%% is provided, it will use the Typed API to handle
|
592
|
+
* ambiguous cases where multiple errors match by name.
|
593
|
+
*
|
594
|
+
* If the %%key%% and %%values%% do not refine to a single error in
|
595
|
+
* the ABI, this will throw.
|
596
|
+
*/
|
597
|
+
getError(key, values) {
|
598
|
+
if ((0, ethers_3.isHexString)(key)) {
|
599
|
+
const selector = key.toLowerCase();
|
600
|
+
if (BuiltinErrors[selector]) {
|
601
|
+
return fragments_js_1.ErrorFragment.from(BuiltinErrors[selector].signature);
|
602
|
+
}
|
603
|
+
for (const fragment of this.#errors.values()) {
|
604
|
+
if (selector === fragment.selector) {
|
605
|
+
return fragment;
|
606
|
+
}
|
607
|
+
}
|
608
|
+
return null;
|
609
|
+
}
|
610
|
+
// It is a bare name, look up the function (will return null if ambiguous)
|
611
|
+
if (key.indexOf('(') === -1) {
|
612
|
+
const matching = [];
|
613
|
+
for (const [name, fragment] of this.#errors) {
|
614
|
+
if (name.split('(' /* fix:) */)[0] === key) {
|
615
|
+
matching.push(fragment);
|
616
|
+
}
|
617
|
+
}
|
618
|
+
if (matching.length === 0) {
|
619
|
+
if (key === 'Error') {
|
620
|
+
return fragments_js_1.ErrorFragment.from('error Error(string)');
|
621
|
+
}
|
622
|
+
if (key === 'Panic') {
|
623
|
+
return fragments_js_1.ErrorFragment.from('error Panic(uint256)');
|
624
|
+
}
|
625
|
+
return null;
|
626
|
+
}
|
627
|
+
else if (matching.length > 1) {
|
628
|
+
const matchStr = matching.map((m) => JSON.stringify(m.format())).join(', ');
|
629
|
+
(0, ethers_3.assertArgument)(false, `ambiguous error description (i.e. ${matchStr})`, 'name', key);
|
630
|
+
}
|
631
|
+
return matching[0];
|
632
|
+
}
|
633
|
+
// Normalize the signature and lookup the function
|
634
|
+
key = fragments_js_1.ErrorFragment.from(key).format();
|
635
|
+
if (key === 'Error(string)') {
|
636
|
+
return fragments_js_1.ErrorFragment.from('error Error(string)');
|
637
|
+
}
|
638
|
+
if (key === 'Panic(uint256)') {
|
639
|
+
return fragments_js_1.ErrorFragment.from('error Panic(uint256)');
|
640
|
+
}
|
641
|
+
const result = this.#errors.get(key);
|
642
|
+
if (result) {
|
643
|
+
return result;
|
644
|
+
}
|
645
|
+
return null;
|
646
|
+
}
|
647
|
+
/**
|
648
|
+
* Iterate over all errors, calling %%callback%%, sorted by their name.
|
649
|
+
*/
|
650
|
+
forEachError(callback) {
|
651
|
+
const names = Array.from(this.#errors.keys());
|
652
|
+
names.sort((a, b) => a.localeCompare(b));
|
653
|
+
for (let i = 0; i < names.length; i++) {
|
654
|
+
const name = names[i];
|
655
|
+
callback(this.#errors.get(name), i);
|
656
|
+
}
|
657
|
+
}
|
658
|
+
// Get the 4-byte selector used by Solidity to identify a function
|
659
|
+
/*
|
660
|
+
getSelector(fragment: ErrorFragment | FunctionFragment): string {
|
661
|
+
if (typeof(fragment) === "string") {
|
662
|
+
const matches: Array<Fragment> = [ ];
|
663
|
+
|
664
|
+
try { matches.push(this.getFunction(fragment)); } catch (error) { }
|
665
|
+
try { matches.push(this.getError(<string>fragment)); } catch (_) { }
|
666
|
+
|
667
|
+
if (matches.length === 0) {
|
668
|
+
logger.throwArgumentError("unknown fragment", "key", fragment);
|
669
|
+
} else if (matches.length > 1) {
|
670
|
+
logger.throwArgumentError("ambiguous fragment matches function and error", "key", fragment);
|
671
|
+
}
|
672
|
+
|
673
|
+
fragment = matches[0];
|
674
|
+
}
|
675
|
+
|
676
|
+
return dataSlice(id(fragment.format()), 0, 4);
|
677
|
+
}
|
678
|
+
*/
|
679
|
+
// Get the 32-byte topic hash used by Solidity to identify an event
|
680
|
+
/*
|
681
|
+
getEventTopic(fragment: EventFragment): string {
|
682
|
+
//if (typeof(fragment) === "string") { fragment = this.getEvent(eventFragment); }
|
683
|
+
return id(fragment.format());
|
684
|
+
}
|
685
|
+
*/
|
686
|
+
_decodeParams(params, data) {
|
687
|
+
return this.#abiCoder.decode(params, data);
|
688
|
+
}
|
689
|
+
_encodeParams(params, values) {
|
690
|
+
return this.#abiCoder.encode(params, values);
|
691
|
+
}
|
692
|
+
/**
|
693
|
+
* Encodes a ``tx.data`` object for deploying the Contract with
|
694
|
+
* the %%values%% as the constructor arguments.
|
695
|
+
*/
|
696
|
+
encodeDeploy(values) {
|
697
|
+
return this._encodeParams(this.deploy.inputs, values || []);
|
698
|
+
}
|
699
|
+
/**
|
700
|
+
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
701
|
+
* specified error (see [[getError]] for valid values for
|
702
|
+
* %%key%%).
|
703
|
+
*
|
704
|
+
* Most developers should prefer the [[parseCallResult]] method instead,
|
705
|
+
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
706
|
+
* corresponding error.
|
707
|
+
*/
|
708
|
+
decodeErrorResult(fragment, data) {
|
709
|
+
if (typeof fragment === 'string') {
|
710
|
+
const f = this.getError(fragment);
|
711
|
+
(0, ethers_3.assertArgument)(f, 'unknown error', 'fragment', fragment);
|
712
|
+
fragment = f;
|
713
|
+
}
|
714
|
+
(0, ethers_3.assertArgument)((0, ethers_3.dataSlice)(data, 0, 4) === fragment.selector, `data signature does not match error ${fragment.name}.`, 'data', data);
|
715
|
+
return this._decodeParams(fragment.inputs, (0, ethers_3.dataSlice)(data, 4));
|
716
|
+
}
|
717
|
+
/**
|
718
|
+
* Encodes the transaction revert data for a call result that
|
719
|
+
* reverted from the the Contract with the sepcified %%error%%
|
720
|
+
* (see [[getError]] for valid values for %%fragment%%) with the %%values%%.
|
721
|
+
*
|
722
|
+
* This is generally not used by most developers, unless trying to mock
|
723
|
+
* a result from a Contract.
|
724
|
+
*/
|
725
|
+
encodeErrorResult(fragment, values) {
|
726
|
+
if (typeof fragment === 'string') {
|
727
|
+
const f = this.getError(fragment);
|
728
|
+
(0, ethers_3.assertArgument)(f, 'unknown error', 'fragment', fragment);
|
729
|
+
fragment = f;
|
730
|
+
}
|
731
|
+
return (0, ethers_3.concat)([fragment.selector, this._encodeParams(fragment.inputs, values || [])]);
|
732
|
+
}
|
733
|
+
/**
|
734
|
+
* Decodes the %%data%% from a transaction ``tx.data`` for
|
735
|
+
* the function specified (see [[getFunction]] for valid values
|
736
|
+
* for %%fragment%%).
|
737
|
+
*
|
738
|
+
* Most developers should prefer the [[parseTransaction]] method
|
739
|
+
* instead, which will automatically detect the fragment.
|
740
|
+
*/
|
741
|
+
decodeFunctionData(fragment, data) {
|
742
|
+
if (typeof fragment === 'string') {
|
743
|
+
const f = this.getFunction(fragment);
|
744
|
+
(0, ethers_3.assertArgument)(f, 'unknown function', 'fragment', fragment);
|
745
|
+
fragment = f;
|
746
|
+
}
|
747
|
+
(0, ethers_3.assertArgument)((0, ethers_3.dataSlice)(data, 0, 4) === fragment.selector, `data signature does not match function ${fragment.name}.`, 'data', data);
|
748
|
+
return this._decodeParams(fragment.inputs, (0, ethers_3.dataSlice)(data, 4));
|
749
|
+
}
|
750
|
+
/**
|
751
|
+
* Encodes the ``tx.data`` for a transaction that calls the function
|
752
|
+
* specified (see [[getFunction]] for valid values for %%fragment%%) with
|
753
|
+
* the %%values%%.
|
754
|
+
*/
|
755
|
+
encodeFunctionData(fragment, values) {
|
756
|
+
if (typeof fragment === 'string') {
|
757
|
+
const f = this.getFunction(fragment);
|
758
|
+
(0, ethers_3.assertArgument)(f, 'unknown function', 'fragment', fragment);
|
759
|
+
fragment = f;
|
760
|
+
}
|
761
|
+
return (0, ethers_3.concat)([fragment.selector, this._encodeParams(fragment.inputs, values || [])]);
|
762
|
+
}
|
763
|
+
/**
|
764
|
+
* Decodes the result %%data%% (e.g. from an ``eth_call``) for the
|
765
|
+
* specified function (see [[getFunction]] for valid values for
|
766
|
+
* %%key%%).
|
767
|
+
*
|
768
|
+
* Most developers should prefer the [[parseCallResult]] method instead,
|
769
|
+
* which will automatically detect a ``CALL_EXCEPTION`` and throw the
|
770
|
+
* corresponding error.
|
771
|
+
*/
|
772
|
+
decodeFunctionResult(fragment, data) {
|
773
|
+
if (typeof fragment === 'string') {
|
774
|
+
const f = this.getFunction(fragment);
|
775
|
+
(0, ethers_3.assertArgument)(f, 'unknown function', 'fragment', fragment);
|
776
|
+
fragment = f;
|
777
|
+
}
|
778
|
+
let message = 'invalid length for result data';
|
779
|
+
const bytes = (0, ethers_3.getBytesCopy)(data);
|
780
|
+
if (bytes.length % 32 === 0) {
|
781
|
+
try {
|
782
|
+
return this.#abiCoder.decode(fragment.outputs, bytes);
|
783
|
+
}
|
784
|
+
catch (error) {
|
785
|
+
message = 'could not decode result data';
|
786
|
+
}
|
787
|
+
}
|
788
|
+
// Call returned data with no error, but the data is junk
|
789
|
+
(0, ethers_3.assert)(false, message, 'BAD_DATA', {
|
790
|
+
value: (0, ethers_3.hexlify)(bytes),
|
791
|
+
info: { method: fragment.name, signature: fragment.format() },
|
792
|
+
});
|
793
|
+
}
|
794
|
+
makeError(_data, tx) {
|
795
|
+
const data = (0, ethers_3.getBytes)(_data, 'data');
|
796
|
+
const error = ethers_4.AbiCoder.getBuiltinCallException('call', tx, data);
|
797
|
+
// Not a built-in error; try finding a custom error
|
798
|
+
const customPrefix = 'execution reverted (unknown custom error)';
|
799
|
+
if (error.message.startsWith(customPrefix)) {
|
800
|
+
const selector = (0, ethers_3.hexlify)(data.slice(0, 4));
|
801
|
+
const ef = this.getError(selector);
|
802
|
+
if (ef) {
|
803
|
+
try {
|
804
|
+
const args = this.#abiCoder.decode(ef.inputs, data.slice(4));
|
805
|
+
error.revert = {
|
806
|
+
name: ef.name,
|
807
|
+
signature: ef.format(),
|
808
|
+
args,
|
809
|
+
};
|
810
|
+
error.reason = error.revert.signature;
|
811
|
+
error.message = `execution reverted: ${error.reason}`;
|
812
|
+
}
|
813
|
+
catch (e) {
|
814
|
+
error.message = `execution reverted (coult not decode custom error)`;
|
815
|
+
}
|
816
|
+
}
|
817
|
+
}
|
818
|
+
// Add the invocation, if available
|
819
|
+
const parsed = this.parseTransaction(tx);
|
820
|
+
if (parsed) {
|
821
|
+
error.invocation = {
|
822
|
+
method: parsed.name,
|
823
|
+
signature: parsed.signature,
|
824
|
+
args: parsed.args,
|
825
|
+
};
|
826
|
+
}
|
827
|
+
return error;
|
828
|
+
}
|
829
|
+
/**
|
830
|
+
* Encodes the result data (e.g. from an ``eth_call``) for the
|
831
|
+
* specified function (see [[getFunction]] for valid values
|
832
|
+
* for %%fragment%%) with %%values%%.
|
833
|
+
*
|
834
|
+
* This is generally not used by most developers, unless trying to mock
|
835
|
+
* a result from a Contract.
|
836
|
+
*/
|
837
|
+
encodeFunctionResult(fragment, values) {
|
838
|
+
if (typeof fragment === 'string') {
|
839
|
+
const f = this.getFunction(fragment);
|
840
|
+
(0, ethers_3.assertArgument)(f, 'unknown function', 'fragment', fragment);
|
841
|
+
fragment = f;
|
842
|
+
}
|
843
|
+
return (0, ethers_3.hexlify)(this.#abiCoder.encode(fragment.outputs, values || []));
|
844
|
+
}
|
845
|
+
/*
|
846
|
+
spelunk(inputs: Array<ParamType>, values: ReadonlyArray<any>, processfunc: (type: string, value: any) => Promise<any>): Promise<Array<any>> {
|
847
|
+
const promises: Array<Promise<>> = [ ];
|
848
|
+
const process = function(type: ParamType, value: any): any {
|
849
|
+
if (type.baseType === "array") {
|
850
|
+
return descend(type.child
|
851
|
+
}
|
852
|
+
if (type. === "address") {
|
853
|
+
}
|
854
|
+
};
|
855
|
+
|
856
|
+
const descend = function (inputs: Array<ParamType>, values: ReadonlyArray<any>) {
|
857
|
+
if (inputs.length !== values.length) { throw new Error("length mismatch"); }
|
858
|
+
|
859
|
+
};
|
860
|
+
|
861
|
+
const result: Array<any> = [ ];
|
862
|
+
values.forEach((value, index) => {
|
863
|
+
if (value == null) {
|
864
|
+
topics.push(null);
|
865
|
+
} else if (param.baseType === "array" || param.baseType === "tuple") {
|
866
|
+
logger.throwArgumentError("filtering with tuples or arrays not supported", ("contract." + param.name), value);
|
867
|
+
} else if (Array.isArray(value)) {
|
868
|
+
topics.push(value.map((value) => encodeTopic(param, value)));
|
869
|
+
} else {
|
870
|
+
topics.push(encodeTopic(param, value));
|
871
|
+
}
|
872
|
+
});
|
873
|
+
}
|
874
|
+
*/
|
875
|
+
// Create the filter for the event with search criteria (e.g. for eth_filterLog)
|
876
|
+
encodeFilterTopics(fragment, values) {
|
877
|
+
if (typeof fragment === 'string') {
|
878
|
+
const f = this.getEvent(fragment);
|
879
|
+
(0, ethers_3.assertArgument)(f, 'unknown event', 'eventFragment', fragment);
|
880
|
+
fragment = f;
|
881
|
+
}
|
882
|
+
(0, ethers_3.assert)(values.length <= fragment.inputs.length, `too many arguments for ${fragment.format()}`, 'UNEXPECTED_ARGUMENT', {
|
883
|
+
count: values.length,
|
884
|
+
expectedCount: fragment.inputs.length,
|
885
|
+
});
|
886
|
+
const topics = [];
|
887
|
+
if (!fragment.anonymous) {
|
888
|
+
topics.push(fragment.topicHash);
|
889
|
+
}
|
890
|
+
// @TODO: Use the coders for this; to properly support tuples, etc.
|
891
|
+
const encodeTopic = (param, value) => {
|
892
|
+
if (param.type === 'string') {
|
893
|
+
return (0, ethers_2.id)(value);
|
894
|
+
}
|
895
|
+
else if (param.type === 'bytes') {
|
896
|
+
return (0, ethers_1.keccak256)((0, ethers_3.hexlify)(value));
|
897
|
+
}
|
898
|
+
if (param.type === 'bool' && typeof value === 'boolean') {
|
899
|
+
value = value ? '0x01' : '0x00';
|
900
|
+
}
|
901
|
+
if (param.type.match(/^u?int/)) {
|
902
|
+
value = (0, ethers_3.toBeHex)(value);
|
903
|
+
}
|
904
|
+
// Check addresses are valid
|
905
|
+
if (param.type === 'address') {
|
906
|
+
this.#abiCoder.encode(['address'], [value]);
|
907
|
+
}
|
908
|
+
return (0, ethers_3.zeroPadValue)((0, ethers_3.hexlify)(value), 32);
|
909
|
+
//@TOOD should probably be return toHex(value, 32)
|
910
|
+
};
|
911
|
+
values.forEach((value, index) => {
|
912
|
+
const param = fragment.inputs[index];
|
913
|
+
if (!param.indexed) {
|
914
|
+
(0, ethers_3.assertArgument)(value == null, 'cannot filter non-indexed parameters; must be null', 'contract.' + param.name, value);
|
915
|
+
return;
|
916
|
+
}
|
917
|
+
if (value == null) {
|
918
|
+
topics.push(null);
|
919
|
+
}
|
920
|
+
else if (param.baseType === 'array' || param.baseType === 'tuple') {
|
921
|
+
(0, ethers_3.assertArgument)(false, 'filtering with tuples or arrays not supported', 'contract.' + param.name, value);
|
922
|
+
}
|
923
|
+
else if (Array.isArray(value)) {
|
924
|
+
topics.push(value.map((value) => encodeTopic(param, value)));
|
925
|
+
}
|
926
|
+
else {
|
927
|
+
topics.push(encodeTopic(param, value));
|
928
|
+
}
|
929
|
+
});
|
930
|
+
// Trim off trailing nulls
|
931
|
+
while (topics.length && topics[topics.length - 1] === null) {
|
932
|
+
topics.pop();
|
933
|
+
}
|
934
|
+
return topics;
|
935
|
+
}
|
936
|
+
encodeEventLog(fragment, values) {
|
937
|
+
if (typeof fragment === 'string') {
|
938
|
+
const f = this.getEvent(fragment);
|
939
|
+
(0, ethers_3.assertArgument)(f, 'unknown event', 'eventFragment', fragment);
|
940
|
+
fragment = f;
|
941
|
+
}
|
942
|
+
const topics = [];
|
943
|
+
const dataTypes = [];
|
944
|
+
const dataValues = [];
|
945
|
+
if (!fragment.anonymous) {
|
946
|
+
topics.push(fragment.topicHash);
|
947
|
+
}
|
948
|
+
(0, ethers_3.assertArgument)(values.length === fragment.inputs.length, 'event arguments/values mismatch', 'values', values);
|
949
|
+
fragment.inputs.forEach((param, index) => {
|
950
|
+
const value = values[index];
|
951
|
+
if (param.indexed) {
|
952
|
+
if (param.type === 'string') {
|
953
|
+
topics.push((0, ethers_2.id)(value));
|
954
|
+
}
|
955
|
+
else if (param.type === 'bytes') {
|
956
|
+
topics.push((0, ethers_1.keccak256)(value));
|
957
|
+
}
|
958
|
+
else if (param.baseType === 'tuple' || param.baseType === 'array') {
|
959
|
+
// @TODO
|
960
|
+
throw new Error('not implemented');
|
961
|
+
}
|
962
|
+
else {
|
963
|
+
topics.push(this.#abiCoder.encode([param.type], [value]));
|
964
|
+
}
|
965
|
+
}
|
966
|
+
else {
|
967
|
+
dataTypes.push(param);
|
968
|
+
dataValues.push(value);
|
969
|
+
}
|
970
|
+
});
|
971
|
+
return {
|
972
|
+
data: this.#abiCoder.encode(dataTypes, dataValues),
|
973
|
+
topics: topics,
|
974
|
+
};
|
975
|
+
}
|
976
|
+
// Decode a filter for the event and the search criteria
|
977
|
+
decodeEventLog(fragment, data, topics) {
|
978
|
+
if (typeof fragment === 'string') {
|
979
|
+
const f = this.getEvent(fragment);
|
980
|
+
(0, ethers_3.assertArgument)(f, 'unknown event', 'eventFragment', fragment);
|
981
|
+
fragment = f;
|
982
|
+
}
|
983
|
+
if (topics != null && !fragment.anonymous) {
|
984
|
+
const eventTopic = fragment.topicHash;
|
985
|
+
(0, ethers_3.assertArgument)((0, ethers_3.isHexString)(topics[0], 32) && topics[0].toLowerCase() === eventTopic, 'fragment/topic mismatch', 'topics[0]', topics[0]);
|
986
|
+
topics = topics.slice(1);
|
987
|
+
}
|
988
|
+
const indexed = [];
|
989
|
+
const nonIndexed = [];
|
990
|
+
const dynamic = [];
|
991
|
+
fragment.inputs.forEach((param, index) => {
|
992
|
+
if (param.indexed) {
|
993
|
+
if (param.type === 'string' ||
|
994
|
+
param.type === 'bytes' ||
|
995
|
+
param.baseType === 'tuple' ||
|
996
|
+
param.baseType === 'array') {
|
997
|
+
indexed.push(fragments_js_1.ParamType.from({ type: 'bytes32', name: param.name }));
|
998
|
+
dynamic.push(true);
|
999
|
+
}
|
1000
|
+
else {
|
1001
|
+
indexed.push(param);
|
1002
|
+
dynamic.push(false);
|
1003
|
+
}
|
1004
|
+
}
|
1005
|
+
else {
|
1006
|
+
nonIndexed.push(param);
|
1007
|
+
dynamic.push(false);
|
1008
|
+
}
|
1009
|
+
});
|
1010
|
+
const resultIndexed = topics != null ? this.#abiCoder.decode(indexed, (0, ethers_3.concat)(topics)) : null;
|
1011
|
+
const resultNonIndexed = this.#abiCoder.decode(nonIndexed, data, true);
|
1012
|
+
//const result: (Array<any> & { [ key: string ]: any }) = [ ];
|
1013
|
+
const values = [];
|
1014
|
+
const keys = [];
|
1015
|
+
let nonIndexedIndex = 0, indexedIndex = 0;
|
1016
|
+
fragment.inputs.forEach((param, index) => {
|
1017
|
+
let value = null;
|
1018
|
+
if (param.indexed) {
|
1019
|
+
if (resultIndexed == null) {
|
1020
|
+
value = new Indexed(null);
|
1021
|
+
}
|
1022
|
+
else if (dynamic[index]) {
|
1023
|
+
value = new Indexed(resultIndexed[indexedIndex++]);
|
1024
|
+
}
|
1025
|
+
else {
|
1026
|
+
try {
|
1027
|
+
value = resultIndexed[indexedIndex++];
|
1028
|
+
}
|
1029
|
+
catch (error) {
|
1030
|
+
value = error;
|
1031
|
+
}
|
1032
|
+
}
|
1033
|
+
}
|
1034
|
+
else {
|
1035
|
+
try {
|
1036
|
+
value = resultNonIndexed[nonIndexedIndex++];
|
1037
|
+
}
|
1038
|
+
catch (error) {
|
1039
|
+
value = error;
|
1040
|
+
}
|
1041
|
+
}
|
1042
|
+
values.push(value);
|
1043
|
+
keys.push(param.name || null);
|
1044
|
+
});
|
1045
|
+
return ethers_5.Result.fromItems(values, keys);
|
1046
|
+
}
|
1047
|
+
/**
|
1048
|
+
* Parses a transaction, finding the matching function and extracts
|
1049
|
+
* the parameter values along with other useful function details.
|
1050
|
+
*
|
1051
|
+
* If the matching function cannot be found, return null.
|
1052
|
+
*/
|
1053
|
+
parseTransaction(tx) {
|
1054
|
+
const data = (0, ethers_3.getBytes)(tx.data, 'tx.data');
|
1055
|
+
const value = (0, ethers_3.getBigInt)(tx.value != null ? tx.value : 0, 'tx.value');
|
1056
|
+
const fragment = this.getFunction((0, ethers_3.hexlify)(data.slice(0, 4)));
|
1057
|
+
if (!fragment) {
|
1058
|
+
return null;
|
1059
|
+
}
|
1060
|
+
const args = this.#abiCoder.decode(fragment.inputs, data.slice(4));
|
1061
|
+
return new TransactionDescription(fragment, fragment.selector, args, value);
|
1062
|
+
}
|
1063
|
+
parseCallResult(data) {
|
1064
|
+
throw new Error('@TODO');
|
1065
|
+
}
|
1066
|
+
/**
|
1067
|
+
* Parses a receipt log, finding the matching event and extracts
|
1068
|
+
* the parameter values along with other useful event details.
|
1069
|
+
*
|
1070
|
+
* If the matching event cannot be found, returns null.
|
1071
|
+
*/
|
1072
|
+
parseLog(log) {
|
1073
|
+
const fragment = this.getEvent(log.topics[0]);
|
1074
|
+
if (!fragment || fragment.anonymous) {
|
1075
|
+
return null;
|
1076
|
+
}
|
1077
|
+
// @TODO: If anonymous, and the only method, and the input count matches, should we parse?
|
1078
|
+
// Probably not, because just because it is the only event in the ABI does
|
1079
|
+
// not mean we have the full ABI; maybe just a fragment?
|
1080
|
+
return new LogDescription(fragment, fragment.topicHash, this.decodeEventLog(fragment, log.data, log.topics));
|
1081
|
+
}
|
1082
|
+
/**
|
1083
|
+
* Parses a revert data, finding the matching error and extracts
|
1084
|
+
* the parameter values along with other useful error details.
|
1085
|
+
*
|
1086
|
+
* If the matching event cannot be found, returns null.
|
1087
|
+
*/
|
1088
|
+
parseError(data) {
|
1089
|
+
const hexData = (0, ethers_3.hexlify)(data);
|
1090
|
+
const fragment = this.getError((0, ethers_3.dataSlice)(hexData, 0, 4));
|
1091
|
+
if (!fragment) {
|
1092
|
+
return null;
|
1093
|
+
}
|
1094
|
+
const args = this.#abiCoder.decode(fragment.inputs, (0, ethers_3.dataSlice)(hexData, 4));
|
1095
|
+
return new ErrorDescription(fragment, fragment.selector, args);
|
1096
|
+
}
|
1097
|
+
/**
|
1098
|
+
* Creates a new [[Interface]] from the ABI %%value%%.
|
1099
|
+
*
|
1100
|
+
* The %%value%% may be provided as an existing [[Interface]] object,
|
1101
|
+
* a JSON-encoded ABI or any Human-Readable ABI format.
|
1102
|
+
*/
|
1103
|
+
static from(value) {
|
1104
|
+
// Already an Interface, which is immutable
|
1105
|
+
if (value instanceof Interface) {
|
1106
|
+
return value;
|
1107
|
+
}
|
1108
|
+
// JSON
|
1109
|
+
if (typeof value === 'string') {
|
1110
|
+
return new Interface(JSON.parse(value));
|
1111
|
+
}
|
1112
|
+
// Maybe an interface from an older version, or from a symlinked copy
|
1113
|
+
if (typeof value.format === 'function') {
|
1114
|
+
return new Interface(value.format('json'));
|
1115
|
+
}
|
1116
|
+
// Array of fragments
|
1117
|
+
return new Interface(value);
|
1118
|
+
}
|
1119
|
+
}
|
1120
|
+
exports.Interface = Interface;
|
1121
|
+
//# sourceMappingURL=interface.js.map
|