@arcblock/erc721did-contract 0.2.6 → 0.3.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +33 -19
- package/lib/cjs/ERC721DID.json +735 -0
- package/lib/cjs/ERC721DIDFactory.json +165 -0
- package/lib/cjs/EvmChainList.json +54 -0
- package/lib/cjs/contract.js +344 -0
- package/lib/esm/ERC721DID.json +735 -0
- package/lib/esm/ERC721DIDFactory.json +165 -0
- package/lib/esm/EvmChainList.json +54 -0
- package/lib/esm/contract.js +1412 -0
- package/package.json +36 -26
- package/lib/ERC721DID.json +0 -725
- package/lib/ERC721DIDFactory.json +0 -155
- package/lib/contract.js +0 -206
- package/lib/helper.js +0 -216
|
@@ -0,0 +1,165 @@
|
|
|
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
|
+
"internalType": "uint256",
|
|
87
|
+
"name": "_price",
|
|
88
|
+
"type": "uint256"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
"internalType": "address payable",
|
|
92
|
+
"name": "_transferTokenAddress",
|
|
93
|
+
"type": "address"
|
|
94
|
+
}
|
|
95
|
+
],
|
|
96
|
+
"name": "create",
|
|
97
|
+
"outputs": [],
|
|
98
|
+
"stateMutability": "nonpayable",
|
|
99
|
+
"type": "function"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"inputs": [],
|
|
103
|
+
"name": "implementation",
|
|
104
|
+
"outputs": [
|
|
105
|
+
{
|
|
106
|
+
"internalType": "address",
|
|
107
|
+
"name": "",
|
|
108
|
+
"type": "address"
|
|
109
|
+
}
|
|
110
|
+
],
|
|
111
|
+
"stateMutability": "view",
|
|
112
|
+
"type": "function"
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
"inputs": [],
|
|
116
|
+
"name": "owner",
|
|
117
|
+
"outputs": [
|
|
118
|
+
{
|
|
119
|
+
"internalType": "address",
|
|
120
|
+
"name": "",
|
|
121
|
+
"type": "address"
|
|
122
|
+
}
|
|
123
|
+
],
|
|
124
|
+
"stateMutability": "view",
|
|
125
|
+
"type": "function"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"inputs": [],
|
|
129
|
+
"name": "renounceOwnership",
|
|
130
|
+
"outputs": [],
|
|
131
|
+
"stateMutability": "nonpayable",
|
|
132
|
+
"type": "function"
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
"inputs": [
|
|
136
|
+
{
|
|
137
|
+
"internalType": "address",
|
|
138
|
+
"name": "_implementation",
|
|
139
|
+
"type": "address"
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"name": "setImplementation",
|
|
143
|
+
"outputs": [],
|
|
144
|
+
"stateMutability": "nonpayable",
|
|
145
|
+
"type": "function"
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"inputs": [
|
|
149
|
+
{
|
|
150
|
+
"internalType": "address",
|
|
151
|
+
"name": "newOwner",
|
|
152
|
+
"type": "address"
|
|
153
|
+
}
|
|
154
|
+
],
|
|
155
|
+
"name": "transferOwnership",
|
|
156
|
+
"outputs": [],
|
|
157
|
+
"stateMutability": "nonpayable",
|
|
158
|
+
"type": "function"
|
|
159
|
+
}
|
|
160
|
+
],
|
|
161
|
+
"bytecode": "0x608060405234801561001057600080fd5b5060405162000e5638038062000e56833981810160405281019061003491906101c6565b61005061004561009760201b60201c565b61009f60201b60201c565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550506101f3565b600033905090565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b600080fd5b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b600061019382610168565b9050919050565b6101a381610188565b81146101ae57600080fd5b50565b6000815190506101c08161019a565b92915050565b6000602082840312156101dc576101db610163565b5b60006101ea848285016101b1565b91505092915050565b610c5380620002036000396000f3fe608060405234801561001057600080fd5b50600436106100665760003560e01c80635c60da1b146100a2578063715018a6146100c05780638da5cb5b146100ca578063c137ecd7146100e8578063d784d42614610104578063f2fde38b1461012057610067565b5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610099906105bb565b60405180910390fd5b6100aa61013c565b6040516100b7919061061c565b60405180910390f35b6100c8610162565b005b6100d2610176565b6040516100df919061061c565b60405180910390f35b61010260048036038101906100fd9190610831565b61019f565b005b61011e60048036038101906101199190610957565b610289565b005b61013a60048036038101906101359190610957565b6102d5565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61016a610359565b61017460006103d7565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006101cc600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661049b565b90508073ffffffffffffffffffffffffffffffffffffffff1663f79da28a8a8a8a8a8a8a8a8a6040518963ffffffff1660e01b8152600401610215989796959493929190610a19565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b505050507f1449abf21e49fd025f33495e77f7b1461caefdd3d4bb646424a3f445c4576a5b81604051610276919061061c565b60405180910390a1505050505050505050565b610291610359565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6102dd610359565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561034d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034490610b25565b60405180910390fd5b610356816103d7565b50565b610361610556565b73ffffffffffffffffffffffffffffffffffffffff1661037f610176565b73ffffffffffffffffffffffffffffffffffffffff16146103d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103cc90610b91565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f09050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610551576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161054890610bfd565b60405180910390fd5b919050565b600033905090565b600082825260208201905092915050565b7f556e6b6e6f772066756e6374696f6e0000000000000000000000000000000000600082015250565b60006105a5600f8361055e565b91506105b08261056f565b602082019050919050565b600060208201905081810360008301526105d481610598565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610606826105db565b9050919050565b610616816105fb565b82525050565b6000602082019050610631600083018461060d565b92915050565b6000604051905090565b600080fd5b600080fd5b610654816105fb565b811461065f57600080fd5b50565b6000813590506106718161064b565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6106ca82610681565b810181811067ffffffffffffffff821117156106e9576106e8610692565b5b80604052505050565b60006106fc610637565b905061070882826106c1565b919050565b600067ffffffffffffffff82111561072857610727610692565b5b61073182610681565b9050602081019050919050565b82818337600083830152505050565b600061076061075b8461070d565b6106f2565b90508281526020810184848401111561077c5761077b61067c565b5b61078784828561073e565b509392505050565b600082601f8301126107a4576107a3610677565b5b81356107b484826020860161074d565b91505092915050565b6000819050919050565b6107d0816107bd565b81146107db57600080fd5b50565b6000813590506107ed816107c7565b92915050565b60006107fe826105db565b9050919050565b61080e816107f3565b811461081957600080fd5b50565b60008135905061082b81610805565b92915050565b600080600080600080600080610100898b03121561085257610851610641565b5b60006108608b828c01610662565b985050602089013567ffffffffffffffff81111561088157610880610646565b5b61088d8b828c0161078f565b975050604089013567ffffffffffffffff8111156108ae576108ad610646565b5b6108ba8b828c0161078f565b965050606089013567ffffffffffffffff8111156108db576108da610646565b5b6108e78b828c0161078f565b955050608089013567ffffffffffffffff81111561090857610907610646565b5b6109148b828c0161078f565b94505060a06109258b828c016107de565b93505060c06109368b828c016107de565b92505060e06109478b828c0161081c565b9150509295985092959890939650565b60006020828403121561096d5761096c610641565b5b600061097b84828501610662565b91505092915050565b600081519050919050565b60005b838110156109ad578082015181840152602081019050610992565b838111156109bc576000848401525b50505050565b60006109cd82610984565b6109d7818561055e565b93506109e781856020860161098f565b6109f081610681565b840191505092915050565b610a04816107bd565b82525050565b610a13816107f3565b82525050565b600061010082019050610a2f600083018b61060d565b8181036020830152610a41818a6109c2565b90508181036040830152610a5581896109c2565b90508181036060830152610a6981886109c2565b90508181036080830152610a7d81876109c2565b9050610a8c60a08301866109fb565b610a9960c08301856109fb565b610aa660e0830184610a0a565b9998505050505050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610b0f60268361055e565b9150610b1a82610ab3565b604082019050919050565b60006020820190508181036000830152610b3e81610b02565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610b7b60208361055e565b9150610b8682610b45565b602082019050919050565b60006020820190508181036000830152610baa81610b6e565b9050919050565b7f455243313136373a20637265617465206661696c656400000000000000000000600082015250565b6000610be760168361055e565b9150610bf282610bb1565b602082019050919050565b60006020820190508181036000830152610c1681610bda565b905091905056fea2646970667358221220557868f3e08664e3b092710a8b1628826491347e6b43951266d630d283f43d0064736f6c63430008090033",
|
|
162
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100665760003560e01c80635c60da1b146100a2578063715018a6146100c05780638da5cb5b146100ca578063c137ecd7146100e8578063d784d42614610104578063f2fde38b1461012057610067565b5b6040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610099906105bb565b60405180910390fd5b6100aa61013c565b6040516100b7919061061c565b60405180910390f35b6100c8610162565b005b6100d2610176565b6040516100df919061061c565b60405180910390f35b61010260048036038101906100fd9190610831565b61019f565b005b61011e60048036038101906101199190610957565b610289565b005b61013a60048036038101906101359190610957565b6102d5565b005b600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61016a610359565b61017460006103d7565b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60006101cc600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1661049b565b90508073ffffffffffffffffffffffffffffffffffffffff1663f79da28a8a8a8a8a8a8a8a8a6040518963ffffffff1660e01b8152600401610215989796959493929190610a19565b600060405180830381600087803b15801561022f57600080fd5b505af1158015610243573d6000803e3d6000fd5b505050507f1449abf21e49fd025f33495e77f7b1461caefdd3d4bb646424a3f445c4576a5b81604051610276919061061c565b60405180910390a1505050505050505050565b610291610359565b80600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555050565b6102dd610359565b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16141561034d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161034490610b25565b60405180910390fd5b610356816103d7565b50565b610361610556565b73ffffffffffffffffffffffffffffffffffffffff1661037f610176565b73ffffffffffffffffffffffffffffffffffffffff16146103d5576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016103cc90610b91565b60405180910390fd5b565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f09050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610551576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161054890610bfd565b60405180910390fd5b919050565b600033905090565b600082825260208201905092915050565b7f556e6b6e6f772066756e6374696f6e0000000000000000000000000000000000600082015250565b60006105a5600f8361055e565b91506105b08261056f565b602082019050919050565b600060208201905081810360008301526105d481610598565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000610606826105db565b9050919050565b610616816105fb565b82525050565b6000602082019050610631600083018461060d565b92915050565b6000604051905090565b600080fd5b600080fd5b610654816105fb565b811461065f57600080fd5b50565b6000813590506106718161064b565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6106ca82610681565b810181811067ffffffffffffffff821117156106e9576106e8610692565b5b80604052505050565b60006106fc610637565b905061070882826106c1565b919050565b600067ffffffffffffffff82111561072857610727610692565b5b61073182610681565b9050602081019050919050565b82818337600083830152505050565b600061076061075b8461070d565b6106f2565b90508281526020810184848401111561077c5761077b61067c565b5b61078784828561073e565b509392505050565b600082601f8301126107a4576107a3610677565b5b81356107b484826020860161074d565b91505092915050565b6000819050919050565b6107d0816107bd565b81146107db57600080fd5b50565b6000813590506107ed816107c7565b92915050565b60006107fe826105db565b9050919050565b61080e816107f3565b811461081957600080fd5b50565b60008135905061082b81610805565b92915050565b600080600080600080600080610100898b03121561085257610851610641565b5b60006108608b828c01610662565b985050602089013567ffffffffffffffff81111561088157610880610646565b5b61088d8b828c0161078f565b975050604089013567ffffffffffffffff8111156108ae576108ad610646565b5b6108ba8b828c0161078f565b965050606089013567ffffffffffffffff8111156108db576108da610646565b5b6108e78b828c0161078f565b955050608089013567ffffffffffffffff81111561090857610907610646565b5b6109148b828c0161078f565b94505060a06109258b828c016107de565b93505060c06109368b828c016107de565b92505060e06109478b828c0161081c565b9150509295985092959890939650565b60006020828403121561096d5761096c610641565b5b600061097b84828501610662565b91505092915050565b600081519050919050565b60005b838110156109ad578082015181840152602081019050610992565b838111156109bc576000848401525b50505050565b60006109cd82610984565b6109d7818561055e565b93506109e781856020860161098f565b6109f081610681565b840191505092915050565b610a04816107bd565b82525050565b610a13816107f3565b82525050565b600061010082019050610a2f600083018b61060d565b8181036020830152610a41818a6109c2565b90508181036040830152610a5581896109c2565b90508181036060830152610a6981886109c2565b90508181036080830152610a7d81876109c2565b9050610a8c60a08301866109fb565b610a9960c08301856109fb565b610aa660e0830184610a0a565b9998505050505050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000610b0f60268361055e565b9150610b1a82610ab3565b604082019050919050565b60006020820190508181036000830152610b3e81610b02565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000610b7b60208361055e565b9150610b8682610b45565b602082019050919050565b60006020820190508181036000830152610baa81610b6e565b9050919050565b7f455243313136373a20637265617465206661696c656400000000000000000000600082015250565b6000610be760168361055e565b9150610bf282610bb1565b602082019050919050565b60006020820190508181036000830152610c1681610bda565b905091905056fea2646970667358221220557868f3e08664e3b092710a8b1628826491347e6b43951266d630d283f43d0064736f6c63430008090033",
|
|
163
|
+
"linkReferences": {},
|
|
164
|
+
"deployedLinkReferences": {}
|
|
165
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
[
|
|
2
|
+
{
|
|
3
|
+
"chainId": "5",
|
|
4
|
+
"chainName": "Goerli",
|
|
5
|
+
"contractFactoryAddress": "0x4c093eAf8d569f6b2dC5a217D25cb3f0B60918C3",
|
|
6
|
+
"isTest": true,
|
|
7
|
+
"networkName": "goerli",
|
|
8
|
+
"symbol": "ETH (Goerli)",
|
|
9
|
+
"defaultRPC": "https://goerli.infura.io/v3/31276ea517a941c5b91d914fab83494e",
|
|
10
|
+
"explorer": "https://goerli.etherscan.io",
|
|
11
|
+
"icon": "eth",
|
|
12
|
+
"enable": true,
|
|
13
|
+
"decimal": 18
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"chainId": "84531",
|
|
17
|
+
"chainName": "Base Goerli",
|
|
18
|
+
"contractFactoryAddress": "0xe83044a18dAb8F28F99F22f413C3856A0e39B153",
|
|
19
|
+
"isTest": true,
|
|
20
|
+
"networkName": "base-goerli",
|
|
21
|
+
"symbol": "ETH (Base Goerli)",
|
|
22
|
+
"defaultRPC": "https://goerli.base.org",
|
|
23
|
+
"explorer": "https://goerli.basescan.org",
|
|
24
|
+
"icon": "base",
|
|
25
|
+
"enable": true,
|
|
26
|
+
"decimal": 18
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"chainId": "97",
|
|
30
|
+
"chainName": "BNB (Binance Smart Chain)",
|
|
31
|
+
"contractFactoryAddress": "0xf13AAEF9071498eE61D0e6390970e0629c60a53C",
|
|
32
|
+
"isTest": true,
|
|
33
|
+
"networkName": "bsc-test",
|
|
34
|
+
"symbol": "BNB",
|
|
35
|
+
"defaultRPC": "https://bsc.getblock.io/13042277-cdaa-47dc-acda-5a0900eaf4ae/testnet",
|
|
36
|
+
"explorer": "https://testnet.bscscan.com",
|
|
37
|
+
"icon": "bnb",
|
|
38
|
+
"enable": true,
|
|
39
|
+
"decimal": 18
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"chainId": "11155111",
|
|
43
|
+
"chainName": "Sepolia",
|
|
44
|
+
"contractFactoryAddress": "0xf13AAEF9071498eE61D0e6390970e0629c60a53C",
|
|
45
|
+
"isTest": true,
|
|
46
|
+
"networkName": "sepolia",
|
|
47
|
+
"symbol": "ETH (Sepolia)",
|
|
48
|
+
"defaultRPC": "https://sepolia.infura.io/v3/31276ea517a941c5b91d914fab83494e",
|
|
49
|
+
"explorer": "https://sepolia.etherscan.io",
|
|
50
|
+
"icon": "eth",
|
|
51
|
+
"enable": false,
|
|
52
|
+
"decimal": 18
|
|
53
|
+
}
|
|
54
|
+
]
|
|
@@ -0,0 +1,344 @@
|
|
|
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 } = require('@ocap/util');
|
|
8
|
+
const upperFirst = require('lodash/upperFirst');
|
|
9
|
+
const keyBy = require('lodash/keyBy');
|
|
10
|
+
const pick = require('lodash/pick');
|
|
11
|
+
const ERC721DID = require('./ERC721DID.json');
|
|
12
|
+
const ERC721DIDFactory = require('./ERC721DIDFactory.json');
|
|
13
|
+
|
|
14
|
+
const INFURA_PROJECT_ID = '31276ea517a941c5b91d914fab83494e';
|
|
15
|
+
|
|
16
|
+
const CHAIN_MAP = {
|
|
17
|
+
1: {
|
|
18
|
+
networkName: 'mainnet',
|
|
19
|
+
chainName: 'Ethereum Mainnet',
|
|
20
|
+
chainId: '1',
|
|
21
|
+
symbol: 'ETH',
|
|
22
|
+
defaultRPC: `https://mainnet.infura.io/v3/${INFURA_PROJECT_ID}`,
|
|
23
|
+
explorer: 'https://etherscan.io',
|
|
24
|
+
icon: 'eth',
|
|
25
|
+
enable: true,
|
|
26
|
+
decimal: 18,
|
|
27
|
+
},
|
|
28
|
+
5: {
|
|
29
|
+
networkName: 'goerli',
|
|
30
|
+
chainName: 'Goerli',
|
|
31
|
+
chainId: '5',
|
|
32
|
+
symbol: 'ETH (Goerli)',
|
|
33
|
+
defaultRPC: `https://goerli.infura.io/v3/${INFURA_PROJECT_ID}`,
|
|
34
|
+
explorer: 'https://goerli.etherscan.io',
|
|
35
|
+
icon: 'eth',
|
|
36
|
+
enable: true,
|
|
37
|
+
decimal: 18,
|
|
38
|
+
},
|
|
39
|
+
31337: {
|
|
40
|
+
networkName: 'localhost',
|
|
41
|
+
chainName: 'Localhost',
|
|
42
|
+
chainId: '31337',
|
|
43
|
+
symbol: 'ETH (Localhost)',
|
|
44
|
+
defaultRPC: 'http://localhost:8545',
|
|
45
|
+
explorer: 'http://localhost:8545',
|
|
46
|
+
icon: 'eth',
|
|
47
|
+
enable: true,
|
|
48
|
+
decimal: 18,
|
|
49
|
+
},
|
|
50
|
+
84531: {
|
|
51
|
+
networkName: 'base-goerli',
|
|
52
|
+
chainName: 'Base Goerli',
|
|
53
|
+
chainId: '84531',
|
|
54
|
+
symbol: 'ETH (Base Goerli)',
|
|
55
|
+
defaultRPC: 'https://goerli.base.org',
|
|
56
|
+
explorer: 'https://goerli.basescan.org',
|
|
57
|
+
icon: 'base',
|
|
58
|
+
enable: true,
|
|
59
|
+
decimal: 18,
|
|
60
|
+
},
|
|
61
|
+
11155111: {
|
|
62
|
+
networkName: 'sepolia',
|
|
63
|
+
chainName: 'Sepolia',
|
|
64
|
+
chainId: '11155111',
|
|
65
|
+
symbol: 'ETH (Sepolia)',
|
|
66
|
+
defaultRPC: `https://sepolia.infura.io/v3/${INFURA_PROJECT_ID}`,
|
|
67
|
+
explorer: 'https://sepolia.etherscan.io',
|
|
68
|
+
icon: 'eth',
|
|
69
|
+
enable: false, // FIXME
|
|
70
|
+
decimal: 18,
|
|
71
|
+
},
|
|
72
|
+
97: {
|
|
73
|
+
networkName: 'bsc-test',
|
|
74
|
+
chainName: 'BNB (Binance Smart Chain)',
|
|
75
|
+
chainId: '97',
|
|
76
|
+
symbol: 'BNB',
|
|
77
|
+
defaultRPC: 'https://bsc.getblock.io/13042277-cdaa-47dc-acda-5a0900eaf4ae/testnet',
|
|
78
|
+
explorer: 'https://testnet.bscscan.com',
|
|
79
|
+
icon: 'bnb',
|
|
80
|
+
enable: true,
|
|
81
|
+
decimal: 18,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const CUSTOM_CHAIN_MAP = {};
|
|
86
|
+
|
|
87
|
+
let isLocal = false;
|
|
88
|
+
|
|
89
|
+
function getProvider(chainId) {
|
|
90
|
+
const { defaultRPC } = getChainInfo(chainId);
|
|
91
|
+
return new ethers.providers.JsonRpcProvider(defaultRPC);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
async function getContract({ contractAddress, chainId, signer } = {}) {
|
|
95
|
+
const provider = getProvider(chainId);
|
|
96
|
+
|
|
97
|
+
const contract = new ethers.Contract(contractAddress, ERC721DID.abi, signer || provider);
|
|
98
|
+
|
|
99
|
+
return contract;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function getContractFactory({ contractAddress, chainId, signer } = {}) {
|
|
103
|
+
const provider = getProvider(chainId);
|
|
104
|
+
|
|
105
|
+
const contract = new ethers.Contract(contractAddress, ERC721DIDFactory.abi, signer || provider);
|
|
106
|
+
|
|
107
|
+
return contract;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
async function getGasPrice({ provider }) {
|
|
111
|
+
const gwei = 1000000000;
|
|
112
|
+
|
|
113
|
+
const chainId = await getChainId({ contract });
|
|
114
|
+
|
|
115
|
+
// ethereum
|
|
116
|
+
if ([1, '1', 'mainnet', 'eth-main'].includes(chainId)) {
|
|
117
|
+
const { data } = await axios.get(`https://token-data.arcblock.io/api/gas-prices?chainId=${chainId}`);
|
|
118
|
+
return (data.fast / 10) * gwei;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
if ([5, '5', 'goerli', 'eth-goerli'].includes(chainId)) {
|
|
122
|
+
const { gasPrice } = await provider.getFeeData();
|
|
123
|
+
return gasPrice.toString();
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// hardhat
|
|
127
|
+
if ([31337, '31337', 'hardhat'].includes(chainId)) {
|
|
128
|
+
return 1 * gwei;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
// TODO: bsc
|
|
132
|
+
// TODO: matic
|
|
133
|
+
// TODO: fantom
|
|
134
|
+
|
|
135
|
+
return 1 * gwei;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function getTxData(params = {}) {
|
|
139
|
+
const { contract, fn, args, value } = params;
|
|
140
|
+
const txData = contract.interface.encodeFunctionData(fn, args);
|
|
141
|
+
|
|
142
|
+
const chainId = await getChainId({ contract });
|
|
143
|
+
|
|
144
|
+
// const gasPrice = await getGasPrice({ provider: contract.provider });
|
|
145
|
+
// const gasPriceAsGwei = Math.ceil(ethers.utils.formatUnits(gasPrice, 'gwei').toString());
|
|
146
|
+
|
|
147
|
+
const extraEtherValueMap = value
|
|
148
|
+
? {
|
|
149
|
+
value,
|
|
150
|
+
}
|
|
151
|
+
: {};
|
|
152
|
+
|
|
153
|
+
const gasLimit = await contract.provider
|
|
154
|
+
.estimateGas({
|
|
155
|
+
to: contract.address,
|
|
156
|
+
data: txData,
|
|
157
|
+
...extraEtherValueMap,
|
|
158
|
+
})
|
|
159
|
+
.then((res) => res.toString());
|
|
160
|
+
|
|
161
|
+
return toBase58(
|
|
162
|
+
Buffer.from(
|
|
163
|
+
JSON.stringify({
|
|
164
|
+
network: chainId,
|
|
165
|
+
tx: {
|
|
166
|
+
to: contract.address,
|
|
167
|
+
value: '0',
|
|
168
|
+
...extraEtherValueMap,
|
|
169
|
+
gasLimit,
|
|
170
|
+
data: txData,
|
|
171
|
+
},
|
|
172
|
+
}),
|
|
173
|
+
'utf-8'
|
|
174
|
+
)
|
|
175
|
+
);
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
const waitForTxReceipt = async ({ contract, txHash }) => {
|
|
179
|
+
let tx = {};
|
|
180
|
+
let receipt = {};
|
|
181
|
+
const txHashTemp = txHash;
|
|
182
|
+
|
|
183
|
+
await waitFor(
|
|
184
|
+
async () => {
|
|
185
|
+
// ethers getTransaction
|
|
186
|
+
tx = await contract.provider.getTransaction(txHashTemp);
|
|
187
|
+
return !!tx?.blockNumber;
|
|
188
|
+
},
|
|
189
|
+
{ interval: 3000, timeout: 30 * 60 * 1000 }
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
await waitFor(
|
|
193
|
+
async () => {
|
|
194
|
+
// ethers getTransactionReceipt
|
|
195
|
+
const originReceipt = await contract.provider.getTransactionReceipt(txHashTemp);
|
|
196
|
+
receipt = {
|
|
197
|
+
...originReceipt,
|
|
198
|
+
parseLog: originReceipt?.logs?.map((log) => {
|
|
199
|
+
try {
|
|
200
|
+
return contract.interface.parseLog(log);
|
|
201
|
+
} catch (_error) {
|
|
202
|
+
return log;
|
|
203
|
+
}
|
|
204
|
+
}),
|
|
205
|
+
};
|
|
206
|
+
return !!receipt?.blockNumber;
|
|
207
|
+
},
|
|
208
|
+
{ interval: 3000, timeout: 30 * 60 * 1000 }
|
|
209
|
+
);
|
|
210
|
+
|
|
211
|
+
return receipt;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
const onContractFilter = async ({ contract, fn, onSuccess }) => {
|
|
215
|
+
contract.provider.on(
|
|
216
|
+
{
|
|
217
|
+
address: contract.address,
|
|
218
|
+
topics: [contract.interface.getEventTopic(upperFirst(fn))],
|
|
219
|
+
},
|
|
220
|
+
async (res) => {
|
|
221
|
+
await onSuccess(res);
|
|
222
|
+
}
|
|
223
|
+
);
|
|
224
|
+
};
|
|
225
|
+
|
|
226
|
+
// @private
|
|
227
|
+
const getChainIdByChainName = (chainName) => {
|
|
228
|
+
return keyBy(
|
|
229
|
+
{
|
|
230
|
+
...CHAIN_MAP,
|
|
231
|
+
...CUSTOM_CHAIN_MAP,
|
|
232
|
+
},
|
|
233
|
+
'networkName'
|
|
234
|
+
)[chainName].chainId;
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
const getChainId = async ({ contract }) => {
|
|
238
|
+
const chainId = await contract.provider.getNetwork().then((res) => res.chainId);
|
|
239
|
+
return `${chainId}`;
|
|
240
|
+
};
|
|
241
|
+
|
|
242
|
+
const setupContractEnv = ({ customEvmChainList, isLocal: _isLocal = false }) => {
|
|
243
|
+
customEvmChainList.forEach((chain) => {
|
|
244
|
+
const { chainId } = chain;
|
|
245
|
+
CUSTOM_CHAIN_MAP[chainId] = chain;
|
|
246
|
+
});
|
|
247
|
+
isLocal = _isLocal;
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
const getChainInfo = (chainId) => {
|
|
251
|
+
return {
|
|
252
|
+
...CHAIN_MAP[chainId],
|
|
253
|
+
...CUSTOM_CHAIN_MAP[chainId],
|
|
254
|
+
};
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
const getExplorerUrl = (chainId) => {
|
|
258
|
+
const { explorer } = getChainInfo(chainId);
|
|
259
|
+
|
|
260
|
+
return `${explorer}`;
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
const getAddressExplorerUrl = ({ chainId, hash }) => {
|
|
264
|
+
return `${getExplorerUrl(chainId)}/address/${hash}`;
|
|
265
|
+
};
|
|
266
|
+
|
|
267
|
+
const getBlockExplorerUrl = ({ chainId, blockletNumber }) => {
|
|
268
|
+
return `${getExplorerUrl(chainId)}/block/${blockletNumber}`;
|
|
269
|
+
};
|
|
270
|
+
|
|
271
|
+
const getTxExplorerUrl = ({ chainId, hash }) => {
|
|
272
|
+
return `${getExplorerUrl(chainId)}/tx/${hash}`;
|
|
273
|
+
};
|
|
274
|
+
|
|
275
|
+
const getCloneContractArgs = ({
|
|
276
|
+
ownerAddress,
|
|
277
|
+
baseImageURI,
|
|
278
|
+
contractName,
|
|
279
|
+
contractSymbol = '',
|
|
280
|
+
contractDescription,
|
|
281
|
+
totalLimit = 0,
|
|
282
|
+
price = '0',
|
|
283
|
+
transferTokenAddress,
|
|
284
|
+
} = {}) => {
|
|
285
|
+
const params = [
|
|
286
|
+
ownerAddress,
|
|
287
|
+
baseImageURI,
|
|
288
|
+
contractName,
|
|
289
|
+
contractSymbol,
|
|
290
|
+
contractDescription,
|
|
291
|
+
totalLimit,
|
|
292
|
+
price,
|
|
293
|
+
transferTokenAddress || ownerAddress,
|
|
294
|
+
];
|
|
295
|
+
return params;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
const getEvmChainList = () => {
|
|
299
|
+
try {
|
|
300
|
+
// eslint-disable-next-line global-require
|
|
301
|
+
let defaultChainList = require('./EvmChainList.json');
|
|
302
|
+
if (isLocal) {
|
|
303
|
+
defaultChainList = [
|
|
304
|
+
...defaultChainList,
|
|
305
|
+
// eslint-disable-next-line global-require
|
|
306
|
+
...require('./EvmChainList.local.json'),
|
|
307
|
+
];
|
|
308
|
+
}
|
|
309
|
+
// CUSTOM_CHAIN_MAP is setup by setupContractEnv
|
|
310
|
+
if (Object.keys(CUSTOM_CHAIN_MAP).length > 0) {
|
|
311
|
+
defaultChainList = defaultChainList.map((item) => {
|
|
312
|
+
const { chainId } = item;
|
|
313
|
+
if (CUSTOM_CHAIN_MAP[chainId]) {
|
|
314
|
+
// override
|
|
315
|
+
return {
|
|
316
|
+
...item,
|
|
317
|
+
...pick(CUSTOM_CHAIN_MAP[chainId], ['enable', 'defaultRPC', 'explorer']),
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
return item;
|
|
321
|
+
});
|
|
322
|
+
}
|
|
323
|
+
return defaultChainList;
|
|
324
|
+
} catch (error) {
|
|
325
|
+
// do nothing
|
|
326
|
+
}
|
|
327
|
+
return [];
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
module.exports.getContract = getContract;
|
|
331
|
+
module.exports.getContractFactory = getContractFactory;
|
|
332
|
+
module.exports.getTxData = getTxData;
|
|
333
|
+
module.exports.getGasPrice = getGasPrice;
|
|
334
|
+
module.exports.waitForTxReceipt = waitForTxReceipt;
|
|
335
|
+
module.exports.onContractFilter = onContractFilter;
|
|
336
|
+
module.exports.getChainId = getChainId;
|
|
337
|
+
module.exports.getChainInfo = getChainInfo;
|
|
338
|
+
module.exports.getBlockExplorerUrl = getBlockExplorerUrl;
|
|
339
|
+
module.exports.getTxExplorerUrl = getTxExplorerUrl;
|
|
340
|
+
module.exports.getAddressExplorerUrl = getAddressExplorerUrl;
|
|
341
|
+
module.exports.getCloneContractArgs = getCloneContractArgs;
|
|
342
|
+
module.exports.getEvmChainList = getEvmChainList;
|
|
343
|
+
module.exports.setupContractEnv = setupContractEnv;
|
|
344
|
+
module.exports.getChainIdByChainName = getChainIdByChainName;
|