@arkecosystem/typescript-crypto 0.0.17 → 0.0.19
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/dist/enums/ContractAbiType.d.ts +2 -1
- package/dist/enums/ContractAbiType.d.ts.map +1 -1
- package/dist/enums/ContractAbiType.js +1 -0
- package/dist/index.js +143 -0
- package/dist/utils/Abi/json/Abi.ERC20BatchTransfer.json +59 -0
- package/dist/utils/Abi/json/index.d.ts +1 -0
- package/dist/utils/Abi/json/index.d.ts.map +1 -1
- package/dist/utils/Abi/json/index.js +1 -0
- package/dist/utils/AbiBase.d.ts.map +1 -1
- package/dist/utils/AbiBase.js +3 -1
- package/dist/utils/TransactionTypeIdentifier.d.ts +28 -0
- package/dist/utils/TransactionTypeIdentifier.d.ts.map +1 -0
- package/dist/utils/TransactionTypeIdentifier.js +89 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +1 -0
- package/package.json +1 -1
- package/src/enums/ContractAbiType.ts +1 -0
- package/src/utils/Abi/json/Abi.ERC20BatchTransfer.json +59 -0
- package/src/utils/Abi/json/index.ts +1 -0
- package/src/utils/AbiBase.ts +9 -1
- package/src/utils/TransactionTypeIdentifier.ts +100 -0
- package/src/utils/index.ts +1 -0
- package/tests/unit/utils/TransactionTypeIdentifier.test.ts +256 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ContractAbiType.d.ts","sourceRoot":"","sources":["../../src/enums/ContractAbiType.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IAC1B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,SAAS,cAAc;
|
|
1
|
+
{"version":3,"file":"ContractAbiType.d.ts","sourceRoot":"","sources":["../../src/enums/ContractAbiType.ts"],"names":[],"mappings":"AAAA,oBAAY,eAAe;IAC1B,MAAM,WAAW;IACjB,KAAK,UAAU;IACf,SAAS,cAAc;IACvB,YAAY,iBAAiB;IAC7B,SAAS,cAAc;IACvB,mBAAmB,uBAAuB;CAC1C"}
|
|
@@ -5,4 +5,5 @@ export var ContractAbiType;
|
|
|
5
5
|
ContractAbiType["CONSENSUS"] = "consensus";
|
|
6
6
|
ContractAbiType["MULTIPAYMENT"] = "multipayment";
|
|
7
7
|
ContractAbiType["USERNAMES"] = "usernames";
|
|
8
|
+
ContractAbiType["ERC20BATCH_TRANSFER"] = "erc20batchtransfer";
|
|
8
9
|
})(ContractAbiType || (ContractAbiType = {}));
|
package/dist/index.js
CHANGED
|
@@ -55,6 +55,7 @@ var ContractAbiType = /* @__PURE__ */ ((ContractAbiType2) => {
|
|
|
55
55
|
ContractAbiType2["CONSENSUS"] = "consensus";
|
|
56
56
|
ContractAbiType2["MULTIPAYMENT"] = "multipayment";
|
|
57
57
|
ContractAbiType2["USERNAMES"] = "usernames";
|
|
58
|
+
ContractAbiType2["ERC20BATCH_TRANSFER"] = "erc20batchtransfer";
|
|
58
59
|
return ContractAbiType2;
|
|
59
60
|
})(ContractAbiType || {});
|
|
60
61
|
|
|
@@ -28134,6 +28135,67 @@ var Abi_Token_default = {
|
|
|
28134
28135
|
bytecode: "0x608060405234801561001057600080fd5b506040518060400160405280600681526020017f4441524b323000000000000000000000000000000000000000000000000000008152506040518060400160405280600681526020017f4441524b32300000000000000000000000000000000000000000000000000000815250816003908161008c91906105bc565b50806004908161009c91906105bc565b5050506100ba336a52b7d2dcc80cd2e40000006100bf60201b60201c565b6107ae565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036101315760006040517fec442f0500000000000000000000000000000000000000000000000000000000815260040161012891906106cf565b60405180910390fd5b6101436000838361014760201b60201c565b5050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361019957806002600082825461018d9190610719565b9250508190555061026c565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905081811015610225578381836040517fe450d38c00000000000000000000000000000000000000000000000000000000815260040161021c9392919061075c565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16036102b55780600260008282540392505081905550610302565b806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405161035f9190610793565b60405180910390a3505050565b600081519050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806103ed57607f821691505b602082108103610400576103ff6103a6565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026104687fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261042b565b610472868361042b565b95508019841693508086168417925050509392505050565b6000819050919050565b6000819050919050565b60006104b96104b46104af8461048a565b610494565b61048a565b9050919050565b6000819050919050565b6104d38361049e565b6104e76104df826104c0565b848454610438565b825550505050565b600090565b6104fc6104ef565b6105078184846104ca565b505050565b5b8181101561052b576105206000826104f4565b60018101905061050d565b5050565b601f8211156105705761054181610406565b61054a8461041b565b81016020851015610559578190505b61056d6105658561041b565b83018261050c565b50505b505050565b600082821c905092915050565b600061059360001984600802610575565b1980831691505092915050565b60006105ac8383610582565b9150826002028217905092915050565b6105c58261036c565b67ffffffffffffffff8111156105de576105dd610377565b5b6105e882546103d5565b6105f382828561052f565b600060209050601f8311600181146106265760008415610614578287015190505b61061e85826105a0565b865550610686565b601f19841661063486610406565b60005b8281101561065c57848901518255600182019150602085019450602081019050610637565b868310156106795784890151610675601f891682610582565b8355505b6001600288020188555050505b505050505050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b60006106b98261068e565b9050919050565b6106c9816106ae565b82525050565b60006020820190506106e460008301846106c0565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006107248261048a565b915061072f8361048a565b9250828201905080821115610747576107466106ea565b5b92915050565b6107568161048a565b82525050565b600060608201905061077160008301866106c0565b61077e602083018561074d565b61078b604083018461074d565b949350505050565b60006020820190506107a8600083018461074d565b92915050565b611156806107bd6000396000f3fe608060405234801561001057600080fd5b506004361061009e5760003560e01c806370a082311161006657806370a082311461015d57806388d695b21461018d57806395d89b41146101bd578063a9059cbb146101db578063dd62ed3e1461020b5761009e565b806306fdde03146100a3578063095ea7b3146100c157806318160ddd146100f157806323b872dd1461010f578063313ce5671461013f575b600080fd5b6100ab61023b565b6040516100b89190610ba8565b60405180910390f35b6100db60048036038101906100d69190610c68565b6102cd565b6040516100e89190610cc3565b60405180910390f35b6100f96102f0565b6040516101069190610ced565b60405180910390f35b61012960048036038101906101249190610d08565b6102fa565b6040516101369190610cc3565b60405180910390f35b610147610329565b6040516101549190610d77565b60405180910390f35b61017760048036038101906101729190610d92565b610332565b6040516101849190610ced565b60405180910390f35b6101a760048036038101906101a29190610e7a565b61037a565b6040516101b49190610cc3565b60405180910390f35b6101c561043e565b6040516101d29190610ba8565b60405180910390f35b6101f560048036038101906101f09190610c68565b6104d0565b6040516102029190610cc3565b60405180910390f35b61022560048036038101906102209190610efb565b6104f3565b6040516102329190610ced565b60405180910390f35b60606003805461024a90610f6a565b80601f016020809104026020016040519081016040528092919081815260200182805461027690610f6a565b80156102c35780601f10610298576101008083540402835291602001916102c3565b820191906000526020600020905b8154815290600101906020018083116102a657829003601f168201915b5050505050905090565b6000806102d861057a565b90506102e5818585610582565b600191505092915050565b6000600254905090565b60008061030561057a565b9050610312858285610594565b61031d858585610628565b60019150509392505050565b60006012905090565b60008060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b60008282905085859050146103c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103bb9061100d565b60405180910390fd5b60005b85859050811015610431576104246103dd61057a565b8787848181106103f0576103ef61102d565b5b90506020020160208101906104059190610d92565b8686858181106104185761041761102d565b5b90506020020135610628565b80806001019150506103c7565b5060019050949350505050565b60606004805461044d90610f6a565b80601f016020809104026020016040519081016040528092919081815260200182805461047990610f6a565b80156104c65780601f1061049b576101008083540402835291602001916104c6565b820191906000526020600020905b8154815290600101906020018083116104a957829003601f168201915b5050505050905090565b6000806104db61057a565b90506104e8818585610628565b600191505092915050565b6000600160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905092915050565b600033905090565b61058f838383600161071c565b505050565b60006105a084846104f3565b90507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff81146106225781811015610612578281836040517ffb8f41b20000000000000000000000000000000000000000000000000000000081526004016106099392919061106b565b60405180910390fd5b6106218484848403600061071c565b5b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361069a5760006040517f96c6fd1e00000000000000000000000000000000000000000000000000000000815260040161069191906110a2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff160361070c5760006040517fec442f0500000000000000000000000000000000000000000000000000000000815260040161070391906110a2565b60405180910390fd5b6107178383836108f3565b505050565b600073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff160361078e5760006040517fe602df0500000000000000000000000000000000000000000000000000000000815260040161078591906110a2565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff16036108005760006040517f94280d620000000000000000000000000000000000000000000000000000000081526004016107f791906110a2565b60405180910390fd5b81600160008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000208190555080156108ed578273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925846040516108e49190610ced565b60405180910390a35b50505050565b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff160361094557806002600082825461093991906110ec565b92505081905550610a18565b60008060008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050818110156109d1578381836040517fe450d38c0000000000000000000000000000000000000000000000000000000081526004016109c89392919061106b565b60405180910390fd5b8181036000808673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550505b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610a615780600260008282540392505081905550610aae565b806000808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825401925050819055505b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef83604051610b0b9190610ced565b60405180910390a3505050565b600081519050919050565b600082825260208201905092915050565b60005b83811015610b52578082015181840152602081019050610b37565b60008484015250505050565b6000601f19601f8301169050919050565b6000610b7a82610b18565b610b848185610b23565b9350610b94818560208601610b34565b610b9d81610b5e565b840191505092915050565b60006020820190508181036000830152610bc28184610b6f565b905092915050565b600080fd5b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610bff82610bd4565b9050919050565b610c0f81610bf4565b8114610c1a57600080fd5b50565b600081359050610c2c81610c06565b92915050565b6000819050919050565b610c4581610c32565b8114610c5057600080fd5b50565b600081359050610c6281610c3c565b92915050565b60008060408385031215610c7f57610c7e610bca565b5b6000610c8d85828601610c1d565b9250506020610c9e85828601610c53565b9150509250929050565b60008115159050919050565b610cbd81610ca8565b82525050565b6000602082019050610cd86000830184610cb4565b92915050565b610ce781610c32565b82525050565b6000602082019050610d026000830184610cde565b92915050565b600080600060608486031215610d2157610d20610bca565b5b6000610d2f86828701610c1d565b9350506020610d4086828701610c1d565b9250506040610d5186828701610c53565b9150509250925092565b600060ff82169050919050565b610d7181610d5b565b82525050565b6000602082019050610d8c6000830184610d68565b92915050565b600060208284031215610da857610da7610bca565b5b6000610db684828501610c1d565b91505092915050565b600080fd5b600080fd5b600080fd5b60008083601f840112610de457610de3610dbf565b5b8235905067ffffffffffffffff811115610e0157610e00610dc4565b5b602083019150836020820283011115610e1d57610e1c610dc9565b5b9250929050565b60008083601f840112610e3a57610e39610dbf565b5b8235905067ffffffffffffffff811115610e5757610e56610dc4565b5b602083019150836020820283011115610e7357610e72610dc9565b5b9250929050565b60008060008060408587031215610e9457610e93610bca565b5b600085013567ffffffffffffffff811115610eb257610eb1610bcf565b5b610ebe87828801610dce565b9450945050602085013567ffffffffffffffff811115610ee157610ee0610bcf565b5b610eed87828801610e24565b925092505092959194509250565b60008060408385031215610f1257610f11610bca565b5b6000610f2085828601610c1d565b9250506020610f3185828601610c1d565b9150509250929050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b60006002820490506001821680610f8257607f821691505b602082108103610f9557610f94610f3b565b5b50919050565b7f726563697069656e747320616e6420616d6f756e7473206c656e677468206d6960008201527f736d617463680000000000000000000000000000000000000000000000000000602082015250565b6000610ff7602683610b23565b915061100282610f9b565b604082019050919050565b6000602082019050818103600083015261102681610fea565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b61106581610bf4565b82525050565b6000606082019050611080600083018661105c565b61108d6020830185610cde565b61109a6040830184610cde565b949350505050565b60006020820190506110b7600083018461105c565b92915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60006110f782610c32565b915061110283610c32565b925082820190508082111561111a576111196110bd565b5b9291505056fea2646970667358221220fdbfd2ff5d7f60018cd1ba9f99f9038e758419b539d4a76b8c9148f3b4c10b6b64736f6c634300081a0033"
|
|
28135
28136
|
};
|
|
28136
28137
|
|
|
28138
|
+
// src/utils/Abi/json/Abi.ERC20BatchTransfer.json
|
|
28139
|
+
var Abi_ERC20BatchTransfer_default = {
|
|
28140
|
+
_format: "hh-sol-artifact-1",
|
|
28141
|
+
contractName: "ERC20BatchTransfer",
|
|
28142
|
+
sourceName: "config/solidity/ERC20BatchTransfer.sol",
|
|
28143
|
+
abi: [
|
|
28144
|
+
{
|
|
28145
|
+
inputs: [],
|
|
28146
|
+
name: "LengthMismatch",
|
|
28147
|
+
type: "error"
|
|
28148
|
+
},
|
|
28149
|
+
{
|
|
28150
|
+
inputs: [
|
|
28151
|
+
{
|
|
28152
|
+
internalType: "contract IERC20",
|
|
28153
|
+
name: "token",
|
|
28154
|
+
type: "address"
|
|
28155
|
+
},
|
|
28156
|
+
{
|
|
28157
|
+
internalType: "address[]",
|
|
28158
|
+
name: "to",
|
|
28159
|
+
type: "address[]"
|
|
28160
|
+
},
|
|
28161
|
+
{
|
|
28162
|
+
internalType: "uint256[]",
|
|
28163
|
+
name: "amount",
|
|
28164
|
+
type: "uint256[]"
|
|
28165
|
+
}
|
|
28166
|
+
],
|
|
28167
|
+
name: "batchTransferFrom",
|
|
28168
|
+
outputs: [],
|
|
28169
|
+
stateMutability: "nonpayable",
|
|
28170
|
+
type: "function"
|
|
28171
|
+
},
|
|
28172
|
+
{
|
|
28173
|
+
inputs: [
|
|
28174
|
+
{
|
|
28175
|
+
internalType: "contract IERC20[]",
|
|
28176
|
+
name: "tokens",
|
|
28177
|
+
type: "address[]"
|
|
28178
|
+
},
|
|
28179
|
+
{
|
|
28180
|
+
internalType: "address[]",
|
|
28181
|
+
name: "to",
|
|
28182
|
+
type: "address[]"
|
|
28183
|
+
},
|
|
28184
|
+
{
|
|
28185
|
+
internalType: "uint256[]",
|
|
28186
|
+
name: "amount",
|
|
28187
|
+
type: "uint256[]"
|
|
28188
|
+
}
|
|
28189
|
+
],
|
|
28190
|
+
name: "multiBatchTransferFrom",
|
|
28191
|
+
outputs: [],
|
|
28192
|
+
stateMutability: "nonpayable",
|
|
28193
|
+
type: "function"
|
|
28194
|
+
}
|
|
28195
|
+
],
|
|
28196
|
+
bytecode: "0x6080604052348015600e575f5ffd5b5061083e8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c80634885b25414610038578063f053e99f14610054575b5f5ffd5b610052600480360381019061004d9190610491565b610070565b005b61006e60048036038101906100699190610577565b6101cd565b005b8181905084849050146100af576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b848490508110156101c5578573ffffffffffffffffffffffffffffffffffffffff166323b872dd338787858181106100ec576100eb610627565b5b9050602002016020810190610101919061067e565b86868681811061011457610113610627565b5b905060200201356040518463ffffffff1660e01b8152600401610139939291906106d0565b6020604051808303815f875af1158015610155573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610179919061073a565b6101b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101af906107bf565b60405180910390fd5b80806001019150506100b1565b505050505050565b85859050848490501415806101e85750858590508282905014155b1561021f576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5f90505b8686905081101561035f5786868281811061024257610241610627565b5b905060200201602081019061025791906107dd565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd3387878581811061028657610285610627565b5b905060200201602081019061029b919061067e565b8686868181106102ae576102ad610627565b5b905060200201356040518463ffffffff1660e01b81526004016102d3939291906106d0565b6020604051808303815f875af11580156102ef573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610313919061073a565b610352576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610349906107bf565b60405180910390fd5b8080600101915050610224565b50505050505050565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61039982610370565b9050919050565b5f6103aa8261038f565b9050919050565b6103ba816103a0565b81146103c4575f5ffd5b50565b5f813590506103d5816103b1565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126103fc576103fb6103db565b5b8235905067ffffffffffffffff811115610419576104186103df565b5b602083019150836020820283011115610435576104346103e3565b5b9250929050565b5f5f83601f840112610451576104506103db565b5b8235905067ffffffffffffffff81111561046e5761046d6103df565b5b60208301915083602082028301111561048a576104896103e3565b5b9250929050565b5f5f5f5f5f606086880312156104aa576104a9610368565b5b5f6104b7888289016103c7565b955050602086013567ffffffffffffffff8111156104d8576104d761036c565b5b6104e4888289016103e7565b9450945050604086013567ffffffffffffffff8111156105075761050661036c565b5b6105138882890161043c565b92509250509295509295909350565b5f5f83601f840112610537576105366103db565b5b8235905067ffffffffffffffff811115610554576105536103df565b5b6020830191508360208202830111156105705761056f6103e3565b5b9250929050565b5f5f5f5f5f5f6060878903121561059157610590610368565b5b5f87013567ffffffffffffffff8111156105ae576105ad61036c565b5b6105ba89828a01610522565b9650965050602087013567ffffffffffffffff8111156105dd576105dc61036c565b5b6105e989828a016103e7565b9450945050604087013567ffffffffffffffff81111561060c5761060b61036c565b5b61061889828a0161043c565b92509250509295509295509295565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b61065d8161038f565b8114610667575f5ffd5b50565b5f8135905061067881610654565b92915050565b5f6020828403121561069357610692610368565b5b5f6106a08482850161066a565b91505092915050565b6106b28161038f565b82525050565b5f819050919050565b6106ca816106b8565b82525050565b5f6060820190506106e35f8301866106a9565b6106f060208301856106a9565b6106fd60408301846106c1565b949350505050565b5f8115159050919050565b61071981610705565b8114610723575f5ffd5b50565b5f8151905061073481610710565b92915050565b5f6020828403121561074f5761074e610368565b5b5f61075c84828501610726565b91505092915050565b5f82825260208201905092915050565b7f5452414e534645525f46524f4d5f4641494c45440000000000000000000000005f82015250565b5f6107a9601483610765565b91506107b482610775565b602082019050919050565b5f6020820190508181035f8301526107d68161079d565b9050919050565b5f602082840312156107f2576107f1610368565b5b5f6107ff848285016103c7565b9150509291505056fea264697066735822122072bc5bd8cacc8452edacb73e0f0321cdfbba275969c6c2476826da50766804ee64736f6c634300081e0033"
|
|
28197
|
+
};
|
|
28198
|
+
|
|
28137
28199
|
// src/utils/AbiBase.ts
|
|
28138
28200
|
var AbiBase = class {
|
|
28139
28201
|
constructor(type = "consensus" /* CONSENSUS */, customAbi) {
|
|
@@ -28150,6 +28212,8 @@ var AbiBase = class {
|
|
|
28150
28212
|
return Abi_Usernames_default;
|
|
28151
28213
|
case "token" /* TOKEN */:
|
|
28152
28214
|
return Abi_Token_default;
|
|
28215
|
+
case "erc20batchtransfer" /* ERC20BATCH_TRANSFER */:
|
|
28216
|
+
return Abi_ERC20BatchTransfer_default;
|
|
28153
28217
|
}
|
|
28154
28218
|
if (customAbi) {
|
|
28155
28219
|
return customAbi;
|
|
@@ -28336,6 +28400,82 @@ var TransactionDataEncoder = class {
|
|
|
28336
28400
|
}
|
|
28337
28401
|
};
|
|
28338
28402
|
|
|
28403
|
+
// src/utils/TransactionTypeIdentifier.ts
|
|
28404
|
+
var TransactionFunctionSigs = {
|
|
28405
|
+
MultiPayment: Abi_Multipayment_default.methodIdentifiers["pay(address[],uint256[])"],
|
|
28406
|
+
RegisterUsername: Abi_Usernames_default.methodIdentifiers["registerUsername(string)"],
|
|
28407
|
+
ResignUsername: Abi_Usernames_default.methodIdentifiers["resignUsername()"],
|
|
28408
|
+
Transfer: "",
|
|
28409
|
+
RegisterValidator: Abi_Consensus_default.methodIdentifiers["registerValidator(bytes)"],
|
|
28410
|
+
ResignValidator: Abi_Consensus_default.methodIdentifiers["resignValidator()"],
|
|
28411
|
+
Vote: Abi_Consensus_default.methodIdentifiers["vote(address)"],
|
|
28412
|
+
Unvote: Abi_Consensus_default.methodIdentifiers["unvote()"],
|
|
28413
|
+
UpdateValidator: Abi_Consensus_default.methodIdentifiers["updateValidator(bytes)"]
|
|
28414
|
+
};
|
|
28415
|
+
var TransactionTypeIdentifier = class _TransactionTypeIdentifier {
|
|
28416
|
+
static isTransfer(data) {
|
|
28417
|
+
return data === TransactionFunctionSigs.Transfer;
|
|
28418
|
+
}
|
|
28419
|
+
static isVote(data) {
|
|
28420
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.Vote);
|
|
28421
|
+
}
|
|
28422
|
+
static isUnvote(data) {
|
|
28423
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.Unvote);
|
|
28424
|
+
}
|
|
28425
|
+
static isMultiPayment(data) {
|
|
28426
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.MultiPayment);
|
|
28427
|
+
}
|
|
28428
|
+
static isUsernameRegistration(data) {
|
|
28429
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.RegisterUsername);
|
|
28430
|
+
}
|
|
28431
|
+
static isUsernameResignation(data) {
|
|
28432
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.ResignUsername);
|
|
28433
|
+
}
|
|
28434
|
+
static isValidatorRegistration(data) {
|
|
28435
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.RegisterValidator);
|
|
28436
|
+
}
|
|
28437
|
+
static isValidatorResignation(data) {
|
|
28438
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.ResignValidator);
|
|
28439
|
+
}
|
|
28440
|
+
static isUpdateValidator(data) {
|
|
28441
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.UpdateValidator);
|
|
28442
|
+
}
|
|
28443
|
+
static isTokenTransfer(data) {
|
|
28444
|
+
const decodedData = _TransactionTypeIdentifier.#decodeTokenFunction(data);
|
|
28445
|
+
return decodedData ? decodedData.functionName === "transfer" : false;
|
|
28446
|
+
}
|
|
28447
|
+
static isApprove(data) {
|
|
28448
|
+
const decodedData = _TransactionTypeIdentifier.#decodeTokenFunction(data);
|
|
28449
|
+
if (decodedData?.functionName === "approve") {
|
|
28450
|
+
return new bignumber_default(decodedData.args[1]).isGreaterThan(0);
|
|
28451
|
+
}
|
|
28452
|
+
return false;
|
|
28453
|
+
}
|
|
28454
|
+
static isRevoke(data) {
|
|
28455
|
+
const decodedData = _TransactionTypeIdentifier.#decodeTokenFunction(data);
|
|
28456
|
+
if (decodedData?.functionName === "approve") {
|
|
28457
|
+
return new bignumber_default(decodedData.args[1]).isZero();
|
|
28458
|
+
}
|
|
28459
|
+
return false;
|
|
28460
|
+
}
|
|
28461
|
+
static isBatchTransfer(data) {
|
|
28462
|
+
try {
|
|
28463
|
+
const decodedData = new AbiDecoder("erc20batchtransfer" /* ERC20BATCH_TRANSFER */).decodeFunctionData(data);
|
|
28464
|
+
return decodedData.functionName === "batchTransferFrom";
|
|
28465
|
+
} catch {
|
|
28466
|
+
}
|
|
28467
|
+
return false;
|
|
28468
|
+
}
|
|
28469
|
+
static #decodeTokenFunction(data) {
|
|
28470
|
+
try {
|
|
28471
|
+
const decodedData = new AbiDecoder("token" /* TOKEN */).decodeFunctionData(data);
|
|
28472
|
+
return { functionName: decodedData.functionName, args: decodedData.args };
|
|
28473
|
+
} catch {
|
|
28474
|
+
}
|
|
28475
|
+
return null;
|
|
28476
|
+
}
|
|
28477
|
+
};
|
|
28478
|
+
|
|
28339
28479
|
// src/transactions/builders/TokenTransferBuilder.ts
|
|
28340
28480
|
var TokenTransferBuilder = class extends AbstractTransactionBuilder {
|
|
28341
28481
|
constructor(data) {
|
|
@@ -28744,6 +28884,7 @@ export {
|
|
|
28744
28884
|
ContractAbiType,
|
|
28745
28885
|
ContractAddresses,
|
|
28746
28886
|
Deserializer,
|
|
28887
|
+
Abi_ERC20BatchTransfer_default as ERC20BatchTransferContract,
|
|
28747
28888
|
EvmCall,
|
|
28748
28889
|
EvmCallBuilder,
|
|
28749
28890
|
Helpers,
|
|
@@ -28762,6 +28903,8 @@ export {
|
|
|
28762
28903
|
Abi_Token_default as TokenContract,
|
|
28763
28904
|
TokenTransferBuilder,
|
|
28764
28905
|
TransactionDataEncoder,
|
|
28906
|
+
TransactionFunctionSigs,
|
|
28907
|
+
TransactionTypeIdentifier,
|
|
28765
28908
|
TransactionUtils,
|
|
28766
28909
|
Transfer,
|
|
28767
28910
|
TransferBuilder,
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "ERC20BatchTransfer",
|
|
4
|
+
"sourceName": "config/solidity/ERC20BatchTransfer.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [],
|
|
8
|
+
"name": "LengthMismatch",
|
|
9
|
+
"type": "error"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"inputs": [
|
|
13
|
+
{
|
|
14
|
+
"internalType": "contract IERC20",
|
|
15
|
+
"name": "token",
|
|
16
|
+
"type": "address"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"internalType": "address[]",
|
|
20
|
+
"name": "to",
|
|
21
|
+
"type": "address[]"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"internalType": "uint256[]",
|
|
25
|
+
"name": "amount",
|
|
26
|
+
"type": "uint256[]"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"name": "batchTransferFrom",
|
|
30
|
+
"outputs": [],
|
|
31
|
+
"stateMutability": "nonpayable",
|
|
32
|
+
"type": "function"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"inputs": [
|
|
36
|
+
{
|
|
37
|
+
"internalType": "contract IERC20[]",
|
|
38
|
+
"name": "tokens",
|
|
39
|
+
"type": "address[]"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"internalType": "address[]",
|
|
43
|
+
"name": "to",
|
|
44
|
+
"type": "address[]"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"internalType": "uint256[]",
|
|
48
|
+
"name": "amount",
|
|
49
|
+
"type": "uint256[]"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"name": "multiBatchTransferFrom",
|
|
53
|
+
"outputs": [],
|
|
54
|
+
"stateMutability": "nonpayable",
|
|
55
|
+
"type": "function"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"bytecode": "0x6080604052348015600e575f5ffd5b5061083e8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c80634885b25414610038578063f053e99f14610054575b5f5ffd5b610052600480360381019061004d9190610491565b610070565b005b61006e60048036038101906100699190610577565b6101cd565b005b8181905084849050146100af576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b848490508110156101c5578573ffffffffffffffffffffffffffffffffffffffff166323b872dd338787858181106100ec576100eb610627565b5b9050602002016020810190610101919061067e565b86868681811061011457610113610627565b5b905060200201356040518463ffffffff1660e01b8152600401610139939291906106d0565b6020604051808303815f875af1158015610155573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610179919061073a565b6101b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101af906107bf565b60405180910390fd5b80806001019150506100b1565b505050505050565b85859050848490501415806101e85750858590508282905014155b1561021f576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5f90505b8686905081101561035f5786868281811061024257610241610627565b5b905060200201602081019061025791906107dd565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd3387878581811061028657610285610627565b5b905060200201602081019061029b919061067e565b8686868181106102ae576102ad610627565b5b905060200201356040518463ffffffff1660e01b81526004016102d3939291906106d0565b6020604051808303815f875af11580156102ef573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610313919061073a565b610352576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610349906107bf565b60405180910390fd5b8080600101915050610224565b50505050505050565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61039982610370565b9050919050565b5f6103aa8261038f565b9050919050565b6103ba816103a0565b81146103c4575f5ffd5b50565b5f813590506103d5816103b1565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126103fc576103fb6103db565b5b8235905067ffffffffffffffff811115610419576104186103df565b5b602083019150836020820283011115610435576104346103e3565b5b9250929050565b5f5f83601f840112610451576104506103db565b5b8235905067ffffffffffffffff81111561046e5761046d6103df565b5b60208301915083602082028301111561048a576104896103e3565b5b9250929050565b5f5f5f5f5f606086880312156104aa576104a9610368565b5b5f6104b7888289016103c7565b955050602086013567ffffffffffffffff8111156104d8576104d761036c565b5b6104e4888289016103e7565b9450945050604086013567ffffffffffffffff8111156105075761050661036c565b5b6105138882890161043c565b92509250509295509295909350565b5f5f83601f840112610537576105366103db565b5b8235905067ffffffffffffffff811115610554576105536103df565b5b6020830191508360208202830111156105705761056f6103e3565b5b9250929050565b5f5f5f5f5f5f6060878903121561059157610590610368565b5b5f87013567ffffffffffffffff8111156105ae576105ad61036c565b5b6105ba89828a01610522565b9650965050602087013567ffffffffffffffff8111156105dd576105dc61036c565b5b6105e989828a016103e7565b9450945050604087013567ffffffffffffffff81111561060c5761060b61036c565b5b61061889828a0161043c565b92509250509295509295509295565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b61065d8161038f565b8114610667575f5ffd5b50565b5f8135905061067881610654565b92915050565b5f6020828403121561069357610692610368565b5b5f6106a08482850161066a565b91505092915050565b6106b28161038f565b82525050565b5f819050919050565b6106ca816106b8565b82525050565b5f6060820190506106e35f8301866106a9565b6106f060208301856106a9565b6106fd60408301846106c1565b949350505050565b5f8115159050919050565b61071981610705565b8114610723575f5ffd5b50565b5f8151905061073481610710565b92915050565b5f6020828403121561074f5761074e610368565b5b5f61075c84828501610726565b91505092915050565b5f82825260208201905092915050565b7f5452414e534645525f46524f4d5f4641494c45440000000000000000000000005f82015250565b5f6107a9601483610765565b91506107b482610775565b602082019050919050565b5f6020820190508181035f8301526107d68161079d565b9050919050565b5f602082840312156107f2576107f1610368565b5b5f6107ff848285016103c7565b9150509291505056fea264697066735822122072bc5bd8cacc8452edacb73e0f0321cdfbba275969c6c2476826da50766804ee64736f6c634300081e0033"
|
|
59
|
+
}
|
|
@@ -2,4 +2,5 @@ export { default as ConsensusContract } from "./Abi.Consensus.json";
|
|
|
2
2
|
export { default as MultipaymentContract } from "./Abi.Multipayment.json";
|
|
3
3
|
export { default as UsernamesContract } from "./Abi.Usernames.json";
|
|
4
4
|
export { default as TokenContract } from "./Abi.Token.json";
|
|
5
|
+
export { default as ERC20BatchTransferContract } from "./Abi.ERC20BatchTransfer.json";
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/Abi/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/utils/Abi/json/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAC1E,OAAO,EAAE,OAAO,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACpE,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,0BAA0B,EAAE,MAAM,+BAA+B,CAAC"}
|
|
@@ -2,3 +2,4 @@ export { default as ConsensusContract } from "./Abi.Consensus.json";
|
|
|
2
2
|
export { default as MultipaymentContract } from "./Abi.Multipayment.json";
|
|
3
3
|
export { default as UsernamesContract } from "./Abi.Usernames.json";
|
|
4
4
|
export { default as TokenContract } from "./Abi.Token.json";
|
|
5
|
+
export { default as ERC20BatchTransferContract } from "./Abi.ERC20BatchTransfer.json";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AbiBase.d.ts","sourceRoot":"","sources":["../../src/utils/AbiBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;
|
|
1
|
+
{"version":3,"file":"AbiBase.d.ts","sourceRoot":"","sources":["../../src/utils/AbiBase.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC1D,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AASnC,8BAAsB,OAAO;IAC5B,SAAS,CAAC,SAAS,EAAE,SAAS,CAAC;gBAEnB,IAAI,GAAE,eAA2C,EAAE,SAAS,CAAC,EAAE,MAAM;IAMjF,OAAO,CAAC,WAAW;CAoBnB"}
|
package/dist/utils/AbiBase.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContractAbiType } from "@/enums/ContractAbiType";
|
|
2
2
|
import { Interface } from "ethers";
|
|
3
|
-
import { ConsensusContract, TokenContract, MultipaymentContract, UsernamesContract } from "@/utils/Abi/json";
|
|
3
|
+
import { ConsensusContract, TokenContract, MultipaymentContract, UsernamesContract, ERC20BatchTransferContract, } from "@/utils/Abi/json";
|
|
4
4
|
export class AbiBase {
|
|
5
5
|
constructor(type = ContractAbiType.CONSENSUS, customAbi) {
|
|
6
6
|
const abi = this.contractAbi(type, customAbi);
|
|
@@ -16,6 +16,8 @@ export class AbiBase {
|
|
|
16
16
|
return UsernamesContract;
|
|
17
17
|
case ContractAbiType.TOKEN:
|
|
18
18
|
return TokenContract;
|
|
19
|
+
case ContractAbiType.ERC20BATCH_TRANSFER:
|
|
20
|
+
return ERC20BatchTransferContract;
|
|
19
21
|
}
|
|
20
22
|
if (customAbi) {
|
|
21
23
|
return customAbi;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export declare const TransactionFunctionSigs: {
|
|
2
|
+
MultiPayment: string;
|
|
3
|
+
RegisterUsername: string;
|
|
4
|
+
ResignUsername: string;
|
|
5
|
+
Transfer: string;
|
|
6
|
+
RegisterValidator: string;
|
|
7
|
+
ResignValidator: string;
|
|
8
|
+
Vote: string;
|
|
9
|
+
Unvote: string;
|
|
10
|
+
UpdateValidator: string;
|
|
11
|
+
};
|
|
12
|
+
export declare class TransactionTypeIdentifier {
|
|
13
|
+
#private;
|
|
14
|
+
static isTransfer(data: string): boolean;
|
|
15
|
+
static isVote(data: string): boolean;
|
|
16
|
+
static isUnvote(data: string): boolean;
|
|
17
|
+
static isMultiPayment(data: string): boolean;
|
|
18
|
+
static isUsernameRegistration(data: string): boolean;
|
|
19
|
+
static isUsernameResignation(data: string): boolean;
|
|
20
|
+
static isValidatorRegistration(data: string): boolean;
|
|
21
|
+
static isValidatorResignation(data: string): boolean;
|
|
22
|
+
static isUpdateValidator(data: string): boolean;
|
|
23
|
+
static isTokenTransfer(data: string): boolean;
|
|
24
|
+
static isApprove(data: string): boolean;
|
|
25
|
+
static isRevoke(data: string): boolean;
|
|
26
|
+
static isBatchTransfer(data: string): boolean;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=TransactionTypeIdentifier.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TransactionTypeIdentifier.d.ts","sourceRoot":"","sources":["../../src/utils/TransactionTypeIdentifier.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,uBAAuB;;;;;;;;;;CAUnC,CAAC;AAEF,qBAAa,yBAAyB;;WACvB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIjC,MAAM,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI/B,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIrC,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI7C,qBAAqB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI5C,uBAAuB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI9C,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAI7C,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAIxC,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAKtC,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAShC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;WAS/B,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;CAqBpD"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
2
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
3
|
+
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");
|
|
4
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
5
|
+
};
|
|
6
|
+
var _a, _TransactionTypeIdentifier_decodeTokenFunction;
|
|
7
|
+
import { ContractAbiType } from "@/enums";
|
|
8
|
+
import { AbiDecoder } from "./AbiDecoder";
|
|
9
|
+
import { ConsensusContract, MultipaymentContract, UsernamesContract } from "./Abi/json";
|
|
10
|
+
import { Helpers } from "./Helpers";
|
|
11
|
+
import BigNumber from "bignumber.js";
|
|
12
|
+
export const TransactionFunctionSigs = {
|
|
13
|
+
MultiPayment: MultipaymentContract.methodIdentifiers["pay(address[],uint256[])"],
|
|
14
|
+
RegisterUsername: UsernamesContract.methodIdentifiers["registerUsername(string)"],
|
|
15
|
+
ResignUsername: UsernamesContract.methodIdentifiers["resignUsername()"],
|
|
16
|
+
Transfer: "",
|
|
17
|
+
RegisterValidator: ConsensusContract.methodIdentifiers["registerValidator(bytes)"],
|
|
18
|
+
ResignValidator: ConsensusContract.methodIdentifiers["resignValidator()"],
|
|
19
|
+
Vote: ConsensusContract.methodIdentifiers["vote(address)"],
|
|
20
|
+
Unvote: ConsensusContract.methodIdentifiers["unvote()"],
|
|
21
|
+
UpdateValidator: ConsensusContract.methodIdentifiers["updateValidator(bytes)"],
|
|
22
|
+
};
|
|
23
|
+
export class TransactionTypeIdentifier {
|
|
24
|
+
static isTransfer(data) {
|
|
25
|
+
return data === TransactionFunctionSigs.Transfer;
|
|
26
|
+
}
|
|
27
|
+
static isVote(data) {
|
|
28
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.Vote);
|
|
29
|
+
}
|
|
30
|
+
static isUnvote(data) {
|
|
31
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.Unvote);
|
|
32
|
+
}
|
|
33
|
+
static isMultiPayment(data) {
|
|
34
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.MultiPayment);
|
|
35
|
+
}
|
|
36
|
+
static isUsernameRegistration(data) {
|
|
37
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.RegisterUsername);
|
|
38
|
+
}
|
|
39
|
+
static isUsernameResignation(data) {
|
|
40
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.ResignUsername);
|
|
41
|
+
}
|
|
42
|
+
static isValidatorRegistration(data) {
|
|
43
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.RegisterValidator);
|
|
44
|
+
}
|
|
45
|
+
static isValidatorResignation(data) {
|
|
46
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.ResignValidator);
|
|
47
|
+
}
|
|
48
|
+
static isUpdateValidator(data) {
|
|
49
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.UpdateValidator);
|
|
50
|
+
}
|
|
51
|
+
static isTokenTransfer(data) {
|
|
52
|
+
const decodedData = __classPrivateFieldGet(_a, _a, "m", _TransactionTypeIdentifier_decodeTokenFunction).call(_a, data);
|
|
53
|
+
return decodedData ? decodedData.functionName === "transfer" : false;
|
|
54
|
+
}
|
|
55
|
+
static isApprove(data) {
|
|
56
|
+
const decodedData = __classPrivateFieldGet(_a, _a, "m", _TransactionTypeIdentifier_decodeTokenFunction).call(_a, data);
|
|
57
|
+
if ((decodedData === null || decodedData === void 0 ? void 0 : decodedData.functionName) === "approve") {
|
|
58
|
+
return new BigNumber(decodedData.args[1]).isGreaterThan(0);
|
|
59
|
+
}
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
static isRevoke(data) {
|
|
63
|
+
const decodedData = __classPrivateFieldGet(_a, _a, "m", _TransactionTypeIdentifier_decodeTokenFunction).call(_a, data);
|
|
64
|
+
if ((decodedData === null || decodedData === void 0 ? void 0 : decodedData.functionName) === "approve") {
|
|
65
|
+
return new BigNumber(decodedData.args[1]).isZero();
|
|
66
|
+
}
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
static isBatchTransfer(data) {
|
|
70
|
+
try {
|
|
71
|
+
const decodedData = new AbiDecoder(ContractAbiType.ERC20BATCH_TRANSFER).decodeFunctionData(data);
|
|
72
|
+
return decodedData.functionName === "batchTransferFrom";
|
|
73
|
+
}
|
|
74
|
+
catch (_b) {
|
|
75
|
+
// Different abi type. Ignore.
|
|
76
|
+
}
|
|
77
|
+
return false;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
_a = TransactionTypeIdentifier, _TransactionTypeIdentifier_decodeTokenFunction = function _TransactionTypeIdentifier_decodeTokenFunction(data) {
|
|
81
|
+
try {
|
|
82
|
+
const decodedData = new AbiDecoder(ContractAbiType.TOKEN).decodeFunctionData(data);
|
|
83
|
+
return { functionName: decodedData.functionName, args: decodedData.args };
|
|
84
|
+
}
|
|
85
|
+
catch (_b) {
|
|
86
|
+
// Different abi type. Ignore.
|
|
87
|
+
}
|
|
88
|
+
return null;
|
|
89
|
+
};
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,WAAW,CAAC;AAC1B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,oBAAoB,CAAC;AACnC,cAAc,iBAAiB,CAAC;AAChC,cAAc,0BAA0B,CAAC;AACzC,cAAc,6BAA6B,CAAC"}
|
package/dist/utils/index.js
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"_format": "hh-sol-artifact-1",
|
|
3
|
+
"contractName": "ERC20BatchTransfer",
|
|
4
|
+
"sourceName": "config/solidity/ERC20BatchTransfer.sol",
|
|
5
|
+
"abi": [
|
|
6
|
+
{
|
|
7
|
+
"inputs": [],
|
|
8
|
+
"name": "LengthMismatch",
|
|
9
|
+
"type": "error"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"inputs": [
|
|
13
|
+
{
|
|
14
|
+
"internalType": "contract IERC20",
|
|
15
|
+
"name": "token",
|
|
16
|
+
"type": "address"
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
"internalType": "address[]",
|
|
20
|
+
"name": "to",
|
|
21
|
+
"type": "address[]"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"internalType": "uint256[]",
|
|
25
|
+
"name": "amount",
|
|
26
|
+
"type": "uint256[]"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"name": "batchTransferFrom",
|
|
30
|
+
"outputs": [],
|
|
31
|
+
"stateMutability": "nonpayable",
|
|
32
|
+
"type": "function"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"inputs": [
|
|
36
|
+
{
|
|
37
|
+
"internalType": "contract IERC20[]",
|
|
38
|
+
"name": "tokens",
|
|
39
|
+
"type": "address[]"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"internalType": "address[]",
|
|
43
|
+
"name": "to",
|
|
44
|
+
"type": "address[]"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
"internalType": "uint256[]",
|
|
48
|
+
"name": "amount",
|
|
49
|
+
"type": "uint256[]"
|
|
50
|
+
}
|
|
51
|
+
],
|
|
52
|
+
"name": "multiBatchTransferFrom",
|
|
53
|
+
"outputs": [],
|
|
54
|
+
"stateMutability": "nonpayable",
|
|
55
|
+
"type": "function"
|
|
56
|
+
}
|
|
57
|
+
],
|
|
58
|
+
"bytecode": "0x6080604052348015600e575f5ffd5b5061083e8061001c5f395ff3fe608060405234801561000f575f5ffd5b5060043610610034575f3560e01c80634885b25414610038578063f053e99f14610054575b5f5ffd5b610052600480360381019061004d9190610491565b610070565b005b61006e60048036038101906100699190610577565b6101cd565b005b8181905084849050146100af576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5b848490508110156101c5578573ffffffffffffffffffffffffffffffffffffffff166323b872dd338787858181106100ec576100eb610627565b5b9050602002016020810190610101919061067e565b86868681811061011457610113610627565b5b905060200201356040518463ffffffff1660e01b8152600401610139939291906106d0565b6020604051808303815f875af1158015610155573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610179919061073a565b6101b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016101af906107bf565b60405180910390fd5b80806001019150506100b1565b505050505050565b85859050848490501415806101e85750858590508282905014155b1561021f576040517fff633a3800000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b5f5f90505b8686905081101561035f5786868281811061024257610241610627565b5b905060200201602081019061025791906107dd565b73ffffffffffffffffffffffffffffffffffffffff166323b872dd3387878581811061028657610285610627565b5b905060200201602081019061029b919061067e565b8686868181106102ae576102ad610627565b5b905060200201356040518463ffffffff1660e01b81526004016102d3939291906106d0565b6020604051808303815f875af11580156102ef573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610313919061073a565b610352576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610349906107bf565b60405180910390fd5b8080600101915050610224565b50505050505050565b5f5ffd5b5f5ffd5b5f73ffffffffffffffffffffffffffffffffffffffff82169050919050565b5f61039982610370565b9050919050565b5f6103aa8261038f565b9050919050565b6103ba816103a0565b81146103c4575f5ffd5b50565b5f813590506103d5816103b1565b92915050565b5f5ffd5b5f5ffd5b5f5ffd5b5f5f83601f8401126103fc576103fb6103db565b5b8235905067ffffffffffffffff811115610419576104186103df565b5b602083019150836020820283011115610435576104346103e3565b5b9250929050565b5f5f83601f840112610451576104506103db565b5b8235905067ffffffffffffffff81111561046e5761046d6103df565b5b60208301915083602082028301111561048a576104896103e3565b5b9250929050565b5f5f5f5f5f606086880312156104aa576104a9610368565b5b5f6104b7888289016103c7565b955050602086013567ffffffffffffffff8111156104d8576104d761036c565b5b6104e4888289016103e7565b9450945050604086013567ffffffffffffffff8111156105075761050661036c565b5b6105138882890161043c565b92509250509295509295909350565b5f5f83601f840112610537576105366103db565b5b8235905067ffffffffffffffff811115610554576105536103df565b5b6020830191508360208202830111156105705761056f6103e3565b5b9250929050565b5f5f5f5f5f5f6060878903121561059157610590610368565b5b5f87013567ffffffffffffffff8111156105ae576105ad61036c565b5b6105ba89828a01610522565b9650965050602087013567ffffffffffffffff8111156105dd576105dc61036c565b5b6105e989828a016103e7565b9450945050604087013567ffffffffffffffff81111561060c5761060b61036c565b5b61061889828a0161043c565b92509250509295509295509295565b7f4e487b71000000000000000000000000000000000000000000000000000000005f52603260045260245ffd5b61065d8161038f565b8114610667575f5ffd5b50565b5f8135905061067881610654565b92915050565b5f6020828403121561069357610692610368565b5b5f6106a08482850161066a565b91505092915050565b6106b28161038f565b82525050565b5f819050919050565b6106ca816106b8565b82525050565b5f6060820190506106e35f8301866106a9565b6106f060208301856106a9565b6106fd60408301846106c1565b949350505050565b5f8115159050919050565b61071981610705565b8114610723575f5ffd5b50565b5f8151905061073481610710565b92915050565b5f6020828403121561074f5761074e610368565b5b5f61075c84828501610726565b91505092915050565b5f82825260208201905092915050565b7f5452414e534645525f46524f4d5f4641494c45440000000000000000000000005f82015250565b5f6107a9601483610765565b91506107b482610775565b602082019050919050565b5f6020820190508181035f8301526107d68161079d565b9050919050565b5f602082840312156107f2576107f1610368565b5b5f6107ff848285016103c7565b9150509291505056fea264697066735822122072bc5bd8cacc8452edacb73e0f0321cdfbba275969c6c2476826da50766804ee64736f6c634300081e0033"
|
|
59
|
+
}
|
|
@@ -2,3 +2,4 @@ export { default as ConsensusContract } from "./Abi.Consensus.json";
|
|
|
2
2
|
export { default as MultipaymentContract } from "./Abi.Multipayment.json";
|
|
3
3
|
export { default as UsernamesContract } from "./Abi.Usernames.json";
|
|
4
4
|
export { default as TokenContract } from "./Abi.Token.json";
|
|
5
|
+
export { default as ERC20BatchTransferContract } from "./Abi.ERC20BatchTransfer.json";
|
package/src/utils/AbiBase.ts
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
import { ContractAbiType } from "@/enums/ContractAbiType";
|
|
2
2
|
import { Interface } from "ethers";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ConsensusContract,
|
|
5
|
+
TokenContract,
|
|
6
|
+
MultipaymentContract,
|
|
7
|
+
UsernamesContract,
|
|
8
|
+
ERC20BatchTransferContract,
|
|
9
|
+
} from "@/utils/Abi/json";
|
|
4
10
|
|
|
5
11
|
export abstract class AbiBase {
|
|
6
12
|
protected interface: Interface;
|
|
@@ -21,6 +27,8 @@ export abstract class AbiBase {
|
|
|
21
27
|
return UsernamesContract;
|
|
22
28
|
case ContractAbiType.TOKEN:
|
|
23
29
|
return TokenContract;
|
|
30
|
+
case ContractAbiType.ERC20BATCH_TRANSFER:
|
|
31
|
+
return ERC20BatchTransferContract;
|
|
24
32
|
}
|
|
25
33
|
|
|
26
34
|
if (customAbi) {
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
import { ContractAbiType } from "@/enums";
|
|
2
|
+
import { AbiDecoder } from "./AbiDecoder";
|
|
3
|
+
import { ConsensusContract, MultipaymentContract, UsernamesContract } from "./Abi/json";
|
|
4
|
+
import { Helpers } from "./Helpers";
|
|
5
|
+
import BigNumber from "bignumber.js";
|
|
6
|
+
|
|
7
|
+
export const TransactionFunctionSigs = {
|
|
8
|
+
MultiPayment: MultipaymentContract.methodIdentifiers["pay(address[],uint256[])"],
|
|
9
|
+
RegisterUsername: UsernamesContract.methodIdentifiers["registerUsername(string)"],
|
|
10
|
+
ResignUsername: UsernamesContract.methodIdentifiers["resignUsername()"],
|
|
11
|
+
Transfer: "",
|
|
12
|
+
RegisterValidator: ConsensusContract.methodIdentifiers["registerValidator(bytes)"],
|
|
13
|
+
ResignValidator: ConsensusContract.methodIdentifiers["resignValidator()"],
|
|
14
|
+
Vote: ConsensusContract.methodIdentifiers["vote(address)"],
|
|
15
|
+
Unvote: ConsensusContract.methodIdentifiers["unvote()"],
|
|
16
|
+
UpdateValidator: ConsensusContract.methodIdentifiers["updateValidator(bytes)"],
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export class TransactionTypeIdentifier {
|
|
20
|
+
public static isTransfer(data: string): boolean {
|
|
21
|
+
return data === TransactionFunctionSigs.Transfer;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public static isVote(data: string): boolean {
|
|
25
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.Vote);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
public static isUnvote(data: string): boolean {
|
|
29
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.Unvote);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public static isMultiPayment(data: string): boolean {
|
|
33
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.MultiPayment);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public static isUsernameRegistration(data: string): boolean {
|
|
37
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.RegisterUsername);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public static isUsernameResignation(data: string): boolean {
|
|
41
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.ResignUsername);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
public static isValidatorRegistration(data: string): boolean {
|
|
45
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.RegisterValidator);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
public static isValidatorResignation(data: string): boolean {
|
|
49
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.ResignValidator);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
public static isUpdateValidator(data: string): boolean {
|
|
53
|
+
return Helpers.removeLeadingHexZero(data).startsWith(TransactionFunctionSigs.UpdateValidator);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
public static isTokenTransfer(data: string): boolean {
|
|
57
|
+
const decodedData = TransactionTypeIdentifier.#decodeTokenFunction(data);
|
|
58
|
+
return decodedData ? decodedData.functionName === "transfer" : false;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public static isApprove(data: string): boolean {
|
|
62
|
+
const decodedData = TransactionTypeIdentifier.#decodeTokenFunction(data);
|
|
63
|
+
if (decodedData?.functionName === "approve") {
|
|
64
|
+
return new BigNumber(decodedData.args[1]).isGreaterThan(0);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return false;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
public static isRevoke(data: string): boolean {
|
|
71
|
+
const decodedData = TransactionTypeIdentifier.#decodeTokenFunction(data);
|
|
72
|
+
if (decodedData?.functionName === "approve") {
|
|
73
|
+
return new BigNumber(decodedData.args[1]).isZero();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public static isBatchTransfer(data: string): boolean {
|
|
80
|
+
try {
|
|
81
|
+
const decodedData = new AbiDecoder(ContractAbiType.ERC20BATCH_TRANSFER).decodeFunctionData(data);
|
|
82
|
+
return decodedData.functionName === "batchTransferFrom";
|
|
83
|
+
} catch {
|
|
84
|
+
// Different abi type. Ignore.
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return false;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
static #decodeTokenFunction(data: string): { functionName: string; args: string[] } | null {
|
|
91
|
+
try {
|
|
92
|
+
const decodedData = new AbiDecoder(ContractAbiType.TOKEN).decodeFunctionData(data);
|
|
93
|
+
return { functionName: decodedData.functionName, args: decodedData.args };
|
|
94
|
+
} catch {
|
|
95
|
+
// Different abi type. Ignore.
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
}
|
package/src/utils/index.ts
CHANGED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
import { jest } from "@jest/globals";
|
|
2
|
+
import { TransactionTypeIdentifier } from "@/utils/TransactionTypeIdentifier";
|
|
3
|
+
import { ConsensusContract, MultipaymentContract, UsernamesContract } from "@/utils/Abi/json";
|
|
4
|
+
import { Helpers } from "@/utils/Helpers";
|
|
5
|
+
|
|
6
|
+
describe("TransactionTypeIdentifier", () => {
|
|
7
|
+
const TransactionFunctionSigs = {
|
|
8
|
+
MultiPayment: MultipaymentContract.methodIdentifiers["pay(address[],uint256[])"],
|
|
9
|
+
RegisterUsername: UsernamesContract.methodIdentifiers["registerUsername(string)"],
|
|
10
|
+
ResignUsername: UsernamesContract.methodIdentifiers["resignUsername()"],
|
|
11
|
+
RegisterValidator: ConsensusContract.methodIdentifiers["registerValidator(bytes)"],
|
|
12
|
+
ResignValidator: ConsensusContract.methodIdentifiers["resignValidator()"],
|
|
13
|
+
Vote: ConsensusContract.methodIdentifiers["vote(address)"],
|
|
14
|
+
Unvote: ConsensusContract.methodIdentifiers["unvote()"],
|
|
15
|
+
UpdateValidator: ConsensusContract.methodIdentifiers["updateValidator(bytes)"],
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const InvalidFunctionSignature = "0x1234567";
|
|
19
|
+
|
|
20
|
+
const APPROVE_BYTECODE =
|
|
21
|
+
"0x095ea7b30000000000000000000000007b3e4936c1d38f907055cfd70b1f1396e805bf77fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe";
|
|
22
|
+
const REVOKE_BYTECODE =
|
|
23
|
+
"0x095ea7b30000000000000000000000007b3e4936c1d38f907055cfd70b1f1396e805bf770000000000000000000000000000000000000000000000000000000000000000";
|
|
24
|
+
const BATCH_TRANSFER_BYTECODE =
|
|
25
|
+
"0x4885b2540000000000000000000000008444ab9d74212f28e14b089b62ed4a4a7a8fefb3000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000003000000000000000000000000a5cc0bfeb09742c5e4c610f2ebaab82eb142ca10000000000000000000000000e3c31e486cca6eb2093c0f4883df949d45b021c5000000000000000000000000a5cc0bfeb09742c5e4c610f2ebaab82eb142ca100000000000000000000000000000000000000000000000000000000000000003000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000003";
|
|
26
|
+
|
|
27
|
+
beforeAll(() => {
|
|
28
|
+
jest.mock("@/utils/AbiDecoder", () => {
|
|
29
|
+
return {
|
|
30
|
+
AbiDecoder: jest.fn().mockImplementation(() => ({
|
|
31
|
+
decodeFunctionData: jest.fn().mockReturnValue({ functionName: "transfer" }),
|
|
32
|
+
})),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
afterAll(() => {
|
|
38
|
+
jest.clearAllMocks();
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe("#isTransfer", () => {
|
|
42
|
+
it("should return true for empty transfer string", () => {
|
|
43
|
+
expect(TransactionTypeIdentifier.isTransfer("")).toBe(true);
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
it("should return false for non-empty data", () => {
|
|
47
|
+
expect(TransactionTypeIdentifier.isTransfer(InvalidFunctionSignature)).toBe(false);
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
describe("#isVote", () => {
|
|
52
|
+
it("should return true for matching vote signature", () => {
|
|
53
|
+
expect(TransactionTypeIdentifier.isVote(Helpers.addLeadingHexZero(TransactionFunctionSigs.Vote))).toBe(
|
|
54
|
+
true,
|
|
55
|
+
);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it("should return true for matching vote signature without 0x prefix", () => {
|
|
59
|
+
expect(TransactionTypeIdentifier.isVote(TransactionFunctionSigs.Vote)).toBe(true);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("should return false for non-matching signature", () => {
|
|
63
|
+
expect(TransactionTypeIdentifier.isVote(InvalidFunctionSignature)).toBe(false);
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
describe("#isUnvote", () => {
|
|
68
|
+
it("should return true for matching unvote signature", () => {
|
|
69
|
+
expect(TransactionTypeIdentifier.isUnvote(Helpers.addLeadingHexZero(TransactionFunctionSigs.Unvote))).toBe(
|
|
70
|
+
true,
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("should return true for matching unvote signature without 0x prefix", () => {
|
|
75
|
+
expect(TransactionTypeIdentifier.isUnvote(TransactionFunctionSigs.Unvote)).toBe(true);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("should return false for non-matching signature", () => {
|
|
79
|
+
expect(TransactionTypeIdentifier.isUnvote(InvalidFunctionSignature)).toBe(false);
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
describe("#isMultiPayment", () => {
|
|
84
|
+
it("should return true for matching multi-payment signature", () => {
|
|
85
|
+
expect(
|
|
86
|
+
TransactionTypeIdentifier.isMultiPayment(
|
|
87
|
+
Helpers.addLeadingHexZero(TransactionFunctionSigs.MultiPayment),
|
|
88
|
+
),
|
|
89
|
+
).toBe(true);
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
it("should return true for matching multi-payment signature without 0x prefix", () => {
|
|
93
|
+
expect(TransactionTypeIdentifier.isMultiPayment(TransactionFunctionSigs.MultiPayment)).toBe(true);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("should return false for non-matching signature", () => {
|
|
97
|
+
expect(TransactionTypeIdentifier.isMultiPayment(InvalidFunctionSignature)).toBe(false);
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe("#isUsernameRegistration", () => {
|
|
102
|
+
it("should return true for matching registration signature", () => {
|
|
103
|
+
expect(
|
|
104
|
+
TransactionTypeIdentifier.isUsernameRegistration(
|
|
105
|
+
Helpers.addLeadingHexZero(TransactionFunctionSigs.RegisterUsername),
|
|
106
|
+
),
|
|
107
|
+
).toBe(true);
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
it("should return true for matching registration signature without 0x prefix", () => {
|
|
111
|
+
expect(TransactionTypeIdentifier.isUsernameRegistration(TransactionFunctionSigs.RegisterUsername)).toBe(
|
|
112
|
+
true,
|
|
113
|
+
);
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
it("should return false for non-matching signature", () => {
|
|
117
|
+
expect(TransactionTypeIdentifier.isUsernameRegistration(InvalidFunctionSignature)).toBe(false);
|
|
118
|
+
});
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
describe("#isUsernameResignation", () => {
|
|
122
|
+
it("should return true for matching resignation signature", () => {
|
|
123
|
+
expect(
|
|
124
|
+
TransactionTypeIdentifier.isUsernameResignation(
|
|
125
|
+
Helpers.addLeadingHexZero(TransactionFunctionSigs.ResignUsername),
|
|
126
|
+
),
|
|
127
|
+
).toBe(true);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it("should return true for matching resignation signature without 0x prefix", () => {
|
|
131
|
+
expect(TransactionTypeIdentifier.isUsernameResignation(TransactionFunctionSigs.ResignUsername)).toBe(true);
|
|
132
|
+
});
|
|
133
|
+
|
|
134
|
+
it("should return false for non-matching signature", () => {
|
|
135
|
+
expect(TransactionTypeIdentifier.isUsernameResignation(InvalidFunctionSignature)).toBe(false);
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
describe("#isValidatorRegistration", () => {
|
|
140
|
+
it("should return true for matching validator registration signature", () => {
|
|
141
|
+
expect(
|
|
142
|
+
TransactionTypeIdentifier.isValidatorRegistration(
|
|
143
|
+
Helpers.addLeadingHexZero(TransactionFunctionSigs.RegisterValidator),
|
|
144
|
+
),
|
|
145
|
+
).toBe(true);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it("should return true for matching validator registration signature without 0x prefix", () => {
|
|
149
|
+
expect(TransactionTypeIdentifier.isValidatorRegistration(TransactionFunctionSigs.RegisterValidator)).toBe(
|
|
150
|
+
true,
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it("should return false for non-matching signature", () => {
|
|
155
|
+
expect(TransactionTypeIdentifier.isValidatorRegistration(InvalidFunctionSignature)).toBe(false);
|
|
156
|
+
});
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
describe("#isValidatorResignation", () => {
|
|
160
|
+
it("should return true for matching validator resignation signature", () => {
|
|
161
|
+
expect(
|
|
162
|
+
TransactionTypeIdentifier.isValidatorResignation(
|
|
163
|
+
Helpers.addLeadingHexZero(TransactionFunctionSigs.ResignValidator),
|
|
164
|
+
),
|
|
165
|
+
).toBe(true);
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
it("should return true for matching validator resignation signature without 0x prefix", () => {
|
|
169
|
+
expect(TransactionTypeIdentifier.isValidatorResignation(TransactionFunctionSigs.ResignValidator)).toBe(
|
|
170
|
+
true,
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
|
|
174
|
+
it("should return false for non-matching signature", () => {
|
|
175
|
+
expect(TransactionTypeIdentifier.isValidatorResignation(InvalidFunctionSignature)).toBe(false);
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
describe("#isUpdateValidator", () => {
|
|
180
|
+
it("should return true for matching update validator signature", () => {
|
|
181
|
+
expect(
|
|
182
|
+
TransactionTypeIdentifier.isUpdateValidator(
|
|
183
|
+
Helpers.addLeadingHexZero(TransactionFunctionSigs.UpdateValidator),
|
|
184
|
+
),
|
|
185
|
+
).toBe(true);
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
it("should return true for matching update validator signature without 0x prefix", () => {
|
|
189
|
+
expect(TransactionTypeIdentifier.isUpdateValidator(TransactionFunctionSigs.UpdateValidator)).toBe(true);
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
it("should return false for non-matching signature", () => {
|
|
193
|
+
expect(TransactionTypeIdentifier.isUpdateValidator(InvalidFunctionSignature)).toBe(false);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
describe("#isTokenTransfer", () => {
|
|
198
|
+
it("should return true for valid token transfer data", () => {
|
|
199
|
+
expect(TransactionTypeIdentifier.isTokenTransfer("0x" + "0".repeat(64))).toBe(false);
|
|
200
|
+
});
|
|
201
|
+
|
|
202
|
+
it("should return false for invalid data", () => {
|
|
203
|
+
expect(TransactionTypeIdentifier.isTokenTransfer(InvalidFunctionSignature)).toBe(false);
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
describe("#isApprove", () => {
|
|
208
|
+
it("should return true for valid approve data with non-zero amount", () => {
|
|
209
|
+
expect(TransactionTypeIdentifier.isApprove(APPROVE_BYTECODE)).toBe(true);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("should return false for approve data with zero amount", () => {
|
|
213
|
+
expect(TransactionTypeIdentifier.isApprove(REVOKE_BYTECODE)).toBe(false);
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
it("should return false for non-approve function", () => {
|
|
217
|
+
expect(TransactionTypeIdentifier.isApprove(InvalidFunctionSignature)).toBe(false);
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
it("should return false for invalid data", () => {
|
|
221
|
+
expect(TransactionTypeIdentifier.isApprove(InvalidFunctionSignature)).toBe(false);
|
|
222
|
+
});
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
describe("#isRevoke", () => {
|
|
226
|
+
it("should return true for approve data with zero amount", () => {
|
|
227
|
+
expect(TransactionTypeIdentifier.isRevoke(REVOKE_BYTECODE)).toBe(true);
|
|
228
|
+
});
|
|
229
|
+
|
|
230
|
+
it("should return false for approve data with non-zero amount", () => {
|
|
231
|
+
expect(TransactionTypeIdentifier.isRevoke(APPROVE_BYTECODE)).toBe(false);
|
|
232
|
+
});
|
|
233
|
+
|
|
234
|
+
it("should return false for non-approve function", () => {
|
|
235
|
+
expect(TransactionTypeIdentifier.isRevoke(InvalidFunctionSignature)).toBe(false);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
it("should return false for invalid data", () => {
|
|
239
|
+
expect(TransactionTypeIdentifier.isRevoke(InvalidFunctionSignature)).toBe(false);
|
|
240
|
+
});
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
describe("#isBatchTransfer", () => {
|
|
244
|
+
it("should return true for valid batch transfer data", () => {
|
|
245
|
+
expect(TransactionTypeIdentifier.isBatchTransfer(BATCH_TRANSFER_BYTECODE)).toBe(true);
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
it("should return false for non batch transfer", () => {
|
|
249
|
+
expect(TransactionTypeIdentifier.isBatchTransfer(InvalidFunctionSignature)).toBe(false);
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
it("should return false for invalid data", () => {
|
|
253
|
+
expect(TransactionTypeIdentifier.isBatchTransfer(InvalidFunctionSignature)).toBe(false);
|
|
254
|
+
});
|
|
255
|
+
});
|
|
256
|
+
});
|