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

Bump up dependencies and move setupL2 #268

Merged
merged 5 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@
"@celo/connect": "^5.3.0",
"@celo/contractkit": "^8.0.0",
"@celo/cryptographic-utils": "^5.0.8",
"@celo/devchain-anvil": "^0.0.11007",
"@celo/explorer": "^5.0.10",
"@celo/governance": "^5.1.1",
"@celo/identity": "^5.1.2",
Expand Down Expand Up @@ -75,6 +74,7 @@
"devDependencies": {
"@celo/celo-devchain": "^7.0.0",
"@celo/dev-utils": "0.0.3",
"@celo/devchain-anvil": "0.0.10957",
"@celo/typescript": "workspace:^",
"@types/debug": "^4.1.4",
"@types/fs-extra": "^8.0.0",
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/network/contracts-l2.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { setupL2, testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import write from '@oclif/core/lib/cli-ux/write'
import { setupL2 } from '../../test-utils/chain-setup'
import { testLocallyWithWeb3Node } from '../../test-utils/cliUtils'
import Contracts from './contracts'
process.env.NO_SYNCCHECK = 'true'
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/network/info-l2.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { newKitFromWeb3 } from '@celo/contractkit'
import { testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { setupL2 } from '../../test-utils/chain-setup'
import { setupL2, testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { stripAnsiCodesFromNestedArray, testLocallyWithWeb3Node } from '../../test-utils/cliUtils'
import Info from './info'
process.env.NO_SYNCCHECK = 'true'
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/network/parameters-l2.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { setupL2 } from '../../test-utils/chain-setup'
import { setupL2, testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { stripAnsiCodesFromNestedArray, testLocallyWithWeb3Node } from '../../test-utils/cliUtils'
import Parameters from './parameters'

Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/commands/network/whitelist-l2.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { setupL2, testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import Web3 from 'web3'
import { setupL2 } from '../../test-utils/chain-setup'
import { testLocallyWithWeb3Node } from '../../test-utils/cliUtils'
import Whitelist from './whitelist'

Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/test-utils/chain-setup.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { isCel2 } from '@celo/connect'
import { testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { setupL2, testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import Web3 from 'web3'
import { setupL2 } from './chain-setup'

testWithAnvil('chain setup', (web3: Web3) => {
describe('setupL2()', () => {
Expand Down
10 changes: 0 additions & 10 deletions packages/cli/src/test-utils/chain-setup.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
import { StrongAddress } from '@celo/base'
import { PROXY_ADMIN_ADDRESS } from '@celo/connect'
import { ContractKit, StableToken } from '@celo/contractkit'
import {
DEFAULT_OWNER_ADDRESS,
STABLES_ADDRESS,
impersonateAccount,
setCode,
stopImpersonatingAccount,
} from '@celo/dev-utils/lib/anvil-test'
import { mineBlocks } from '@celo/dev-utils/lib/ganache-test'
import { addressToPublicKey } from '@celo/utils/lib/signatureUtils'
import BigNumber from 'bignumber.js'
import Web3 from 'web3'
import { proxyBytecode } from './constants'

export const GANACHE_EPOCH_SIZE = 100
export const MIN_LOCKED_CELO_VALUE = new BigNumber(Web3.utils.toWei('10000', 'ether')) // 10k CELO
Expand Down Expand Up @@ -142,13 +139,6 @@ export const topUpWithToken = async (
await stopImpersonatingAccount(kit.web3, STABLES_ADDRESS)
}

// TODO remove this once no longer needed
export const setupL2 = async (web3: Web3) => {
// Temporarily deploying any bytecode, so it's just there,
// isCel2 should hence return true as it just checks for bytecode existence
await setCode(web3, PROXY_ADMIN_ADDRESS, proxyBytecode)
}

// replace the original owner in the devchain, so we can act as the multisig owner
// the transaction needs to be sent by the multisig itself and it needs some funds first
export const changeMultiSigOwner = async (kit: ContractKit, toAccount: StrongAddress) => {
Expand Down
3 changes: 1 addition & 2 deletions packages/cli/src/utils/fee-currency.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import { isCel2 } from '@celo/connect'
import { newKitFromWeb3 } from '@celo/contractkit'
import { FeeCurrencyDirectoryWrapper } from '@celo/contractkit/lib/wrappers/FeeCurrencyDirectoryWrapper'
import { FeeCurrencyWhitelistWrapper } from '@celo/contractkit/lib/wrappers/FeeCurrencyWhitelistWrapper'
import { testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import { setupL2, testWithAnvil } from '@celo/dev-utils/lib/anvil-test'
import Web3 from 'web3'
import { setupL2 } from '../test-utils/chain-setup'
import { getFeeCurrencyContractWrapper } from './fee-currency'

testWithAnvil('getFeeCurrencyContractWrapper', async (web3: Web3) => {
Expand Down
18 changes: 18 additions & 0 deletions packages/dev-utils/src/anvil-test.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PROXY_ADMIN_ADDRESS } from '@celo/connect'
import { Anvil, CreateAnvilOptions, createAnvil } from '@viem/anvil'
import Web3 from 'web3'
import {
Expand Down Expand Up @@ -57,6 +58,23 @@ export function stopImpersonatingAccount(web3: Web3, address: string) {
return jsonRpcCall(web3, 'anvil_stopImpersonatingAccount', [address])
}

export const withImpersonatedAccount = async (
web3: Web3,
account: string,
fn: () => Promise<void>
) => {
await impersonateAccount(web3, account)
await fn()
await stopImpersonatingAccount(web3, account)
}

export function setCode(web3: Web3, address: string, code: string) {
return jsonRpcCall(web3, 'anvil_setCode', [address, code])
}

// TODO remove this once no longer needed
export const setupL2 = async (web3: Web3) => {
// Temporarily deploying any bytecode, so it's just there,
// isCel2 should hence return true as it just checks for bytecode existence
await setCode(web3, PROXY_ADMIN_ADDRESS, '0x1234567890')
}
2 changes: 1 addition & 1 deletion packages/sdk/contractkit/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
},
"dependencies": {
"@celo/abis": "11.0.0",
"@celo/abis-12": "npm:@celo/[email protected].0",
"@celo/abis-12": "npm:@celo/[email protected].2",
"@celo/base": "^6.0.1",
"@celo/connect": "^5.3.0",
"@celo/utils": "^6.0.1",
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1555,10 +1555,10 @@ __metadata:
languageName: node
linkType: hard

"@celo/abis-12@npm:@celo/[email protected].0":
version: 12.0.0-canary.0
resolution: "@celo/abis@npm:12.0.0-canary.0"
checksum: a7bc515a936b9ee8c198f3d5699c56ebe144df2a3123625e7f5f1480e248f4667efa16669997f6547a85cbdf329d903eea88ecf6ace222e334e34609910da656
"@celo/abis-12@npm:@celo/[email protected].2":
version: 12.0.0-canary.2
resolution: "@celo/abis@npm:12.0.0-canary.2"
checksum: 01d62e7b11b1d2f2b8feaaedbed1615b016b09b2903bcb48695de855399548f9ab150a38add32f2887ae6dba958586d49ee12c809b867699b2808de2ea8796e2
languageName: node
linkType: hard

Expand Down Expand Up @@ -1619,7 +1619,7 @@ __metadata:
"@celo/contractkit": "npm:^8.0.0"
"@celo/cryptographic-utils": "npm:^5.0.8"
"@celo/dev-utils": "npm:0.0.3"
"@celo/devchain-anvil": "npm:^0.0.11007"
"@celo/devchain-anvil": "npm:0.0.10957"
"@celo/explorer": "npm:^5.0.10"
"@celo/governance": "npm:^5.1.1"
"@celo/identity": "npm:^5.1.2"
Expand Down Expand Up @@ -1750,7 +1750,7 @@ __metadata:
resolution: "@celo/contractkit@workspace:packages/sdk/contractkit"
dependencies:
"@celo/abis": "npm:11.0.0"
"@celo/abis-12": "npm:@celo/[email protected].0"
"@celo/abis-12": "npm:@celo/[email protected].2"
"@celo/base": "npm:^6.0.1"
"@celo/celo-devchain": "npm:^7.0.0"
"@celo/connect": "npm:^5.3.0"
Expand Down Expand Up @@ -1813,10 +1813,10 @@ __metadata:
languageName: unknown
linkType: soft

"@celo/devchain-anvil@npm:^0.0.11007":
version: 0.0.11007
resolution: "@celo/devchain-anvil@npm:0.0.11007"
checksum: 08ff1904363969996e5b747781c317c45150a6ddee4868ae6aae6e515114ebb0b953a0abaecce1c2f7550544facc53beaf0081b8dfdfb5757ceece4e1c69e2e1
"@celo/devchain-anvil@npm:0.0.10957":
version: 0.0.10957
resolution: "@celo/devchain-anvil@npm:0.0.10957"
checksum: b74167cbb6902a5e7d6c88e7f74691c4fef02a2e2e03cc8cf3fac676088289fe9571cbaaeb63a32510ff36ef3a47f774ef18db6243d4c94efc620d18f263b22e
languageName: node
linkType: hard

Expand Down
Loading