@inco/shield-js 0.1.0 → 0.2.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.
Files changed (74) hide show
  1. package/README.md +52 -308
  2. package/dist/contracts/abi.d.ts +2000 -4513
  3. package/dist/contracts/abi.js +2400 -5651
  4. package/dist/contracts/index.d.ts +2 -2
  5. package/dist/contracts/index.js +2 -2
  6. package/dist/contracts/utils.d.ts +5 -24
  7. package/dist/contracts/utils.js +13 -24
  8. package/dist/errors.d.ts +16 -47
  9. package/dist/errors.js +6 -53
  10. package/dist/generated/inco/shield/v2/conductor_pb.d.ts +77 -0
  11. package/dist/generated/inco/shield/v2/conductor_pb.js +6 -0
  12. package/dist/generated/inco/shield/v2/deposit_pb.d.ts +12 -103
  13. package/dist/generated/inco/shield/v2/deposit_pb.js +4 -141
  14. package/dist/generated/inco/shield/v2/drafting_pb.d.ts +45 -269
  15. package/dist/generated/inco/shield/v2/drafting_pb.js +8 -361
  16. package/dist/generated/inco/shield/v2/types_pb.d.ts +47 -166
  17. package/dist/generated/inco/shield/v2/types_pb.js +12 -261
  18. package/dist/index.d.ts +1 -7
  19. package/dist/index.js +1 -14
  20. package/dist/shield/abi.d.ts +5 -0
  21. package/dist/shield/abi.js +28 -0
  22. package/dist/shield/client.d.ts +27 -51
  23. package/dist/shield/client.js +73 -65
  24. package/dist/shield/convert.d.ts +2 -14
  25. package/dist/shield/convert.js +39 -115
  26. package/dist/shield/encryption.d.ts +0 -67
  27. package/dist/shield/encryption.js +0 -67
  28. package/dist/shield/envelope.d.ts +10 -11
  29. package/dist/shield/envelope.js +15 -14
  30. package/dist/shield/fee.d.ts +24 -0
  31. package/dist/shield/fee.js +151 -0
  32. package/dist/shield/index.d.ts +9 -3
  33. package/dist/shield/index.js +7 -2
  34. package/dist/shield/intent.d.ts +20 -933
  35. package/dist/shield/intent.js +92 -112
  36. package/dist/shield/permission-status.d.ts +9 -0
  37. package/dist/shield/permission-status.js +8 -0
  38. package/dist/shield/rpc.d.ts +50 -49
  39. package/dist/shield/rpc.js +207 -354
  40. package/dist/shield/shield.eip712.gen.d.ts +1096 -43
  41. package/dist/shield/shield.eip712.gen.js +572 -62
  42. package/dist/shield/types.d.ts +7 -102
  43. package/dist/shield/types.js +1 -4
  44. package/dist/shield/userop/gas-estimation.d.ts +7 -22
  45. package/dist/shield/userop/gas-estimation.js +100 -137
  46. package/dist/shield/userop/paymaster.d.ts +15 -0
  47. package/dist/shield/userop/paymaster.js +17 -0
  48. package/dist/shield/userop/token-exchange.d.ts +5 -52
  49. package/dist/shield/userop/token-exchange.js +41 -149
  50. package/dist/shield/userop/types.d.ts +2 -27
  51. package/dist/shield/userop/types.js +0 -3
  52. package/dist/shield/userop/userOp.d.ts +0 -19
  53. package/dist/shield/userop/userOp.js +4 -22
  54. package/dist/shield/utils/chain.d.ts +1 -0
  55. package/dist/shield/utils/chain.js +3 -0
  56. package/dist/shield/validate-withdrawal-split.d.ts +13 -0
  57. package/dist/shield/validate-withdrawal-split.js +93 -0
  58. package/package.json +18 -27
  59. package/dist/generated/inco/shield/v2/conductor_connect.d.ts +0 -137
  60. package/dist/generated/inco/shield/v2/conductor_connect.js +0 -141
  61. package/dist/generated/inco/shield/v2/permission_pb.d.ts +0 -443
  62. package/dist/generated/inco/shield/v2/permission_pb.js +0 -639
  63. package/dist/generated/inco/shield/v2/query_pb.d.ts +0 -103
  64. package/dist/generated/inco/shield/v2/query_pb.js +0 -141
  65. package/dist/shield/userop/index.d.ts +0 -1
  66. package/dist/shield/userop/index.js +0 -1
  67. package/dist/uniswap-adapter/config.d.ts +0 -34
  68. package/dist/uniswap-adapter/config.js +0 -45
  69. package/dist/uniswap-adapter/find-pools.d.ts +0 -91
  70. package/dist/uniswap-adapter/find-pools.js +0 -108
  71. package/dist/uniswap-adapter/index.d.ts +0 -10
  72. package/dist/uniswap-adapter/index.js +0 -13
  73. package/dist/uniswap-adapter/swap.d.ts +0 -344
  74. package/dist/uniswap-adapter/swap.js +0 -309
@@ -1,18 +1,16 @@
1
- // GENERATED FILE — DO NOT EDIT
2
- // Source: Shield.eip712.sol
3
1
  import { encodeAbiParameters, concat, keccak256, stringToBytes } from 'viem';
4
- export const ASSET_MOVEMENT_TYPEHASH = keccak256(stringToBytes("AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)"));
2
+ export const ASSET_TYPEHASH = keccak256(stringToBytes("Asset(uint8 standard,address token,uint256 tokenId)"));
3
+ export function assetStructHash(s) {
4
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "uint8" }, { type: "address" }, { type: "uint256" }], [ASSET_TYPEHASH, s.standard, s.token, s.tokenId]));
5
+ }
6
+ export const ASSET_MOVEMENT_TYPEHASH = keccak256(stringToBytes("AssetMovement(address account,address assetAdapter,bytes movementArgs)"));
5
7
  export function assetMovementStructHash(s) {
6
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [ASSET_MOVEMENT_TYPEHASH, s.assetAdapter, keccak256(s.assetIdentificationArgs), keccak256(s.movementArgs)]));
8
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "address" }, { type: "bytes32" }], [ASSET_MOVEMENT_TYPEHASH, s.account, s.assetAdapter, keccak256(s.movementArgs)]));
7
9
  }
8
10
  export const CALL_TYPEHASH = keccak256(stringToBytes("Call(address target,uint256 value,bytes data)"));
9
11
  export function callStructHash(s) {
10
12
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "uint256" }, { type: "bytes32" }], [CALL_TYPEHASH, s.target, s.value, keccak256(s.data)]));
11
13
  }
12
- export const BALANCE_QUERY_TYPEHASH = keccak256(stringToBytes("BalanceQuery(address requester,address owner,bytes32 assetId,uint64 queryTimestamp)"));
13
- export function balanceQueryStructHash(s) {
14
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "address" }, { type: "bytes32" }, { type: "uint64" }], [BALANCE_QUERY_TYPEHASH, s.requester, s.owner, s.assetId, s.queryTimestamp]));
15
- }
16
14
  export const HANDLE_PREIMAGE_TYPEHASH = keccak256(stringToBytes("HandlePreimage(bytes32 previousHandle,bytes32 previousBlockHash,uint256 blockTimestamp,bytes32 operationHash)"));
17
15
  export function handlePreimageStructHash(s) {
18
16
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "bytes32" }], [HANDLE_PREIMAGE_TYPEHASH, s.previousHandle, s.previousBlockHash, s.blockTimestamp, s.operationHash]));
@@ -21,31 +19,31 @@ export const BLOCK_TYPEHASH = keccak256(stringToBytes("Block(uint256 blockNumber
21
19
  export function blockStructHash(s) {
22
20
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "uint256" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "bytes32" }], [BLOCK_TYPEHASH, s.blockNumber, s.blockHash, s.parentBlockHash, s.parentHandle, s.handle, s.blockTimestamp, s.eventsHash]));
23
21
  }
24
- export const DEPOSIT_ATTESTATION_TYPEHASH = keccak256(stringToBytes("DepositAttestation(bytes ciphertext,bytes32 assetId,bytes32 escapeCommitment,bytes receiverEscapeData)"));
22
+ export const DEPOSIT_ATTESTATION_PAYLOAD_TYPEHASH = keccak256(stringToBytes("DepositAttestationPayload(bytes ciphertext,bytes32 assetId,bytes32 escapeCommitment,bytes receiverEscapeData)"));
23
+ export function depositAttestationPayloadStructHash(s) {
24
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [DEPOSIT_ATTESTATION_PAYLOAD_TYPEHASH, keccak256(s.ciphertext), s.assetId, s.escapeCommitment, keccak256(s.receiverEscapeData)]));
25
+ }
26
+ export const DEPOSIT_ATTESTATION_TYPEHASH = keccak256(stringToBytes("DepositAttestation(DepositAttestationPayload payload,bytes signature)DepositAttestationPayload(bytes ciphertext,bytes32 assetId,bytes32 escapeCommitment,bytes receiverEscapeData)"));
25
27
  export function depositAttestationStructHash(s) {
26
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [DEPOSIT_ATTESTATION_TYPEHASH, keccak256(s.ciphertext), s.assetId, s.escapeCommitment, keccak256(s.receiverEscapeData)]));
28
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [DEPOSIT_ATTESTATION_TYPEHASH, depositAttestationPayloadStructHash(s.payload), keccak256(s.signature)]));
27
29
  }
