@invisi-labs/sdk 1.1.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.
@@ -0,0 +1,239 @@
1
+ import { Note, CreditDeliveryState, ViewingCapability, Wallet, WalletAuthorizationProvider, ReceivingKeyLookup, Hex as Hex$1 } from '@invisi-labs/core';
2
+ import { S as StoredNote, W as WalletScope, b as WalletStore } from './state-DHl6j33x.cjs';
3
+ import { TransactionContext, CanonicalBlock, NoteMembership, FundingInput, TransactRequestParams, CreditMembership, Protocol, ChainReader, ProtocolDataProvider, TokenProtocol } from '@invisi-labs/protocol';
4
+ import * as _invisi_labs_prover from '@invisi-labs/prover';
5
+ import { Prover, ProofTarget, AggregateMember } from '@invisi-labs/prover';
6
+ import { Signer } from 'ethers';
7
+ import { Address, Hex, Delivery, ShieldParams, ShieldOutput, CreateCreditParams, CreditDrawParams, CancelCreditParams, TopUpCreditParams, TransactRequest } from '@invisi-labs/protocol/contracts';
8
+
9
+ interface CoinSelector {
10
+ select(candidates: readonly StoredNote[], requiredAmount: bigint): readonly Hex[] | Promise<readonly Hex[]>;
11
+ }
12
+ interface FundingTypedData {
13
+ domain: Record<string, unknown>;
14
+ primaryType: string;
15
+ types: Record<string, readonly {
16
+ name: string;
17
+ type: string;
18
+ }[]>;
19
+ message: Record<string, unknown>;
20
+ }
21
+ interface FundingSigner {
22
+ readonly address: Address;
23
+ signTypedData(data: FundingTypedData): Promise<Hex>;
24
+ }
25
+ interface FundingAuthorizationVerifier {
26
+ verifyTypedData(data: FundingTypedData & {
27
+ address: Address;
28
+ signature: Hex;
29
+ }): Promise<boolean>;
30
+ }
31
+ interface FundingSource {
32
+ payer: Address;
33
+ amount: bigint;
34
+ authorization?: "signature" | "caller";
35
+ sigNonce?: bigint;
36
+ deadline?: bigint;
37
+ permit?: NonNullable<FundingInput["permit"]>;
38
+ }
39
+ interface PaymentOutput {
40
+ to: string;
41
+ amount: bigint;
42
+ }
43
+ interface TransferPreparation {
44
+ tokenAddress: Address;
45
+ outputs: readonly PaymentOutput[];
46
+ funding?: FundingSource;
47
+ deadline?: bigint;
48
+ target?: ProofTarget;
49
+ }
50
+ interface WithdrawalPreparation {
51
+ tokenAddress: Address;
52
+ to: Address;
53
+ amount: bigint;
54
+ deadline?: bigint;
55
+ target?: ProofTarget;
56
+ }
57
+ interface SweepPreparation {
58
+ tokenAddress: Address;
59
+ commitments?: readonly Hex[];
60
+ deadline?: bigint;
61
+ target?: ProofTarget;
62
+ }
63
+ interface ShieldPreparation {
64
+ tokenAddress: Address;
65
+ outputs: readonly PaymentOutput[];
66
+ funding: FundingSource;
67
+ deadline?: bigint;
68
+ }
69
+ interface PreparedOutput {
70
+ note: Note;
71
+ commitment: Hex;
72
+ identity: Hex;
73
+ delivery: Delivery;
74
+ address: string;
75
+ change: boolean;
76
+ }
77
+ interface CreateCreditPreparation {
78
+ tokenAddress: Address;
79
+ spender: string;
80
+ amount: bigint;
81
+ expiry: bigint;
82
+ funding?: FundingSource;
83
+ deadline?: bigint;
84
+ }
85
+ interface DrawCreditPreparation {
86
+ tokenAddress: Address;
87
+ credits: readonly {
88
+ credit: Hex;
89
+ amount: bigint;
90
+ }[];
91
+ deadline?: bigint;
92
+ }
93
+ interface TopUpCreditPreparation {
94
+ tokenAddress: Address;
95
+ credit: Hex;
96
+ additionalAmount: bigint;
97
+ expiry?: bigint;
98
+ funding?: FundingSource;
99
+ deadline?: bigint;
100
+ }
101
+ interface CancelCreditPreparation {
102
+ tokenAddress: Address;
103
+ credit: Hex;
104
+ deadline?: bigint;
105
+ }
106
+ interface PreparedCreditOutput {
107
+ state: CreditDeliveryState;
108
+ commitment: Hex;
109
+ deliveries: [Delivery, Delivery];
110
+ }
111
+ interface PreparedCreditInput extends CreditMembership {
112
+ commitment: Hex;
113
+ role: "owner" | "spender";
114
+ }
115
+ interface CreditPlan {
116
+ inputs: PreparedCreditInput[];
117
+ outputs: PreparedCreditOutput[];
118
+ deliveries: Delivery[];
119
+ creation?: CreateCreditParams;
120
+ draw?: CreditDrawParams;
121
+ cancel?: CancelCreditParams;
122
+ topUp?: TopUpCreditParams;
123
+ amounts?: bigint[];
124
+ }
125
+ interface OperationPlan {
126
+ version: 1;
127
+ id: string;
128
+ kind: "transfer" | "withdraw" | "sweep" | "shield" | "create-credit" | "draw-credit" | "top-up-credit" | "cancel-credit";
129
+ context: TransactionContext;
130
+ scope: WalletScope;
131
+ preparedAt: CanonicalBlock;
132
+ deadline: bigint;
133
+ outputs: PreparedOutput[];
134
+ inputs: Array<NoteMembership & {
135
+ commitment: Hex;
136
+ }>;
137
+ funding: FundingInput;
138
+ fundingMode: "none" | "signature" | "caller";
139
+ params?: TransactRequestParams;
140
+ shieldParams?: ShieldParams;
141
+ shieldOutputs?: ShieldOutput[];
142
+ capacity?: number;
143
+ credit?: CreditPlan;
144
+ statement?: _invisi_labs_prover.ProofStatement;
145
+ }
146
+ interface WalletSessionOptions {
147
+ gasBenchmarks?: readonly GasBenchmarkProfile[];
148
+ /** Optional ethers gas/funding signer; distinct from the Invisi wallet authority. */
149
+ signer?: Signer;
150
+ viewing?: Pick<ViewingCapability, "walletIdentity" | "decryptNote" | "decryptCredit">;
151
+ wallet: Wallet;
152
+ protocol: Protocol;
153
+ namespace?: string;
154
+ store?: WalletStore;
155
+ chainReader?: ChainReader;
156
+ protocolRpc?: ProtocolDataProvider;
157
+ authorization?: WalletAuthorizationProvider;
158
+ prover?: Prover;
159
+ fundingSigner?: FundingSigner;
160
+ fundingVerifier?: FundingAuthorizationVerifier;
161
+ addressResolver?: ReceivingKeyLookup;
162
+ coinSelector?: CoinSelector;
163
+ transactionTTL?: bigint;
164
+ }
165
+ interface OperationRuntime {
166
+ options: Omit<WalletSessionOptions, "protocol"> & {
167
+ protocol: TokenProtocol;
168
+ };
169
+ scope: WalletScope;
170
+ store: WalletStore;
171
+ reader: ChainReader;
172
+ authorization: () => WalletAuthorizationProvider;
173
+ }
174
+ interface OperationAggregateMember extends AggregateMember {
175
+ context: TransactionContext;
176
+ request: TransactRequest;
177
+ }
178
+
179
+ interface GasBenchmarkShape {
180
+ kind: OperationPlan["kind"];
181
+ target: string;
182
+ capacity: number;
183
+ noteInputs: number;
184
+ noteOutputs: number;
185
+ sourceTrees: number;
186
+ creditInputs: number;
187
+ creditOutputs: number;
188
+ creditRemainders: number;
189
+ funding: "none" | "caller" | "signature";
190
+ permit: boolean;
191
+ deliveryBytes: number;
192
+ }
193
+ interface GasBenchmarkDeployment {
194
+ chainId: string;
195
+ protocolAddress: Hex$1;
196
+ runtimeCodeHash: Hex$1 | null;
197
+ tokenAddress: Hex$1;
198
+ }
199
+ interface GasBenchmarkCircuit {
200
+ circuitName: string;
201
+ target: string;
202
+ artifactSha256: string;
203
+ vkSha256: string;
204
+ }
205
+ interface GasBenchmarkSample {
206
+ gasUsed: string;
207
+ transactionHash: Hex$1;
208
+ blockNumber: string;
209
+ blockHash: Hex$1;
210
+ calldataBytes: number;
211
+ }
212
+ interface GasBenchmarkProfile {
213
+ formatVersion: 1;
214
+ id: string;
215
+ deployment: GasBenchmarkDeployment;
216
+ source: {
217
+ protocolCommit: string;
218
+ measuredAt: string;
219
+ chain: string;
220
+ hardfork: string;
221
+ token: string;
222
+ verifier: "real";
223
+ assumptions: string[];
224
+ };
225
+ measurements: Array<{
226
+ id: string;
227
+ shape: GasBenchmarkShape;
228
+ circuit: GasBenchmarkCircuit | null;
229
+ samples: GasBenchmarkSample[];
230
+ }>;
231
+ }
232
+ /** Parse a trusted, JSON-compatible benchmark catalog. No network access or publisher authentication. */
233
+ declare function defineGasBenchmarks(input: unknown): GasBenchmarkProfile[];
234
+ /** Pre-proof reference only; ethers must estimate the final transaction independently. */
235
+ interface GasReference {
236
+ gasUnits: bigint;
237
+ }
238
+
239
+ export { type CancelCreditPreparation as C, type DrawCreditPreparation as D, type FundingSigner as F, type GasReference as G, type OperationRuntime as O, type ShieldPreparation as S, type TopUpCreditPreparation as T, type WithdrawalPreparation as W, type OperationPlan as a, type OperationAggregateMember as b, type CreateCreditPreparation as c, type SweepPreparation as d, type TransferPreparation as e, type WalletSessionOptions as f, type CoinSelector as g, type FundingAuthorizationVerifier as h, type FundingSource as i, type FundingTypedData as j, type GasBenchmarkCircuit as k, type GasBenchmarkDeployment as l, type GasBenchmarkProfile as m, type GasBenchmarkSample as n, type GasBenchmarkShape as o, defineGasBenchmarks as p };
@@ -0,0 +1,239 @@
1
+ import { Note, CreditDeliveryState, ViewingCapability, Wallet, WalletAuthorizationProvider, ReceivingKeyLookup, Hex as Hex$1 } from '@invisi-labs/core';
2
+ import { S as StoredNote, W as WalletScope, b as WalletStore } from './state-DHl6j33x.js';
3
+ import { TransactionContext, CanonicalBlock, NoteMembership, FundingInput, TransactRequestParams, CreditMembership, Protocol, ChainReader, ProtocolDataProvider, TokenProtocol } from '@invisi-labs/protocol';
4
+ import * as _invisi_labs_prover from '@invisi-labs/prover';
5
+ import { Prover, ProofTarget, AggregateMember } from '@invisi-labs/prover';
6
+ import { Signer } from 'ethers';
7
+ import { Address, Hex, Delivery, ShieldParams, ShieldOutput, CreateCreditParams, CreditDrawParams, CancelCreditParams, TopUpCreditParams, TransactRequest } from '@invisi-labs/protocol/contracts';
8
+
9
+ interface CoinSelector {
10
+ select(candidates: readonly StoredNote[], requiredAmount: bigint): readonly Hex[] | Promise<readonly Hex[]>;
11
+ }
12
+ interface FundingTypedData {
13
+ domain: Record<string, unknown>;
14
+ primaryType: string;
15
+ types: Record<string, readonly {
16
+ name: string;
17
+ type: string;
18
+ }[]>;
19
+ message: Record<string, unknown>;
20
+ }
21
+ interface FundingSigner {
22
+ readonly address: Address;
23
+ signTypedData(data: FundingTypedData): Promise<Hex>;
24
+ }
25
+ interface FundingAuthorizationVerifier {
26
+ verifyTypedData(data: FundingTypedData & {
27
+ address: Address;
28
+ signature: Hex;
29
+ }): Promise<boolean>;
30
+ }
31
+ interface FundingSource {
32
+ payer: Address;
33
+ amount: bigint;
34
+ authorization?: "signature" | "caller";
35
+ sigNonce?: bigint;
36
+ deadline?: bigint;
37
+ permit?: NonNullable<FundingInput["permit"]>;
38
+ }
39
+ interface PaymentOutput {
40
+ to: string;
41
+ amount: bigint;
42
+ }
43
+ interface TransferPreparation {
44
+ tokenAddress: Address;
45
+ outputs: readonly PaymentOutput[];
46
+ funding?: FundingSource;
47
+ deadline?: bigint;
48
+ target?: ProofTarget;
49
+ }
50
+ interface WithdrawalPreparation {
51
+ tokenAddress: Address;
52
+ to: Address;
53
+ amount: bigint;
54
+ deadline?: bigint;
55
+ target?: ProofTarget;
56
+ }
57
+ interface SweepPreparation {
58
+ tokenAddress: Address;
59
+ commitments?: readonly Hex[];
60
+ deadline?: bigint;
61
+ target?: ProofTarget;
62
+ }
63
+ interface ShieldPreparation {
64
+ tokenAddress: Address;
65
+ outputs: readonly PaymentOutput[];
66
+ funding: FundingSource;
67
+ deadline?: bigint;
68
+ }
69
+ interface PreparedOutput {
70
+ note: Note;
71
+ commitment: Hex;
72
+ identity: Hex;
73
+ delivery: Delivery;
74
+ address: string;
75
+ change: boolean;
76
+ }
77
+ interface CreateCreditPreparation {
78
+ tokenAddress: Address;
79
+ spender: string;
80
+ amount: bigint;
81
+ expiry: bigint;
82
+ funding?: FundingSource;
83
+ deadline?: bigint;
84
+ }
85
+ interface DrawCreditPreparation {
86
+ tokenAddress: Address;
87
+ credits: readonly {
88
+ credit: Hex;
89
+ amount: bigint;
90
+ }[];
91
+ deadline?: bigint;
92
+ }
93
+ interface TopUpCreditPreparation {
94
+ tokenAddress: Address;
95
+ credit: Hex;
96
+ additionalAmount: bigint;
97
+ expiry?: bigint;
98
+ funding?: FundingSource;
99
+ deadline?: bigint;
100
+ }
101
+ interface CancelCreditPreparation {
102
+ tokenAddress: Address;
103
+ credit: Hex;
104
+ deadline?: bigint;
105
+ }
106
+ interface PreparedCreditOutput {
107
+ state: CreditDeliveryState;
108
+ commitment: Hex;
109
+ deliveries: [Delivery, Delivery];
110
+ }
111
+ interface PreparedCreditInput extends CreditMembership {
112
+ commitment: Hex;
113
+ role: "owner" | "spender";
114
+ }
115
+ interface CreditPlan {
116
+ inputs: PreparedCreditInput[];
117
+ outputs: PreparedCreditOutput[];
118
+ deliveries: Delivery[];
119
+ creation?: CreateCreditParams;
120
+ draw?: CreditDrawParams;
121
+ cancel?: CancelCreditParams;
122
+ topUp?: TopUpCreditParams;
123
+ amounts?: bigint[];
124
+ }
125
+ interface OperationPlan {
126
+ version: 1;
127
+ id: string;
128
+ kind: "transfer" | "withdraw" | "sweep" | "shield" | "create-credit" | "draw-credit" | "top-up-credit" | "cancel-credit";
129
+ context: TransactionContext;
130
+ scope: WalletScope;
131
+ preparedAt: CanonicalBlock;
132
+ deadline: bigint;
133
+ outputs: PreparedOutput[];
134
+ inputs: Array<NoteMembership & {
135
+ commitment: Hex;
136
+ }>;
137
+ funding: FundingInput;
138
+ fundingMode: "none" | "signature" | "caller";
139
+ params?: TransactRequestParams;
140
+ shieldParams?: ShieldParams;
141
+ shieldOutputs?: ShieldOutput[];
142
+ capacity?: number;
143
+ credit?: CreditPlan;
144
+ statement?: _invisi_labs_prover.ProofStatement;
145
+ }
146
+ interface WalletSessionOptions {
147
+ gasBenchmarks?: readonly GasBenchmarkProfile[];
148
+ /** Optional ethers gas/funding signer; distinct from the Invisi wallet authority. */
149
+ signer?: Signer;
150
+ viewing?: Pick<ViewingCapability, "walletIdentity" | "decryptNote" | "decryptCredit">;
151
+ wallet: Wallet;
152
+ protocol: Protocol;
153
+ namespace?: string;
154
+ store?: WalletStore;
155
+ chainReader?: ChainReader;
156
+ protocolRpc?: ProtocolDataProvider;
157
+ authorization?: WalletAuthorizationProvider;
158
+ prover?: Prover;
159
+ fundingSigner?: FundingSigner;
160
+ fundingVerifier?: FundingAuthorizationVerifier;
161
+ addressResolver?: ReceivingKeyLookup;
162
+ coinSelector?: CoinSelector;
163
+ transactionTTL?: bigint;
164
+ }
165
+ interface OperationRuntime {
166
+ options: Omit<WalletSessionOptions, "protocol"> & {
167
+ protocol: TokenProtocol;
168
+ };
169
+ scope: WalletScope;
170
+ store: WalletStore;
171
+ reader: ChainReader;
172
+ authorization: () => WalletAuthorizationProvider;
173
+ }
174
+ interface OperationAggregateMember extends AggregateMember {
175
+ context: TransactionContext;
176
+ request: TransactRequest;
177
+ }
178
+
179
+ interface GasBenchmarkShape {
180
+ kind: OperationPlan["kind"];
181
+ target: string;
182
+ capacity: number;
183
+ noteInputs: number;
184
+ noteOutputs: number;
185
+ sourceTrees: number;
186
+ creditInputs: number;
187
+ creditOutputs: number;
188
+ creditRemainders: number;
189
+ funding: "none" | "caller" | "signature";
190
+ permit: boolean;
191
+ deliveryBytes: number;
192
+ }
193
+ interface GasBenchmarkDeployment {
194
+ chainId: string;
195
+ protocolAddress: Hex$1;
196
+ runtimeCodeHash: Hex$1 | null;
197
+ tokenAddress: Hex$1;
198
+ }
199
+ interface GasBenchmarkCircuit {
200
+ circuitName: string;
201
+ target: string;
202
+ artifactSha256: string;
203
+ vkSha256: string;
204
+ }
205
+ interface GasBenchmarkSample {
206
+ gasUsed: string;
207
+ transactionHash: Hex$1;
208
+ blockNumber: string;
209
+ blockHash: Hex$1;
210
+ calldataBytes: number;
211
+ }
212
+ interface GasBenchmarkProfile {
213
+ formatVersion: 1;
214
+ id: string;
215
+ deployment: GasBenchmarkDeployment;
216
+ source: {
217
+ protocolCommit: string;
218
+ measuredAt: string;
219
+ chain: string;
220
+ hardfork: string;
221
+ token: string;
222
+ verifier: "real";
223
+ assumptions: string[];
224
+ };
225
+ measurements: Array<{
226
+ id: string;
227
+ shape: GasBenchmarkShape;
228
+ circuit: GasBenchmarkCircuit | null;
229
+ samples: GasBenchmarkSample[];
230
+ }>;
231
+ }
232
+ /** Parse a trusted, JSON-compatible benchmark catalog. No network access or publisher authentication. */
233
+ declare function defineGasBenchmarks(input: unknown): GasBenchmarkProfile[];
234
+ /** Pre-proof reference only; ethers must estimate the final transaction independently. */
235
+ interface GasReference {
236
+ gasUnits: bigint;
237
+ }
238
+
239
+ export { type CancelCreditPreparation as C, type DrawCreditPreparation as D, type FundingSigner as F, type GasReference as G, type OperationRuntime as O, type ShieldPreparation as S, type TopUpCreditPreparation as T, type WithdrawalPreparation as W, type OperationPlan as a, type OperationAggregateMember as b, type CreateCreditPreparation as c, type SweepPreparation as d, type TransferPreparation as e, type WalletSessionOptions as f, type CoinSelector as g, type FundingAuthorizationVerifier as h, type FundingSource as i, type FundingTypedData as j, type GasBenchmarkCircuit as k, type GasBenchmarkDeployment as l, type GasBenchmarkProfile as m, type GasBenchmarkSample as n, type GasBenchmarkShape as o, defineGasBenchmarks as p };