Skip to content

Commit

Permalink
Merge pull request #39 from provable-things/new-eth-testnets
Browse files Browse the repository at this point in the history
feat(repo): <- adds support to that for `sepolia` & `goerli` testnets
  • Loading branch information
gskapka authored Aug 26, 2022
2 parents d333200 + f55e0b3 commit c74513c
Show file tree
Hide file tree
Showing 10 changed files with 8,330 additions and 3,580 deletions.
101 changes: 41 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ Then, to see the usage guide, run:
Output:

```
❍ pTokens ERC20 Vault Command Line Interface
Copyright Provable Things 2021
Expand All @@ -34,89 +33,71 @@ Output:
NOTE: Functions that make transactions require a private key. Please provide a GPG encrpyted file called
'private-key.gpg' containing your key in the root of the repository. Create one via:
'echo <your-private-key> | gpg -c --output private-key.gpg'
Multiple private keys may be provisioned, and the tool will provide you with a list to select from.
NOTE: The tool requires a '.env' file to exist in the root of the repository with the following info:
ENDPOINT=<rpc-endpoint-for-blochain-to-interact-with>
Multiple such files may be provisioned, and the tool will provide you with a list to select from.
NOTE: To call the 'verifyVault' function, the following extra environment variable is required:
NOTE: To call functions which verify contracts, the following extra environment variable is required:
ETHERSCAN_API_KEY=<api-key-for-automated-contract-verifications>
❍ Usage:
cli.js --help
cli.js --version
cli.js deployVault
cli.js flattenContract
cli.js showSuggestedFees
cli.js showWalletDetails
cli.js deployVaultContract
cli.js showExistingContracts
cli.js getPNetwork <deployedAddress>
cli.js getWEthAddress <deployedAddress>
cli.js getSupportedTokens <deployedAddress>
cli.js verifyVault <network> <deployedAddress>
cli.js deployUnwrapperContract <wEthAddress>
cli.js setPNetwork <deployedAddress> <ethAddress>
cli.js verifyVaultContract <network> <deployedAddress>
cli.js isTokenSupported <deployedAddress> <ethAddress>
cli.js getEncodedInitArgs <wEthAddress> <tokensToSupport>...
cli.js pegIn <deployedAddress> <amount> <tokenAddress> <destinationAddress> --userData=<hex>
cli.js addSupportedToken <deployedAddress> <ethAddress>
cli.js setWEthUnwrapperAddress <deployedAddress> <ethAddress>
cli.js verifyUnwrapperContract <network> <deployedAddress> <wEthAddress>
cli.js encodeInitArgs <wEthAddress> <originChainId> [--token=<ethAddress>...]
cli.js pegIn <deployedAddress> <amount> <tokenAddress> <destinationAddress> <destinationChainId> [--userData=<hex>]
❍ Commands:
setPNetwork ❍ Set the pNetwork address.
showSuggestedFees ❍ Show 'ethers.js' suggested fees.
deployVault ❍ Deploy the ERC20 vault logic contract.
verifyVault ❍ Verify a deployed pToken logic contract.
pegIn ❍ Peg in <amount> of <tokenAddress> to <destinationAddress>.
getPNetwork ❍ Show the pNetwork address of the vault at <deployedAddress>.
getWEthAddress ❍ Show the wETH address set in the vault at <deployedAddress>.
flattenContract ❍ Flatten the contract in case manual verification is required.
getSupportedTokens ❍ Show list of tokens supprted by the vault at <deployedAddress>.
showWalletDetails ❍ Decrypts the private key and shows address & balance information.
isTokenSupported ❍ Is token at <ethAddress> supported in vault at <deployedAddress>.
getEncodedInitArgs ❍ Calculate the initializer function arguments in ABI encoded format.
showExistingContracts ❍ Show list of existing logic contract addresses on various blockchains.
setPNetwork ❍ Set the pNetwork address.
showSuggestedFees ❍ Show 'ethers.js' suggested fees.
deployUnwrapperContract ❍ Deploy the WETH unwrapper contract.
deployVaultContract ❍ Deploy the ERC20 vault logic contract.
verifyVaultContract ❍ Verify a deployed pToken logic contract.
verifyUnwrapperContract ❍ Verify a deployed WETH unwrapper contract.
getPNetwork ❍ Show the pNetwork address of the vault at <deployedAddress>.
getWEthAddress ❍ Show the wETH address set in the vault at <deployedAddress>.
flattenContract ❍ Flatten the contract in case manual verification is required.
getSupportedTokens ❍ Show list of tokens supprted by the vault at <deployedAddress>.
showWalletDetails ❍ Decrypts the private key and shows address & balance information.
isTokenSupported ❍ Is token at <ethAddress> supported in vault at <deployedAddress>.
encodeInitArgs ❍ Calculate the initializer function arguments in ABI encoded format.
showExistingContracts ❍ Show list of existing logic contract addresses on various blockchains.
addSupportedToken ❍ Adds token at <ethAddress> to the supported tokens in vault at <deployedAddress>.
pegIn ❍ Peg in <amount> of <tokenAddress> to <destinationAddress> on <destinationChainId>.
setWEthUnwrapperAddress ❍ Sets the WETH unwrapper contract at <ethAddress> in the vault at <deployedAddress>.
❍ Options:
--help ❍ Show this message.
--version ❍ Show tool version.
<ethAddress> ❍ A valid ETH address.
<tokenAddress> ❍ ETH address of token.
<deployedAddress> ❍ The ETH address of the deployed vault.
<destinationAddress> ❍ Destination address of a token peg in.
--userData=<hex> ❍ User data in hex format [default: 0x].
<amount> ❍ Amount of tokens in their most granular format.
<tokensToSupport> ❍ Addresses of ERC20 tokens the vault will support.
<wEthAddress> ❍ The address for the wrapped ETH token on the blockchain to be deployed to.
<network> ❍ Network the vault is deployed on. It must exist in the 'hardhat.config.json'.
```

