|
| 1 | +import { Transaction } from "@mysten/sui/transactions"; |
| 2 | +import { DEEPTRADE_CORE_PACKAGE_ID, MULTISIG_CONFIG_OBJECT_ID, MULTISIG_ADMIN_CAP_OBJECT_ID } from "../constants"; |
| 3 | +import { buildAndLogMultisigTransaction } from "../multisig/buildAndLogMultisigTransaction"; |
| 4 | +import { MULTISIG_CONFIG } from "../multisig/multisig"; |
| 5 | +import { SIGNATURE_FLAG_TO_SCHEME } from "@mysten/sui/cryptography"; |
| 6 | + |
| 7 | +// --- NEW multisig config comes from standard MULTISIG_* env vars (loaded by multisig.ts) --- |
| 8 | +const { publicKeysSuiBytes, publicKeys, weights, threshold, address } = MULTISIG_CONFIG; |
| 9 | + |
| 10 | +// Usage: npx tsx examples/multisig/update-multisig-config.ts > update-multisig-config.log 2>&1 |
| 11 | +(async () => { |
| 12 | + console.warn(`Building transaction to update multisig config`); |
| 13 | + console.warn(`\nNew multisig config:`); |
| 14 | + console.warn(`- Address: ${address}`); |
| 15 | + console.warn(`- Signers: ${publicKeys.length}`); |
| 16 | + console.warn(`- Weights: ${JSON.stringify(weights)}`); |
| 17 | + console.warn(`- Threshold: ${threshold}`); |
| 18 | + publicKeys.forEach((pk, i) => { |
| 19 | + const scheme = SIGNATURE_FLAG_TO_SCHEME[pk.flag() as keyof typeof SIGNATURE_FLAG_TO_SCHEME]; |
| 20 | + console.warn(` - Signer ${i + 1}: ${pk.toSuiAddress()} (${scheme}, weight: ${weights[i]})`); |
| 21 | + }); |
| 22 | + |
| 23 | + const tx = new Transaction(); |
| 24 | + |
| 25 | + tx.moveCall({ |
| 26 | + target: `${DEEPTRADE_CORE_PACKAGE_ID}::multisig_config::update_multisig_config`, |
| 27 | + arguments: [ |
| 28 | + tx.object(MULTISIG_CONFIG_OBJECT_ID), |
| 29 | + tx.object(MULTISIG_ADMIN_CAP_OBJECT_ID), |
| 30 | + tx.pure.vector("vector<u8>", publicKeysSuiBytes), |
| 31 | + tx.pure.vector("u8", weights), |
| 32 | + tx.pure.u16(threshold), |
| 33 | + ], |
| 34 | + }); |
| 35 | + |
| 36 | + await buildAndLogMultisigTransaction(tx); |
| 37 | +})(); |
0 commit comments