@funkit/api-base 1.4.1 → 1.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -5,855 +5,12 @@ var API_BASE_URL = false ? "https://api.fun.xyz/staging/v1" : false ? "https://a
5
5
  );
6
6
  var FUN_FAUCET_URL = "https://api.fun.xyz/demo-faucet";
7
7
 
8
- // src/errors/BaseError.ts
9
- var discord = "https://discord.gg/mvQunrx6NG";
10
- var BaseError = class extends Error {
11
- constructor(baseType, type, code, msg, rawMessage, paramsUsed, fixSuggestion, docLink, isInternal = false) {
12
- super(`${msg}
13
-
14
- ${fixSuggestion}
15
- Docs: ${docLink}
16
- Discord: ${discord}`);
17
- this.baseType = baseType;
18
- this.type = type;
19
- this.code = code;
20
- this.rawMessage = rawMessage;
21
- this.paramsUsed = paramsUsed;
22
- if (isInternal) {
23
- this.loadEnd();
24
- }
25
- this.message += "\n\nTrace:";
26
- this.timestamp = (/* @__PURE__ */ new Date()).toUTCString();
27
- }
28
- loadEnd() {
29
- this.message += "\n\nThis is an internal sdk error. Please contact the fun team at our Discord for the fastest response.";
30
- }
31
- };
32
-
33
- // src/errors/errors.json
34
- var errors_default = {
35
- AA21: {
36
- info: " Your wallet lacks funds for this transaction.",
37
- suggestion: "To fix this error, make sure you have enough funds in your wallet to cover the transaction fee."
38
- },
39
- FW000: {
40
- info: " Create3Deployer.requireDeployerOnly() - Signatures were not sorted before being passed in",
41
- suggestion: "To fix this error, make sure to short sigs before passing them into `requireDeployerOnly`. You can do this by calling `sigs.sort()` before passing them in. It is also possible to run into this error if the hash that was signed was not the correct hash."
42
- },
43
- FW001: {
44
- info: " Create3Deployer.requireDeployerOnly() - Signature failed to be recovered. ercrecover returned the zero address",
45
- suggestion: "To fix this error, make sure to pass in enough valid signatures that sign the `hash` in the `sigs` array"
46
- },
47
- FW002: {
48
- info: " Create3Deployer.addDeployer() - Invalid Hash",
49
- suggestion: "To fix this error, make sure `hash` is equal to `hashAddDeployer()`"
50
- },
51
- FW003: {
52
- info: " Create3Deployer.removeDeployer() - Invalid Hash",
53
- suggestion: "To fix this error, make sure `hash` is equal to `hashRemoveDeployer()`"
54
- },
55
- FW004: {
56
- info: " Create3Deployer.setThreshold() - Threshold must be greater than 1",
57
- suggestion: "To fix this error, `threshold` is greater than 1"
58
- },
59
- FW005: {
60
- info: " Create3Deployer.setThreshold() - Invalid Hash",
61
- suggestion: "To fix this error, make sure `hash` is equal to `keccak256(abi.encodePacked(_threshold))`"
62
- },
63
- FW006: {
64
- info: " Create3Deployer.callChild() - Invalid Hash",
65
- suggestion: "To fix this error, make sure `hash` is equal to `keccak256(abi.encodePacked(child, data, _nonce, block.chainid))`"
66
- },
67
- FW007: {
68
- info: " Create3Deployer.callChild() - Invalid Nonce, nonce must be 1 greater than the current nonce",
69
- suggestion: "To fix this error, make sure `_nonce` is equal to the current nonce + 1"
70
- },
71
- FW008: {
72
- info: " Create3Deployer.callChild() - call to child failed",
73
- suggestion: "To fix this error, check to see what is making the call to the child fail"
74
- },
75
- FW009: {
76
- info: " Create3Deployer.deploy() - Invalid Hash",
77
- suggestion: "To fix this error, make sure `hash` is equal to `keccak256(abi.encodePacked(_salt, _creationCode))`"
78
- },
79
- FW010: {
80
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
81
- suggestion: "To fix this error, make sure `_deployer` is not equal to the zero address"
82
- },
83
- FW011: {
84
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
85
- suggestion: "To fix this error, make sure `_funWalletImpAddress` is not equal to the zero address"
86
- },
87
- FW012: {
88
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
89
- suggestion: "To fix this error, make sure `_feeOracle` is not equal to the zero address"
90
- },
91
- FW013: {
92
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
93
- suggestion: "To fix this error, make sure `_walletInit` is not equal to the zero address"
94
- },
95
- FW014: {
96
- info: " FunWalletFactory.constructor() - Unable to generate the address from this deployerSalt",
97
- suggestion: "To fix this error, make sure `FunWalletFactoryV1` has not already been deployed from the given create3deployer contract. If it has been, change `FunWalletFactoryV1` to `FunWalletFactoryV2` or another version."
98
- },
99
- FW015: {
100
- info: " FunWalletFactory.constructor() - Generated the wrong address from this deployerSalt",
101
- suggestion: "To fix this error, make sure `FunWalletFactoryV1` has not already been deployed from the given create3deployer contract. If it has been, change `FunWalletFactoryV1` to `FunWalletFactoryV2` or another version."
102
- },
103
- FW016: {
104
- info: " FunWalletFactory.createAccount() - Call to initialize failed on the deployed proxy",
105
- suggestion: "To fix this error, make sure the `initializerCallData` is formatted correctly"
106
- },
107
- FW017: {
108
- info: " FunWalletFactory - Caller must be deployer",
109
- suggestion: "To fix this error, make sure to call the function from the deployer address"
110
- },
111
- FW018: {
112
- info: " WalletInit.commit() - The previous commit has not expired",
113
- suggestion: "To fix this error, wait for the previous commit with this `commitKey` to expire. This should take at most 10 minutes."
114
- },
115
- FW019: {
116
- info: " WalletInit.validateSalt() - The hash at the commitKey does not match `keccak256(abi.encode(seed, owner, initializerCallData))`",
117
- suggestion: "To fix this error, make sure the seed, owner, and initializerCallData are hashed and stored in commits at the corresponding `commitKey`"
118
- },
119
- FW020: {
120
- info: " WalletInit.validateSalt() - The new owner of the funwallet must match data.newFunWalletOwner from loginData",
121
- suggestion: "To fix this error, make sure the owner set in `loginData` matches the owner address returned from the tweet."
122
- },
123
- FW021: {
124
- info: " WalletInit.setOracle() - The address of the new `_oracle` must not be the zero address",
125
- suggestion: "To fix this error, make sure `_oracle` is not the zero address"
126
- },
127
- FW022: {
128
- info: " Create3Deployer.deployFromChild() - Invalid Child Address",
129
- suggestion: "To fix this error, make sure the caller is a contract deployed from the Create3Deployer"
130
- },
131
- FW023: {
132
- info: " ImplementationRegistry.verifyIsValidContractAndImplementation() - Invalid Target Code Hash",
133
- suggestion: "To fix this error, make sure the caller is a contract targeted is a ERC1967ProxyData contract"
134
- },
135
- FW024: {
136
- info: " ImplementationRegistry.verifyIsValidContractAndImplementation() - Invalid Contract Implementation Address",
137
- suggestion: "To fix this error, make sure you have the minimun threshold amount of valid signatures."
138
- },
139
- FW025: {
140
- info: " ImplementationRegistry.addImplementation() - Invalid Signature Amount",
141
- suggestion: "To fix this error, make sure you have the minimun threshold amount of valid signatures."
142
- },
143
- FW026: {
144
- info: " ImplementationRegistry.removeImplementation() - Invalid Signature Amount",
145
- suggestion: "To fix this error, make sure you have the minimun threshold amount of valid signatures."
146
- },
147
- FW027: {
148
- info: " WalletInit.commit() - Unable to commit with a previously used commit hash",
149
- suggestion: "To fix this error, make sure you are not reusing someone else's commit hash. If there are conflicts, just regenerate the seed randomly"
150
- },
151
- FW028: {
152
- info: " MultiSigDeployer.constructor() - Threshold can't be greater than deployers length",
153
- suggestion: "To fix this error, make sure the threshold value is not 0"
154
- },
155
- FW029: {
156
- info: " WalletInit.invalidateUsedSeed() - msg.sender must equal funwalletfactory",
157
- suggestion: "To fix this error, make sure you are calling this function from the FunWalletFactory contract"
158
- },
159
- FW030: {
160
- info: " WalletInit.setFunWalletFactory() - funwalletfactory address cannot be set to 0",
161
- suggestion: "To fix this error, make sure you are passing in the valid funwalletfactory address"
162
- },
163
- FW031: {
164
- info: " WalletInit.validateSalt() - seed has already been used",
165
- suggestion: "To fix this error, make sure you are not using an existing salt"
166
- },
167
- FW032: {
168
- info: " FunWalletFactory.setFeeOracle() - Cannot set the fee oracle address to 0",
169
- suggestion: "To fix this error, make sure you are using the correct address of the fee oracle"
170
- },
171
- FW033: {
172
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
173
- suggestion: "To fix this error, make sure `_entryPoint` is not equal to the zero address"
174
- },
175
- FW034: {
176
- info: " Create3Deployer.callChild() - Value not equal to msg.value",
177
- suggestion: "To fix this error, make sure `msg.value` is equal to the `value` parameter."
178
- },
179
- FW100: {
180
- info: " Module.execute() - execute() needs to be overriden",
181
- suggestion: "To fix this error, make sure you are overriding the execute method in your module"
182
- },
183
- FW101: {
184
- info: " ApproveAndExec.approveAndExecute() - the approveData's first four bytes must be the approve() function selector",
185
- suggestion: "To fix this error, change `approveData` such that the first four bytes are `bytes4(keccak256('approve(address,uint256)'))`"
186
- },
187
- FW102: {
188
- info: " ApproveAndSwap.constructor() - `_wethAddr` cannot be the zero address",
189
- suggestion: "To fix this error, make sure `_wethAddr` is not set to the zero address"
190
- },
191
- FW103: {
192
- info: " ApproveAndSwap.constructor() - `_router` cannot be the zero address",
193
- suggestion: "To fix this error, make sure `_router` is not set to the zero address"
194
- },
195
- FW104: {
196
- info: " ApproveAndSwap.executeSwapEth() - msg.sender does not have enough weth",
197
- suggestion: "To fix this error, make sure msg.sender has a weth balance >= `amount`"
198
- },
199
- FW105: {
200
- info: " ApproveAndSwap.\\_internalSwap() - Approve failed",
201
- suggestion: "To fix this error, make sure you have formatted approve correctly"
202
- },
203
- FW106: {
204
- info: " AaveWithdraw.execute() - Withdrawing a zero balance",
205
- suggestion: "You are trying to withdraw from aave but don't have a balance"
206
- },
207
- FW107: {
208
- info: " ApproveAndExec.approveAndExecute() - Approve failed",
209
- suggestion: "The token you tried to approve failed"
210
- },
211
- FW108: {
212
- info: " UniswapV3LimitOrder.execute() - Approval Failed",
213
- suggestion: "You are trying to withdraw from aave but don't have a balance"
214
- },
215
- FW109: {
216
- info: " UniswapV3LimitOrder.constructor() - Router cannot be address zero",
217
- suggestion: "Make sure you are not passing in the zero address when initializing the module"
218
- },
219
- FW110: {
220
- info: " UniswapV3LimitOrder.constructor() - Quoter cannot be zero address",
221
- suggestion: "Make sure you are not passing in the zero address when initializing the module"
222
- },
223
- FW200: {
224
- info: " FeePercentOracle.setValues() - feepercent must be less than or equals to 100%",
225
- suggestion: "To fix this error, `_feepercent` must be less than or equals to `10 ** _decimals`"
226
- },
227
- FW201: {
228
- info: " FeePercentOracle.withdrawEth() - eth transfer failed",
229
- suggestion: "To fix this error, investigate why the eth withdrawal failed. This is likely because `amount` was greater than the eth balance in the FeePercentOracle"
230
- },
231
- FW202: {
232
- info: " TokenPriceOracle.getTokenValueOfEth() - chainlink aggregator price must be greater than 0",
233
- suggestion: "To fix this error, retry the call and make sure price is greater than 0"
234
- },
235
- FW203: {
236
- info: " TokenPriceOracle.getTokenValueOfEth() - chainlink aggregator updatedAt must be greater than 0",
237
- suggestion: "To fix this error, retry the call and make sure updatedAt is greater than 0"
238
- },
239
- FW204: {
240
- info: " TokenPriceOracle.getTokenValueOfEth() - chainlink aggregator answeredInRound must be greater than or equal to roundId",
241
- suggestion: "To fix this error, retry the call and make sure answeredInRound must be greater than or equal to roundId"
242
- },
243
- FW205: {
244
- info: " TwitterOracle.batchSetTweet() - socialHandles, loginTypes, seeds, owners length must match in length",
245
- suggestion: "To fix this error, make sure all arrays passed into this function are the same length."
246
- },
247
- FW206: {
248
- info: " TwitterOracle.setTweet() - the seed from twitter cannot be empty",
249
- suggestion: "To fix this error, make sure the seed you post on twitter is not empty {}"
250
- },
251
- FW207: {
252
- info: " TwitterOracle.setTweet() - the address from twitter cannot be 0",
253
- suggestion: "To fix this error, make sure the address you post on twitter for the new owner is not the zero address, otherwise you would be unable to claim ownership of the funwallet"
254
- },
255
- FW208: {
256
- info: " TwitterOracle.batchSetTweet() - the seed from twitter cannot be empty",
257
- suggestion: "To fix this error, make sure the seed you post on twitter is not empty {}"
258
- },
259
- FW209: {
260
- info: " TwitterOracle.batchSetTweet() - the address from twitter cannot be 0",
261
- suggestion: "To fix this error, make sure the address you post on twitter for the new owner is not the zero address, otherwise you would be unable to claim ownership of the funwallet"
262
- },
263
- FW210: {
264
- info: " TwitterOracle.fetchTweet() - the seed from twitter cannot be empty",
265
- suggestion: "To fix this error, make sure the seed you post on twitter is not empty {}"
266
- },
267
- FW211: {
268
- info: " TwitterOracle.fetchTweet() - the address from twitter cannot be 0",
269
- suggestion: "To fix this error, make sure the address you post on twitter for the new owner is not the zero address, otherwise you would be unable to claim ownership of the funwallet"
270
- },
271
- FW300: {
272
- info: " BasePaymaster.constructor() - entrypoint address cannot be the zero address",
273
- suggestion: "To fix this error, make sure entrypoint address is not the zero address"
274
- },
275
- FW301: {
276
- info: " BasePaymaster.\\_requireFromEntryPoint() - the msg.sender must be from the entrypoint",
277
- suggestion: "To fix this error, make sure the msg.sender must be from the entrypoint"
278
- },
279
- FW302: {
280
- info: " GaslessPaymaster.batchActions() - the ith delegate call failed",
281
- suggestion: "To fix this error, make sure the calldata for `data[i]` is a valid call"
282
- },
283
- FW303: {
284
- info: " GaslessPaymaster.batchActions() - batchActions consumed more eth than `msg.value` allocated",
285
- suggestion: "To fix this error, increase the amount of msg.value you are passing to this function"
286
- },
287
- FW304: {
288
- info: " GaslessPaymaster.\\_withdrawDepositTo() - the withdrawal has not been unlocked",
289
- suggestion: "To fix this error, wait till block.number is greater than the unlockBlock for the sender and make sure `unlockBlock[sender]` is nonzero"
290
- },
291
- FW305: {
292
- info: " GaslessPaymaster.\\_withdrawDepositTo() - the balances of the sender must be greater than the withdrawal amount",
293
- suggestion: "To fix this error, decrease the amount you are trying to withdraw"
294
- },
295
- FW306: {
296
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - the userOp.paymasterAndData must have a length of 40",
297
- suggestion: "To fix this error, change the `paymasterAndData` field in the `userOp` such that the length is 40"
298
- },
299
- FW307: {
300
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - the verificationGasLimit must be greater than the `COST_OF_POST` variable in GaslessPaymaster",
301
- suggestion: "To fix this error, increase the `verificationGasLimit` in the `userOp`"
302
- },
303
- FW308: {
304
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - the sponsor's eth is not locked for use",
305
- suggestion: "To fix this error, make sure the sponsor's eth is locked using `lockDeposit()`"
306
- },
307
- FW309: {
308
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - The sponsor needs to approve the spender",
309
- suggestion: "To fix this error, make sure to approve the spender using `setSpenderWhitelistMode()` or `setSpenderBlacklistMode()` and the sponsor's list mode is set to whitelist mode or blacklist mode using `setListMode()"
310
- },
311
- FW310: {
312
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - The sponsor does not have sufficient eth in the paymaster to cover this operation",
313
- suggestion: "To fix this error, make sure to stake enough eth from the sponsor's address using `addDepositTo()`"
314
- },
315
- FW311: {
316
- info: " GaslessPaymaster.addDepositTo() - `msg.value` must be greater than or equal to amount",
317
- suggestion: "To fix this error, make sure `msg.value` must be greater than or equal to amount"
318
- },
319
- FW312: {
320
- info: " TokenPaymaster.batchActions() - the ith delegate call failed",
321
- suggestion: "To fix this error, make sure the calldata for `data[i]` is a valid call"
322
- },
323
- FW313: {
324
- info: " TokenPaymaster.batchActions() - batchActions consumed more eth than `msg.value` allocated",
325
- suggestion: "To fix this error, increase the amount of msg.value you are passing to this function"
326
- },
327
- FW314: {
328
- info: " TokenPaymaster.\\_addTokenDepositTo() - token decimals must be greater than 0",
329
- suggestion: "To fix this error, change the decimals in token using `setTokenData()`"
330
- },
331
- FW315: {
332
- info: " TokenPaymaster.\\_withdrawTokenDepositTo() - token is not unlocked for withdrawal",
333
- suggestion: "To fix this error, call `unlockTokenDepositAfter()`"
334
- },
335
- FW316: {
336
- info: " TokenPaymaster.\\_withdrawTokenDepositTo() - you are withdrawing more tokens that you have in balance",
337
- suggestion: "To fix this error, call `getTokenBalance()` to check how many tokens you have and make sure `amount` is less than that"
338
- },
339
- FW317: {
340
- info: " TokenPaymaster.\\_withdrawEthDepositTo() - token is not unlocked for withdrawal",
341
- suggestion: "To fix this error, call `unlockTokenDepositAfter()` with `ETH` as the token"
342
- },
343
- FW318: {
344
- info: " TokenPaymaster.\\_withdrawEthDepositTo() - you are withdrawing more ether that you have in balance",
345
- suggestion: "To fix this error, call `getTokenBalance()` with `ETH` as the token to check how many tokens you have and make sure `amount` is less than that"
346
- },
347
- FW319: {
348
- info: " TokenPaymaster.\\_getTokenValueOfEth() - call to token oracle failed",
349
- suggestion: "To fix this error, check the token oracle and call `setTokenData()` to change the oracle if it is broken"
350
- },
351
- FW320: {
352
- info: " TokenPaymaster.\\_reimbursePaymaster() - failed to reimbursePaymaster with tokens via `permitTransfer()`",
353
- suggestion: "To fix this **error**, make sure you have permitted the paymaster to spend your tokens"
354
- },
355
- FW321: {
356
- info: " TokenPaymaster.\\_reimbursePaymaster() - spender doesn't have enough tokens",
357
- suggestion: "To fix this error, make sure to add more tokens to the token paymaster via `addTokenDepositTo()`"
358
- },
359
- FW322: {
360
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - `paymasterAndData` length must be 60",
361
- suggestion: "To fix this error, make sure to set `paymasterAndData` length to be 60"
362
- },
363
- FW323: {
364
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - `verificationGasLimit` must be greater than `COST_OF_POST`",
365
- suggestion: "To fix this error, make sure to set the userOp's `verificationGasLimit` to be greater than `COST_OF_POST`"
366
- },
367
- FW324: {
368
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor must lock their ETH",
369
- suggestion: "To fix this error, make sure the sponsor has locked their eth by calling `lockTokenDeposit()` from the sponsor address"
370
- },
371
- FW325: {
372
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the account must lock their tokens",
373
- suggestion: "To fix this error, make sure the user of the token paymaster has locked their tokens by calling `lockTokenDeposit()` from their address"
374
- },
375
- FW326: {
376
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor eth balance must be greater than maxCost",
377
- suggestion: "To fix this error, make sure the sponsor eth balance is greater than maxCost"
378
- },
379
- FW327: {
380
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor must approve the spender",
381
- suggestion: "To fix this error, make sure the sponsor has approved the spender by calling `setSpenderWhitelistMode()` or `setSpenderBlacklistMode()` and the sponsor's list mode is set to whitelist mode or blacklist mode using `setListMode()`"
382
- },
383
- FW328: {
384
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor must have approved the token to the paymaster",
385
- suggestion: "To fix this error, make sure the sponsor has approved the spender by calling `setTokenWhitelistMode()` or `setTokenBlacklistMode()` and the sponsor's list mode is set to whitelist mode or blacklist mode using `setTokenListMode()`"
386
- },
387
- FW329: {
388
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the permitted token must be equal to the token you are trying to pay with if using permit",
389
- suggestion: "To fix this error, make sure the permitted token is equal to the token you are trying to pay with if using permit"
390
- },
391
- FW330: {
392
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the permitted transfer recipient must be the token paymaster",
393
- suggestion: "To fix this error, make sure to permit the token paymaster to spend your tokens"
394
- },
395
- FW331: {
396
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the permitted transfer amount must be greater than or equal to the maxTokenCost",
397
- suggestion: "To fix this error, make sure the permitted transfer amount is greater than or equal to the maxTokenCost"
398
- },
399
- FW332: {
400
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - if permit was not used, make sure the tokenPaymaster was approved to spend tokens by the sponsor or enough tokens were deposited into the TokenPaymaster",
401
- suggestion: "To fix this error, make sure the tokenPaymaster was approved(`approve()`) to spend tokens by the sponsor or enough tokens were deposited into the TokenPaymaster via `addTokenDepositTo()`"
402
- },
403
- FW333: {
404
- info: " TokenPaymaster.addEthDepositTo() - make sure msg.value is greater than or equal to amount",
405
- suggestion: "To fix this error, make sure that the msg.value is greater than or equal to amount"
406
- },
407
- FW334: {
408
- info: " TokenPaymaster.addTokenDepositTo() - sponsor cannot be the zero address",
409
- suggestion: "To fix this error, make sure the sponsor is not the zero address"
410
- },
411
- FW335: {
412
- info: " TokenPaymaster.addTokenDepositTo() - target cannot be the zero address",
413
- suggestion: "To fix this error, make sure the target is not the zero address"
414
- },
415
- FW336: {
416
- info: " TokenPaymaster.addTokenDepositTo() - token address cannot be the zero address",
417
- suggestion: "To fix this error, make sure the token address is not the zero address"
418
- },
419
- FW337: {
420
- info: " TokenPaymaster.addTokenDepositTo() - spender address cannot be the zero address",
421
- suggestion: "To fix this error, make sure the spender address is not the zero address"
422
- },
423
- FW338: {
424
- info: " TokenPaymaster.addTokenDepositTo() - the token oracle cannot be the zero address",
425
- suggestion: "To fix this error, make sure the token oracle is not the zero address"
426
- },
427
- FW339: {
428
- info: " TokenPaymaster.addTokenDepositTo() - the tokenAddress cannot be the zero address",
429
- suggestion: "To fix this error, make sure the tokenAddress is not the zero address"
430
- },
431
- FW340: {
432
- info: " TokenPaymaster.addTokenDepositTo() - the token decimals must be greater than 0",
433
- suggestion: "To fix this error, make sure the token decimals is greater than 0"
434
- },
435
- FW341: {
436
- info: " TokenPaymaster.addTokenDepositTo() - the chainlink aggregator cannot be the zero address",
437
- suggestion: "To fix this error, make sure the chainlink aggregator is not the zero address"
438
- },
439
- FW342: {
440
- info: " TokenPaymaster.removeTokenData() - The token doesn't exist in tokens",
441
- suggestion: "To fix this error, make sure the token address is not the zero address"
442
- },
443
- FW343: {
444
- info: " TokenPaymaster.removeTokenData() - The tokenListIndex doesn't match with the tokenAddress",
445
- suggestion: "To fix this error, make sure the token at tokenList[tokenListIndex] is the same as the tokenAddress"
446
- },
447
- FW344: {
448
- info: " GaslessPaymaster.batchActions() - Cannot recursively call batchActions from within batchActions",
449
- suggestion: "To fix this error, make sure you are not recursively calling batchActions from within batchActions"
450
- },
451
- FW345: {
452
- info: " TokenPaymaster.batchActions() - Cannot recursively call batchActions from within batchActions",
453
- suggestion: "To fix this error, make sure you are not recursively calling batchActions from within batchActions"
454
- },
455
- FW346: {
456
- info: " TokenPaymaster.postOp() - Invalid Permit transfer amount",
457
- suggestion: "To fix this error, make sure your permit transfer has transfered the correct amount of tokens"
458
- },
459
- FW347: {
460
- info: " TokenPaymaster.\\_reimbursePaymaster() - Invalid amount of tokens transferred",
461
- suggestion: "The likely cause of this error is using a deflationary token that charges a tax when you transfer tokens. To fix this error, make sure you are transferring the correct amount of tokens and to account for the tax/deflation."
462
- },
463
- FW348: {
464
- info: " UserAuthentication.init() - groupId count must be equal to groups length",
465
- suggestion: "Make sure the number of groupIds equals the number of groups."
466
- },
467
- FW349: {
468
- info: " TokenPaymaster.calculatePostOpGas() - Invalid Auth Type",
469
- suggestion: "Make sure the authtype is correct"
470
- },
471
- FW350: {
472
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - Does not have enough balance of token",
473
- suggestion: "To fix this error, make sure your has enough tokens to permit transfer"
474
- },
475
- FW351: {
476
- info: " BasePaymaster.\\withdrawStakeFromEntryPoint() - Cannot withdraw to address zero",
477
- suggestion: "To fix this error, make sure you are not withdrawing to address zero"
478
- },
479
- FW401: {
480
- info: " RoleBasedAccessControl",
481
- suggestion: "### `FW402`: RoleBasedAccessControl.isValidAction(), isValidActionAndFee() - Invalid Target"
482
- },
483
- FW402: {
484
- info: " RoleBasedAccessControl.isValidAction(), isValidActionAndFee() - Invalid Target",
485
- suggestion: "To fix this error, make sure the target that you are calling is in the merkle root of allowed targets verified by the rule. If this does not work make sure you are using the correct merkle root implementation."
486
- },
487
- FW403: {
488
- info: " RoleBasedAccessControl",
489
- suggestion: "To fix this error, make sure the selector that you are calling is in the merkle root of allowed selector verified by the rule. If this does not work make sure you are using the correct merkle root implementation."
490
- },
491
- FW404: {
492
- info: " RoleBasedAccessControl",
493
- suggestion: "To fix this error, make sure the ownerId is not 0 or an existing owner"
494
- },
495
- FW405: {
496
- info: " RoleBasedAccessControl",
497
- suggestion: "To fix this error, make sure the ruleId is not 0"
498
- },
499
- FW406: {
500
- info: " RoleBasedAccessControl",
501
- suggestion: "To fix this error, make sure the rule that you are using has a deadline that has passed."
502
- },
503
- FW408: {
504
- info: " RoleBasedAccessControl",
505
- suggestion: "### `FW410`: RoleBasedAccessControl: isValidAction(), isValidActionAndFee() - Rule not added to role"
506
- },
507
- FW410: {
508
- info: " RoleBasedAccessControl",
509
- suggestion: "To fix this error, make sure the rule is added to the role"
510
- },
511
- FW411: {
512
- info: " RoleBasedAccessControl",
513
- suggestion: "To fix this error, make sure the value for the execution call is less than the limit"
514
- },
515
- FW412: {
516
- info: " RoleBasedAccessControl",
517
- suggestion: "To fix this error, make sure the fee value for the execution call is less than the limit"
518
- },
519
- FW413: {
520
- info: " RoleBasedAccessControl",
521
- suggestion: "To fix this error, make sure the fee recipient is in the rule fee merkle root"
522
- },
523
- FW414: {
524
- info: " RoleBasedAccessControl",
525
- suggestion: "To fix this error, make sure the fee token is in the rule fee merkle root"
526
- },
527
- FW417: {
528
- info: " RoleBasedAccessControl",
529
- suggestion: "To fix this error, make sure the rule you are using exists"
530
- },
531
- FW418: {
532
- info: " RoleBasedAccessControl",
533
- suggestion: "To fix this error, make sure the user is in the role"
534
- },
535
- FW419: {
536
- info: " RoleBasedAccessControl",
537
- suggestion: "To fix this error, make sure the feeRecipientTokenMerkleRootHash is not zero"
538
- },
539
- FW420: {
540
- info: " RoleBasedAccessControl",
541
- suggestion: "To fix this error, make sure the targetSelectorMerkleRootHash is not zero"
542
- },
543
- FW421: {
544
- info: " RoleBasedAccessControl",
545
- suggestion: "### `FW422`: RoleBasedAccessControl: init() - Wallet has not been initialized"
546
- },
547
- FW422: {
548
- info: " RoleBasedAccessControl",
549
- suggestion: "To fix this error, make sure the wallet has not initialized the validation contract"
550
- },
551
- FW500: {
552
- info: " FunWallet.initialize() - the entrypoint cannot be the zero address",
553
- suggestion: "To fix this error, make sure the entrypoint is not the zero address"
554
- },
555
- FW501: {
556
- info: " FunWallet.initialize() - the msg.sender cannot be the address of the Funwallet contract",
557
- suggestion: "To fix this error, make sure the msg.sender is not the address of the Funwallet contract"
558
- },
559
- FW502: {
560
- info: " FunWallet.\\_requireFromFunWalletProxy() - the function must be called from the funwallet proxy",
561
- suggestion: "To fix this error, make sure the msg.sender == funwallet"
562
- },
563
- FW503: {
564
- info: " FunWallet.updateEntryPoint() - the new entrypoint address cannot be the zero address",
565
- suggestion: "To fix this error, make sure the new entrypoint address is not the zero address"
566
- },
567
- FW504: {
568
- info: " FunWallet.depositToEntryPoint() - not enough eth in the funwallet",
569
- suggestion: "To fix this error, make sure the funwallet has more than the amount of eth you are trying to deposit"
570
- },
571
- FW505: {
572
- info: " FunWallet.\\_transferEthFromEntrypoint() - withdrawing eth from the entrypoint failed",
573
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the entrypoint"
574
- },
575
- FW506: {
576
- info: " FunWallet.\\_requireFromModule() - make sure a funwalletfactory deployed the module",
577
- suggestion: "To fix this error, make sure the msg.sender is the module"
578
- },
579
- FW507: {
580
- info: " FunWallet.\\_requireFromEntryPoint() - the msg.sender must be the entrypoint",
581
- suggestion: "To fix this error, make sure the msg.sender is the entrypoint"
582
- },
583
- FW508: {
584
- info: " WalletFee.\\_transferEth() - the eth transfer failed",
585
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the wallet"
586
- },
587
- FW509: {
588
- info: " WalletFee.\\_handleFee() - the developer eth transfer failed",
589
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the wallet"
590
- },
591
- FW510: {
592
- info: " WalletFee.\\_handleFee() - the funOracle eth transfer failed",
593
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the wallet"
594
- },
595
- FW511: {
596
- info: " WalletValidation.initValidations() - the WalletValidations contract has already been initialized",
597
- suggestion: "Don't call initValidations() more than once"
598
- },
599
- FW512: {
600
- info: " WalletValidation.initValidations() - make sure there are more than zero validations",
601
- suggestion: "To fix this error, make sure there are more than zero validations and the number of validation contract addresses are equal to the number of `initCallData` elements"
602
- },
603
- FW513: {
604
- info: " WalletValidation.initValidations() - make sure there are no duplicate validation contract addresses",
605
- suggestion: "To fix this error, make sure there are no duplicate validation contract addresses in `validationData`"
606
- },
607
- FW514: {
608
- info: " WalletValidation.\\_validateUserOp() - make sure the signature length is greater than 0",
609
- suggestion: "To fix this error, make sure the signature length is greater than 0"
610
- },
611
- FW515: {
612
- info: " WalletValidation.isValidSignature() - make sure the number of validations is greater than zero",
613
- suggestion: "To fix this error, make sure the number of validations is greater than zero"
614
- },
615
- FW516: {
616
- info: " WalletValidation.\\_requireValidValidation() - the validation failed",
617
- suggestion: "To fix this error, make sure the validation contract returns true"
618
- },
619
- FW517: {
620
- info: " WalletValidation.\\_requireValidValidationFormat() - the validation was incorrectly formatted",
621
- suggestion: "To fix this error, make sure the validation contract address is not the zero address and the validation is valid and the address is not the zero address"
622
- },
623
- FW518: {
624
- info: " WalletValidation.\\_requireValidPrevValidation() - the previous validation must be linked to this validation",
625
- suggestion: "To fix this error, make sure the previous validation is linked to this validation when adding or removing the validation"
626
- },
627
- FW519: {
628
- info: " WalletValidation.getValidations() - you must have more than zero validations to get validations",
629
- suggestion: "To fix this error, make sure there are a nonzero amount of validations"
630
- },
631
- FW520: {
632
- info: " WalletValidation.addValidation() - The caller must be this wallet.",
633
- suggestion: "To fix this error, make sure you are calling addValidation() from your funwallet."
634
- },
635
- FW521: {
636
- info: " WalletValidation.removeValidation() - The caller must be this wallet.",
637
- suggestion: "To fix this error, make sure you are calling removeValidation() from your funwallet."
638
- },
639
- FW522: {
640
- info: " WalletValidation.updateValidation() - The caller must be this wallet.",
641
- suggestion: "To fix this error, make sure you are calling updateValidation() from your funwallet."
642
- },
643
- FW523: {
644
- info: " WalletModules.permitTransfer() - Invalid Permit Signature.",
645
- suggestion: "To fix this error, make sure you have a valid permit signature."
646
- },
647
- FW524: {
648
- info: " WalletValidation.getValidations() - No Validations in the wallet",
649
- suggestion: "To fix this error, make sure the wallet has validation contracts"
650
- },
651
- FW600: {
652
- info: " DataLib",
653
- suggestion: "To fix this error, make sure you are calling either execFromEntryPoint() or execFromEntryPointWithFee() from your funwallet."
654
- },
655
- FW601: {
656
- info: " Ownable2StepNoRenounce",
657
- suggestion: "To fix this error, don't call this function."
658
- }
659
- };
660
-
661
- // src/errors/types.ts
662
- var ErrorBaseType = /* @__PURE__ */ ((ErrorBaseType2) => {
663
- ErrorBaseType2["ClientError"] = "ClientError";
664
- ErrorBaseType2["ServerError"] = "ServerError";
665
- return ErrorBaseType2;
666
- })(ErrorBaseType || {});
667
- var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
668
- ErrorType2["InvalidParameter"] = "InvalidParameter";
669
- ErrorType2["InternalServerFailure"] = "InternalServerFailure";
670
- ErrorType2["ResourceNotFound"] = "ResourceNotFound";
671
- ErrorType2["InvalidAction"] = "InvalidAction";
672
- ErrorType2["ThrottlingError"] = "ThrottlingError";
673
- ErrorType2["AccessDeniedError"] = "AccessDeniedError";
674
- ErrorType2["UserOpFailureError"] = "UserOpFailureError";
675
- return ErrorType2;
676
- })(ErrorType || {});
677
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
678
- ErrorCode2["MissingParameter"] = "MissingParameter";
679
- ErrorCode2["InvalidParameter"] = "InvalidParameter";
680
- ErrorCode2["InvalidThreshold"] = "InvalidThreshold";
681
- ErrorCode2["InvalidChainIdentifier"] = "InvalidChainIdentifier";
682
- ErrorCode2["InvalidNFTIdentifier"] = "InvalidNFTIdentifier";
683
- ErrorCode2["InsufficientSignatures"] = "InsufficientSignatures";
684
- ErrorCode2["InvalidParameterCombination"] = "InvalidParameterCombination";
685
- ErrorCode2["CheckPointHintsNotFound"] = "CheckPointHintsNotFound";
686
- ErrorCode2["GroupNotFound"] = "GroupNotFound";
687
- ErrorCode2["TokenNotFound"] = "TokenNotFound";
688
- ErrorCode2["AddressNotFound"] = "AddressNotFound";
689
- ErrorCode2["UserAlreadyExists"] = "UserAlreadyExists";
690
- ErrorCode2["UserNotFound"] = "UserNotFound";
691
- ErrorCode2["ChainNotSupported"] = "ChainNotSupported";
692
- ErrorCode2["ServerMissingData"] = "ServerMissingData";
693
- ErrorCode2["ServerFailure"] = "ServerFailure";
694
- ErrorCode2["ServerTimeout"] = "ServerTimeout";
695
- ErrorCode2["UnknownServerError"] = "UnknownServerError";
696
- ErrorCode2["ServerConnectionError"] = "ServerConnectionError";
697
- ErrorCode2["UserOpFailureError"] = "UserOpFailureError";
698
- ErrorCode2["Unauthorized"] = "Unauthorized";
699
- ErrorCode2["RequestLimitExceeded"] = "RequestLimitExceeded";
700
- ErrorCode2["WalletPrefundError"] = "PrefundError";
701
- ErrorCode2["GasSponsorFundError"] = "GasSponsorFundError";
702
- ErrorCode2["FunWalletErrorCode"] = "FunWalletErrorCode";
703
- ErrorCode2["BridgeRouteNotFound"] = "BridgeRouteNotFound";
704
- ErrorCode2["BridgeAllowanceDataNotFound"] = "BridgeAllowanceDataNotFound";
705
- ErrorCode2["BridgeApproveTxDataNotFound"] = "BridgeApproveTxDataNotFound";
706
- ErrorCode2["CheckoutInitDepositAddrNotFound"] = "CheckoutInitDepositAddrNotFound";
707
- return ErrorCode2;
708
- })(ErrorCode || {});
709
-
710
- // src/errors/ClientError.ts
711
- var ClientError = class extends BaseError {
712
- constructor(type, code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
713
- super(
714
- "ClientError" /* ClientError */,
715
- type,
716
- code,
717
- msg,
718
- rawMessage,
719
- paramsUsed,
720
- fixSuggestion,
721
- docLink,
722
- false
723
- );
724
- }
725
- };
726
- var InvalidParameterError = class extends ClientError {
727
- constructor(code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
728
- super(
729
- "InvalidParameter" /* InvalidParameter */,
730
- code,
731
- msg,
732
- rawMessage,
733
- paramsUsed,
734
- fixSuggestion,
735
- docLink
736
- );
737
- }
738
- };
739
- var ResourceNotFoundError = class extends ClientError {
740
- constructor(code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
741
- if (msg.includes("Chain name not found")) {
742
- const { reqId } = JSON.parse(msg);
743
- super(
744
- "ResourceNotFound" /* ResourceNotFound */,
745
- "ChainNotSupported" /* ChainNotSupported */,
746
- ": Chain name not found or not supported.",
747
- rawMessage,
748
- { reqId },
749
- "Change your EnvOptions to the correct chain identifier.",
750
- docLink
751
- );
752
- } else {
753
- super(
754
- "ResourceNotFound" /* ResourceNotFound */,
755
- code,
756
- msg,
757
- rawMessage,
758
- paramsUsed,
759
- fixSuggestion,
760
- docLink
761
- );
762
- }
763
- }
764
- };
765
- var ThrottlingError = class extends ClientError {
766
- constructor(code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
767
- super(
768
- "ThrottlingError" /* ThrottlingError */,
769
- code,
770
- msg,
771
- rawMessage,
772
- paramsUsed,
773
- fixSuggestion,
774
- docLink
775
- );
776
- }
777
- };
778
- var AccessDeniedError = class extends ClientError {
779
- constructor(code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
780
- super(
781
- "AccessDeniedError" /* AccessDeniedError */,
782
- code,
783
- msg,
784
- rawMessage,
785
- paramsUsed,
786
- fixSuggestion,
787
- docLink
788
- );
789
- }
790
- };
791
- var UserOpFailureError = class extends ClientError {
792
- constructor(code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
793
- const FWCode = findFWContractError(msg);
794
- if (FWCode) {
795
- const { reqId } = JSON.parse(msg);
796
- super(
797
- "UserOpFailureError" /* UserOpFailureError */,
798
- "FunWalletErrorCode" /* FunWalletErrorCode */,
799
- errors_default[FWCode].info,
800
- rawMessage,
801
- { reqId },
802
- errors_default[FWCode].suggestion,
803
- docLink
804
- );
805
- } else {
806
- super(
807
- "UserOpFailureError" /* UserOpFailureError */,
808
- code,
809
- msg,
810
- rawMessage,
811
- paramsUsed,
812
- fixSuggestion,
813
- docLink
814
- );
815
- }
816
- }
817
- };
818
- var findFWContractError = (msg) => {
819
- let match = msg.match(/FW\d{3}/);
820
- if (!match) {
821
- match = msg.match(/AA\d./);
822
- }
823
- return match?.[0];
824
- };
825
-
826
- // src/errors/ServerError.ts
827
- var ServerError = class extends BaseError {
828
- constructor(type, code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
829
- super(
830
- "ServerError" /* ServerError */,
831
- type,
832
- code,
833
- msg,
834
- rawMessage,
835
- paramsUsed,
836
- fixSuggestion,
837
- docLink,
838
- true
839
- );
840
- }
841
- };
842
- var InternalFailureError = class extends ServerError {
843
- constructor(code, msg, rawMessage, paramsUsed, fixSuggestion, docLink) {
844
- super(
845
- "InternalServerFailure" /* InternalServerFailure */,
846
- code,
847
- msg,
848
- rawMessage,
849
- paramsUsed,
850
- fixSuggestion,
851
- docLink
852
- );
853
- }
854
- };
855
-
856
8
  // src/utils/error.ts
