From c7354510fe75c9be4fada3475cce2183fdf0c785 Mon Sep 17 00:00:00 2001 From: Corban Riley Date: Fri, 12 Apr 2024 11:48:51 -0400 Subject: [PATCH] wip 3 --- networks/hardhat.json | 22 ++++++++++++++++++++++ package.json | 2 +- test/Factory.spec.ts | 5 +++++ test/MainModule.spec.ts | 1 + test/utils/contracts.ts | 6 +++++- test/utils/wallet.ts | 24 +++++++++++++----------- 6 files changed, 47 insertions(+), 13 deletions(-) create mode 100644 networks/hardhat.json diff --git a/networks/hardhat.json b/networks/hardhat.json new file mode 100644 index 00000000..67df434c --- /dev/null +++ b/networks/hardhat.json @@ -0,0 +1,22 @@ +[ + { + "contractName": "WalletFactory", + "address": "0xFaA5c0b14d1bED5C888Ca655B9a8A5911F78eF4A" + }, + { + "contractName": "MainModule", + "address": "0xE1846F966D116B86d65481Fe81886219D698b60D" + }, + { + "contractName": "MainModuleUpgradable", + "address": "0xB39E1ed61caC9E8eE8CDD3218765cF6a7fE390db" + }, + { + "contractName": "GuestModule", + "address": "0x28Ec0675C7b40ed78EBcBBbDF39e5652c0787B18" + }, + { + "contractName": "SequenceUtils", + "address": "0x4817Fe9f2352E88991A7c84E4385708Ccff05704" + } +] \ No newline at end of file diff --git a/package.json b/package.json index 581c31f2..528fd5ac 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "test": "hardhat test", "benchmark": "BENCHMARK=true pnpm test", "coverage": "COVERAGE=true NET_ID=1 hardhat coverage", - "deploy": "hardhat run utils/deploy-contracts.ts --network", + "deploy": "hardhat run utils/deploy-contracts.ts --network hardhat", "verify": "hardhat verify --network", "release": "pnpm publish src", "lint": "pnpm lint:ts && pnpm lint:sol", diff --git a/test/Factory.spec.ts b/test/Factory.spec.ts index b4dad4a6..c4988574 100644 --- a/test/Factory.spec.ts +++ b/test/Factory.spec.ts @@ -12,6 +12,9 @@ contract('Factory', () => { beforeEach(async () => { module = await ModuleMock.deploy() factory = await Factory.deploy() + + await module.waitForDeployment() + await factory.waitForDeployment() }) describe('Deploy wallets', () => { @@ -20,12 +23,14 @@ contract('Factory', () => { await module.getAddress(), ethers.AbiCoder.defaultAbiCoder().encode(['address'], [ethers.Wallet.createRandom().address]) ) + await factory.waitForDeployment() }) it('Should predict wallet address', async () => { const hash = ethers.hexlify(ethers.randomBytes(32)) const predict = addressOf(await factory.getAddress(), await module.getAddress(), hash) await factory.deploy(await module.getAddress(), hash) + await factory.waitForDeployment() expect(await hethers.provider.getCode(predict)).to.not.equal('0x') }) diff --git a/test/MainModule.spec.ts b/test/MainModule.spec.ts index 69cb1c76..8b3bb343 100644 --- a/test/MainModule.spec.ts +++ b/test/MainModule.spec.ts @@ -46,6 +46,7 @@ contract('MainModule', (accounts: string[]) => { beforeEach(async () => { callReceiver = await CallReceiverMock.deploy() + await callReceiver.waitForDeployment() wallet = SequenceWallet.basicWallet(context) await wallet.deploy() diff --git a/test/utils/contracts.ts b/test/utils/contracts.ts index f9d0f696..c2d6561b 100644 --- a/test/utils/contracts.ts +++ b/test/utils/contracts.ts @@ -73,7 +73,11 @@ export const deploySequenceContext = async (owner?: string) => { const mainModuleUpgradable = await MainModuleUpgradable.deploy() const mainModule = await MainModule.deploy(await factory.getAddress(), await mainModuleUpgradable.getAddress()) - return { factory, mainModule, mainModuleUpgradable } + return { + factory: await factory.waitForDeployment(), + mainModule: await mainModule.waitForDeployment(), + mainModuleUpgradable: await mainModuleUpgradable.waitForDeployment() + } } export type SequenceContext = { diff --git a/test/utils/wallet.ts b/test/utils/wallet.ts index 72cf3111..b23690a6 100644 --- a/test/utils/wallet.ts +++ b/test/utils/wallet.ts @@ -84,13 +84,7 @@ export class SequenceWallet { public isSequence = true _isSigner: boolean = true - factoryAddress: string = ethers.ZeroAddress - mainModuleAddress: string = ethers.ZeroAddress - - constructor(public options: WalletOptions) { - this.options.context.factory.getAddress().then(address => (this.factoryAddress = address)) - this.options.context.mainModule.getAddress().then(address => (this.mainModuleAddress = address)) - } + constructor(public options: WalletOptions) {} static basicWallet(context: SequenceContext, opts?: Partial): SequenceWallet { const options = { ...{ signing: 1, idle: 0, topologyConverter: defaultTopology }, ...opts } @@ -188,7 +182,11 @@ export class SequenceWallet { get address() { if (this.options.address) return this.options.address - return addressOf(this.factoryAddress, this.mainModuleAddress, this.imageHash) + return addressOf( + this.options.context.factory.target as string, + this.options.context.mainModule.target as string, + this.imageHash + ) } getAddress() { @@ -212,14 +210,15 @@ export class SequenceWallet { return } - return this.options.context.factory.deploy(await this.options.context.mainModule.getAddress(), this.imageHash) + await this.options.context.factory.deploy(await this.options.context.mainModule.getAddress(), this.imageHash) + return this.options.context.factory.waitForDeployment() } async getNonce(space: ethers.BigNumberish = 0) { return this.mainModule.readNonce(space) } - async updateImageHash(input: ethers.BytesLike | WalletConfig) { + async updateImageHash(input: ethers.BytesLike | WalletConfig): Promise { if (!ethers.isBytesLike(input)) return this.updateImageHash(imageHash(input)) return this.sendTransactions([ @@ -230,7 +229,10 @@ export class SequenceWallet { ]) } - async addExtraImageHash(input: ethers.BytesLike | WalletConfig, expiration: ethers.BigNumberish = 2n ** 248n) { + async addExtraImageHash( + input: ethers.BytesLike | WalletConfig, + expiration: ethers.BigNumberish = 2n ** 248n + ): Promise { if (!ethers.isBytesLike(input)) return this.addExtraImageHash(imageHash(input)) return this.sendTransactions([