Skip to content

Commit e5ef12c

Browse files
authored
add init multisig & update multisig config ci (#131)
2 parents 6a2b6b2 + f90c031 commit e5ef12c

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Manage Multisig Config
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
action_type:
7+
description: "Select action"
8+
type: choice
9+
options:
10+
- Initialize Multisig Config
11+
- Update Multisig Config
12+
13+
jobs:
14+
build-multisig-config-tx:
15+
runs-on: ubuntu-latest
16+
env:
17+
# Multisig config (from repo vars — the target state)
18+
MULTISIG_ADDRESS: ${{ vars.MULTISIG_ADDRESS }}
19+
MULTISIG_SIGNERS_BASE64_PUBKEYS: ${{ vars.MULTISIG_SIGNERS_BASE64_PUBKEYS }}
20+
MULTISIG_THRESHOLD: ${{ vars.MULTISIG_THRESHOLD }}
21+
MULTISIG_WEIGHTS: ${{ vars.MULTISIG_WEIGHTS }}
22+
steps:
23+
- name: Checkout Code
24+
uses: actions/checkout@v4
25+
26+
- name: Setup Node.js
27+
uses: actions/setup-node@v4
28+
with:
29+
node-version: 20
30+
31+
- name: Install Dependencies
32+
run: npm ci
33+
34+
- name: Build Initialize Multisig Config Transaction
35+
if: ${{ inputs.action_type == 'Initialize Multisig Config' }}
36+
run: npx tsx examples/multisig/initialize-multisig-config.ts
37+
38+
- name: Build Update Multisig Config Transaction
39+
if: ${{ inputs.action_type == 'Update Multisig Config' }}
40+
run: npx tsx examples/multisig/update-multisig-config.ts
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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+
6+
// Usage: npx tsx examples/multisig/initialize-multisig-config.ts > initialize-multisig-config.log 2>&1
7+
(async () => {
8+
const { publicKeysSuiBytes, weights, threshold, address } = MULTISIG_CONFIG;
9+
10+
console.warn(`Building transaction to initialize multisig config`);
11+
console.warn(`- Multisig address: ${address}`);
12+
console.warn(`- Signers: ${publicKeysSuiBytes.length}`);
13+
console.warn(`- Weights: ${JSON.stringify(weights)}`);
14+
console.warn(`- Threshold: ${threshold}`);
15+
16+
const tx = new Transaction();
17+
18+
tx.moveCall({
19+
target: `${DEEPTRADE_CORE_PACKAGE_ID}::multisig_config::initialize_multisig_config`,
20+
arguments: [
21+
tx.object(MULTISIG_CONFIG_OBJECT_ID),
22+
tx.object(MULTISIG_ADMIN_CAP_OBJECT_ID),
23+
tx.pure.vector("vector<u8>", publicKeysSuiBytes),
24+
tx.pure.vector("u8", weights),
25+
tx.pure.u16(threshold),
26+
],
27+
});
28+
29+
await buildAndLogMultisigTransaction(tx);
30+
})();
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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

Comments
 (0)