&nbsp;

### :radioactive: Secrets:

This tool requires a private key in order to sign transactions. GPG is used to protect the private key. To encrypt a private key using a GPG key from your keyring:

```
echo <your-private-key> | gpg -e --output private-key.gpg
```

Or, if you'd rather use a password to encrypt your keyfile, use this instead:
--help ❍ Show this message.
--version ❍ Show tool version.
<ethAddress> ❍ A valid ETH address.
<tokenAddress> ❍ ETH address of token.
<deployedAddress> ❍ The ETH address of the deployed vault.
<destinationAddress> ❍ Destination address of a token peg in.
--userData=<hex> ❍ User data in hex format [default: 0x].
--token=<ethAddress> ❍ ETH addresses of tokens the vault will support.
<amount> ❍ Amount of tokens in their most granular format.
<originChainId> ❍ Metadata chain ID of the chain this contract is deployed to.
<destinationChainId> ❍ Metadata chain ID of the chains this contract supports peg-ins to.
<wEthAddress> ❍ The address for the wrapped ETH token on the blockchain to be deployed to.
<network> ❍ Network the vault is deployed on. It must exist in the 'hardhat.config.json'.
```
echo <your-private-key> | gpg -c --output private-key.gpg
```

The CLI also requires a JsonRPC endpoint for the blockchain you're interacting with. To easily provision this, create a `.env` file in the root of the repository and fill it in thusly:

```
ENDPOINT=<ethRpcEndpoint>
```

Finally, to verify a contract, you'll need an etherscan API key too. You can add this to your `.env` file thusly:

```
ETHERSCAN_API_KEY=<apikey>
```

NOTE: If you're not verifying contracts, you don't need to provide this environment variable at all.

&nbsp;

