Skip to content

Commit 5e9e4c7

Browse files
committed
fix: rationalize configs
1 parent f4811a6 commit 5e9e4c7

14 files changed

+12319
-403
lines changed

‎.env-cmdrc

-17
This file was deleted.

‎cli/lib/constants.mjs

+3-30
Original file line numberDiff line numberDiff line change
@@ -14,33 +14,6 @@ export const TX_TYPES = {
1414
export const APPROVE_AMOUNT =
1515
'115792089237316195423570985008687907853269984665640564039457584007913129639935';
1616

17-
export const ENVIRONMENTS = {
18-
mainnet: {
19-
name: 'Mainnet',
20-
chainId: 1,
21-
clientApiUrl: '',
22-
optimistApiUrl: '',
23-
optimistWsUrl: '',
24-
},
25-
ropsten: {
26-
name: 'Ropsten',
27-
chainId: 3,
28-
clientApiUrl: 'https://client1.testnet.nightfall3.com',
29-
optimistApiUrl: 'https://optimist1.testnet.nightfall3.com',
30-
optimistWsUrl: 'wss://optimist1-ws.testnet.nightfall3.com',
31-
},
32-
rinkeby: {
33-
name: 'Rinkeby',
34-
chainId: 4,
35-
clientApiUrl: '',
36-
optimistApiUrl: '',
37-
optimistWsUrl: '',
38-
},
39-
localhost: {
40-
name: 'Localhost',
41-
chainId: 4378921,
42-
clientApiUrl: 'http://localhost:8080',
43-
optimistApiUrl: 'http://localhost:8081',
44-
optimistWsUrl: 'ws://localhost:8082',
45-
},
46-
};
17+
export const DEFAULT_FEE = 10;
18+
export const DEFAULT_PROPOSER_BOND = 10;
19+
export const DEFAULT_BLOCK_STAKE = 1;

‎cli/lib/environment.mjs

+1-36
Original file line numberDiff line numberDiff line change
@@ -42,20 +42,6 @@ const SUPPORTED_ENVIRONMENTS = {
4242
},
4343
};
4444

