Skip to content

Commit cdf10b1

Browse files
committed
Add multisig deployment
1 parent d56ca25 commit cdf10b1

File tree

5 files changed

+45
-7
lines changed

5 files changed

+45
-7
lines changed

deployments/multisig.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0x737ee2f87ce571a58c6c8da558ec18a07ceb64a6172d5ec46171fbc80077a48: 0.1.0 (goerli-1, goerli-2)

scripts/deploy-account.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import "dotenv/config";
22
import { declareContract, deployAccount, deployer, loadContract, provider } from "../tests/lib";
33

4-
const argentAccountClassHash = await declareContract("ArgentAccount", false);
4+
const argentAccountClassHash = await declareContract("ArgentAccount", true);
55
console.log("ArgentAccount class hash:", argentAccountClassHash);
6-
const testDappClassHash = await declareContract("TestDapp", false);
6+
const testDappClassHash = await declareContract("TestDapp", true);
77
console.log("TestDapp class hash:", testDappClassHash);
88

99
console.log("Deploying new account");

scripts/deploy-multisig.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import "dotenv/config";
2+
import { declareContract, deployer, deployMultisig, loadContract, provider } from "../tests/lib";
3+
4+
const multisigClassHash = await declareContract("ArgentMultisig", true);
5+
console.log("ArgentMultisig class hash:", multisigClassHash);
6+
const testDappClassHash = await declareContract("TestDapp", true);
7+
console.log("TestDapp class hash:", testDappClassHash);
8+
9+
console.log("Deploying new account");
10+
11+
const threshold = 1;
12+
const signersLength = 2;
13+
const { account, keys, signers } = await deployMultisig(multisigClassHash, threshold, signersLength);
14+
15+
console.log("Account address:", account.address);
16+
console.log("Account signers:", signers);
17+
console.log(
18+
"Account private keys:",
19+
keys.map(({ privateKey }) => privateKey),
20+
);
21+
22+
console.log("Deploying new test dapp");
23+
const { contract_address } = await deployer.deployContract({ classHash: testDappClassHash });
24+
console.log("TestDapp address:", contract_address);
25+
const testDappContract = await loadContract(contract_address);
26+
27+
console.log("Calling test dapp");
28+
testDappContract.connect(account);
29+
const response = await testDappContract.set_number(42n);
30+
await provider.waitForTransaction(response.transaction_hash);
31+
32+
const number = await testDappContract.get_number(account.address);
33+
console.log(number === 42n ? "Seems good!" : "Something went wrong :(");

tests/lib/accounts.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -147,15 +147,16 @@ export async function upgradeAccount(
147147
return await provider.waitForTransaction(transferTxHash);
148148
}
149149

150-
export async function fundAccount(recipient: string, amount: number | bigint): Promise<void> {
150+
export async function fundAccount(recipient: string, amount: number | bigint) {
151151
if (provider.isDevnet) {
152-
return await mintEth(recipient);
152+
await mintEth(recipient);
153+
return;
153154
}
154155
const ethContract = await getEthContract();
155156
ethContract.connect(deployer);
156157

157158
const bn = uint256.bnToUint256(amount);
158-
await ethContract.invoke("transfer", CallData.compile([recipient, bn.low, bn.high]));
159+
return ethContract.invoke("transfer", CallData.compile([recipient, bn.low, bn.high]));
159160
}
160161

161162
export enum EscapeStatus {

tests/lib/multisig.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Account, CallData, Contract, GetTransactionReceiptResponse, hash, num } from "starknet";
2-
import { KeyPair, MultisigSigner, loadContract, mintEth, provider, randomKeyPair, randomKeyPairs } from ".";
2+
import { KeyPair, MultisigSigner, loadContract, provider, randomKeyPair, randomKeyPairs, fundAccount } from ".";
33

44
export interface MultisigWallet {
55
account: Account;
@@ -22,7 +22,10 @@ export async function deployMultisig(
2222
const addressSalt = num.toHex(randomKeyPair().privateKey);
2323

2424
const contractAddress = hash.calculateContractAddressFromHash(addressSalt, classHash, constructorCalldata, 0);
25-
await mintEth(contractAddress);
25+
const response = await fundAccount(contractAddress, 1e15); // 0.001 ETH
26+
if (response) {
27+
await provider.waitForTransaction(response.transaction_hash);
28+
}
2629

2730
const deploymentSigner = new MultisigSigner(keys.filter((_, i) => deploymentIndexes.includes(i)));
2831
const account = new Account(provider, contractAddress, deploymentSigner, "1");

0 commit comments

Comments
 (0)