Skip to content

Commit

Permalink
Merge pull request #33 from provable-things/add-supported-token
Browse files Browse the repository at this point in the history
feat(CLI): <- adds fxn to add supported token to that
  • Loading branch information
gskapka authored May 5, 2022
2 parents 5bd0fd7 + e8ffbe1 commit 538732c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const { verifyVault } = require('./lib/verify-vault')
const { getWEthAddress } = require('./lib/get-weth-address')
const { isTokenSupported } = require('./lib/is-token-supported')
const { showWalletDetails } = require('./lib/show-wallet-details')
const { addSupportedToken } = require('./lib/add-supported-token')
const { showSuggestedFees } = require('./lib/show-suggested-fees')
const { getSupportedTokens } = require('./lib/get-supported-tokens')
const { getEncodedInitArgs } = require('./lib/get-encoded-init-args')
Expand Down Expand Up @@ -39,6 +40,7 @@ const IS_TOKEN_SUPPORTED_CMD = 'isTokenSupported'
const GET_ENCODED_INIT_ARGS_CMD = 'encodeInitArgs'
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 DESTINATION_ADDRESS_ARG = '<destinationAddress>'
const DESTINATION_CHAIN_ID_ARG = '<destinationChainId>'
Expand Down Expand Up @@ -79,6 +81,7 @@ const USAGE_INFO = `
${TOOL_NAME} ${VERIFY_VAULT_CMD} ${NETWORK_ARG} ${DEPLOYED_ADDRESS_ARG}
${TOOL_NAME} ${SET_PNETWORK_CMD} ${DEPLOYED_ADDRESS_ARG} ${ETH_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} ${GET_ENCODED_INIT_ARGS_CMD} ${WETH_ADDRESS_ARG} ${ORIGIN_CHAIN_ID_ARG} [${TOKENS_ARG}...]
${TOOL_NAME} ${PEG_IN_CMD} ${DEPLOYED_ADDRESS_ARG} ${AMOUNT_ARG} ${TOKEN_ADDRESS_ARG} ${DESTINATION_ADDRESS_ARG} ${DESTINATION_CHAIN_ID_ARG} [${USER_DATA_ARG}]
Expand All @@ -95,6 +98,7 @@ const USAGE_INFO = `
${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}.
❍ Options:
Expand Down Expand Up @@ -128,6 +132,8 @@ const main = _ => {
return showExistingContractAddresses()
} else if (CLI_ARGS[SET_PNETWORK_CMD]) {
return setPNetwork(CLI_ARGS[DEPLOYED_ADDRESS_ARG], CLI_ARGS[ETH_ADDRESS_ARG])
} else if (CLI_ARGS[ADD_SUPPORTED_TOKEN_CMD]) {
return addSupportedToken(CLI_ARGS[DEPLOYED_ADDRESS_ARG], CLI_ARGS[ETH_ADDRESS_ARG])
} else if (CLI_ARGS[GET_PNETWORK_CMD]) {
return getPNetwork(CLI_ARGS[DEPLOYED_ADDRESS_ARG])
} else if (CLI_ARGS[GET_SUPPORTED_TOKENS_CMD]) {
Expand Down
11 changes: 11 additions & 0 deletions lib/add-supported-token.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { getVaultContract } = require('./get-vault-contract')
const { callFxnInContractAndAwaitReceipt } = require('./contract-utils')

const addSupportedToken = (_deployedContractAddress, _address) => {
console.info(`✔ Setting pNetwork address to ${_address}...`)
return getVaultContract(_deployedContractAddress)
.then(callFxnInContractAndAwaitReceipt('addSupportedToken', [ _address ]))
.then(_receipt => console.info('✔ Success! Transaction receipt:\n', _receipt))
}

module.exports = { addSupportedToken }
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ptokens-erc20-vault-smart-contract",
"version": "2.2.0",
"version": "2.3.0",
"description": "The pToken ERC20 vault smart-contract & CLI",
"main": "cli.js",
"scripts": {
Expand Down

0 comments on commit 538732c

Please sign in to comment.