28
- export const DEPOSIT_TYPEHASH = keccak256(stringToBytes("Deposit(DepositAttestation attestation,AssetMovement assetMovement,uint256 amount,address from,bytes teeAttestationSignature)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)DepositAttestation(bytes ciphertext,bytes32 assetId,bytes32 escapeCommitment,bytes receiverEscapeData)"));
30
+ export const DEPOSIT_TYPEHASH = keccak256(stringToBytes("Deposit(DepositAttestation attestation,Asset asset,AssetMovement assetMovement)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)DepositAttestation(DepositAttestationPayload payload,bytes signature)DepositAttestationPayload(bytes ciphertext,bytes32 assetId,bytes32 escapeCommitment,bytes receiverEscapeData)"));
29
31
  export function depositStructHash(s) {
30
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "address" }, { type: "bytes32" }], [DEPOSIT_TYPEHASH, depositAttestationStructHash(s.attestation), assetMovementStructHash(s.assetMovement), s.amount, s.from, keccak256(s.teeAttestationSignature)]));
31
- }
32
- export const DEPOSIT_ATTESTATION_REQUEST_TYPEHASH = keccak256(stringToBytes("DepositAttestationRequest(address recipient,bytes32 assetId)"));
33
- export function depositAttestationRequestStructHash(s) {
34
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [DEPOSIT_ATTESTATION_REQUEST_TYPEHASH, s.recipient, s.assetId]));
32
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [DEPOSIT_TYPEHASH, depositAttestationStructHash(s.attestation), assetStructHash(s.asset), assetMovementStructHash(s.assetMovement)]));
35
33
  }
36
- export const PERMISSION_TYPEHASH = keccak256(stringToBytes("Permission(address owner,address spender,bytes32 assetId,uint256 allowance,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)"));
34
+ export const PERMISSION_TYPEHASH = keccak256(stringToBytes("Permission(address owner,address spender,bytes32 assetId,uint256 allowance,address[] to,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)"));
37
35
  export function permissionStructHash(s) {
38
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "bytes32" }, { type: "bytes32" }], [PERMISSION_TYPEHASH, s.owner, s.spender, s.assetId, s.allowance, s.start, s.end, s.period, s.agreementHash, s.salt]));
36
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "bytes32" }, { type: "bytes32" }], [PERMISSION_TYPEHASH, s.owner, s.spender, s.assetId, s.allowance, keccak256(concat(s.to.map(e => encodeAbiParameters([{ type: "address" }], [e])))), s.start, s.end, s.period, s.agreementHash, s.salt]));
39
37
  }
40
- export const PERMISSION_ATTESTATION_REQUEST_TYPEHASH = keccak256(stringToBytes("PermissionAttestationRequest(Permission permission,uint64 intentExpiry)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)"));
41
- export function permissionAttestationRequestStructHash(s) {
42
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }], [PERMISSION_ATTESTATION_REQUEST_TYPEHASH, permissionStructHash(s.permission), s.intentExpiry]));
38
+ export const PERMISSION_REQUEST_TYPEHASH = keccak256(stringToBytes("PermissionRequest(Permission permission,uint64 requestExpiry)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,address[] to,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)"));
39
+ export function permissionRequestStructHash(s) {
40
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }], [PERMISSION_REQUEST_TYPEHASH, permissionStructHash(s.permission), s.requestExpiry]));
43
41
  }
44
- export const PERMISSION_ATTESTATION_PAYLOAD_TYPEHASH = keccak256(stringToBytes("PermissionAttestationPayload(bytes32 permissionId,Permission permission,bytes32 draftingHandle)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)"));
42
+ export const PERMISSION_ATTESTATION_PAYLOAD_TYPEHASH = keccak256(stringToBytes("PermissionAttestationPayload(bytes32 permissionId,Permission permission,bytes32 draftingHandle)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,address[] to,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)"));
45
43
  export function permissionAttestationPayloadStructHash(s) {
46
44
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [PERMISSION_ATTESTATION_PAYLOAD_TYPEHASH, s.permissionId, permissionStructHash(s.permission), s.draftingHandle]));
47
45
  }
48
- export const PERMISSION_ATTESTATION_TYPEHASH = keccak256(stringToBytes("PermissionAttestation(PermissionAttestationPayload payload,bytes signature)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)PermissionAttestationPayload(bytes32 permissionId,Permission permission,bytes32 draftingHandle)"));
46
+ export const PERMISSION_ATTESTATION_TYPEHASH = keccak256(stringToBytes("PermissionAttestation(PermissionAttestationPayload payload,bytes signature)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,address[] to,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)PermissionAttestationPayload(bytes32 permissionId,Permission permission,bytes32 draftingHandle)"));
49
47
  export function permissionAttestationStructHash(s) {
50
48
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [PERMISSION_ATTESTATION_TYPEHASH, permissionAttestationPayloadStructHash(s.payload), keccak256(s.signature)]));
51
49
  }
@@ -53,15 +51,15 @@ export const TRANSFER_INTENT_OP_TYPEHASH = keccak256(stringToBytes("TransferInte
53
51
  export function transferIntentOpStructHash(s) {
54
52
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "bytes32" }], [TRANSFER_INTENT_OP_TYPEHASH, s.receiver, s.assetId, s.amount, keccak256(s.memo)]));
55
53
  }
56
- export const WITHDRAWAL_CORE_INTENT_OP_TYPEHASH = keccak256(stringToBytes("WithdrawalCoreIntentOp(address to,bytes32 assetId,uint256 amount,AssetMovement assetMovement)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)"));
54
+ export const WITHDRAWAL_CORE_INTENT_OP_TYPEHASH = keccak256(stringToBytes("WithdrawalCoreIntentOp(Asset asset,AssetMovement[] assetMovements)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)"));
57
55
  export function withdrawalCoreIntentOpStructHash(s) {
58
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "bytes32" }], [WITHDRAWAL_CORE_INTENT_OP_TYPEHASH, s.to, s.assetId, s.amount, assetMovementStructHash(s.assetMovement)]));
56
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [WITHDRAWAL_CORE_INTENT_OP_TYPEHASH, assetStructHash(s.asset), keccak256(concat(s.assetMovements.map(e => assetMovementStructHash(e))))]));
59
57
  }
60
- export const WITHDRAWAL_INTENT_OP_TYPEHASH = keccak256(stringToBytes("WithdrawalIntentOp(WithdrawalCoreIntentOp core,bytes memo)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)WithdrawalCoreIntentOp(address to,bytes32 assetId,uint256 amount,AssetMovement assetMovement)"));
58
+ export const WITHDRAWAL_INTENT_OP_TYPEHASH = keccak256(stringToBytes("WithdrawalIntentOp(WithdrawalCoreIntentOp core,bytes memo)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)WithdrawalCoreIntentOp(Asset asset,AssetMovement[] assetMovements)"));
61
59
  export function withdrawalIntentOpStructHash(s) {
62
60
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [WITHDRAWAL_INTENT_OP_TYPEHASH, withdrawalCoreIntentOpStructHash(s.core), keccak256(s.memo)]));
63
61
  }
64
- export const DEFI_INTERACTION_INTENT_OP_TYPEHASH = keccak256(stringToBytes("DefiInteractionIntentOp(WithdrawalCoreIntentOp withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)WithdrawalCoreIntentOp(address to,bytes32 assetId,uint256 amount,AssetMovement assetMovement)"));
62
+ export const DEFI_INTERACTION_INTENT_OP_TYPEHASH = keccak256(stringToBytes("DefiInteractionIntentOp(WithdrawalCoreIntentOp withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)WithdrawalCoreIntentOp(Asset asset,AssetMovement[] assetMovements)"));
65
63
  export function defiInteractionIntentOpStructHash(s) {
66
64
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [DEFI_INTERACTION_INTENT_OP_TYPEHASH, withdrawalCoreIntentOpStructHash(s.withdrawal), s.defiAdapter, keccak256(s.adapterArgs), keccak256(s.memo)]));
67
65
  }
@@ -73,55 +71,55 @@ export const USER_WIDE_REVOCATION_INTENT_OP_TYPEHASH = keccak256(stringToBytes("
73
71
  export function userWideRevocationIntentOpStructHash(s) {
74
72
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }], [USER_WIDE_REVOCATION_INTENT_OP_TYPEHASH, keccak256(s.empty)]));
75
73
  }
76
- export const GAS_TYPEHASH = keccak256(stringToBytes("Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)"));
74
+ export const GAS_TYPEHASH = keccak256(stringToBytes("Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)"));
77
75
  export function gasStructHash(s) {
78
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }], [GAS_TYPEHASH, s.assetId, s.maxAmount, s.callGasLimit, s.verificationGasLimit, s.preVerificationGas, s.paymasterVerificationGasLimit, s.paymasterPostOpGasLimit, s.maxFeePerGas, s.maxPriorityFeePerGas]));
76
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }], [GAS_TYPEHASH, assetStructHash(s.asset), s.maxAmount, assetMovementStructHash(s.assetMovement), s.callGasLimit, s.verificationGasLimit, s.preVerificationGas, s.paymasterVerificationGasLimit, s.paymasterPostOpGasLimit, s.maxFeePerGas, s.maxPriorityFeePerGas]));
79
77
  }