9
+ import {
10
+ InvalidParameterError,
11
+ ResourceNotFoundError,
12
+ UserOpFailureError
13
+ } from "@funkit/utils";
857
14
  var errorAbortHandler = (err, context) => {
858
15
  if (err instanceof ResourceNotFoundError || err instanceof InvalidParameterError || err instanceof UserOpFailureError) {
859
16
  context.abort();
@@ -895,6 +52,15 @@ function roundToNearestBottomTenth(n) {
895
52
  // src/utils/request.ts
896
53
  import { retry } from "@lifeomic/attempt";
897
54
  import { toHex as toHex2 } from "viem";
55
+ import {
56
+ AccessDeniedError,
57
+ ErrorCode,
58
+ InternalFailureError,
59
+ InvalidParameterError as InvalidParameterError2,
60
+ ResourceNotFoundError as ResourceNotFoundError2,
61
+ ThrottlingError,
62
+ UserOpFailureError as UserOpFailureError2
63
+ } from "@funkit/utils";
898
64
  var stringifyWithBigIntSanitization = (object) => {
899
65
  return JSON.stringify(
900
66
  object,
@@ -933,73 +99,78 @@ var sendRequest = async ({
933
99
  }
934
100
  const { errorMsg, errorCode } = json;
935
101
  if (response.status === 400) {
936
- throw new InvalidParameterError(
937
- "InvalidParameter" /* InvalidParameter */,
102
+ throw new InvalidParameterError2(
103
+ ErrorCode.InvalidParameter,
938
104
  `bad request ${JSON.stringify(json)}`,
939
105
  errorMsg,
940
106
  { body },
941
107
  "check the api call parameters. its mostly because some call parameters are wrong",
942
108
  "https://docs.fun.xyz"
943
109
  );
944
- } else if (response.status === 403) {
110
+ }
111
+ if (response.status === 403) {
945
112
  throw new AccessDeniedError(
946
- "Unauthorized" /* Unauthorized */,
113
+ ErrorCode.Unauthorized,
947
114
  "Invalid API key or insufficient access.",
948
115
  errorMsg,
949
116
  { apiKey },
950
117
  "Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
951
118
  "https://docs.fun.xyz"
952
119
  );
953
- } else if (response.status === 404) {
954
- throw new ResourceNotFoundError(
955
- "ServerMissingData" /* ServerMissingData */,
120
+ }
121
+ if (response.status === 404) {
122
+ throw new ResourceNotFoundError2(
123
+ ErrorCode.ServerMissingData,
956
124
  JSON.stringify(json),
957
125
  errorMsg,
958
126
  { body },
959
127
  "check the api call parameters. its mostly because some call parameters are wrong",
960
128
  "https://docs.fun.xyz"
961
129
  );
962
- } else if (response.status === 429) {
130
+ }
131
+ if (response.status === 429) {
963
132
  throw new ThrottlingError(
964
- "RequestLimitExceeded" /* RequestLimitExceeded */,
133
+ ErrorCode.RequestLimitExceeded,
965
134
  `too many requests ${JSON.stringify(json)}`,
966
135
  "Too many requests",
967
136
  { body },
968
137
  "you are making too many requests. please slow down. Reach out to fun team if you need more quota",
969
138
  "https://docs.fun.xyz"
970
139
  );
971
- } else if (response.status === 500) {
972
- if (errorCode === "UserOpFailureError" /* UserOpFailureError */) {
973
- throw new UserOpFailureError(
974
- "UserOpFailureError" /* UserOpFailureError */,
140
+ }
141
+ if (response.status === 500) {
142
+ if (errorCode === ErrorCode.UserOpFailureError) {
143
+ throw new UserOpFailureError2(
144
+ ErrorCode.UserOpFailureError,
975
145
  `server failure ${JSON.stringify(json)}`,
976
146
  errorMsg,
977
147
  { body },
978
148
  "fix user op failure. Most of the time this is due to invalid parameters",
979
149
  "https://docs.fun.xyz"
980
150
  );
981
- } else {
982
- throw new InternalFailureError(
983
- "ServerFailure" /* ServerFailure */,
984
- `server failure ${JSON.stringify(json)}`,
985
- errorMsg,
986
- { body },
987
- "retry later. if it still fails, please contact us.",
988
- "https://docs.fun.xyz"
989
- );
990
151
  }
991
- } else if (response.status === 504) {
992
152
  throw new InternalFailureError(
993
- "ServerTimeout" /* ServerTimeout */,
153
+ ErrorCode.ServerFailure,
154
+ `server failure ${JSON.stringify(json)}`,
155
+ errorMsg,
156
+ { body },
157
+ "retry later. if it still fails, please contact us.",
158
+ "https://docs.fun.xyz"
159
+ );
160
+ }
161
+ if (response.status === 504) {
162
+ throw new InternalFailureError(
163
+ ErrorCode.ServerTimeout,
994
164
  `server timeout failure ${JSON.stringify(json)}`,
995
165
  errorMsg,
996
166
  { body },
997
167
  "retry later. if it still fails, please contact us.",
998
168
  "https://docs.fun.xyz"
999
169
  );
1000
- } else if (!response.ok) {
170
+ }
171
+ if (!response.ok) {
1001
172
  throw new InternalFailureError(
1002
- "UnknownServerError" /* UnknownServerError */,
173
+ ErrorCode.UnknownServerError,
1003
174
  `unknown server failure ${JSON.stringify(json)}`,
1004
175
  errorMsg,
1005
176
  { body },
@@ -1011,7 +182,7 @@ var sendRequest = async ({
1011
182
  }, finalRetryOptions);
1012
183
  } catch (err) {
1013
184
  throw new InternalFailureError(
1014
- "ServerConnectionError" /* ServerConnectionError */,
185
+ ErrorCode.ServerConnectionError,
1015
186
  `Cannot connect to Fun API Service ${err}`,
1016
187
  "",
1017
188
  { body },
@@ -1160,6 +331,7 @@ async function getWalletLidoWithdrawalsByChainId({
1160
331
 
1161
332
  // src/services/checkout/endpoints.ts
1162
333
  import Big from "big.js";
334
+ import { ErrorCode as ErrorCode2, ResourceNotFoundError as ResourceNotFoundError3 } from "@funkit/utils";
1163
335
 
1164
336
  // src/services/checkout/types.ts
1165
337
  var CheckoutState = /* @__PURE__ */ ((CheckoutState2) => {
@@ -1268,8 +440,8 @@ async function initializeCheckout({
1268
440
  apiKey
1269
441
  });
1270
442
  if (!res?.depositAddr) {
1271
- throw new ResourceNotFoundError(
1272
- "CheckoutInitDepositAddrNotFound" /* CheckoutInitDepositAddrNotFound */,
443
+ throw new ResourceNotFoundError3(
444
+ ErrorCode2.CheckoutInitDepositAddrNotFound,
1273
445
  "Unable to initialize checkout",
1274
446
  "Unable to initialize checkout",
1275
447
  body,
@@ -1309,7 +481,7 @@ async function getCheckoutByDepositAddress({
1309
481
  signal
1310
482
  });
1311
483
  } catch (err) {
1312
- if (err instanceof ResourceNotFoundError) {
484
+ if (err instanceof ResourceNotFoundError3) {
1313
485
  return null;
1314
486
  }
1315
487
  throw err;
@@ -1390,8 +562,8 @@ async function initializeCheckoutTokenTransferAddress({
1390
562
  apiKey
1391
563
  });
1392
564
  if (!res?.depositAddr) {
1393
- throw new ResourceNotFoundError(
1394
- "CheckoutInitDepositAddrNotFound" /* CheckoutInitDepositAddrNotFound */,
565
+ throw new ResourceNotFoundError3(
566
+ ErrorCode2.CheckoutInitDepositAddrNotFound,
1395
567
  "Unable to initialize checkout token transfer address",
1396
568
  "Unable to initialize checkout token transfer address",
1397
569
  body,
@@ -1548,6 +720,7 @@ var MeshExecuteTransferMfaType = /* @__PURE__ */ ((MeshExecuteTransferMfaType2)
1548
720
  })(MeshExecuteTransferMfaType || {});
1549
721
 
1550
722
  // src/services/moonpay/endpoints.ts
723
+ import { ErrorCode as ErrorCode3, InternalFailureError as InternalFailureError2 } from "@funkit/utils";
1551
724
  async function getMoonpayUrlSignature({
1552
725
  url,
1553
726
  isSandbox,
@@ -1559,8 +732,8 @@ async function getMoonpayUrlSignature({
1559
732
  apiKey
1560
733
  });
1561
734
  if (!signature || !signature?.url) {
1562
- throw new InternalFailureError(
1563
- "UnknownServerError" /* UnknownServerError */,
735
+ throw new InternalFailureError2(
736
+ ErrorCode3.UnknownServerError,
1564
737
  "No onramp url found.",
1565
738
  "",
1566
739
  { url },
@@ -1595,70 +768,6 @@ async function getMoonpayBuyQuoteForCreditCard({
1595
768
  });
1596
769
  return res;
1597
770
  }
1598
- async function getMoonpayOnRampUrl({
1599
- apiKey,
1600
- walletAddr,
1601
- currencyCode
1602
- }) {
1603
- const endpoint = `on-ramp/${walletAddr}?provider=moonpay`;
1604
- if (currencyCode) {
1605
- endpoint.concat(`&currencyCode=${currencyCode}`);
1606
- }
1607
- const url = (await sendGetRequest({
1608
- uri: `${API_BASE_URL}/${endpoint}`,
1609
- apiKey
1610
- }))?.url;
1611
- if (!url) {
1612
- throw new InternalFailureError(
1613
- "UnknownServerError" /* UnknownServerError */,
1614
- "No onramp url found.",
1615
- "",
1616
- { walletAddr },
1617
- "This is an internal error, please contact support.",
1618
- "https://docs.fun.xyz"
1619
- );
1620
- }
1621
- return url;
1622
- }
1623
- async function getMoonpayOffRampUrl({
1624
- walletAddr,
1625
- apiKey
1626
- }) {
1627
- const url = (await sendGetRequest({
1628
- uri: `${API_BASE_URL}/off-ramp/${walletAddr}?provider=moonpay`,
1629
- apiKey
1630
- }))?.url;
1631
- if (!url) {
1632
- throw new InternalFailureError(
1633
- "UnknownServerError" /* UnknownServerError */,
1634
- "No offramp url found.",
1635
- "",
1636
- { walletAddr },
1637
- "This is an internal error, please contact support.",
1638
- "https://docs.fun.xyz"
1639
- );
1640
- }
1641
- return url;
1642
- }
1643
- async function getMoonpayOnRampSupportedCurrencies({
1644
- apiKey
1645
- }) {
1646
- const currencies = await sendGetRequest({
1647
- uri: `${API_BASE_URL}/on-ramp/moonpay-currencies`,
1648
- apiKey
1649
- });
1650
- if (!currencies || !currencies.length) {
1651
- throw new InternalFailureError(
1652
- "UnknownServerError" /* UnknownServerError */,
1653
- "No supported currencies found.",
1654
- "",
1655
- {},
1656
- "This is an internal error, please contact support.",
1657
- "https://docs.fun.xyz"
1658
- );
1659
- }
1660
- return currencies;
1661
- }
1662
771
 
1663
772
  // src/services/stripe/endpoints.ts
1664
773
  async function getStripeBuyQuote({
@@ -1752,23 +861,11 @@ async function sendSupportMessage({
1752
861
  }
1753
862
  export {
1754
863
  API_BASE_URL,
1755
- AccessDeniedError,
1756
- BaseError,
1757
864
  CheckoutState,
1758
- ClientError,
1759
865
  DEFAULT_RETRY_OPTIONS,
1760
- ErrorBaseType,
1761
- ErrorCode,
1762
- ErrorType,
1763
866
  FUN_FAUCET_URL,
1764
- InternalFailureError,
1765
- InvalidParameterError,
1766
867
  MeshExecuteTransferMfaType,
1767
868
  MeshExecuteTransferStatus,
1768
- ResourceNotFoundError,
1769
- ServerError,
1770
- ThrottlingError,
1771
- UserOpFailureError,
1772
869
  createStripeBuySession,
1773
870
  deactivateCheckout,
1774
871
  errorAbortHandler,
@@ -1786,9 +883,6 @@ export {
1786
883
  getCheckoutsByRecipientAddress,
1787
884
  getCheckoutsByUserId,
1788
885
  getMoonpayBuyQuoteForCreditCard,
1789
- getMoonpayOffRampUrl,
1790
- getMoonpayOnRampSupportedCurrencies,
1791
- getMoonpayOnRampUrl,
1792
886
  getMoonpayUrlSignature,
1793
887
  getPaymasterDataForCheckoutSponsoredTransfer,
1794
888
  getRiskAssessmentForAddress,