diff --git a/deployments/multisig.txt b/deployments/multisig.txt new file mode 100644 index 00000000..09e4b9ae --- /dev/null +++ b/deployments/multisig.txt @@ -0,0 +1 @@ +0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48: 0.1.0 (goerli-1, goerli-2) diff --git a/scripts/deploy-account.ts b/scripts/deploy-account.ts index a2d980f9..d009534e 100644 --- a/scripts/deploy-account.ts +++ b/scripts/deploy-account.ts @@ -1,9 +1,9 @@ import "dotenv/config"; import { declareContract, deployAccount, deployer, loadContract, provider } from "../tests/lib"; -const argentAccountClassHash = await declareContract("ArgentAccount", false); +const argentAccountClassHash = await declareContract("ArgentAccount", true); console.log("ArgentAccount class hash:", argentAccountClassHash); -const testDappClassHash = await declareContract("TestDapp", false); +const testDappClassHash = await declareContract("TestDapp", true); console.log("TestDapp class hash:", testDappClassHash); console.log("Deploying new account"); diff --git a/scripts/deploy-multisig.ts b/scripts/deploy-multisig.ts new file mode 100644 index 00000000..c775532f --- /dev/null +++ b/scripts/deploy-multisig.ts @@ -0,0 +1,33 @@ +import "dotenv/config"; +import { declareContract, deployer, deployMultisig, loadContract, provider } from "../tests/lib"; + +const multisigClassHash = await declareContract("ArgentMultisig", true); +console.log("ArgentMultisig class hash:", multisigClassHash); +const testDappClassHash = await declareContract("TestDapp", true); +console.log("TestDapp class hash:", testDappClassHash); + +console.log("Deploying new account"); + +const threshold = 1; +const signersLength = 2; +const { account, keys, signers } = await deployMultisig(multisigClassHash, threshold, signersLength); + +console.log("Account address:", account.address); +console.log("Account signers:", signers); +console.log( + "Account private keys:", + keys.map(({ privateKey }) => privateKey), +); + +console.log("Deploying new test dapp"); +const { contract_address } = await deployer.deployContract({ classHash: testDappClassHash }); +console.log("TestDapp address:", contract_address); +const testDappContract = await loadContract(contract_address); + +console.log("Calling test dapp"); +testDappContract.connect(account); +const response = await testDappContract.set_number(42n); +await provider.waitForTransaction(response.transaction_hash); + +const number = await testDappContract.get_number(account.address); +console.log(number === 42n ? "Seems good!" : "Something went wrong :("); diff --git a/tests/lib/accounts.ts b/tests/lib/accounts.ts index 556e633a..b270f3ec 100644 --- a/tests/lib/accounts.ts +++ b/tests/lib/accounts.ts @@ -147,15 +147,16 @@ export async function upgradeAccount( return await provider.waitForTransaction(transferTxHash); } -export async function fundAccount(recipient: string, amount: number | bigint): Promise { +export async function fundAccount(recipient: string, amount: number | bigint) { if (provider.isDevnet) { - return await mintEth(recipient); + await mintEth(recipient); + return; } const ethContract = await getEthContract(); ethContract.connect(deployer); const bn = uint256.bnToUint256(amount); - await ethContract.invoke("transfer", CallData.compile([recipient, bn.low, bn.high])); + return ethContract.invoke("transfer", CallData.compile([recipient, bn.low, bn.high])); } export enum EscapeStatus { diff --git a/tests/lib/multisig.ts b/tests/lib/multisig.ts index 6711df76..3394a2d3 100644 --- a/tests/lib/multisig.ts +++ b/tests/lib/multisig.ts @@ -1,5 +1,5 @@ import { Account, CallData, Contract, GetTransactionReceiptResponse, hash, num } from "starknet"; -import { KeyPair, MultisigSigner, loadContract, mintEth, provider, randomKeyPair, randomKeyPairs } from "."; +import { KeyPair, MultisigSigner, loadContract, provider, randomKeyPair, randomKeyPairs, fundAccount } from "."; export interface MultisigWallet { account: Account; @@ -22,7 +22,10 @@ export async function deployMultisig( const addressSalt = num.toHex(randomKeyPair().privateKey); const contractAddress = hash.calculateContractAddressFromHash(addressSalt, classHash, constructorCalldata, 0); - await mintEth(contractAddress); + const response = await fundAccount(contractAddress, 1e15); // 0.001 ETH + if (response) { + await provider.waitForTransaction(response.transaction_hash); + } const deploymentSigner = new MultisigSigner(keys.filter((_, i) => deploymentIndexes.includes(i))); const account = new Account(provider, contractAddress, deploymentSigner, "1");