@veilo/sdk-core 0.5.0 → 0.7.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/README.md +282 -18
- package/accounts.d.ts +2 -0
- package/accounts.js +3 -0
- package/cloak.d.ts +2 -0
- package/cloak.js +3 -0
- package/config.d.ts +2 -0
- package/config.js +3 -0
- package/dist/cjs/events/index.d.ts +6 -0
- package/dist/cjs/events/index.js +22 -0
- package/dist/cjs/events/parsing.d.ts +25 -0
- package/dist/cjs/events/parsing.js +158 -0
- package/dist/cjs/events/position.d.ts +26 -0
- package/dist/cjs/events/position.js +53 -0
- package/dist/cjs/events/recovery.d.ts +87 -0
- package/dist/cjs/events/recovery.js +281 -0
- package/dist/cjs/events/scanning.d.ts +35 -0
- package/dist/cjs/events/scanning.js +98 -0
- package/dist/cjs/events/tree.d.ts +27 -0
- package/dist/cjs/events/tree.js +63 -0
- package/dist/cjs/events/types.d.ts +39 -0
- package/dist/cjs/events/types.js +2 -0
- package/dist/cjs/events.d.ts +1 -77
- package/dist/cjs/events.js +6 -154
- package/dist/cjs/identity/encoding.d.ts +9 -0
- package/dist/cjs/identity/encoding.js +85 -0
- package/dist/cjs/identity/index.d.ts +4 -0
- package/dist/cjs/identity/index.js +20 -0
- package/dist/cjs/identity/noteKey.d.ts +33 -0
- package/dist/cjs/identity/noteKey.js +97 -0
- package/dist/cjs/identity/spending.d.ts +18 -0
- package/dist/cjs/identity/spending.js +46 -0
- package/dist/cjs/identity/viewKey.d.ts +38 -0
- package/dist/cjs/identity/viewKey.js +105 -0
- package/dist/cjs/idl/index.d.ts +18 -0
- package/dist/cjs/idl/index.js +24 -0
- package/dist/cjs/idl/privacy_pool.json +9907 -9907
- package/dist/cjs/idl/privacy_pool_legacy.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool_legacy.js +3307 -0
- package/dist/cjs/idl/privacy_pool_legacy.json +2302 -0
- package/dist/cjs/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool_legacy2.js +3397 -0
- package/dist/cjs/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/cjs/index.d.ts +8 -3
- package/dist/cjs/index.js +12 -2
- package/dist/cjs/notes/amount.d.ts +2 -0
- package/dist/cjs/notes/amount.js +21 -0
- package/dist/cjs/notes/index.d.ts +4 -0
- package/dist/cjs/notes/index.js +4 -0
- package/dist/cjs/notes/recovery.d.ts +16 -6
- package/dist/cjs/notes/recovery.js +33 -16
- package/dist/cjs/notes/scan.d.ts +74 -0
- package/dist/cjs/notes/scan.js +110 -0
- package/dist/cjs/notes/selection.d.ts +133 -0
- package/dist/cjs/notes/selection.js +260 -0
- package/dist/cjs/notes/spent.d.ts +60 -0
- package/dist/cjs/notes/spent.js +101 -0
- package/dist/cjs/perps/constants.d.ts +16 -0
- package/dist/cjs/perps/constants.js +52 -0
- package/dist/cjs/perps/index.d.ts +5 -0
- package/dist/cjs/perps/index.js +21 -0
- package/dist/cjs/perps/keys.d.ts +16 -0
- package/dist/cjs/perps/keys.js +43 -0
- package/dist/cjs/perps/pdas.d.ts +29 -0
- package/dist/cjs/perps/pdas.js +55 -0
- package/dist/cjs/perps/relayer.d.ts +9 -0
- package/dist/cjs/perps/relayer.js +35 -0
- package/dist/cjs/perps/types.d.ts +126 -0
- package/dist/cjs/perps/types.js +2 -0
- package/dist/cjs/positions/index.d.ts +4 -0
- package/dist/cjs/positions/index.js +20 -0
- package/dist/cjs/positions/keys.d.ts +29 -0
- package/dist/cjs/positions/keys.js +71 -0
- package/dist/cjs/positions/pdas.d.ts +15 -0
- package/dist/cjs/positions/pdas.js +54 -0
- package/dist/cjs/positions/relayer.d.ts +4 -0
- package/dist/cjs/positions/relayer.js +15 -0
- package/dist/cjs/positions/types.d.ts +97 -0
- package/dist/cjs/positions/types.js +2 -0
- package/dist/cjs/predictions/client.d.ts +41 -0
- package/dist/cjs/predictions/client.js +147 -0
- package/dist/cjs/predictions/index.d.ts +5 -0
- package/dist/cjs/predictions/index.js +21 -0
- package/dist/cjs/predictions/keys.d.ts +14 -0
- package/dist/cjs/predictions/keys.js +40 -0
- package/dist/cjs/predictions/pdas.d.ts +6 -0
- package/dist/cjs/predictions/pdas.js +13 -0
- package/dist/cjs/predictions/relayer.d.ts +3 -0
- package/dist/cjs/predictions/relayer.js +11 -0
- package/dist/cjs/predictions/types.d.ts +178 -0
- package/dist/cjs/predictions/types.js +2 -0
- package/dist/cjs/program.d.ts +2 -0
- package/dist/cjs/program.js +8 -7
- package/dist/cjs/prover.d.ts +27 -4
- package/dist/cjs/prover.js +107 -48
- package/dist/cjs/relayer/api.d.ts +41 -0
- package/dist/cjs/relayer/api.js +99 -0
- package/dist/cjs/relayer/client.d.ts +42 -17
- package/dist/cjs/relayer/client.js +94 -17
- package/dist/cjs/relayer/errors.d.ts +1 -1
- package/dist/cjs/relayer/errors.js +1 -1
- package/dist/cjs/relayer/index.d.ts +4 -1
- package/dist/cjs/relayer/index.js +1 -1
- package/dist/cjs/relayer/internal-config.d.ts +36 -0
- package/dist/cjs/relayer/internal-config.js +9 -0
- package/dist/cjs/relayer/internal.d.ts +6 -0
- package/dist/cjs/relayer/internal.js +14 -0
- package/dist/cjs/relayer/transport.d.ts +4 -2
- package/dist/cjs/relayer/transport.js +10 -5
- package/dist/cjs/relayer/types.d.ts +40 -10
- package/dist/cjs/relayer/types.js +1 -1
- package/dist/cjs/shield/owner.js +1 -4
- package/dist/esm/events/index.d.ts +6 -0
- package/dist/esm/events/index.js +6 -0
- package/dist/esm/events/parsing.d.ts +25 -0
- package/dist/esm/events/parsing.js +120 -0
- package/dist/esm/events/position.d.ts +26 -0
- package/dist/esm/events/position.js +48 -0
- package/dist/esm/events/recovery.d.ts +87 -0
- package/dist/esm/events/recovery.js +237 -0
- package/dist/esm/events/scanning.d.ts +35 -0
- package/dist/esm/events/scanning.js +92 -0
- package/dist/esm/events/tree.d.ts +27 -0
- package/dist/esm/events/tree.js +58 -0
- package/dist/esm/events/types.d.ts +39 -0
- package/dist/esm/events/types.js +1 -0
- package/dist/esm/events.d.ts +1 -77
- package/dist/esm/events.js +3 -129
- package/dist/esm/identity/encoding.d.ts +9 -0
- package/dist/esm/identity/encoding.js +75 -0
- package/dist/esm/identity/index.d.ts +4 -0
- package/dist/esm/identity/index.js +4 -0
- package/dist/esm/identity/noteKey.d.ts +33 -0
- package/dist/esm/identity/noteKey.js +91 -0
- package/dist/esm/identity/spending.d.ts +18 -0
- package/dist/esm/identity/spending.js +35 -0
- package/dist/esm/identity/viewKey.d.ts +38 -0
- package/dist/esm/identity/viewKey.js +96 -0
- package/dist/esm/idl/index.d.ts +18 -0
- package/dist/esm/idl/index.js +18 -0
- package/dist/esm/idl/privacy_pool.json +9907 -9907
- package/dist/esm/idl/privacy_pool_legacy.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy.js +3305 -0
- package/dist/esm/idl/privacy_pool_legacy.json +2302 -0
- package/dist/esm/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy2.js +3395 -0
- package/dist/esm/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/esm/index.d.ts +8 -3
- package/dist/esm/index.js +8 -3
- package/dist/esm/notes/amount.d.ts +2 -0
- package/dist/esm/notes/amount.js +18 -0
- package/dist/esm/notes/index.d.ts +4 -0
- package/dist/esm/notes/index.js +4 -0
- package/dist/esm/notes/recovery.d.ts +16 -6
- package/dist/esm/notes/recovery.js +33 -16
- package/dist/esm/notes/scan.d.ts +74 -0
- package/dist/esm/notes/scan.js +105 -0
- package/dist/esm/notes/selection.d.ts +133 -0
- package/dist/esm/notes/selection.js +254 -0
- package/dist/esm/notes/spent.d.ts +60 -0
- package/dist/esm/notes/spent.js +96 -0
- package/dist/esm/perps/constants.d.ts +16 -0
- package/dist/esm/perps/constants.js +48 -0
- package/dist/esm/perps/index.d.ts +5 -0
- package/dist/esm/perps/index.js +5 -0
- package/dist/esm/perps/keys.d.ts +16 -0
- package/dist/esm/perps/keys.js +35 -0
- package/dist/esm/perps/pdas.d.ts +29 -0
- package/dist/esm/perps/pdas.js +47 -0
- package/dist/esm/perps/relayer.d.ts +9 -0
- package/dist/esm/perps/relayer.js +25 -0
- package/dist/esm/perps/types.d.ts +126 -0
- package/dist/esm/perps/types.js +1 -0
- package/dist/esm/positions/index.d.ts +4 -0
- package/dist/esm/positions/index.js +4 -0
- package/dist/esm/positions/keys.d.ts +29 -0
- package/dist/esm/positions/keys.js +65 -0
- package/dist/esm/positions/pdas.d.ts +15 -0
- package/dist/esm/positions/pdas.js +44 -0
- package/dist/esm/positions/relayer.d.ts +4 -0
- package/dist/esm/positions/relayer.js +10 -0
- package/dist/esm/positions/types.d.ts +97 -0
- package/dist/esm/positions/types.js +1 -0
- package/dist/esm/predictions/client.d.ts +41 -0
- package/dist/esm/predictions/client.js +141 -0
- package/dist/esm/predictions/index.d.ts +5 -0
- package/dist/esm/predictions/index.js +5 -0
- package/dist/esm/predictions/keys.d.ts +14 -0
- package/dist/esm/predictions/keys.js +33 -0
- package/dist/esm/predictions/pdas.d.ts +6 -0
- package/dist/esm/predictions/pdas.js +10 -0
- package/dist/esm/predictions/relayer.d.ts +3 -0
- package/dist/esm/predictions/relayer.js +7 -0
- package/dist/esm/predictions/types.d.ts +178 -0
- package/dist/esm/predictions/types.js +1 -0
- package/dist/esm/program.d.ts +2 -0
- package/dist/esm/program.js +4 -3
- package/dist/esm/prover.d.ts +27 -4
- package/dist/esm/prover.js +106 -15
- package/dist/esm/relayer/api.d.ts +41 -0
- package/dist/esm/relayer/api.js +66 -0
- package/dist/esm/relayer/client.d.ts +42 -17
- package/dist/esm/relayer/client.js +94 -17
- package/dist/esm/relayer/errors.d.ts +1 -1
- package/dist/esm/relayer/errors.js +1 -1
- package/dist/esm/relayer/index.d.ts +4 -1
- package/dist/esm/relayer/index.js +1 -1
- package/dist/esm/relayer/internal-config.d.ts +36 -0
- package/dist/esm/relayer/internal-config.js +6 -0
- package/dist/esm/relayer/internal.d.ts +6 -0
- package/dist/esm/relayer/internal.js +10 -0
- package/dist/esm/relayer/transport.d.ts +4 -2
- package/dist/esm/relayer/transport.js +10 -5
- package/dist/esm/relayer/types.d.ts +40 -10
- package/dist/esm/relayer/types.js +1 -1
- package/dist/esm/shield/owner.js +1 -4
- package/identity.d.ts +2 -0
- package/identity.js +3 -0
- package/idl.d.ts +2 -0
- package/idl.js +3 -0
- package/notes.d.ts +2 -0
- package/notes.js +3 -0
- package/package.json +85 -3
- package/perps.d.ts +2 -0
- package/perps.js +3 -0
- package/poseidon.d.ts +2 -0
- package/poseidon.js +3 -0
- package/positions.d.ts +2 -0
- package/positions.js +3 -0
- package/predictions.d.ts +2 -0
- package/predictions.js +3 -0
- package/proof.d.ts +2 -0
- package/proof.js +3 -0
- package/prover.d.ts +2 -0
- package/prover.js +3 -0
- package/relayer.d.ts +2 -0
- package/relayer.js +3 -0
- package/shield.d.ts +2 -0
- package/shield.js +3 -0
- package/transactions.d.ts +2 -0
- package/transactions.js +3 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { assertBytes, utf8 } from "../identity/encoding.js";
|
|
3
|
+
export function derivePredictionSlotPda(params) {
|
|
4
|
+
assertBytes(params.withdrawalId, 32, "prediction withdrawal ID");
|
|
5
|
+
return PublicKey.findProgramAddressSync([
|
|
6
|
+
utf8("prediction_slot_v1"),
|
|
7
|
+
params.mint.toBytes(),
|
|
8
|
+
params.withdrawalId,
|
|
9
|
+
], params.programId)[0];
|
|
10
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PredictionOpenRequest, PredictionOpenResponse, PredictionReissueRequest, PredictionReissueResponse } from "./types.js";
|
|
2
|
+
export declare function submitPredictionOpen(data: PredictionOpenRequest): Promise<PredictionOpenResponse>;
|
|
3
|
+
export declare function submitPredictionReissue(data: PredictionReissueRequest): Promise<PredictionReissueResponse>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getInternalRelayerClient } from "../relayer/internal.js";
|
|
2
|
+
export function submitPredictionOpen(data) {
|
|
3
|
+
return getInternalRelayerClient().submitPredictionOpen(data);
|
|
4
|
+
}
|
|
5
|
+
export function submitPredictionReissue(data) {
|
|
6
|
+
return getInternalRelayerClient().submitPredictionReissue(data);
|
|
7
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { TransactNote } from "../relayer/types.js";
|
|
2
|
+
export interface PredictionOpenRequest {
|
|
3
|
+
notes: TransactNote[];
|
|
4
|
+
/** USDC stake, raw 6-decimal units. */
|
|
5
|
+
depositAmount: string;
|
|
6
|
+
/** 32-byte prediction-slot withdrawal ID, hex. */
|
|
7
|
+
withdrawalId: string;
|
|
8
|
+
/** Deterministic ephemeral wallet and open-proof claimant, base58. */
|
|
9
|
+
claimantPublicKey: string;
|
|
10
|
+
userPublicKey: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PredictionOpenResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
data?: {
|
|
16
|
+
txSignature: string;
|
|
17
|
+
ephemeralWallet: string;
|
|
18
|
+
ephemeralTokenAccount: string;
|
|
19
|
+
changeAmount: string;
|
|
20
|
+
fee: string;
|
|
21
|
+
feeBps: number;
|
|
22
|
+
totalDebited: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface PredictionReissueRequest {
|
|
26
|
+
withdrawalId: string;
|
|
27
|
+
claimantSecretKey: string;
|
|
28
|
+
/** Kept for API compatibility; the relayer reads the real chain balance. */
|
|
29
|
+
reissueAmount: string;
|
|
30
|
+
veiloPublicKey: string;
|
|
31
|
+
userPublicKey: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PredictionReissueResponse {
|
|
34
|
+
success: boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
data?: {
|
|
37
|
+
txSignature: string | null;
|
|
38
|
+
reissueAmount: string;
|
|
39
|
+
fee?: string;
|
|
40
|
+
tradeHappened?: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface PredictionMarketPricing {
|
|
44
|
+
buyYesPriceUsd: number;
|
|
45
|
+
sellYesPriceUsd: number;
|
|
46
|
+
buyNoPriceUsd: number;
|
|
47
|
+
sellNoPriceUsd: number;
|
|
48
|
+
volume: number;
|
|
49
|
+
}
|
|
50
|
+
export interface PredictionMarket {
|
|
51
|
+
provider: string;
|
|
52
|
+
marketId: string;
|
|
53
|
+
status: "open" | "closed" | "cancelled";
|
|
54
|
+
result: string | null;
|
|
55
|
+
title: string;
|
|
56
|
+
openTime: number;
|
|
57
|
+
closeTime: number;
|
|
58
|
+
rulesPrimary?: string;
|
|
59
|
+
imageUrl?: string;
|
|
60
|
+
clobTokenIds?: string[];
|
|
61
|
+
pricing: PredictionMarketPricing;
|
|
62
|
+
}
|
|
63
|
+
export interface PredictionEvent {
|
|
64
|
+
eventId: string;
|
|
65
|
+
isActive: boolean;
|
|
66
|
+
isLive: boolean;
|
|
67
|
+
category: string;
|
|
68
|
+
subcategory: string;
|
|
69
|
+
tags: string[];
|
|
70
|
+
metadata: {
|
|
71
|
+
title: string;
|
|
72
|
+
closeTime: string;
|
|
73
|
+
imageUrl?: string;
|
|
74
|
+
series?: string;
|
|
75
|
+
slug?: string;
|
|
76
|
+
};
|
|
77
|
+
volumeUsd: string;
|
|
78
|
+
volume24hr: string;
|
|
79
|
+
closeCondition?: string;
|
|
80
|
+
markets: PredictionMarket[];
|
|
81
|
+
}
|
|
82
|
+
export interface PredictionPosition {
|
|
83
|
+
pubkey: string;
|
|
84
|
+
owner: string;
|
|
85
|
+
marketId: string;
|
|
86
|
+
isYes: boolean;
|
|
87
|
+
contracts: string;
|
|
88
|
+
contractsDecimal: string;
|
|
89
|
+
totalCostUsd: string;
|
|
90
|
+
sizeUsd: string;
|
|
91
|
+
valueUsd: string;
|
|
92
|
+
avgPriceUsd: string;
|
|
93
|
+
markPriceUsd: string;
|
|
94
|
+
pnlUsd: string;
|
|
95
|
+
pnlUsdPercent: number;
|
|
96
|
+
feesPaidUsd: string;
|
|
97
|
+
claimed: boolean;
|
|
98
|
+
claimable: boolean;
|
|
99
|
+
payoutUsd: string;
|
|
100
|
+
sellPriceUsd: string;
|
|
101
|
+
settlementDate: number;
|
|
102
|
+
eventMetadata: {
|
|
103
|
+
title: string;
|
|
104
|
+
category: string;
|
|
105
|
+
imageUrl?: string;
|
|
106
|
+
};
|
|
107
|
+
marketMetadata: {
|
|
108
|
+
title: string;
|
|
109
|
+
result: string | null;
|
|
110
|
+
status: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export interface PlacePredictionOrderRequest {
|
|
114
|
+
ownerPubkey: string;
|
|
115
|
+
marketId: string;
|
|
116
|
+
isYes: boolean;
|
|
117
|
+
isBuy: true;
|
|
118
|
+
depositAmount: string;
|
|
119
|
+
depositMint: string;
|
|
120
|
+
}
|
|
121
|
+
export interface PredictionTransactionResponse {
|
|
122
|
+
transaction: string;
|
|
123
|
+
txMeta: {
|
|
124
|
+
blockhash: string;
|
|
125
|
+
lastValidBlockHeight: number;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export interface PlacePredictionOrderResponse extends PredictionTransactionResponse {
|
|
129
|
+
order: {
|
|
130
|
+
orderPubkey: string;
|
|
131
|
+
positionPubkey: string;
|
|
132
|
+
contracts: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export type PredictionOrderStatus = "pending" | "filled" | "partiallyfilled" | "failed";
|
|
136
|
+
export interface PredictionOrderStatusResponse {
|
|
137
|
+
orderPubkey: string;
|
|
138
|
+
status: PredictionOrderStatus;
|
|
139
|
+
latestEventType: string;
|
|
140
|
+
latestSignature: string;
|
|
141
|
+
history: Array<{
|
|
142
|
+
eventType: string;
|
|
143
|
+
status: string;
|
|
144
|
+
rawStatus: string;
|
|
145
|
+
timestamp: number;
|
|
146
|
+
signature: string;
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
export interface PredictionHistoryEvent {
|
|
150
|
+
id: number;
|
|
151
|
+
eventType: string;
|
|
152
|
+
signature: string;
|
|
153
|
+
timestamp: number;
|
|
154
|
+
marketId: string;
|
|
155
|
+
isYes: boolean;
|
|
156
|
+
isBuy: boolean;
|
|
157
|
+
contractsDecimal: string;
|
|
158
|
+
avgFillPriceUsd?: string;
|
|
159
|
+
totalCostUsd?: string;
|
|
160
|
+
netProceedsUsd?: string;
|
|
161
|
+
realizedPnl?: string;
|
|
162
|
+
payoutAmountUsd?: string;
|
|
163
|
+
eventMetadata: {
|
|
164
|
+
title: string;
|
|
165
|
+
category?: string;
|
|
166
|
+
imageUrl?: string;
|
|
167
|
+
};
|
|
168
|
+
marketMetadata: {
|
|
169
|
+
title: string;
|
|
170
|
+
result: string | null;
|
|
171
|
+
status: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export type PredictionPriceInterval = "1d" | "1w" | "1m" | "max";
|
|
175
|
+
export interface PredictionPricePoint {
|
|
176
|
+
t: number;
|
|
177
|
+
p: number;
|
|
178
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/program.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Program, Idl, Wallet } from "@coral-xyz/anchor";
|
|
2
2
|
import { Connection, PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY2_IDL, PRIVACY_POOL_LEGACY_IDL } from "./idl/index.js";
|
|
3
4
|
export declare const PRIVACY_POOL_IDL: Idl;
|
|
5
|
+
export { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY_IDL, PRIVACY_POOL_LEGACY2_IDL, };
|
|
4
6
|
/** Deployed program ID extracted from the bundled IDL. */
|
|
5
7
|
export declare const PRIVACY_POOL_PROGRAM_ID: PublicKey;
|
|
6
8
|
/**
|
package/dist/esm/program.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Program, AnchorProvider } from "@coral-xyz/anchor";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
|
-
import
|
|
3
|
+
import { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY2_IDL, PRIVACY_POOL_LEGACY_IDL, } from "./idl/index.js";
|
|
4
4
|
// Re-export so consumers can access the raw IDL if needed
|
|
5
|
-
export const PRIVACY_POOL_IDL =
|
|
5
|
+
export const PRIVACY_POOL_IDL = PRIVACY_POOL_CURRENT_IDL;
|
|
6
|
+
export { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY_IDL, PRIVACY_POOL_LEGACY2_IDL, };
|
|
6
7
|
/** Deployed program ID extracted from the bundled IDL. */
|
|
7
|
-
export const PRIVACY_POOL_PROGRAM_ID = new PublicKey(
|
|
8
|
+
export const PRIVACY_POOL_PROGRAM_ID = new PublicKey(PRIVACY_POOL_CURRENT_IDL.address);
|
|
8
9
|
/**
|
|
9
10
|
* Create an Anchor `Program` instance for the Veilo Privacy Pool.
|
|
10
11
|
*
|
package/dist/esm/prover.d.ts
CHANGED
|
@@ -3,8 +3,10 @@ import { type SwapProofBuilder } from "./proofs/swap.js";
|
|
|
3
3
|
/**
|
|
4
4
|
* Circuit artifact paths required by snarkjs.
|
|
5
5
|
*
|
|
6
|
-
* These files are large (10-100 MB) and
|
|
7
|
-
*
|
|
6
|
+
* These files are large (10-100 MB) and are NOT bundled in the npm package —
|
|
7
|
+
* `files` ships `dist/` only. Optional: omit them and the prover resolves a
|
|
8
|
+
* local copy (see `resolveCircuitArtifacts`). Supply them explicitly whenever
|
|
9
|
+
* the defaults cannot apply, which includes every browser build.
|
|
8
10
|
*
|
|
9
11
|
* For Node.js: pass file system paths (e.g. "./circuits/transaction.wasm").
|
|
10
12
|
* For browsers: pass Uint8Array buffers or URLs that fetch returns as ArrayBuffer.
|
|
@@ -15,6 +17,27 @@ export interface CircuitArtifacts {
|
|
|
15
17
|
/** Path or buffer for the Groth16 proving key (.zkey) */
|
|
16
18
|
zkeyPath: string | Uint8Array;
|
|
17
19
|
}
|
|
20
|
+
/** The circuits this package can resolve artifacts for. */
|
|
21
|
+
export type CircuitName = "transaction" | "swap";
|
|
22
|
+
/**
|
|
23
|
+
* Resolve circuit artifacts from disk when the caller did not supply them.
|
|
24
|
+
*
|
|
25
|
+
* Search order, first hit wins:
|
|
26
|
+
*
|
|
27
|
+
* 1. $VEILO_CIRCUITS_DIR explicit override
|
|
28
|
+
* 2. <package>/circuits populated by `npm run copy:circuits`
|
|
29
|
+
* 3. <cwd>/circuits
|
|
30
|
+
* 4. <cwd>/node_modules/@veilo/sdk-core/circuits
|
|
31
|
+
*
|
|
32
|
+
* NODE ONLY, AND DELIBERATELY LAZY. `node:fs` is imported inside the call, not
|
|
33
|
+
* at module scope: this module is reachable from the package root export, and a
|
|
34
|
+
* top-level `node:fs` import throws at bundle time in browser builds with no
|
|
35
|
+
* Node polyfill — the same reason `random.ts` avoids `node:crypto`. Browsers
|
|
36
|
+
* must pass `CircuitArtifacts` explicitly; there is nothing to resolve there.
|
|
37
|
+
*
|
|
38
|
+
* @throws when no candidate directory holds both files, listing what it tried
|
|
39
|
+
*/
|
|
40
|
+
export declare function resolveCircuitArtifacts(circuit: CircuitName): Promise<CircuitArtifacts>;
|
|
18
41
|
/**
|
|
19
42
|
* Create a proof builder function for the transaction circuit.
|
|
20
43
|
*
|
|
@@ -41,9 +64,9 @@ export interface CircuitArtifacts {
|
|
|
41
64
|
* const proof = await prover(circuitInputs);
|
|
42
65
|
* ```
|
|
43
66
|
*/
|
|
44
|
-
export declare function createTransactionProver(artifacts
|
|
67
|
+
export declare function createTransactionProver(artifacts?: CircuitArtifacts): TransactionProofBuilder;
|
|
45
68
|
/** Create a proof builder for the current `swap.circom` witness shape. */
|
|
46
|
-
export declare function createSwapProver(artifacts
|
|
69
|
+
export declare function createSwapProver(artifacts?: CircuitArtifacts): SwapProofBuilder;
|
|
47
70
|
/**
|
|
48
71
|
* Verify a Groth16 proof against public signals and a verification key.
|
|
49
72
|
*
|
package/dist/esm/prover.js
CHANGED
|
@@ -1,14 +1,91 @@
|
|
|
1
1
|
import { formatInputsForSnarkjs } from "./proofs/formatting.js";
|
|
2
2
|
import { formatSwapInputsForSnarkjs, } from "./proofs/swap.js";
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
/**
|
|
4
|
+
* Lazy-load snarkjs — works in both CJS and ESM contexts.
|
|
5
|
+
*
|
|
6
|
+
* The import is built through `Function` so TypeScript cannot rewrite it into a
|
|
7
|
+
* `require()` in the CommonJS build, and bundlers cannot follow it into browser
|
|
8
|
+
* output. Never call `require("snarkjs")` directly here: `require` is not
|
|
9
|
+
* defined in the ESM build, so it throws ReferenceError instead of this
|
|
10
|
+
* message.
|
|
11
|
+
*/
|
|
12
|
+
async function loadSnarkjs(purpose = "proof generation") {
|
|
5
13
|
try {
|
|
6
14
|
// Dynamic import works in both CJS (Node 12+) and ESM
|
|
7
15
|
return await Function('return import("snarkjs")')();
|
|
8
16
|
}
|
|
9
17
|
catch {
|
|
10
|
-
throw new Error(
|
|
18
|
+
throw new Error(`snarkjs is required for ${purpose}. Install it: npm install snarkjs`);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/** Layout produced by `npm run copy:circuits`, relative to a circuits root. */
|
|
22
|
+
const ARTIFACT_LAYOUT = {
|
|
23
|
+
transaction: {
|
|
24
|
+
wasm: "transaction/transaction_js/transaction.wasm",
|
|
25
|
+
zkey: "transaction/transaction_final.zkey",
|
|
26
|
+
},
|
|
27
|
+
swap: {
|
|
28
|
+
wasm: "swap/swap_js/swap.wasm",
|
|
29
|
+
zkey: "swap/swap_final.zkey",
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolve circuit artifacts from disk when the caller did not supply them.
|
|
34
|
+
*
|
|
35
|
+
* Search order, first hit wins:
|
|
36
|
+
*
|
|
37
|
+
* 1. $VEILO_CIRCUITS_DIR explicit override
|
|
38
|
+
* 2. <package>/circuits populated by `npm run copy:circuits`
|
|
39
|
+
* 3. <cwd>/circuits
|
|
40
|
+
* 4. <cwd>/node_modules/@veilo/sdk-core/circuits
|
|
41
|
+
*
|
|
42
|
+
* NODE ONLY, AND DELIBERATELY LAZY. `node:fs` is imported inside the call, not
|
|
43
|
+
* at module scope: this module is reachable from the package root export, and a
|
|
44
|
+
* top-level `node:fs` import throws at bundle time in browser builds with no
|
|
45
|
+
* Node polyfill — the same reason `random.ts` avoids `node:crypto`. Browsers
|
|
46
|
+
* must pass `CircuitArtifacts` explicitly; there is nothing to resolve there.
|
|
47
|
+
*
|
|
48
|
+
* @throws when no candidate directory holds both files, listing what it tried
|
|
49
|
+
*/
|
|
50
|
+
export async function resolveCircuitArtifacts(circuit) {
|
|
51
|
+
let fs;
|
|
52
|
+
let path;
|
|
53
|
+
try {
|
|
54
|
+
fs = await Function('return import("node:fs")')();
|
|
55
|
+
path = await Function('return import("node:path")')();
|
|
56
|
+
}
|
|
57
|
+
catch {
|
|
58
|
+
throw new Error(`Cannot resolve ${circuit} circuit artifacts: no filesystem available. ` +
|
|
59
|
+
"Pass CircuitArtifacts explicitly (browsers must supply buffers or URLs).");
|
|
60
|
+
}
|
|
61
|
+
const layout = ARTIFACT_LAYOUT[circuit];
|
|
62
|
+
if (!layout) {
|
|
63
|
+
throw new Error(`Unknown circuit ${JSON.stringify(circuit)}. Known circuits: ` +
|
|
64
|
+
`${Object.keys(ARTIFACT_LAYOUT).join(", ")}.`);
|
|
11
65
|
}
|
|
66
|
+
const cwd = typeof process !== "undefined" ? process.cwd() : ".";
|
|
67
|
+
// __dirname exists in the CJS build; the ESM build falls back to cwd-relative
|
|
68
|
+
// candidates. dist/cjs/prover.js → ../../circuits is the package root copy.
|
|
69
|
+
const packageDir = typeof __dirname !== "undefined"
|
|
70
|
+
? path.resolve(__dirname, "..", "..", "circuits")
|
|
71
|
+
: undefined;
|
|
72
|
+
const roots = [
|
|
73
|
+
process.env?.VEILO_CIRCUITS_DIR,
|
|
74
|
+
packageDir,
|
|
75
|
+
path.resolve(cwd, "circuits"),
|
|
76
|
+
path.resolve(cwd, "node_modules", "@veilo", "sdk-core", "circuits"),
|
|
77
|
+
].filter((root) => Boolean(root));
|
|
78
|
+
for (const root of roots) {
|
|
79
|
+
const wasmPath = path.resolve(root, layout.wasm);
|
|
80
|
+
const zkeyPath = path.resolve(root, layout.zkey);
|
|
81
|
+
if (fs.existsSync(wasmPath) && fs.existsSync(zkeyPath)) {
|
|
82
|
+
return { wasmPath, zkeyPath };
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
throw new Error(`Cannot resolve ${circuit} circuit artifacts. Looked for ${layout.wasm} ` +
|
|
86
|
+
`and ${layout.zkey} under:\n ${roots.join("\n ")}\n` +
|
|
87
|
+
"Run `npm run copy:circuits` in the SDK, set VEILO_CIRCUITS_DIR, or pass " +
|
|
88
|
+
"CircuitArtifacts explicitly.");
|
|
12
89
|
}
|
|
13
90
|
/**
|
|
14
91
|
* Create a proof builder function for the transaction circuit.
|
|
@@ -37,18 +114,30 @@ async function loadSnarkjs() {
|
|
|
37
114
|
* ```
|
|
38
115
|
*/
|
|
39
116
|
export function createTransactionProver(artifacts) {
|
|
117
|
+
// Resolved on first use, not at factory time: constructing a prover must stay
|
|
118
|
+
// free of filesystem access so browser bundles can import this module.
|
|
119
|
+
let resolved;
|
|
40
120
|
return async (inputs) => {
|
|
41
121
|
const snarkjs = await loadSnarkjs();
|
|
122
|
+
resolved ?? (resolved = artifacts
|
|
123
|
+
? Promise.resolve(artifacts)
|
|
124
|
+
: resolveCircuitArtifacts("transaction"));
|
|
125
|
+
const { wasmPath, zkeyPath } = await resolved;
|
|
42
126
|
const formattedInputs = formatInputsForSnarkjs(inputs);
|
|
43
|
-
const { proof } = await snarkjs.groth16.fullProve(formattedInputs,
|
|
127
|
+
const { proof } = await snarkjs.groth16.fullProve(formattedInputs, wasmPath, zkeyPath);
|
|
44
128
|
return proof;
|
|
45
129
|
};
|
|
46
130
|
}
|
|
47
131
|
/** Create a proof builder for the current `swap.circom` witness shape. */
|
|
48
132
|
export function createSwapProver(artifacts) {
|
|
133
|
+
let resolved;
|
|
49
134
|
return async (inputs) => {
|
|
50
135
|
const snarkjs = await loadSnarkjs();
|
|
51
|
-
|
|
136
|
+
resolved ?? (resolved = artifacts
|
|
137
|
+
? Promise.resolve(artifacts)
|
|
138
|
+
: resolveCircuitArtifacts("swap"));
|
|
139
|
+
const { wasmPath, zkeyPath } = await resolved;
|
|
140
|
+
const { proof } = await snarkjs.groth16.fullProve(formatSwapInputsForSnarkjs(inputs), wasmPath, zkeyPath);
|
|
52
141
|
return proof;
|
|
53
142
|
};
|
|
54
143
|
}
|
|
@@ -63,18 +152,20 @@ export function createSwapProver(artifacts) {
|
|
|
63
152
|
* @returns true if the proof is valid
|
|
64
153
|
*/
|
|
65
154
|
export async function verifyProof(proof, publicSignals, vkey) {
|
|
66
|
-
|
|
67
|
-
let snarkjs;
|
|
68
|
-
try {
|
|
69
|
-
snarkjs = require("snarkjs");
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
throw new Error('snarkjs is required for proof verification. Install it: npm install snarkjs');
|
|
73
|
-
}
|
|
155
|
+
const snarkjs = await loadSnarkjs("proof verification");
|
|
74
156
|
let vkeyObj;
|
|
75
157
|
if (typeof vkey === "string") {
|
|
76
|
-
// Node.js file path — read and parse
|
|
77
|
-
|
|
158
|
+
// Node.js file path — read and parse. Same hidden import as
|
|
159
|
+
// resolveCircuitArtifacts: a plain `await import("fs")` is followed by
|
|
160
|
+
// bundlers and breaks browser builds that have no Node polyfill.
|
|
161
|
+
let fs;
|
|
162
|
+
try {
|
|
163
|
+
fs = await Function('return import("node:fs")')();
|
|
164
|
+
}
|
|
165
|
+
catch {
|
|
166
|
+
throw new Error("Reading a verification key from a path requires Node. Pass the parsed " +
|
|
167
|
+
"verification key object instead.");
|
|
168
|
+
}
|
|
78
169
|
vkeyObj = JSON.parse(fs.readFileSync(vkey, "utf-8"));
|
|
79
170
|
}
|
|
80
171
|
else {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CheckNullifiersResponse, CompactScanResponse, FetchByCommitmentRequest, FetchByCommitmentResponse, ChallengeResponse, CheckUsernameResponse, DeleteUserDataResponse, MerkleRootResponse, MerkleTreeResponse, PreRegisterKeyResponse, PrivateSwapRequest, PrivateSwapResponse, PrivateTransferRequest, PrivateTransferResponse, QueryNotesRequest, QueryNotesResponse, RegisterRequest, RegisterResponse, RestoreRequest, RestoreResponse, SaveEncryptedNoteRequest, SaveEncryptedNoteResponse, VeiloPublicKeyResponse, WithdrawRequest, WithdrawResponse } from "./types.js";
|
|
2
|
+
/** Request a wallet-authentication challenge from Veilo. */
|
|
3
|
+
export declare function getChallenge(walletPublicKey: string): Promise<ChallengeResponse>;
|
|
4
|
+
/** Register a Veilo account and receive its auth token. */
|
|
5
|
+
export declare function register(data: RegisterRequest): Promise<RegisterResponse>;
|
|
6
|
+
/** Restore a Veilo account and receive its auth token. */
|
|
7
|
+
export declare function restore(data: RestoreRequest): Promise<RestoreResponse>;
|
|
8
|
+
export declare function checkUsername(username: string): Promise<CheckUsernameResponse>;
|
|
9
|
+
export declare function getVeiloPublicKey(params: {
|
|
10
|
+
username: string;
|
|
11
|
+
publicKey?: never;
|
|
12
|
+
} | {
|
|
13
|
+
publicKey: string;
|
|
14
|
+
username?: never;
|
|
15
|
+
}): Promise<VeiloPublicKeyResponse>;
|
|
16
|
+
export declare function preRegisterKey(solanaAddress: string): Promise<PreRegisterKeyResponse>;
|
|
17
|
+
export declare function saveEncryptedNote(data: SaveEncryptedNoteRequest): Promise<SaveEncryptedNoteResponse>;
|
|
18
|
+
/** Query notes with an explicit per-call token; no auth state is shared. */
|
|
19
|
+
export declare function queryEncryptedNotes(authToken: string, params?: QueryNotesRequest): Promise<QueryNotesResponse>;
|
|
20
|
+
/** Delete the authenticated user's stored data without retaining their token. */
|
|
21
|
+
export declare function deleteUserData(authToken: string): Promise<DeleteUserDataResponse>;
|
|
22
|
+
/** One page of the public compact-note feed. Prefer `scanCompactNotes`. */
|
|
23
|
+
export declare function compactScan(params?: {
|
|
24
|
+
limit?: number;
|
|
25
|
+
cursor?: string;
|
|
26
|
+
}): Promise<CompactScanResponse>;
|
|
27
|
+
/**
|
|
28
|
+
* One fetch-by-commitment request, capped at 50 commitments by the server.
|
|
29
|
+
* Prefer `fetchNotesByCommitment` from the notes module, which chunks for you.
|
|
30
|
+
*/
|
|
31
|
+
export declare function fetchNotesByCommitmentPage(data: FetchByCommitmentRequest): Promise<FetchByCommitmentResponse>;
|
|
32
|
+
/** Raw check-batch call. Prefer `checkNullifiersSpent`, which chunks for you. */
|
|
33
|
+
export declare function checkNullifiers(nullifiers: string[]): Promise<CheckNullifiersResponse>;
|
|
34
|
+
export declare function getMerkleRoot(mintAddress?: string, treeId?: number): Promise<MerkleRootResponse>;
|
|
35
|
+
export declare function getMerkleTree(mintAddress?: string, treeId?: number): Promise<MerkleTreeResponse>;
|
|
36
|
+
export declare function submitWithdraw(data: WithdrawRequest): Promise<WithdrawResponse>;
|
|
37
|
+
export declare function submitPrivateTransfer(data: PrivateTransferRequest): Promise<PrivateTransferResponse>;
|
|
38
|
+
export declare function submitPrivateSwap(data: PrivateSwapRequest): Promise<PrivateSwapResponse>;
|
|
39
|
+
export { submitClosePosition, submitMergePositions, submitOpenPosition, } from "../positions/relayer.js";
|
|
40
|
+
export { submitJperpCancelTrigger, submitJperpClose, submitJperpOpen, submitJperpRecoverNative, submitJperpRecoverSeed, submitJperpReissue, submitJperpSetTpsl, submitJperpUpdateTpsl, } from "../perps/relayer.js";
|
|
41
|
+
export { submitPredictionOpen, submitPredictionReissue, } from "../predictions/relayer.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { createInternalRelayerClient, getInternalRelayerClient, } from "./internal.js";
|
|
2
|
+
/** Request a wallet-authentication challenge from Veilo. */
|
|
3
|
+
export function getChallenge(walletPublicKey) {
|
|
4
|
+
return getInternalRelayerClient().getChallenge(walletPublicKey);
|
|
5
|
+
}
|
|
6
|
+
/** Register a Veilo account and receive its auth token. */
|
|
7
|
+
export function register(data) {
|
|
8
|
+
return getInternalRelayerClient().register(data);
|
|
9
|
+
}
|
|
10
|
+
/** Restore a Veilo account and receive its auth token. */
|
|
11
|
+
export function restore(data) {
|
|
12
|
+
return getInternalRelayerClient().restore(data);
|
|
13
|
+
}
|
|
14
|
+
export function checkUsername(username) {
|
|
15
|
+
return getInternalRelayerClient().checkUsername(username);
|
|
16
|
+
}
|
|
17
|
+
export function getVeiloPublicKey(params) {
|
|
18
|
+
return getInternalRelayerClient().getVeiloPublicKey(params);
|
|
19
|
+
}
|
|
20
|
+
export function preRegisterKey(solanaAddress) {
|
|
21
|
+
return getInternalRelayerClient().preRegisterKey(solanaAddress);
|
|
22
|
+
}
|
|
23
|
+
export function saveEncryptedNote(data) {
|
|
24
|
+
return getInternalRelayerClient().saveEncryptedNote(data);
|
|
25
|
+
}
|
|
26
|
+
/** Query notes with an explicit per-call token; no auth state is shared. */
|
|
27
|
+
export function queryEncryptedNotes(authToken, params = {}) {
|
|
28
|
+
return createInternalRelayerClient({ authToken }).queryEncryptedNotes(params);
|
|
29
|
+
}
|
|
30
|
+
/** Delete the authenticated user's stored data without retaining their token. */
|
|
31
|
+
export function deleteUserData(authToken) {
|
|
32
|
+
return createInternalRelayerClient({ authToken }).deleteUserData();
|
|
33
|
+
}
|
|
34
|
+
/** One page of the public compact-note feed. Prefer `scanCompactNotes`. */
|
|
35
|
+
export function compactScan(params = {}) {
|
|
36
|
+
return getInternalRelayerClient().compactScan(params);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* One fetch-by-commitment request, capped at 50 commitments by the server.
|
|
40
|
+
* Prefer `fetchNotesByCommitment` from the notes module, which chunks for you.
|
|
41
|
+
*/
|
|
42
|
+
export function fetchNotesByCommitmentPage(data) {
|
|
43
|
+
return getInternalRelayerClient().fetchNotesByCommitment(data);
|
|
44
|
+
}
|
|
45
|
+
/** Raw check-batch call. Prefer `checkNullifiersSpent`, which chunks for you. */
|
|
46
|
+
export function checkNullifiers(nullifiers) {
|
|
47
|
+
return getInternalRelayerClient().checkNullifiers(nullifiers);
|
|
48
|
+
}
|
|
49
|
+
export function getMerkleRoot(mintAddress, treeId) {
|
|
50
|
+
return getInternalRelayerClient().getMerkleRoot(mintAddress, treeId);
|
|
51
|
+
}
|
|
52
|
+
export function getMerkleTree(mintAddress, treeId) {
|
|
53
|
+
return getInternalRelayerClient().getMerkleTree(mintAddress, treeId);
|
|
54
|
+
}
|
|
55
|
+
export function submitWithdraw(data) {
|
|
56
|
+
return getInternalRelayerClient().submitWithdraw(data);
|
|
57
|
+
}
|
|
58
|
+
export function submitPrivateTransfer(data) {
|
|
59
|
+
return getInternalRelayerClient().submitPrivateTransfer(data);
|
|
60
|
+
}
|
|
61
|
+
export function submitPrivateSwap(data) {
|
|
62
|
+
return getInternalRelayerClient().submitPrivateSwap(data);
|
|
63
|
+
}
|
|
64
|
+
export { submitClosePosition, submitMergePositions, submitOpenPosition, } from "../positions/relayer.js";
|
|
65
|
+
export { submitJperpCancelTrigger, submitJperpClose, submitJperpOpen, submitJperpRecoverNative, submitJperpRecoverSeed, submitJperpReissue, submitJperpSetTpsl, submitJperpUpdateTpsl, } from "../perps/relayer.js";
|
|
66
|
+
export { submitPredictionOpen, submitPredictionReissue, } from "../predictions/relayer.js";
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import type { ChallengeResponse, CheckUsernameResponse, DeleteUserDataResponse, MerkleRootResponse, MerkleTreeResponse, PreRegisterKeyResponse, PrivateSwapRequest, PrivateSwapResponse, PrivateTransferRequest, PrivateTransferResponse, QueryNotesRequest, QueryNotesResponse, RegisterRequest, RegisterResponse, RestoreRequest, RestoreResponse, RetryPolicy, SaveEncryptedNoteRequest, SaveEncryptedNoteResponse, VeiloPublicKeyResponse,
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* const client = new VeiloRelayerClient({
|
|
11
|
-
* apiKey: "your-api-key",
|
|
12
|
-
* relayerPublicKey: "<base64 NaCl public key>",
|
|
13
|
-
* });
|
|
14
|
-
* const root = await client.getMerkleRoot("So111...");
|
|
15
|
-
* ```
|
|
16
|
-
*/
|
|
1
|
+
import type { CheckNullifiersResponse, CompactScanResponse, FetchByCommitmentRequest, FetchByCommitmentResponse, ChallengeResponse, CheckUsernameResponse, DeleteUserDataResponse, MerkleRootResponse, MerkleTreeResponse, PreRegisterKeyResponse, PrivateSwapRequest, PrivateSwapResponse, PrivateTransferRequest, PrivateTransferResponse, QueryNotesRequest, QueryNotesResponse, RegisterRequest, RegisterResponse, RestoreRequest, RestoreResponse, RetryPolicy, SaveEncryptedNoteRequest, SaveEncryptedNoteResponse, VeiloPublicKeyResponse, WithdrawRequest, WithdrawResponse } from "./types.js";
|
|
2
|
+
import { type InternalRelayerClientOptions } from "./internal-config.js";
|
|
3
|
+
import type { ClosePositionRequest, ClosePositionResponse, MergePositionsRequest, MergePositionsResponse, OpenPositionRequest, OpenPositionResponse } from "../positions/types.js";
|
|
4
|
+
import type { JperpCancelTriggerRequest, JperpCancelTriggerResponse, JperpCloseRequest, JperpDecreaseResponse, JperpOpenRequest, JperpOpenResponse, JperpRecoverNativeRequest, JperpRecoverNativeResponse, JperpRecoverSeedRequest, JperpRecoverSeedResponse, JperpReissueRequest, JperpReissueResponse, JperpSetTpslRequest, JperpUpdateTpslRequest } from "../perps/types.js";
|
|
5
|
+
import type { PredictionOpenRequest, PredictionOpenResponse, PredictionReissueRequest, PredictionReissueResponse } from "../predictions/types.js";
|
|
6
|
+
/** @internal Relayer transport behind the SDK's functional helpers. */
|
|
17
7
|
export declare class VeiloRelayerClient {
|
|
18
8
|
private readonly transport;
|
|
19
9
|
private readonly relayerPubKey;
|
|
20
|
-
constructor(config
|
|
10
|
+
constructor(config?: InternalRelayerClientOptions, retry?: Partial<RetryPolicy>);
|
|
21
11
|
/** Update the auth token (e.g. after register/restore). */
|
|
22
12
|
setAuthToken(token: string): void;
|
|
23
13
|
private encryptPayload;
|
|
@@ -47,6 +37,27 @@ export declare class VeiloRelayerClient {
|
|
|
47
37
|
/** Query encrypted notes for the authenticated user. Requires auth token. */
|
|
48
38
|
queryEncryptedNotes(params?: QueryNotesRequest): Promise<QueryNotesResponse>;
|
|
49
39
|
/** Delete all stored data for the authenticated user. Requires auth token. */
|
|
40
|
+
/**
|
|
41
|
+
* One page of the public compact-note feed.
|
|
42
|
+
*
|
|
43
|
+
* Unauthenticated by design: rows carry only ciphertext and a one-byte view
|
|
44
|
+
* tag, so scanning reveals nothing without the recipient's key. The feed
|
|
45
|
+
* excludes spent notes and any note already claimed by a wallet.
|
|
46
|
+
*/
|
|
47
|
+
compactScan(params?: {
|
|
48
|
+
limit?: number;
|
|
49
|
+
cursor?: string;
|
|
50
|
+
}): Promise<CompactScanResponse>;
|
|
51
|
+
/** Look up stored notes by commitment. Max 50 per request. */
|
|
52
|
+
fetchNotesByCommitment(data: FetchByCommitmentRequest): Promise<FetchByCommitmentResponse>;
|
|
53
|
+
/**
|
|
54
|
+
* Ask which of these nullifiers the relayer has seen spent.
|
|
55
|
+
*
|
|
56
|
+
* Caller must respect MAX_NULLIFIERS_PER_CHECK; `checkNullifiersSpent` in
|
|
57
|
+
* notes/spent.ts does the chunking. Unauthenticated: a nullifier reveals
|
|
58
|
+
* nothing about ownership on its own.
|
|
59
|
+
*/
|
|
60
|
+
checkNullifiers(nullifiers: string[]): Promise<CheckNullifiersResponse>;
|
|
50
61
|
deleteUserData(): Promise<DeleteUserDataResponse>;
|
|
51
62
|
/** Fetch the current Merkle root for a pool, optionally filtered by mint and tree ID. */
|
|
52
63
|
getMerkleRoot(mintAddress?: string, treeId?: number): Promise<MerkleRootResponse>;
|
|
@@ -58,4 +69,18 @@ export declare class VeiloRelayerClient {
|
|
|
58
69
|
submitPrivateTransfer(data: PrivateTransferRequest): Promise<PrivateTransferResponse>;
|
|
59
70
|
/** Submit an encrypted private swap request. Not retried on failure. */
|
|
60
71
|
submitPrivateSwap(data: PrivateSwapRequest): Promise<PrivateSwapResponse>;
|
|
72
|
+
submitOpenPosition(data: OpenPositionRequest): Promise<OpenPositionResponse>;
|
|
73
|
+
submitClosePosition(data: ClosePositionRequest): Promise<ClosePositionResponse>;
|
|
74
|
+
submitMergePositions(data: MergePositionsRequest): Promise<MergePositionsResponse>;
|
|
75
|
+
submitJperpOpen(data: JperpOpenRequest): Promise<JperpOpenResponse>;
|
|
76
|
+
submitJperpClose(data: JperpCloseRequest): Promise<JperpDecreaseResponse>;
|
|
77
|
+
submitJperpSetTpsl(data: JperpSetTpslRequest): Promise<JperpDecreaseResponse>;
|
|
78
|
+
submitJperpUpdateTpsl(data: JperpUpdateTpslRequest): Promise<JperpDecreaseResponse>;
|
|
79
|
+
submitJperpCancelTrigger(data: JperpCancelTriggerRequest): Promise<JperpCancelTriggerResponse>;
|
|
80
|
+
submitJperpReissue(data: JperpReissueRequest): Promise<JperpReissueResponse>;
|
|
81
|
+
submitJperpRecoverSeed(data: JperpRecoverSeedRequest): Promise<JperpRecoverSeedResponse>;
|
|
82
|
+
submitJperpRecoverNative(data: JperpRecoverNativeRequest): Promise<JperpRecoverNativeResponse>;
|
|
83
|
+
submitPredictionOpen(data: PredictionOpenRequest): Promise<PredictionOpenResponse>;
|
|
84
|
+
submitPredictionReissue(data: PredictionReissueRequest): Promise<PredictionReissueResponse>;
|
|
85
|
+
private submitEncrypted;
|
|
61
86
|
}
|