80
- export const TRANSFER_INTENT_TYPEHASH = keccak256(stringToBytes("TransferIntent(TransferIntentOp op,address signer,Gas gas,bytes32 salt)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)TransferIntentOp(address receiver,bytes32 assetId,uint256 amount,bytes memo)"));
78
+ export const TRANSFER_INTENT_TYPEHASH = keccak256(stringToBytes("TransferIntent(TransferIntentOp op,address signer,Gas gas,bytes32 salt)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)TransferIntentOp(address receiver,bytes32 assetId,uint256 amount,bytes memo)"));
81
79
  export function transferIntentStructHash(s) {
82
80
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [TRANSFER_INTENT_TYPEHASH, transferIntentOpStructHash(s.op), s.signer, gasStructHash(s.gas), s.salt]));
83
81
  }
84
- export const WITHDRAWAL_INTENT_TYPEHASH = keccak256(stringToBytes("WithdrawalIntent(WithdrawalIntentOp op,address signer,Gas gas,bytes32 salt)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)WithdrawalCoreIntentOp(address to,bytes32 assetId,uint256 amount,AssetMovement assetMovement)WithdrawalIntentOp(WithdrawalCoreIntentOp core,bytes memo)"));
82
+ export const WITHDRAWAL_INTENT_TYPEHASH = keccak256(stringToBytes("WithdrawalIntent(WithdrawalIntentOp op,address signer,Gas gas,bytes32 salt)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)WithdrawalCoreIntentOp(Asset asset,AssetMovement[] assetMovements)WithdrawalIntentOp(WithdrawalCoreIntentOp core,bytes memo)"));
85
83
  export function withdrawalIntentStructHash(s) {
86
84
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [WITHDRAWAL_INTENT_TYPEHASH, withdrawalIntentOpStructHash(s.op), s.signer, gasStructHash(s.gas), s.salt]));
87
85
  }
88
- export const DEFI_INTERACTION_INTENT_TYPEHASH = keccak256(stringToBytes("DefiInteractionIntent(DefiInteractionIntentOp op,address signer,Gas gas,bytes32 salt)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)DefiInteractionIntentOp(WithdrawalCoreIntentOp withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)WithdrawalCoreIntentOp(address to,bytes32 assetId,uint256 amount,AssetMovement assetMovement)"));
86
+ export const DEFI_INTERACTION_INTENT_TYPEHASH = keccak256(stringToBytes("DefiInteractionIntent(DefiInteractionIntentOp op,address signer,Gas gas,bytes32 salt)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)DefiInteractionIntentOp(WithdrawalCoreIntentOp withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)WithdrawalCoreIntentOp(Asset asset,AssetMovement[] assetMovements)"));
89
87
  export function defiInteractionIntentStructHash(s) {
90
88
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [DEFI_INTERACTION_INTENT_TYPEHASH, defiInteractionIntentOpStructHash(s.op), s.signer, gasStructHash(s.gas), s.salt]));
91
89
  }
92
- export const INDIVIDUAL_REVOCATION_INTENT_TYPEHASH = keccak256(stringToBytes("IndividualRevocationIntent(IndividualRevocationIntentOp op,address signer,Gas gas,bytes32 salt)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)IndividualRevocationIntentOp(bytes32 permissionId)"));
90
+ export const INDIVIDUAL_REVOCATION_INTENT_TYPEHASH = keccak256(stringToBytes("IndividualRevocationIntent(IndividualRevocationIntentOp op,address signer,Gas gas,bytes32 salt)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)IndividualRevocationIntentOp(bytes32 permissionId)"));
93
91
  export function individualRevocationIntentStructHash(s) {
94
92
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [INDIVIDUAL_REVOCATION_INTENT_TYPEHASH, individualRevocationIntentOpStructHash(s.op), s.signer, gasStructHash(s.gas), s.salt]));
95
93
  }
96
- export const USER_WIDE_REVOCATION_INTENT_TYPEHASH = keccak256(stringToBytes("UserWideRevocationIntent(UserWideRevocationIntentOp op,address signer,Gas gas,bytes32 salt)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)UserWideRevocationIntentOp(bytes empty)"));
94
+ export const USER_WIDE_REVOCATION_INTENT_TYPEHASH = keccak256(stringToBytes("UserWideRevocationIntent(UserWideRevocationIntentOp op,address signer,Gas gas,bytes32 salt)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)UserWideRevocationIntentOp(bytes empty)"));
97
95
  export function userWideRevocationIntentStructHash(s) {
98
96
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [USER_WIDE_REVOCATION_INTENT_TYPEHASH, userWideRevocationIntentOpStructHash(s.op), s.signer, gasStructHash(s.gas), s.salt]));
99
97
  }
100
- export const DELEGATED_TRANSFER_INTENT_TYPEHASH = keccak256(stringToBytes("DelegatedTransferIntent(TransferIntent intent,address spender,PermissionAttestation attestation)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)PermissionAttestation(PermissionAttestationPayload payload,bytes signature)PermissionAttestationPayload(bytes32 permissionId,Permission permission,bytes32 draftingHandle)TransferIntent(TransferIntentOp op,address signer,Gas gas,bytes32 salt)TransferIntentOp(address receiver,bytes32 assetId,uint256 amount,bytes memo)"));
98
+ export const DELEGATED_TRANSFER_INTENT_TYPEHASH = keccak256(stringToBytes("DelegatedTransferIntent(TransferIntent intent,address spender,bytes32 permissionId)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)TransferIntent(TransferIntentOp op,address signer,Gas gas,bytes32 salt)TransferIntentOp(address receiver,bytes32 assetId,uint256 amount,bytes memo)"));
101
99
  export function delegatedTransferIntentStructHash(s) {
102
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [DELEGATED_TRANSFER_INTENT_TYPEHASH, transferIntentStructHash(s.intent), s.spender, permissionAttestationStructHash(s.attestation)]));
100
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [DELEGATED_TRANSFER_INTENT_TYPEHASH, transferIntentStructHash(s.intent), s.spender, s.permissionId]));
103
101
  }
104
- export const DELEGATED_WITHDRAWAL_INTENT_TYPEHASH = keccak256(stringToBytes("DelegatedWithdrawalIntent(WithdrawalIntent intent,address spender,PermissionAttestation attestation)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)PermissionAttestation(PermissionAttestationPayload payload,bytes signature)PermissionAttestationPayload(bytes32 permissionId,Permission permission,bytes32 draftingHandle)WithdrawalCoreIntentOp(address to,bytes32 assetId,uint256 amount,AssetMovement assetMovement)WithdrawalIntent(WithdrawalIntentOp op,address signer,Gas gas,bytes32 salt)WithdrawalIntentOp(WithdrawalCoreIntentOp core,bytes memo)"));
102
+ export const DELEGATED_WITHDRAWAL_INTENT_TYPEHASH = keccak256(stringToBytes("DelegatedWithdrawalIntent(WithdrawalIntent intent,address spender,bytes32 permissionId)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)WithdrawalCoreIntentOp(Asset asset,AssetMovement[] assetMovements)WithdrawalIntent(WithdrawalIntentOp op,address signer,Gas gas,bytes32 salt)WithdrawalIntentOp(WithdrawalCoreIntentOp core,bytes memo)"));
105
103
  export function delegatedWithdrawalIntentStructHash(s) {
106
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [DELEGATED_WITHDRAWAL_INTENT_TYPEHASH, withdrawalIntentStructHash(s.intent), s.spender, permissionAttestationStructHash(s.attestation)]));
104
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [DELEGATED_WITHDRAWAL_INTENT_TYPEHASH, withdrawalIntentStructHash(s.intent), s.spender, s.permissionId]));
107
105
  }
108
- export const DELEGATED_DEFI_INTERACTION_INTENT_TYPEHASH = keccak256(stringToBytes("DelegatedDefiInteractionIntent(DefiInteractionIntent intent,address spender,PermissionAttestation attestation)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)DefiInteractionIntent(DefiInteractionIntentOp op,address signer,Gas gas,bytes32 salt)DefiInteractionIntentOp(WithdrawalCoreIntentOp withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)Gas(bytes32 assetId,uint256 maxAmount,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)PermissionAttestation(PermissionAttestationPayload payload,bytes signature)PermissionAttestationPayload(bytes32 permissionId,Permission permission,bytes32 draftingHandle)WithdrawalCoreIntentOp(address to,bytes32 assetId,uint256 amount,AssetMovement assetMovement)"));
106
+ export const DELEGATED_DEFI_INTERACTION_INTENT_TYPEHASH = keccak256(stringToBytes("DelegatedDefiInteractionIntent(DefiInteractionIntent intent,address spender,bytes32 permissionId)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)DefiInteractionIntent(DefiInteractionIntentOp op,address signer,Gas gas,bytes32 salt)DefiInteractionIntentOp(WithdrawalCoreIntentOp withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)Gas(Asset asset,uint256 maxAmount,AssetMovement assetMovement,uint256 callGasLimit,uint256 verificationGasLimit,uint256 preVerificationGas,uint256 paymasterVerificationGasLimit,uint256 paymasterPostOpGasLimit,uint256 maxFeePerGas,uint256 maxPriorityFeePerGas)WithdrawalCoreIntentOp(Asset asset,AssetMovement[] assetMovements)"));
109
107
  export function delegatedDefiInteractionIntentStructHash(s) {
110
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [DELEGATED_DEFI_INTERACTION_INTENT_TYPEHASH, defiInteractionIntentStructHash(s.intent), s.spender, permissionAttestationStructHash(s.attestation)]));
108
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [DELEGATED_DEFI_INTERACTION_INTENT_TYPEHASH, defiInteractionIntentStructHash(s.intent), s.spender, s.permissionId]));
111
109
  }