45-
const ContractNames = {
46-
Shield: 'Shield',
47-
Proposers: 'Proposers',
48-
Challenges: 'Challenges',
49-
State: 'State',
50-
};
51-
52-
const CONTRACT_ADDRESSES = {
53-
[ContractNames.Shield]: '',
54-
[ContractNames.Proposers]: '',
55-
[ContractNames.Challenges]: '',
56-
[ContractNames.State]: '',
57-
};
58-
5945
const currentEnvironment = {
6046
clientApiUrl: '',
6147
optimistApiUrl: '',
@@ -87,26 +73,6 @@ function isEnvironmentSupportedByNetworkName(env) {
8773
return false;
8874
}
8975

90-
/**
91-
* Stores the addresses of NF contract by type
92-
* @param {Object} nf3 - Nightfall instance to retrieve contract addresses from
93-
* @param {String} contractName - Name of contract
94-
*/
95-
async function setContractAddress(nf3, contractName) {
96-
CONTRACT_ADDRESSES[contractName] = await nf3.getContractAddress(contractName);
97-
}
98-
99-
/**
100-
* Stores the addresses of NF contracts
101-
* @param {Object} nf3 - Nightfall instance to retrieve contract addresses from
102-
*/
103-
async function setContractAddresses(nf3) {
104-
setContractAddress(nf3, ContractNames.Shield);
105-
setContractAddress(nf3, ContractNames.Proposers);
106-
setContractAddress(nf3, ContractNames.Challenges);
107-
setContractAddress(nf3, ContractNames.State);
108-
}
109-
11076
/**
11177
* Stores the NF client API URL
11278
* @param {String} baseApiUrl - client API URL
@@ -192,9 +158,8 @@ function setEnvironment(env) {
192158
*/
193159
function getCurrentEnvironment() {
194160
return {
195-
contracts: CONTRACT_ADDRESSES,
196161
currentEnvironment,
197162
};
198163
}
199164

200-
export { setEnvironment, getCurrentEnvironment, getSupportedEnvironments, setContractAddresses };
165+
export { setEnvironment, getCurrentEnvironment, getSupportedEnvironments };

‎cli/lib/nf3.mjs

+14-7
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { approve } from './tokens.mjs';
77
import erc20 from './abis/ERC20.mjs';
88
import erc721 from './abis/ERC721.mjs';
99
import erc1155 from './abis/ERC1155.mjs';
10-
import { ENVIRONMENTS } from './constants.mjs';
10+
import { DEFAULT_BLOCK_STAKE, DEFAULT_PROPOSER_BOND, DEFAULT_FEE } from './constants.mjs';
1111

1212
/**
1313
@class
@@ -46,11 +46,11 @@ class Nf3 {
4646

4747
zkpKeys;
4848

49-
defaultFee = 10;
49+
defaultFee = DEFAULT_FEE;
5050

51-
PROPOSER_BOND = 10;
51+
PROPOSER_BOND = DEFAULT_PROPOSER_BOND;
5252

53-
BLOCK_STAKE = 1;
53+
BLOCK_STAKE = DEFAULT_BLOCK_STAKE;
5454

5555
nonce = 0;
5656

@@ -64,9 +64,16 @@ class Nf3 {
6464

6565
currentEnvironment;
6666

67-
notConfirmed = 0;
68-
69-
constructor(web3WsUrl, ethereumSigningKey, environment = ENVIRONMENTS.localhost, zkpKeys) {
67+
constructor(
68+
web3WsUrl,
69+
ethereumSigningKey,
70+
environment = {
71+
clientApiUrl: 'http://localhost:8080',
72+
optimistApiUrl: 'http://localhost:8081',
73+
optimistWsUrl: 'ws://localhost:8082',
74+
},
75+
zkpKeys,
76+
) {
7077
this.clientBaseUrl = environment.clientApiUrl;
7178
this.optimistBaseUrl = environment.optimistApiUrl;
7279
this.optimistWsUrl = environment.optimistWsUrl;

‎config/default.js

+72
Original file line numberDiff line numberDiff line change
@@ -128,4 +128,76 @@ module.exports = {
128128
U: BigInt(5), // non square in Fp
129129
},
130130
MAX_QUEUE: 5,
131+
ENVIRONMENTS: {
132+
mainnet: {
133+
name: 'Mainnet',
134+
chainId: 1,
135+
clientApiUrl: '',
136+
optimistApiUrl: '',
137+
optimistWsUrl: '',
138+
web3WsUrl: '',
139+
},
140+
ropsten: {
141+
name: 'Ropsten',
142+
chainId: 3,
143+
clientApiUrl: 'https://client1.testnet.nightfall3.com',
144+
optimistApiUrl: 'https://optimist1.testnet.nightfall3.com',
145+
optimistWsUrl: 'wss://optimist1-ws.testnet.nightfall3.com',
146+
web3WsUrl: `${process.env.ROPSTEN_NODE}`,
147+
},
148+
rinkeby: {
149+
name: 'Rinkeby',
150+
chainId: 4,
151+
clientApiUrl: '',
152+
optimistApiUrl: '',
153+
optimistWsUrl: '',
154+
web3WsUrl: '',
155+
},
156+
localhost: {
157+
name: 'Localhost',
158+
chainId: 4378921,
159+
clientApiUrl: 'http://localhost:8080',
160+
optimistApiUrl: 'http://localhost:8081',
161+
optimistWsUrl: 'ws://localhost:8082',
162+
web3WsUrl: 'ws://localhost:8546',
163+
},
164+
},
165+
TEST_OPTIONS: {
166+
tokenId: '0x00',
167+
tokenType: 'ERC20', // it can be 'ERC721' or 'ERC1155'
168+
tokenTypeERC721: 'ERC721',
169+
tokenTypeERC1155: 'ERC1155',
170+
value: 10,
171+
// this is the etherum private key for accounts[0]
172+
privateKey: '0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69e',
173+
gas: 10000000,
174+
gasCosts: 8000000000000000,
175+
fee: 1,
176+
BLOCK_STAKE: 1, // 1 wei
177+
bond: 10, // 10 wei
178+
txPerBlock: 2,
179+
walletTestAddress: '0xfCb059A4dB5B961d3e48706fAC91a55Bad0035C9',
180+
walletTestSigningkey: '0xd42905d0582c476c4b74757be6576ec323d715a0c7dcff231b6348b7ab0190eb',
181+
ethereumSigningKeyUser1: '0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69e',
182+
ethereumAddressUser1: '0x9c8b2276d490141ae1440da660e470e7c0349c63',
183+
ethereumSigningKeyUser2: '0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69e',
184+
ethereumSigningKeyProposer1:
185+
'0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69d',
186+
ethereumSigningKeyProposer2:
187+
'0xd42905d0582c476c4b74757be6576ec323d715a0c7dcff231b6348b7ab0190eb',
188+
ethereumSigningKeyProposer3:
189+
'0xfbc1ee1c7332e2e5a76a99956f50b3ba2639aff73d56477e877ef8390c41e0c6',
190+
ethereumSigningKeyChallenger:
191+
'0xd42905d0582c476c4b74757be6576ec323d715a0c7dcff231b6348b7ab0190eb',
192+
ethereumSigningKeyLiquidityProvider:
193+
'0xfbc1ee1c7332e2e5a76a99956f50b3ba2639aff73d56477e877ef8390c41e0c6',
194+
mnemonicUser1: 'trip differ bamboo bundle bonus luxury strike mad merry muffin nose auction',
195+
mnemonicUser2:
196+
'control series album tribe category saddle prosper enforce moon eternal talk fame',
197+
mnemonicProposer: 'high return hold whale promote payment hat panel reduce oyster ramp mouse',
198+
mnemonicChallenger:
199+
'crush power outer gadget enter maze advance rather divert monster indoor axis',
200+
mnemonicLiquidityProvider:
201+
'smart base soup sister army address member poem point quick save penalty',
202+
},
131203
};

0 commit comments

Comments
 (0)