Skip to content

Commit

Permalink
Add @casimir/env to dev scripts and deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
shanejearley committed Sep 15, 2023
1 parent a143e35 commit 6a4c2c1
Show file tree
Hide file tree
Showing 14 changed files with 162 additions and 114 deletions.
2 changes: 1 addition & 1 deletion apps/landing/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"version": "0.0.1",
"scripts": {
"dev": "vite",
"build": "vue-tsc --noEmit && vite build",
"build": "vite build",
"preview": "vite preview"
},
"dependencies": {
Expand Down
47 changes: 29 additions & 18 deletions common/env/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,41 @@
const ETHEREUM_CONTRACT_ADDRESSES = {
const ETHEREUM_CONTRACTS = {
TESTNET: {
FunctionsOracleFactory: '0xfA2D8643D87E625004bcA263Bcd2002255fDD4BB',
FunctionsOracle: '0xF89a8DDFdb39C6BB3125bBeA3BB356B40A99b46f',
FunctionsBillingRegistry: '0x6310Cc8288aE5f70E914363c72F7d2e1D1C8533d',
CasimirPoolBeacon: '0x98A6f99c1bD042b4B1B5C03755805a7FFac902e1',
CasimirRegistryBeacon: '0x3FB35C4de1a1AeA102B192d28391227C93305cA5',
CasimirUpkeepBeacon: '0x12CCBd11A592Bc7ad0405c15c90c8419b390E814',
CasimirManager: '0x813aA99639F77A275b5bD5E12904cCd48826C19F',
CasimirRegistry: '0x97d5b6F9801D2CdCB492e567b1246a837Cd8d2D4',
CasimirUpkeep: '0x1A4f46e5209b71C11aeb6776fD161B80174B2a63',
CasimirViews: '0xc9F69bD5F43153FB485cBF1DB907EE1eb28c9B29'
}
}
MANAGER_ADDRESS: '0x813aA99639F77A275b5bD5E12904cCd48826C19F',
REGISTRY_ADDRESS: '0x97d5b6F9801D2CdCB492e567b1246a837Cd8d2D4',
UPKEEP_ADDRESS: '0x1A4f46e5209b71C11aeb6776fD161B80174B2a63',
VIEWS_ADDRESS: '0xc9F69bD5F43153FB485cBF1DB907EE1eb28c9B29',

enum ETHEREUM_FORK_URL {
MAINNET = 'https://mainnet.infura.io/v3/46a379ac6895489f812f33beb726b03b',
TESTNET = 'https://goerli.infura.io/v3/46a379ac6895489f812f33beb726b03b'
FUNCTIONS_ORACLE_FACTORY_ADDRESS: '0xfA2D8643D87E625004bcA263Bcd2002255fDD4BB',
FUNCTIONS_ORACLE_ADDRESS: '0xF89a8DDFdb39C6BB3125bBeA3BB356B40A99b46f',
FUNCTIONS_BILLING_REGISTRY_ADDRESS: '0x6310Cc8288aE5f70E914363c72F7d2e1D1C8533d',

POOL_BEACON_ADDRESS: '0x98A6f99c1bD042b4B1B5C03755805a7FFac902e1',
REGISTRY_BEACON_ADDRESS: '0x3FB35C4de1a1AeA102B192d28391227C93305cA5',
UPKEEP_BEACON_ADDRESS: '0x12CCBd11A592Bc7ad0405c15c90c8419b390E814',

BEACON_DEPOSIT_ADDRESS: '0x07b39F4fDE4A38bACe212b546dAc87C58DfE3fDC',
DAO_ORACLE_ADDRESS: '',
LINK_ETH_FEED_ADDRESS: '0xb4c4a493AB6356497713A78FFA6c60FB53517c63',
KEEPER_REGISTRAR_ADDRESS: '0x57A4a13b35d25EE78e084168aBaC5ad360252467',
KEEPER_REGISTRY_ADDRESS: '0xE16Df59B887e3Caa439E0b29B42bA2e7976FD8b2',
LINK_TOKEN_ADDRESS: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB',
SSV_NETWORK_ADDRESS: '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D',
SSV_VIEWS_ADDRESS: '0xAE2C84c48272F5a1746150ef333D5E5B51F68763',
SSV_TOKEN_ADDRESS: '0x3a9f01091C446bdE031E39ea8354647AFef091E7',
SWAP_FACTORY_ADDRESS: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
SWAP_ROUTER_ADDRESS: '0xE592427A0AEce92De3Edee1F18E0157C05861564',
WETH_TOKEN_ADDRESS: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6'
}
}

enum ETHEREUM_NETWORK_NAME {
MAINNET = 'mainnet',
TESTNET = 'goerli'
}
enum ETHEREUM_NETWORK_URL {

enum ETHEREUM_RPC_URL {
MAINNET = 'https://mainnet.infura.io/v3/46a379ac6895489f812f33beb726b03b',
TESTNET = 'https://goerli.infura.io/v3/46a379ac6895489f812f33beb726b03b'
}

export { ETHEREUM_CONTRACT_ADDRESSES, ETHEREUM_FORK_URL, ETHEREUM_NETWORK_NAME, ETHEREUM_NETWORK_URL }
export { ETHEREUM_CONTRACTS, ETHEREUM_NETWORK_NAME, ETHEREUM_RPC_URL }
23 changes: 12 additions & 11 deletions contracts/ethereum/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import '@nomiclabs/hardhat-ethers'
import '@nomicfoundation/hardhat-toolbox'
import '@openzeppelin/hardhat-upgrades'
import 'hardhat-abi-exporter'
import { ETHEREUM_CONTRACTS } from '@casimir/env'

// Seed is provided
const mnemonic = process.env.BIP39_SEED as string
Expand Down Expand Up @@ -47,23 +48,23 @@ const externalEnv = {
WETH_TOKEN_ADDRESS: '0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2'
},
goerli: {
BEACON_DEPOSIT_ADDRESS: '0x07b39F4fDE4A38bACe212b546dAc87C58DfE3fDC',
BEACON_DEPOSIT_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.BEACON_DEPOSIT_ADDRESS,
DAO_ORACLE_ADDRESS: '',
FUNCTIONS_BILLING_REGISTRY_ADDRESS: '',
FUNCTIONS_ORACLE_ADDRESS: '',
LINK_ETH_FEED_ADDRESS: '0xb4c4a493AB6356497713A78FFA6c60FB53517c63',
KEEPER_REGISTRAR_ADDRESS: '0x57A4a13b35d25EE78e084168aBaC5ad360252467',
KEEPER_REGISTRY_ADDRESS: '0xE16Df59B887e3Caa439E0b29B42bA2e7976FD8b2',
LINK_TOKEN_ADDRESS: '0x326C977E6efc84E512bB9C30f76E30c160eD06FB',
LINK_ETH_FEED_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.LINK_ETH_FEED_ADDRESS,
KEEPER_REGISTRAR_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.KEEPER_REGISTRAR_ADDRESS,
KEEPER_REGISTRY_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.KEEPER_REGISTRY_ADDRESS,
LINK_TOKEN_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.LINK_TOKEN_ADDRESS,
POOL_BEACON_ADDRESS: '',
REGISTRY_BEACON_ADDRESS: '',
SSV_NETWORK_ADDRESS: '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D',
SSV_VIEWS_ADDRESS: '0xAE2C84c48272F5a1746150ef333D5E5B51F68763',
SSV_TOKEN_ADDRESS: '0x3a9f01091C446bdE031E39ea8354647AFef091E7',
SWAP_FACTORY_ADDRESS: '0x1F98431c8aD98523631AE4a59f267346ea31F984',
SWAP_ROUTER_ADDRESS: '0xE592427A0AEce92De3Edee1F18E0157C05861564',
SSV_NETWORK_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SSV_NETWORK_ADDRESS,
SSV_VIEWS_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SSV_VIEWS_ADDRESS,
SSV_TOKEN_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SSV_TOKEN_ADDRESS,
SWAP_FACTORY_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SWAP_FACTORY_ADDRESS,
SWAP_ROUTER_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.SWAP_ROUTER_ADDRESS,
UPKEEP_BEACON_ADDRESS: '',
WETH_TOKEN_ADDRESS: '0xB4FBF271143F4FBf7B91A5ded31805e42b2208d6'
WETH_TOKEN_ADDRESS: ETHEREUM_CONTRACTS.TESTNET.WETH_TOKEN_ADDRESS
}
}

Expand Down
2 changes: 1 addition & 1 deletion contracts/ethereum/helpers/oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const ssvViewsAddress = process.env.SSV_VIEWS_ADDRESS as string
if (!ssvViewsAddress) throw new Error('No ssv views address provided')
const ssvTokenAddress = process.env.SSV_TOKEN_ADDRESS as string
if (!ssvTokenAddress) throw new Error('No ssv token address provided')
const uniswapV3FactoryAddress = process.env.UNISWAP_V3_FACTORY_ADDRESS as string
const uniswapV3FactoryAddress = process.env.SWAP_FACTORY_ADDRESS as string
if (!uniswapV3FactoryAddress) throw new Error('No uniswap v3 factory address provided')
const wethTokenAddress = process.env.WETH_TOKEN_ADDRESS as string
if (!wethTokenAddress) throw new Error('No weth token address provided')
Expand Down
27 changes: 20 additions & 7 deletions scripts/cdk/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getSecret, loadCredentials } from '@casimir/aws'
import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env'
import { run } from '@casimir/shell'

