@quantabit/multi-sig-sdk 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 QuantaBit Team
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # @quantabit/multi-sig-sdk
2
+
3
+ QuantaBit Multi-Sig SDK provides high-level utilities for creating and managing multi-signature vaults, constructing transaction proposals, approval workflows, and on-chain proposal execution inside the QuantaBit ecosystem.
4
+
5
+ ## Features
6
+
7
+ - **Vault Creation**: Initialize safe vaults with specified owners and signing threshold.
8
+ - **Proposal Flow**: Streamlined pipeline to propose, approve, and execute transactions.
9
+ - **State Synchronization**: Custom React hooks to monitor proposal lifecycle.
10
+ - **Multilingual Messaging**: Integrated localized alerts for EN, ZH, JA, and KO.
11
+
12
+ ## Installation
13
+
14
+ ```bash
15
+ npm install @quantabit/multi-sig-sdk @quantabit/sdk-config
16
+ ```
17
+
18
+ ## Quick Start
19
+
20
+ ```javascript
21
+ import { createMultisigVault, createProposal, approveProposal } from '@quantabit/multi-sig-sdk';
22
+
23
+ // Initialize a 2-of-3 multisig vault
24
+ const vault = await createMultisigVault(['addr1', 'addr2', 'addr3'], 2);
25
+
26
+ // Propose a transfer transaction
27
+ const proposal = await createProposal(vault.vaultAddress, {
28
+ to: 'destination_address',
29
+ amount: 5000000000 // in QBT grains
30
+ });
31
+
32
+ // Approve the proposal
33
+ await approveProposal(proposal.id, 'addr1');
34
+ ```
35
+
36
+ ## Brand & Links
37
+
38
+ - **Official Website**: [https://quantabit.io](https://quantabit.io)
39
+ - **Documentation**: [https://docs.quantabit.io](https://docs.quantabit.io)
40
+ - **Explorer**: [https://explorer.mg.qbitchain.io](https://explorer.mg.qbitchain.io)
41
+ - **Source Code**: [https://github.com/quantabit-chain/qbit-sdk](https://github.com/quantabit-chain/qbit-sdk)
package/dist/index.cjs ADDED
@@ -0,0 +1,161 @@
1
+ 'use strict';
2
+
3
+ var react = require('react');
4
+ var sdkConfig = require('@quantabit/sdk-config');
5
+
6
+ const messages = {
7
+ en: {
8
+ proposal_created: "Multi-sig proposal created successfully",
9
+ proposal_executed: "Multi-sig proposal executed successfully",
10
+ proposal_approved: "Proposal approved successfully",
11
+ proposal_rejected: "Proposal rejected successfully",
12
+ insufficient_signatures: "Insufficient signatures to execute proposal",
13
+ invalid_multisig: "Invalid multi-sig vault address"
14
+ },
15
+ zh: {
16
+ proposal_created: "多签提案创建成功",
17
+ proposal_executed: "多签提案执行成功",
18
+ proposal_approved: "提案审批成功",
19
+ proposal_rejected: "提案否决成功",
20
+ insufficient_signatures: "签名不足,无法执行提案",
21
+ invalid_multisig: "无效的多签金库地址"
22
+ },
23
+ ja: {
24
+ proposal_created: "マルチシグ提案が正常に作成されました",
25
+ proposal_executed: "マルチシグ提案が正常に実行されました",
26
+ proposal_approved: "提案が正常に承認されました",
27
+ proposal_rejected: "提案が正常に却下されました",
28
+ insufficient_signatures: "提案を実行するための署名が不足しています",
29
+ invalid_multisig: "無効なマルチシグ金庫アドレス"
30
+ },
31
+ ko: {
32
+ proposal_created: "다중 서명 제안이 성공적으로 생성되었습니다",
33
+ proposal_executed: "다중 서명 제안이 성공적으로 실행되었습니다",
34
+ proposal_approved: "제안 승인 완료",
35
+ proposal_rejected: "제안 반려 완료",
36
+ insufficient_signatures: "제안을 실행하기에 서명이 부족합니다",
37
+ invalid_multisig: "유효하지 않은 다중 서명 금고 주소"
38
+ }
39
+ };
40
+ let currentLang = null;
41
+ function getLanguage() {
42
+ return currentLang || sdkConfig.getLanguage() || 'en';
43
+ }
44
+ function setLanguage(lang) {
45
+ if (messages[lang]) {
46
+ currentLang = lang;
47
+ }
48
+ }
49
+ function t(key) {
50
+ const lang = getLanguage();
51
+ return messages[lang]?.[key] || messages['en']?.[key] || key;
52
+ }
53
+
54
+ // 模拟多签提案数据库
55
+ const proposalsDb = {};
56
+ async function createMultisigVault(owners, threshold) {
57
+ if (!owners || owners.length === 0) {
58
+ throw new Error("Owners list cannot be empty");
59
+ }
60
+ if (threshold <= 0 || threshold > owners.length) {
61
+ throw new Error("Invalid threshold value");
62
+ }
63
+
64
+ // 模拟生成多签金库地址
65
+ const vaultAddress = `vault_${Math.random().toString(36).substr(2, 9)}`;
66
+ return {
67
+ vaultAddress,
68
+ owners,
69
+ threshold,
70
+ createdAt: Date.now()
71
+ };
72
+ }
73
+ async function createProposal(vaultAddress, transactionData) {
74
+ if (!vaultAddress || !vaultAddress.startsWith("vault_")) {
75
+ throw new Error(t('invalid_multisig'));
76
+ }
77
+ const proposalId = `prop_${Math.random().toString(36).substr(2, 9)}`;
78
+ const proposal = {
79
+ id: proposalId,
80
+ vaultAddress,
81
+ transactionData,
82
+ approvals: [],
83
+ status: 'pending',
84
+ // pending, approved, executed, rejected
85
+ createdAt: Date.now()
86
+ };
87
+ proposalsDb[proposalId] = proposal;
88
+ return proposal;
89
+ }
90
+ async function approveProposal(proposalId, signerAddress) {
91
+ const proposal = proposalsDb[proposalId];
92
+ if (!proposal) {
93
+ throw new Error("Proposal not found");
94
+ }
95
+ if (proposal.status !== 'pending') {
96
+ throw new Error("Proposal is no longer pending");
97
+ }
98
+ if (!proposal.approvals.includes(signerAddress)) {
99
+ proposal.approvals.push(signerAddress);
100
+ }
101
+
102
+ // 检查是否已达到阈值(模拟设定所有金库阈值为 2)
103
+ if (proposal.approvals.length >= 2) {
104
+ proposal.status = 'approved';
105
+ }
106
+ return {
107
+ ...proposal,
108
+ message: t('proposal_approved')
109
+ };
110
+ }
111
+ async function executeProposal(proposalId) {
112
+ const proposal = proposalsDb[proposalId];
113
+ if (!proposal) {
114
+ throw new Error("Proposal not found");
115
+ }
116
+
117
+ // 模拟只有处于 approved 状态的提案才能执行
118
+ if (proposal.status !== 'approved' && proposal.approvals.length < 2) {
119
+ throw new Error(t('insufficient_signatures'));
120
+ }
121
+ proposal.status = 'executed';
122
+ return {
123
+ ...proposal,
124
+ executedAt: Date.now(),
125
+ message: t('proposal_executed')
126
+ };
127
+ }
128
+ function useMultisig(vaultAddress) {
129
+ const [proposals, setProposals] = react.useState([]);
130
+ const [loading, setLoading] = react.useState(true);
131
+ react.useEffect(() => {
132
+ if (!vaultAddress) return;
133
+ setLoading(true);
134
+
135
+ // 模拟从节点查询多签提案列表
136
+ const timer = setTimeout(() => {
137
+ const filtered = Object.values(proposalsDb).filter(p => p.vaultAddress === vaultAddress);
138
+ setProposals(filtered);
139
+ setLoading(false);
140
+ }, 500);
141
+ return () => clearTimeout(timer);
142
+ }, [vaultAddress]);
143
+ return {
144
+ proposals,
145
+ loading
146
+ };
147
+ }
148
+ const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
149
+
150
+ exports.SUPPORTED_LANGUAGES = SUPPORTED_LANGUAGES;
151
+ exports.approveProposal = approveProposal;
152
+ exports.createMultisigVault = createMultisigVault;
153
+ exports.createProposal = createProposal;
154
+ exports.executeProposal = executeProposal;
155
+ exports.getLanguage = getLanguage;
156
+ exports.messages = messages;
157
+ exports.proposalsDb = proposalsDb;
158
+ exports.setLanguage = setLanguage;
159
+ exports.t = t;
160
+ exports.useMultisig = useMultisig;
161
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.cjs","sources":["../src/i18n/index.js","../src/index.js"],"sourcesContent":["import { getLanguage as getGlobalLang } from '@quantabit/sdk-config';\n\nexport const messages = {\n en: {\n proposal_created: \"Multi-sig proposal created successfully\",\n proposal_executed: \"Multi-sig proposal executed successfully\",\n proposal_approved: \"Proposal approved successfully\",\n proposal_rejected: \"Proposal rejected successfully\",\n insufficient_signatures: \"Insufficient signatures to execute proposal\",\n invalid_multisig: \"Invalid multi-sig vault address\"\n },\n zh: {\n proposal_created: \"多签提案创建成功\",\n proposal_executed: \"多签提案执行成功\",\n proposal_approved: \"提案审批成功\",\n proposal_rejected: \"提案否决成功\",\n insufficient_signatures: \"签名不足,无法执行提案\",\n invalid_multisig: \"无效的多签金库地址\"\n },\n ja: {\n proposal_created: \"マルチシグ提案が正常に作成されました\",\n proposal_executed: \"マルチシグ提案が正常に実行されました\",\n proposal_approved: \"提案が正常に承認されました\",\n proposal_rejected: \"提案が正常に却下されました\",\n insufficient_signatures: \"提案を実行するための署名が不足しています\",\n invalid_multisig: \"無効なマルチシグ金庫アドレス\"\n },\n ko: {\n proposal_created: \"다중 서명 제안이 성공적으로 생성되었습니다\",\n proposal_executed: \"다중 서명 제안이 성공적으로 실행되었습니다\",\n proposal_approved: \"제안 승인 완료\",\n proposal_rejected: \"제안 반려 완료\",\n insufficient_signatures: \"제안을 실행하기에 서명이 부족합니다\",\n invalid_multisig: \"유효하지 않은 다중 서명 금고 주소\"\n }\n};\n\nlet currentLang = null;\n\nexport function getLanguage() {\n return currentLang || getGlobalLang() || 'en';\n}\n\nexport function setLanguage(lang) {\n if (messages[lang]) {\n currentLang = lang;\n }\n}\n\nexport function t(key) {\n const lang = getLanguage();\n return messages[lang]?.[key] || messages['en']?.[key] || key;\n}\n","import { useState, useEffect } from 'react';\nimport { getConfig } from '@quantabit/sdk-config';\nimport { t, setLanguage, getLanguage, messages } from './i18n/index.js';\n\n// 模拟多签提案数据库\nconst proposalsDb = {};\n\nexport async function createMultisigVault(owners, threshold) {\n if (!owners || owners.length === 0) {\n throw new Error(\"Owners list cannot be empty\");\n }\n if (threshold <= 0 || threshold > owners.length) {\n throw new Error(\"Invalid threshold value\");\n }\n \n // 模拟生成多签金库地址\n const vaultAddress = `vault_${Math.random().toString(36).substr(2, 9)}`;\n return {\n vaultAddress,\n owners,\n threshold,\n createdAt: Date.now()\n };\n}\n\nexport async function createProposal(vaultAddress, transactionData) {\n if (!vaultAddress || !vaultAddress.startsWith(\"vault_\")) {\n throw new Error(t('invalid_multisig'));\n }\n \n const proposalId = `prop_${Math.random().toString(36).substr(2, 9)}`;\n const proposal = {\n id: proposalId,\n vaultAddress,\n transactionData,\n approvals: [],\n status: 'pending', // pending, approved, executed, rejected\n createdAt: Date.now()\n };\n \n proposalsDb[proposalId] = proposal;\n return proposal;\n}\n\nexport async function approveProposal(proposalId, signerAddress) {\n const proposal = proposalsDb[proposalId];\n if (!proposal) {\n throw new Error(\"Proposal not found\");\n }\n if (proposal.status !== 'pending') {\n throw new Error(\"Proposal is no longer pending\");\n }\n if (!proposal.approvals.includes(signerAddress)) {\n proposal.approvals.push(signerAddress);\n }\n \n // 检查是否已达到阈值(模拟设定所有金库阈值为 2)\n if (proposal.approvals.length >= 2) {\n proposal.status = 'approved';\n }\n \n return {\n ...proposal,\n message: t('proposal_approved')\n };\n}\n\nexport async function executeProposal(proposalId) {\n const proposal = proposalsDb[proposalId];\n if (!proposal) {\n throw new Error(\"Proposal not found\");\n }\n \n // 模拟只有处于 approved 状态的提案才能执行\n if (proposal.status !== 'approved' && proposal.approvals.length < 2) {\n throw new Error(t('insufficient_signatures'));\n }\n \n proposal.status = 'executed';\n return {\n ...proposal,\n executedAt: Date.now(),\n message: t('proposal_executed')\n };\n}\n\nexport function useMultisig(vaultAddress) {\n const [proposals, setProposals] = useState([]);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n if (!vaultAddress) return;\n setLoading(true);\n \n // 模拟从节点查询多签提案列表\n const timer = setTimeout(() => {\n const filtered = Object.values(proposalsDb).filter(p => p.vaultAddress === vaultAddress);\n setProposals(filtered);\n setLoading(false);\n }, 500);\n\n return () => clearTimeout(timer);\n }, [vaultAddress]);\n\n return { proposals, loading };\n}\n\nexport { t, setLanguage, getLanguage, messages };\nexport const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport { proposalsDb };\n"],"names":["messages","en","proposal_created","proposal_executed","proposal_approved","proposal_rejected","insufficient_signatures","invalid_multisig","zh","ja","ko","currentLang","getLanguage","getGlobalLang","setLanguage","lang","t","key","proposalsDb","createMultisigVault","owners","threshold","length","Error","vaultAddress","Math","random","toString","substr","createdAt","Date","now","createProposal","transactionData","startsWith","proposalId","proposal","id","approvals","status","approveProposal","signerAddress","includes","push","message","executeProposal","executedAt","useMultisig","proposals","setProposals","useState","loading","setLoading","useEffect","timer","setTimeout","filtered","Object","values","filter","p","clearTimeout","SUPPORTED_LANGUAGES"],"mappings":";;;;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,EAAE,EAAE;AACFC,IAAAA,gBAAgB,EAAE,yCAAyC;AAC3DC,IAAAA,iBAAiB,EAAE,0CAA0C;AAC7DC,IAAAA,iBAAiB,EAAE,gCAAgC;AACnDC,IAAAA,iBAAiB,EAAE,gCAAgC;AACnDC,IAAAA,uBAAuB,EAAE,6CAA6C;AACtEC,IAAAA,gBAAgB,EAAE;GACnB;AACDC,EAAAA,EAAE,EAAE;AACFN,IAAAA,gBAAgB,EAAE,UAAU;AAC5BC,IAAAA,iBAAiB,EAAE,UAAU;AAC7BC,IAAAA,iBAAiB,EAAE,QAAQ;AAC3BC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SAAS,EAAEC,YAAY,CAAC,GAAGC,cAAQ,CAAC,EAAE,CAAC;EAC9C,MAAM,CAACC,OAAO,EAAEC,UAAU,CAAC,GAAGF,cAAQ,CAAC,IAAI,CAAC;AAE5CG,EAAAA,eAAS,CAAC,MAAM;IACd,IAAI,CAAC7B,YAAY,EAAE;IACnB4B,UAAU,CAAC,IAAI,CAAC;;AAEhB;AACA,IAAA,MAAME,KAAK,GAAGC,UAAU,CAAC,MAAM;AAC7B,MAAA,MAAMC,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACxC,WAAW,CAAC,CAACyC,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACpC,YAAY,KAAKA,YAAY,CAAC;MACxFyB,YAAY,CAACO,QAAQ,CAAC;MACtBJ,UAAU,CAAC,KAAK,CAAC;IACnB,CAAC,EAAE,GAAG,CAAC;AAEP,IAAA,OAAO,MAAMS,YAAY,CAACP,KAAK,CAAC;AAClC,EAAA,CAAC,EAAE,CAAC9B,YAAY,CAAC,CAAC;EAElB,OAAO;IAAEwB,SAAS;AAAEG,IAAAA;GAAS;AAC/B;AAGO,MAAMW,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;;;;;;;;;;;;;;"}
@@ -0,0 +1,149 @@
1
+ import { useState, useEffect } from 'react';
2
+ import { getLanguage as getLanguage$1 } from '@quantabit/sdk-config';
3
+
4
+ const messages = {
5
+ en: {
6
+ proposal_created: "Multi-sig proposal created successfully",
7
+ proposal_executed: "Multi-sig proposal executed successfully",
8
+ proposal_approved: "Proposal approved successfully",
9
+ proposal_rejected: "Proposal rejected successfully",
10
+ insufficient_signatures: "Insufficient signatures to execute proposal",
11
+ invalid_multisig: "Invalid multi-sig vault address"
12
+ },
13
+ zh: {
14
+ proposal_created: "多签提案创建成功",
15
+ proposal_executed: "多签提案执行成功",
16
+ proposal_approved: "提案审批成功",
17
+ proposal_rejected: "提案否决成功",
18
+ insufficient_signatures: "签名不足,无法执行提案",
19
+ invalid_multisig: "无效的多签金库地址"
20
+ },
21
+ ja: {
22
+ proposal_created: "マルチシグ提案が正常に作成されました",
23
+ proposal_executed: "マルチシグ提案が正常に実行されました",
24
+ proposal_approved: "提案が正常に承認されました",
25
+ proposal_rejected: "提案が正常に却下されました",
26
+ insufficient_signatures: "提案を実行するための署名が不足しています",
27
+ invalid_multisig: "無効なマルチシグ金庫アドレス"
28
+ },
29
+ ko: {
30
+ proposal_created: "다중 서명 제안이 성공적으로 생성되었습니다",
31
+ proposal_executed: "다중 서명 제안이 성공적으로 실행되었습니다",
32
+ proposal_approved: "제안 승인 완료",
33
+ proposal_rejected: "제안 반려 완료",
34
+ insufficient_signatures: "제안을 실행하기에 서명이 부족합니다",
35
+ invalid_multisig: "유효하지 않은 다중 서명 금고 주소"
36
+ }
37
+ };
38
+ let currentLang = null;
39
+ function getLanguage() {
40
+ return currentLang || getLanguage$1() || 'en';
41
+ }
42
+ function setLanguage(lang) {
43
+ if (messages[lang]) {
44
+ currentLang = lang;
45
+ }
46
+ }
47
+ function t(key) {
48
+ const lang = getLanguage();
49
+ return messages[lang]?.[key] || messages['en']?.[key] || key;
50
+ }
51
+
52
+ // 模拟多签提案数据库
53
+ const proposalsDb = {};
54
+ async function createMultisigVault(owners, threshold) {
55
+ if (!owners || owners.length === 0) {
56
+ throw new Error("Owners list cannot be empty");
57
+ }
58
+ if (threshold <= 0 || threshold > owners.length) {
59
+ throw new Error("Invalid threshold value");
60
+ }
61
+
62
+ // 模拟生成多签金库地址
63
+ const vaultAddress = `vault_${Math.random().toString(36).substr(2, 9)}`;
64
+ return {
65
+ vaultAddress,
66
+ owners,
67
+ threshold,
68
+ createdAt: Date.now()
69
+ };
70
+ }
71
+ async function createProposal(vaultAddress, transactionData) {
72
+ if (!vaultAddress || !vaultAddress.startsWith("vault_")) {
73
+ throw new Error(t('invalid_multisig'));
74
+ }
75
+ const proposalId = `prop_${Math.random().toString(36).substr(2, 9)}`;
76
+ const proposal = {
77
+ id: proposalId,
78
+ vaultAddress,
79
+ transactionData,
80
+ approvals: [],
81
+ status: 'pending',
82
+ // pending, approved, executed, rejected
83
+ createdAt: Date.now()
84
+ };
85
+ proposalsDb[proposalId] = proposal;
86
+ return proposal;
87
+ }
88
+ async function approveProposal(proposalId, signerAddress) {
89
+ const proposal = proposalsDb[proposalId];
90
+ if (!proposal) {
91
+ throw new Error("Proposal not found");
92
+ }
93
+ if (proposal.status !== 'pending') {
94
+ throw new Error("Proposal is no longer pending");
95
+ }
96
+ if (!proposal.approvals.includes(signerAddress)) {
97
+ proposal.approvals.push(signerAddress);
98
+ }
99
+
100
+ // 检查是否已达到阈值(模拟设定所有金库阈值为 2)
101
+ if (proposal.approvals.length >= 2) {
102
+ proposal.status = 'approved';
103
+ }
104
+ return {
105
+ ...proposal,
106
+ message: t('proposal_approved')
107
+ };
108
+ }
109
+ async function executeProposal(proposalId) {
110
+ const proposal = proposalsDb[proposalId];
111
+ if (!proposal) {
112
+ throw new Error("Proposal not found");
113
+ }
114
+
115
+ // 模拟只有处于 approved 状态的提案才能执行
116
+ if (proposal.status !== 'approved' && proposal.approvals.length < 2) {
117
+ throw new Error(t('insufficient_signatures'));
118
+ }
119
+ proposal.status = 'executed';
120
+ return {
121
+ ...proposal,
122
+ executedAt: Date.now(),
123
+ message: t('proposal_executed')
124
+ };
125
+ }
126
+ function useMultisig(vaultAddress) {
127
+ const [proposals, setProposals] = useState([]);
128
+ const [loading, setLoading] = useState(true);
129
+ useEffect(() => {
130
+ if (!vaultAddress) return;
131
+ setLoading(true);
132
+
133
+ // 模拟从节点查询多签提案列表
134
+ const timer = setTimeout(() => {
135
+ const filtered = Object.values(proposalsDb).filter(p => p.vaultAddress === vaultAddress);
136
+ setProposals(filtered);
137
+ setLoading(false);
138
+ }, 500);
139
+ return () => clearTimeout(timer);
140
+ }, [vaultAddress]);
141
+ return {
142
+ proposals,
143
+ loading
144
+ };
145
+ }
146
+ const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];
147
+
148
+ export { SUPPORTED_LANGUAGES, approveProposal, createMultisigVault, createProposal, executeProposal, getLanguage, messages, proposalsDb, setLanguage, t, useMultisig };
149
+ //# sourceMappingURL=index.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.esm.js","sources":["../src/i18n/index.js","../src/index.js"],"sourcesContent":["import { getLanguage as getGlobalLang } from '@quantabit/sdk-config';\n\nexport const messages = {\n en: {\n proposal_created: \"Multi-sig proposal created successfully\",\n proposal_executed: \"Multi-sig proposal executed successfully\",\n proposal_approved: \"Proposal approved successfully\",\n proposal_rejected: \"Proposal rejected successfully\",\n insufficient_signatures: \"Insufficient signatures to execute proposal\",\n invalid_multisig: \"Invalid multi-sig vault address\"\n },\n zh: {\n proposal_created: \"多签提案创建成功\",\n proposal_executed: \"多签提案执行成功\",\n proposal_approved: \"提案审批成功\",\n proposal_rejected: \"提案否决成功\",\n insufficient_signatures: \"签名不足,无法执行提案\",\n invalid_multisig: \"无效的多签金库地址\"\n },\n ja: {\n proposal_created: \"マルチシグ提案が正常に作成されました\",\n proposal_executed: \"マルチシグ提案が正常に実行されました\",\n proposal_approved: \"提案が正常に承認されました\",\n proposal_rejected: \"提案が正常に却下されました\",\n insufficient_signatures: \"提案を実行するための署名が不足しています\",\n invalid_multisig: \"無効なマルチシグ金庫アドレス\"\n },\n ko: {\n proposal_created: \"다중 서명 제안이 성공적으로 생성되었습니다\",\n proposal_executed: \"다중 서명 제안이 성공적으로 실행되었습니다\",\n proposal_approved: \"제안 승인 완료\",\n proposal_rejected: \"제안 반려 완료\",\n insufficient_signatures: \"제안을 실행하기에 서명이 부족합니다\",\n invalid_multisig: \"유효하지 않은 다중 서명 금고 주소\"\n }\n};\n\nlet currentLang = null;\n\nexport function getLanguage() {\n return currentLang || getGlobalLang() || 'en';\n}\n\nexport function setLanguage(lang) {\n if (messages[lang]) {\n currentLang = lang;\n }\n}\n\nexport function t(key) {\n const lang = getLanguage();\n return messages[lang]?.[key] || messages['en']?.[key] || key;\n}\n","import { useState, useEffect } from 'react';\nimport { getConfig } from '@quantabit/sdk-config';\nimport { t, setLanguage, getLanguage, messages } from './i18n/index.js';\n\n// 模拟多签提案数据库\nconst proposalsDb = {};\n\nexport async function createMultisigVault(owners, threshold) {\n if (!owners || owners.length === 0) {\n throw new Error(\"Owners list cannot be empty\");\n }\n if (threshold <= 0 || threshold > owners.length) {\n throw new Error(\"Invalid threshold value\");\n }\n \n // 模拟生成多签金库地址\n const vaultAddress = `vault_${Math.random().toString(36).substr(2, 9)}`;\n return {\n vaultAddress,\n owners,\n threshold,\n createdAt: Date.now()\n };\n}\n\nexport async function createProposal(vaultAddress, transactionData) {\n if (!vaultAddress || !vaultAddress.startsWith(\"vault_\")) {\n throw new Error(t('invalid_multisig'));\n }\n \n const proposalId = `prop_${Math.random().toString(36).substr(2, 9)}`;\n const proposal = {\n id: proposalId,\n vaultAddress,\n transactionData,\n approvals: [],\n status: 'pending', // pending, approved, executed, rejected\n createdAt: Date.now()\n };\n \n proposalsDb[proposalId] = proposal;\n return proposal;\n}\n\nexport async function approveProposal(proposalId, signerAddress) {\n const proposal = proposalsDb[proposalId];\n if (!proposal) {\n throw new Error(\"Proposal not found\");\n }\n if (proposal.status !== 'pending') {\n throw new Error(\"Proposal is no longer pending\");\n }\n if (!proposal.approvals.includes(signerAddress)) {\n proposal.approvals.push(signerAddress);\n }\n \n // 检查是否已达到阈值(模拟设定所有金库阈值为 2)\n if (proposal.approvals.length >= 2) {\n proposal.status = 'approved';\n }\n \n return {\n ...proposal,\n message: t('proposal_approved')\n };\n}\n\nexport async function executeProposal(proposalId) {\n const proposal = proposalsDb[proposalId];\n if (!proposal) {\n throw new Error(\"Proposal not found\");\n }\n \n // 模拟只有处于 approved 状态的提案才能执行\n if (proposal.status !== 'approved' && proposal.approvals.length < 2) {\n throw new Error(t('insufficient_signatures'));\n }\n \n proposal.status = 'executed';\n return {\n ...proposal,\n executedAt: Date.now(),\n message: t('proposal_executed')\n };\n}\n\nexport function useMultisig(vaultAddress) {\n const [proposals, setProposals] = useState([]);\n const [loading, setLoading] = useState(true);\n\n useEffect(() => {\n if (!vaultAddress) return;\n setLoading(true);\n \n // 模拟从节点查询多签提案列表\n const timer = setTimeout(() => {\n const filtered = Object.values(proposalsDb).filter(p => p.vaultAddress === vaultAddress);\n setProposals(filtered);\n setLoading(false);\n }, 500);\n\n return () => clearTimeout(timer);\n }, [vaultAddress]);\n\n return { proposals, loading };\n}\n\nexport { t, setLanguage, getLanguage, messages };\nexport const SUPPORTED_LANGUAGES = ['en', 'zh', 'ja', 'ko'];\nexport { proposalsDb };\n"],"names":["messages","en","proposal_created","proposal_executed","proposal_approved","proposal_rejected","insufficient_signatures","invalid_multisig","zh","ja","ko","currentLang","getLanguage","getGlobalLang","setLanguage","lang","t","key","proposalsDb","createMultisigVault","owners","threshold","length","Error","vaultAddress","Math","random","toString","substr","createdAt","Date","now","createProposal","transactionData","startsWith","proposalId","proposal","id","approvals","status","approveProposal","signerAddress","includes","push","message","executeProposal","executedAt","useMultisig","proposals","setProposals","useState","loading","setLoading","useEffect","timer","setTimeout","filtered","Object","values","filter","p","clearTimeout","SUPPORTED_LANGUAGES"],"mappings":";;;AAEO,MAAMA,QAAQ,GAAG;AACtBC,EAAAA,EAAE,EAAE;AACFC,IAAAA,gBAAgB,EAAE,yCAAyC;AAC3DC,IAAAA,iBAAiB,EAAE,0CAA0C;AAC7DC,IAAAA,iBAAiB,EAAE,gCAAgC;AACnDC,IAAAA,iBAAiB,EAAE,gCAAgC;AACnDC,IAAAA,uBAAuB,EAAE,6CAA6C;AACtEC,IAAAA,gBAAgB,EAAE;GACnB;AACDC,EAAAA,EAAE,EAAE;AACFN,IAAAA,gBAAgB,EAAE,UAAU;AAC5BC,IAAAA,iBAAiB,EAAE,UAAU;AAC7BC,IAAAA,iBAAiB,EAAE,QAAQ;AAC3BC,IAAAA,iBAAiB,EAAE,QAAQ;AAC3BC,IAAAA,uBAAuB,EAAE,aAAa;AACtCC,IAA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AAO,EAAEC,UAAU,CAAC,GAAGF,QAAQ,CAAC,IAAI,CAAC;AAE5CG,EAAAA,SAAS,CAAC,MAAM;IACd,IAAI,CAAC7B,YAAY,EAAE;IACnB4B,UAAU,CAAC,IAAI,CAAC;;AAEhB;AACA,IAAA,MAAME,KAAK,GAAGC,UAAU,CAAC,MAAM;AAC7B,MAAA,MAAMC,QAAQ,GAAGC,MAAM,CAACC,MAAM,CAACxC,WAAW,CAAC,CAACyC,MAAM,CAACC,CAAC,IAAIA,CAAC,CAACpC,YAAY,KAAKA,YAAY,CAAC;MACxFyB,YAAY,CAACO,QAAQ,CAAC;MACtBJ,UAAU,CAAC,KAAK,CAAC;IACnB,CAAC,EAAE,GAAG,CAAC;AAEP,IAAA,OAAO,MAAMS,YAAY,CAACP,KAAK,CAAC;AAClC,EAAA,CAAC,EAAE,CAAC9B,YAAY,CAAC,CAAC;EAElB,OAAO;IAAEwB,SAAS;AAAEG,IAAAA;GAAS;AAC/B;AAGO,MAAMW,mBAAmB,GAAG,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI;;;;"}
package/package.json ADDED
@@ -0,0 +1,71 @@
1
+ {
2
+ "name": "@quantabit/multi-sig-sdk",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "QuantaBit Multi-Sig SDK - Decentralized multisig vault and proposal management",
6
+ "main": "dist/index.cjs",
7
+ "module": "dist/index.esm.js",
8
+ "types": "types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./types/index.d.ts",
12
+ "import": "./dist/index.esm.js",
13
+ "require": "./dist/index.cjs"
14
+ }
15
+ },
16
+ "sideEffects": [
17
+ "*.css"
18
+ ],
19
+ "files": [
20
+ "dist",
21
+ "types",
22
+ "README.md",
23
+ "LICENSE"
24
+ ],
25
+ "scripts": {
26
+ "build": "rollup -c",
27
+ "dev": "rollup -c -w",
28
+ "test": "jest --passWithNoTests",
29
+ "prepublishOnly": "npm run build"
30
+ },
31
+ "repository": {
32
+ "type": "git",
33
+ "url": "https://github.com/quantabit-chain/qbit-sdk.git",
34
+ "directory": "packages/multi-sig-sdk"
35
+ },
36
+ "keywords": [
37
+ "multisig",
38
+ "safe",
39
+ "squads",
40
+ "web3",
41
+ "react",
42
+ "quantabit"
43
+ ],
44
+ "author": "QuantaBit Team",
45
+ "license": "MIT",
46
+ "engines": {
47
+ "node": ">=18.0.0"
48
+ },
49
+ "peerDependencies": {
50
+ "react": ">=17.0.0",
51
+ "react-dom": ">=17.0.0"
52
+ },
53
+ "dependencies": {
54
+ "@quantabit/sdk-config": "^1.0.10"
55
+ },
56
+ "publishConfig": {
57
+ "access": "public"
58
+ },
59
+ "qbit": {
60
+ "privacy": {
61
+ "level": "functional",
62
+ "dataCollection": "Queries multisig proposal data. No sensitive personal data collected.",
63
+ "gdprCompliant": true,
64
+ "ccpaCompliant": true
65
+ }
66
+ },
67
+ "homepage": "https://github.com/quantabit-chain/qbit-sdk/tree/main/packages/multi-sig-sdk#readme",
68
+ "bugs": {
69
+ "url": "https://github.com/quantabit-chain/qbit-sdk/issues"
70
+ }
71
+ }
@@ -0,0 +1,31 @@
1
+ export interface MultisigVault {
2
+ vaultAddress: string;
3
+ owners: string[];
4
+ threshold: number;
5
+ createdAt: number;
6
+ }
7
+
8
+ export interface Proposal {
9
+ id: string;
10
+ vaultAddress: string;
11
+ transactionData: any;
12
+ approvals: string[];
13
+ status: 'pending' | 'approved' | 'executed' | 'rejected';
14
+ createdAt: number;
15
+ }
16
+
17
+ export function createMultisigVault(owners: string[], threshold: number): Promise<MultisigVault>;
18
+ export function createProposal(vaultAddress: string, transactionData: any): Promise<Proposal>;
19
+ export function approveProposal(proposalId: string, signerAddress: string): Promise<Proposal & { message: string }>;
20
+ export function executeProposal(proposalId: string): Promise<Proposal & { executedAt: number; message: string }>;
21
+
22
+ export function useMultisig(vaultAddress: string): {
23
+ proposals: Proposal[];
24
+ loading: boolean;
25
+ };
26
+
27
+ export function getLanguage(): string;
28
+ export function setLanguage(lang: string): void;
29
+ export function t(key: string): string;
30
+ export const SUPPORTED_LANGUAGES: string[];
31
+ export const messages: Record<string, Record<string, string>>;