solvrn-sdk 1.0.0 → 1.0.1
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/dist/index.d.ts +19 -1
- package/dist/index.js +26 -3
- package/package.json +4 -2
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import * as _aztec_bb_js from '@aztec/bb.js';
|
|
2
|
-
import { Buffer } from 'buffer';
|
|
3
2
|
import { AnchorProvider } from '@coral-xyz/anchor';
|
|
4
3
|
import { PublicKey } from '@solana/web3.js';
|
|
5
4
|
|
|
@@ -38,6 +37,14 @@ declare class SolvrnApi {
|
|
|
38
37
|
}): Promise<any>;
|
|
39
38
|
proveTally(proposalId: number, yesVotes: number, noVotes: number, threshold: number, quorum: number): Promise<any>;
|
|
40
39
|
getVoteCounts(proposalId: number): Promise<any>;
|
|
40
|
+
createProposal(proposalId: number, votingMint: string, metadata: ProposalMetadata, creator: string, targetWallet?: string): Promise<{
|
|
41
|
+
success: boolean;
|
|
42
|
+
tx?: string;
|
|
43
|
+
proposalId?: string;
|
|
44
|
+
root?: string;
|
|
45
|
+
voterCount?: number;
|
|
46
|
+
error?: string;
|
|
47
|
+
}>;
|
|
41
48
|
private post;
|
|
42
49
|
private get;
|
|
43
50
|
}
|
|
@@ -65,6 +72,17 @@ declare class SolvrnClient {
|
|
|
65
72
|
encryption: SolvrnEncryption;
|
|
66
73
|
constructor(relayerUrl: string, arciumProgramId?: string, programId?: string);
|
|
67
74
|
init(circuitJson: any): Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* Create a proposal with privacy-preserving mode.
|
|
77
|
+
* The proposal is created via the relayer - creator identity is NOT stored on-chain.
|
|
78
|
+
*
|
|
79
|
+
* @param provider - AnchorProvider (still needed for connection info)
|
|
80
|
+
* @param authorityPubkey - Creator's public key (stored off-chain only)
|
|
81
|
+
* @param votingMint - Token mint for voting eligibility
|
|
82
|
+
* @param metadata - Proposal title, description, duration
|
|
83
|
+
* @param gasBufferSol - (deprecated, relayer pays gas now)
|
|
84
|
+
* @param proposalIdOverride - Optional specific proposal ID
|
|
85
|
+
*/
|
|
68
86
|
createProposal(provider: AnchorProvider, authorityPubkey: PublicKey, votingMint: string, metadata: ProposalMetadata, gasBufferSol: number, proposalIdOverride?: number): Promise<{
|
|
69
87
|
proposalId: number;
|
|
70
88
|
txid: string;
|
package/dist/index.js
CHANGED
|
@@ -57,12 +57,24 @@ var SolvrnApi = class {
|
|
|
57
57
|
async getVoteCounts(proposalId) {
|
|
58
58
|
return this.get(`vote-counts/${proposalId}`);
|
|
59
59
|
}
|
|
60
|
+
// --- PRIVACY-PRESERVING PROPOSAL CREATION ---
|
|
61
|
+
// Creates proposal via relayer (creator identity hidden on-chain)
|
|
62
|
+
async createProposal(proposalId, votingMint, metadata, creator, targetWallet) {
|
|
63
|
+
return this.post("create-proposal", {
|
|
64
|
+
proposalId,
|
|
65
|
+
votingMint,
|
|
66
|
+
metadata,
|
|
67
|
+
creator,
|
|
68
|
+
targetWallet
|
|
69
|
+
});
|
|
70
|
+
}
|
|
60
71
|
async post(endpoint, body) {
|
|
61
72
|
const allowedEndpoints = [
|
|
62
73
|
"initialize-snapshot",
|
|
63
74
|
"get-proof",
|
|
64
75
|
"relay-vote",
|
|
65
|
-
"prove-tally"
|
|
76
|
+
"prove-tally",
|
|
77
|
+
"create-proposal"
|
|
66
78
|
];
|
|
67
79
|
if (!allowedEndpoints.includes(endpoint)) {
|
|
68
80
|
throw new Error(`Endpoint '${endpoint}' is not accessible through SDK. Use direct API calls for admin functionality.`);
|
|
@@ -129,7 +141,6 @@ var SolvrnProver = class {
|
|
|
129
141
|
// src/encryption.ts
|
|
130
142
|
import { getMXEPublicKey, RescueCipher, x25519 } from "@arcium-hq/client";
|
|
131
143
|
import { PublicKey as PublicKey2 } from "@solana/web3.js";
|
|
132
|
-
import { Buffer as Buffer2 } from "buffer";
|
|
133
144
|
var SolvrnEncryption = class {
|
|
134
145
|
constructor(programId = process.env.ARCIUM_PROGRAM_ID || "DBCtofDd6f3U342nwz768FXbH6K5QyGxZUGLjFeb9JTS") {
|
|
135
146
|
this.programId = new PublicKey2(programId);
|
|
@@ -155,7 +166,7 @@ var SolvrnEncryption = class {
|
|
|
155
166
|
const nonce = x25519.utils.randomSecretKey().slice(0, 16);
|
|
156
167
|
const encrypted = cipher.encrypt(inputs, nonce);
|
|
157
168
|
return {
|
|
158
|
-
ciphertext:
|
|
169
|
+
ciphertext: Buffer.from(new Uint8Array(encrypted.flat().map((n) => Number(n)))),
|
|
159
170
|
nonce: Array.from(nonce),
|
|
160
171
|
public_key: Array.from(ephemeralPublic)
|
|
161
172
|
};
|
|
@@ -880,6 +891,17 @@ var SolvrnClient = class {
|
|
|
880
891
|
async init(circuitJson) {
|
|
881
892
|
await this.prover.init(circuitJson);
|
|
882
893
|
}
|
|
894
|
+
/**
|
|
895
|
+
* Create a proposal with privacy-preserving mode.
|
|
896
|
+
* The proposal is created via the relayer - creator identity is NOT stored on-chain.
|
|
897
|
+
*
|
|
898
|
+
* @param provider - AnchorProvider (still needed for connection info)
|
|
899
|
+
* @param authorityPubkey - Creator's public key (stored off-chain only)
|
|
900
|
+
* @param votingMint - Token mint for voting eligibility
|
|
901
|
+
* @param metadata - Proposal title, description, duration
|
|
902
|
+
* @param gasBufferSol - (deprecated, relayer pays gas now)
|
|
903
|
+
* @param proposalIdOverride - Optional specific proposal ID
|
|
904
|
+
*/
|
|
883
905
|
async createProposal(provider, authorityPubkey, votingMint, metadata, gasBufferSol, proposalIdOverride) {
|
|
884
906
|
let proposalId = proposalIdOverride;
|
|
885
907
|
if (!proposalId) {
|
|
@@ -887,6 +909,7 @@ var SolvrnClient = class {
|
|
|
887
909
|
if (!success) throw new Error("Failed to get ID");
|
|
888
910
|
proposalId = nextId;
|
|
889
911
|
}
|
|
912
|
+
console.log("SDK: Creating proposal (temporary revert to old flow)");
|
|
890
913
|
const snap = await this.api.initializeSnapshot(
|
|
891
914
|
proposalId,
|
|
892
915
|
votingMint,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solvrn-sdk",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1",
|
|
4
4
|
"description": "Privacy SDK for Solana governance using zero-knowledge proofs and confidential computing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -31,7 +31,9 @@
|
|
|
31
31
|
"exports": {
|
|
32
32
|
".": {
|
|
33
33
|
"types": "./dist/index.d.ts",
|
|
34
|
-
"import": "./dist/index.js"
|
|
34
|
+
"import": "./dist/index.js",
|
|
35
|
+
"require": "./dist/index.js",
|
|
36
|
+
"default": "./dist/index.js"
|
|
35
37
|
}
|
|
36
38
|
},
|
|
37
39
|
"scripts": {
|