Expand Down
78 changes: 40 additions & 38 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ const ETH_ADDRESS_ARG = '<ethAddress>'
const SET_PNETWORK_CMD = 'setPNetwork'
const GET_PNETWORK_CMD = 'getPNetwork'
const WETH_ADDRESS_ARG = '<wEthAddress>'
const DEPLOY_VAULT_CMD = 'deployVaultContract'
const VERIFY_VAULT_CMD = 'verifyVaultContract'
const GET_WETH_ADDRESS = 'getWEthAddress'
const TOKEN_ADDRESS_ARG = '<tokenAddress>'
const USER_DATA_OPTIONAL_ARG = '--userData'
const ORIGIN_CHAIN_ID_ARG = '<originChainId>'
const DEPLOY_VAULT_CMD = 'deployVaultContract'
const VERIFY_VAULT_CMD = 'verifyVaultContract'
const FLATTEN_CONTRACT_CMD = 'flattenContract'
const TOKENS_ARG = `${TOKEN_FLAG}=<ethAddress>`
const DEPLOYED_ADDRESS_ARG = '<deployedAddress>'
Expand All @@ -45,13 +45,13 @@ const SHOW_SUGGESTED_FEES_CMD = 'showSuggestedFees'
const SHOW_WALLET_DETAILS_CMD = 'showWalletDetails'
const ADD_SUPPORTED_TOKEN_CMD = 'addSupportedToken'
const GET_SUPPORTED_TOKENS_CMD = 'getSupportedTokens'
const SET_WETH_UNWRAPPER_ADDRESS = 'setWEthUnwrapperAddress'
const VERIFY_UNWRAPPER_CMD = 'verifyUnwrapperContractContract'
const VERIFY_UNWRAPPER_CMD = 'verifyUnwrapperContract'
const DEPLOY_UNWRAPPER_CMD = 'deployUnwrapperContract'
const DESTINATION_ADDRESS_ARG = '<destinationAddress>'
const DESTINATION_CHAIN_ID_ARG = '<destinationChainId>'
const USER_DATA_ARG = `${USER_DATA_OPTIONAL_ARG}=<hex>`
const SHOW_EXISTING_CONTRACTS_CMD = 'showExistingContracts'
const SET_WETH_UNWRAPPER_ADDRESS = 'setWEthUnwrapperAddress'

