Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

daveroga/rationalize configs #398

Merged
merged 2 commits into from
Feb 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 0 additions & 17 deletions .env-cmdrc

This file was deleted.

33 changes: 3 additions & 30 deletions cli/lib/constants.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,6 @@ export const TX_TYPES = {
export const APPROVE_AMOUNT =
'115792089237316195423570985008687907853269984665640564039457584007913129639935';

export const ENVIRONMENTS = {
mainnet: {
name: 'Mainnet',
chainId: 1,
clientApiUrl: '',
optimistApiUrl: '',
optimistWsUrl: '',
},
ropsten: {
name: 'Ropsten',
chainId: 3,
clientApiUrl: 'https://client1.testnet.nightfall3.com',
optimistApiUrl: 'https://optimist1.testnet.nightfall3.com',
optimistWsUrl: 'wss://optimist1-ws.testnet.nightfall3.com',
},
rinkeby: {
name: 'Rinkeby',
chainId: 4,
clientApiUrl: '',
optimistApiUrl: '',
optimistWsUrl: '',
},
localhost: {
name: 'Localhost',
chainId: 4378921,
clientApiUrl: 'http://localhost:8080',
optimistApiUrl: 'http://localhost:8081',
optimistWsUrl: 'ws://localhost:8082',
},
};
export const DEFAULT_FEE = 10;
export const DEFAULT_PROPOSER_BOND = 10;
export const DEFAULT_BLOCK_STAKE = 1;
37 changes: 1 addition & 36 deletions cli/lib/environment.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@ const SUPPORTED_ENVIRONMENTS = {
},
};

const ContractNames = {
Shield: 'Shield',
Proposers: 'Proposers',
Challenges: 'Challenges',
State: 'State',
};

const CONTRACT_ADDRESSES = {
[ContractNames.Shield]: '',
[ContractNames.Proposers]: '',
[ContractNames.Challenges]: '',
[ContractNames.State]: '',
};

