Skip to content

Commit 17c5307

Browse files
authored
Feature/ci multisig management (#132)
2 parents e5ef12c + b574967 commit 17c5307

File tree

8 files changed

+703
-266
lines changed

8 files changed

+703
-266
lines changed

.github/workflows/build-manage-multisig-config-tx.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Manage Multisig Config
1+
name: Build Multisig Config Transaction
22

33
on:
44
workflow_dispatch:
@@ -19,6 +19,7 @@ jobs:
1919
MULTISIG_SIGNERS_BASE64_PUBKEYS: ${{ vars.MULTISIG_SIGNERS_BASE64_PUBKEYS }}
2020
MULTISIG_THRESHOLD: ${{ vars.MULTISIG_THRESHOLD }}
2121
MULTISIG_WEIGHTS: ${{ vars.MULTISIG_WEIGHTS }}
22+
MULTISIG_ADMIN_CAP_HOLDER_ADDRESS: ${{ vars.MULTISIG_ADMIN_CAP_HOLDER_ADDRESS }}
2223
steps:
2324
- name: Checkout Code
2425
uses: actions/checkout@v4
Lines changed: 38 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,47 @@
1-
name: Manage Protocol Version
1+
name: Build Protocol Version Transaction
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
action_type:
7-
description: "Select action"
8-
type: choice
9-
options:
10-
- Enable Version
11-
- Disable Version
12-
target_version:
13-
description: "Protocol Version Number (e.g., 1, 2, etc.)"
14-
required: true
15-
type: string
4+
workflow_dispatch:
5+
inputs:
6+
action_type:
7+
description: "Select action"
8+
type: choice
9+
options:
10+
- Enable Version
11+
- Disable Version
12+
target_version:
13+
description: "Protocol Version Number (e.g., 1, 2, etc.)"
14+
required: true
15+
type: string
1616

1717
jobs:
18-
build-version-tx:
19-
runs-on: ubuntu-latest
20-
env:
21-
# Multisig specific config (can be secrets or vars)
22-
MULTISIG_ADDRESS: ${{ vars.MULTISIG_ADDRESS }}
23-
MULTISIG_SIGNERS_BASE64_PUBKEYS: ${{ vars.MULTISIG_SIGNERS_BASE64_PUBKEYS }}
24-
MULTISIG_THRESHOLD: ${{ vars.MULTISIG_THRESHOLD }}
25-
MULTISIG_WEIGHTS: ${{ vars.MULTISIG_WEIGHTS }}
18+
build-version-tx:
19+
runs-on: ubuntu-latest
20+
env:
21+
# Multisig specific config (can be secrets or vars)
22+
MULTISIG_ADDRESS: ${{ vars.MULTISIG_ADDRESS }}
23+
MULTISIG_SIGNERS_BASE64_PUBKEYS: ${{ vars.MULTISIG_SIGNERS_BASE64_PUBKEYS }}
24+
MULTISIG_THRESHOLD: ${{ vars.MULTISIG_THRESHOLD }}
25+
MULTISIG_WEIGHTS: ${{ vars.MULTISIG_WEIGHTS }}
2626

27-
# Dynamic Inputs
28-
PROTOCOL_VERSION: ${{ inputs.target_version }}
29-
steps:
30-
- name: Checkout Code
31-
uses: actions/checkout@v4
27+
# Dynamic Inputs
28+
PROTOCOL_VERSION: ${{ inputs.target_version }}
29+
steps:
30+
- name: Checkout Code
31+
uses: actions/checkout@v4
3232

33-
- name: Setup Node.js
34-
uses: actions/setup-node@v4
35-
with:
36-
node-version: 20
33+
- name: Setup Node.js
34+
uses: actions/setup-node@v4
35+
with:
36+
node-version: 20
3737

38-
- name: Install Dependencies
39-
run: npm ci
38+
- name: Install Dependencies
39+
run: npm ci
4040

41-
- name: Build Enable Version Transaction
42-
if: ${{ inputs.action_type == 'Enable Version' }}
43-
run: npx tsx examples/treasury/versions/enable-version.ts
41+
- name: Build Enable Version Transaction
42+
if: ${{ inputs.action_type == 'Enable Version' }}
43+
run: npx tsx examples/treasury/versions/enable-version.ts
4444

45-
- name: Build Disable Version Transaction
46-
if: ${{ inputs.action_type == 'Disable Version' }}
47-
run: npx tsx examples/treasury/versions/disable-version.ts
45+
- name: Build Disable Version Transaction
46+
if: ${{ inputs.action_type == 'Disable Version' }}
47+
run: npx tsx examples/treasury/versions/disable-version.ts
Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,52 @@
1-
name: Withdraw Fees Transaction
1+
name: Build Withdraw Fees Transaction
22

33
on:
4-
workflow_dispatch:
5-
inputs:
6-
withdrawal_type:
7-
description: "Select what to withdraw"
8-
type: choice
9-
options:
10-
- Withdraw Protocol Fees
11-
- Withdraw Coverage Fees
12-
- Withdraw DEEP Reserves
13-
tickets:
14-
description: "Comma-separated list of Ticket Object IDs (e.g. 0x123..., 0xabc...)"
15-
required: true
16-
type: string
4+
workflow_dispatch:
5+
inputs:
6+
withdrawal_type:
7+
description: "Select what to withdraw"
8+
type: choice
9+
options:
10+
- Withdraw Protocol Fees
11+
- Withdraw Coverage Fees
12+
- Withdraw DEEP Reserves
13+
tickets:
14+
description: "Comma-separated list of Ticket Object IDs (e.g. 0x123..., 0xabc...)"
15+
required: true
16+
type: string
1717

1818
jobs:
19-
build-withdraw-tx:
20-
runs-on: ubuntu-latest
21-
env:
22-
# Multisig specific config (can be secrets or vars)
23-
MULTISIG_ADDRESS: ${{ vars.MULTISIG_ADDRESS }}
24-
MULTISIG_SIGNERS_BASE64_PUBKEYS: ${{ vars.MULTISIG_SIGNERS_BASE64_PUBKEYS }}
25-
MULTISIG_THRESHOLD: ${{ vars.MULTISIG_THRESHOLD }}
26-
MULTISIG_WEIGHTS: ${{ vars.MULTISIG_WEIGHTS }}
27-
28-
# Dynamic Inputs
29-
TICKETS: ${{ inputs.tickets }}
30-
steps:
31-
- name: Checkout Code
32-
uses: actions/checkout@v4
33-
34-
- name: Setup Node.js
35-
uses: actions/setup-node@v4
36-
with:
37-
node-version: 20
38-
39-
- name: Install Dependencies
40-
run: npm ci
41-
42-
- name: Build Protocol Fees Withdrawal
43-
if: ${{ inputs.withdrawal_type == 'Withdraw Protocol Fees' }}
44-
run: npx tsx examples/ticket/admin-withdraw-protocol-fee.ts
45-
46-
- name: Build Coverage Fees Withdrawal
47-
if: ${{ inputs.withdrawal_type == 'Withdraw Coverage Fees' }}
48-
run: npx tsx examples/ticket/admin-withdraw-all-coins-coverage-fee.ts
49-
50-
- name: Build DEEP Reserves Withdrawal
51-
if: ${{ inputs.withdrawal_type == 'Withdraw DEEP Reserves' }}
52-
run: npx tsx examples/ticket/admin-withdraw-all-deep-reserves.ts
19+
build-withdraw-tx:
20+
runs-on: ubuntu-latest
21+
env:
22+
# Multisig specific config (can be secrets or vars)
23+
MULTISIG_ADDRESS: ${{ vars.MULTISIG_ADDRESS }}
24+
MULTISIG_SIGNERS_BASE64_PUBKEYS: ${{ vars.MULTISIG_SIGNERS_BASE64_PUBKEYS }}
25+
MULTISIG_THRESHOLD: ${{ vars.MULTISIG_THRESHOLD }}
26+
MULTISIG_WEIGHTS: ${{ vars.MULTISIG_WEIGHTS }}
27+
28+
# Dynamic Inputs
29+
TICKETS: ${{ inputs.tickets }}
30+
steps:
31+
- name: Checkout Code
32+
uses: actions/checkout@v4
33+
34+
- name: Setup Node.js
35+
uses: actions/setup-node@v4
36+
with:
37+
node-version: 20
38+
39+
- name: Install Dependencies
40+
run: npm ci
41+
42+
- name: Build Protocol Fees Withdrawal
43+
if: ${{ inputs.withdrawal_type == 'Withdraw Protocol Fees' }}
44+
run: npx tsx examples/ticket/admin-withdraw-protocol-fee.ts
45+
46+
- name: Build Coverage Fees Withdrawal
47+
if: ${{ inputs.withdrawal_type == 'Withdraw Coverage Fees' }}
48+
run: npx tsx examples/ticket/admin-withdraw-all-coins-coverage-fee.ts
49+
50+
- name: Build DEEP Reserves Withdrawal
51+
if: ${{ inputs.withdrawal_type == 'Withdraw DEEP Reserves' }}
52+
run: npx tsx examples/ticket/admin-withdraw-all-deep-reserves.ts

examples/multisig/buildAndLogMultisigTransaction.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import { MULTISIG_CONFIG } from "./multisig";
77
* Handles the boilerplate of building, dry running, and logging a multisig transaction.
88
* @param tx - The transaction block to process.
99
*/
10-
export async function buildAndLogMultisigTransaction(tx: Transaction): Promise<void> {
11-
tx.setSender(MULTISIG_CONFIG.address);
10+
export async function buildAndLogMultisigTransaction(tx: Transaction, sender = MULTISIG_CONFIG.address): Promise<void> {
11+
tx.setSender(sender);
1212

1313
const transactionBytes = await tx.build({ client: provider });
1414
const base64TxBytes = toBase64(transactionBytes);

examples/multisig/initialize-multisig-config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@ import { DEEPTRADE_CORE_PACKAGE_ID, MULTISIG_CONFIG_OBJECT_ID, MULTISIG_ADMIN_CA
33
import { buildAndLogMultisigTransaction } from "../multisig/buildAndLogMultisigTransaction";
44
import { MULTISIG_CONFIG } from "../multisig/multisig";
55

6+
const ADMIN_CAP_HOLDER_ADDRESS = process.env.MULTISIG_ADMIN_CAP_HOLDER_ADDRESS;
7+
if (!ADMIN_CAP_HOLDER_ADDRESS) {
8+
throw new Error("MULTISIG_ADMIN_CAP_HOLDER_ADDRESS environment variable is required.");
9+
}
10+
611
// Usage: npx tsx examples/multisig/initialize-multisig-config.ts > initialize-multisig-config.log 2>&1
712
(async () => {
813
const { publicKeysSuiBytes, weights, threshold, address } = MULTISIG_CONFIG;
@@ -12,6 +17,7 @@ import { MULTISIG_CONFIG } from "../multisig/multisig";
1217
console.warn(`- Signers: ${publicKeysSuiBytes.length}`);
1318
console.warn(`- Weights: ${JSON.stringify(weights)}`);
1419
console.warn(`- Threshold: ${threshold}`);
20+
console.warn(`- Admin cap holder (sender): ${ADMIN_CAP_HOLDER_ADDRESS}`);
1521

1622
const tx = new Transaction();
1723

@@ -26,5 +32,5 @@ import { MULTISIG_CONFIG } from "../multisig/multisig";
2632
],
2733
});
2834

29-
await buildAndLogMultisigTransaction(tx);
35+
await buildAndLogMultisigTransaction(tx, ADMIN_CAP_HOLDER_ADDRESS);
3036
})();

examples/multisig/update-multisig-config.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ import { SIGNATURE_FLAG_TO_SCHEME } from "@mysten/sui/cryptography";
77
// --- NEW multisig config comes from standard MULTISIG_* env vars (loaded by multisig.ts) ---
88
const { publicKeysSuiBytes, publicKeys, weights, threshold, address } = MULTISIG_CONFIG;
99

10+
const ADMIN_CAP_HOLDER_ADDRESS = process.env.MULTISIG_ADMIN_CAP_HOLDER_ADDRESS;
11+
if (!ADMIN_CAP_HOLDER_ADDRESS) {
12+
throw new Error("MULTISIG_ADMIN_CAP_HOLDER_ADDRESS environment variable is required.");
13+
}
14+
1015
// Usage: npx tsx examples/multisig/update-multisig-config.ts > update-multisig-config.log 2>&1
1116
(async () => {
1217
console.warn(`Building transaction to update multisig config`);
@@ -19,6 +24,7 @@ const { publicKeysSuiBytes, publicKeys, weights, threshold, address } = MULTISIG
1924
const scheme = SIGNATURE_FLAG_TO_SCHEME[pk.flag() as keyof typeof SIGNATURE_FLAG_TO_SCHEME];
2025
console.warn(` - Signer ${i + 1}: ${pk.toSuiAddress()} (${scheme}, weight: ${weights[i]})`);
2126
});
27+
console.warn(`- Admin cap holder (sender): ${ADMIN_CAP_HOLDER_ADDRESS}`);
2228

2329
const tx = new Transaction();
2430

@@ -33,5 +39,5 @@ const { publicKeysSuiBytes, publicKeys, weights, threshold, address } = MULTISIG
3339
],
3440
});
3541

36-
await buildAndLogMultisigTransaction(tx);
42+
await buildAndLogMultisigTransaction(tx, ADMIN_CAP_HOLDER_ADDRESS);
3743
})();

0 commit comments

Comments
 (0)