@massalabs/multisig-contract 0.1.1-dev.20260604054703 → 0.1.1-dev.20260721085727

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,330 +1,169 @@
1
- # Massa Multisignature Wallet
2
-
3
- The purpose of multisig wallets is to increase security by requiring multiple parties to agree on transactions before execution. Transactions can be executed only when confirmed by a predefined number of owners.
4
-
5
- Features
6
- Can hold Massa and all kinds of tokens
7
- Integration with web3 wallets
8
- Interacting with any contracts
9
- @dev Most important concepts:
10
- * Threshold/required: Number of required confirmations for a Multisig transaction.
11
- * Owners: List of addresses that control the Multisig. They are the only ones that
12
- can submit, approve, and execute transactions.
13
- * UpgradeDelay: Delay necessary between an upgrade proposition and the actual upgrade
14
- * executionDelay: Delay necessary between the time the threshold is met for a specific transaction and its execution.
15
- * Id: Each transaction has a different ID to prevent replay attacks.
16
- * Signature: A valid signature of an owner of the Multisig for a transaction hash.
17
- * Owners can only be added/removed by the multisig (same for changing the threshold
18
- and upgrading the contract)
19
- * Change the owners, required,& upgradeDelay to your needs in src/deploy.ts
20
-
21
- The executionDelay starts once the threshold is met, and is not reset when another wallet approves the tx. It can be reset if a wallet revokes approval and the approval count goes below the threshold.
22
-
23
- Anyone can send coins to the multisig using the receiveCoins functions.
24
- Only owners can call submit, approve, execute & revoke functions.
25
- Only the multisig itself can call addOwner, removeOwner, replaceOwner, changeRequirement, changeExecutionDelay, changeUpgradeDelay, proposeUpgrade & upgrade functions. Thus, they can only be called by submitting the call through the multisig, approving & executing it.
26
-
27
- ## Security
28
-
29
- The code was fully audited for security by a third party professional security firm.
30
- The report is publicly available as the [security_audit.pdf](security_audit.pdf) file at the root of the repository.
31
-
32
- ## Build
33
-
34
- By default this will build all files in `assembly/contracts` directory.
35
-
36
- ```shell
37
- npm run build
38
- ```
39
-
40
- ## Deploy the multisig
41
-
42
- Prerequisites :
43
-
44
- - You must add a `.env` file at the root of the repository with the following keys set to valid values:
45
- - `PRIVATE_KEY="wallet_private_key"`
46
- - `C_LAYER_RPC_URL="https://..."` (optional, defaults to buildnet)
47
- - `CURRENCY_REGISTRY_ADDRESS="AS..."` (required for currency-registry helper scripts)
48
-
49
- These keys will be the ones used by the deployment script to interact with the blockchain.
50
-
51
- Pass owners and threshold as CLI arguments to the deploy script.
52
- `--owner-addresses` must be a comma-separated list and `--threshold` must be
53
- a positive integer not greater than the number of owners.
54
- `upgradeDelay` and `validationDelay` are configured directly in `src/deploy.ts` (not via CLI args).
55
-
56
- Run build first, then deploy. The deploy script uses the already-built
57
- `build/Multisig.wasm` artifact and automatically runs the constructor.
58
-
59
- ```shell
60
- npm run build && npm run deploy -- --owner-addresses AU1abc...,AU1def... --threshold 2
61
- ```
62
-
63
- ## Generate a wallet
64
-
65
- You can generate a new Massa wallet keypair for local usage with:
66
-
67
- ```shell
68
- npm run generate:wallet
69
- ```
70
-
71
- The script prints the wallet address and a `PRIVATE_KEY="..."` line you can copy into your `.env`.
72
-
73
- ## Proposal lifecycle (important)
74
-
75
- Submitting a proposal does **not** count as an approval for the proposing owner. The proposer must call approve separately if they want their confirmation included toward the threshold.
76
-
77
- The approve flow only records confirmations. When the number of approvals reaches the threshold, the proposal is **not** executed automatically. Someone with the right to execute must call execute explicitly (and respect any `executionDelay` enforced on-chain after the threshold is met).
78
-
79
- These behaviors are intentional in the current design. Automatically approving on behalf of the submitter, or automatically executing once the threshold is reached, could be explored as future improvements but are not implemented today.
80
-
81
- ## Create an add-member proposal
82
-
83
- The repository also includes a helper script to submit a multisig proposal that adds a new owner.
84
-
85
- ```shell
86
- npm run propose:add-member -- <multisig-address> <new-member-address>
87
- ```
88
-
89
- The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
90
-
91
- ## Create a revoke-member proposal
92
-
93
- The repository also includes a helper script to submit a multisig proposal that removes an existing owner.
94
-
95
- ```shell
96
- npm run propose:revoke-member -- <multisig-address> <member-address>
97
- ```
98
-
99
- The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
100
-
101
- ## Create a replace-member proposal
102
-
103
- The repository also includes a helper script to submit a multisig proposal that replaces an existing owner with a new one.
104
-
105
- ```shell
106
- npm run propose:replace-member -- <multisig-address> <current-member-address> <new-member-address>
107
- ```
108
-
109
- The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
110
-
111
- ## Create a threshold proposal
112
-
113
- The repository also includes a helper script to submit a multisig proposal that updates the required approval threshold.
114
-
115
- ```shell
116
- npm run propose:threshold -- <multisig-address> <threshold>
117
- ```
118
-
119
- The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
120
-
121
- ## Create an execution-delay proposal
122
-
123
- The repository also includes a helper script to submit a multisig proposal that updates the execution delay.
124
-
125
- ```shell
126
- npm run propose:execution-delay -- <multisig-address> <execution-delay>
127
- ```
128
-
129
- The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
130
-
131
- ## Create a currency pause/unpause proposal (C-layer)
132
-
133
- The repository also includes a helper script to submit a multisig proposal that updates `isPaused` for a currency in the C-layer currency-registry.
134
-
135
- ```shell
136
- npm run propose:currency-pause -- <multisig-address> <currency-ticker> <pause|unpause>
137
- ```
138
-
139
- The script reads the current currency from currency-registry, preserves all fields, toggles only `isPaused`, then submits a multisig `updateCurrency` proposal with the same coin value used by the currency-registry wrapper (`0.1 MAS`).
140
-
141
- ## Add a currency to registry (C-layer)
142
-
143
- The repository also includes a helper script to call `createCurrency` on the C-layer currency-registry.
144
-
145
- ```shell
146
- npm run add:currency-to-registry -- <ticker> <name> <decimals> <currency-multisig-address> [isPaused]
147
- ```
148
-
149
- Notes:
150
- * This call requires a wallet with the `CURRENCY_MANAGER` role (typically the COS-managed key).
151
- * The script uses `PRIVATE_KEY` from `.env` as the caller key.
152
- * It submits with `0.1 MAS`, aligned with the `certonym-contracts` currency-registry wrapper.
153
- * `isPaused` is optional (`false` by default). Accepted values: `true/false` or `1/0`.
154
-
155
- ## Remove a currency from registry (C-layer)
156
-
157
- The repository also includes a helper script to call `removeCurrency` on the C-layer currency-registry.
158
-
159
- ```shell
160
- npm run remove:currency-from-registry -- <currency-id>
161
- ```
162
-
163
- ## Generate a new DECC number (P-layer)
164
-
165
- The repository includes a helper script to generate and print a new DECC number.
166
-
167
- ```shell
168
- npm run generate:decc-no
169
- ```
170
-
171
- ## Open a DECC (P-layer)
172
-
173
- The repository includes a helper script to open a DECC for a given currency.
174
-
175
- ```shell
176
- npm run open:decc -- <decc-no> <currency-ticker>
177
- ```
178
-
179
- ## Get DECC balance (P-layer)
180
-
181
- The repository includes a helper script to read the current raw balance of a DECC.
182
-
183
- ```shell
184
- npm run get:decc-balance -- <decc-no>
185
- ```
186
-
187
- ## Transfer funds between DECCs (P-layer)
188
-
189
- The repository includes a helper script to transfer funds from one DECC to another.
190
-
191
- ```shell
192
- npm run transfer:funds -- <sender-decc-no> <recipient-decc-no> <raw_amount> <currency-ticker>
193
- ```
194
-
195
- `<raw_amount>` must be the on-chain raw integer amount.
196
-
197
- ## Burn funds (P-layer)
198
-
199
- The repository includes a helper script to burn funds from a DECC.
200
-
201
- ```shell
202
- npm run burn:funds -- <source-decc-no> <raw_amount> <currency-ticker>
203
- ```
204
-
205
- ## Create a mint proposal (P-layer)
206
-
207
- The repository also includes a helper script to submit a P-layer multisig `mint` proposal via the Player API.
208
-
209
- ```shell
210
- npm run propose:mint -- <decc-no> <raw_amount> <currency-ticker>
211
- ```
212
-
213
- `<raw_amount>` must be the on-chain raw integer amount.
214
-
215
- ## Create a transfer_from proposal (P-layer)
216
-
217
- The repository also includes a helper script to submit a P-layer multisig `transfer_from` proposal via the Player API.
218
-
219
- ```shell
220
- npm run propose:transfer_from -- <multisig-decc-no> <sender-decc-no> <recipient-decc-no> <raw_amount> <currency-ticker>
221
- ```
222
-
223
- ## Create a freeze_account proposal (P-layer)
224
-
225
- The repository also includes a helper script to submit a P-layer multisig `freeze_account` proposal via the Player API.
226
-
227
- ```shell
228
- npm run propose:freeze_account -- <multisig-decc-no> <target-decc-no> <currency-ticker>
229
- ```
230
-
231
- ## Create an unfreeze_account proposal (P-layer)
232
-
233
- The repository also includes a helper script to submit a P-layer multisig `unfreeze_account` proposal via the Player API.
234
-
235
- ```shell
236
- npm run propose:unfreeze_account -- <multisig-decc-no> <target-decc-no> <currency-ticker>
237
- ```
238
-
239
- ## List proposals (P-layer)
240
-
241
- The repository also includes a read-only helper script to retrieve non-executed P-layer multisig proposals for a currency.
242
-
243
- ```shell
244
- npm run list:p-layer-proposals -- <multisig-decc-no> <currency-ticker>
245
- ```
246
-
247
- The script prints a JSON array with proposal ids, proposal type data, approval count, status, and period metadata.
248
-
249
- ## Approve a proposal (P-layer)
250
-
251
- The repository also includes a helper script to approve an existing P-layer multisig proposal by id.
252
-
253
- ```shell
254
- npm run approve:p-layer-proposal -- <multisig-decc-no> <currency-ticker> <proposal-id>
255
- ```
256
-
257
- ## Get available currency info (P-layer)
258
-
259
- ```shell
260
- npm run get:available-currency-info
261
- ```
262
-
263
- This script prints currencies in the form `TICKER: Name. Decimals: X. ID: Y. Paused: Z`.
264
-
265
- ## Get currency multisig info (P-layer)
266
-
267
- ```shell
268
- npm run get:currency-multisig-info -- <currency-ticker>
269
- ```
270
-
271
- The script submits the approval via the Player API and prints the resulting operation id.
272
-
273
- These scripts use:
274
- - `PRIVATE_KEY` from `.env` for signing,
275
- - `P_LAYER_GRPC_URL` from `.env` for gRPC endpoint,
276
- - proposal kind encoding from `p-layer-runtime/api/example-js`.
277
-
278
- ## Approve a proposal
279
-
280
- The repository also includes a helper script to approve an existing multisig proposal by id.
281
-
282
- ```shell
283
- npm run approve:proposal -- <multisig-address> <proposal-id>
284
- ```
285
-
286
- The script uses the same `.env` configuration as deployment and prints the approval operation id plus the final events emitted by the contract.
287
-
288
- ## Execute a proposal
289
-
290
- The repository also includes a helper script to execute an existing multisig proposal by id.
291
-
292
- ```shell
293
- npm run execute:proposal -- <multisig-address> <proposal-id>
294
- ```
295
-
296
- The script uses the same `.env` configuration as deployment and prints the execution operation id plus the final events emitted by the contract.
297
-
298
- ## List proposals
299
-
300
- The repository also includes a read-only helper script to retrieve all multisig proposals and their current statuses.
301
-
302
- ```shell
303
- npm run list:proposals -- <multisig-address>
304
- ```
305
-
306
- The script prints a JSON array with each proposal's id, target, method, value, approvals, timestamp, execution flag, and derived status.
307
-
308
- ## Get multisig parameters
309
-
310
- The repository also includes a read-only helper script to retrieve the multisig members, threshold, and execution delay directly from storage.
311
-
312
- ```shell
313
- npm run get:multisig-parameters -- <multisig-address>
314
- ```
315
-
316
- The script prints a JSON object containing the `members`, `threshold`, and `delay`.
317
-
318
- ## Unit tests
319
-
320
- The test framework documentation is available here: [as-pect docs](https://as-pect.gitbook.io/as-pect)
321
-
322
- ```shell
323
- npm run test
324
- ```
325
-
326
- ## Format code
327
-
328
- ```shell
329
- npm run fmt
330
- ```
1
+ # Massa Multisignature Wallet
2
+
3
+ The purpose of multisig wallets is to increase security by requiring multiple parties to agree on transactions before execution. Transactions can be executed only when confirmed by a predefined number of owners.
4
+
5
+ Features
6
+ Can hold Massa and all kinds of tokens
7
+ Integration with web3 wallets
8
+ Interacting with any contracts
9
+ @dev Most important concepts:
10
+ * Threshold/required: Number of required confirmations for a Multisig transaction.
11
+ * Owners: List of addresses that control the Multisig. They are the only ones that
12
+ can submit, approve, and execute transactions.
13
+ * UpgradeDelay: Delay necessary between an upgrade proposition and the actual upgrade
14
+ * executionDelay: Delay necessary between the time the threshold is met for a specific transaction and its execution.
15
+ * Id: Each transaction has a different ID to prevent replay attacks.
16
+ * Signature: A valid signature of an owner of the Multisig for a transaction hash.
17
+ * Owners can only be added/removed by the multisig (same for changing the threshold
18
+ and upgrading the contract)
19
+ * Change the owners, required,& upgradeDelay to your needs in src/deploy.ts
20
+
21
+ The executionDelay starts once the threshold is met, and is not reset when another wallet approves the tx. It can be reset if a wallet revokes approval and the approval count goes below the threshold.
22
+
23
+ Anyone can send coins to the multisig using the receiveCoins functions.
24
+ Only owners can call submit, approve, execute & revoke functions.
25
+ Only the multisig itself can call addOwner, removeOwner, replaceOwner, changeRequirement, changeExecutionDelay, changeUpgradeDelay, proposeUpgrade & upgrade functions. Thus, they can only be called by submitting the call through the multisig, approving & executing it.
26
+
27
+ ## Security
28
+
29
+ The code was fully audited for security by a third party professional security firm.
30
+ The report is publicly available as the [security_audit.pdf](security_audit.pdf) file at the root of the repository.
31
+
32
+ ## Build
33
+
34
+ By default this will build all files in `assembly/contracts` directory.
35
+
36
+ ```shell
37
+ npm run build
38
+ ```
39
+
40
+ ## Deploy the multisig
41
+
42
+ Prerequisites :
43
+
44
+ - You must add a `.env` file at the root of the repository with the following keys set to valid values:
45
+ - `PRIVATE_KEY="wallet_private_key"`
46
+ - `RPC_URL="https://..."` (optional, defaults to buildnet)
47
+
48
+ These keys will be the ones used by the deployment script to interact with the blockchain.
49
+
50
+ Adapt `required`, `owners` & `upgradeDelay` to your liking (cf. important concepts) in `src/deploy.ts`.
51
+
52
+ The following command will build contracts in `assembly/contracts` directory and execute the deployment script
53
+ `src/deploy.ts`. This script deploys `Multisig.wasm` directly and automatically runs its constructor.
54
+
55
+ ```shell
56
+ npm run deploy
57
+ ```
58
+
59
+ ## Proposal lifecycle (important)
60
+
61
+ Submitting a proposal does **not** count as an approval for the proposing owner. The proposer must call approve separately if they want their confirmation included toward the threshold.
62
+
63
+ The approve flow only records confirmations. When the number of approvals reaches the threshold, the proposal is **not** executed automatically. Someone with the right to execute must call execute explicitly (and respect any `executionDelay` enforced on-chain after the threshold is met).
64
+
65
+ These behaviors are intentional in the current design. Automatically approving on behalf of the submitter, or automatically executing once the threshold is reached, could be explored as future improvements but are not implemented today.
66
+
67
+ ## Create an add-member proposal
68
+
69
+ The repository also includes a helper script to submit a multisig proposal that adds a new owner.
70
+
71
+ ```shell
72
+ npm run propose:add-member -- <multisig-address> <new-member-address>
73
+ ```
74
+
75
+ The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
76
+
77
+ ## Create a revoke-member proposal
78
+
79
+ The repository also includes a helper script to submit a multisig proposal that removes an existing owner.
80
+
81
+ ```shell
82
+ npm run propose:revoke-member -- <multisig-address> <member-address>
83
+ ```
84
+
85
+ The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
86
+
87
+ ## Create a replace-member proposal
88
+
89
+ The repository also includes a helper script to submit a multisig proposal that replaces an existing owner with a new one.
90
+
91
+ ```shell
92
+ npm run propose:replace-member -- <multisig-address> <current-member-address> <new-member-address>
93
+ ```
94
+
95
+ The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
96
+
97
+ ## Create a threshold proposal
98
+
99
+ The repository also includes a helper script to submit a multisig proposal that updates the required approval threshold.
100
+
101
+ ```shell
102
+ npm run propose:threshold -- <multisig-address> <threshold>
103
+ ```
104
+
105
+ The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
106
+
107
+ ## Create an execution-delay proposal
108
+
109
+ The repository also includes a helper script to submit a multisig proposal that updates the execution delay.
110
+
111
+ ```shell
112
+ npm run propose:execution-delay -- <multisig-address> <execution-delay>
113
+ ```
114
+
115
+ The script uses the same `.env` configuration as deployment and prints the submitted operation id plus the final events emitted by the contract.
116
+
117
+ ## Approve a proposal
118
+
119
+ The repository also includes a helper script to approve an existing multisig proposal by id.
120
+
121
+ ```shell
122
+ npm run approve:proposal -- <multisig-address> <proposal-id>
123
+ ```
124
+
125
+ The script uses the same `.env` configuration as deployment and prints the approval operation id plus the final events emitted by the contract.
126
+
127
+ ## Execute a proposal
128
+
129
+ The repository also includes a helper script to execute an existing multisig proposal by id.
130
+
131
+ ```shell
132
+ npm run execute:proposal -- <multisig-address> <proposal-id>
133
+ ```
134
+
135
+ The script uses the same `.env` configuration as deployment and prints the execution operation id plus the final events emitted by the contract.
136
+
137
+ ## List proposals
138
+
139
+ The repository also includes a read-only helper script to retrieve all multisig proposals and their current statuses.
140
+
141
+ ```shell
142
+ npm run list:proposals -- <multisig-address>
143
+ ```
144
+
145
+ The script prints a JSON array with each proposal's id, target, method, value, approvals, timestamp, execution flag, and derived status.
146
+
147
+ ## Get multisig parameters
148
+
149
+ The repository also includes a read-only helper script to retrieve the multisig members, threshold, and execution delay directly from storage.
150
+
151
+ ```shell
152
+ npm run get:multisig-parameters -- <multisig-address>
153
+ ```
154
+
155
+ The script prints a JSON object containing the `members`, `threshold`, and `delay`.
156
+
157
+ ## Unit tests
158
+
159
+ The test framework documentation is available here: [as-pect docs](https://as-pect.gitbook.io/as-pect)
160
+
161
+ ```shell
162
+ npm run test
163
+ ```
164
+
165
+ ## Format code
166
+
167
+ ```shell
168
+ npm run fmt
169
+ ```
@@ -337,10 +337,10 @@ export function upgrade(_: StaticArray<u8>): void {
337
337
  */
338
338
  export function getTransactions(bs: StaticArray<u8>): StaticArray<u8> {
339
339
  const args = new Args(bs);
340
- const from = args.nextU64().isOk() ? args.nextU64().unwrap() : u64(0);
341
- const to = args.nextU64().isOk()
342
- ? args.nextU64().unwrap()
343
- : TRANSACTIONS.size();
340
+ const fromRes = args.nextU64();
341
+ const from = fromRes.isOk() ? fromRes.unwrap() : u64(0);
342
+ const toRes = args.nextU64();
343
+ const to = toRes.isOk() ? toRes.unwrap() : TRANSACTIONS.size();
344
344
  const txs: Transaction[] = [];
345
345
 
346
346
  for (let i = from; i < to; i++) {
package/package.json CHANGED
@@ -1,38 +1,20 @@
1
1
  {
2
2
  "name": "@massalabs/multisig-contract",
3
- "version": "0.1.1-dev.20260604054703",
3
+ "version": "0.1.1-dev.20260721085727",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "test": "asp --summary",
7
7
  "build": "npx massa-as-compile",
8
8
  "deploy": "tsx src/deploy.ts",
9
- "generate:wallet": "tsx src/generate-wallet.ts",
10
- "add:currency-to-registry": "tsx src/add-currency-to-registry.ts",
11
- "remove:currency-from-registry": "tsx src/remove-currency-from-registry.ts",
12
9
  "approve:proposal": "tsx src/approve-proposal.ts",
13
10
  "execute:proposal": "tsx src/execute-proposal.ts",
14
11
  "get:multisig-parameters": "tsx src/get-multisig-parameters.ts",
15
12
  "list:proposals": "tsx src/list-proposals.ts",
16
- "list:p-layer-proposals": "tsx src/list-p-layer-proposals.ts",
17
- "get:available-currency-info": "tsx src/get-available-currency-info.ts",
18
- "get:currency-multisig-info": "tsx src/get-currency-multisig-info.ts",
19
- "generate:decc-no": "tsx src/generate-decc-no.ts",
20
- "open:decc": "tsx src/open-decc.ts",
21
- "get:decc-balance": "tsx src/get-decc-balance.ts",
22
- "transfer:funds": "tsx src/transfer-funds.ts",
23
- "burn:funds": "tsx src/burn-funds.ts",
24
13
  "propose:add-member": "tsx src/propose-add-member.ts",
25
14
  "propose:replace-member": "tsx src/propose-replace-member.ts",
26
15
  "propose:revoke-member": "tsx src/propose-revoke-member.ts",
27
16
  "propose:threshold": "tsx src/propose-threshold.ts",
28
17
  "propose:execution-delay": "tsx src/propose-execution-delay.ts",
29
- "propose:currency-pause": "tsx src/propose-currency-pause.ts",
30
- "propose:mint": "tsx src/propose-mint.ts",
31
- "propose:transfer_from": "tsx src/propose-transfer-from.ts",
32
- "propose:freeze_account": "tsx src/propose-freeze-account.ts",
33
- "propose:unfreeze_account": "tsx src/propose-unfreeze-account.ts",
34
- "propose:burn": "tsx src/propose-burn.ts",
35
- "approve:p-layer-proposal": "tsx src/approve-p-layer-proposal.ts",
36
18
  "prettier": "prettier assembly//**/*.ts --check",
37
19
  "prettier:fix": "prettier assembly//**/*.ts --write",
38
20
  "lint": "eslint .",