create-veil-app 0.3.1 → 0.3.3
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.
|
@@ -369,12 +369,15 @@ async function addVeilToProject(projectPath, config) {
|
|
|
369
369
|
generateRecoveryTs: generateRecoveryTs2,
|
|
370
370
|
generateAccessTs: generateAccessTs2,
|
|
371
371
|
generateGuaranteesTs: generateGuaranteesTs2,
|
|
372
|
+
generateVotingTs: generateVotingTs2,
|
|
373
|
+
generateMultisigTs: generateMultisigTs2,
|
|
374
|
+
generateStakingTs: generateStakingTs2,
|
|
372
375
|
generateRpcTs: generateRpcTs2,
|
|
373
376
|
generateHeliusTs: generateHeliusTs2,
|
|
374
377
|
generateVeilProvider: generateVeilProvider2,
|
|
375
378
|
generateVeilHooks: generateVeilHooks2,
|
|
376
379
|
generateShadowPayModule: generateShadowPayModule2
|
|
377
|
-
} = await import("./templates-
|
|
380
|
+
} = await import("./templates-VCOAX7N3.js");
|
|
378
381
|
const dirs = ["privacy", "infra", "contexts", "hooks"];
|
|
379
382
|
for (const dir of dirs) {
|
|
380
383
|
await fs2.ensureDir(path2.join(projectPath, dir));
|
|
@@ -382,15 +385,22 @@ async function addVeilToProject(projectPath, config) {
|
|
|
382
385
|
const files = [
|
|
383
386
|
{ path: "veil.config.ts", content: generateVeilConfig2(config) },
|
|
384
387
|
{ path: ".env.example", content: generateEnvExample2(config), append: true },
|
|
385
|
-
// Privacy module
|
|
388
|
+
// Privacy module - Core
|
|
386
389
|
{ path: "privacy/login.ts", content: generateLoginTs2() },
|
|
387
390
|
{ path: "privacy/recovery.ts", content: generateRecoveryTs2() },
|
|
388
391
|
{ path: "privacy/access.ts", content: generateAccessTs2() },
|
|
389
392
|
{ path: "privacy/guarantees.ts", content: generateGuaranteesTs2() },
|
|
393
|
+
// Privacy module - Advanced (voting, multisig, staking)
|
|
394
|
+
{ path: "privacy/voting.ts", content: generateVotingTs2() },
|
|
395
|
+
{ path: "privacy/multisig.ts", content: generateMultisigTs2() },
|
|
396
|
+
{ path: "privacy/staking.ts", content: generateStakingTs2() },
|
|
390
397
|
{ path: "privacy/index.ts", content: `export * from "./login.js";
|
|
391
398
|
export * from "./recovery.js";
|
|
392
399
|
export * from "./access.js";
|
|
393
400
|
export * from "./guarantees.js";
|
|
401
|
+
export * from "./voting.js";
|
|
402
|
+
export * from "./multisig.js";
|
|
403
|
+
export * from "./staking.js";
|
|
394
404
|
` },
|
|
395
405
|
// Infra module
|
|
396
406
|
{ path: "infra/rpc.ts", content: generateRpcTs2() },
|
|
@@ -729,6 +739,168 @@ export type PrivacyGuarantee = keyof typeof PRIVACY_GUARANTEES;
|
|
|
729
739
|
`;
|
|
730
740
|
}
|
|
731
741
|
|
|
742
|
+
// src/templates/privacy-modules.ts
|
|
743
|
+
function generateVotingTs() {
|
|
744
|
+
return `/**
|
|
745
|
+
* Private Voting Module
|
|
746
|
+
*
|
|
747
|
+
* Commit-reveal voting for DAOs with hidden votes until reveal phase.
|
|
748
|
+
*
|
|
749
|
+
* PRIVACY GUARANTEE:
|
|
750
|
+
* - Vote choices are hidden during voting phase (commitment only)
|
|
751
|
+
* - Votes revealed simultaneously after voting ends
|
|
752
|
+
* - No correlation between commitment and voter identity
|
|
753
|
+
*/
|
|
754
|
+
|
|
755
|
+
import { Connection, PublicKey, Transaction } from "@solana/web3.js";
|
|
756
|
+
import { PrivateVotingClient, VoteChoice } from "@veil-protocol/sdk/voting";
|
|
757
|
+
|
|
758
|
+
// Initialize voting client
|
|
759
|
+
export function createVotingClient(
|
|
760
|
+
connection: Connection,
|
|
761
|
+
encryptionKey: string
|
|
762
|
+
): PrivateVotingClient {
|
|
763
|
+
return new PrivateVotingClient(connection, encryptionKey);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
/**
|
|
767
|
+
* Cast a private vote on a proposal
|
|
768
|
+
* Your vote choice is hidden until the reveal phase
|
|
769
|
+
*/
|
|
770
|
+
export async function castPrivateVote(
|
|
771
|
+
client: PrivateVotingClient,
|
|
772
|
+
proposalId: Uint8Array,
|
|
773
|
+
choice: VoteChoice,
|
|
774
|
+
signTransaction: (tx: Transaction) => Promise<Transaction>
|
|
775
|
+
): Promise<{ success: boolean; commitment?: string; error?: string }> {
|
|
776
|
+
return client.createVote(proposalId, choice, signTransaction);
|
|
777
|
+
}
|
|
778
|
+
|
|
779
|
+
/**
|
|
780
|
+
* Reveal your vote after voting ends
|
|
781
|
+
* All votes are revealed simultaneously
|
|
782
|
+
*/
|
|
783
|
+
export async function revealVote(
|
|
784
|
+
client: PrivateVotingClient,
|
|
785
|
+
proposalId: Uint8Array,
|
|
786
|
+
commitment: Uint8Array,
|
|
787
|
+
signTransaction: (tx: Transaction) => Promise<Transaction>
|
|
788
|
+
): Promise<{ success: boolean; error?: string }> {
|
|
789
|
+
return client.revealVote(proposalId, commitment, signTransaction);
|
|
790
|
+
}
|
|
791
|
+
|
|
792
|
+
// Re-export types
|
|
793
|
+
export { VoteChoice } from "@veil-protocol/sdk/voting";
|
|
794
|
+
`;
|
|
795
|
+
}
|
|
796
|
+
function generateMultisigTs() {
|
|
797
|
+
return `/**
|
|
798
|
+
* Stealth Multisig Module
|
|
799
|
+
*
|
|
800
|
+
* M-of-N signing with hidden signer identities.
|
|
801
|
+
*
|
|
802
|
+
* PRIVACY GUARANTEE:
|
|
803
|
+
* - Signer identities never revealed on-chain (commitment hashes only)
|
|
804
|
+
* - No one knows WHICH signers approved a transaction
|
|
805
|
+
* - Only know that threshold was reached
|
|
806
|
+
*/
|
|
807
|
+
|
|
808
|
+
import { Connection, PublicKey, Transaction } from "@solana/web3.js";
|
|
809
|
+
import { StealthMultisigClient, SignerSecret } from "@veil-protocol/sdk/multisig";
|
|
810
|
+
|
|
811
|
+
// Initialize multisig client
|
|
812
|
+
export function createMultisigClient(
|
|
813
|
+
connection: Connection,
|
|
814
|
+
encryptionKey: string
|
|
815
|
+
): StealthMultisigClient {
|
|
816
|
+
return new StealthMultisigClient(connection, encryptionKey);
|
|
817
|
+
}
|
|
818
|
+
|
|
819
|
+
/**
|
|
820
|
+
* Create a stealth multisig vault
|
|
821
|
+
* Signers are identified by commitment hashes, not addresses
|
|
822
|
+
*/
|
|
823
|
+
export async function createStealthVault(
|
|
824
|
+
client: StealthMultisigClient,
|
|
825
|
+
threshold: number,
|
|
826
|
+
signerIdentifiers: string[], // emails, names, etc. - never stored on-chain
|
|
827
|
+
signTransaction: (tx: Transaction) => Promise<Transaction>
|
|
828
|
+
): Promise<{
|
|
829
|
+
success: boolean;
|
|
830
|
+
vaultId?: string;
|
|
831
|
+
signerSecrets?: SignerSecret[];
|
|
832
|
+
error?: string;
|
|
833
|
+
}> {
|
|
834
|
+
return client.createVault(threshold, signerIdentifiers, signTransaction);
|
|
835
|
+
}
|
|
836
|
+
|
|
837
|
+
/**
|
|
838
|
+
* Sign a proposal without revealing your identity
|
|
839
|
+
* Only commitment hash is stored on-chain
|
|
840
|
+
*/
|
|
841
|
+
export async function stealthSign(
|
|
842
|
+
client: StealthMultisigClient,
|
|
843
|
+
proposalId: Uint8Array,
|
|
844
|
+
signerSecret: SignerSecret,
|
|
845
|
+
signTransaction: (tx: Transaction) => Promise<Transaction>
|
|
846
|
+
): Promise<{ success: boolean; signature?: string; error?: string }> {
|
|
847
|
+
return client.stealthSign(proposalId, signerSecret, signTransaction);
|
|
848
|
+
}
|
|
849
|
+
`;
|
|
850
|
+
}
|
|
851
|
+
function generateStakingTs() {
|
|
852
|
+
return `/**
|
|
853
|
+
* Private Staking Module
|
|
854
|
+
*
|
|
855
|
+
* Stake with hidden amounts using Pedersen commitments.
|
|
856
|
+
*
|
|
857
|
+
* PRIVACY GUARANTEE:
|
|
858
|
+
* - Stake amounts hidden via Pedersen commitments
|
|
859
|
+
* - Only you can decrypt your stake/rewards
|
|
860
|
+
* - Withdrawal uses ZK proof (proves ownership without revealing amount)
|
|
861
|
+
*/
|
|
862
|
+
|
|
863
|
+
import { Connection, PublicKey, Transaction } from "@solana/web3.js";
|
|
864
|
+
import { PrivateStakingClient } from "@veil-protocol/sdk/staking";
|
|
865
|
+
|
|
866
|
+
// Initialize staking client
|
|
867
|
+
export function createStakingClient(
|
|
868
|
+
connection: Connection,
|
|
869
|
+
encryptionKey: string
|
|
870
|
+
): PrivateStakingClient {
|
|
871
|
+
return new PrivateStakingClient(connection, encryptionKey);
|
|
872
|
+
}
|
|
873
|
+
|
|
874
|
+
/**
|
|
875
|
+
* Stake privately with hidden amount
|
|
876
|
+
* Amount is committed, not revealed on-chain
|
|
877
|
+
*/
|
|
878
|
+
export async function privateStake(
|
|
879
|
+
client: PrivateStakingClient,
|
|
880
|
+
validator: PublicKey,
|
|
881
|
+
amountSol: number,
|
|
882
|
+
signTransaction: (tx: Transaction) => Promise<Transaction>
|
|
883
|
+
): Promise<{
|
|
884
|
+
success: boolean;
|
|
885
|
+
commitment?: string;
|
|
886
|
+
unlockAt?: number;
|
|
887
|
+
error?: string;
|
|
888
|
+
}> {
|
|
889
|
+
return client.stake(validator, amountSol, signTransaction);
|
|
890
|
+
}
|
|
891
|
+
|
|
892
|
+
/**
|
|
893
|
+
* Get your stake rewards (decrypted client-side)
|
|
894
|
+
*/
|
|
895
|
+
export async function getRewards(
|
|
896
|
+
client: PrivateStakingClient,
|
|
897
|
+
stakeCommitment: Uint8Array
|
|
898
|
+
): Promise<{ pending: number; claimed: number; apr: number }> {
|
|
899
|
+
return client.getRewardsInfo(stakeCommitment);
|
|
900
|
+
}
|
|
901
|
+
`;
|
|
902
|
+
}
|
|
903
|
+
|
|
732
904
|
// src/templates/infra.ts
|
|
733
905
|
function generateRpcTs(config) {
|
|
734
906
|
const rpcUrl = config.helius ? "process.env.HELIUS_RPC_URL" : config.network === "devnet" ? '"https://api.devnet.solana.com"' : '"http://localhost:8899"';
|
|
@@ -2025,6 +2197,9 @@ export {
|
|
|
2025
2197
|
generateRecoveryTs,
|
|
2026
2198
|
generateAccessTs,
|
|
2027
2199
|
generateGuaranteesTs,
|
|
2200
|
+
generateVotingTs,
|
|
2201
|
+
generateMultisigTs,
|
|
2202
|
+
generateStakingTs,
|
|
2028
2203
|
generateRpcTs,
|
|
2029
2204
|
generateHeliusTs,
|
|
2030
2205
|
generatePackageJson,
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import {
|
|
|
3
3
|
TEMPLATE_INFO,
|
|
4
4
|
runAdd,
|
|
5
5
|
runInit
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-4DZ7WBYJ.js";
|
|
7
7
|
|
|
8
8
|
// src/index.ts
|
|
9
9
|
import { Command } from "commander";
|
|
@@ -179,7 +179,10 @@ function displayTemplates() {
|
|
|
179
179
|
}
|
|
180
180
|
}
|
|
181
181
|
var program = new Command();
|
|
182
|
-
program.name("veil").description("Privacy infrastructure for Solana \u2014 DeFi, DApps, Exchanges, Wallets").version("0.3.
|
|
182
|
+
program.name("create-veil-app").description("Privacy infrastructure for Solana \u2014 DeFi, DApps, Exchanges, Wallets").version("0.3.2").argument("[name]", "Project name").option("-t, --template <template>", "Template: dex, lending, yield, pool, gaming, nft, social, governance, cex, aggregator, trading, wallet, portfolio, payments, basic").option("-f, --framework <framework>", "Framework: nextjs or vite").option("--helius", "Enable Helius RPC (default: true)").option("--no-helius", "Disable Helius RPC").option("--shadow-pay", "Enable ShadowPay mainnet integration").option("--no-shadow-pay", "Disable ShadowPay").option("--network <network>", "Veil features network: devnet or localnet").action(async (name, options) => {
|
|
183
|
+
displayBanner();
|
|
184
|
+
await runInit({ ...options, name });
|
|
185
|
+
});
|
|
183
186
|
program.command("init [name]").description("Create a new project with full Veil + ShadowWire privacy stack").option("-t, --template <template>", "Template: dex, lending, yield, pool, gaming, nft, social, governance, cex, aggregator, trading, wallet, portfolio, payments, basic").option("-f, --framework <framework>", "Framework: nextjs or vite").option("--helius", "Enable Helius RPC (default: true)").option("--no-helius", "Disable Helius RPC").option("--shadow-pay", "Enable ShadowPay mainnet integration").option("--no-shadow-pay", "Disable ShadowPay").option("--network <network>", "Veil features network: devnet or localnet").action(async (name, options) => {
|
|
184
187
|
displayBanner();
|
|
185
188
|
await runInit({ ...options, name });
|
|
@@ -201,20 +204,20 @@ program.command("identity <action>").description("Manage ZK identities (create,
|
|
|
201
204
|
if (process.argv.length === 2) {
|
|
202
205
|
displayBanner();
|
|
203
206
|
console.log(chalk2.bold("Quick Start:\n"));
|
|
204
|
-
console.log(` ${chalk2.cyan("veil
|
|
205
|
-
console.log(` ${chalk2.cyan("veil
|
|
206
|
-
console.log(` ${chalk2.cyan("veil
|
|
207
|
+
console.log(` ${chalk2.cyan("npx create-veil-app my-dex --template=dex")}`);
|
|
208
|
+
console.log(` ${chalk2.cyan("npx create-veil-app my-wallet --template=wallet")}`);
|
|
209
|
+
console.log(` ${chalk2.cyan("npx create-veil-app my-dao --template=governance")}`);
|
|
207
210
|
console.log();
|
|
208
|
-
console.log(chalk2.dim("
|
|
209
|
-
console.log(` ${chalk2.cyan("veil
|
|
210
|
-
console.log(` ${chalk2.cyan("veil
|
|
211
|
-
console.log(` ${chalk2.cyan("veil
|
|
212
|
-
console.log(` ${chalk2.cyan("veil
|
|
211
|
+
console.log(chalk2.dim("Usage:"));
|
|
212
|
+
console.log(` ${chalk2.cyan("npx create-veil-app [name]")} Create new project`);
|
|
213
|
+
console.log(` ${chalk2.cyan("npx create-veil-app [name] -t dex")} Use specific template`);
|
|
214
|
+
console.log(` ${chalk2.cyan("npx create-veil-app init [name]")} Alternative syntax`);
|
|
215
|
+
console.log(` ${chalk2.cyan("npx create-veil-app templates")} List all templates`);
|
|
216
|
+
console.log(` ${chalk2.cyan("npx create-veil-app demo")} Interactive SDK demo`);
|
|
213
217
|
console.log();
|
|
214
218
|
console.log(chalk2.dim("Network Info:"));
|
|
215
219
|
console.log(` ${chalk2.yellow("ShadowPay")} runs on ${chalk2.bold("mainnet")} (real private transfers)`);
|
|
216
220
|
console.log(` ${chalk2.cyan("Veil features")} run on ${chalk2.bold("devnet")} (voting, staking, multisig)`);
|
|
217
221
|
console.log();
|
|
218
|
-
} else {
|
|
219
|
-
program.parse();
|
|
220
222
|
}
|
|
223
|
+
program.parse();
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
generateHeliusTs,
|
|
8
8
|
generateLayoutTsx,
|
|
9
9
|
generateLoginTs,
|
|
10
|
+
generateMultisigTs,
|
|
10
11
|
generateNextConfig,
|
|
11
12
|
generatePackageJson,
|
|
12
13
|
generatePostcssConfig,
|
|
@@ -18,13 +19,15 @@ import {
|
|
|
18
19
|
generateSdkHooks,
|
|
19
20
|
generateSdkProvider,
|
|
20
21
|
generateShadowPayModule,
|
|
22
|
+
generateStakingTs,
|
|
21
23
|
generateTailwindConfig,
|
|
22
24
|
generateTsConfig,
|
|
23
25
|
generateVeilConfig,
|
|
24
26
|
generateVeilHooks,
|
|
25
27
|
generateVeilProvider,
|
|
28
|
+
generateVotingTs,
|
|
26
29
|
generateWalletButton
|
|
27
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-4DZ7WBYJ.js";
|
|
28
31
|
export {
|
|
29
32
|
generateAccessTs,
|
|
30
33
|
generateAppEntry,
|
|
@@ -34,6 +37,7 @@ export {
|
|
|
34
37
|
generateHeliusTs,
|
|
35
38
|
generateLayoutTsx,
|
|
36
39
|
generateLoginTs,
|
|
40
|
+
generateMultisigTs,
|
|
37
41
|
generateNextConfig,
|
|
38
42
|
generatePackageJson,
|
|
39
43
|
generatePostcssConfig,
|
|
@@ -45,10 +49,12 @@ export {
|
|
|
45
49
|
generateSdkHooks,
|
|
46
50
|
generateSdkProvider,
|
|
47
51
|
generateShadowPayModule,
|
|
52
|
+
generateStakingTs,
|
|
48
53
|
generateTailwindConfig,
|
|
49
54
|
generateTsConfig,
|
|
50
55
|
generateVeilConfig,
|
|
51
56
|
generateVeilHooks,
|
|
52
57
|
generateVeilProvider,
|
|
58
|
+
generateVotingTs,
|
|
53
59
|
generateWalletButton
|
|
54
60
|
};
|