Skip to content

Commit

Permalink
first draft
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Jan 21, 2025
1 parent 1352198 commit 3c947f3
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions scripts/multisig-change-threshold.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
////////////////////////////////////////////////////////////////////////////////////////////
// Instructions:
// - Setup `.env` file with all 3 variables.
// For instance for goerli network you can use this:
// RPC_URL=https://api.hydrogen.argent47.net/v1/starknet/goerli/rpc/v0.6
// - Run the command: `yarn tsc && node --loader ts-node/esm scripts/multisig-change-threshold.ts`
////////////////////////////////////////////////////////////////////////////////////////////
import "dotenv/config";
import { RPC } from "starknet";
import { ArgentAccount, LegacyMultisigKeyPair, LegacyMultisigSigner, ensureSuccess, manager } from "../lib";

const privateKey2 = "";

// You shouldn't modify anything below this line
const contractAddress = process.env.ADDRESS;
const privateKey1 = process.env.PRIVATE_KEY;
const newThreshold = 1;

if (!contractAddress || !privateKey1 || !privateKey2) {
console.error("Please set the ADDRESS, PRIVATE_KEY environment variables, and fill in the privateKey2 variable");
process.exit(1);
}

const signer1 = new LegacyMultisigKeyPair(privateKey1);
const signer2 = new LegacyMultisigKeyPair(privateKey2);

const signer = new LegacyMultisigSigner([signer1, signer2]);
const account = new ArgentAccount(manager, contractAddress, signer, "1", RPC.ETransactionVersion.V3);
const accountContract = await manager.loadContract(contractAddress);

// This script only works with this classHash
if (accountContract.classHash !== "0x6e150953b26271a740bf2b6e9bca17cc52c68d765f761295de51ceb8526ee72") {
console.error("Invalid class hash");
process.exit(1);
}

accountContract.connect(account);
const { transaction_hash: txHash } = await ensureSuccess(await accountContract.change_threshold(newThreshold));
console.log(`Threshold successfully updated to ${newThreshold}, transaction hash: ${txHash}`);

0 comments on commit 3c947f3

Please sign in to comment.