const USAGE_INFO = `
❍ pTokens ERC20 Vault Command Line Interface
Expand All @@ -66,27 +66,29 @@ const USAGE_INFO = `
NOTE: Functions that make transactions require a private key. Please provide a GPG encrpyted file called
'private-key.gpg' containing your key in the root of the repository. Create one via:
'echo <your-private-key> | gpg -c --output private-key.gpg'
Multiple private keys may be provisioned, and the tool will provide you with a list to select from.
NOTE: The tool requires a '.env' file to exist in the root of the repository with the following info:
ENDPOINT=<rpc-endpoint-for-blochain-to-interact-with>
Multiple such files may be provisioned, and the tool will provide you with a list to select from.
NOTE: To call the '${VERIFY_VAULT_CMD}' function, the following extra environment variable is required:
NOTE: To call functions which verify contracts, the following extra environment variable is required:
ETHERSCAN_API_KEY=<api-key-for-automated-contract-verifications>
❍ Usage:
${TOOL_NAME} ${HELP_ARG}
${TOOL_NAME} ${VERSION_ARG}
${TOOL_NAME} ${DEPLOY_VAULT_CMD}
${TOOL_NAME} ${FLATTEN_CONTRACT_CMD}
${TOOL_NAME} ${SHOW_SUGGESTED_FEES_CMD}
${TOOL_NAME} ${SHOW_WALLET_DETAILS_CMD}
${TOOL_NAME} ${DEPLOY_VAULT_CMD}
${TOOL_NAME} ${SHOW_EXISTING_CONTRACTS_CMD}
${TOOL_NAME} ${GET_PNETWORK_CMD} ${DEPLOYED_ADDRESS_ARG}
${TOOL_NAME} ${GET_WETH_ADDRESS} ${DEPLOYED_ADDRESS_ARG}
${TOOL_NAME} ${GET_SUPPORTED_TOKENS_CMD} ${DEPLOYED_ADDRESS_ARG}
${TOOL_NAME} ${VERIFY_VAULT_CMD} ${NETWORK_ARG} ${DEPLOYED_ADDRESS_ARG}
${TOOL_NAME} ${SET_PNETWORK_CMD} ${DEPLOYED_ADDRESS_ARG} ${ETH_ADDRESS_ARG}
${TOOL_NAME} ${DEPLOY_UNWRAPPER_CMD} ${WETH_ADDRESS_ARG}
${TOOL_NAME} ${SET_PNETWORK_CMD} ${DEPLOYED_ADDRESS_ARG} ${ETH_ADDRESS_ARG}
${TOOL_NAME} ${VERIFY_VAULT_CMD} ${NETWORK_ARG} ${DEPLOYED_ADDRESS_ARG}
${TOOL_NAME} ${IS_TOKEN_SUPPORTED_CMD} ${DEPLOYED_ADDRESS_ARG} ${ETH_ADDRESS_ARG}
${TOOL_NAME} ${ADD_SUPPORTED_TOKEN_CMD} ${DEPLOYED_ADDRESS_ARG} ${ETH_ADDRESS_ARG}
${TOOL_NAME} ${SET_WETH_UNWRAPPER_ADDRESS} ${DEPLOYED_ADDRESS_ARG} ${ETH_ADDRESS_ARG}
Expand All @@ -95,38 +97,38 @@ const USAGE_INFO = `
${TOOL_NAME} ${PEG_IN_CMD} ${DEPLOYED_ADDRESS_ARG} ${AMOUNT_ARG} ${TOKEN_ADDRESS_ARG} ${DESTINATION_ADDRESS_ARG} ${DESTINATION_CHAIN_ID_ARG} [${USER_DATA_ARG}]
❍ Commands:
${SET_PNETWORK_CMD} ❍ Set the pNetwork address.
${SHOW_SUGGESTED_FEES_CMD} ❍ Show 'ethers.js' suggested fees.
${DEPLOY_VAULT_CMD} ❍ Deploy the ERC20 vault logic contract.
${DEPLOY_UNWRAPPER_CMD} ❍ Deploy the WETH unwrapper contract.
${VERIFY_VAULT_CMD} ❍ Verify a deployed pToken logic contract.
${VERIFY_UNWRAPPER_CMD} ❍ Verify a deployed WETH unwrapper contract.
${GET_PNETWORK_CMD} ❍ Show the pNetwork address of the vault at ${DEPLOYED_ADDRESS_ARG}.
${GET_WETH_ADDRESS} ❍ Show the wETH address set in the vault at ${DEPLOYED_ADDRESS_ARG}.
${FLATTEN_CONTRACT_CMD} ❍ Flatten the contract in case manual verification is required.
${GET_SUPPORTED_TOKENS_CMD} ❍ Show list of tokens supprted by the vault at ${DEPLOYED_ADDRESS_ARG}.
${SHOW_WALLET_DETAILS_CMD} ❍ Decrypts the private key and shows address & balance information.
${IS_TOKEN_SUPPORTED_CMD} ❍ Is token at ${ETH_ADDRESS_ARG} supported in vault at ${DEPLOYED_ADDRESS_ARG}.
${GET_ENCODED_INIT_ARGS_CMD} ❍ Calculate the initializer function arguments in ABI encoded format.
${SHOW_EXISTING_CONTRACTS_CMD} ❍ Show list of existing logic contract addresses on various blockchains.
${ADD_SUPPORTED_TOKEN_CMD} ❍ Adds token at ${ETH_ADDRESS_ARG} to the supported tokens in vault at ${DEPLOYED_ADDRESS_ARG}.
${SET_WETH_UNWRAPPER_ADDRESS} ❍ Sets the WETH unwrapper contract at ${ETH_ADDRESS_ARG} in the vault at ${DEPLOYED_ADDRESS_ARG}.
${PEG_IN_CMD} ❍ Peg in ${AMOUNT_ARG} of ${TOKEN_ADDRESS_ARG} to ${DESTINATION_ADDRESS_ARG} on ${DESTINATION_CHAIN_ID_ARG}.
${SET_PNETWORK_CMD} ❍ Set the pNetwork address.
${SHOW_SUGGESTED_FEES_CMD} ❍ Show 'ethers.js' suggested fees.
${DEPLOY_UNWRAPPER_CMD} ❍ Deploy the WETH unwrapper contract.
${DEPLOY_VAULT_CMD} ❍ Deploy the ERC20 vault logic contract.
${VERIFY_VAULT_CMD} ❍ Verify a deployed pToken logic contract.
${VERIFY_UNWRAPPER_CMD} ❍ Verify a deployed WETH unwrapper contract.
${GET_PNETWORK_CMD} ❍ Show the pNetwork address of the vault at ${DEPLOYED_ADDRESS_ARG}.
${GET_WETH_ADDRESS} ❍ Show the wETH address set in the vault at ${DEPLOYED_ADDRESS_ARG}.
${FLATTEN_CONTRACT_CMD} ❍ Flatten the contract in case manual verification is required.
${GET_SUPPORTED_TOKENS_CMD} ❍ Show list of tokens supprted by the vault at ${DEPLOYED_ADDRESS_ARG}.
${SHOW_WALLET_DETAILS_CMD} ❍ Decrypts the private key and shows address & balance information.
${IS_TOKEN_SUPPORTED_CMD} ❍ Is token at ${ETH_ADDRESS_ARG} supported in vault at ${DEPLOYED_ADDRESS_ARG}.
${GET_ENCODED_INIT_ARGS_CMD} ❍ Calculate the initializer function arguments in ABI encoded format.
${SHOW_EXISTING_CONTRACTS_CMD} ❍ Show list of existing logic contract addresses on various blockchains.
${ADD_SUPPORTED_TOKEN_CMD} ❍ Adds token at ${ETH_ADDRESS_ARG} to the supported tokens in vault at ${DEPLOYED_ADDRESS_ARG}.
${PEG_IN_CMD} ❍ Peg in ${AMOUNT_ARG} of ${TOKEN_ADDRESS_ARG} to ${DESTINATION_ADDRESS_ARG} on ${DESTINATION_CHAIN_ID_ARG}.
${SET_WETH_UNWRAPPER_ADDRESS} ❍ Sets the WETH unwrapper contract at ${ETH_ADDRESS_ARG} in the vault at ${DEPLOYED_ADDRESS_ARG}.
❍ Options:
${HELP_ARG} ❍ Show this message.
${VERSION_ARG} ❍ Show tool version.
${ETH_ADDRESS_ARG} ❍ A valid ETH address.
${TOKEN_ADDRESS_ARG} ❍ ETH address of token.
${DEPLOYED_ADDRESS_ARG} ❍ The ETH address of the deployed vault.
${DESTINATION_ADDRESS_ARG} ❍ Destination address of a token peg in.
${USER_DATA_ARG} ❍ User data in hex format [default: 0x].
${TOKENS_ARG} ❍ ETH addresses of tokens the vault will support.
${AMOUNT_ARG} ❍ Amount of tokens in their most granular format.
${ORIGIN_CHAIN_ID_ARG} ❍ Metadata chain ID of the chain this contract is deployed to.
${DESTINATION_CHAIN_ID_ARG} ❍ Metadata chain ID of the chains this contract supports peg-ins to.
${WETH_ADDRESS_ARG} ❍ The address for the wrapped ETH token on the blockchain to be deployed to.
${NETWORK_ARG} ❍ Network the vault is deployed on. It must exist in the 'hardhat.config.json'.
${HELP_ARG} ❍ Show this message.
${VERSION_ARG} ❍ Show tool version.
${ETH_ADDRESS_ARG} ❍ A valid ETH address.
${TOKEN_ADDRESS_ARG} ❍ ETH address of token.
${DEPLOYED_ADDRESS_ARG} ❍ The ETH address of the deployed vault.
${DESTINATION_ADDRESS_ARG} ❍ Destination address of a token peg in.
${USER_DATA_ARG} ❍ User data in hex format [default: 0x].
${TOKENS_ARG} ❍ ETH addresses of tokens the vault will support.
${AMOUNT_ARG} ❍ Amount of tokens in their most granular format.
${ORIGIN_CHAIN_ID_ARG} ❍ Metadata chain ID of the chain this contract is deployed to.
${DESTINATION_CHAIN_ID_ARG} ❍ Metadata chain ID of the chains this contract supports peg-ins to.
${WETH_ADDRESS_ARG} ❍ The address for the wrapped ETH token on the blockchain to be deployed to.
${NETWORK_ARG} ❍ Network the vault is deployed on. It must exist in the 'hardhat.config.json'.
`
const main = _ => {
const CLI_ARGS = docopt(USAGE_INFO, { version })
Expand Down
3 changes: 3 additions & 0 deletions hardhat.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ const SUPPORTED_NETWORKS = [
'ambrosTestnet',
'ethMainnet',
'bscMainnet',
'goerli',
'prater',
'sepolia',
]

const getEnvVarOrThow = _name => {
Expand Down
2 changes: 2 additions & 0 deletions lib/show-existing-contract-addresses.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const EXISTING_LOGIC_CONTRACT_ADDRESSES = [
{ 'version': 'v2', 'chain': 'rinkeby', 'address': '0x6819bbFdf803B8b87850916d3eEB3642DdE6C24F' },
{ 'version': 'v2', 'chain': 'interim', 'address': '0xeEa7CE353a076898E35E82609e45918B5e4d0e0A' },
{ 'version': 'v2', 'chain': 'ethereum', 'address': '0xE01a9c36170b8Fa163C6a54D7aB3015C85e0186c' },
{ 'version': 'v2', 'chain': 'goerli', 'address': '0xEa1FFBf0715FE7ccaae5d57dC698550f23581a27' },
{ 'version': 'v2', 'chain': 'sepolia', 'address': '0x9fdbc63D5250Aa59cb6d5382eF4e92113fE1FC35' },
]

const showExistingContractAddresses = _ =>
Expand Down
Loading

0 comments on commit c74513c

Please sign in to comment.