@arcblock/erc721did-contract 0.2.4

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 ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2018-2020 ArcBlock
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,52 @@
1
+ ## ArcBridge Contracts
2
+
3
+ Solidity contracts that powers ArcBridge.
4
+
5
+ ### How to Deploy
6
+
7
+ 0. create dotenv file
8
+ 1. (optional) deploy token
9
+ 2. deploy multisig library
10
+ 3. deploy rollup contract
11
+
12
+ ### FAQ
13
+
14
+ - How to Deploy? https://github.com/wighawag/hardhat-deploy
15
+
16
+ ### Getting Started
17
+
18
+ 如果是本地开发环境,需要修改 src/library/ERC20Token.sol,替换其中的 TokenSymbol 为 DEV,然后再部署
19
+
20
+ #### Cleanup
21
+
22
+ > Only required if you want a clean setup
23
+
24
+ ```bash
25
+ rm -rf deployments
26
+ ```
27
+
28
+ #### Deploy ERC20Token
29
+
30
+ > Will update .env.dev.tba
31
+
32
+ ```bash
33
+ NODE_ENV=dev.tba npm run deploy -- --network goerli --tags token
34
+ ```
35
+
36
+ #### Deploy MultiSig
37
+
38
+ > Will update .env.dev.tba
39
+
40
+ ```bash
41
+ NODE_ENV=dev.tba npm run deploy -- --network goerli --tags multisig
42
+ ```
43
+
44
+ #### Deploy ERC20Rollup
45
+
46
+ > Please remember to set `MIGRATED_FROM` and `MIN_SIGNER_COUNT` before deploy.
47
+
48
+ ```bash
49
+ NODE_ENV=dev.tba npm run deploy -- --network goerli --tags rollup
50
+ ```
51
+
52
+ Then you are all set on ethereum.
@@ -0,0 +1,155 @@
1
+ {
2
+ "_format": "hh-sol-artifact-1",
3
+ "contractName": "ERC721DIDFactory",
4
+ "sourceName": "src/ERC721DIDFactory.sol",
5
+ "abi": [
6
+ {
7
+ "inputs": [
8
+ {
9
+ "internalType": "address",
10
+ "name": "_implementation",
11
+ "type": "address"
12
+ }
13
+ ],
14
+ "stateMutability": "nonpayable",
15
+ "type": "constructor"
16
+ },
17
+ {
18
+ "anonymous": false,
19
+ "inputs": [
20
+ {
21
+ "indexed": false,
22
+ "internalType": "address",
23
+ "name": "contractAddress",
24
+ "type": "address"
25
+ }
26
+ ],
27
+ "name": "Created",
28
+ "type": "event"
29
+ },
30
+ {
31
+ "anonymous": false,
32
+ "inputs": [
33
+ {
34
+ "indexed": true,
35
+ "internalType": "address",
36
+ "name": "previousOwner",
37
+ "type": "address"
38
+ },
39
+ {
40
+ "indexed": true,
41
+ "internalType": "address",
42
+ "name": "newOwner",
43
+ "type": "address"
44
+ }
45
+ ],
46
+ "name": "OwnershipTransferred",
47
+ "type": "event"
48
+ },
49
+ {
50
+ "stateMutability": "nonpayable",
51
+ "type": "fallback"
52
+ },
53
+ {
54
+ "inputs": [
55
+ {
56
+ "internalType": "address",
57
+ "name": "_proxyRegistryAddress",
58
+ "type": "address"
59
+ },
60
+ {
61
+ "internalType": "string",
62
+ "name": "_baseImageURI",
63
+ "type": "string"
64
+ },
65
+ {
66
+ "internalType": "string",
67
+ "name": "_contractName",
68
+ "type": "string"
69
+ },
70
+ {
71
+ "internalType": "string",
72
+ "name": "_contractSymbol",
73
+ "type": "string"
74
+ },
75
+ {
76
+ "internalType": "string",
77
+ "name": "_contractDescription",
78
+ "type": "string"
79
+ },
80
+ {
81
+ "internalType": "uint256",
82
+ "name": "_totalLimit",
83
+ "type": "uint256"
84
+ }
85
+ ],
86
+ "name": "create",
87
+ "outputs": [],
88
+ "stateMutability": "nonpayable",
89
+ "type": "function"
90
+ },
91
+ {
92
+ "inputs": [],
93
+ "name": "implementation",
94
+ "outputs": [
95
+ {
96
+ "internalType": "address",
97
+ "name": "",
98
+ "type": "address"
99
+ }
100
+ ],
101
+ "stateMutability": "view",
102
+ "type": "function"
103
+ },
104
+ {
105
+ "inputs": [],
106
+ "name": "owner",
107
+ "outputs": [
108
+ {
109
+ "internalType": "address",
110
+ "name": "",
111
+ "type": "address"
112
+ }
113
+ ],
114
+ "stateMutability": "view",
115
+ "type": "function"
116
+ },
117
+ {
118
+ "inputs": [],
119
+ "name": "renounceOwnership",
120
+ "outputs": [],
121
+ "stateMutability": "nonpayable",
122
+ "type": "function"
123
+ },
124
+ {
125
+ "inputs": [
126
+ {
127
+ "internalType": "address",
128
+ "name": "_implementation",
129
+ "type": "address"
130
+ }
131
+ ],
132
+ "name": "setImplementation",
133
+ "outputs": [],
134
+ "stateMutability": "nonpayable",
135
+ "type": "function"
136
+ },
137
+ {
138
+ "inputs": [
139
+ {
140
+ "internalType": "address",
141
+ "name": "newOwner",
142
+ "type": "address"
143
+ }
144
+ ],
145
+ "name": "transferOwnership",
146
+ "outputs": [],
147
+ "stateMutability": "nonpayable",
148
+ "type": "function"
149
+ }
150
+ ],
151
+ "bytecode": "0x608060405234801561001057600080fd5b50604051610d7d380380610d7d83398181016040528101906100329190610176565b61004e61004361009560201b60201c565b61009d60201b60201c565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506101e8565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600081519050610170816101d1565b92915050565b60006020828403121561018857600080fd5b600061019684828501610161565b91505092915050565b60006101aa826101b1565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6101da8161019f565b81146101e557600080fd5b50565b610b86806101f76000396000f3fe608060405234801561001057600080fd5b50600436106100665760003560e01c80633040090b146100a25780635c60da1b146100be578063715018a6146100dc5780638da5cb5b146100e6578063d784d42614610104578063f2fde38b1461012057610067565b5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610099906108d7565b60405180910390fd5b6100bc60048036038101906100b79190610613565b61013c565b005b6100c6610220565b6040516100d391906107df565b60405180910390f35b6100e4610246565b005b6100ee61025a565b6040516100fb91906107df565b60405180910390f35b61011e600480360381019061011991906105ea565b610283565b005b61013a600480360381019061013591906105ea565b6102cf565b005b6000610169600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610353565b90508073ffffffffffffffffffffffffffffffffffffffff1663fe9c9ff18888888888886040518763ffffffff1660e01b81526004016101ae969594939291906107fa565b600060405180830381600087803b1580156101c857600080fd5b505af11580156101dc573d6000803e3d6000fd5b505050507f1449abf21e49fd025f33495e77f7b1461caefdd3d4bb646424a3f445c4576a5b8160405161020f91906107df565b60405180910390a150505050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61024e61040e565b610258600061048c565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61028b61040e565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6102d761040e565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610347576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161033e90610877565b60405180910390fd5b6103508161048c565b50565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f09050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040090610897565b60405180910390fd5b919050565b610416610550565b73ffffffffffffffffffffffffffffffffffffffff1661043461025a565b73ffffffffffffffffffffffffffffffffffffffff161461048a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610481906108b7565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b600061056b6105668461091c565b6108f7565b90508281526020810184848401111561058357600080fd5b61058e8482856109a5565b509392505050565b6000813590506105a581610b22565b92915050565b600082601f8301126105bc57600080fd5b81356105cc848260208601610558565b91505092915050565b6000813590506105e481610b39565b92915050565b6000602082840312156105fc57600080fd5b600061060a84828501610596565b91505092915050565b60008060008060008060c0878903121561062c57600080fd5b600061063a89828a01610596565b965050602087013567ffffffffffffffff81111561065757600080fd5b61066389828a016105ab565b955050604087013567ffffffffffffffff81111561068057600080fd5b61068c89828a016105ab565b945050606087013567ffffffffffffffff8111156106a957600080fd5b6106b589828a016105ab565b935050608087013567ffffffffffffffff8111156106d257600080fd5b6106de89828a016105ab565b92505060a06106ef89828a016105d5565b9150509295509295509295565b61070581610969565b82525050565b60006107168261094d565b6107208185610958565b93506107308185602086016109b4565b61073981610a47565b840191505092915050565b6000610751602683610958565b915061075c82610a58565b604082019050919050565b6000610774601683610958565b915061077f82610aa7565b602082019050919050565b6000610797602083610958565b91506107a282610ad0565b602082019050919050565b60006107ba600f83610958565b91506107c582610af9565b602082019050919050565b6107d98161099b565b82525050565b60006020820190506107f460008301846106fc565b92915050565b600060c08201905061080f60008301896106fc565b8181036020830152610821818861070b565b90508181036040830152610835818761070b565b90508181036060830152610849818661070b565b9050818103608083015261085d818561070b565b905061086c60a08301846107d0565b979650505050505050565b6000602082019050818103600083015261089081610744565b9050919050565b600060208201905081810360008301526108b081610767565b9050919050565b600060208201905081810360008301526108d08161078a565b9050919050565b600060208201905081810360008301526108f0816107ad565b9050919050565b6000610901610912565b905061090d82826109e7565b919050565b6000604051905090565b600067ffffffffffffffff82111561093757610936610a18565b5b61094082610a47565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b60006109748261097b565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156109d25780820151818401526020810190506109b7565b838111156109e1576000848401525b50505050565b6109f082610a47565b810181811067ffffffffffffffff82111715610a0f57610a0e610a18565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243313136373a20637265617465206661696c656400000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f556e6b6e6f772066756e6374696f6e0000000000000000000000000000000000600082015250565b610b2b81610969565b8114610b3657600080fd5b50565b610b428161099b565b8114610b4d57600080fd5b5056fea2646970667358221220b5fa8967ae0dd37c26ae927cac9ffccafe881cbd1273bb80536ba6e37309d4cf64736f6c63430008040033",
152
+ "deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100665760003560e01c80633040090b146100a25780635c60da1b146100be578063715018a6146100dc5780638da5cb5b146100e6578063d784d42614610104578063f2fde38b1461012057610067565b5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610099906108d7565b60405180910390fd5b6100bc60048036038101906100b79190610613565b61013c565b005b6100c6610220565b6040516100d391906107df565b60405180910390f35b6100e4610246565b005b6100ee61025a565b6040516100fb91906107df565b60405180910390f35b61011e600480360381019061011991906105ea565b610283565b005b61013a600480360381019061013591906105ea565b6102cf565b005b6000610169600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16610353565b90508073ffffffffffffffffffffffffffffffffffffffff1663fe9c9ff18888888888886040518763ffffffff1660e01b81526004016101ae969594939291906107fa565b600060405180830381600087803b1580156101c857600080fd5b505af11580156101dc573d6000803e3d6000fd5b505050507f1449abf21e49fd025f33495e77f7b1461caefdd3d4bb646424a3f445c4576a5b8160405161020f91906107df565b60405180910390a150505050505050565b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61024e61040e565b610258600061048c565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b61028b61040e565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6102d761040e565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610347576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161033e90610877565b60405180910390fd5b6103508161048c565b50565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f09050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610409576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161040090610897565b60405180910390fd5b919050565b610416610550565b73ffffffffffffffffffffffffffffffffffffffff1661043461025a565b73ffffffffffffffffffffffffffffffffffffffff161461048a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610481906108b7565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600033905090565b600061056b6105668461091c565b6108f7565b90508281526020810184848401111561058357600080fd5b61058e8482856109a5565b509392505050565b6000813590506105a581610b22565b92915050565b600082601f8301126105bc57600080fd5b81356105cc848260208601610558565b91505092915050565b6000813590506105e481610b39565b92915050565b6000602082840312156105fc57600080fd5b600061060a84828501610596565b91505092915050565b60008060008060008060c0878903121561062c57600080fd5b600061063a89828a01610596565b965050602087013567ffffffffffffffff81111561065757600080fd5b61066389828a016105ab565b955050604087013567ffffffffffffffff81111561068057600080fd5b61068c89828a016105ab565b945050606087013567ffffffffffffffff8111156106a957600080fd5b6106b589828a016105ab565b935050608087013567ffffffffffffffff8111156106d257600080fd5b6106de89828a016105ab565b92505060a06106ef89828a016105d5565b9150509295509295509295565b61070581610969565b82525050565b60006107168261094d565b6107208185610958565b93506107308185602086016109b4565b61073981610a47565b840191505092915050565b6000610751602683610958565b915061075c82610a58565b604082019050919050565b6000610774601683610958565b915061077f82610aa7565b602082019050919050565b6000610797602083610958565b91506107a282610ad0565b602082019050919050565b60006107ba600f83610958565b91506107c582610af9565b602082019050919050565b6107d98161099b565b82525050565b60006020820190506107f460008301846106fc565b92915050565b600060c08201905061080f60008301896106fc565b8181036020830152610821818861070b565b90508181036040830152610835818761070b565b90508181036060830152610849818661070b565b9050818103608083015261085d818561070b565b905061086c60a08301846107d0565b979650505050505050565b6000602082019050818103600083015261089081610744565b9050919050565b600060208201905081810360008301526108b081610767565b9050919050565b600060208201905081810360008301526108d08161078a565b9050919050565b600060208201905081810360008301526108f0816107ad565b9050919050565b6000610901610912565b905061090d82826109e7565b919050565b6000604051905090565b600067ffffffffffffffff82111561093757610936610a18565b5b61094082610a47565b9050602081019050919050565b600081519050919050565b600082825260208201905092915050565b60006109748261097b565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b82818337600083830152505050565b60005b838110156109d25780820151818401526020810190506109b7565b838111156109e1576000848401525b50505050565b6109f082610a47565b810181811067ffffffffffffffff82111715610a0f57610a0e610a18565b5b80604052505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6000601f19601f8301169050919050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b7f455243313136373a20637265617465206661696c656400000000000000000000600082015250565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b7f556e6b6e6f772066756e6374696f6e0000000000000000000000000000000000600082015250565b610b2b81610969565b8114610b3657600080fd5b50565b610b428161099b565b8114610b4d57600080fd5b5056fea2646970667358221220b5fa8967ae0dd37c26ae927cac9ffccafe881cbd1273bb80536ba6e37309d4cf64736f6c63430008040033",
153
+ "linkReferences": {},
154
+ "deployedLinkReferences": {}
155
+ }
@@ -0,0 +1,208 @@
1
+ /* eslint-disable no-unused-vars */
2
+ /* eslint-disable no-undef */
3
+ require('dotenv-flow').config();
4
+ const ethers = require('ethers');
5
+ const axios = require('axios');
6
+ const waitFor = require('p-wait-for');
7
+ const { toBase58, toBN } = require('@ocap/util');
8
+ const upperFirst = require('lodash/upperFirst');
9
+ // eslint-disable-next-line import/no-useless-path-segments
10
+ const ERC721DID = require('../lib/ERC721DID.json');
11
+ // eslint-disable-next-line import/no-useless-path-segments
12
+ const ERC721DIDFactory = require('../lib/ERC721DIDFactory.json');
13
+
14
+ const { INFURA_PROJECT_ID } = process.env;
15
+
16
+ function getDefaultProvider(isLocal = false) {
17
+ return isLocal
18
+ ? new ethers.providers.JsonRpcProvider('http://localhost:8545')
19
+ : new ethers.providers.InfuraProvider('goerli', INFURA_PROJECT_ID);
20
+ }
21
+
22
+ async function getContract({ contractAddress, isLocal = false, signer } = {}) {
23
+ const provider = getDefaultProvider(isLocal);
24
+
25
+ const contract = new ethers.Contract(contractAddress, ERC721DID.abi, signer || provider);
26
+
27
+ return contract;
28
+ }
29
+
30
+ async function getContractFactory({ contractAddress, isLocal = false, signer } = {}) {
31
+ const provider = getDefaultProvider(isLocal);
32
+
33
+ const contract = new ethers.Contract(contractAddress, ERC721DIDFactory.abi, signer || provider);
34
+
35
+ return contract;
36
+ }
37
+
38
+ async function getGasPrice({ provider }) {
39
+ const gwei = 1000000000;
40
+
41
+ const networkId = await getNetworkId({ contract });
42
+
43
+ // ethereum
44
+ if ([1, '1', 'mainnet', 'eth-main'].includes(networkId)) {
45
+ const { data } = await axios.get(`https://token-data.arcblock.io/api/gas-prices?chainId=${networkId}`);
46
+ return (data.fast / 10) * gwei;
47
+ }
48
+
49
+ if ([5, '5', 'goerli', 'eth-goerli'].includes(networkId)) {
50
+ const { gasPrice } = await provider.getFeeData();
51
+ return gasPrice.toString();
52
+ }
53
+
54
+ // hardhat
55
+ if ([31337, '31337', 'hardhat'].includes(networkId)) {
56
+ return 1 * gwei;
57
+ }
58
+
59
+ // TODO: bsc
60
+ // TODO: matic
61
+ // TODO: fantom
62
+
63
+ return 1 * gwei;
64
+ }
65
+
66
+ async function getTxData(params = {}) {
67
+ const { contract, fn, args } = params;
68
+ const txData = contract.interface.encodeFunctionData(fn, args);
69
+
70
+ const networkId = await getNetworkId({ contract });
71
+
72
+ // const gasPrice = await getGasPrice({ provider: contract.provider });
73
+ // const gasPriceAsGwei = Math.ceil(ethers.utils.formatUnits(gasPrice, 'gwei').toString());
74
+
75
+ const gasLimit = await contract.provider
76
+ .estimateGas({
77
+ to: contract.address,
78
+ data: txData,
79
+ })
80
+ .then((res) => res.toString());
81
+
82
+ return toBase58(
83
+ Buffer.from(
84
+ JSON.stringify({
85
+ network: networkId,
86
+ tx: {
87
+ to: contract.address,
88
+ value: '0',
89
+ gasLimit,
90
+ data: txData,
91
+ },
92
+ }),
93
+ 'utf-8'
94
+ )
95
+ );
96
+ }
97
+
98
+ const waitForTxReceipt = async ({ contract, txHash }) => {
99
+ let tx = {};
100
+ let receipt = {};
101
+ const txHashTemp = txHash;
102
+
103
+ await waitFor(
104
+ async () => {
105
+ // ethers getTransaction
106
+ tx = await contract.provider.getTransaction(txHashTemp);
107
+ return !!tx?.blockNumber;
108
+ },
109
+ { interval: 3000, timeout: 30 * 60 * 1000 }
110
+ );
111
+
112
+ await waitFor(
113
+ async () => {
114
+ // ethers getTransactionReceipt
115
+ const originReceipt = await contract.provider.getTransactionReceipt(txHashTemp);
116
+ receipt = {
117
+ ...originReceipt,
118
+ parseLog: originReceipt?.logs?.map((log) => {
119
+ try {
120
+ return contract.interface.parseLog(log);
121
+ } catch (_error) {
122
+ return log;
123
+ }
124
+ }),
125
+ };
126
+ return !!receipt?.blockNumber;
127
+ },
128
+ { interval: 3000, timeout: 30 * 60 * 1000 }
129
+ );
130
+
131
+ return receipt;
132
+ };
133
+
134
+ const onContractFilter = async ({ contract, fn, onSuccess }) => {
135
+ contract.provider.on(
136
+ {
137
+ address: contract.address,
138
+ topics: [contract.interface.getEventTopic(upperFirst(fn))],
139
+ },
140
+ async (res) => {
141
+ await onSuccess(res);
142
+ }
143
+ );
144
+ };
145
+
146
+ const getNetworkId = async ({ contract }) => {
147
+ const networkId = await contract.provider.getNetwork().then((res) => res.chainId);
148
+ return networkId;
149
+ };
150
+
151
+ const getNetworkName = (networkId) => {
152
+ const networkIdString = `${networkId}`;
153
+ switch (networkIdString) {
154
+ case '1':
155
+ return 'mainnet';
156
+ case '3':
157
+ return 'ropsten';
158
+ case '4':
159
+ return 'rinkeby';
160
+ case '5':
161
+ return 'goerli';
162
+ case '42':
163
+ return 'kovan';
164
+ case '31337':
165
+ return 'hardhat';
166
+ default:
167
+ return 'unknown';
168
+ }
169
+ };
170
+
171
+ const getAddressExplorerUrl = ({ networkId, hash }) => {
172
+ return `https://${getNetworkName(networkId)}.etherscan.io/address/${hash}`;
173
+ };
174
+
175
+ const getBlockExplorerUrl = ({ networkId, blockletNumber }) => {
176
+ return `https://${getNetworkName(networkId)}.etherscan.io/block/${blockletNumber}`;
177
+ };
178
+
179
+ const getTxExplorerUrl = ({ networkId, hash }) => {
180
+ return `https://${getNetworkName(networkId)}.etherscan.io/tx/${hash}`;
181
+ };
182
+
183
+ const getCloneContractArgs = ({
184
+ ownerAddress,
185
+ baseImageURI,
186
+ contractName,
187
+ contractSymbol = '',
188
+ contractDescription,
189
+ totalLimit = 0,
190
+ } = {}) => {
191
+ const params = [ownerAddress, baseImageURI, contractName, contractSymbol, contractDescription, totalLimit];
192
+ return params;
193
+ };
194
+
195
+ module.exports = {
196
+ getContract,
197
+ getContractFactory,
198
+ getTxData,
199
+ getGasPrice,
200
+ waitForTxReceipt,
201
+ onContractFilter,
202
+ getNetworkId,
203
+ getNetworkName,
204
+ getBlockExplorerUrl,
205
+ getTxExplorerUrl,
206
+ getAddressExplorerUrl,
207
+ getCloneContractArgs,
208
+ };