@arcblock/erc721did-contract 0.3.1 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/lib/cjs/ERC721DID.json +735 -0
- package/lib/cjs/ERC721DIDFactory.json +165 -0
- package/lib/{EvmChainList.json → cjs/EvmChainList.json} +23 -19
- package/lib/{contract.js → cjs/contract.js} +91 -66
- 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 +1414 -0
- package/package.json +26 -15
- package/lib/ERC721DID.json +0 -725
- package/lib/ERC721DIDFactory.json +0 -155
|
@@ -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": "0x608060405234801561001057600080fd5b5060405161091438038061091483398101604081905261002f916100e2565b6100383361005d565b600180546001600160a01b0319166001600160a01b039290921691909117905561010b565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60006001600160a01b0382165b92915050565b6100c9816100ad565b81146100d457600080fd5b50565b80516100ba816100c0565b6000602082840312156100f7576100f7600080fd5b600061010384846100d7565b949350505050565b6107fa8061011a6000396000f3fe608060405234801561001057600080fd5b50600436106100625760003560e01c80635c60da1b14610083578063715018a6146100ac5780638da5cb5b146100b6578063c137ecd7146100c7578063d784d426146100da578063f2fde38b146100ed575b60405162461bcd60e51b815260040161007a90610352565b60405180910390fd5b600154610096906001600160a01b031681565b6040516100a39190610388565b60405180910390f35b6100b4610100565b005b6000546001600160a01b0316610096565b6100b46100d53660046104c4565b610114565b6100b46100e83660046105e3565b6101dd565b6100b46100fb3660046105e3565b610207565b610108610241565b610112600061026b565b565b60015460009061012c906001600160a01b03166102bb565b604051637bced14560e11b81529091506001600160a01b0382169063f79da28a90610169908c908c908c908c908c908c908c908c9060040161066c565b600060405180830381600087803b15801561018357600080fd5b505af1158015610197573d6000803e3d6000fd5b505050507f1449abf21e49fd025f33495e77f7b1461caefdd3d4bb646424a3f445c4576a5b816040516101ca9190610388565b60405180910390a1505050505050505050565b6101e5610241565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b61020f610241565b6001600160a01b0381166102355760405162461bcd60e51b815260040161007a906106ff565b61023e8161026b565b50565b6000546001600160a01b031633146101125760405162461bcd60e51b815260040161007a90610779565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b0381166103275760405162461bcd60e51b815260040161007a906107b4565b919050565b600f8152602081016e2ab735b737bb90333ab731ba34b7b760891b815290505b60200190565b602080825281016103628161032c565b92915050565b60006001600160a01b038216610362565b61038281610368565b82525050565b602081016103628284610379565b61039f81610368565b811461023e57600080fd5b803561036281610396565b634e487b7160e01b600052604160045260246000fd5b601f19601f830116810181811067ffffffffffffffff821117156103f1576103f16103b5565b6040525050565b600061040360405190565b905061032782826103cb565b600067ffffffffffffffff821115610429576104296103b5565b601f19601f83011660200192915050565b82818337506000910152565b60006104596104548461040f565b6103f8565b90508281526020810184848401111561047457610474600080fd5b61047f84828561043a565b509392505050565b600082601f83011261049b5761049b600080fd5b81356104ab848260208601610446565b949350505050565b8061039f565b8035610362816104b3565b600080600080600080600080610100898b0312156104e4576104e4600080fd5b60006104f08b8b6103aa565b985050602089013567ffffffffffffffff81111561051057610510600080fd5b61051c8b828c01610487565b975050604089013567ffffffffffffffff81111561053c5761053c600080fd5b6105488b828c01610487565b965050606089013567ffffffffffffffff81111561056857610568600080fd5b6105748b828c01610487565b955050608089013567ffffffffffffffff81111561059457610594600080fd5b6105a08b828c01610487565b94505060a06105b18b828c016104b9565b93505060c06105c28b828c016104b9565b92505060e06105d38b828c016103aa565b9150509295985092959890939650565b6000602082840312156105f8576105f8600080fd5b60006104ab84846103aa565b60005b8381101561061f578181015183820152602001610607565b8381111561062e576000848401525b50505050565b600061063e825190565b808452602084019350610655818560208601610604565b601f01601f19169290920192915050565b80610382565b610100810161067b828b610379565b818103602083015261068d818a610634565b905081810360408301526106a18189610634565b905081810360608301526106b58188610634565b905081810360808301526106c98187610634565b90506106d860a0830186610666565b6106e560c0830185610666565b6106f260e0830184610379565b9998505050505050505050565b6020808252810161036281602681527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160208201526564647265737360d01b604082015260600190565b60208082527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572910190815261034c565b6020808252810161036281610749565b601681526020810175115490cc4c4d8dce8818dc99585d194819985a5b195960521b8152905061034c565b602080825281016103628161078956fea26469706673582212206b3b4db5959cc750e7d240d269ad0f1ecf46bc9c3fedc4fa170569c318499f3c64736f6c63430008090033",
|
|
162
|
+
"deployedBytecode": "0x608060405234801561001057600080fd5b50600436106100625760003560e01c80635c60da1b14610083578063715018a6146100ac5780638da5cb5b146100b6578063c137ecd7146100c7578063d784d426146100da578063f2fde38b146100ed575b60405162461bcd60e51b815260040161007a90610352565b60405180910390fd5b600154610096906001600160a01b031681565b6040516100a39190610388565b60405180910390f35b6100b4610100565b005b6000546001600160a01b0316610096565b6100b46100d53660046104c4565b610114565b6100b46100e83660046105e3565b6101dd565b6100b46100fb3660046105e3565b610207565b610108610241565b610112600061026b565b565b60015460009061012c906001600160a01b03166102bb565b604051637bced14560e11b81529091506001600160a01b0382169063f79da28a90610169908c908c908c908c908c908c908c908c9060040161066c565b600060405180830381600087803b15801561018357600080fd5b505af1158015610197573d6000803e3d6000fd5b505050507f1449abf21e49fd025f33495e77f7b1461caefdd3d4bb646424a3f445c4576a5b816040516101ca9190610388565b60405180910390a1505050505050505050565b6101e5610241565b600180546001600160a01b0319166001600160a01b0392909216919091179055565b61020f610241565b6001600160a01b0381166102355760405162461bcd60e51b815260040161007a906106ff565b61023e8161026b565b50565b6000546001600160a01b031633146101125760405162461bcd60e51b815260040161007a90610779565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000763d602d80600a3d3981f3363d3d373d3d3d363d730000008260601b60e81c176000526e5af43d82803e903d91602b57fd5bf38260781b17602052603760096000f090506001600160a01b0381166103275760405162461bcd60e51b815260040161007a906107b4565b919050565b600f8152602081016e2ab735b737bb90333ab731ba34b7b760891b815290505b60200190565b602080825281016103628161032c565b92915050565b60006001600160a01b038216610362565b61038281610368565b82525050565b602081016103628284610379565b61039f81610368565b811461023e57600080fd5b803561036281610396565b634e487b7160e01b600052604160045260246000fd5b601f19601f830116810181811067ffffffffffffffff821117156103f1576103f16103b5565b6040525050565b600061040360405190565b905061032782826103cb565b600067ffffffffffffffff821115610429576104296103b5565b601f19601f83011660200192915050565b82818337506000910152565b60006104596104548461040f565b6103f8565b90508281526020810184848401111561047457610474600080fd5b61047f84828561043a565b509392505050565b600082601f83011261049b5761049b600080fd5b81356104ab848260208601610446565b949350505050565b8061039f565b8035610362816104b3565b600080600080600080600080610100898b0312156104e4576104e4600080fd5b60006104f08b8b6103aa565b985050602089013567ffffffffffffffff81111561051057610510600080fd5b61051c8b828c01610487565b975050604089013567ffffffffffffffff81111561053c5761053c600080fd5b6105488b828c01610487565b965050606089013567ffffffffffffffff81111561056857610568600080fd5b6105748b828c01610487565b955050608089013567ffffffffffffffff81111561059457610594600080fd5b6105a08b828c01610487565b94505060a06105b18b828c016104b9565b93505060c06105c28b828c016104b9565b92505060e06105d38b828c016103aa565b9150509295985092959890939650565b6000602082840312156105f8576105f8600080fd5b60006104ab84846103aa565b60005b8381101561061f578181015183820152602001610607565b8381111561062e576000848401525b50505050565b600061063e825190565b808452602084019350610655818560208601610604565b601f01601f19169290920192915050565b80610382565b610100810161067b828b610379565b818103602083015261068d818a610634565b905081810360408301526106a18189610634565b905081810360608301526106b58188610634565b905081810360808301526106c98187610634565b90506106d860a0830186610666565b6106e560c0830185610666565b6106f260e0830184610379565b9998505050505050505050565b6020808252810161036281602681527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160208201526564647265737360d01b604082015260600190565b60208082527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572910190815261034c565b6020808252810161036281610749565b601681526020810175115490cc4c4d8dce8818dc99585d194819985a5b195960521b8152905061034c565b602080825281016103628161078956fea26469706673582212206b3b4db5959cc750e7d240d269ad0f1ecf46bc9c3fedc4fa170569c318499f3c64736f6c63430008090033",
|
|
163
|
+
"linkReferences": {},
|
|
164
|
+
"deployedLinkReferences": {}
|
|
165
|
+
}
|
|
@@ -2,49 +2,53 @@
|
|
|
2
2
|
{
|
|
3
3
|
"chainId": "5",
|
|
4
4
|
"chainName": "Goerli",
|
|
5
|
-
"contractFactoryAddress": "
|
|
5
|
+
"contractFactoryAddress": "0x4c093eAf8d569f6b2dC5a217D25cb3f0B60918C3",
|
|
6
6
|
"isTest": true,
|
|
7
7
|
"networkName": "goerli",
|
|
8
8
|
"symbol": "ETH (Goerli)",
|
|
9
9
|
"defaultRPC": "https://goerli.infura.io/v3/31276ea517a941c5b91d914fab83494e",
|
|
10
10
|
"explorer": "https://goerli.etherscan.io",
|
|
11
11
|
"icon": "eth",
|
|
12
|
-
"enable": true
|
|
12
|
+
"enable": true,
|
|
13
|
+
"decimal": 18
|
|
13
14
|
},
|
|
14
15
|
{
|
|
15
16
|
"chainId": "84531",
|
|
16
17
|
"chainName": "Base Goerli",
|
|
17
|
-
"contractFactoryAddress": "
|
|
18
|
+
"contractFactoryAddress": "0xe83044a18dAb8F28F99F22f413C3856A0e39B153",
|
|
18
19
|
"isTest": true,
|
|
19
20
|
"networkName": "base-goerli",
|
|
20
21
|
"symbol": "ETH (Base Goerli)",
|
|
21
22
|
"defaultRPC": "https://goerli.base.org",
|
|
22
23
|
"explorer": "https://goerli.basescan.org",
|
|
23
24
|
"icon": "base",
|
|
24
|
-
"enable": true
|
|
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": "tBNB",
|
|
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
|
|
25
40
|
},
|
|
26
41
|
{
|
|
27
42
|
"chainId": "11155111",
|
|
28
43
|
"chainName": "Sepolia",
|
|
29
|
-
"contractFactoryAddress": "
|
|
44
|
+
"contractFactoryAddress": "0xf13AAEF9071498eE61D0e6390970e0629c60a53C",
|
|
30
45
|
"isTest": true,
|
|
31
46
|
"networkName": "sepolia",
|
|
32
47
|
"symbol": "ETH (Sepolia)",
|
|
33
48
|
"defaultRPC": "https://sepolia.infura.io/v3/31276ea517a941c5b91d914fab83494e",
|
|
34
49
|
"explorer": "https://sepolia.etherscan.io",
|
|
35
50
|
"icon": "eth",
|
|
36
|
-
"enable": false
|
|
37
|
-
|
|
38
|
-
{
|
|
39
|
-
"chainId": "97",
|
|
40
|
-
"chainName": "BNB (Binance Smart Chain)",
|
|
41
|
-
"contractFactoryAddress": "0xA44112bA00F1a4bc20374C99EC9547C6FA925db7",
|
|
42
|
-
"isTest": true,
|
|
43
|
-
"networkName": "bsc-test",
|
|
44
|
-
"symbol": "BNB",
|
|
45
|
-
"defaultRPC": "https://bsc.getblock.io/13042277-cdaa-47dc-acda-5a0900eaf4ae/testnet",
|
|
46
|
-
"explorer": "https://testnet.bscscan.com",
|
|
47
|
-
"icon": "bnb",
|
|
48
|
-
"enable": true
|
|
51
|
+
"enable": false,
|
|
52
|
+
"decimal": 18
|
|
49
53
|
}
|
|
50
|
-
]
|
|
54
|
+
]
|
|
@@ -7,10 +7,11 @@ const waitFor = require('p-wait-for');
|
|
|
7
7
|
const { toBase58 } = require('@ocap/util');
|
|
8
8
|
const upperFirst = require('lodash/upperFirst');
|
|
9
9
|
const keyBy = require('lodash/keyBy');
|
|
10
|
+
const pick = require('lodash/pick');
|
|
10
11
|
const ERC721DID = require('./ERC721DID.json');
|
|
11
12
|
const ERC721DIDFactory = require('./ERC721DIDFactory.json');
|
|
12
13
|
|
|
13
|
-
const
|
|
14
|
+
const INFURA_PROJECT_ID = '31276ea517a941c5b91d914fab83494e';
|
|
14
15
|
|
|
15
16
|
const CHAIN_MAP = {
|
|
16
17
|
1: {
|
|
@@ -22,6 +23,7 @@ const CHAIN_MAP = {
|
|
|
22
23
|
explorer: 'https://etherscan.io',
|
|
23
24
|
icon: 'eth',
|
|
24
25
|
enable: true,
|
|
26
|
+
decimal: 18,
|
|
25
27
|
},
|
|
26
28
|
5: {
|
|
27
29
|
networkName: 'goerli',
|
|
@@ -32,6 +34,7 @@ const CHAIN_MAP = {
|
|
|
32
34
|
explorer: 'https://goerli.etherscan.io',
|
|
33
35
|
icon: 'eth',
|
|
34
36
|
enable: true,
|
|
37
|
+
decimal: 18,
|
|
35
38
|
},
|
|
36
39
|
31337: {
|
|
37
40
|
networkName: 'localhost',
|
|
@@ -42,6 +45,7 @@ const CHAIN_MAP = {
|
|
|
42
45
|
explorer: 'http://localhost:8545',
|
|
43
46
|
icon: 'eth',
|
|
44
47
|
enable: true,
|
|
48
|
+
decimal: 18,
|
|
45
49
|
},
|
|
46
50
|
84531: {
|
|
47
51
|
networkName: 'base-goerli',
|
|
@@ -52,6 +56,7 @@ const CHAIN_MAP = {
|
|
|
52
56
|
explorer: 'https://goerli.basescan.org',
|
|
53
57
|
icon: 'base',
|
|
54
58
|
enable: true,
|
|
59
|
+
decimal: 18,
|
|
55
60
|
},
|
|
56
61
|
11155111: {
|
|
57
62
|
networkName: 'sepolia',
|
|
@@ -62,26 +67,25 @@ const CHAIN_MAP = {
|
|
|
62
67
|
explorer: 'https://sepolia.etherscan.io',
|
|
63
68
|
icon: 'eth',
|
|
64
69
|
enable: false, // FIXME
|
|
70
|
+
decimal: 18,
|
|
65
71
|
},
|
|
66
72
|
97: {
|
|
67
73
|
networkName: 'bsc-test',
|
|
68
74
|
chainName: 'BNB (Binance Smart Chain)',
|
|
69
75
|
chainId: '97',
|
|
70
|
-
symbol: '
|
|
76
|
+
symbol: 'tBNB',
|
|
71
77
|
defaultRPC: 'https://bsc.getblock.io/13042277-cdaa-47dc-acda-5a0900eaf4ae/testnet',
|
|
72
78
|
explorer: 'https://testnet.bscscan.com',
|
|
73
79
|
icon: 'bnb',
|
|
74
80
|
enable: true,
|
|
81
|
+
decimal: 18,
|
|
75
82
|
},
|
|
76
83
|
};
|
|
77
84
|
|
|
78
85
|
const CUSTOM_CHAIN_MAP = {};
|
|
79
86
|
|
|
80
|
-
let isLocal = false;
|
|
81
|
-
|
|
82
87
|
function getProvider(chainId) {
|
|
83
88
|
const { defaultRPC } = getChainInfo(chainId);
|
|
84
|
-
|
|
85
89
|
return new ethers.providers.JsonRpcProvider(defaultRPC);
|
|
86
90
|
}
|
|
87
91
|
|
|
@@ -129,8 +133,8 @@ async function getGasPrice({ provider }) {
|
|
|
129
133
|
return 1 * gwei;
|
|
130
134
|
}
|
|
131
135
|
|
|
132
|
-
async function getTxData(params = {}) {
|
|
133
|
-
const { contract, fn, args } = params;
|
|
136
|
+
async function getTxData(params = {}, type = 'arcblock') {
|
|
137
|
+
const { contract, fn, args, value } = params;
|
|
134
138
|
const txData = contract.interface.encodeFunctionData(fn, args);
|
|
135
139
|
|
|
136
140
|
const chainId = await getChainId({ contract });
|
|
@@ -138,27 +142,42 @@ async function getTxData(params = {}) {
|
|
|
138
142
|
// const gasPrice = await getGasPrice({ provider: contract.provider });
|
|
139
143
|
// const gasPriceAsGwei = Math.ceil(ethers.utils.formatUnits(gasPrice, 'gwei').toString());
|
|
140
144
|
|
|
145
|
+
const extraEtherValueMap = value
|
|
146
|
+
? {
|
|
147
|
+
value,
|
|
148
|
+
}
|
|
149
|
+
: {};
|
|
150
|
+
|
|
141
151
|
const gasLimit = await contract.provider
|
|
142
152
|
.estimateGas({
|
|
143
153
|
to: contract.address,
|
|
144
154
|
data: txData,
|
|
155
|
+
...extraEtherValueMap,
|
|
145
156
|
})
|
|
146
157
|
.then((res) => res.toString());
|
|
147
158
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
if (type === 'arcblock') {
|
|
160
|
+
return toBase58(
|
|
161
|
+
Buffer.from(
|
|
162
|
+
JSON.stringify({
|
|
163
|
+
network: chainId,
|
|
164
|
+
tx: {
|
|
165
|
+
to: contract.address,
|
|
166
|
+
value: '0',
|
|
167
|
+
...extraEtherValueMap,
|
|
168
|
+
gasLimit,
|
|
169
|
+
data: txData,
|
|
170
|
+
},
|
|
171
|
+
}),
|
|
172
|
+
'utf-8'
|
|
173
|
+
)
|
|
174
|
+
);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return {
|
|
178
|
+
txData,
|
|
179
|
+
gasLimit,
|
|
180
|
+
};
|
|
162
181
|
}
|
|
163
182
|
|
|
164
183
|
const waitForTxReceipt = async ({ contract, txHash }) => {
|
|
@@ -225,12 +244,11 @@ const getChainId = async ({ contract }) => {
|
|
|
225
244
|
return `${chainId}`;
|
|
226
245
|
};
|
|
227
246
|
|
|
228
|
-
const setupContractEnv = ({ customEvmChainList
|
|
247
|
+
const setupContractEnv = ({ customEvmChainList }) => {
|
|
229
248
|
customEvmChainList.forEach((chain) => {
|
|
230
249
|
const { chainId } = chain;
|
|
231
250
|
CUSTOM_CHAIN_MAP[chainId] = chain;
|
|
232
251
|
});
|
|
233
|
-
isLocal = _isLocal;
|
|
234
252
|
};
|
|
235
253
|
|
|
236
254
|
const getChainInfo = (chainId) => {
|
|
@@ -265,57 +283,64 @@ const getCloneContractArgs = ({
|
|
|
265
283
|
contractSymbol = '',
|
|
266
284
|
contractDescription,
|
|
267
285
|
totalLimit = 0,
|
|
286
|
+
price = '0',
|
|
287
|
+
transferTokenAddress,
|
|
268
288
|
} = {}) => {
|
|
269
|
-
const params = [
|
|
289
|
+
const params = [
|
|
290
|
+
ownerAddress,
|
|
291
|
+
baseImageURI,
|
|
292
|
+
contractName,
|
|
293
|
+
contractSymbol,
|
|
294
|
+
contractDescription,
|
|
295
|
+
totalLimit,
|
|
296
|
+
price,
|
|
297
|
+
transferTokenAddress || ownerAddress,
|
|
298
|
+
];
|
|
270
299
|
return params;
|
|
271
300
|
};
|
|
272
301
|
|
|
273
302
|
const getEvmChainList = () => {
|
|
303
|
+
// eslint-disable-next-line global-require
|
|
304
|
+
let defaultChainList = require('./EvmChainList.json');
|
|
274
305
|
try {
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
// eslint-disable-next-line global-require
|
|
281
|
-
...require('./EvmChainList.local.json'),
|
|
282
|
-
];
|
|
283
|
-
}
|
|
284
|
-
// CUSTOM_CHAIN_MAP is setup by setupContractEnv
|
|
285
|
-
if (Object.keys(CUSTOM_CHAIN_MAP).length > 0) {
|
|
286
|
-
defaultChainList = defaultChainList.map((item) => {
|
|
287
|
-
const { chainId } = item;
|
|
288
|
-
if (CUSTOM_CHAIN_MAP[chainId]) {
|
|
289
|
-
// override
|
|
290
|
-
return {
|
|
291
|
-
...item,
|
|
292
|
-
...CUSTOM_CHAIN_MAP[chainId],
|
|
293
|
-
};
|
|
294
|
-
}
|
|
295
|
-
return item;
|
|
296
|
-
});
|
|
297
|
-
}
|
|
298
|
-
return defaultChainList;
|
|
306
|
+
defaultChainList = [
|
|
307
|
+
...defaultChainList,
|
|
308
|
+
// eslint-disable-next-line global-require
|
|
309
|
+
...require('./EvmChainList.local.json'),
|
|
310
|
+
];
|
|
299
311
|
} catch (error) {
|
|
300
312
|
// do nothing
|
|
301
313
|
}
|
|
302
|
-
|
|
314
|
+
// CUSTOM_CHAIN_MAP is setup by setupContractEnv
|
|
315
|
+
if (Object.keys(CUSTOM_CHAIN_MAP).length > 0) {
|
|
316
|
+
defaultChainList = defaultChainList.map((item) => {
|
|
317
|
+
const { chainId } = item;
|
|
318
|
+
if (CUSTOM_CHAIN_MAP[chainId]) {
|
|
319
|
+
// override
|
|
320
|
+
return {
|
|
321
|
+
...item,
|
|
322
|
+
...pick(CUSTOM_CHAIN_MAP[chainId], ['enable', 'defaultRPC', 'explorer']),
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
return item;
|
|
326
|
+
});
|
|
327
|
+
}
|
|
328
|
+
return defaultChainList;
|
|
303
329
|
};
|
|
304
330
|
|
|
305
|
-
module.exports =
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
};
|
|
331
|
+
module.exports.getContract = getContract;
|
|
332
|
+
module.exports.getContractFactory = getContractFactory;
|
|
333
|
+
module.exports.getTxData = getTxData;
|
|
334
|
+
module.exports.getGasPrice = getGasPrice;
|
|
335
|
+
module.exports.waitForTxReceipt = waitForTxReceipt;
|
|
336
|
+
module.exports.onContractFilter = onContractFilter;
|
|
337
|
+
module.exports.getChainId = getChainId;
|
|
338
|
+
module.exports.getChainInfo = getChainInfo;
|
|
339
|
+
module.exports.getBlockExplorerUrl = getBlockExplorerUrl;
|
|
340
|
+
module.exports.getTxExplorerUrl = getTxExplorerUrl;
|
|
341
|
+
module.exports.getAddressExplorerUrl = getAddressExplorerUrl;
|
|
342
|
+
module.exports.getCloneContractArgs = getCloneContractArgs;
|
|
343
|
+
module.exports.getEvmChainList = getEvmChainList;
|
|
344
|
+
module.exports.setupContractEnv = setupContractEnv;
|
|
345
|
+
module.exports.getChainIdByChainName = getChainIdByChainName;
|
|
346
|
+
module.exports.ethers = ethers;
|