@tokenops/sdk 1.1.1 → 1.6.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 (163) hide show
  1. package/CHANGELOG.md +158 -2
  2. package/README.md +18 -8
  3. package/SECURITY.md +7 -1
  4. package/dist/{chunk-56UI7LUR.cjs → chunk-2RNW4MIJ.cjs} +37 -0
  5. package/dist/{chunk-VDXVNZCO.cjs → chunk-43RFBQ73.cjs} +85 -29
  6. package/dist/{chunk-BE2AIZ3K.js → chunk-46T67CE2.js} +1 -1
  7. package/dist/{chunk-WRCUDSUJ.js → chunk-4KJ66YRH.js} +61 -3
  8. package/dist/{chunk-ITQ7WKVC.cjs → chunk-4ZCXK4VI.cjs} +68 -8
  9. package/dist/{chunk-JFLEEXKP.js → chunk-6WSNS3UV.js} +58 -2
  10. package/dist/{chunk-W7JHOK7G.cjs → chunk-7G7UOQV4.cjs} +4 -4
  11. package/dist/{chunk-5KHIQG7Y.cjs → chunk-AYGRYDBX.cjs} +35 -36
  12. package/dist/{chunk-5SGMJADP.cjs → chunk-BD4LZBVF.cjs} +85 -9
  13. package/dist/{chunk-OYLZEEHF.cjs → chunk-BK7YIVLK.cjs} +304 -179
  14. package/dist/{chunk-SEKC7H5Y.cjs → chunk-CBRL2PJA.cjs} +12 -11
  15. package/dist/{chunk-XWDVPV42.js → chunk-CNP4L3GF.js} +4 -4
  16. package/dist/{chunk-IVE3QEGD.js → chunk-DRSPMIZ7.js} +28 -1
  17. package/dist/{chunk-SAGJIEQK.cjs → chunk-EUKPOXWR.cjs} +15 -16
  18. package/dist/chunk-FT4LNBOS.js +11 -0
  19. package/dist/{chunk-ITQBDRWX.js → chunk-HETNKZEE.js} +1 -1
  20. package/dist/{chunk-JJ4R5QXF.js → chunk-KSDSXJ34.js} +1 -1
  21. package/dist/{chunk-SYHXDHWX.cjs → chunk-LBWRFZR3.cjs} +218 -31
  22. package/dist/{chunk-ZXCOJY2Z.js → chunk-NFW7AUEX.js} +1 -1
  23. package/dist/{chunk-FPQBFIUW.cjs → chunk-OL6SHN3D.cjs} +3 -3
  24. package/dist/{chunk-XSNLAS5M.js → chunk-PD7ME2BT.js} +75 -2
  25. package/dist/{chunk-FXCW7LVB.js → chunk-QET3Q4JP.js} +94 -9
  26. package/dist/{chunk-M7V2EDPB.js → chunk-QKKBBH7I.js} +2 -2
  27. package/dist/{chunk-XXXDQSHE.js → chunk-S2XD75JM.js} +12 -3
  28. package/dist/{chunk-5SA2HF2W.cjs → chunk-SPGSO5SO.cjs} +31 -22
  29. package/dist/{chunk-Q7ARQSUH.cjs → chunk-SYHNZSZZ.cjs} +3 -3
  30. package/dist/{chunk-X56UVEXS.js → chunk-TN65XNTI.js} +248 -120
  31. package/dist/chunk-U57COLUE.js +56 -0
  32. package/dist/{chunk-OQZAZIAS.js → chunk-UE5XK2SY.js} +193 -6
  33. package/dist/{chunk-NS44KBV5.cjs → chunk-UJS4N2XM.cjs} +12 -12
  34. package/dist/{chunk-IR5AK5U5.js → chunk-V5D7BHW3.js} +4 -5
  35. package/dist/{chunk-3PQ2RFPC.js → chunk-VHSNYUYV.js} +5 -4
  36. package/dist/{chunk-CQIPRNS7.cjs → chunk-VR3FREBX.cjs} +3 -3
  37. package/dist/{chunk-G7G75C46.cjs → chunk-WO72UBQD.cjs} +11 -11
  38. package/dist/chunk-WOEETTH7.cjs +59 -0
  39. package/dist/{chunk-QE7ZONJ2.js → chunk-WTK6JDSI.js} +4 -5
  40. package/dist/{chunk-3ZRHDTEX.cjs → chunk-WUXUWTFW.cjs} +3 -3
  41. package/dist/{chunk-23F7JIK5.cjs → chunk-YFIWCYHC.cjs} +141 -54
  42. package/dist/{chunk-FYQ2UW4T.js → chunk-YPYCWLYP.js} +1 -1
  43. package/dist/chunk-ZQUE2B3Q.cjs +33 -0
  44. package/dist/core/addresses.d.ts +1 -1
  45. package/dist/core/errors.d.ts +41 -1
  46. package/dist/core/revert-mapper.d.ts +77 -0
  47. package/dist/core/wagmi-compat.d.ts +40 -0
  48. package/dist/fhe/index.cjs +134 -68
  49. package/dist/fhe/index.d.cts +2 -1
  50. package/dist/fhe/index.d.ts +2 -1
  51. package/dist/fhe/index.js +64 -10
  52. package/dist/fhe/mock-erc7984.d.ts +4 -4
  53. package/dist/fhe/operators.d.ts +142 -2
  54. package/dist/fhe/react/index.cjs +21 -8
  55. package/dist/fhe/react/index.d.cts +2 -0
  56. package/dist/fhe/react/index.d.ts +2 -0
  57. package/dist/fhe/react/index.js +8 -3
  58. package/dist/fhe/react/useEnsureOperator.d.ts +56 -0
  59. package/dist/fhe/react/useIsOperator.d.ts +54 -0
  60. package/dist/fhe/sepolia-encryptor-web.d.ts +45 -4
  61. package/dist/fhe/sepolia-encryptor.d.ts +38 -0
  62. package/dist/fhe-airdrop/advanced/index.cjs +9 -9
  63. package/dist/fhe-airdrop/advanced/index.js +7 -7
  64. package/dist/fhe-airdrop/advanced/react/index.cjs +14 -14
  65. package/dist/fhe-airdrop/advanced/react/index.js +10 -10
  66. package/dist/fhe-airdrop/airdrop.d.ts +9 -0
  67. package/dist/fhe-airdrop/encryption.d.ts +8 -0
  68. package/dist/fhe-airdrop/factory.d.ts +86 -1
  69. package/dist/fhe-airdrop/index.cjs +69 -66
  70. package/dist/fhe-airdrop/index.d.cts +3 -3
  71. package/dist/fhe-airdrop/index.d.ts +3 -3
  72. package/dist/fhe-airdrop/index.js +7 -8
  73. package/dist/fhe-airdrop/react/index.cjs +176 -135
  74. package/dist/fhe-airdrop/react/index.d.cts +7 -4
  75. package/dist/fhe-airdrop/react/index.d.ts +7 -4
  76. package/dist/fhe-airdrop/react/index.js +43 -16
  77. package/dist/fhe-airdrop/react/useAccessClaimAmount.d.ts +17 -11
  78. package/dist/fhe-airdrop/react/useAirdropIsSignatureValid.d.ts +3 -2
  79. package/dist/fhe-airdrop/react/useClaim.d.ts +10 -0
  80. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdrop.d.ts +8 -0
  81. package/dist/fhe-airdrop/react/useCreateAndFundConfidentialAirdropAndGetAddress.d.ts +8 -0
  82. package/dist/fhe-airdrop/react/useFundConfidentialAirdrop.d.ts +8 -0
  83. package/dist/fhe-airdrop/react/usePreflightCreateAirdrop.d.ts +51 -0
  84. package/dist/fhe-airdrop/react/useSignClaimAuthorization.d.ts +1 -1
  85. package/dist/fhe-airdrop/types.d.ts +56 -0
  86. package/dist/fhe-disperse/encryption.d.ts +8 -0
  87. package/dist/fhe-disperse/errors.d.ts +55 -0
  88. package/dist/fhe-disperse/index.cjs +77 -66
  89. package/dist/fhe-disperse/index.d.cts +2 -2
  90. package/dist/fhe-disperse/index.d.ts +2 -2
  91. package/dist/fhe-disperse/index.js +8 -9
  92. package/dist/fhe-disperse/react/index.cjs +108 -87
  93. package/dist/fhe-disperse/react/index.d.cts +4 -2
  94. package/dist/fhe-disperse/react/index.d.ts +4 -2
  95. package/dist/fhe-disperse/react/index.js +12 -11
  96. package/dist/fhe-disperse/react/useCalculateFee.d.ts +7 -0
  97. package/dist/fhe-disperse/react/useDisperse.d.ts +9 -0
  98. package/dist/fhe-disperse/react/usePreflightDisperse.d.ts +7 -0
  99. package/dist/fhe-disperse/react/useSingletonCalculateFee.d.ts +7 -0
  100. package/dist/fhe-disperse/react/useSingletonWithdrawTokenFee.d.ts +6 -0
  101. package/dist/fhe-disperse/react/useWithdrawTokenFee.d.ts +6 -0
  102. package/dist/fhe-disperse/singleton.d.ts +29 -0
  103. package/dist/fhe-disperse/subtotals.d.ts +6 -0
  104. package/dist/fhe-vesting/advanced/index.cjs +8 -9
  105. package/dist/fhe-vesting/advanced/index.js +6 -7
  106. package/dist/fhe-vesting/advanced/react/index.cjs +15 -15
  107. package/dist/fhe-vesting/advanced/react/index.js +12 -12
  108. package/dist/fhe-vesting/encryption.d.ts +8 -0
  109. package/dist/fhe-vesting/index.cjs +82 -79
  110. package/dist/fhe-vesting/index.d.cts +2 -2
  111. package/dist/fhe-vesting/index.d.ts +2 -2
  112. package/dist/fhe-vesting/index.js +9 -10
  113. package/dist/fhe-vesting/manager.d.ts +119 -1
  114. package/dist/fhe-vesting/react/index.cjs +264 -224
  115. package/dist/fhe-vesting/react/index.d.cts +9 -6
  116. package/dist/fhe-vesting/react/index.d.ts +9 -6
  117. package/dist/fhe-vesting/react/index.js +44 -21
  118. package/dist/fhe-vesting/react/useAccessClaimableAmount.d.ts +11 -3
  119. package/dist/fhe-vesting/react/useAccessSettledAmount.d.ts +11 -3
  120. package/dist/fhe-vesting/react/useAccessTotalAllocation.d.ts +11 -3
  121. package/dist/fhe-vesting/react/useAccessVestedAmount.d.ts +11 -3
  122. package/dist/fhe-vesting/react/useAdminClaim.d.ts +2 -0
  123. package/dist/fhe-vesting/react/useAdminGetClaimableAmount.d.ts +1 -1
  124. package/dist/fhe-vesting/react/useAdminGetSettledAmount.d.ts +1 -1
  125. package/dist/fhe-vesting/react/useAdminGetTotalAllocation.d.ts +1 -1
  126. package/dist/fhe-vesting/react/useAdminGetVestedAmount.d.ts +1 -1
  127. package/dist/fhe-vesting/react/useAdminPartialClaim.d.ts +10 -0
  128. package/dist/fhe-vesting/react/useBatchCreateVesting.d.ts +8 -0
  129. package/dist/fhe-vesting/react/useClaim.d.ts +3 -1
  130. package/dist/fhe-vesting/react/useCreateVesting.d.ts +8 -0
  131. package/dist/fhe-vesting/react/useDiscloseHandleToParty.d.ts +1 -1
  132. package/dist/fhe-vesting/react/useManagerDiscloseHandleToParty.d.ts +1 -1
  133. package/dist/fhe-vesting/react/useManagerWithdrawTokenFee.d.ts +6 -0
  134. package/dist/fhe-vesting/react/usePartialClaim.d.ts +9 -1
  135. package/dist/fhe-vesting/react/usePreflightCreateVesting.d.ts +37 -0
  136. package/dist/fhe-vesting/react/useVestingClaim.d.ts +2 -0
  137. package/dist/fhe-vesting/react/useVestingInfo.d.ts +1 -1
  138. package/dist/fhe-vesting/react/useWithdrawAdmin.d.ts +6 -0
  139. package/dist/fhe-vesting/react/useWithdrawTokenFee.d.ts +6 -0
  140. package/dist/fhe-vesting/types.d.ts +45 -0
  141. package/dist/index.cjs +93 -86
  142. package/dist/index.d.cts +1 -1
  143. package/dist/index.d.ts +1 -1
  144. package/dist/index.js +2 -3
  145. package/dist/testnet-faucet/index.cjs +58 -55
  146. package/dist/testnet-faucet/index.d.cts +1 -1
  147. package/dist/testnet-faucet/index.d.ts +1 -1
  148. package/dist/testnet-faucet/index.js +5 -6
  149. package/dist/testnet-faucet/react/index.cjs +60 -56
  150. package/dist/testnet-faucet/react/index.d.cts +3 -2
  151. package/dist/testnet-faucet/react/index.d.ts +3 -2
  152. package/dist/testnet-faucet/react/index.js +11 -11
  153. package/dist/testnet-faucet/react/useConfidentialBalance.d.ts +3 -2
  154. package/dist/testnet-faucet/react/useUnderlyingBalance.d.ts +2 -2
  155. package/package.json +14 -8
  156. package/dist/chunk-66IHPTOK.cjs +0 -20
  157. package/dist/chunk-KWFFIJYX.js +0 -11
  158. package/dist/fhe-airdrop/react/useAirdropClaim.d.ts +0 -25
  159. package/dist/fhe-airdrop/react/useGetClaimAmount.d.ts +0 -30
  160. package/dist/fhe-vesting/react/useGetClaimableAmount.d.ts +0 -13
  161. package/dist/fhe-vesting/react/useGetSettledAmount.d.ts +0 -14
  162. package/dist/fhe-vesting/react/useGetTotalAllocation.d.ts +0 -13
  163. package/dist/fhe-vesting/react/useGetVestedAmount.d.ts +0 -25