112
110
  export const TRANSFER_TYPEHASH = keccak256(stringToBytes("Transfer(bytes32 draftingHandle,uint64 draftingTimestamp,bytes32 nullifier,bytes32 senderEscapeCommitment,bytes32 receiverEscapeCommitment,bytes senderEscapeData,bytes receiverEscapeData,bytes ciphertext,bytes memo)"));
113
111
  export function transferStructHash(s) {
114
112
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [TRANSFER_TYPEHASH, s.draftingHandle, s.draftingTimestamp, s.nullifier, s.senderEscapeCommitment, s.receiverEscapeCommitment, keccak256(s.senderEscapeData), keccak256(s.receiverEscapeData), keccak256(s.ciphertext), keccak256(s.memo)]));
115
113
  }
116
- export const WITHDRAWAL_CORE_TYPEHASH = keccak256(stringToBytes("WithdrawalCore(address to,uint256 amount,bytes32 nullifier,bytes32 draftingHandle,uint64 draftingTimestamp,AssetMovement assetMovement,bytes ciphertext,bytes32 senderEscapeCommitment,bytes senderEscapeData)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)"));
114
+ export const WITHDRAWAL_CORE_TYPEHASH = keccak256(stringToBytes("WithdrawalCore(Asset asset,AssetMovement[] assetMovements,bytes32 nullifier,bytes32 draftingHandle,uint64 draftingTimestamp,bytes ciphertext,bytes32 senderEscapeCommitment,bytes senderEscapeData)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)"));
117
115
  export function withdrawalCoreStructHash(s) {
118
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "uint256" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [WITHDRAWAL_CORE_TYPEHASH, s.to, s.amount, s.nullifier, s.draftingHandle, s.draftingTimestamp, assetMovementStructHash(s.assetMovement), keccak256(s.ciphertext), s.senderEscapeCommitment, keccak256(s.senderEscapeData)]));
116
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [WITHDRAWAL_CORE_TYPEHASH, assetStructHash(s.asset), keccak256(concat(s.assetMovements.map(e => assetMovementStructHash(e)))), s.nullifier, s.draftingHandle, s.draftingTimestamp, keccak256(s.ciphertext), s.senderEscapeCommitment, keccak256(s.senderEscapeData)]));
119
117
  }
120
- export const WITHDRAWAL_TYPEHASH = keccak256(stringToBytes("Withdrawal(WithdrawalCore core,bytes memo)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)WithdrawalCore(address to,uint256 amount,bytes32 nullifier,bytes32 draftingHandle,uint64 draftingTimestamp,AssetMovement assetMovement,bytes ciphertext,bytes32 senderEscapeCommitment,bytes senderEscapeData)"));
118
+ export const WITHDRAWAL_TYPEHASH = keccak256(stringToBytes("Withdrawal(WithdrawalCore core,bytes memo)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)WithdrawalCore(Asset asset,AssetMovement[] assetMovements,bytes32 nullifier,bytes32 draftingHandle,uint64 draftingTimestamp,bytes ciphertext,bytes32 senderEscapeCommitment,bytes senderEscapeData)"));
121
119
  export function withdrawalStructHash(s) {
122
120
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [WITHDRAWAL_TYPEHASH, withdrawalCoreStructHash(s.core), keccak256(s.memo)]));
123
121
  }
124
- export const DEFI_INTERACTION_TYPEHASH = keccak256(stringToBytes("DefiInteraction(WithdrawalCore withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)AssetMovement(address assetAdapter,bytes assetIdentificationArgs,bytes movementArgs)WithdrawalCore(address to,uint256 amount,bytes32 nullifier,bytes32 draftingHandle,uint64 draftingTimestamp,AssetMovement assetMovement,bytes ciphertext,bytes32 senderEscapeCommitment,bytes senderEscapeData)"));
122
+ export const DEFI_INTERACTION_TYPEHASH = keccak256(stringToBytes("DefiInteraction(WithdrawalCore withdrawal,address defiAdapter,bytes adapterArgs,bytes memo)Asset(uint8 standard,address token,uint256 tokenId)AssetMovement(address account,address assetAdapter,bytes movementArgs)WithdrawalCore(Asset asset,AssetMovement[] assetMovements,bytes32 nullifier,bytes32 draftingHandle,uint64 draftingTimestamp,bytes ciphertext,bytes32 senderEscapeCommitment,bytes senderEscapeData)"));
125
123
  export function defiInteractionStructHash(s) {
126
124
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [DEFI_INTERACTION_TYPEHASH, withdrawalCoreStructHash(s.withdrawal), s.defiAdapter, keccak256(s.adapterArgs), keccak256(s.memo)]));
127
125
  }
@@ -161,25 +159,104 @@ export const RECEIVER_ESCAPE_PLAINTEXT_TYPEHASH = keccak256(stringToBytes("Recei
161
159
  export function receiverEscapePlaintextStructHash(s) {
162
160
  return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "bytes32" }, { type: "uint64" }, { type: "uint64" }], [RECEIVER_ESCAPE_PLAINTEXT_TYPEHASH, s.receiver, s.assetId, s.draftingHandle, s.receiveAmount, s.balanceSnapshot, s.chequeNullifier, s.senderChequeNumber, s.oldestPossiblyOutstandingSend]));
163
161
  }
164
- export const GET_PERMISSIONS_BY_OWNER_TYPEHASH = keccak256(stringToBytes("GetPermissionsByOwner(address requester,bool includeExpired,uint64 timestamp)"));
162
+ export const GET_PERMISSIONS_BY_OWNER_TYPEHASH = keccak256(stringToBytes("GetPermissionsByOwner(address requester,bool includeExpired)"));
165
163
  export function getPermissionsByOwnerStructHash(s) {
166
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bool" }, { type: "uint64" }], [GET_PERMISSIONS_BY_OWNER_TYPEHASH, s.requester, s.includeExpired, s.timestamp]));
164
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bool" }], [GET_PERMISSIONS_BY_OWNER_TYPEHASH, s.requester, s.includeExpired]));
167
165
  }
168
- export const GET_PERMISSIONS_BY_SPENDER_TYPEHASH = keccak256(stringToBytes("GetPermissionsBySpender(address requester,bool includeExpired,uint64 timestamp)"));
166
+ export const GET_PERMISSIONS_BY_SPENDER_TYPEHASH = keccak256(stringToBytes("GetPermissionsBySpender(address requester,bool includeExpired)"));
169
167
  export function getPermissionsBySpenderStructHash(s) {
170
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bool" }, { type: "uint64" }], [GET_PERMISSIONS_BY_SPENDER_TYPEHASH, s.requester, s.includeExpired, s.timestamp]));
168
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bool" }], [GET_PERMISSIONS_BY_SPENDER_TYPEHASH, s.requester, s.includeExpired]));
171
169
  }
172
- export const GET_PERMISSION_DETAILS_TYPEHASH = keccak256(stringToBytes("GetPermissionDetails(address requester,bytes32 permissionId,uint64 timestamp)"));
170
+ export const GET_PERMISSION_DETAILS_TYPEHASH = keccak256(stringToBytes("GetPermissionDetails(address requester,bytes32 permissionId)"));
173
171
  export function getPermissionDetailsStructHash(s) {
174
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "uint64" }], [GET_PERMISSION_DETAILS_TYPEHASH, s.requester, s.permissionId, s.timestamp]));
172
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [GET_PERMISSION_DETAILS_TYPEHASH, s.requester, s.permissionId]));
175
173
  }
176
- export const GET_SPENDABLE_TYPEHASH = keccak256(stringToBytes("GetSpendable(address requester,bytes32 permissionId,uint64 timestamp)"));
174
+ export const GET_SPENDABLE_TYPEHASH = keccak256(stringToBytes("GetSpendable(address requester,bytes32 permissionId)"));
177
175
  export function getSpendableStructHash(s) {
178
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "uint64" }], [GET_SPENDABLE_TYPEHASH, s.requester, s.permissionId, s.timestamp]));
176
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }], [GET_SPENDABLE_TYPEHASH, s.requester, s.permissionId]));
179
177
  }