/**
Expand All @@ -12,15 +13,27 @@ void async function () {
await loadCredentials()
process.env.AWS_ACCOUNT = await getSecret('casimir-aws-account')

process.env.ETHEREUM_RPC_URL = 'https://nodes.casimir.co/eth/hardhat'
process.env.USERS_URL = `https://users.${process.env.STAGE}.casimir.co`

process.env.PUBLIC_MANAGER_ADDRESS = '0x5d35a44Db8a390aCfa997C9a9Ba3a2F878595630'
process.env.PUBLIC_VIEWS_ADDRESS = '0xC88C4022347305336E344e624E5Fa4fB8e61c21E'
process.env.PUBLIC_REGISTRY_ADDRESS = '0xB567C0E87Ec176177E44C91577704267C24Fbd83'
process.env.PUBLIC_ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL
process.env.CRYPTO_COMPARE_API_KEY = await getSecret('casimir-crypto-compare-api-key')

const networkKey = process.env.NETWORK?.toUpperCase() || process.env.FORK?.toUpperCase() || 'TESTNET'
process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL[networkKey]
process.env.MANAGER_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.MANAGER_ADDRESS
process.env.REGISTRY_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.REGISTRY_ADDRESS
process.env.UPKEEP_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.UPKEEP_ADDRESS
process.env.VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.VIEWS_ADDRESS
process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_NETWORK_ADDRESS
process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[networkKey]?.SSV_VIEWS_ADDRESS

process.env.PUBLIC_USERS_URL = process.env.USERS_URL
process.env.PUBLIC_CRYPTO_COMPARE_API_KEY = await getSecret('casimir-crypto-compare-api-key')
process.env.PUBLIC_CRYPTO_COMPARE_API_KEY = process.env.CRYPTO_COMPARE_API_KEY
process.env.PUBLIC_ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL
process.env.PUBLIC_MANAGER_ADDRESS = process.env.MANAGER_ADDRESS
process.env.PUBLIC_REGISTRY_ADDRESS = process.env.REGISTRY_ADDRESS
process.env.PUBLIC_UPKEEP_ADDRESS = process.env.UPKEEP_ADDRESS
process.env.PUBLIC_VIEWS_ADDRESS = process.env.VIEWS_ADDRESS
process.env.PUBLIC_SSV_NETWORK_ADDRESS = process.env.SSV_NETWORK_ADDRESS
process.env.PUBLIC_SSV_VIEWS_ADDRESS = process.env.SSV_VIEWS_ADDRESS

await run('npm run build --workspace @casimir/ethereum')
await run('npm run build:docs --workspace @casimir/ethereum')
Expand Down
9 changes: 0 additions & 9 deletions scripts/cdk/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,8 @@ void async function () {

await loadCredentials()
process.env.AWS_ACCOUNT = await getSecret('casimir-aws-account')

process.env.ETHEREUM_RPC_URL = 'https://nodes.casimir.co/eth/hardhat'
process.env.USERS_URL = `https://users.${process.env.STAGE}.casimir.co`

process.env.PUBLIC_MANAGER_ADDRESS = '0x5d35a44Db8a390aCfa997C9a9Ba3a2F878595630'
process.env.PUBLIC_VIEWS_ADDRESS = '0xC88C4022347305336E344e624E5Fa4fB8e61c21E'
process.env.PUBLIC_REGISTRY_ADDRESS = '0xB567C0E87Ec176177E44C91577704267C24Fbd83'
process.env.PUBLIC_ETHEREUM_RPC_URL = process.env.ETHEREUM_RPC_URL
process.env.PUBLIC_USERS_URL = process.env.USERS_URL
process.env.PUBLIC_CRYPTO_COMPARE_API_KEY = await getSecret('casimir-crypto-compare-api-key')

await run('npm run build --workspace @casimir/ethereum')
await run('npm run build:docs --workspace @casimir/ethereum')
await run('npm run build --workspace @casimir/landing')
Expand Down
4 changes: 2 additions & 2 deletions scripts/ethereum/deploy.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { loadCredentials, getSecret } from '@casimir/aws'
import { ETHEREUM_NETWORK_NAME, ETHEREUM_NETWORK_URL } from '@casimir/env'
import { ETHEREUM_NETWORK_NAME, ETHEREUM_RPC_URL } from '@casimir/env'
import { run } from '@casimir/shell'

/**
Expand All @@ -15,7 +15,7 @@ void async function () {
console.log(`Your mnemonic seed is ${process.env.BIP39_SEED}`)

process.env.NETWORK = process.env.NETWORK || 'testnet'
process.env.ETHEREUM_RPC_URL = ETHEREUM_NETWORK_URL[process.env.NETWORK.toUpperCase()]
process.env.ETHEREUM_RPC_URL = ETHEREUM_RPC_URL[process.env.NETWORK.toUpperCase()]
const networkName = ETHEREUM_NETWORK_NAME[process.env.NETWORK.toUpperCase()]

console.log(`Using ${networkName} network from ${process.env.ETHEREUM_RPC_URL}`)
Expand Down
24 changes: 12 additions & 12 deletions scripts/ethereum/dev.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ethers } from 'ethers'
import { loadCredentials, getSecret } from '@casimir/aws'
import { ETHEREUM_FORK_URL } from '@casimir/env'
import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env'
import { run } from '@casimir/shell'

/**
Expand All @@ -20,7 +20,7 @@ void async function () {
process.env.MINING_INTERVAL = '12'
process.env.ETHEREUM_RPC_URL = 'http://127.0.0.1:8545'

process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_FORK_URL[process.env.FORK.toUpperCase()]
process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_RPC_URL[process.env.FORK.toUpperCase()]
if (!process.env.ETHEREUM_FORK_RPC_URL) {
throw new Error(`Ethereum ${process.env.FORK} is not supported`)
}
Expand All @@ -44,13 +44,6 @@ void async function () {
})
}

if (!process.env.VIEWS_ADDRESS) {
process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({
from: wallet.address,
nonce: walletNonce + 2
})
}

if (!process.env.REGISTRY_ADDRESS) {
process.env.REGISTRY_ADDRESS = ethers.utils.getContractAddress({
from: process.env.MANAGER_ADDRESS,
Expand All @@ -65,9 +58,16 @@ void async function () {
})
}

process.env.SSV_NETWORK_ADDRESS = '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D'
process.env.SSV_VIEWS_ADDRESS = '0xAE2C84c48272F5a1746150ef333D5E5B51F68763'
process.env.UNISWAP_V3_FACTORY_ADDRESS = '0x1F98431c8aD98523631AE4a59f267346ea31F984'
if (!process.env.VIEWS_ADDRESS) {
process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({
from: wallet.address,
nonce: walletNonce + 2
})
}

process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_NETWORK_ADDRESS
process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_VIEWS_ADDRESS
process.env.SWAP_FACTORY_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SWAP_FACTORY_ADDRESS

run('npm run node --workspace @casimir/ethereum')
const hardhatWaitTime = 2500
Expand Down
24 changes: 12 additions & 12 deletions scripts/ethereum/test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ethers } from 'ethers'
import { loadCredentials, getSecret } from '@casimir/aws'
import { ETHEREUM_FORK_URL } from '@casimir/env'
import { ETHEREUM_CONTRACTS, ETHEREUM_RPC_URL } from '@casimir/env'
import { run } from '@casimir/shell'

/**
Expand All @@ -17,7 +17,7 @@ void async function () {

process.env.FORK = process.env.FORK || 'testnet'

process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_FORK_URL[process.env.FORK.toUpperCase()]
process.env.ETHEREUM_FORK_RPC_URL = ETHEREUM_RPC_URL[process.env.FORK.toUpperCase()]
if (!process.env.ETHEREUM_FORK_RPC_URL) {
throw new Error(`Ethereum ${process.env.FORK} is not supported`)
}
Expand All @@ -38,13 +38,6 @@ void async function () {
})
}

if (!process.env.VIEWS_ADDRESS) {
process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({
from: wallet.address,
nonce: walletNonce + 2
})
}

if (!process.env.REGISTRY_ADDRESS) {
process.env.REGISTRY_ADDRESS = ethers.utils.getContractAddress({
from: process.env.MANAGER_ADDRESS,
Expand All @@ -59,9 +52,16 @@ void async function () {
})
}

process.env.SSV_NETWORK_ADDRESS = '0xC3CD9A0aE89Fff83b71b58b6512D43F8a41f363D'
process.env.SSV_VIEWS_ADDRESS = '0xAE2C84c48272F5a1746150ef333D5E5B51F68763'
process.env.UNISWAP_V3_FACTORY_ADDRESS = process.env.UNISWAP_V3_FACTORY_ADDRESS || '0x1F98431c8aD98523631AE4a59f267346ea31F984'
if (!process.env.VIEWS_ADDRESS) {
process.env.VIEWS_ADDRESS = ethers.utils.getContractAddress({
from: wallet.address,
nonce: walletNonce + 2
})
}

process.env.SSV_NETWORK_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_NETWORK_ADDRESS
process.env.SSV_VIEWS_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SSV_VIEWS_ADDRESS
process.env.SWAP_FACTORY_ADDRESS = ETHEREUM_CONTRACTS[process.env.FORK.toUpperCase()]?.SWAP_FACTORY_ADDRESS

await run('npm run generate --workspace @casimir/oracle')
run('npm run test --workspace @casimir/ethereum')
Expand Down
Loading

0 comments on commit 6a4c2c1

Please sign in to comment.