@@ -1,6 +1,7 @@
1
- import { normaliseAddress } from './chunk-BE2AIZ3K.js';
1
+ import { erc7984OperatorAbi } from './chunk-7VELUOMI.js';
2
+ import { normaliseAddress } from './chunk-46T67CE2.js';
3
+ import { TokenOpsContractError } from './chunk-DRSPMIZ7.js';
2
4
  import { withTelemetry } from './chunk-Q2GP5UDC.js';
3
- import { TokenOpsContractError } from './chunk-IVE3QEGD.js';
4
5
 
5
6
  // src/fhe/operators.ts
6
7
  var ERC7984_SET_OPERATOR_ABI = [
@@ -92,5 +93,62 @@ async function revokeOperator(args) {
92
93
  });
93
94
  });
94
95
  }
96
+ async function isOperator(args) {
97
+ const token = normaliseAddress(args.token);
98
+ const holder = normaliseAddress(args.holder);
99
+ const spender = normaliseAddress(args.spender);
100
+ return withTelemetry(args.telemetry, "fhe.isOperator", async () => {
101
+ try {
102
+ return await args.publicClient.readContract({
103
+ address: token,
104
+ abi: erc7984OperatorAbi,
105
+ functionName: "isOperator",
106
+ args: [holder, spender]
107
+ });
108
+ } catch (err) {
109
+ throw new TokenOpsContractError(
110
+ `isOperator: readContract failed (token=${token}, holder=${holder}, spender=${spender})`,
111
+ { contract: "ERC7984", call: "isOperator", token, holder, spender, cause: err }
112
+ );
113
+ }
114
+ });
115
+ }
116
+ async function ensureOperator(args) {
117
+ return withTelemetry(args.telemetry, "fhe.ensureOperator", async () => {
118
+ if (args.deadline <= 0n || args.deadline > ERC7984_OPERATOR_MAX_DEADLINE) {
119
+ throw new TokenOpsContractError(
120
+ `ensureOperator: deadline ${args.deadline} out of range (0, ${ERC7984_OPERATOR_MAX_DEADLINE}]`,
121
+ { contract: "ERC7984", call: "ensureOperator", deadline: args.deadline.toString() }
122
+ );
123
+ }
124
+ const fromAccount = args.account ?? args.walletClient.account;
125
+ if (!fromAccount) {
126
+ throw new TokenOpsContractError(
127
+ "ensureOperator: no account available \u2014 pass `account` explicitly or attach an account to the walletClient",
128
+ { contract: "ERC7984", call: "ensureOperator" }
129
+ );
130
+ }
131
+ const holder = typeof fromAccount === "string" ? fromAccount : fromAccount.address;
132
+ const authorized = await isOperator({
133
+ publicClient: args.publicClient,
134
+ token: args.token,
135
+ holder,
136
+ spender: args.spender
137
+ });
138
+ if (authorized) {
139
+ return { alreadyOperator: true, hash: null };
140
+ }
141
+ const hash = await setOperator({
142
+ publicClient: args.publicClient,
143
+ walletClient: args.walletClient,
144
+ ...args.account !== void 0 ? { account: args.account } : {},
145
+ token: args.token,
146
+ spender: args.spender,
147
+ deadline: args.deadline,
148
+ ...args.waitForReceipt !== void 0 ? { waitForReceipt: args.waitForReceipt } : {}
149
+ });
150
+ return { alreadyOperator: false, hash };
151
+ });
152
+ }
95
153
 
