Skip to content

Commit

Permalink
add contract setup script
Browse files Browse the repository at this point in the history
  • Loading branch information
RnkSngh committed Jul 22, 2024
1 parent 0feb8b7 commit 27f9e3f
Show file tree
Hide file tree
Showing 14 changed files with 588 additions and 234 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"name": "@open-ibc/vibc-core-smart-contracts",
"version": "2.1.10",
"version": "2.1.11",
"main": "dist/index.js",
"bin": {
"verify-vibc-core-smart-contracts": "./dist/scripts/verify-contract-script.js",
"deploy-vibc-core-smart-contracts": "./dist/scripts/deploy-script.js",
"upgrade-vibc-core-smart-contracts": "./dist/scripts/upgrade-script.js",
"update-vibc-core-smart-contracts": "./dist/scripts/update-contracts-script.js",
"setup-vibc-core-dispatcher": "./dist/scripts/setup-dispatcher-script.js",
"vibc-core-deploy-test": "./dist/scripts/fork-deployment-test.js"
},
Expand Down
161 changes: 161 additions & 0 deletions specs/update.spec.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
# Spec for deploying contracts and configuring them via txs within a single run

# NOTE:
# {{name}} is replaced with one of the following, whichever matches first
# - the deployed contract address whose name matches `name` (not factoryName)
# - variables of the running chain, e.g. {{chain.chainName}}, {{chain.chainId}}
# - deployment factory names from written deployment files
# NOTE: order of the contracts matters, as some contracts depend on others
# contracts with no deps should be placed before those with deps

# Spec items can either be a ContractItemSchema, or TxItemSchema type:

###### ContractItemSchema TYPE ######
# This spec can be used for deploying a contract, either from vibc-core or external contracts.

## The following arguments can be specified in ContractItemSchema spec:
# name: name of key that will be stored in the contract registry
# deployer: must be # name of key that will be stored in the contract registry a valid name in accountRegistry; default to 'default' if not specified
# description: description to be stored in the contract registry
# factoryName: the name of the typechain factory used to deploy the contract
# deployer: deployer key, should correspond to either a private key or one that can be looked up in the evm.accounts.yaml
# libraries: if a contract depends on libraries, the location of the library file & the deployed library address can be specified here, as an array with 2 elements
# deployArgs: The arguments that will be called in the contract constructor. Note: if $INITARGS is passed in as an argument, it will be abi.encode the arguments passed to the init paramater
# init: any arguments that need to be abi encoded (e.g. for calling upgradeToAndCall for ERC1967Proxy). These will be rendered in the place of $INITARGS

###### TxItemSchema TYPE ######
# This spec can be used for sending any tx to a contract, including proxy upgrades, calling setters, transferring ownership, etc.

## The following arguments can be specified in tx spec:
# name: name of entry that will be stored in tx registry
# description: description in tx registry
# factoryName: factory to use to read abi to send tx
# deployer: can be set in the accounts.yaml
# address: address of contract to call method on
# signature: signature of method to call for this tx
# args: args to make the function call with, need to be compatible with the signature

- name: LightClient
description: 'DummyLightClient'
factoryName: 'DummyLightClient'
deployer: 'KEY_POLYMER'

- name: Ibc
description: 'IBC library'
factoryName: 'Ibc'
deployer: 'KEY_POLYMER'

- name: IbcUtils
description: 'IBC utils library'
factoryName: 'IbcUtils'
deployer: 'KEY_POLYMER'

- name: Dispatcher
description: 'IBC Core contract'
factoryName: 'Dispatcher'
libraries:
- name: 'contracts/libs/Ibc.sol:Ibc'
address: '{{Ibc}}'
- name: 'contracts/libs/IbcUtils.sol:IbcUtils'
address: '{{IbcUtils}}'
deployer: 'KEY_POLYMER'

- name: FeeVault
description: 'FeeVault'
factoryName: 'FeeVault'
deployer: 'KEY_POLYMER'

- name: DispatcherProxy
description: 'Dispatcher proxy contract'
factoryName: 'ERC1967Proxy'
deployArgs:
- '{{Dispatcher}}'
- '$INITARGS'
init:
signature: 'initialize(string,address)'
args:
- 'polyibc.{{chain.chainName}}.'
- '{{FeeVault}}'
deployer: 'KEY_POLYMER'

- name: UC
description: 'Universal Chanel IBC-middleware contract'
factoryName: 'UniversalChannelHandler'
deployer: 'KEY_POLYMER'
libraries:
- name: 'contracts/libs/IbcUtils.sol:IbcUtils'
address: '{{IbcUtils}}'

- name: UCProxy
description: 'Universal Chanel IBC-middleware proxy'
factoryName: 'ERC1967Proxy'
deployer: 'KEY_POLYMER'
deployArgs:
- '{{UC}}'
- '$INITARGS'
init:
signature: 'initialize(address)'
args:
- '{{DispatcherProxy}}'

# dApp contracts for testing and as examples
- name: Mars
description: 'Mars contract directly owns a IBC channel'
deployArgs:
- '{{DispatcherProxy}}'
deployer: 'KEY_DAPP1'

- name: Earth
description: 'Earth contract uses shared universal channel'
deployArgs:
- '{{UCProxy}}'
deployer: 'KEY_DAPP2'


# Contract Setup below
- name: DispatcherUpgrade
description: 'UUPS Upgrade for dispatcher contract implementation'
deployer: 'KEY_POLYMER'
signature: "upgradeTo(address)"
address: '{{DispatcherProxy}}'
factoryName: "Dispatcher"
args:
- '{{Dispatcher}}'

- name: DispatcherUpgrade
description: 'UUPS Upgrade for dispatcher contract implementation'
deployer: 'KEY_POLYMER'
signature: "upgradeTo(address)"
address: '{{DispatcherProxy}}'
factoryName: "Dispatcher"
args:
- '{{Dispatcher}}'

- name: UCH Upgrade
description: 'Upgrade for uch contract'
deployer: 'KEY_POLYMER'
signature: "upgradeTo(address)"
address: '{{ UC Proxy }}'
factoryName: "UC"
args:
- '{{UC}}'

- name: DispatcherClientSetup-Connection-0
description: 'Setup client for dispatcher contracts'
deployer: 'KEY_POLYMER'
signature: "setClientForConnection(string,address)"
address: '{{DispatcherProxy}}'
factoryName: "Dispatcher"
args:
- 'connection-0'
- '{{LightClient}}'

- name: DispatcherClientSetup-Connection-1
description: 'Setup client for dispatcher contracts'
deployer: 'KEY_POLYMER'
signature: "setClientForConnection(string,address)"
address: '{{DispatcherProxy}}'
factoryName: "Dispatcher"
args:
- 'connection-2'
- '{{LightClient}}'
11 changes: 10 additions & 1 deletion specs/upgrade.spec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,13 @@
address: '{{DispatcherProxy}}'
factoryName: "Dispatcher"
args:
- '{{Dispatcher}}'
- '{{Dispatcher}}'

- name: UCH Upgrade
description: 'Upgrade for uch contract'
deployer: 'KEY_POLYMER'
signature: "upgradeTo(address)"
address: '{{ UC Proxy }}'
factoryName: "UC"
args:
- '{{UC}}'
Loading

0 comments on commit 27f9e3f

Please sign in to comment.