180
- export const GET_OWNER_GENERATION_TYPEHASH = keccak256(stringToBytes("GetOwnerGeneration(address requester,uint64 timestamp)"));
178
+ export const GET_OWNER_GENERATION_TYPEHASH = keccak256(stringToBytes("GetOwnerGeneration(address requester)"));
181
179
  export function getOwnerGenerationStructHash(s) {
182
- return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "uint64" }], [GET_OWNER_GENERATION_TYPEHASH, s.requester, s.timestamp]));
180
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }], [GET_OWNER_GENERATION_TYPEHASH, s.requester]));
181
+ }
182
+ export const SPENDABLE_RESPONSE_TYPEHASH = keccak256(stringToBytes("SpendableResponse(address requester,bytes32 permissionId,uint256 spendable,bool found,bytes32 draftingHandle,uint64 draftingTimestamp)"));
183
+ export function spendableResponseStructHash(s) {
184
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "bool" }, { type: "bytes32" }, { type: "uint64" }], [SPENDABLE_RESPONSE_TYPEHASH, s.requester, s.permissionId, s.spendable, s.found, s.draftingHandle, s.draftingTimestamp]));
185
+ }
186
+ export const OWNER_GENERATION_RESPONSE_TYPEHASH = keccak256(stringToBytes("OwnerGenerationResponse(address requester,uint64 generation,bytes32 draftingHandle,uint64 draftingTimestamp)"));
187
+ export function ownerGenerationResponseStructHash(s) {
188
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "uint64" }, { type: "bytes32" }, { type: "uint64" }], [OWNER_GENERATION_RESPONSE_TYPEHASH, s.requester, s.generation, s.draftingHandle, s.draftingTimestamp]));
189
+ }
190
+ export const PERMISSION_INFO_TYPEHASH = keccak256(stringToBytes("PermissionInfo(bytes32 permissionId,Permission terms,uint256 spentInCurrentPeriod,uint256 availableAllowance,uint8 status,uint64 currentPeriodStart)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,address[] to,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)"));
191
+ export function permissionInfoStructHash(s) {
192
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "uint8" }, { type: "uint64" }], [PERMISSION_INFO_TYPEHASH, s.permissionId, permissionStructHash(s.terms), s.spentInCurrentPeriod, s.availableAllowance, s.status, s.currentPeriodStart]));
193
+ }
194
+ export const PERMISSION_DETAILS_RESPONSE_TYPEHASH = keccak256(stringToBytes("PermissionDetailsResponse(address requester,bytes32 draftingHandle,uint64 draftingTimestamp,bool found,PermissionInfo permission)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,address[] to,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)PermissionInfo(bytes32 permissionId,Permission terms,uint256 spentInCurrentPeriod,uint256 availableAllowance,uint8 status,uint64 currentPeriodStart)"));
195
+ export function permissionDetailsResponseStructHash(s) {
196
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "uint64" }, { type: "bool" }, { type: "bytes32" }], [PERMISSION_DETAILS_RESPONSE_TYPEHASH, s.requester, s.draftingHandle, s.draftingTimestamp, s.found, permissionInfoStructHash(s.permission)]));
197
+ }
198
+ export const PERMISSION_LIST_RESPONSE_TYPEHASH = keccak256(stringToBytes("PermissionListResponse(address requester,bool byOwner,bool includeExpired,bytes32 draftingHandle,uint64 draftingTimestamp,PermissionInfo[] permissions)Permission(address owner,address spender,bytes32 assetId,uint256 allowance,address[] to,uint256 start,uint256 end,uint256 period,bytes32 agreementHash,bytes32 salt)PermissionInfo(bytes32 permissionId,Permission terms,uint256 spentInCurrentPeriod,uint256 availableAllowance,uint8 status,uint64 currentPeriodStart)"));
199
+ export function permissionListResponseStructHash(s) {
200
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bool" }, { type: "bool" }, { type: "bytes32" }, { type: "uint64" }, { type: "bytes32" }], [PERMISSION_LIST_RESPONSE_TYPEHASH, s.requester, s.byOwner, s.includeExpired, s.draftingHandle, s.draftingTimestamp, keccak256(concat(s.permissions.map(e => permissionInfoStructHash(e))))]));
201
+ }
202
+ export const VIEWING_SESSION_TYPEHASH = keccak256(stringToBytes("ViewingSession(address owner,uint64 issuedAt,uint64 expiresAt,uint64 periodStart,uint64 periodEnd,bytes responseKey,bytes32 salt)"));
203
+ export function viewingSessionStructHash(s) {
204
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "uint64" }, { type: "uint64" }, { type: "uint64" }, { type: "uint64" }, { type: "bytes32" }, { type: "bytes32" }], [VIEWING_SESSION_TYPEHASH, s.owner, s.issuedAt, s.expiresAt, s.periodStart, s.periodEnd, keccak256(s.responseKey), s.salt]));
205
+ }
206
+ export const BALANCE_QUERY_TYPEHASH = keccak256(stringToBytes("BalanceQuery(ViewingSession session,bytes32 assetId)ViewingSession(address owner,uint64 issuedAt,uint64 expiresAt,uint64 periodStart,uint64 periodEnd,bytes responseKey,bytes32 salt)"));
207
+ export function balanceQueryStructHash(s) {
208
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [BALANCE_QUERY_TYPEHASH, viewingSessionStructHash(s.session), s.assetId]));
209
+ }
210
+ export const PORTFOLIO_QUERY_TYPEHASH = keccak256(stringToBytes("PortfolioQuery(ViewingSession session)ViewingSession(address owner,uint64 issuedAt,uint64 expiresAt,uint64 periodStart,uint64 periodEnd,bytes responseKey,bytes32 salt)"));
211
+ export function portfolioQueryStructHash(s) {
212
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }], [PORTFOLIO_QUERY_TYPEHASH, viewingSessionStructHash(s.session)]));
213
+ }
214
+ export const HISTORY_CURSOR_TYPEHASH = keccak256(stringToBytes("HistoryCursor(bytes32 anchorHandle,uint64 afterTimestamp,uint64 afterOpIndex)"));
215
+ export function historyCursorStructHash(s) {
216
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }, { type: "uint64" }], [HISTORY_CURSOR_TYPEHASH, s.anchorHandle, s.afterTimestamp, s.afterOpIndex]));
217
+ }
218
+ export const REQUEST_PAGINATION_TYPEHASH = keccak256(stringToBytes("RequestPagination(HistoryCursor cursor,uint32 limit)HistoryCursor(bytes32 anchorHandle,uint64 afterTimestamp,uint64 afterOpIndex)"));
219
+ export function requestPaginationStructHash(s) {
220
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint32" }], [REQUEST_PAGINATION_TYPEHASH, historyCursorStructHash(s.cursor), s.limit]));
221
+ }
222
+ export const BALANCE_HISTORY_QUERY_TYPEHASH = keccak256(stringToBytes("BalanceHistoryQuery(ViewingSession session,bytes32 assetId,RequestPagination pagination)HistoryCursor(bytes32 anchorHandle,uint64 afterTimestamp,uint64 afterOpIndex)RequestPagination(HistoryCursor cursor,uint32 limit)ViewingSession(address owner,uint64 issuedAt,uint64 expiresAt,uint64 periodStart,uint64 periodEnd,bytes responseKey,bytes32 salt)"));
223
+ export function balanceHistoryQueryStructHash(s) {
224
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [BALANCE_HISTORY_QUERY_TYPEHASH, viewingSessionStructHash(s.session), s.assetId, requestPaginationStructHash(s.pagination)]));
225
+ }
226
+ export const PORTFOLIO_HISTORY_QUERY_TYPEHASH = keccak256(stringToBytes("PortfolioHistoryQuery(ViewingSession session,RequestPagination pagination)HistoryCursor(bytes32 anchorHandle,uint64 afterTimestamp,uint64 afterOpIndex)RequestPagination(HistoryCursor cursor,uint32 limit)ViewingSession(address owner,uint64 issuedAt,uint64 expiresAt,uint64 periodStart,uint64 periodEnd,bytes responseKey,bytes32 salt)"));
227
+ export function portfolioHistoryQueryStructHash(s) {
228
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [PORTFOLIO_HISTORY_QUERY_TYPEHASH, viewingSessionStructHash(s.session), requestPaginationStructHash(s.pagination)]));
229
+ }
230
+ export const HISTORY_ENTRY_TYPEHASH = keccak256(stringToBytes("HistoryEntry(uint64 opIndex,uint8 kind,address sender,address receiver,bytes32 assetId,uint256 amount,uint256 balanceAfter,bytes32 nullifier,bytes memo,bytes32 handle,uint64 blockTimestamp,uint64 blockNumber,bytes32 blockHash,bytes32 txHash)"));
231
+ export function historyEntryStructHash(s) {
232
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "uint64" }, { type: "uint8" }, { type: "address" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }, { type: "uint64" }, { type: "bytes32" }, { type: "bytes32" }], [HISTORY_ENTRY_TYPEHASH, s.opIndex, s.kind, s.sender, s.receiver, s.assetId, s.amount, s.balanceAfter, s.nullifier, keccak256(s.memo), s.handle, s.blockTimestamp, s.blockNumber, s.blockHash, s.txHash]));
233
+ }
234
+ export const RESPONSE_PAGINATION_TYPEHASH = keccak256(stringToBytes("ResponsePagination(bytes32 anchorHandle,bytes32 anchorBlockHash,uint64 anchorTimestamp,uint64 nextTimestamp,uint64 nextOpIndex,bool hasMore)"));
235
+ export function responsePaginationStructHash(s) {
236
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }, { type: "uint64" }, { type: "uint64" }, { type: "bool" }], [RESPONSE_PAGINATION_TYPEHASH, s.anchorHandle, s.anchorBlockHash, s.anchorTimestamp, s.nextTimestamp, s.nextOpIndex, s.hasMore]));
237
+ }
238
+ export const BALANCE_HISTORY_RESPONSE_TYPEHASH = keccak256(stringToBytes("BalanceHistoryResponse(address owner,bytes32 assetId,ResponsePagination pagination,HistoryEntry[] entries)HistoryEntry(uint64 opIndex,uint8 kind,address sender,address receiver,bytes32 assetId,uint256 amount,uint256 balanceAfter,bytes32 nullifier,bytes memo,bytes32 handle,uint64 blockTimestamp,uint64 blockNumber,bytes32 blockHash,bytes32 txHash)ResponsePagination(bytes32 anchorHandle,bytes32 anchorBlockHash,uint64 anchorTimestamp,uint64 nextTimestamp,uint64 nextOpIndex,bool hasMore)"));
239
+ export function balanceHistoryResponseStructHash(s) {
240
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }, { type: "bytes32" }], [BALANCE_HISTORY_RESPONSE_TYPEHASH, s.owner, s.assetId, responsePaginationStructHash(s.pagination), keccak256(concat(s.entries.map(e => historyEntryStructHash(e))))]));
241
+ }
242
+ export const PORTFOLIO_HISTORY_RESPONSE_TYPEHASH = keccak256(stringToBytes("PortfolioHistoryResponse(address owner,ResponsePagination pagination,HistoryEntry[] entries)HistoryEntry(uint64 opIndex,uint8 kind,address sender,address receiver,bytes32 assetId,uint256 amount,uint256 balanceAfter,bytes32 nullifier,bytes memo,bytes32 handle,uint64 blockTimestamp,uint64 blockNumber,bytes32 blockHash,bytes32 txHash)ResponsePagination(bytes32 anchorHandle,bytes32 anchorBlockHash,uint64 anchorTimestamp,uint64 nextTimestamp,uint64 nextOpIndex,bool hasMore)"));
243
+ export function portfolioHistoryResponseStructHash(s) {
244
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }], [PORTFOLIO_HISTORY_RESPONSE_TYPEHASH, s.owner, responsePaginationStructHash(s.pagination), keccak256(concat(s.entries.map(e => historyEntryStructHash(e))))]));
245
+ }
246
+ export const BALANCE_RESPONSE_TYPEHASH = keccak256(stringToBytes("BalanceResponse(address owner,bytes32 assetId,uint256 bankBalance,uint256 outstandingBalance,uint256 bookBalance,bytes32 anchorHandle,bytes32 anchorBlockHash)"));
247
+ export function balanceResponseStructHash(s) {
248
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "uint256" }, { type: "uint256" }, { type: "bytes32" }, { type: "bytes32" }], [BALANCE_RESPONSE_TYPEHASH, s.owner, s.assetId, s.bankBalance, s.outstandingBalance, s.bookBalance, s.anchorHandle, s.anchorBlockHash]));
249
+ }
250
+ export const ASSET_BALANCE_TYPEHASH = keccak256(stringToBytes("AssetBalance(bytes32 assetId,uint256 bankBalance)"));
251
+ export function assetBalanceStructHash(s) {
252
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "bytes32" }, { type: "uint256" }], [ASSET_BALANCE_TYPEHASH, s.assetId, s.bankBalance]));
253
+ }
254
+ export const PORTFOLIO_RESPONSE_TYPEHASH = keccak256(stringToBytes("PortfolioResponse(address owner,bytes32 anchorHandle,bytes32 anchorBlockHash,uint64 anchorTimestamp,AssetBalance[] balances)AssetBalance(bytes32 assetId,uint256 bankBalance)"));
255
+ export function portfolioResponseStructHash(s) {
256
+ return keccak256(encodeAbiParameters([{ type: "bytes32" }, { type: "address" }, { type: "bytes32" }, { type: "bytes32" }, { type: "uint64" }, { type: "bytes32" }], [PORTFOLIO_RESPONSE_TYPEHASH, s.owner, s.anchorHandle, s.anchorBlockHash, s.anchorTimestamp, keccak256(concat(s.balances.map(e => assetBalanceStructHash(e))))]));
257
+ }
258
+ export function assetDigest(s, domainSeparator) {
259
+ return keccak256(concat(["0x1901", domainSeparator, assetStructHash(s)]));
183
260
  }