96
- export { ERC7984_OPERATOR_MAX_DEADLINE, ERC7984_SET_OPERATOR_ABI, revokeOperator, setOperator };
154
+ export { ERC7984_OPERATOR_MAX_DEADLINE, ERC7984_SET_OPERATOR_ABI, ensureOperator, isOperator, revokeOperator, setOperator };
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkCQIPRNS7_cjs = require('./chunk-CQIPRNS7.cjs');
3
+ var chunkFWHYQZ5E_cjs = require('./chunk-FWHYQZ5E.cjs');
4
+ var chunkVR3FREBX_cjs = require('./chunk-VR3FREBX.cjs');
5
+ var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
4
6
  var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
5
- var chunk56UI7LUR_cjs = require('./chunk-56UI7LUR.cjs');
6
7
 
7
8
  // src/fhe/operators.ts
8
9
  var ERC7984_SET_OPERATOR_ABI = [
@@ -20,19 +21,19 @@ var ERC7984_SET_OPERATOR_ABI = [
20
21
  var ERC7984_OPERATOR_MAX_DEADLINE = (1n << 48n) - 1n;
21
22
  async function setOperator(args) {
22
23
  const { publicClient, walletClient, account, waitForReceipt = true, telemetry } = args;
23
- const token = chunkCQIPRNS7_cjs.normaliseAddress(args.token);
24
- const spender = chunkCQIPRNS7_cjs.normaliseAddress(args.spender);
24
+ const token = chunkVR3FREBX_cjs.normaliseAddress(args.token);
25
+ const spender = chunkVR3FREBX_cjs.normaliseAddress(args.spender);
25
26
  const deadline = args.deadline ?? ERC7984_OPERATOR_MAX_DEADLINE;
26
27
  return chunkVJKZWYYJ_cjs.withTelemetry(telemetry, "fhe.setOperator", async () => {
27
28
  const fromAccount = account ?? walletClient.account;
28
29
  if (!fromAccount) {
29
- throw new chunk56UI7LUR_cjs.TokenOpsContractError(
30
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
30
31
  "setOperator: no account available \u2014 pass `account` explicitly or attach an account to the walletClient",
31
32
  { contract: "ERC7984", call: "setOperator" }
32
33
  );
33
34
  }
34
35
  if (deadline < 0n || deadline > ERC7984_OPERATOR_MAX_DEADLINE) {
35
- throw new chunk56UI7LUR_cjs.TokenOpsContractError(
36
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
36
37
  `setOperator: deadline ${deadline} out of uint48 range [0, ${ERC7984_OPERATOR_MAX_DEADLINE}]`,
37
38
  { contract: "ERC7984", call: "setOperator", deadline: deadline.toString() }
38
39
  );
@@ -53,7 +54,7 @@ async function setOperator(args) {
53
54
  chain: walletClient.chain
54
55
  });
55
56
  } catch (err) {
56
- throw new chunk56UI7LUR_cjs.TokenOpsContractError(
57
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
57
58
  `setOperator: writeContract failed (token=${token}, spender=${spender})`,
58
59
  {
59
60
  contract: "ERC7984",
@@ -68,7 +69,7 @@ async function setOperator(args) {
68
69
  try {
69
70
  await publicClient.waitForTransactionReceipt({ hash });
70
71
  } catch (err) {
71
- throw new chunk56UI7LUR_cjs.TokenOpsContractError(`setOperator: receipt wait failed (tx=${hash})`, {
72
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(`setOperator: receipt wait failed (tx=${hash})`, {
72
73
  contract: "ERC7984",
73
74
  call: "setOperator",
74
75
  tx: hash,
@@ -94,8 +95,67 @@ async function revokeOperator(args) {
94
95
  });
95
96
  });
96
97
  }
98
+ async function isOperator(args) {
99
+ const token = chunkVR3FREBX_cjs.normaliseAddress(args.token);
100
+ const holder = chunkVR3FREBX_cjs.normaliseAddress(args.holder);
101
+ const spender = chunkVR3FREBX_cjs.normaliseAddress(args.spender);
102
+ return chunkVJKZWYYJ_cjs.withTelemetry(args.telemetry, "fhe.isOperator", async () => {
103
+ try {
104
+ return await args.publicClient.readContract({
105
+ address: token,
106
+ abi: chunkFWHYQZ5E_cjs.erc7984OperatorAbi,
107
+ functionName: "isOperator",
108
+ args: [holder, spender]
109
+ });
110
+ } catch (err) {
111
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
112
+ `isOperator: readContract failed (token=${token}, holder=${holder}, spender=${spender})`,
113
+ { contract: "ERC7984", call: "isOperator", token, holder, spender, cause: err }
114
+ );
115
+ }
116
+ });
117
+ }
118
+ async function ensureOperator(args) {
119
+ return chunkVJKZWYYJ_cjs.withTelemetry(args.telemetry, "fhe.ensureOperator", async () => {
120
+ if (args.deadline <= 0n || args.deadline > ERC7984_OPERATOR_MAX_DEADLINE) {
121
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
122
+ `ensureOperator: deadline ${args.deadline} out of range (0, ${ERC7984_OPERATOR_MAX_DEADLINE}]`,
123
+ { contract: "ERC7984", call: "ensureOperator", deadline: args.deadline.toString() }
124
+ );
125
+ }
126
+ const fromAccount = args.account ?? args.walletClient.account;
127
+ if (!fromAccount) {
128
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(
129
+ "ensureOperator: no account available \u2014 pass `account` explicitly or attach an account to the walletClient",
130
+ { contract: "ERC7984", call: "ensureOperator" }
131
+ );
132
+ }
133
+ const holder = typeof fromAccount === "string" ? fromAccount : fromAccount.address;
134
+ const authorized = await isOperator({
135
+ publicClient: args.publicClient,
136
+ token: args.token,
137
+ holder,
138
+ spender: args.spender
139
+ });
140
+ if (authorized) {
141
+ return { alreadyOperator: true, hash: null };
142
+ }
143
+ const hash = await setOperator({
144
+ publicClient: args.publicClient,
145
+ walletClient: args.walletClient,
146
+ ...args.account !== void 0 ? { account: args.account } : {},
147
+ token: args.token,
148
+ spender: args.spender,
149
+ deadline: args.deadline,
150
+ ...args.waitForReceipt !== void 0 ? { waitForReceipt: args.waitForReceipt } : {}
151
+ });
152
+ return { alreadyOperator: false, hash };
153
+ });
154
+ }
97
155
 
98
156
  exports.ERC7984_OPERATOR_MAX_DEADLINE = ERC7984_OPERATOR_MAX_DEADLINE;
99
157
  exports.ERC7984_SET_OPERATOR_ABI = ERC7984_SET_OPERATOR_ABI;
158
+ exports.ensureOperator = ensureOperator;
159
+ exports.isOperator = isOperator;
100
160
  exports.revokeOperator = revokeOperator;
101
161
  exports.setOperator = setOperator;
@@ -1,8 +1,51 @@
1
- import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-IVE3QEGD.js';
1
+ import { TokenOpsSdkError, ContractRevertError, InvalidArgumentError, OperatorNotApprovedError, InvalidSignatureError, FheHandleNotAllowedError, TransferFailedError, FeatureDisabledError, BatchTooLargeError, InsufficientBalanceError, InsufficientFeeError, ReentrancyError, AlreadyInitializedError, AccessDeniedError, PausedError, UnknownWriteFailureError, WalletRejectedError, WalletChainMismatchError, InsufficientGasFundsError, NetworkError } from './chunk-DRSPMIZ7.js';
2
2
  import { decodeErrorResult, BaseError, ContractFunctionRevertedError, UserRejectedRequestError, TransactionRejectedRpcError, ChainMismatchError, InsufficientFundsError, HttpRequestError, TimeoutError } from 'viem';
3
3
 
4
4
  // src/core/version.ts
5
5
  var SDK_VERSION = "1.0.0";
6
+ var ERC7984_ERRORS_ABI = [
7
+ {
8
+ type: "error",
9
+ name: "ERC7984UnauthorizedSpender",
10
+ inputs: [
11
+ { name: "holder", type: "address" },
12
+ { name: "spender", type: "address" }
13
+ ]
14
+ },
15
+ {
16
+ type: "error",
17
+ name: "ERC7984UnauthorizedCaller",
18
+ inputs: [{ name: "caller", type: "address" }]
19
+ },
20
+ {
21
+ type: "error",
22
+ name: "ERC7984UnauthorizedUseOfEncryptedAmount",
23
+ inputs: [
24
+ { name: "amount", type: "bytes32" },
25
+ { name: "user", type: "address" }
26
+ ]
27
+ },
28
+ {
29
+ type: "error",
30
+ name: "ERC7984InvalidReceiver",
31
+ inputs: [{ name: "receiver", type: "address" }]
32
+ },
33
+ {
34
+ type: "error",
35
+ name: "ERC7984InvalidSender",
36
+ inputs: [{ name: "sender", type: "address" }]
37
+ },
38
+ {
39
+ type: "error",
40
+ name: "ERC7984ZeroBalance",
41
+ inputs: [{ name: "holder", type: "address" }]
42
+ },
43
+ {
44
+ type: "error",
45
+ name: "ERC7984InvalidGatewayRequest",
46
+ inputs: [{ name: "requestId", type: "uint256" }]
47
+ }
48
+ ];
6
49
  function mapContractRevert(error, args) {
7
50
  if (error instanceof TokenOpsSdkError) return error;
8
51
  const ctx = {
@@ -22,7 +65,10 @@ function mapContractRevert(error, args) {
22
65
  if (revertName === void 0 && rawRevertData !== void 0 && rawRevertData.length >= 10) {
23
66
  revertSelector = rawRevertData.slice(0, 10);
24
67
  try {
25
- const decoded = decodeErrorResult({ abi: args.abi, data: rawRevertData });
68
+ const decoded = decodeErrorResult({
69
+ abi: [...args.abi, ...ERC7984_ERRORS_ABI],
70
+ data: rawRevertData
71
+ });
26
72
  revertName = decoded.errorName;
27
73
  revertArgs = decoded.args;
28
74
  } catch {
@@ -120,6 +166,16 @@ function defaultRevertNameMapper(name, errArgs, ctx, account) {
120
166
  }
121
167
  case "InvalidSignature":
122
168
  return new InvalidSignatureError(ctx);
169
+ case "ERC7984UnauthorizedSpender": {
170
+ const holder = errArgs?.[0];
171
+ const spender = errArgs?.[1];
172
+ return new OperatorNotApprovedError({
173
+ method: ctx.method,
174
+ contractAddress: ctx.contractAddress,
175
+ holder,
176
+ spender
177
+ });
178
+ }
123
179
  // Range / arg-validation reverts the SDK should already have caught in
124
180
  // preflight or input validation. If they slip through, surface them as
125
181
  // structural `InvalidArgumentError` so consumers see `TOKENOPS_INVALID_ARGUMENT`
@@ -1,9 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var chunkSAGJIEQK_cjs = require('./chunk-SAGJIEQK.cjs');
3
+ var chunkEUKPOXWR_cjs = require('./chunk-EUKPOXWR.cjs');
4
4
 
5
5
  // src/fhe-vesting/advanced/factory-advanced.ts
6
- var ConfidentialVestingFactoryAdvancedClient = class extends chunkSAGJIEQK_cjs.ConfidentialVestingFactoryClient {
6
+ var ConfidentialVestingFactoryAdvancedClient = class extends chunkEUKPOXWR_cjs.ConfidentialVestingFactoryClient {
7
7
  /**
8
8
  * Compute the deterministic CREATE2 clone address as the factory would have
9
9
  * computed it at `args.blockNumber`.
@@ -20,7 +20,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkSAGJIEQK_cjs.C
20
20
  if (hasOptions) {
21
21
  return this.publicClient.readContract({
22
22
  address: this.address,
23
- abi: chunkSAGJIEQK_cjs.confidentialVestingFactoryAbi,
23
+ abi: chunkEUKPOXWR_cjs.confidentialVestingFactoryAbi,
24
24
  functionName: "predictManagerAddressWithOptions",
25
25
  args: [
26
26
  args.token,
@@ -34,7 +34,7 @@ var ConfidentialVestingFactoryAdvancedClient = class extends chunkSAGJIEQK_cjs.C
34
34
  }
35
35
  return this.publicClient.readContract({
36
36
  address: this.address,
37
- abi: chunkSAGJIEQK_cjs.confidentialVestingFactoryAbi,
37
+ abi: chunkEUKPOXWR_cjs.confidentialVestingFactoryAbi,
38
38
  functionName: "predictManagerAddress",
39
39
  args: [args.token, args.userSalt, args.deployer],
40
40
  blockNumber: args.blockNumber
@@ -1,11 +1,10 @@
1
1
  'use strict';
2
2
 
3
- var chunkVDXVNZCO_cjs = require('./chunk-VDXVNZCO.cjs');
4
- var chunk3ZRHDTEX_cjs = require('./chunk-3ZRHDTEX.cjs');
5
- var chunkCQIPRNS7_cjs = require('./chunk-CQIPRNS7.cjs');
3
+ var chunk43RFBQ73_cjs = require('./chunk-43RFBQ73.cjs');
4
+ var chunkWUXUWTFW_cjs = require('./chunk-WUXUWTFW.cjs');
5
+ var chunkVR3FREBX_cjs = require('./chunk-VR3FREBX.cjs');
6
+ var chunk2RNW4MIJ_cjs = require('./chunk-2RNW4MIJ.cjs');
6
7
  var chunkVJKZWYYJ_cjs = require('./chunk-VJKZWYYJ.cjs');
7
- var chunk66IHPTOK_cjs = require('./chunk-66IHPTOK.cjs');
8
- var chunk56UI7LUR_cjs = require('./chunk-56UI7LUR.cjs');
9
8
  var chains = require('viem/chains');
10
9
  var viem = require('viem');
11
10
 
@@ -1701,7 +1700,7 @@ var tokenopsTestTokenAbi = [
1701
1700
  ];
1702
1701
 
1703
1702
  // src/testnet-faucet/errors.ts
1704
- var FaucetSupplyExhaustedError = class extends chunk56UI7LUR_cjs.TokenOpsSdkError {
1703
+ var FaucetSupplyExhaustedError = class extends chunk2RNW4MIJ_cjs.TokenOpsSdkError {
1705
1704
  name = "FaucetSupplyExhaustedError";
1706
1705
  constructor(args) {
1707
1706
  super(
@@ -1721,14 +1720,14 @@ function isTestnetFaucetChainId(chainId) {
1721
1720
  function assertTestnetFaucetChain(chainId) {
1722
1721
  if (chainId === void 0) return;
1723
1722
  if (!isTestnetFaucetChainId(chainId)) {
1724
- throw new chunk56UI7LUR_cjs.UnsupportedChainError(chainId);
1723
+ throw new chunk2RNW4MIJ_cjs.UnsupportedChainError(chainId);
1725
1724
  }
1726
1725
  }
1727
1726
  var UINT64_MAX = (1n << 64n) - 1n;
1728
1727
  var UINT256_MAX = (1n << 256n) - 1n;
1729
1728
  function assertUint64Amount(value, argument, method) {
1730
1729
  if (typeof value !== "bigint") {
1731
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1730
+ throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1732
1731
  method,
1733
1732
  argument,
1734
1733
  reason: "amount must be a bigint",
@@ -1736,7 +1735,7 @@ function assertUint64Amount(value, argument, method) {
1736
1735
  });
1737
1736
  }
1738
1737
  if (value <= 0n) {
1739
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1738
+ throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1740
1739
  method,
1741
1740
  argument,
1742
1741
  reason: "amount must be greater than zero",
@@ -1744,7 +1743,7 @@ function assertUint64Amount(value, argument, method) {
1744
1743
  });
1745
1744
  }
1746
1745
  if (value > UINT64_MAX) {
1747
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1746
+ throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1748
1747
  method,
1749
1748
  argument,
1750
1749
  reason: `amount exceeds uint64 max (${UINT64_MAX.toString()})`,
@@ -1754,7 +1753,7 @@ function assertUint64Amount(value, argument, method) {
1754
1753
  }
1755
1754
  function assertUint256Amount(value, argument, method) {
1756
1755
  if (typeof value !== "bigint") {
1757
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1756
+ throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1758
1757
  method,
1759
1758
  argument,
1760
1759
  reason: "amount must be a bigint",
@@ -1762,7 +1761,7 @@ function assertUint256Amount(value, argument, method) {
1762
1761
  });
1763
1762
  }
1764
1763
  if (value <= 0n) {
1765
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1764
+ throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1766
1765
  method,
1767
1766
  argument,
1768
1767
  reason: "amount must be greater than zero",
@@ -1770,7 +1769,7 @@ function assertUint256Amount(value, argument, method) {
1770
1769
  });
1771
1770
  }
1772
1771
  if (value > UINT256_MAX) {
1773
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1772
+ throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1774
1773
  method,
1775
1774
  argument,
1776
1775
  reason: "amount exceeds uint256 max",
@@ -1779,9 +1778,9 @@ function assertUint256Amount(value, argument, method) {
1779
1778
  }
1780
1779
  }
1781
1780
  function assertNonZeroRecipient(input, argument, method) {
1782
- const normalised = chunkCQIPRNS7_cjs.normaliseAddress(input);
1781
+ const normalised = chunkVR3FREBX_cjs.normaliseAddress(input);
1783
1782
  if (/^0x0{40}$/i.test(normalised)) {
1784
- throw new chunk56UI7LUR_cjs.InvalidArgumentError({
1783
+ throw new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1785
1784
  method,
1786
1785
  argument,
1787
1786
  reason: "recipient must not be the zero address",
@@ -1799,7 +1798,7 @@ var faucetProductMapper = (name, _args, ctx) => {
1799
1798
  });
1800
1799
  case "ERC7984InvalidReceiver":
1801
1800
  case "ERC20InvalidReceiver":
1802
- return new chunk56UI7LUR_cjs.InvalidArgumentError({
1801
+ return new chunk2RNW4MIJ_cjs.InvalidArgumentError({
1803
1802
  method: ctx.method,
1804
1803
  argument: "to",
1805
1804
  reason: "recipient must not be the zero address"
@@ -1824,10 +1823,10 @@ var TestnetFaucetClient = class {
1824
1823
  const chainId = config.chainId ?? config.publicClient.chain?.id;
1825
1824
  this.#chainId = chainId;
1826
1825
  assertTestnetFaucetChain(chainId);
1827
- const addressOverride = config.address ? chunkCQIPRNS7_cjs.normaliseAddress(config.address) : void 0;
1828
- const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunk3ZRHDTEX_cjs.getConfidentialTestTokenAddress(chainId));
1826
+ const addressOverride = config.address ? chunkVR3FREBX_cjs.normaliseAddress(config.address) : void 0;
1827
+ const resolved = addressOverride ?? (chainId === void 0 ? void 0 : chunkWUXUWTFW_cjs.getConfidentialTestTokenAddress(chainId));
1829
1828
  if (!resolved) {
1830
- throw new chunk56UI7LUR_cjs.DeploymentAddressUnavailableError({
1829
+ throw new chunk2RNW4MIJ_cjs.DeploymentAddressUnavailableError({
1831
1830
  reason: chainId === void 0 ? "chain-id-missing" : "registry-not-deployed",
1832
1831
  product: "testnetFaucet",
1833
1832
  contract: "confidentialTestToken",
@@ -1840,7 +1839,7 @@ var TestnetFaucetClient = class {
1840
1839
  this.#telemetry?.event("testnet-faucet.client.init", {
1841
1840
  chainId: chainId ?? null,
1842
1841
  hasWallet: !!this.walletClient,
1843
- sdkVersion: chunkVDXVNZCO_cjs.SDK_VERSION
1842
+ sdkVersion: chunk43RFBQ73_cjs.SDK_VERSION
1844
1843
  });
1845
1844
  }
1846
1845
  // ============================================================
@@ -1863,9 +1862,9 @@ var TestnetFaucetClient = class {
1863
1862
  */
1864
1863
  async underlyingToken() {
1865
1864
  if (this.#cachedUnderlying) return this.#cachedUnderlying;
1866
- const fromRegistry = this.#cttAddressIsOverride || this.#chainId === void 0 ? void 0 : chunk3ZRHDTEX_cjs.getTestTokenAddress(this.#chainId);
1865
+ const fromRegistry = this.#cttAddressIsOverride || this.#chainId === void 0 ? void 0 : chunkWUXUWTFW_cjs.getTestTokenAddress(this.#chainId);
1867
1866
  const resolved = fromRegistry ?? await this.#readCtt("underlying");
1868
- this.#cachedUnderlying = chunkCQIPRNS7_cjs.normaliseAddress(resolved);
1867
+ this.#cachedUnderlying = chunkVR3FREBX_cjs.normaliseAddress(resolved);
1869
1868
  return this.#cachedUnderlying;
1870
1869
  }
1871
1870
  /**
@@ -1884,7 +1883,7 @@ var TestnetFaucetClient = class {
1884
1883
  async confidentialBalanceOf(account) {
1885
1884
  const who = this.#resolveReadAddress(account, "confidentialBalanceOf");
1886
1885
  const handle = await this.#readCtt("confidentialBalanceOf", [who]);
1887
- return chunk66IHPTOK_cjs.asEncryptedHandle(handle);
1886
+ return chunk2RNW4MIJ_cjs.asEncryptedHandle(handle);
1888
1887
  }
1889
1888
  /**
1890
1889
  * Read the plaintext underlying `TokenopsTestToken` (TTT) balance for
@@ -1997,7 +1996,7 @@ var TestnetFaucetClient = class {
1997
1996
  }
1998
1997
  const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
1999
1998
  if (receipt.status !== "success") {
2000
- throw new chunk56UI7LUR_cjs.TokenOpsContractError(`mintConfidential: transaction ${hash} reverted`, {
1999
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(`mintConfidential: transaction ${hash} reverted`, {
2001
2000
  contract: "ConfidentialTokenopsTestToken",
2002
2001
  call: "mint",
2003
2002
  tx: hash
@@ -2010,7 +2009,7 @@ var TestnetFaucetClient = class {
2010
2009
  });
2011
2010
  const ours = events.filter((ev2) => ev2.address.toLowerCase() === this.address.toLowerCase());
2012
2011
  if (ours.length === 0) {
2013
- throw new chunk56UI7LUR_cjs.ReceiptEventNotFoundError({
2012
+ throw new chunk2RNW4MIJ_cjs.ReceiptEventNotFoundError({
2014
2013
  method: "mintConfidential",
2015
2014
  eventName: "ConfidentialMint",
2016
2015
  contractAddress: this.address,
@@ -2018,7 +2017,7 @@ var TestnetFaucetClient = class {
2018
2017
  });
2019
2018
  }
2020
2019
  if (ours.length > 1) {
2021
- throw new chunk56UI7LUR_cjs.ReceiptEventAmbiguousError({
2020
+ throw new chunk2RNW4MIJ_cjs.ReceiptEventAmbiguousError({
2022
2021
  method: "mintConfidential",
2023
2022
  eventName: "ConfidentialMint",
2024
2023
  contractAddress: this.address,
@@ -2028,11 +2027,11 @@ var TestnetFaucetClient = class {
2028
2027
  }
2029
2028
  const ev = ours[0];
2030
2029
  return {
2031
- hash: chunk66IHPTOK_cjs.asTxHash(hash),
2030
+ hash: chunk2RNW4MIJ_cjs.asTxHash(hash),
2032
2031
  to: ev.args.to,
2033
2032
  amount: args.amount,
2034
2033
  underlyingMinted: ev.args.underlyingMinted,
2035
- handle: chunk66IHPTOK_cjs.asEncryptedHandle(ev.args.encryptedAmount)
2034
+ handle: chunk2RNW4MIJ_cjs.asEncryptedHandle(ev.args.encryptedAmount)
2036
2035
  };
2037
2036
  });
2038
2037
  }
@@ -2071,13 +2070,13 @@ var TestnetFaucetClient = class {
2071
2070
  }
2072
2071
  const receipt = await this.publicClient.waitForTransactionReceipt({ hash });
2073
2072
  if (receipt.status !== "success") {
2074
- throw new chunk56UI7LUR_cjs.TokenOpsContractError(`mintUnderlying: transaction ${hash} reverted`, {
2073
+ throw new chunk2RNW4MIJ_cjs.TokenOpsContractError(`mintUnderlying: transaction ${hash} reverted`, {
2075
2074
  contract: "TokenopsTestToken",
2076
2075
  call: "mint",
2077
2076
  tx: hash
2078
2077
  });
2079
2078
  }
2080
- return { hash: chunk66IHPTOK_cjs.asTxHash(hash), to, amount: args.amount };
2079
+ return { hash: chunk2RNW4MIJ_cjs.asTxHash(hash), to, amount: args.amount };
2081
2080
  });
2082
2081
  }
2083
2082
  // ============================================================
@@ -2088,14 +2087,14 @@ var TestnetFaucetClient = class {
2088
2087
  }
2089
2088
  #requireWallet(method) {
2090
2089
  if (!this.walletClient) {
2091
- throw new chunk56UI7LUR_cjs.MissingWalletClientError(method);
2090
+ throw new chunk2RNW4MIJ_cjs.MissingWalletClientError(method);
2092
2091
  }
2093
2092
  return this.walletClient;
2094
2093
  }
2095
2094
  #resolveAccount(wallet, override, method) {
2096
2095
  const acct = override ?? wallet.account;
2097
2096
  if (!acct) {
2098
- throw new chunk56UI7LUR_cjs.MissingAccountError(method);
2097
+ throw new chunk2RNW4MIJ_cjs.MissingAccountError(method);
2099
2098
  }
2100
2099
  return acct;
2101
2100
  }
@@ -2105,10 +2104,10 @@ var TestnetFaucetClient = class {
2105
2104
  * neither is available (a read-only client must be told whose balance to read).
2106
2105
  */
2107
2106
  #resolveReadAddress(override, method) {
2108
- if (override) return chunkCQIPRNS7_cjs.normaliseAddress(override);
2107
+ if (override) return chunkVR3FREBX_cjs.normaliseAddress(override);
2109
2108
  const acct = this.walletClient?.account?.address;
2110
2109
  if (!acct) {
2111
- throw new chunk56UI7LUR_cjs.MissingAccountError(method);
2110
+ throw new chunk2RNW4MIJ_cjs.MissingAccountError(method);
2112
2111
  }
2113
2112
  return acct;
2114
2113
  }
@@ -2147,13 +2146,13 @@ var TestnetFaucetClient = class {
2147
2146
  account
2148
2147
  });
2149
2148
  } catch (err) {
2150
- if (chunkVDXVNZCO_cjs.isContractRevert(err)) {
2149
+ if (chunk43RFBQ73_cjs.isContractRevert(err)) {
2151
2150
  throw this.#mapRevert(target, method, err, void 0, accountAddress(account));
2152
2151
  }
2153
2152
  }
2154
2153
  }
2155
2154
  #mapRevert(target, method, err, productContext, account) {
2156
- return chunkVDXVNZCO_cjs.mapContractRevert(err, {
2155
+ return chunk43RFBQ73_cjs.mapContractRevert(err, {
2157
2156
  method,
2158
2157
  contractAddress: target.address,
2159
2158
  abi: target.abi,