@funkit/api-base 1.4.1 → 1.5.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.
package/dist/index.js CHANGED
@@ -1,859 +1,14 @@
1
1
  // src/consts/api.ts
2
- var API_BASE_URL = false ? "https://api.fun.xyz/staging/v1" : false ? "https://api.fun.xyz/testing/v1" : false ? "http://127.0.0.1:3000" : (
3
- // Production
4
- "https://api.fun.xyz/v1"
5
- );
2
+ var API_BASE_URL = "https://api.fun.xyz/v1";
3
+ var MESH_API_BASE_URL = "https://frog.fun.xyz";
6
4
  var FUN_FAUCET_URL = "https://api.fun.xyz/demo-faucet";
7
5
 
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
6
  // src/utils/error.ts
7
+ import {
8
+ InvalidParameterError,
9
+ ResourceNotFoundError,
10
+ UserOpFailureError
11
+ } from "@funkit/utils";
857
12
  var errorAbortHandler = (err, context) => {
858
13
  if (err instanceof ResourceNotFoundError || err instanceof InvalidParameterError || err instanceof UserOpFailureError) {
859
14
  context.abort();
@@ -895,6 +50,15 @@ function roundToNearestBottomTenth(n) {
895
50
  // src/utils/request.ts
896
51
  import { retry } from "@lifeomic/attempt";
897
52
  import { toHex as toHex2 } from "viem";
53
+ import {
54
+ AccessDeniedError,
55
+ ErrorCode,
56
+ InternalFailureError,
57
+ InvalidParameterError as InvalidParameterError2,
58
+ ResourceNotFoundError as ResourceNotFoundError2,
59
+ ThrottlingError,
60
+ UserOpFailureError as UserOpFailureError2
61
+ } from "@funkit/utils";
898
62
  var stringifyWithBigIntSanitization = (object) => {
899
63
  return JSON.stringify(
900
64
  object,
@@ -933,73 +97,78 @@ var sendRequest = async ({
933
97
  }
934
98
  const { errorMsg, errorCode } = json;
935
99
  if (response.status === 400) {
936
- throw new InvalidParameterError(
937
- "InvalidParameter" /* InvalidParameter */,
100
+ throw new InvalidParameterError2(
101
+ ErrorCode.InvalidParameter,
938
102
  `bad request ${JSON.stringify(json)}`,
939
103
  errorMsg,
940
104
  { body },
941
105
  "check the api call parameters. its mostly because some call parameters are wrong",
942
106
  "https://docs.fun.xyz"
943
107
  );
944
- } else if (response.status === 403) {
108
+ }
109
+ if (response.status === 403) {
945
110
  throw new AccessDeniedError(
946
- "Unauthorized" /* Unauthorized */,
111
+ ErrorCode.Unauthorized,
947
112
  "Invalid API key or insufficient access.",
948
113
  errorMsg,
949
114
  { apiKey },
950
115
  "Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
951
116
  "https://docs.fun.xyz"
952
117
  );
953
- } else if (response.status === 404) {
954
- throw new ResourceNotFoundError(
955
- "ServerMissingData" /* ServerMissingData */,
118
+ }
119
+ if (response.status === 404) {
120
+ throw new ResourceNotFoundError2(
121
+ ErrorCode.ServerMissingData,
956
122
  JSON.stringify(json),
957
123
  errorMsg,
958
124
  { body },
959
125
  "check the api call parameters. its mostly because some call parameters are wrong",
960
126
  "https://docs.fun.xyz"
961
127
  );
962
- } else if (response.status === 429) {
128
+ }
129
+ if (response.status === 429) {
963
130
  throw new ThrottlingError(
964
- "RequestLimitExceeded" /* RequestLimitExceeded */,
131
+ ErrorCode.RequestLimitExceeded,
965
132
  `too many requests ${JSON.stringify(json)}`,
966
133
  "Too many requests",
967
134
  { body },
968
135
  "you are making too many requests. please slow down. Reach out to fun team if you need more quota",
969
136
  "https://docs.fun.xyz"
970
137
  );
971
- } else if (response.status === 500) {
972
- if (errorCode === "UserOpFailureError" /* UserOpFailureError */) {
973
- throw new UserOpFailureError(
974
- "UserOpFailureError" /* UserOpFailureError */,
138
+ }
139
+ if (response.status === 500) {
140
+ if (errorCode === ErrorCode.UserOpFailureError) {
141
+ throw new UserOpFailureError2(
142
+ ErrorCode.UserOpFailureError,
975
143
  `server failure ${JSON.stringify(json)}`,
976
144
  errorMsg,
977
145
  { body },
978
146
  "fix user op failure. Most of the time this is due to invalid parameters",
979
147
  "https://docs.fun.xyz"
980
148
  );
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
149
  }
991
- } else if (response.status === 504) {
992
150
  throw new InternalFailureError(
993
- "ServerTimeout" /* ServerTimeout */,
151
+ ErrorCode.ServerFailure,
152
+ `server failure ${JSON.stringify(json)}`,
153
+ errorMsg,
154
+ { body },
155
+ "retry later. if it still fails, please contact us.",
156
+ "https://docs.fun.xyz"
157
+ );
158
+ }
159
+ if (response.status === 504) {
160
+ throw new InternalFailureError(
161
+ ErrorCode.ServerTimeout,
994
162
  `server timeout failure ${JSON.stringify(json)}`,
995
163
  errorMsg,
996
164
  { body },
997
165
  "retry later. if it still fails, please contact us.",
998
166
  "https://docs.fun.xyz"
999
167
  );
1000
- } else if (!response.ok) {
168
+ }
169
+ if (!response.ok) {
1001
170
  throw new InternalFailureError(
1002
- "UnknownServerError" /* UnknownServerError */,
171
+ ErrorCode.UnknownServerError,
1003
172
  `unknown server failure ${JSON.stringify(json)}`,
1004
173
  errorMsg,
1005
174
  { body },
@@ -1011,7 +180,7 @@ var sendRequest = async ({
1011
180
  }, finalRetryOptions);
1012
181
  } catch (err) {
1013
182
  throw new InternalFailureError(
1014
- "ServerConnectionError" /* ServerConnectionError */,
183
+ ErrorCode.ServerConnectionError,
1015
184
  `Cannot connect to Fun API Service ${err}`,
1016
185
  "",
1017
186
  { body },
@@ -1157,9 +326,29 @@ async function getWalletLidoWithdrawalsByChainId({
1157
326
  apiKey
1158
327
  });
1159
328
  }
329
+ async function getNftName({
330
+ chainId,
331
+ nftAddress,
332
+ apiKey
333
+ }) {
334
+ return await sendGetRequest({
335
+ uri: `${API_BASE_URL}/asset/nft/${chainId}/${nftAddress}`,
336
+ apiKey
337
+ });
338
+ }
339
+ async function getNftAddress({
340
+ name,
341
+ apiKey
342
+ }) {
343
+ return await sendGetRequest({
344
+ uri: `${API_BASE_URL}/asset/nft?name=${name}`,
345
+ apiKey
346
+ });
347
+ }
1160
348
 
1161
349
  // src/services/checkout/endpoints.ts
1162
350
  import Big from "big.js";
351
+ import { ErrorCode as ErrorCode2, ResourceNotFoundError as ResourceNotFoundError3 } from "@funkit/utils";
1163
352
 
1164
353
  // src/services/checkout/types.ts
1165
354
  var CheckoutState = /* @__PURE__ */ ((CheckoutState2) => {
@@ -1268,8 +457,8 @@ async function initializeCheckout({
1268
457
  apiKey
1269
458
  });
1270
459
  if (!res?.depositAddr) {
1271
- throw new ResourceNotFoundError(
1272
- "CheckoutInitDepositAddrNotFound" /* CheckoutInitDepositAddrNotFound */,
460
+ throw new ResourceNotFoundError3(
461
+ ErrorCode2.CheckoutInitDepositAddrNotFound,
1273
462
  "Unable to initialize checkout",
1274
463
  "Unable to initialize checkout",
1275
464
  body,
@@ -1309,7 +498,7 @@ async function getCheckoutByDepositAddress({
1309
498
  signal
1310
499
  });
1311
500
  } catch (err) {
1312
- if (err instanceof ResourceNotFoundError) {
501
+ if (err instanceof ResourceNotFoundError3) {
1313
502
  return null;
1314
503
  }
1315
504
  throw err;
@@ -1390,8 +579,8 @@ async function initializeCheckoutTokenTransferAddress({
1390
579
  apiKey
1391
580
  });
1392
581
  if (!res?.depositAddr) {
1393
- throw new ResourceNotFoundError(
1394
- "CheckoutInitDepositAddrNotFound" /* CheckoutInitDepositAddrNotFound */,
582
+ throw new ResourceNotFoundError3(
583
+ ErrorCode2.CheckoutInitDepositAddrNotFound,
1395
584
  "Unable to initialize checkout token transfer address",
1396
585
  "Unable to initialize checkout token transfer address",
1397
586
  body,
@@ -1415,6 +604,77 @@ async function getAssetFromFaucet({
1415
604
  });
1416
605
  }
1417
606
 
607
+ // src/services/fw-access/endpoints.ts
608
+ async function initializeWalletAccess({
609
+ walletAddr,
610
+ creatorAddr,
611
+ apiKey
612
+ }) {
613
+ await sendPostRequest({
614
+ uri: `${API_BASE_URL}/access/wallet`,
615
+ body: { walletAddr, creatorAddr },
616
+ apiKey
617
+ });
618
+ }
619
+ async function checkWalletAccessInitialization({
620
+ walletAddr,
621
+ apiKey
622
+ }) {
623
+ return (await sendGetRequest({
624
+ uri: `${API_BASE_URL}/access/wallet/${walletAddr}`,
625
+ apiKey
626
+ })).initialized;
627
+ }
628
+
629
+ // src/services/fw-group/endpoints.ts
630
+ async function getGroups({
631
+ groupIds,
632
+ chainId,
633
+ apiKey
634
+ }) {
635
+ return (await sendPostRequest({
636
+ uri: `${API_BASE_URL}/group/get-groups`,
637
+ body: { groupIds, chainId },
638
+ apiKey
639
+ })).groups;
640
+ }
641
+
642
+ // src/services/fw-paymaster/endpoints.ts
643
+ async function addTransaction({
644
+ chainId,
645
+ timestamp,
646
+ txid,
647
+ transaction,
648
+ paymasterType,
649
+ sponsorAddress,
650
+ apiKey
651
+ }) {
652
+ try {
653
+ return await sendPostRequest({
654
+ uri: `${API_BASE_URL}/dashboard/paymasters/add-transaction`,
655
+ body: {
656
+ chain: chainId,
657
+ sponsorAddress,
658
+ type: paymasterType,
659
+ timestamp,
660
+ transaction,
661
+ txid
662
+ },
663
+ apiKey
664
+ });
665
+ } catch (_err) {
666
+ }
667
+ }
668
+
669
+ // src/services/fw-paymaster/types.ts
670
+ var PaymasterType = /* @__PURE__ */ ((PaymasterType2) => {
671
+ PaymasterType2["BaseSponsor"] = "base";
672
+ PaymasterType2["GaslessSponsor"] = "gasless";
673
+ PaymasterType2["TokenSponsor"] = "token";
674
+ PaymasterType2["CheckoutSponsor"] = "checkout";
675
+ return PaymasterType2;
676
+ })(PaymasterType || {});
677
+
1418
678
  // src/services/mesh/endpoints.ts
1419
679
  async function meshGetCryptocurrencyHoldings({
1420
680
  authToken,
@@ -1428,6 +688,17 @@ async function meshGetCryptocurrencyHoldings({
1428
688
  });
1429
689
  return res;
1430
690
  }
691
+ async function meshGetCryptocurrencyHoldingsProxy({
692
+ apiKey,
693
+ ...props
694
+ }) {
695
+ const res = await sendPostRequest({
696
+ uri: `${MESH_API_BASE_URL}/mesh/holdings/get`,
697
+ body: { ...props },
698
+ apiKey
699
+ });
700
+ return res;
701
+ }
1431
702
  async function meshGetTransferIntegrations({
1432
703
  apiKey
1433
704
  }) {
@@ -1444,16 +715,12 @@ async function meshGetLinkToken({
1444
715
  transferOptions,
1445
716
  apiKey
1446
717
  }) {
1447
- let body = { userId };
1448
- if (integrationId) {
1449
- body = { ...body, integrationId };
1450
- }
1451
- if (restrictMultipleAccounts) {
1452
- body = { ...body, restrictMultipleAccounts };
1453
- }
1454
- if (transferOptions) {
1455
- body = { ...body, transferOptions };
1456
- }
718
+ const body = {
719
+ userId,
720
+ ...integrationId && { integrationId },
721
+ ...restrictMultipleAccounts && { restrictMultipleAccounts },
722
+ ...transferOptions && { transferOptions }
723
+ };
1457
724
  const res = await sendPostRequest({
1458
725
  uri: `${API_BASE_URL}/mesh/linktoken`,
1459
726
  body,
@@ -1474,31 +741,18 @@ async function meshPreviewTransfer({
1474
741
  fiatCurrency,
1475
742
  apiKey
1476
743
  }) {
1477
- let body = { fromAuthToken, fromType };
1478
- if (toAuthToken) {
1479
- body = { ...body, toAuthToken };
1480
- }
1481
- if (toType) {
1482
- body = { ...body, toType };
1483
- }
1484
- if (networkId) {
1485
- body = { ...body, networkId };
1486
- }
1487
- if (symbol) {
1488
- body = { ...body, symbol };
1489
- }
1490
- if (toAddress) {
1491
- body = { ...body, toAddress };
1492
- }
1493
- if (amount) {
1494
- body = { ...body, amount };
1495
- }
1496
- if (amountInFiat) {
1497
- body = { ...body, amountInFiat };
1498
- }
1499
- if (fiatCurrency) {
1500
- body = { ...body, fiatCurrency };
1501
- }
744
+ const body = {
745
+ fromAuthToken,
746
+ fromType,
747
+ ...toAuthToken && { toAuthToken },
748
+ ...toType && { toType },
749
+ ...networkId && { networkId },
750
+ ...symbol && { symbol },
751
+ ...toAddress && { toAddress },
752
+ ...amount && { amount },
753
+ ...amountInFiat && { amountInFiat },
754
+ ...fiatCurrency && { fiatCurrency }
755
+ };
1502
756
  const res = await sendPostRequest({
1503
757
  uri: `${API_BASE_URL}/mesh/transfers/managed/preview`,
1504
758
  body,
@@ -1507,6 +761,19 @@ async function meshPreviewTransfer({
1507
761
  });
1508
762
  return res;
1509
763
  }
764
+ async function meshPreviewTransferProxy({
765
+ apiKey,
766
+ ...props
767
+ }) {
768
+ const body = { ...props };
769
+ const res = await sendPostRequest({
770
+ uri: `${MESH_API_BASE_URL}/mesh/transfers/managed/preview`,
771
+ body,
772
+ apiKey,
773
+ retryOptions: { maxAttempts: 1 }
774
+ });
775
+ return res;
776
+ }
1510
777
  async function meshExecuteTransfer({
1511
778
  fromAuthToken,
1512
779
  fromType,
@@ -1514,10 +781,12 @@ async function meshExecuteTransfer({
1514
781
  mfaCode,
1515
782
  apiKey
1516
783
  }) {
1517
- let body = { fromAuthToken, fromType, previewId };
1518
- if (mfaCode) {
1519
- body = { ...body, mfaCode };
1520
- }
784
+ const body = {
785
+ fromAuthToken,
786
+ fromType,
787
+ previewId,
788
+ ...mfaCode && { mfaCode }
789
+ };
1521
790
  const res = await sendPostRequest({
1522
791
  uri: `${API_BASE_URL}/mesh/transfers/managed/execute`,
1523
792
  body,
@@ -1525,6 +794,40 @@ async function meshExecuteTransfer({
1525
794
  });
1526
795
  return res;
1527
796
  }
797
+ async function meshExecuteTransferProxy({
798
+ apiKey,
799
+ ...props
800
+ }) {
801
+ const body = { ...props };
802
+ const res = await sendPostRequest({
803
+ uri: `${MESH_API_BASE_URL}/mesh/transfers/managed/execute`,
804
+ body,
805
+ apiKey
806
+ });
807
+ return res;
808
+ }
809
+ async function saveTokensToMeshProxy({
810
+ apiKey,
811
+ ...props
812
+ }) {
813
+ const body = { ...props };
814
+ const res = await sendPostRequest({
815
+ uri: `${MESH_API_BASE_URL}/api/tokens`,
816
+ body,
817
+ apiKey
818
+ });
819
+ return res;
820
+ }
821
+ async function removeTokensFromMeshProxy({
822
+ apiKey,
823
+ ...props
824
+ }) {
825
+ const body = { ...props };
826
+ return await sendDeleteRequest({
827
+ uri: `${MESH_API_BASE_URL}/api/tokens?deviceId=${body.deviceId}&brokerType=${body.brokerType}`,
828
+ apiKey
829
+ });
830
+ }
1528
831
 
1529
832
  // src/services/mesh/types.ts
1530
833
  var MeshExecuteTransferStatus = /* @__PURE__ */ ((MeshExecuteTransferStatus2) => {
@@ -1548,6 +851,7 @@ var MeshExecuteTransferMfaType = /* @__PURE__ */ ((MeshExecuteTransferMfaType2)
1548
851
  })(MeshExecuteTransferMfaType || {});
1549
852
 
1550
853
  // src/services/moonpay/endpoints.ts
854
+ import { ErrorCode as ErrorCode3, InternalFailureError as InternalFailureError2 } from "@funkit/utils";
1551
855
  async function getMoonpayUrlSignature({
1552
856
  url,
1553
857
  isSandbox,
@@ -1559,8 +863,8 @@ async function getMoonpayUrlSignature({
1559
863
  apiKey
1560
864
  });
1561
865
  if (!signature || !signature?.url) {
1562
- throw new InternalFailureError(
1563
- "UnknownServerError" /* UnknownServerError */,
866
+ throw new InternalFailureError2(
867
+ ErrorCode3.UnknownServerError,
1564
868
  "No onramp url found.",
1565
869
  "",
1566
870
  { url },
@@ -1595,70 +899,6 @@ async function getMoonpayBuyQuoteForCreditCard({
1595
899
  });
1596
900
  return res;
1597
901
  }
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
902
 
1663
903
  // src/services/stripe/endpoints.ts
1664
904
  async function getStripeBuyQuote({
@@ -1752,23 +992,15 @@ async function sendSupportMessage({
1752
992
  }
1753
993
  export {
1754
994
  API_BASE_URL,
1755
- AccessDeniedError,
1756
- BaseError,
1757
995
  CheckoutState,
1758
- ClientError,
1759
996
  DEFAULT_RETRY_OPTIONS,
1760
- ErrorBaseType,
1761
- ErrorCode,
1762
- ErrorType,
1763
997
  FUN_FAUCET_URL,
1764
- InternalFailureError,
1765
- InvalidParameterError,
998
+ MESH_API_BASE_URL,
1766
999
  MeshExecuteTransferMfaType,
1767
1000
  MeshExecuteTransferStatus,
1768
- ResourceNotFoundError,
1769
- ServerError,
1770
- ThrottlingError,
1771
- UserOpFailureError,
1001
+ PaymasterType,
1002
+ addTransaction,
1003
+ checkWalletAccessInitialization,
1772
1004
  createStripeBuySession,
1773
1005
  deactivateCheckout,
1774
1006
  errorAbortHandler,
@@ -1785,11 +1017,11 @@ export {
1785
1017
  getCheckoutsByFunWalletAddress,
1786
1018
  getCheckoutsByRecipientAddress,
1787
1019
  getCheckoutsByUserId,
1020
+ getGroups,
1788
1021
  getMoonpayBuyQuoteForCreditCard,
1789
- getMoonpayOffRampUrl,
1790
- getMoonpayOnRampSupportedCurrencies,
1791
- getMoonpayOnRampUrl,
1792
1022
  getMoonpayUrlSignature,
1023
+ getNftAddress,
1024
+ getNftName,
1793
1025
  getPaymasterDataForCheckoutSponsoredTransfer,
1794
1026
  getRiskAssessmentForAddress,
1795
1027
  getStripeBuyQuote,
@@ -1797,13 +1029,19 @@ export {
1797
1029
  getWalletLidoWithdrawalsByChainId,
1798
1030
  initializeCheckout,
1799
1031
  initializeCheckoutTokenTransferAddress,
1032
+ initializeWalletAccess,
1800
1033
  meshExecuteTransfer,
1034
+ meshExecuteTransferProxy,
1801
1035
  meshGetCryptocurrencyHoldings,
1036
+ meshGetCryptocurrencyHoldingsProxy,
1802
1037
  meshGetLinkToken,
1803
1038
  meshGetTransferIntegrations,
1804
1039
  meshPreviewTransfer,
1040
+ meshPreviewTransferProxy,
1805
1041
  randomBytes,
1042
+ removeTokensFromMeshProxy,
1806
1043
  roundToNearestBottomTenth,
1044
+ saveTokensToMeshProxy,
1807
1045
  sendDeleteRequest,
1808
1046
  sendGetRequest,
1809
1047
  sendPostRequest,