@invisi-labs/protocol 1.1.0 → 1.1.2

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.cts CHANGED
@@ -1,10 +1,9 @@
1
- import * as _invisi_labs_core from '@invisi-labs/core';
2
- import { Hex, Address, ReceivingKeyLookup, WalletAuthorizationRequest, Wallet, WalletAuthorizationProvider, Note, CreditDeliveryState, AuthorizedStatement } from '@invisi-labs/core';
3
- import { ContractRunner, Provider } from 'ethers';
4
- import { Prover, ProverOptions, ProofTarget, CircuitName, ProofStatement, ProvingRequest } from '@invisi-labs/prover';
1
+ import { Hex, Address, ReceivingKeyLookup, Wallet, Note, CreditDeliveryState, AuthorizedStatement } from '@invisi-labs/core';
2
+ import { ContractRunner, Signer, Provider } from 'ethers';
5
3
  import { DeploymentContext, CanonicalBlock, ProtocolDeployment, ProtocolRpcClient } from '@invisi-labs/rpc';
6
4
  export { CanonicalBlock, DeploymentContext, Membership, ProtocolDataProvider, ProtocolDataStatus, ProtocolUpdateRange, ProtocolUpdates } from '@invisi-labs/rpc';
7
- import { F as FundingParams, D as Delivery, I as InputSource, C as CreateCreditParams, a as CancelCreditParams, b as CreditDrawParams, T as TopUpCreditParams, c as TransactRequest, S as ShieldParams, d as ShieldOutput, e as CrossTreeTransactParams } from './types-RN45XzKc.cjs';
5
+ import { F as FundingParams, D as Delivery, I as InputSource, C as CreateCreditParams, a as CancelCreditParams, b as CreditDrawParams, T as TopUpCreditParams, c as TransactRequest, S as ShieldParams, d as ShieldOutput, e as CrossTreeTransactParams } from './types-BCTQjKzw.cjs';
6
+ import { ProofTarget, CircuitName, ProofStatement, ProvingRequest } from '@invisi-labs/prover';
8
7
 