184
261
  export function assetMovementDigest(s, domainSeparator) {
185
262
  return keccak256(concat(["0x1901", domainSeparator, assetMovementStructHash(s)]));
@@ -187,29 +264,26 @@ export function assetMovementDigest(s, domainSeparator) {
187
264
  export function callDigest(s, domainSeparator) {
188
265
  return keccak256(concat(["0x1901", domainSeparator, callStructHash(s)]));
189
266
  }
190
- export function balanceQueryDigest(s, domainSeparator) {
191
- return keccak256(concat(["0x1901", domainSeparator, balanceQueryStructHash(s)]));
192
- }
193
267
  export function handlePreimageDigest(s, domainSeparator) {
194
268
  return keccak256(concat(["0x1901", domainSeparator, handlePreimageStructHash(s)]));
195
269
  }
196
270
  export function blockDigest(s, domainSeparator) {
197
271
  return keccak256(concat(["0x1901", domainSeparator, blockStructHash(s)]));
198
272
  }
273
+ export function depositAttestationPayloadDigest(s, domainSeparator) {
274
+ return keccak256(concat(["0x1901", domainSeparator, depositAttestationPayloadStructHash(s)]));
275
+ }
199
276
  export function depositAttestationDigest(s, domainSeparator) {
200
277
  return keccak256(concat(["0x1901", domainSeparator, depositAttestationStructHash(s)]));
201
278
  }
202
279
  export function depositDigest(s, domainSeparator) {
203
280
  return keccak256(concat(["0x1901", domainSeparator, depositStructHash(s)]));
204
281
  }
205
- export function depositAttestationRequestDigest(s, domainSeparator) {
206
- return keccak256(concat(["0x1901", domainSeparator, depositAttestationRequestStructHash(s)]));
207
- }
208
282
  export function permissionDigest(s, domainSeparator) {
209
283
  return keccak256(concat(["0x1901", domainSeparator, permissionStructHash(s)]));
210
284
  }
211
- export function permissionAttestationRequestDigest(s, domainSeparator) {
212
- return keccak256(concat(["0x1901", domainSeparator, permissionAttestationRequestStructHash(s)]));
285
+ export function permissionRequestDigest(s, domainSeparator) {
286
+ return keccak256(concat(["0x1901", domainSeparator, permissionRequestStructHash(s)]));
213
287
  }
214
288
  export function permissionAttestationPayloadDigest(s, domainSeparator) {
215
289
  return keccak256(concat(["0x1901", domainSeparator, permissionAttestationPayloadStructHash(s)]));
@@ -316,3 +390,439 @@ export function getSpendableDigest(s, domainSeparator) {
316
390
  export function getOwnerGenerationDigest(s, domainSeparator) {
317
391
  return keccak256(concat(["0x1901", domainSeparator, getOwnerGenerationStructHash(s)]));
318
392
  }
393
+ export function spendableResponseDigest(s, domainSeparator) {
394
+ return keccak256(concat(["0x1901", domainSeparator, spendableResponseStructHash(s)]));
395
+ }
396
+ export function ownerGenerationResponseDigest(s, domainSeparator) {
397
+ return keccak256(concat(["0x1901", domainSeparator, ownerGenerationResponseStructHash(s)]));
398
+ }
399
+ export function permissionInfoDigest(s, domainSeparator) {
400
+ return keccak256(concat(["0x1901", domainSeparator, permissionInfoStructHash(s)]));
401
+ }
402
+ export function permissionDetailsResponseDigest(s, domainSeparator) {
403
+ return keccak256(concat(["0x1901", domainSeparator, permissionDetailsResponseStructHash(s)]));
404
+ }
405
+ export function permissionListResponseDigest(s, domainSeparator) {
406
+ return keccak256(concat(["0x1901", domainSeparator, permissionListResponseStructHash(s)]));
407
+ }
408
+ export function viewingSessionDigest(s, domainSeparator) {
409
+ return keccak256(concat(["0x1901", domainSeparator, viewingSessionStructHash(s)]));
410
+ }
411
+ export function balanceQueryDigest(s, domainSeparator) {
412
+ return keccak256(concat(["0x1901", domainSeparator, balanceQueryStructHash(s)]));
413
+ }
414
+ export function portfolioQueryDigest(s, domainSeparator) {
415
+ return keccak256(concat(["0x1901", domainSeparator, portfolioQueryStructHash(s)]));
416
+ }
417
+ export function historyCursorDigest(s, domainSeparator) {
418
+ return keccak256(concat(["0x1901", domainSeparator, historyCursorStructHash(s)]));
419
+ }
420
+ export function requestPaginationDigest(s, domainSeparator) {
421
+ return keccak256(concat(["0x1901", domainSeparator, requestPaginationStructHash(s)]));
422
+ }
423
+ export function balanceHistoryQueryDigest(s, domainSeparator) {
424
+ return keccak256(concat(["0x1901", domainSeparator, balanceHistoryQueryStructHash(s)]));
425
+ }
426
+ export function portfolioHistoryQueryDigest(s, domainSeparator) {
427
+ return keccak256(concat(["0x1901", domainSeparator, portfolioHistoryQueryStructHash(s)]));
428
+ }
429
+ export function historyEntryDigest(s, domainSeparator) {
430
+ return keccak256(concat(["0x1901", domainSeparator, historyEntryStructHash(s)]));
431
+ }
432
+ export function responsePaginationDigest(s, domainSeparator) {
433
+ return keccak256(concat(["0x1901", domainSeparator, responsePaginationStructHash(s)]));
434
+ }
435
+ export function balanceHistoryResponseDigest(s, domainSeparator) {
436
+ return keccak256(concat(["0x1901", domainSeparator, balanceHistoryResponseStructHash(s)]));
437
+ }
438
+ export function portfolioHistoryResponseDigest(s, domainSeparator) {
439
+ return keccak256(concat(["0x1901", domainSeparator, portfolioHistoryResponseStructHash(s)]));
440
+ }
441
+ export function balanceResponseDigest(s, domainSeparator) {
442
+ return keccak256(concat(["0x1901", domainSeparator, balanceResponseStructHash(s)]));
443
+ }
444
+ export function assetBalanceDigest(s, domainSeparator) {
445
+ return keccak256(concat(["0x1901", domainSeparator, assetBalanceStructHash(s)]));
446
+ }
447
+ export function portfolioResponseDigest(s, domainSeparator) {
448
+ return keccak256(concat(["0x1901", domainSeparator, portfolioResponseStructHash(s)]));
449
+ }
450
+ export const EIP712_TYPES = {
451
+ Asset: [
452
+ { name: "standard", type: "uint8" },
453
+ { name: "token", type: "address" },
454
+ { name: "tokenId", type: "uint256" }
455
+ ],
456
+ AssetMovement: [
457
+ { name: "account", type: "address" },
458
+ { name: "assetAdapter", type: "address" },
459
+ { name: "movementArgs", type: "bytes" }
460
+ ],
461
+ Call: [
462
+ { name: "target", type: "address" },
463
+ { name: "value", type: "uint256" },
464
+ { name: "data", type: "bytes" }
465
+ ],
466
+ HandlePreimage: [
467
+ { name: "previousHandle", type: "bytes32" },
468
+ { name: "previousBlockHash", type: "bytes32" },
469
+ { name: "blockTimestamp", type: "uint256" },
470
+ { name: "operationHash", type: "bytes32" }
471
+ ],
472
+ Block: [
473
+ { name: "blockNumber", type: "uint256" },
474
+ { name: "blockHash", type: "bytes32" },
475
+ { name: "parentBlockHash", type: "bytes32" },
476
+ { name: "parentHandle", type: "bytes32" },
477
+ { name: "handle", type: "bytes32" },
478
+ { name: "blockTimestamp", type: "uint256" },
479
+ { name: "eventsHash", type: "bytes32" }
480
+ ],
481
+ DepositAttestationPayload: [
482
+ { name: "ciphertext", type: "bytes" },
483
+ { name: "assetId", type: "bytes32" },
484
+ { name: "escapeCommitment", type: "bytes32" },
485
+ { name: "receiverEscapeData", type: "bytes" }
486
+ ],
487
+ DepositAttestation: [
488
+ { name: "payload", type: "DepositAttestationPayload" },
489
+ { name: "signature", type: "bytes" }
490
+ ],
491
+ Deposit: [
492
+ { name: "attestation", type: "DepositAttestation" },
493
+ { name: "asset", type: "Asset" },
494
+ { name: "assetMovement", type: "AssetMovement" }
495
+ ],
496
+ Permission: [
497
+ { name: "owner", type: "address" },
498
+ { name: "spender", type: "address" },
499
+ { name: "assetId", type: "bytes32" },
500
+ { name: "allowance", type: "uint256" },
501
+ { name: "to", type: "address[]" },
502
+ { name: "start", type: "uint256" },
503
+ { name: "end", type: "uint256" },
504
+ { name: "period", type: "uint256" },
505
+ { name: "agreementHash", type: "bytes32" },
506
+ { name: "salt", type: "bytes32" }
507
+ ],
508
+ PermissionRequest: [
509
+ { name: "permission", type: "Permission" },
510
+ { name: "requestExpiry", type: "uint64" }
511
+ ],
512
+ PermissionAttestationPayload: [
513
+ { name: "permissionId", type: "bytes32" },
514
+ { name: "permission", type: "Permission" },
515
+ { name: "draftingHandle", type: "bytes32" }
516
+ ],
517
+ PermissionAttestation: [
518
+ { name: "payload", type: "PermissionAttestationPayload" },
519
+ { name: "signature", type: "bytes" }
520
+ ],
521
+ TransferIntentOp: [
522
+ { name: "receiver", type: "address" },
523
+ { name: "assetId", type: "bytes32" },
524
+ { name: "amount", type: "uint256" },
525
+ { name: "memo", type: "bytes" }
526
+ ],
527
+ WithdrawalCoreIntentOp: [
528
+ { name: "asset", type: "Asset" },
529
+ { name: "assetMovements", type: "AssetMovement[]" }
530
+ ],
531
+ WithdrawalIntentOp: [
532
+ { name: "core", type: "WithdrawalCoreIntentOp" },
533
+ { name: "memo", type: "bytes" }
534
+ ],
535
+ DefiInteractionIntentOp: [
536
+ { name: "withdrawal", type: "WithdrawalCoreIntentOp" },
537
+ { name: "defiAdapter", type: "address" },
538
+ { name: "adapterArgs", type: "bytes" },
539
+ { name: "memo", type: "bytes" }
540
+ ],
541
+ IndividualRevocationIntentOp: [
542
+ { name: "permissionId", type: "bytes32" }
543
+ ],
544
+ UserWideRevocationIntentOp: [
545
+ { name: "empty", type: "bytes" }
546
+ ],
547
+ Gas: [
548
+ { name: "asset", type: "Asset" },
549
+ { name: "maxAmount", type: "uint256" },
550
+ { name: "assetMovement", type: "AssetMovement" },
551
+ { name: "callGasLimit", type: "uint256" },
552
+ { name: "verificationGasLimit", type: "uint256" },
553
+ { name: "preVerificationGas", type: "uint256" },
554
+ { name: "paymasterVerificationGasLimit", type: "uint256" },
555
+ { name: "paymasterPostOpGasLimit", type: "uint256" },
556
+ { name: "maxFeePerGas", type: "uint256" },
557
+ { name: "maxPriorityFeePerGas", type: "uint256" }
558
+ ],
559
+ TransferIntent: [
560
+ { name: "op", type: "TransferIntentOp" },
561
+ { name: "signer", type: "address" },
562
+ { name: "gas", type: "Gas" },
563
+ { name: "salt", type: "bytes32" }
564
+ ],
565
+ WithdrawalIntent: [
566
+ { name: "op", type: "WithdrawalIntentOp" },
567
+ { name: "signer", type: "address" },
568
+ { name: "gas", type: "Gas" },
569
+ { name: "salt", type: "bytes32" }
570
+ ],
571
+ DefiInteractionIntent: [
572
+ { name: "op", type: "DefiInteractionIntentOp" },
573
+ { name: "signer", type: "address" },
574
+ { name: "gas", type: "Gas" },
575
+ { name: "salt", type: "bytes32" }
576
+ ],
577
+ IndividualRevocationIntent: [
578
+ { name: "op", type: "IndividualRevocationIntentOp" },
579
+ { name: "signer", type: "address" },
580
+ { name: "gas", type: "Gas" },
581
+ { name: "salt", type: "bytes32" }
582
+ ],
583
+ UserWideRevocationIntent: [
584
+ { name: "op", type: "UserWideRevocationIntentOp" },
585
+ { name: "signer", type: "address" },
586
+ { name: "gas", type: "Gas" },
587
+ { name: "salt", type: "bytes32" }
588
+ ],
589
+ DelegatedTransferIntent: [
590
+ { name: "intent", type: "TransferIntent" },
591
+ { name: "spender", type: "address" },
592
+ { name: "permissionId", type: "bytes32" }
593
+ ],
594
+ DelegatedWithdrawalIntent: [
595
+ { name: "intent", type: "WithdrawalIntent" },
596
+ { name: "spender", type: "address" },
597
+ { name: "permissionId", type: "bytes32" }
598
+ ],
599
+ DelegatedDefiInteractionIntent: [
600
+ { name: "intent", type: "DefiInteractionIntent" },
601
+ { name: "spender", type: "address" },
602
+ { name: "permissionId", type: "bytes32" }
603
+ ],
604
+ Transfer: [
605
+ { name: "draftingHandle", type: "bytes32" },
606
+ { name: "draftingTimestamp", type: "uint64" },
607
+ { name: "nullifier", type: "bytes32" },
608
+ { name: "senderEscapeCommitment", type: "bytes32" },
609
+ { name: "receiverEscapeCommitment", type: "bytes32" },
610
+ { name: "senderEscapeData", type: "bytes" },
611
+ { name: "receiverEscapeData", type: "bytes" },
612
+ { name: "ciphertext", type: "bytes" },
613
+ { name: "memo", type: "bytes" }
614
+ ],
615
+ WithdrawalCore: [
616
+ { name: "asset", type: "Asset" },
617
+ { name: "assetMovements", type: "AssetMovement[]" },
618
+ { name: "nullifier", type: "bytes32" },
619
+ { name: "draftingHandle", type: "bytes32" },
620
+ { name: "draftingTimestamp", type: "uint64" },
621
+ { name: "ciphertext", type: "bytes" },
622
+ { name: "senderEscapeCommitment", type: "bytes32" },
623
+ { name: "senderEscapeData", type: "bytes" }
624
+ ],
625
+ Withdrawal: [
626
+ { name: "core", type: "WithdrawalCore" },
627
+ { name: "memo", type: "bytes" }
628
+ ],
629
+ DefiInteraction: [
630
+ { name: "withdrawal", type: "WithdrawalCore" },
631
+ { name: "defiAdapter", type: "address" },
632
+ { name: "adapterArgs", type: "bytes" },
633
+ { name: "memo", type: "bytes" }
634
+ ],
635
+ IndividualRevocation: [
636
+ { name: "ciphertext", type: "bytes" },
637
+ { name: "draftingHandle", type: "bytes32" },
638
+ { name: "draftingTimestamp", type: "uint64" }
639
+ ],
640
+ UserWideRevocation: [
641
+ { name: "ciphertext", type: "bytes" },
642
+ { name: "draftingHandle", type: "bytes32" },
643
+ { name: "draftingTimestamp", type: "uint64" }
644
+ ],
645
+ TransferPlaintext: [
646
+ { name: "sender", type: "address" },
647
+ { name: "receiver", type: "address" },
648
+ { name: "amount", type: "uint256" },
649
+ { name: "assetId", type: "bytes32" }
650
+ ],
651
+ WithdrawalPlaintext: [
652
+ { name: "sender", type: "address" }
653
+ ],
654
+ DepositPlaintext: [
655
+ { name: "receiver", type: "address" }
656
+ ],
657
+ IndividualRevocationPlaintext: [
658
+ { name: "owner", type: "address" },
659
+ { name: "permissionId", type: "bytes32" }
660
+ ],
661
+ UserWideRevocationPlaintext: [
662
+ { name: "owner", type: "address" }
663
+ ],
664
+ SenderEscapePlaintext: [
665
+ { name: "sender", type: "address" },
666
+ { name: "assetId", type: "bytes32" },
667
+ { name: "draftingHandle", type: "bytes32" },
668
+ { name: "spendAmount", type: "uint256" },
669
+ { name: "balanceSnapshot", type: "uint256" },
670
+ { name: "chequeNumber", type: "uint64" },
671
+ { name: "oldestPossiblyOutstanding", type: "uint64" }
672
+ ],
673
+ ReceiverEscapePlaintext: [
674
+ { name: "receiver", type: "address" },
675
+ { name: "assetId", type: "bytes32" },
676
+ { name: "draftingHandle", type: "bytes32" },
677
+ { name: "receiveAmount", type: "uint256" },
678
+ { name: "balanceSnapshot", type: "uint256" },
679
+ { name: "chequeNullifier", type: "bytes32" },
680
+ { name: "senderChequeNumber", type: "uint64" },
681
+ { name: "oldestPossiblyOutstandingSend", type: "uint64" }
682
+ ],
683
+ GetPermissionsByOwner: [
684
+ { name: "requester", type: "address" },
685
+ { name: "includeExpired", type: "bool" }
686
+ ],
687
+ GetPermissionsBySpender: [
688
+ { name: "requester", type: "address" },
689
+ { name: "includeExpired", type: "bool" }
690
+ ],
691
+ GetPermissionDetails: [
692
+ { name: "requester", type: "address" },
693
+ { name: "permissionId", type: "bytes32" }
694
+ ],
695
+ GetSpendable: [
696
+ { name: "requester", type: "address" },
697
+ { name: "permissionId", type: "bytes32" }
698
+ ],
699
+ GetOwnerGeneration: [
700
+ { name: "requester", type: "address" }
701
+ ],
702
+ SpendableResponse: [
703
+ { name: "requester", type: "address" },
704
+ { name: "permissionId", type: "bytes32" },
705
+ { name: "spendable", type: "uint256" },
706
+ { name: "found", type: "bool" },
707
+ { name: "draftingHandle", type: "bytes32" },
708
+ { name: "draftingTimestamp", type: "uint64" }
709
+ ],
710
+ OwnerGenerationResponse: [
711
+ { name: "requester", type: "address" },
712
+ { name: "generation", type: "uint64" },
713
+ { name: "draftingHandle", type: "bytes32" },
714
+ { name: "draftingTimestamp", type: "uint64" }
715
+ ],
716
+ PermissionInfo: [
717
+ { name: "permissionId", type: "bytes32" },
718
+ { name: "terms", type: "Permission" },
719
+ { name: "spentInCurrentPeriod", type: "uint256" },
720
+ { name: "availableAllowance", type: "uint256" },
721
+ { name: "status", type: "uint8" },
722
+ { name: "currentPeriodStart", type: "uint64" }
723
+ ],
724
+ PermissionDetailsResponse: [
725
+ { name: "requester", type: "address" },
726
+ { name: "draftingHandle", type: "bytes32" },
727
+ { name: "draftingTimestamp", type: "uint64" },
728
+ { name: "found", type: "bool" },
729
+ { name: "permission", type: "PermissionInfo" }
730
+ ],
731
+ PermissionListResponse: [
732
+ { name: "requester", type: "address" },
733
+ { name: "byOwner", type: "bool" },
734
+ { name: "includeExpired", type: "bool" },
735
+ { name: "draftingHandle", type: "bytes32" },
736
+ { name: "draftingTimestamp", type: "uint64" },
737
+ { name: "permissions", type: "PermissionInfo[]" }
738
+ ],
739
+ ViewingSession: [
740
+ { name: "owner", type: "address" },
741
+ { name: "issuedAt", type: "uint64" },
742
+ { name: "expiresAt", type: "uint64" },
743
+ { name: "periodStart", type: "uint64" },
744
+ { name: "periodEnd", type: "uint64" },
745
+ { name: "responseKey", type: "bytes" },
746
+ { name: "salt", type: "bytes32" }
747
+ ],
748
+ BalanceQuery: [
749
+ { name: "session", type: "ViewingSession" },
750
+ { name: "assetId", type: "bytes32" }
751
+ ],
752
+ PortfolioQuery: [
753
+ { name: "session", type: "ViewingSession" }
754
+ ],
755
+ HistoryCursor: [
756
+ { name: "anchorHandle", type: "bytes32" },
757
+ { name: "afterTimestamp", type: "uint64" },
758
+ { name: "afterOpIndex", type: "uint64" }
759
+ ],
760
+ RequestPagination: [
761
+ { name: "cursor", type: "HistoryCursor" },
762
+ { name: "limit", type: "uint32" }
763
+ ],
764
+ BalanceHistoryQuery: [
765
+ { name: "session", type: "ViewingSession" },
766
+ { name: "assetId", type: "bytes32" },
767
+ { name: "pagination", type: "RequestPagination" }
768
+ ],
769
+ PortfolioHistoryQuery: [
770
+ { name: "session", type: "ViewingSession" },
771
+ { name: "pagination", type: "RequestPagination" }
772
+ ],
773
+ HistoryEntry: [
774
+ { name: "opIndex", type: "uint64" },
775
+ { name: "kind", type: "uint8" },
776
+ { name: "sender", type: "address" },
777
+ { name: "receiver", type: "address" },
778
+ { name: "assetId", type: "bytes32" },
779
+ { name: "amount", type: "uint256" },
780
+ { name: "balanceAfter", type: "uint256" },
781
+ { name: "nullifier", type: "bytes32" },
782
+ { name: "memo", type: "bytes" },
783
+ { name: "handle", type: "bytes32" },
784
+ { name: "blockTimestamp", type: "uint64" },
785
+ { name: "blockNumber", type: "uint64" },
786
+ { name: "blockHash", type: "bytes32" },
787
+ { name: "txHash", type: "bytes32" }
788
+ ],
789
+ ResponsePagination: [
790
+ { name: "anchorHandle", type: "bytes32" },
791
+ { name: "anchorBlockHash", type: "bytes32" },
792
+ { name: "anchorTimestamp", type: "uint64" },
793
+ { name: "nextTimestamp", type: "uint64" },
794
+ { name: "nextOpIndex", type: "uint64" },
795
+ { name: "hasMore", type: "bool" }
796
+ ],
797
+ BalanceHistoryResponse: [
798
+ { name: "owner", type: "address" },
799
+ { name: "assetId", type: "bytes32" },
800
+ { name: "pagination", type: "ResponsePagination" },
801
+ { name: "entries", type: "HistoryEntry[]" }
802
+ ],
803
+ PortfolioHistoryResponse: [
804
+ { name: "owner", type: "address" },
805
+ { name: "pagination", type: "ResponsePagination" },
806
+ { name: "entries", type: "HistoryEntry[]" }
807
+ ],
808
+ BalanceResponse: [
809
+ { name: "owner", type: "address" },
810
+ { name: "assetId", type: "bytes32" },
811
+ { name: "bankBalance", type: "uint256" },
812
+ { name: "outstandingBalance", type: "uint256" },
813
+ { name: "bookBalance", type: "uint256" },
814
+ { name: "anchorHandle", type: "bytes32" },
815
+ { name: "anchorBlockHash", type: "bytes32" }
816
+ ],
817
+ AssetBalance: [
818
+ { name: "assetId", type: "bytes32" },
819
+ { name: "bankBalance", type: "uint256" }
820
+ ],
821
+ PortfolioResponse: [
822
+ { name: "owner", type: "address" },
823
+ { name: "anchorHandle", type: "bytes32" },
824
+ { name: "anchorBlockHash", type: "bytes32" },
825
+ { name: "anchorTimestamp", type: "uint64" },
826
+ { name: "balances", type: "AssetBalance[]" }
827
+ ]
828
+ };