const currentEnvironment = {
clientApiUrl: '',
optimistApiUrl: '',
Expand Down Expand Up @@ -87,26 +73,6 @@ function isEnvironmentSupportedByNetworkName(env) {
return false;
}

/**
* Stores the addresses of NF contract by type
* @param {Object} nf3 - Nightfall instance to retrieve contract addresses from
* @param {String} contractName - Name of contract
*/
async function setContractAddress(nf3, contractName) {
CONTRACT_ADDRESSES[contractName] = await nf3.getContractAddress(contractName);
}

/**
* Stores the addresses of NF contracts
* @param {Object} nf3 - Nightfall instance to retrieve contract addresses from
*/
async function setContractAddresses(nf3) {
setContractAddress(nf3, ContractNames.Shield);
setContractAddress(nf3, ContractNames.Proposers);
setContractAddress(nf3, ContractNames.Challenges);
setContractAddress(nf3, ContractNames.State);
}

/**
* Stores the NF client API URL
* @param {String} baseApiUrl - client API URL
Expand Down Expand Up @@ -192,9 +158,8 @@ function setEnvironment(env) {
*/
function getCurrentEnvironment() {
return {
contracts: CONTRACT_ADDRESSES,
currentEnvironment,
};
}

export { setEnvironment, getCurrentEnvironment, getSupportedEnvironments, setContractAddresses };
export { setEnvironment, getCurrentEnvironment, getSupportedEnvironments };
21 changes: 14 additions & 7 deletions cli/lib/nf3.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { approve } from './tokens.mjs';
import erc20 from './abis/ERC20.mjs';
import erc721 from './abis/ERC721.mjs';
import erc1155 from './abis/ERC1155.mjs';
import { ENVIRONMENTS } from './constants.mjs';
import { DEFAULT_BLOCK_STAKE, DEFAULT_PROPOSER_BOND, DEFAULT_FEE } from './constants.mjs';

/**
@class
Expand Down Expand Up @@ -46,11 +46,11 @@ class Nf3 {

zkpKeys;

defaultFee = 10;
defaultFee = DEFAULT_FEE;

PROPOSER_BOND = 10;
PROPOSER_BOND = DEFAULT_PROPOSER_BOND;

BLOCK_STAKE = 1;
BLOCK_STAKE = DEFAULT_BLOCK_STAKE;

nonce = 0;

Expand All @@ -64,9 +64,16 @@ class Nf3 {

currentEnvironment;

notConfirmed = 0;

constructor(web3WsUrl, ethereumSigningKey, environment = ENVIRONMENTS.localhost, zkpKeys) {
constructor(
web3WsUrl,
ethereumSigningKey,
environment = {
clientApiUrl: 'http://localhost:8080',
optimistApiUrl: 'http://localhost:8081',
optimistWsUrl: 'ws://localhost:8082',
},
zkpKeys,
) {
this.clientBaseUrl = environment.clientApiUrl;
this.optimistBaseUrl = environment.optimistApiUrl;
this.optimistWsUrl = environment.optimistWsUrl;
Expand Down
72 changes: 72 additions & 0 deletions config/default.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,4 +128,76 @@ module.exports = {
U: BigInt(5), // non square in Fp
},
MAX_QUEUE: 5,
ENVIRONMENTS: {
mainnet: {
name: 'Mainnet',
chainId: 1,
clientApiUrl: '',
optimistApiUrl: '',
optimistWsUrl: '',
web3WsUrl: '',
},
ropsten: {
name: 'Ropsten',
chainId: 3,
clientApiUrl: 'https://client1.testnet.nightfall3.com',
optimistApiUrl: 'https://optimist1.testnet.nightfall3.com',
optimistWsUrl: 'wss://optimist1-ws.testnet.nightfall3.com',
web3WsUrl: `${process.env.ROPSTEN_NODE}`,
},
rinkeby: {
name: 'Rinkeby',
chainId: 4,
clientApiUrl: '',
optimistApiUrl: '',
optimistWsUrl: '',
web3WsUrl: '',
},
localhost: {
name: 'Localhost',
chainId: 4378921,
clientApiUrl: 'http://localhost:8080',
optimistApiUrl: 'http://localhost:8081',
optimistWsUrl: 'ws://localhost:8082',
web3WsUrl: 'ws://localhost:8546',
},
},
TEST_OPTIONS: {
tokenId: '0x00',
tokenType: 'ERC20', // it can be 'ERC721' or 'ERC1155'
tokenTypeERC721: 'ERC721',
tokenTypeERC1155: 'ERC1155',
value: 10,
// this is the etherum private key for accounts[0]
privateKey: '0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69e',
gas: 10000000,
gasCosts: 8000000000000000,
fee: 1,
BLOCK_STAKE: 1, // 1 wei
bond: 10, // 10 wei
txPerBlock: 2,
walletTestAddress: '0xfCb059A4dB5B961d3e48706fAC91a55Bad0035C9',
walletTestSigningkey: '0xd42905d0582c476c4b74757be6576ec323d715a0c7dcff231b6348b7ab0190eb',
ethereumSigningKeyUser1: '0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69e',
ethereumAddressUser1: '0x9c8b2276d490141ae1440da660e470e7c0349c63',
ethereumSigningKeyUser2: '0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69e',
ethereumSigningKeyProposer1:
'0x4775af73d6dc84a0ae76f8726bda4b9ecf187c377229cb39e1afa7a18236a69d',
ethereumSigningKeyProposer2:
'0xd42905d0582c476c4b74757be6576ec323d715a0c7dcff231b6348b7ab0190eb',
ethereumSigningKeyProposer3:
'0xfbc1ee1c7332e2e5a76a99956f50b3ba2639aff73d56477e877ef8390c41e0c6',
ethereumSigningKeyChallenger:
'0xd42905d0582c476c4b74757be6576ec323d715a0c7dcff231b6348b7ab0190eb',
ethereumSigningKeyLiquidityProvider:
'0xfbc1ee1c7332e2e5a76a99956f50b3ba2639aff73d56477e877ef8390c41e0c6',
mnemonicUser1: 'trip differ bamboo bundle bonus luxury strike mad merry muffin nose auction',
mnemonicUser2:
'control series album tribe category saddle prosper enforce moon eternal talk fame',
mnemonicProposer: 'high return hold whale promote payment hat panel reduce oyster ramp mouse',
mnemonicChallenger:
'crush power outer gadget enter maze advance rather divert monster indoor axis',
mnemonicLiquidityProvider:
'smart base soup sister army address member poem point quick save penalty',
},
};
Loading