9
8
  interface RegistryContext {
10
9
  chainId: bigint;
@@ -17,7 +16,7 @@ interface RegistryReceivingKeys {
17
16
  clueKey: Hex;
18
17
  }
19
18
  interface AddressRegistration {
20
- /** Nonzero 20-byte EVM owner address. ABI calls zero-pad it to bytes32. */
19
+ /** Nonzero EVM owner: 20 bytes or canonical zero-padded bytes32. */
21
20
  walletIdentity: Hex;
22
21
  keys: RegistryReceivingKeys;
23
22
  /** The current registry nonce expected for this operation. */
@@ -33,10 +32,8 @@ interface RegistrationCalldata {
33
32
  to: Address;
34
33
  callData: Hex;
35
34
  value: 0n;
36
- publicInputs: readonly [Hex, Hex, Hex];
37
35
  }
38
- /** Private-wallet authorization request; it contains only the public transcript. */
39
- declare function registrationAuthorizationRequest(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): WalletAuthorizationRequest;
36
+ /** Standard registry EIP-712 data, independent of private WalletAuthorization. */
40
37
  declare function registrationTypedData(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): {
41
38
  domain: {
42
39
  name: string;
@@ -44,25 +41,24 @@ declare function registrationTypedData(context: RegistryContext, registration: A
44
41
  chainId: bigint;
45
42
  verifyingContract: `0x${string}`;
46
43
  };
44
+ primaryType: string;
47
45
  types: {
48
- readonly WalletAuthorization: readonly [{
49
- readonly name: "operation";
50
- readonly type: "bytes32";
51
- }, {
52
- readonly name: "statementHash";
53
- readonly type: "bytes32";
54
- }];
46
+ [x: string]: {
47
+ name: string;
48
+ type: string;
49
+ }[];
55
50
  };
56
- primaryType: "WalletAuthorization";
57
51
  message: {
58
- operation: `0x${string}`;
59
- statementHash: `0x${string}`;
52
+ nonce: bigint;
53
+ deadline: bigint;
54
+ viewingPublicKey: Hex;
55
+ clueKey: Hex;
56
+ walletIdentity: string;
60
57
  };
61
58
  };
62
- /** Exact wallet_registration public statement: WID, digest high128, digest low128. */
63
- declare function registrationPublicInputs(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): readonly [Hex, Hex, Hex];
64
- /** Encode a relayer-ready call after obtaining a proof; does not sign or broadcast. */
65
- declare function buildRegistrationCalldata(context: RegistryContext, registration: AddressRegistration, proof: Hex, options?: RegistrationOptions): RegistrationCalldata;
59
+ declare function registrationDigest(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): Hex;
60
+ /** Encode an owner call (empty signature) or an EIP-712 / ERC-1271 authorized relay. */
61
+ declare function buildRegistrationCalldata(context: RegistryContext, registration: AddressRegistration, signature: Hex, options?: RegistrationOptions): RegistrationCalldata;
66
62
  /** Ethers runner used for registry contract reads. */
67
63
  type RegistryReadClient = ContractRunner;
68
64
  /** One receivingKeysOf query per short address; RPC failures propagate unchanged. */
@@ -91,7 +87,7 @@ declare const word: (v: bigint | string) => Hex;
91
87
  declare function dense<T>(v: readonly T[], name: string): readonly T[];
92
88
  declare function known(v: object, keys: readonly string[], name?: string): void;
93
89
  declare function notes(v: readonly Hex[], name: string): `0x${string}`[];
94
- declare function envelope(v: Hex, length: number, version?: number): Hex;
90
+ declare function envelope(v: Hex, length: number, version?: number, maximum?: number): Hex;
95
91
  declare function normalizeContext(c: TransactionContext): {
96
92
  chainId: bigint;
97
93
  protocolAddress: Hex;
@@ -149,6 +145,8 @@ interface CanonicalReceipt {
149
145
  }
150
146
  interface ChainReader {
151
147
  getChainId(): Promise<bigint>;
148
+ /** Required when a selected deployment includes a receiving-key registry. */
149
+ getProtocolAddressRegistry?(address: Address): Promise<Address>;
152
150
  getCode(address: Address): Promise<Hex>;
153
151
  getBlock(number: bigint): Promise<CanonicalBlock>;
154
152
  getLatestBlockNumber(): Promise<bigint>;
@@ -175,17 +173,18 @@ interface FactoryReader {
175
173
  }
176
174
 
177
175
  interface RegistryReader extends Pick<ChainReader, "getChainId" | "getCode" | "getBlock" | "getLatestBlockNumber" | "getTransaction" | "getReceipt"> {
176
+ /** Validate arbitrary ERC-1271 bytes for a contract owner; transport errors propagate. */
177
+ isValidRegistrationSignature?(owner: Address, digest: Hex, signature: Hex): Promise<boolean>;
178
178
  getRegistryNonce(context: RegistryContext, walletIdentity: Hex, block: CanonicalBlock): Promise<bigint>;
179
179
  }
180
180
  interface RegistrationPreparation {
181
181
  wallet: Wallet;
182
182
  reader: RegistryReader;
183
- authorization?: WalletAuthorizationProvider;
184
- prover?: Prover;
183
+ signer?: Signer;
185
184
  deadline?: bigint;
186
185
  update?: boolean;
187
186
  }
188
- type RegistrationStatus = "prepared" | "authorized" | "ready" | "submitted" | "confirmed" | "uncertain" | "failed" | "expired" | "reorged";
187
+ type RegistrationStatus = "prepared" | "ready" | "submitted" | "confirmed" | "uncertain" | "failed" | "expired" | "reorged";
189
188
  declare class RegistrationOperation {
190
189
  #private;
191
190
  readonly status: RegistrationStatus;
@@ -203,12 +202,38 @@ declare class RegistrationOperation {
203
202
  chainId: bigint;
204
203
  registryAddress: `0x${string}`;
205
204
  };
205
+ /** Sign with ethers, or attach externally obtained ERC-1271 signature bytes. */
206
206
  authorize(options?: {
207
207
  signal?: AbortSignal;
208
+ signature?: Hex;
208
209
  }): Promise<RegistrationOperation>;
209
- prove(options?: ProverOptions): Promise<RegistrationOperation>;
210
+ /** Empty signatures require the transaction sender to be the wallet owner. */
211
+ authorizeDirect(): Promise<RegistrationOperation>;
212
+ typedData(): {
213
+ domain: {
214
+ name: string;
215
+ version: string;
216
+ chainId: bigint;
217
+ verifyingContract: `0x${string}`;
218
+ };
219
+ primaryType: string;
220
+ types: {
221
+ [x: string]: {
222
+ name: string;
223
+ type: string;
224
+ }[];
225
+ };
226
+ message: {
227
+ nonce: bigint;
228
+ deadline: bigint;
229
+ viewingPublicKey: Hex;
230
+ clueKey: Hex;
231
+ walletIdentity: string;
232
+ };
233
+ };
210
234
  private call;
211
235
  exportTransaction(): Promise<TransactionCall>;
236
+ private validateFreshness;
212
237
  /** Associate a signed/broadcast transaction; ethers owns sending and receipt waiting. */
213
238
  trackTransaction(transactionHash: string): RegistrationOperation;
214
239
  reconcile(options?: {
@@ -235,9 +260,30 @@ declare class AddressRegistry {
235
260
  validateDeployment(reader: Pick<RegistryReader, "getChainId" | "getCode">): Promise<void>;
236
261
  prepareRegistration(options: RegistrationPreparation): Promise<RegistrationOperation>;
237
262
  resolve(address: string): Promise<string>;
238
- authorization(registration: AddressRegistration, options?: RegistrationOptions): _invisi_labs_core.WalletAuthorizationRequest;
239
- publicInputs(registration: AddressRegistration, options?: RegistrationOptions): readonly [`0x${string}`, `0x${string}`, `0x${string}`];
240
- buildCall(registration: AddressRegistration, proof: `0x${string}`, options?: RegistrationOptions): RegistrationCalldata;
263
+ typedData(registration: AddressRegistration, options?: RegistrationOptions): {
264
+ domain: {
265
+ name: string;
266
+ version: string;
267
+ chainId: bigint;
268
+ verifyingContract: `0x${string}`;
269
+ };
270
+ primaryType: string;
271
+ types: {
272
+ [x: string]: {
273
+ name: string;
274
+ type: string;
275
+ }[];
276
+ };
277
+ message: {
278
+ nonce: bigint;
279
+ deadline: bigint;
280
+ viewingPublicKey: Hex;
281
+ clueKey: Hex;
282
+ walletIdentity: string;
283
+ };
284
+ };
285
+ digest(registration: AddressRegistration, options?: RegistrationOptions): `0x${string}`;
286
+ buildCall(registration: AddressRegistration, signature: `0x${string}`, options?: RegistrationOptions): RegistrationCalldata;
241
287
  }
242
288
 
243
289
  declare const CREATE_CREDIT_FIELDS: readonly ["token", "sources", "nullifiers", "creditCommitment", "changeCommitment", "owner", "expiry", "deadline"];
@@ -554,7 +600,7 @@ type TransactCapacity = (typeof TRANSACT_CAPACITIES)[number];
554
600
  declare function selectTransactCapacity(inputs: number, outputs: number): TransactCapacity;
555
601
  type TransactRequestParams = CrossTreeTransactParams;
556
602
  declare function normalizeTransactRequest(c: TransactionContext, p: TransactRequestParams, cs: readonly Delivery[], funding?: FundingInput): {
557
- capacity: 14 | 56 | 112 | 168;
603
+ capacity: 112 | 14 | 56 | 168;
558
604
  sources: {
559
605
  treeId: bigint;
560
606
  merkleRoot: `0x${string}`;
@@ -648,7 +694,7 @@ interface BuildTransactCalldataParams {
648
694
  }
649
695
  declare function buildTransactCalldata(p: BuildTransactCalldataParams): {
650
696
  data: `0x${string}`;
651
- capacity: 14 | 56 | 112 | 168;
697
+ capacity: 112 | 14 | 56 | 168;
652
698
  approveAmount: bigint;
653
699
  };
654
700
  interface BuildTransactAggregateCalldataParams {
@@ -768,7 +814,7 @@ declare class TokenProtocol {
768
814
  }): Promise<void>;
769
815
  transact(request: Omit<BuildTransactCalldataParams, "context">): {
770
816
  data: `0x${string}`;
771
- capacity: 14 | 56 | 112 | 168;
817
+ capacity: 112 | 14 | 56 | 168;
772
818
  approveAmount: bigint;
773
819
  to: `0x${string}`;
774
820
  value: bigint;
@@ -825,6 +871,7 @@ declare class Protocol {
825
871
  }): Promise<Protocol>;
826
872
  validateDeployment(connection: Provider | (Pick<ChainReader, "getChainId" | "getCode"> & {
827
873
  getProtocolVersion?(address: Address): Promise<bigint>;
874
+ getProtocolAddressRegistry?(address: Address): Promise<Address>;
828
875
  })): Promise<void>;
829
876
  aggregate(request: Omit<BuildTransactAggregateCalldataParams, "context">): {
830
877
  data: Hex;
@@ -872,7 +919,7 @@ interface BuildWithdrawalCalldataParams extends Omit<BuildTransactCalldataParams
872
919
  /** Prepare a full public withdrawal whose spending authority is already proven in the supplied proof. */
873
920
  declare function buildWithdrawalCalldata(p: BuildWithdrawalCalldataParams): Promise<{
874
921
  data: `0x${string}`;
875
- capacity: 14 | 56 | 112 | 168;
922
+ capacity: 112 | 14 | 56 | 168;
876
923
  approveAmount: bigint;
877
924
  }>;
878
925
 
@@ -936,7 +983,6 @@ declare class WitnessBuilder {
936
983
  cancelCredit(p: CancelCreditWitnessParams): Promise<ProvingRequest>;
937
984
  drawCredit(p: DrawCreditWitnessParams): Promise<ProvingRequest>;
938
985
  topUpCredit(p: TopUpCreditWitnessParams): Promise<ProvingRequest>;
939
- static registration(context: RegistryContext, registration: AddressRegistration, authorization: AuthorizedStatement, options?: RegistrationOptions): Promise<ProvingRequest>;
940
986
  }
941
987
 
942
988
  /**
@@ -945,4 +991,4 @@ declare class WitnessBuilder {
945
991
  */
946
992
  declare function resolveInstanceAddress(client: ContractRunner, factoryAddress: `0x${string}`, salt: `0x${string}`): Promise<`0x${string}`>;
947
993
 
948
- export { type AddressRegistration, AddressRegistry, type AddressRegistryOptions, type AggregateMemberInput, type BuildCancelCreditCalldataParams, type BuildCreateCreditCalldataParams, type BuildCreditDrawCalldataParams, type BuildShieldCalldataParams, type BuildTopUpCreditCalldataParams, type BuildTransactAggregateCalldataParams, type BuildTransactCalldataParams, type BuildWithdrawalCalldataParams, CREATE_CREDIT_FIELDS, CREDIT_DRAW_CAPACITIES, type CancelCreditWitnessParams, type CanonicalReceipt, type ChainReader, type CreateCreditWitnessParams, type CreditMembership, type DrawCreditWitnessParams, EMPTY_FUNDING, EMPTY_PERMIT, FIELD_MODULUS, type FactoryReader, type FundingInput, type NoteMembership, Protocol, type ProtocolLog, type ProtocolOptions, type RegistrationCalldata, RegistrationOperation, type RegistrationOptions, type RegistrationPreparation, type RegistrationStatus, type RegistryContext, type RegistryReadClient, type RegistryReader, type RegistryReceivingKeys, TRANSACT_CAPACITIES, TokenProtocol, type TokenProtocolOptions, type TopUpCreditWitnessParams, type TransactCapacity, type TransactRequestParams, type TransactWitnessParams, type TransactionCall, type TransactionContext, type VerifyCreditCommitmentParams, type VerifyNoteCommitmentParams, WitnessBuilder, ZERO_ADDRESS, ZERO_WORD, aggregateMemberRequestHash, aggregatePublicInputs, buildCancelCreditCalldata, buildCreateCreditCalldata, buildCreditDrawCalldata, buildRegistrationCalldata, buildShieldCalldata, buildTopUpCreditCalldata, buildTransactAggregateCalldata, buildTransactCalldata, buildWithdrawalCalldata, cancelCreditBaseInputs, cancelCreditPublicInputs, cancelCreditRequestHash, checkDeadline, createCreditBaseInputs, createCreditPublicInputs, createCreditRequestHash, createRegistryReceivingKeyLookup, creditDrawBaseInputs, creditDrawPublicInputs, deliveriesHash, dense, encodeAggregateFundingTypedData, encodeCancelCreditTypedData, encodeCreateCreditFundingTypedData, encodeCreateCreditTypedData, encodeCreditDrawTypedData, encodeCreditProof, encodeShieldFundingTypedData, encodeTopUpCreditFundingTypedData, encodeTopUpCreditTypedData, encodeTransactFundingTypedData, encodeTransactTypedData, envelope, field, fundingFields, getEIP712Domain, known, normalizeContext, normalizeDelivery, normalizeFunding, normalizeSources, normalizeTransactRequest, notes, pad, registrationAuthorizationRequest, registrationPublicInputs, registrationTypedData, resolveInstanceAddress, selectCreditDrawCircuit, selectTransactCapacity, shieldFundingRequestHash, topUpCreditBaseInputs, topUpCreditPublicInputs, topUpCreditRequestHash, transactFundingRequestHash, transactPublicInputs, transactUserPublicInputs, uint, validateCancelCreditRequest, validateCreateCreditRequest, validateCreditDrawRequest, validateFundingSubmission, validateShieldRequest, validateTopUpCreditRequest, verifyCreditCommitment, verifyNoteCommitment, word };
994
+ export { type AddressRegistration, AddressRegistry, type AddressRegistryOptions, type AggregateMemberInput, type BuildCancelCreditCalldataParams, type BuildCreateCreditCalldataParams, type BuildCreditDrawCalldataParams, type BuildShieldCalldataParams, type BuildTopUpCreditCalldataParams, type BuildTransactAggregateCalldataParams, type BuildTransactCalldataParams, type BuildWithdrawalCalldataParams, CREATE_CREDIT_FIELDS, CREDIT_DRAW_CAPACITIES, type CancelCreditWitnessParams, type CanonicalReceipt, type ChainReader, type CreateCreditWitnessParams, type CreditMembership, type DrawCreditWitnessParams, EMPTY_FUNDING, EMPTY_PERMIT, FIELD_MODULUS, type FactoryReader, type FundingInput, type NoteMembership, Protocol, type ProtocolLog, type ProtocolOptions, type RegistrationCalldata, RegistrationOperation, type RegistrationOptions, type RegistrationPreparation, type RegistrationStatus, type RegistryContext, type RegistryReadClient, type RegistryReader, type RegistryReceivingKeys, TRANSACT_CAPACITIES, TokenProtocol, type TokenProtocolOptions, type TopUpCreditWitnessParams, type TransactCapacity, type TransactRequestParams, type TransactWitnessParams, type TransactionCall, type TransactionContext, type VerifyCreditCommitmentParams, type VerifyNoteCommitmentParams, WitnessBuilder, ZERO_ADDRESS, ZERO_WORD, aggregateMemberRequestHash, aggregatePublicInputs, buildCancelCreditCalldata, buildCreateCreditCalldata, buildCreditDrawCalldata, buildRegistrationCalldata, buildShieldCalldata, buildTopUpCreditCalldata, buildTransactAggregateCalldata, buildTransactCalldata, buildWithdrawalCalldata, cancelCreditBaseInputs, cancelCreditPublicInputs, cancelCreditRequestHash, checkDeadline, createCreditBaseInputs, createCreditPublicInputs, createCreditRequestHash, createRegistryReceivingKeyLookup, creditDrawBaseInputs, creditDrawPublicInputs, deliveriesHash, dense, encodeAggregateFundingTypedData, encodeCancelCreditTypedData, encodeCreateCreditFundingTypedData, encodeCreateCreditTypedData, encodeCreditDrawTypedData, encodeCreditProof, encodeShieldFundingTypedData, encodeTopUpCreditFundingTypedData, encodeTopUpCreditTypedData, encodeTransactFundingTypedData, encodeTransactTypedData, envelope, field, fundingFields, getEIP712Domain, known, normalizeContext, normalizeDelivery, normalizeFunding, normalizeSources, normalizeTransactRequest, notes, pad, registrationDigest, registrationTypedData, resolveInstanceAddress, selectCreditDrawCircuit, selectTransactCapacity, shieldFundingRequestHash, topUpCreditBaseInputs, topUpCreditPublicInputs, topUpCreditRequestHash, transactFundingRequestHash, transactPublicInputs, transactUserPublicInputs, uint, validateCancelCreditRequest, validateCreateCreditRequest, validateCreditDrawRequest, validateFundingSubmission, validateShieldRequest, validateTopUpCreditRequest, verifyCreditCommitment, verifyNoteCommitment, word };
package/dist/index.d.ts CHANGED
@@ -1,10 +1,9 @@
1
- import * as _invisi_labs_core from '@invisi-labs/core';
2
- import { Hex, Address, ReceivingKeyLookup, WalletAuthorizationRequest, Wallet, WalletAuthorizationProvider, Note, CreditDeliveryState, AuthorizedStatement } from '@invisi-labs/core';
3
- import { ContractRunner, Provider } from 'ethers';
4
- import { Prover, ProverOptions, ProofTarget, CircuitName, ProofStatement, ProvingRequest } from '@invisi-labs/prover';
1
+ import { Hex, Address, ReceivingKeyLookup, Wallet, Note, CreditDeliveryState, AuthorizedStatement } from '@invisi-labs/core';
2
+ import { ContractRunner, Signer, Provider } from 'ethers';
5
3
  import { DeploymentContext, CanonicalBlock, ProtocolDeployment, ProtocolRpcClient } from '@invisi-labs/rpc';
6
4
  export { CanonicalBlock, DeploymentContext, Membership, ProtocolDataProvider, ProtocolDataStatus, ProtocolUpdateRange, ProtocolUpdates } from '@invisi-labs/rpc';
7
- import { F as FundingParams, D as Delivery, I as InputSource, C as CreateCreditParams, a as CancelCreditParams, b as CreditDrawParams, T as TopUpCreditParams, c as TransactRequest, S as ShieldParams, d as ShieldOutput, e as CrossTreeTransactParams } from './types-RN45XzKc.js';
5
+ import { F as FundingParams, D as Delivery, I as InputSource, C as CreateCreditParams, a as CancelCreditParams, b as CreditDrawParams, T as TopUpCreditParams, c as TransactRequest, S as ShieldParams, d as ShieldOutput, e as CrossTreeTransactParams } from './types-BCTQjKzw.js';
6
+ import { ProofTarget, CircuitName, ProofStatement, ProvingRequest } from '@invisi-labs/prover';
8
7
 
9
8
  interface RegistryContext {
10
9
  chainId: bigint;
@@ -17,7 +16,7 @@ interface RegistryReceivingKeys {
17
16
  clueKey: Hex;
18
17
  }
19
18
  interface AddressRegistration {
20
- /** Nonzero 20-byte EVM owner address. ABI calls zero-pad it to bytes32. */
19
+ /** Nonzero EVM owner: 20 bytes or canonical zero-padded bytes32. */
21
20
  walletIdentity: Hex;
22
21
  keys: RegistryReceivingKeys;
23
22
  /** The current registry nonce expected for this operation. */
@@ -33,10 +32,8 @@ interface RegistrationCalldata {
33
32
  to: Address;
34
33
  callData: Hex;
35
34
  value: 0n;
36
- publicInputs: readonly [Hex, Hex, Hex];
37
35
  }
38
- /** Private-wallet authorization request; it contains only the public transcript. */
39
- declare function registrationAuthorizationRequest(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): WalletAuthorizationRequest;
36
+ /** Standard registry EIP-712 data, independent of private WalletAuthorization. */
40
37
  declare function registrationTypedData(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): {
41
38
  domain: {
42
39
  name: string;
@@ -44,25 +41,24 @@ declare function registrationTypedData(context: RegistryContext, registration: A
44
41
  chainId: bigint;
45
42
  verifyingContract: `0x${string}`;
46
43
  };
44
+ primaryType: string;
47
45
  types: {
48
- readonly WalletAuthorization: readonly [{
49
- readonly name: "operation";
50
- readonly type: "bytes32";
51
- }, {
52
- readonly name: "statementHash";
53
- readonly type: "bytes32";
54
- }];
46
+ [x: string]: {
47
+ name: string;
48
+ type: string;
49
+ }[];
55
50
  };
56
- primaryType: "WalletAuthorization";
57
51
  message: {
58
- operation: `0x${string}`;
59
- statementHash: `0x${string}`;
52
+ nonce: bigint;
53
+ deadline: bigint;
54
+ viewingPublicKey: Hex;
55
+ clueKey: Hex;
56
+ walletIdentity: string;
60
57
  };
61
58
  };
62
- /** Exact wallet_registration public statement: WID, digest high128, digest low128. */
63
- declare function registrationPublicInputs(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): readonly [Hex, Hex, Hex];
64
- /** Encode a relayer-ready call after obtaining a proof; does not sign or broadcast. */
65
- declare function buildRegistrationCalldata(context: RegistryContext, registration: AddressRegistration, proof: Hex, options?: RegistrationOptions): RegistrationCalldata;
59
+ declare function registrationDigest(context: RegistryContext, registration: AddressRegistration, options?: RegistrationOptions): Hex;
60
+ /** Encode an owner call (empty signature) or an EIP-712 / ERC-1271 authorized relay. */
61
+ declare function buildRegistrationCalldata(context: RegistryContext, registration: AddressRegistration, signature: Hex, options?: RegistrationOptions): RegistrationCalldata;
66
62
  /** Ethers runner used for registry contract reads. */
67
63
  type RegistryReadClient = ContractRunner;
68
64
  /** One receivingKeysOf query per short address; RPC failures propagate unchanged. */
@@ -91,7 +87,7 @@ declare const word: (v: bigint | string) => Hex;
91
87
  declare function dense<T>(v: readonly T[], name: string): readonly T[];
92
88
  declare function known(v: object, keys: readonly string[], name?: string): void;
93
89
  declare function notes(v: readonly Hex[], name: string): `0x${string}`[];
94
- declare function envelope(v: Hex, length: number, version?: number): Hex;
90
+ declare function envelope(v: Hex, length: number, version?: number, maximum?: number): Hex;
95
91
  declare function normalizeContext(c: TransactionContext): {
96
92
  chainId: bigint;
97
93
  protocolAddress: Hex;
@@ -149,6 +145,8 @@ interface CanonicalReceipt {
149
145
  }
150
146
  interface ChainReader {
151
147
  getChainId(): Promise<bigint>;
148
+ /** Required when a selected deployment includes a receiving-key registry. */
149
+ getProtocolAddressRegistry?(address: Address): Promise<Address>;
152
150
  getCode(address: Address): Promise<Hex>;
153
151
  getBlock(number: bigint): Promise<CanonicalBlock>;
154
152
  getLatestBlockNumber(): Promise<bigint>;
@@ -175,17 +173,18 @@ interface FactoryReader {
175
173
  }
176
174
 
177
175
  interface RegistryReader extends Pick<ChainReader, "getChainId" | "getCode" | "getBlock" | "getLatestBlockNumber" | "getTransaction" | "getReceipt"> {
176
+ /** Validate arbitrary ERC-1271 bytes for a contract owner; transport errors propagate. */
177
+ isValidRegistrationSignature?(owner: Address, digest: Hex, signature: Hex): Promise<boolean>;
178
178
  getRegistryNonce(context: RegistryContext, walletIdentity: Hex, block: CanonicalBlock): Promise<bigint>;
179
179
  }
180
180
  interface RegistrationPreparation {
181
181
  wallet: Wallet;
182
182
  reader: RegistryReader;
183
- authorization?: WalletAuthorizationProvider;
184
- prover?: Prover;
183
+ signer?: Signer;
185
184
  deadline?: bigint;
186
185
  update?: boolean;
187
186
  }
188
- type RegistrationStatus = "prepared" | "authorized" | "ready" | "submitted" | "confirmed" | "uncertain" | "failed" | "expired" | "reorged";
187
+ type RegistrationStatus = "prepared" | "ready" | "submitted" | "confirmed" | "uncertain" | "failed" | "expired" | "reorged";
189
188
  declare class RegistrationOperation {
190
189
  #private;
191
190
  readonly status: RegistrationStatus;
@@ -203,12 +202,38 @@ declare class RegistrationOperation {
203
202
  chainId: bigint;
204
203
  registryAddress: `0x${string}`;
205
204
  };
205
+ /** Sign with ethers, or attach externally obtained ERC-1271 signature bytes. */
206
206
  authorize(options?: {
207
207
  signal?: AbortSignal;
208
+ signature?: Hex;
208
209
  }): Promise<RegistrationOperation>;
209
- prove(options?: ProverOptions): Promise<RegistrationOperation>;
210
+ /** Empty signatures require the transaction sender to be the wallet owner. */
211
+ authorizeDirect(): Promise<RegistrationOperation>;
212
+ typedData(): {
213
+ domain: {
214
+ name: string;
215
+ version: string;
216
+ chainId: bigint;
217
+ verifyingContract: `0x${string}`;
218
+ };
219
+ primaryType: string;
220
+ types: {
221
+ [x: string]: {
222
+ name: string;
223
+ type: string;
224
+ }[];
225
+ };
226
+ message: {
227
+ nonce: bigint;
228
+ deadline: bigint;
229
+ viewingPublicKey: Hex;
230
+ clueKey: Hex;
231
+ walletIdentity: string;
232
+ };
233
+ };
210
234
  private call;
211
235
  exportTransaction(): Promise<TransactionCall>;
236
+ private validateFreshness;
212
237
  /** Associate a signed/broadcast transaction; ethers owns sending and receipt waiting. */
213
238
  trackTransaction(transactionHash: string): RegistrationOperation;
214
239
  reconcile(options?: {
@@ -235,9 +260,30 @@ declare class AddressRegistry {
235
260
  validateDeployment(reader: Pick<RegistryReader, "getChainId" | "getCode">): Promise<void>;
236
261
  prepareRegistration(options: RegistrationPreparation): Promise<RegistrationOperation>;
237
262
  resolve(address: string): Promise<string>;
238
- authorization(registration: AddressRegistration, options?: RegistrationOptions): _invisi_labs_core.WalletAuthorizationRequest;
239
- publicInputs(registration: AddressRegistration, options?: RegistrationOptions): readonly [`0x${string}`, `0x${string}`, `0x${string}`];
240
- buildCall(registration: AddressRegistration, proof: `0x${string}`, options?: RegistrationOptions): RegistrationCalldata;
263
+ typedData(registration: AddressRegistration, options?: RegistrationOptions): {
264
+ domain: {
265
+ name: string;
266
+ version: string;
267
+ chainId: bigint;
268
+ verifyingContract: `0x${string}`;
269
+ };
270
+ primaryType: string;
271
+ types: {
272
+ [x: string]: {
273
+ name: string;
274
+ type: string;
275
+ }[];
276
+ };
277
+ message: {
278
+ nonce: bigint;
279
+ deadline: bigint;
280
+ viewingPublicKey: Hex;
281
+ clueKey: Hex;
282
+ walletIdentity: string;
283
+ };
284
+ };
285
+ digest(registration: AddressRegistration, options?: RegistrationOptions): `0x${string}`;
286
+ buildCall(registration: AddressRegistration, signature: `0x${string}`, options?: RegistrationOptions): RegistrationCalldata;
241
287
  }
242
288
 
243
289
  declare const CREATE_CREDIT_FIELDS: readonly ["token", "sources", "nullifiers", "creditCommitment", "changeCommitment", "owner", "expiry", "deadline"];
@@ -554,7 +600,7 @@ type TransactCapacity = (typeof TRANSACT_CAPACITIES)[number];
554
600
  declare function selectTransactCapacity(inputs: number, outputs: number): TransactCapacity;
555
601
  type TransactRequestParams = CrossTreeTransactParams;
556
602
  declare function normalizeTransactRequest(c: TransactionContext, p: TransactRequestParams, cs: readonly Delivery[], funding?: FundingInput): {
557
- capacity: 14 | 56 | 112 | 168;
603
+ capacity: 112 | 14 | 56 | 168;
558
604
  sources: {
559
605
  treeId: bigint;
560
606
  merkleRoot: `0x${string}`;
@@ -648,7 +694,7 @@ interface BuildTransactCalldataParams {
648
694
  }
649
695
  declare function buildTransactCalldata(p: BuildTransactCalldataParams): {
650
696
  data: `0x${string}`;
651
- capacity: 14 | 56 | 112 | 168;
697
+ capacity: 112 | 14 | 56 | 168;
652
698
  approveAmount: bigint;
653
699
  };
654
700
  interface BuildTransactAggregateCalldataParams {
@@ -768,7 +814,7 @@ declare class TokenProtocol {
768
814
  }): Promise<void>;
769
815
  transact(request: Omit<BuildTransactCalldataParams, "context">): {
770
816
  data: `0x${string}`;
771
- capacity: 14 | 56 | 112 | 168;
817
+ capacity: 112 | 14 | 56 | 168;
772
818
  approveAmount: bigint;
773
819
  to: `0x${string}`;
774
820
  value: bigint;
@@ -825,6 +871,7 @@ declare class Protocol {
825
871
  }): Promise<Protocol>;
826
872
  validateDeployment(connection: Provider | (Pick<ChainReader, "getChainId" | "getCode"> & {
827
873
  getProtocolVersion?(address: Address): Promise<bigint>;
874
+ getProtocolAddressRegistry?(address: Address): Promise<Address>;
828
875
  })): Promise<void>;
829
876
  aggregate(request: Omit<BuildTransactAggregateCalldataParams, "context">): {
830
877
  data: Hex;
@@ -872,7 +919,7 @@ interface BuildWithdrawalCalldataParams extends Omit<BuildTransactCalldataParams
872
919
  /** Prepare a full public withdrawal whose spending authority is already proven in the supplied proof. */
873
920
  declare function buildWithdrawalCalldata(p: BuildWithdrawalCalldataParams): Promise<{
874
921
  data: `0x${string}`;
875
- capacity: 14 | 56 | 112 | 168;
922
+ capacity: 112 | 14 | 56 | 168;
876
923
  approveAmount: bigint;
877
924
  }>;
878
925
 
@@ -936,7 +983,6 @@ declare class WitnessBuilder {
936
983
  cancelCredit(p: CancelCreditWitnessParams): Promise<ProvingRequest>;
937
984
  drawCredit(p: DrawCreditWitnessParams): Promise<ProvingRequest>;
938
985
  topUpCredit(p: TopUpCreditWitnessParams): Promise<ProvingRequest>;
939
- static registration(context: RegistryContext, registration: AddressRegistration, authorization: AuthorizedStatement, options?: RegistrationOptions): Promise<ProvingRequest>;
940
986
  }
941
987
 
942
988
  /**
@@ -945,4 +991,4 @@ declare class WitnessBuilder {
945
991
  */
946
992
  declare function resolveInstanceAddress(client: ContractRunner, factoryAddress: `0x${string}`, salt: `0x${string}`): Promise<`0x${string}`>;
947
993
 
948
- export { type AddressRegistration, AddressRegistry, type AddressRegistryOptions, type AggregateMemberInput, type BuildCancelCreditCalldataParams, type BuildCreateCreditCalldataParams, type BuildCreditDrawCalldataParams, type BuildShieldCalldataParams, type BuildTopUpCreditCalldataParams, type BuildTransactAggregateCalldataParams, type BuildTransactCalldataParams, type BuildWithdrawalCalldataParams, CREATE_CREDIT_FIELDS, CREDIT_DRAW_CAPACITIES, type CancelCreditWitnessParams, type CanonicalReceipt, type ChainReader, type CreateCreditWitnessParams, type CreditMembership, type DrawCreditWitnessParams, EMPTY_FUNDING, EMPTY_PERMIT, FIELD_MODULUS, type FactoryReader, type FundingInput, type NoteMembership, Protocol, type ProtocolLog, type ProtocolOptions, type RegistrationCalldata, RegistrationOperation, type RegistrationOptions, type RegistrationPreparation, type RegistrationStatus, type RegistryContext, type RegistryReadClient, type RegistryReader, type RegistryReceivingKeys, TRANSACT_CAPACITIES, TokenProtocol, type TokenProtocolOptions, type TopUpCreditWitnessParams, type TransactCapacity, type TransactRequestParams, type TransactWitnessParams, type TransactionCall, type TransactionContext, type VerifyCreditCommitmentParams, type VerifyNoteCommitmentParams, WitnessBuilder, ZERO_ADDRESS, ZERO_WORD, aggregateMemberRequestHash, aggregatePublicInputs, buildCancelCreditCalldata, buildCreateCreditCalldata, buildCreditDrawCalldata, buildRegistrationCalldata, buildShieldCalldata, buildTopUpCreditCalldata, buildTransactAggregateCalldata, buildTransactCalldata, buildWithdrawalCalldata, cancelCreditBaseInputs, cancelCreditPublicInputs, cancelCreditRequestHash, checkDeadline, createCreditBaseInputs, createCreditPublicInputs, createCreditRequestHash, createRegistryReceivingKeyLookup, creditDrawBaseInputs, creditDrawPublicInputs, deliveriesHash, dense, encodeAggregateFundingTypedData, encodeCancelCreditTypedData, encodeCreateCreditFundingTypedData, encodeCreateCreditTypedData, encodeCreditDrawTypedData, encodeCreditProof, encodeShieldFundingTypedData, encodeTopUpCreditFundingTypedData, encodeTopUpCreditTypedData, encodeTransactFundingTypedData, encodeTransactTypedData, envelope, field, fundingFields, getEIP712Domain, known, normalizeContext, normalizeDelivery, normalizeFunding, normalizeSources, normalizeTransactRequest, notes, pad, registrationAuthorizationRequest, registrationPublicInputs, registrationTypedData, resolveInstanceAddress, selectCreditDrawCircuit, selectTransactCapacity, shieldFundingRequestHash, topUpCreditBaseInputs, topUpCreditPublicInputs, topUpCreditRequestHash, transactFundingRequestHash, transactPublicInputs, transactUserPublicInputs, uint, validateCancelCreditRequest, validateCreateCreditRequest, validateCreditDrawRequest, validateFundingSubmission, validateShieldRequest, validateTopUpCreditRequest, verifyCreditCommitment, verifyNoteCommitment, word };
994
+ export { type AddressRegistration, AddressRegistry, type AddressRegistryOptions, type AggregateMemberInput, type BuildCancelCreditCalldataParams, type BuildCreateCreditCalldataParams, type BuildCreditDrawCalldataParams, type BuildShieldCalldataParams, type BuildTopUpCreditCalldataParams, type BuildTransactAggregateCalldataParams, type BuildTransactCalldataParams, type BuildWithdrawalCalldataParams, CREATE_CREDIT_FIELDS, CREDIT_DRAW_CAPACITIES, type CancelCreditWitnessParams, type CanonicalReceipt, type ChainReader, type CreateCreditWitnessParams, type CreditMembership, type DrawCreditWitnessParams, EMPTY_FUNDING, EMPTY_PERMIT, FIELD_MODULUS, type FactoryReader, type FundingInput, type NoteMembership, Protocol, type ProtocolLog, type ProtocolOptions, type RegistrationCalldata, RegistrationOperation, type RegistrationOptions, type RegistrationPreparation, type RegistrationStatus, type RegistryContext, type RegistryReadClient, type RegistryReader, type RegistryReceivingKeys, TRANSACT_CAPACITIES, TokenProtocol, type TokenProtocolOptions, type TopUpCreditWitnessParams, type TransactCapacity, type TransactRequestParams, type TransactWitnessParams, type TransactionCall, type TransactionContext, type VerifyCreditCommitmentParams, type VerifyNoteCommitmentParams, WitnessBuilder, ZERO_ADDRESS, ZERO_WORD, aggregateMemberRequestHash, aggregatePublicInputs, buildCancelCreditCalldata, buildCreateCreditCalldata, buildCreditDrawCalldata, buildRegistrationCalldata, buildShieldCalldata, buildTopUpCreditCalldata, buildTransactAggregateCalldata, buildTransactCalldata, buildWithdrawalCalldata, cancelCreditBaseInputs, cancelCreditPublicInputs, cancelCreditRequestHash, checkDeadline, createCreditBaseInputs, createCreditPublicInputs, createCreditRequestHash, createRegistryReceivingKeyLookup, creditDrawBaseInputs, creditDrawPublicInputs, deliveriesHash, dense, encodeAggregateFundingTypedData, encodeCancelCreditTypedData, encodeCreateCreditFundingTypedData, encodeCreateCreditTypedData, encodeCreditDrawTypedData, encodeCreditProof, encodeShieldFundingTypedData, encodeTopUpCreditFundingTypedData, encodeTopUpCreditTypedData, encodeTransactFundingTypedData, encodeTransactTypedData, envelope, field, fundingFields, getEIP712Domain, known, normalizeContext, normalizeDelivery, normalizeFunding, normalizeSources, normalizeTransactRequest, notes, pad, registrationDigest, registrationTypedData, resolveInstanceAddress, selectCreditDrawCircuit, selectTransactCapacity, shieldFundingRequestHash, topUpCreditBaseInputs, topUpCreditPublicInputs, topUpCreditRequestHash, transactFundingRequestHash, transactPublicInputs, transactUserPublicInputs, uint, validateCancelCreditRequest, validateCreateCreditRequest, validateCreditDrawRequest, validateFundingSubmission, validateShieldRequest, validateTopUpCreditRequest, verifyCreditCommitment, verifyNoteCommitment, word };