@funkit/core 2.2.8 → 2.2.9

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,5 +1,6 @@
1
1
  // src/actions/AccessControl.ts
2
2
  import { getAddress, pad as pad6 } from "viem";
3
+ import { ErrorCode as ErrorCode8, InvalidParameterError as InvalidParameterError8 } from "@funkit/utils";
3
4
 
4
5
  // src/auth/Auth.ts
5
6
  import {
@@ -13,9 +14,15 @@ import {
13
14
  } from "viem";
14
15
  import { privateKeyToAccount } from "viem/accounts";
15
16
  import * as viemChains from "viem/chains";
17
+ import {
18
+ ErrorCode as ErrorCode7,
19
+ InvalidParameterError as InvalidParameterError7,
20
+ ResourceNotFoundError as ResourceNotFoundError5
21
+ } from "@funkit/utils";
16
22
 
17
23
  // src/apis/UserApis.ts
18
- import { InvalidParameterError as InvalidParameterError2 } from "viem";
24
+ import { InvalidParameterError as InvalidParameterError6 } from "viem";
25
+ import { ResourceNotFoundError as ResourceNotFoundError4 } from "@funkit/utils";
19
26
 
20
27
  // src/common/constants.ts
21
28
  import { padHex } from "viem";
@@ -13367,858 +13374,24 @@ import {
13367
13374
  http,
13368
13375
  createPublicClient
13369
13376
  } from "viem";
13377
+ import {
13378
+ ErrorCode as ErrorCode4,
13379
+ InternalFailureError as InternalFailureError2,
13380
+ InvalidParameterError as InvalidParameterError3,
13381
+ ResourceNotFoundError as ResourceNotFoundError3
13382
+ } from "@funkit/utils";
13370
13383
 
13371
13384
  // src/utils/ApiUtils.ts
13372
13385
  import { retry } from "@lifeomic/attempt";
13373
-
13374
- // src/errors/BaseError.ts
13375
- var discord = "https://discord.gg/mvQunrx6NG";
13376
- var BaseError = class extends Error {
13377
- constructor(baseType, type, code, msg, paramsUsed, fixSuggestion, docLink, isInternal = false) {
13378
- super(`${msg}
13379
-
13380
- ${fixSuggestion}
13381
- Docs: ${docLink}
13382
- Discord: ${discord}`);
13383
- this.baseType = baseType;
13384
- this.type = type;
13385
- this.code = code;
13386
- this.paramsUsed = paramsUsed;
13387
- if (isInternal) {
13388
- this.loadEnd();
13389
- }
13390
- this.message += "\n\nTrace:";
13391
- this.timestamp = (/* @__PURE__ */ new Date()).toUTCString();
13392
- }
13393
- loadEnd() {
13394
- this.message += "\n\nThis is an internal sdk error. Please contact the fun team at our Discord for the fastest response.";
13395
- }
13396
- };
13397
-
13398
- // src/errors/errors.json
13399
- var errors_default = {
13400
- AA21: {
13401
- info: " Your wallet lacks funds for this transaction.",
13402
- suggestion: "To fix this error, make sure you have enough funds in your wallet to cover the transaction fee."
13403
- },
13404
- FW000: {
13405
- info: " Create3Deployer.requireDeployerOnly() - Signatures were not sorted before being passed in",
13406
- 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."
13407
- },
13408
- FW001: {
13409
- info: " Create3Deployer.requireDeployerOnly() - Signature failed to be recovered. ercrecover returned the zero address",
13410
- suggestion: "To fix this error, make sure to pass in enough valid signatures that sign the `hash` in the `sigs` array"
13411
- },
13412
- FW002: {
13413
- info: " Create3Deployer.addDeployer() - Invalid Hash",
13414
- suggestion: "To fix this error, make sure `hash` is equal to `hashAddDeployer()`"
13415
- },
13416
- FW003: {
13417
- info: " Create3Deployer.removeDeployer() - Invalid Hash",
13418
- suggestion: "To fix this error, make sure `hash` is equal to `hashRemoveDeployer()`"
13419
- },
13420
- FW004: {
13421
- info: " Create3Deployer.setThreshold() - Threshold must be greater than 1",
13422
- suggestion: "To fix this error, `threshold` is greater than 1"
13423
- },
13424
- FW005: {
13425
- info: " Create3Deployer.setThreshold() - Invalid Hash",
13426
- suggestion: "To fix this error, make sure `hash` is equal to `keccak256(abi.encodePacked(_threshold))`"
13427
- },
13428
- FW006: {
13429
- info: " Create3Deployer.callChild() - Invalid Hash",
13430
- suggestion: "To fix this error, make sure `hash` is equal to `keccak256(abi.encodePacked(child, data, _nonce, block.chainid))`"
13431
- },
13432
- FW007: {
13433
- info: " Create3Deployer.callChild() - Invalid Nonce, nonce must be 1 greater than the current nonce",
13434
- suggestion: "To fix this error, make sure `_nonce` is equal to the current nonce + 1"
13435
- },
13436
- FW008: {
13437
- info: " Create3Deployer.callChild() - call to child failed",
13438
- suggestion: "To fix this error, check to see what is making the call to the child fail"
13439
- },
13440
- FW009: {
13441
- info: " Create3Deployer.deploy() - Invalid Hash",
13442
- suggestion: "To fix this error, make sure `hash` is equal to `keccak256(abi.encodePacked(_salt, _creationCode))`"
13443
- },
13444
- FW010: {
13445
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
13446
- suggestion: "To fix this error, make sure `_deployer` is not equal to the zero address"
13447
- },
13448
- FW011: {
13449
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
13450
- suggestion: "To fix this error, make sure `_funWalletImpAddress` is not equal to the zero address"
13451
- },
13452
- FW012: {
13453
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
13454
- suggestion: "To fix this error, make sure `_feeOracle` is not equal to the zero address"
13455
- },
13456
- FW013: {
13457
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
13458
- suggestion: "To fix this error, make sure `_walletInit` is not equal to the zero address"
13459
- },
13460
- FW014: {
13461
- info: " FunWalletFactory.constructor() - Unable to generate the address from this deployerSalt",
13462
- 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."
13463
- },
13464
- FW015: {
13465
- info: " FunWalletFactory.constructor() - Generated the wrong address from this deployerSalt",
13466
- 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."
13467
- },
13468
- FW016: {
13469
- info: " FunWalletFactory.createAccount() - Call to initialize failed on the deployed proxy",
13470
- suggestion: "To fix this error, make sure the `initializerCallData` is formatted correctly"
13471
- },
13472
- FW017: {
13473
- info: " FunWalletFactory - Caller must be deployer",
13474
- suggestion: "To fix this error, make sure to call the function from the deployer address"
13475
- },
13476
- FW018: {
13477
- info: " WalletInit.commit() - The previous commit has not expired",
13478
- suggestion: "To fix this error, wait for the previous commit with this `commitKey` to expire. This should take at most 10 minutes."
13479
- },
13480
- FW019: {
13481
- info: " WalletInit.validateSalt() - The hash at the commitKey does not match `keccak256(abi.encode(seed, owner, initializerCallData))`",
13482
- suggestion: "To fix this error, make sure the seed, owner, and initializerCallData are hashed and stored in commits at the corresponding `commitKey`"
13483
- },
13484
- FW020: {
13485
- info: " WalletInit.validateSalt() - The new owner of the funwallet must match data.newFunWalletOwner from loginData",
13486
- suggestion: "To fix this error, make sure the owner set in `loginData` matches the owner address returned from the tweet."
13487
- },
13488
- FW021: {
13489
- info: " WalletInit.setOracle() - The address of the new `_oracle` must not be the zero address",
13490
- suggestion: "To fix this error, make sure `_oracle` is not the zero address"
13491
- },
13492
- FW022: {
13493
- info: " Create3Deployer.deployFromChild() - Invalid Child Address",
13494
- suggestion: "To fix this error, make sure the caller is a contract deployed from the Create3Deployer"
13495
- },
13496
- FW023: {
13497
- info: " ImplementationRegistry.verifyIsValidContractAndImplementation() - Invalid Target Code Hash",
13498
- suggestion: "To fix this error, make sure the caller is a contract targeted is a ERC1967ProxyData contract"
13499
- },
13500
- FW024: {
13501
- info: " ImplementationRegistry.verifyIsValidContractAndImplementation() - Invalid Contract Implementation Address",
13502
- suggestion: "To fix this error, make sure you have the minimun threshold amount of valid signatures."
13503
- },
13504
- FW025: {
13505
- info: " ImplementationRegistry.addImplementation() - Invalid Signature Amount",
13506
- suggestion: "To fix this error, make sure you have the minimun threshold amount of valid signatures."
13507
- },
13508
- FW026: {
13509
- info: " ImplementationRegistry.removeImplementation() - Invalid Signature Amount",
13510
- suggestion: "To fix this error, make sure you have the minimun threshold amount of valid signatures."
13511
- },
13512
- FW027: {
13513
- info: " WalletInit.commit() - Unable to commit with a previously used commit hash",
13514
- 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"
13515
- },
13516
- FW028: {
13517
- info: " MultiSigDeployer.constructor() - Threshold can't be greater than deployers length",
13518
- suggestion: "To fix this error, make sure the threshold value is not 0"
13519
- },
13520
- FW029: {
13521
- info: " WalletInit.invalidateUsedSeed() - msg.sender must equal funwalletfactory",
13522
- suggestion: "To fix this error, make sure you are calling this function from the FunWalletFactory contract"
13523
- },
13524
- FW030: {
13525
- info: " WalletInit.setFunWalletFactory() - funwalletfactory address cannot be set to 0",
13526
- suggestion: "To fix this error, make sure you are passing in the valid funwalletfactory address"
13527
- },
13528
- FW031: {
13529
- info: " WalletInit.validateSalt() - seed has already been used",
13530
- suggestion: "To fix this error, make sure you are not using an existing salt"
13531
- },
13532
- FW032: {
13533
- info: " FunWalletFactory.setFeeOracle() - Cannot set the fee oracle address to 0",
13534
- suggestion: "To fix this error, make sure you are using the correct address of the fee oracle"
13535
- },
13536
- FW033: {
13537
- info: " FunWalletFactory.constructor() - Invalid Address, cannot be the zero address",
13538
- suggestion: "To fix this error, make sure `_entryPoint` is not equal to the zero address"
13539
- },
13540
- FW034: {
13541
- info: " Create3Deployer.callChild() - Value not equal to msg.value",
13542
- suggestion: "To fix this error, make sure `msg.value` is equal to the `value` parameter."
13543
- },
13544
- FW100: {
13545
- info: " Module.execute() - execute() needs to be overriden",
13546
- suggestion: "To fix this error, make sure you are overriding the execute method in your module"
13547
- },
13548
- FW101: {
13549
- info: " ApproveAndExec.approveAndExecute() - the approveData's first four bytes must be the approve() function selector",
13550
- suggestion: "To fix this error, change `approveData` such that the first four bytes are `bytes4(keccak256('approve(address,uint256)'))`"
13551
- },
13552
- FW102: {
13553
- info: " ApproveAndSwap.constructor() - `_wethAddr` cannot be the zero address",
13554
- suggestion: "To fix this error, make sure `_wethAddr` is not set to the zero address"
13555
- },
13556
- FW103: {
13557
- info: " ApproveAndSwap.constructor() - `_router` cannot be the zero address",
13558
- suggestion: "To fix this error, make sure `_router` is not set to the zero address"
13559
- },
13560
- FW104: {
13561
- info: " ApproveAndSwap.executeSwapEth() - msg.sender does not have enough weth",
13562
- suggestion: "To fix this error, make sure msg.sender has a weth balance >= `amount`"
13563
- },
13564
- FW105: {
13565
- info: " ApproveAndSwap.\\_internalSwap() - Approve failed",
13566
- suggestion: "To fix this error, make sure you have formatted approve correctly"
13567
- },
13568
- FW106: {
13569
- info: " AaveWithdraw.execute() - Withdrawing a zero balance",
13570
- suggestion: "You are trying to withdraw from aave but don't have a balance"
13571
- },
13572
- FW107: {
13573
- info: " ApproveAndExec.approveAndExecute() - Approve failed",
13574
- suggestion: "The token you tried to approve failed"
13575
- },
13576
- FW108: {
13577
- info: " UniswapV3LimitOrder.execute() - Approval Failed",
13578
- suggestion: "You are trying to withdraw from aave but don't have a balance"
13579
- },
13580
- FW109: {
13581
- info: " UniswapV3LimitOrder.constructor() - Router cannot be address zero",
13582
- suggestion: "Make sure you are not passing in the zero address when initializing the module"
13583
- },
13584
- FW110: {
13585
- info: " UniswapV3LimitOrder.constructor() - Quoter cannot be zero address",
13586
- suggestion: "Make sure you are not passing in the zero address when initializing the module"
13587
- },
13588
- FW200: {
13589
- info: " FeePercentOracle.setValues() - feepercent must be less than or equals to 100%",
13590
- suggestion: "To fix this error, `_feepercent` must be less than or equals to `10 ** _decimals`"
13591
- },
13592
- FW201: {
13593
- info: " FeePercentOracle.withdrawEth() - eth transfer failed",
13594
- 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"
13595
- },
13596
- FW202: {
13597
- info: " TokenPriceOracle.getTokenValueOfEth() - chainlink aggregator price must be greater than 0",
13598
- suggestion: "To fix this error, retry the call and make sure price is greater than 0"
13599
- },
13600
- FW203: {
13601
- info: " TokenPriceOracle.getTokenValueOfEth() - chainlink aggregator updatedAt must be greater than 0",
13602
- suggestion: "To fix this error, retry the call and make sure updatedAt is greater than 0"
13603
- },
13604
- FW204: {
13605
- info: " TokenPriceOracle.getTokenValueOfEth() - chainlink aggregator answeredInRound must be greater than or equal to roundId",
13606
- suggestion: "To fix this error, retry the call and make sure answeredInRound must be greater than or equal to roundId"
13607
- },
13608
- FW205: {
13609
- info: " TwitterOracle.batchSetTweet() - socialHandles, loginTypes, seeds, owners length must match in length",
13610
- suggestion: "To fix this error, make sure all arrays passed into this function are the same length."
13611
- },
13612
- FW206: {
13613
- info: " TwitterOracle.setTweet() - the seed from twitter cannot be empty",
13614
- suggestion: "To fix this error, make sure the seed you post on twitter is not empty {}"
13615
- },
13616
- FW207: {
13617
- info: " TwitterOracle.setTweet() - the address from twitter cannot be 0",
13618
- 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"
13619
- },
13620
- FW208: {
13621
- info: " TwitterOracle.batchSetTweet() - the seed from twitter cannot be empty",
13622
- suggestion: "To fix this error, make sure the seed you post on twitter is not empty {}"
13623
- },
13624
- FW209: {
13625
- info: " TwitterOracle.batchSetTweet() - the address from twitter cannot be 0",
13626
- 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"
13627
- },
13628
- FW210: {
13629
- info: " TwitterOracle.fetchTweet() - the seed from twitter cannot be empty",
13630
- suggestion: "To fix this error, make sure the seed you post on twitter is not empty {}"
13631
- },
13632
- FW211: {
13633
- info: " TwitterOracle.fetchTweet() - the address from twitter cannot be 0",
13634
- 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"
13635
- },
13636
- FW300: {
13637
- info: " BasePaymaster.constructor() - entrypoint address cannot be the zero address",
13638
- suggestion: "To fix this error, make sure entrypoint address is not the zero address"
13639
- },
13640
- FW301: {
13641
- info: " BasePaymaster.\\_requireFromEntryPoint() - the msg.sender must be from the entrypoint",
13642
- suggestion: "To fix this error, make sure the msg.sender must be from the entrypoint"
13643
- },
13644
- FW302: {
13645
- info: " GaslessPaymaster.batchActions() - the ith delegate call failed",
13646
- suggestion: "To fix this error, make sure the calldata for `data[i]` is a valid call"
13647
- },
13648
- FW303: {
13649
- info: " GaslessPaymaster.batchActions() - batchActions consumed more eth than `msg.value` allocated",
13650
- suggestion: "To fix this error, increase the amount of msg.value you are passing to this function"
13651
- },
13652
- FW304: {
13653
- info: " GaslessPaymaster.\\_withdrawDepositTo() - the withdrawal has not been unlocked",
13654
- suggestion: "To fix this error, wait till block.number is greater than the unlockBlock for the sender and make sure `unlockBlock[sender]` is nonzero"
13655
- },
13656
- FW305: {
13657
- info: " GaslessPaymaster.\\_withdrawDepositTo() - the balances of the sender must be greater than the withdrawal amount",
13658
- suggestion: "To fix this error, decrease the amount you are trying to withdraw"
13659
- },
13660
- FW306: {
13661
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - the userOp.paymasterAndData must have a length of 40",
13662
- suggestion: "To fix this error, change the `paymasterAndData` field in the `userOp` such that the length is 40"
13663
- },
13664
- FW307: {
13665
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - the verificationGasLimit must be greater than the `COST_OF_POST` variable in GaslessPaymaster",
13666
- suggestion: "To fix this error, increase the `verificationGasLimit` in the `userOp`"
13667
- },
13668
- FW308: {
13669
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - the sponsor's eth is not locked for use",
13670
- suggestion: "To fix this error, make sure the sponsor's eth is locked using `lockDeposit()`"
13671
- },
13672
- FW309: {
13673
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - The sponsor needs to approve the spender",
13674
- 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()"
13675
- },
13676
- FW310: {
13677
- info: " GaslessPaymaster.\\_validatePaymasterUserOp() - The sponsor does not have sufficient eth in the paymaster to cover this operation",
13678
- suggestion: "To fix this error, make sure to stake enough eth from the sponsor's address using `addDepositTo()`"
13679
- },
13680
- FW311: {
13681
- info: " GaslessPaymaster.addDepositTo() - `msg.value` must be greater than or equal to amount",
13682
- suggestion: "To fix this error, make sure `msg.value` must be greater than or equal to amount"
13683
- },
13684
- FW312: {
13685
- info: " TokenPaymaster.batchActions() - the ith delegate call failed",
13686
- suggestion: "To fix this error, make sure the calldata for `data[i]` is a valid call"
13687
- },
13688
- FW313: {
13689
- info: " TokenPaymaster.batchActions() - batchActions consumed more eth than `msg.value` allocated",
13690
- suggestion: "To fix this error, increase the amount of msg.value you are passing to this function"
13691
- },
13692
- FW314: {
13693
- info: " TokenPaymaster.\\_addTokenDepositTo() - token decimals must be greater than 0",
13694
- suggestion: "To fix this error, change the decimals in token using `setTokenData()`"
13695
- },
13696
- FW315: {
13697
- info: " TokenPaymaster.\\_withdrawTokenDepositTo() - token is not unlocked for withdrawal",
13698
- suggestion: "To fix this error, call `unlockTokenDepositAfter()`"
13699
- },
13700
- FW316: {
13701
- info: " TokenPaymaster.\\_withdrawTokenDepositTo() - you are withdrawing more tokens that you have in balance",
13702
- suggestion: "To fix this error, call `getTokenBalance()` to check how many tokens you have and make sure `amount` is less than that"
13703
- },
13704
- FW317: {
13705
- info: " TokenPaymaster.\\_withdrawEthDepositTo() - token is not unlocked for withdrawal",
13706
- suggestion: "To fix this error, call `unlockTokenDepositAfter()` with `ETH` as the token"
13707
- },
13708
- FW318: {
13709
- info: " TokenPaymaster.\\_withdrawEthDepositTo() - you are withdrawing more ether that you have in balance",
13710
- 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"
13711
- },
13712
- FW319: {
13713
- info: " TokenPaymaster.\\_getTokenValueOfEth() - call to token oracle failed",
13714
- suggestion: "To fix this error, check the token oracle and call `setTokenData()` to change the oracle if it is broken"
13715
- },
13716
- FW320: {
13717
- info: " TokenPaymaster.\\_reimbursePaymaster() - failed to reimbursePaymaster with tokens via `permitTransfer()`",
13718
- suggestion: "To fix this **error**, make sure you have permitted the paymaster to spend your tokens"
13719
- },
13720
- FW321: {
13721
- info: " TokenPaymaster.\\_reimbursePaymaster() - spender doesn't have enough tokens",
13722
- suggestion: "To fix this error, make sure to add more tokens to the token paymaster via `addTokenDepositTo()`"
13723
- },
13724
- FW322: {
13725
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - `paymasterAndData` length must be 60",
13726
- suggestion: "To fix this error, make sure to set `paymasterAndData` length to be 60"
13727
- },
13728
- FW323: {
13729
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - `verificationGasLimit` must be greater than `COST_OF_POST`",
13730
- suggestion: "To fix this error, make sure to set the userOp's `verificationGasLimit` to be greater than `COST_OF_POST`"
13731
- },
13732
- FW324: {
13733
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor must lock their ETH",
13734
- suggestion: "To fix this error, make sure the sponsor has locked their eth by calling `lockTokenDeposit()` from the sponsor address"
13735
- },
13736
- FW325: {
13737
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the account must lock their tokens",
13738
- suggestion: "To fix this error, make sure the user of the token paymaster has locked their tokens by calling `lockTokenDeposit()` from their address"
13739
- },
13740
- FW326: {
13741
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor eth balance must be greater than maxCost",
13742
- suggestion: "To fix this error, make sure the sponsor eth balance is greater than maxCost"
13743
- },
13744
- FW327: {
13745
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor must approve the spender",
13746
- 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()`"
13747
- },
13748
- FW328: {
13749
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the sponsor must have approved the token to the paymaster",
13750
- 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()`"
13751
- },
13752
- FW329: {
13753
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the permitted token must be equal to the token you are trying to pay with if using permit",
13754
- suggestion: "To fix this error, make sure the permitted token is equal to the token you are trying to pay with if using permit"
13755
- },
13756
- FW330: {
13757
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the permitted transfer recipient must be the token paymaster",
13758
- suggestion: "To fix this error, make sure to permit the token paymaster to spend your tokens"
13759
- },
13760
- FW331: {
13761
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - the permitted transfer amount must be greater than or equal to the maxTokenCost",
13762
- suggestion: "To fix this error, make sure the permitted transfer amount is greater than or equal to the maxTokenCost"
13763
- },
13764
- FW332: {
13765
- 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",
13766
- 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()`"
13767
- },
13768
- FW333: {
13769
- info: " TokenPaymaster.addEthDepositTo() - make sure msg.value is greater than or equal to amount",
13770
- suggestion: "To fix this error, make sure that the msg.value is greater than or equal to amount"
13771
- },
13772
- FW334: {
13773
- info: " TokenPaymaster.addTokenDepositTo() - sponsor cannot be the zero address",
13774
- suggestion: "To fix this error, make sure the sponsor is not the zero address"
13775
- },
13776
- FW335: {
13777
- info: " TokenPaymaster.addTokenDepositTo() - target cannot be the zero address",
13778
- suggestion: "To fix this error, make sure the target is not the zero address"
13779
- },
13780
- FW336: {
13781
- info: " TokenPaymaster.addTokenDepositTo() - token address cannot be the zero address",
13782
- suggestion: "To fix this error, make sure the token address is not the zero address"
13783
- },
13784
- FW337: {
13785
- info: " TokenPaymaster.addTokenDepositTo() - spender address cannot be the zero address",
13786
- suggestion: "To fix this error, make sure the spender address is not the zero address"
13787
- },
13788
- FW338: {
13789
- info: " TokenPaymaster.addTokenDepositTo() - the token oracle cannot be the zero address",
13790
- suggestion: "To fix this error, make sure the token oracle is not the zero address"
13791
- },
13792
- FW339: {
13793
- info: " TokenPaymaster.addTokenDepositTo() - the tokenAddress cannot be the zero address",
13794
- suggestion: "To fix this error, make sure the tokenAddress is not the zero address"
13795
- },
13796
- FW340: {
13797
- info: " TokenPaymaster.addTokenDepositTo() - the token decimals must be greater than 0",
13798
- suggestion: "To fix this error, make sure the token decimals is greater than 0"
13799
- },
13800
- FW341: {
13801
- info: " TokenPaymaster.addTokenDepositTo() - the chainlink aggregator cannot be the zero address",
13802
- suggestion: "To fix this error, make sure the chainlink aggregator is not the zero address"
13803
- },
13804
- FW342: {
13805
- info: " TokenPaymaster.removeTokenData() - The token doesn't exist in tokens",
13806
- suggestion: "To fix this error, make sure the token address is not the zero address"
13807
- },
13808
- FW343: {
13809
- info: " TokenPaymaster.removeTokenData() - The tokenListIndex doesn't match with the tokenAddress",
13810
- suggestion: "To fix this error, make sure the token at tokenList[tokenListIndex] is the same as the tokenAddress"
13811
- },
13812
- FW344: {
13813
- info: " GaslessPaymaster.batchActions() - Cannot recursively call batchActions from within batchActions",
13814
- suggestion: "To fix this error, make sure you are not recursively calling batchActions from within batchActions"
13815
- },
13816
- FW345: {
13817
- info: " TokenPaymaster.batchActions() - Cannot recursively call batchActions from within batchActions",
13818
- suggestion: "To fix this error, make sure you are not recursively calling batchActions from within batchActions"
13819
- },
13820
- FW346: {
13821
- info: " TokenPaymaster.postOp() - Invalid Permit transfer amount",
13822
- suggestion: "To fix this error, make sure your permit transfer has transfered the correct amount of tokens"
13823
- },
13824
- FW347: {
13825
- info: " TokenPaymaster.\\_reimbursePaymaster() - Invalid amount of tokens transferred",
13826
- 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."
13827
- },
13828
- FW348: {
13829
- info: " UserAuthentication.init() - groupId count must be equal to groups length",
13830
- suggestion: "Make sure the number of groupIds equals the number of groups."
13831
- },
13832
- FW349: {
13833
- info: " TokenPaymaster.calculatePostOpGas() - Invalid Auth Type",
13834
- suggestion: "Make sure the authtype is correct"
13835
- },
13836
- FW350: {
13837
- info: " TokenPaymaster.\\_validatePaymasterUserOp() - Does not have enough balance of token",
13838
- suggestion: "To fix this error, make sure your has enough tokens to permit transfer"
13839
- },
13840
- FW351: {
13841
- info: " BasePaymaster.\\withdrawStakeFromEntryPoint() - Cannot withdraw to address zero",
13842
- suggestion: "To fix this error, make sure you are not withdrawing to address zero"
13843
- },
13844
- FW401: {
13845
- info: " RoleBasedAccessControl",
13846
- suggestion: "### `FW402`: RoleBasedAccessControl.isValidAction(), isValidActionAndFee() - Invalid Target"
13847
- },
13848
- FW402: {
13849
- info: " RoleBasedAccessControl.isValidAction(), isValidActionAndFee() - Invalid Target",
13850
- 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."
13851
- },
13852
- FW403: {
13853
- info: " RoleBasedAccessControl",
13854
- 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."
13855
- },
13856
- FW404: {
13857
- info: " RoleBasedAccessControl",
13858
- suggestion: "To fix this error, make sure the ownerId is not 0 or an existing owner"
13859
- },
13860
- FW405: {
13861
- info: " RoleBasedAccessControl",
13862
- suggestion: "To fix this error, make sure the ruleId is not 0"
13863
- },
13864
- FW406: {
13865
- info: " RoleBasedAccessControl",
13866
- suggestion: "To fix this error, make sure the rule that you are using has a deadline that has passed."
13867
- },
13868
- FW408: {
13869
- info: " RoleBasedAccessControl",
13870
- suggestion: "### `FW410`: RoleBasedAccessControl: isValidAction(), isValidActionAndFee() - Rule not added to role"
13871
- },
13872
- FW410: {
13873
- info: " RoleBasedAccessControl",
13874
- suggestion: "To fix this error, make sure the rule is added to the role"
13875
- },
13876
- FW411: {
13877
- info: " RoleBasedAccessControl",
13878
- suggestion: "To fix this error, make sure the value for the execution call is less than the limit"
13879
- },
13880
- FW412: {
13881
- info: " RoleBasedAccessControl",
13882
- suggestion: "To fix this error, make sure the fee value for the execution call is less than the limit"
13883
- },
13884
- FW413: {
13885
- info: " RoleBasedAccessControl",
13886
- suggestion: "To fix this error, make sure the fee recipient is in the rule fee merkle root"
13887
- },
13888
- FW414: {
13889
- info: " RoleBasedAccessControl",
13890
- suggestion: "To fix this error, make sure the fee token is in the rule fee merkle root"
13891
- },
13892
- FW417: {
13893
- info: " RoleBasedAccessControl",
13894
- suggestion: "To fix this error, make sure the rule you are using exists"
13895
- },
13896
- FW418: {
13897
- info: " RoleBasedAccessControl",
13898
- suggestion: "To fix this error, make sure the user is in the role"
13899
- },
13900
- FW419: {
13901
- info: " RoleBasedAccessControl",
13902
- suggestion: "To fix this error, make sure the feeRecipientTokenMerkleRootHash is not zero"
13903
- },
13904
- FW420: {
13905
- info: " RoleBasedAccessControl",
13906
- suggestion: "To fix this error, make sure the targetSelectorMerkleRootHash is not zero"
13907
- },
13908
- FW421: {
13909
- info: " RoleBasedAccessControl",
13910
- suggestion: "### `FW422`: RoleBasedAccessControl: init() - Wallet has not been initialized"
13911
- },
13912
- FW422: {
13913
- info: " RoleBasedAccessControl",
13914
- suggestion: "To fix this error, make sure the wallet has not initialized the validation contract"
13915
- },
13916
- FW500: {
13917
- info: " FunWallet.initialize() - the entrypoint cannot be the zero address",
13918
- suggestion: "To fix this error, make sure the entrypoint is not the zero address"
13919
- },
13920
- FW501: {
13921
- info: " FunWallet.initialize() - the msg.sender cannot be the address of the Funwallet contract",
13922
- suggestion: "To fix this error, make sure the msg.sender is not the address of the Funwallet contract"
13923
- },
13924
- FW502: {
13925
- info: " FunWallet.\\_requireFromFunWalletProxy() - the function must be called from the funwallet proxy",
13926
- suggestion: "To fix this error, make sure the msg.sender == funwallet"
13927
- },
13928
- FW503: {
13929
- info: " FunWallet.updateEntryPoint() - the new entrypoint address cannot be the zero address",
13930
- suggestion: "To fix this error, make sure the new entrypoint address is not the zero address"
13931
- },
13932
- FW504: {
13933
- info: " FunWallet.depositToEntryPoint() - not enough eth in the funwallet",
13934
- suggestion: "To fix this error, make sure the funwallet has more than the amount of eth you are trying to deposit"
13935
- },
13936
- FW505: {
13937
- info: " FunWallet.\\_transferEthFromEntrypoint() - withdrawing eth from the entrypoint failed",
13938
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the entrypoint"
13939
- },
13940
- FW506: {
13941
- info: " FunWallet.\\_requireFromModule() - make sure a funwalletfactory deployed the module",
13942
- suggestion: "To fix this error, make sure the msg.sender is the module"
13943
- },
13944
- FW507: {
13945
- info: " FunWallet.\\_requireFromEntryPoint() - the msg.sender must be the entrypoint",
13946
- suggestion: "To fix this error, make sure the msg.sender is the entrypoint"
13947
- },
13948
- FW508: {
13949
- info: " WalletFee.\\_transferEth() - the eth transfer failed",
13950
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the wallet"
13951
- },
13952
- FW509: {
13953
- info: " WalletFee.\\_handleFee() - the developer eth transfer failed",
13954
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the wallet"
13955
- },
13956
- FW510: {
13957
- info: " WalletFee.\\_handleFee() - the funOracle eth transfer failed",
13958
- suggestion: "To fix this error, retry the operation and make sure you have greater than amount balance in the wallet"
13959
- },
13960
- FW511: {
13961
- info: " WalletValidation.initValidations() - the WalletValidations contract has already been initialized",
13962
- suggestion: "Don't call initValidations() more than once"
13963
- },
13964
- FW512: {
13965
- info: " WalletValidation.initValidations() - make sure there are more than zero validations",
13966
- 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"
13967
- },
13968
- FW513: {
13969
- info: " WalletValidation.initValidations() - make sure there are no duplicate validation contract addresses",
13970
- suggestion: "To fix this error, make sure there are no duplicate validation contract addresses in `validationData`"
13971
- },
13972
- FW514: {
13973
- info: " WalletValidation.\\_validateUserOp() - make sure the signature length is greater than 0",
13974
- suggestion: "To fix this error, make sure the signature length is greater than 0"
13975
- },
13976
- FW515: {
13977
- info: " WalletValidation.isValidSignature() - make sure the number of validations is greater than zero",
13978
- suggestion: "To fix this error, make sure the number of validations is greater than zero"
13979
- },
13980
- FW516: {
13981
- info: " WalletValidation.\\_requireValidValidation() - the validation failed",
13982
- suggestion: "To fix this error, make sure the validation contract returns true"
13983
- },
13984
- FW517: {
13985
- info: " WalletValidation.\\_requireValidValidationFormat() - the validation was incorrectly formatted",
13986
- 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"
13987
- },
13988
- FW518: {
13989
- info: " WalletValidation.\\_requireValidPrevValidation() - the previous validation must be linked to this validation",
13990
- suggestion: "To fix this error, make sure the previous validation is linked to this validation when adding or removing the validation"
13991
- },
13992
- FW519: {
13993
- info: " WalletValidation.getValidations() - you must have more than zero validations to get validations",
13994
- suggestion: "To fix this error, make sure there are a nonzero amount of validations"
13995
- },
13996
- FW520: {
13997
- info: " WalletValidation.addValidation() - The caller must be this wallet.",
13998
- suggestion: "To fix this error, make sure you are calling addValidation() from your funwallet."
13999
- },
14000
- FW521: {
14001
- info: " WalletValidation.removeValidation() - The caller must be this wallet.",
14002
- suggestion: "To fix this error, make sure you are calling removeValidation() from your funwallet."
14003
- },
14004
- FW522: {
14005
- info: " WalletValidation.updateValidation() - The caller must be this wallet.",
14006
- suggestion: "To fix this error, make sure you are calling updateValidation() from your funwallet."
14007
- },
14008
- FW523: {
14009
- info: " WalletModules.permitTransfer() - Invalid Permit Signature.",
14010
- suggestion: "To fix this error, make sure you have a valid permit signature."
14011
- },
14012
- FW524: {
14013
- info: " WalletValidation.getValidations() - No Validations in the wallet",
14014
- suggestion: "To fix this error, make sure the wallet has validation contracts"
14015
- },
14016
- FW600: {
14017
- info: " DataLib",
14018
- suggestion: "To fix this error, make sure you are calling either execFromEntryPoint() or execFromEntryPointWithFee() from your funwallet."
14019
- },
14020
- FW601: {
14021
- info: " Ownable2StepNoRenounce",
14022
- suggestion: "To fix this error, don't call this function."
14023
- }
14024
- };
14025
-
14026
- // src/errors/types.ts
14027
- var ErrorBaseType = /* @__PURE__ */ ((ErrorBaseType2) => {
14028
- ErrorBaseType2["ClientError"] = "ClientError";
14029
- ErrorBaseType2["ServerError"] = "ServerError";
14030
- return ErrorBaseType2;
14031
- })(ErrorBaseType || {});
14032
- var ErrorType = /* @__PURE__ */ ((ErrorType2) => {
14033
- ErrorType2["InvalidParameter"] = "InvalidParameter";
14034
- ErrorType2["InternalServerFailure"] = "InternalServerFailure";
14035
- ErrorType2["ResourceNotFound"] = "ResourceNotFound";
14036
- ErrorType2["InvalidAction"] = "InvalidAction";
14037
- ErrorType2["ThrottlingError"] = "ThrottlingError";
14038
- ErrorType2["AccessDeniedError"] = "AccessDeniedError";
14039
- ErrorType2["UserOpFailureError"] = "UserOpFailureError";
14040
- return ErrorType2;
14041
- })(ErrorType || {});
14042
- var ErrorCode = /* @__PURE__ */ ((ErrorCode2) => {
14043
- ErrorCode2["MissingParameter"] = "MissingParameter";
14044
- ErrorCode2["InvalidParameter"] = "InvalidParameter";
14045
- ErrorCode2["InvalidThreshold"] = "InvalidThreshold";
14046
- ErrorCode2["InvalidChainIdentifier"] = "InvalidChainIdentifier";
14047
- ErrorCode2["InvalidNFTIdentifier"] = "InvalidNFTIdentifier";
14048
- ErrorCode2["InsufficientSignatures"] = "InsufficientSignatures";
14049
- ErrorCode2["InvalidParameterCombination"] = "InvalidParameterCombination";
14050
- ErrorCode2["CheckPointHintsNotFound"] = "CheckPointHintsNotFound";
14051
- ErrorCode2["GroupNotFound"] = "GroupNotFound";
14052
- ErrorCode2["TokenNotFound"] = "TokenNotFound";
14053
- ErrorCode2["AddressNotFound"] = "AddressNotFound";
14054
- ErrorCode2["UserAlreadyExists"] = "UserAlreadyExists";
14055
- ErrorCode2["UserNotFound"] = "UserNotFound";
14056
- ErrorCode2["ChainNotSupported"] = "ChainNotSupported";
14057
- ErrorCode2["ServerMissingData"] = "ServerMissingData";
14058
- ErrorCode2["ServerFailure"] = "ServerFailure";
14059
- ErrorCode2["ServerTimeout"] = "ServerTimeout";
14060
- ErrorCode2["UnknownServerError"] = "UnknownServerError";
14061
- ErrorCode2["ServerConnectionError"] = "ServerConnectionError";
14062
- ErrorCode2["UserOpFailureError"] = "UserOpFailureError";
14063
- ErrorCode2["Unauthorized"] = "Unauthorized";
14064
- ErrorCode2["RequestLimitExceeded"] = "RequestLimitExceeded";
14065
- ErrorCode2["WalletPrefundError"] = "PrefundError";
14066
- ErrorCode2["GasSponsorFundError"] = "GasSponsorFundError";
14067
- ErrorCode2["FunWalletErrorCode"] = "FunWalletErrorCode";
14068
- ErrorCode2["BridgeRouteNotFound"] = "BridgeRouteNotFound";
14069
- ErrorCode2["BridgeAllowanceDataNotFound"] = "BridgeAllowanceDataNotFound";
14070
- ErrorCode2["BridgeApproveTxDataNotFound"] = "BridgeApproveTxDataNotFound";
14071
- ErrorCode2["CheckoutInitDepositAddrNotFound"] = "CheckoutInitDepositAddrNotFound";
14072
- return ErrorCode2;
14073
- })(ErrorCode || {});
14074
-
14075
- // src/errors/ClientError.ts
14076
- var ClientError = class extends BaseError {
14077
- constructor(type, code, msg, paramsUsed, fixSuggestion, docLink) {
14078
- super(
14079
- "ClientError" /* ClientError */,
14080
- type,
14081
- code,
14082
- msg,
14083
- paramsUsed,
14084
- fixSuggestion,
14085
- docLink,
14086
- false
14087
- );
14088
- }
14089
- };
14090
- var InvalidParameterError = class extends ClientError {
14091
- constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
14092
- super(
14093
- "InvalidParameter" /* InvalidParameter */,
14094
- code,
14095
- msg,
14096
- paramsUsed,
14097
- fixSuggestion,
14098
- docLink
14099
- );
14100
- }
14101
- };
14102
- var ResourceNotFoundError = class extends ClientError {
14103
- constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
14104
- if (msg.includes("Chain name not found")) {
14105
- const { reqId } = JSON.parse(msg);
14106
- super(
14107
- "ResourceNotFound" /* ResourceNotFound */,
14108
- "ChainNotSupported" /* ChainNotSupported */,
14109
- ": Chain name not found or not supported.",
14110
- { reqId },
14111
- "Change your EnvOptions to the correct chain identifier.",
14112
- docLink
14113
- );
14114
- } else {
14115
- super(
14116
- "ResourceNotFound" /* ResourceNotFound */,
14117
- code,
14118
- msg,
14119
- paramsUsed,
14120
- fixSuggestion,
14121
- docLink
14122
- );
14123
- }
14124
- }
14125
- };
14126
- var InvalidActionError = class extends ClientError {
14127
- constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
14128
- super(
14129
- "InvalidAction" /* InvalidAction */,
14130
- code,
14131
- msg,
14132
- paramsUsed,
14133
- fixSuggestion,
14134
- docLink
14135
- );
14136
- }
14137
- };
14138
- var ThrottlingError = class extends ClientError {
14139
- constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
14140
- super(
14141
- "ThrottlingError" /* ThrottlingError */,
14142
- code,
14143
- msg,
14144
- paramsUsed,
14145
- fixSuggestion,
14146
- docLink
14147
- );
14148
- }
14149
- };
14150
- var AccessDeniedError = class extends ClientError {
14151
- constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
14152
- super(
14153
- "AccessDeniedError" /* AccessDeniedError */,
14154
- code,
14155
- msg,
14156
- paramsUsed,
14157
- fixSuggestion,
14158
- docLink
14159
- );
14160
- }
14161
- };
14162
- var UserOpFailureError = class extends ClientError {
14163
- constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
14164
- const FWCode = findFWContractError(msg);
14165
- if (FWCode) {
14166
- const { reqId } = JSON.parse(msg);
14167
- super(
14168
- "UserOpFailureError" /* UserOpFailureError */,
14169
- "FunWalletErrorCode" /* FunWalletErrorCode */,
14170
- errors_default[FWCode].info,
14171
- { reqId },
14172
- errors_default[FWCode].suggestion,
14173
- docLink
14174
- );
14175
- } else {
14176
- super(
14177
- "UserOpFailureError" /* UserOpFailureError */,
14178
- code,
14179
- msg,
14180
- paramsUsed,
14181
- fixSuggestion,
14182
- docLink
14183
- );
14184
- }
14185
- }
14186
- };
14187
- var findFWContractError = (msg) => {
14188
- let match = msg.match(/FW\d{3}/);
14189
- if (!match) {
14190
- match = msg.match(/AA\d./);
14191
- }
14192
- return match?.[0];
14193
- };
14194
-
14195
- // src/errors/ServerError.ts
14196
- var ServerError = class extends BaseError {
14197
- constructor(type, code, msg, paramsUsed, fixSuggestion, docLink) {
14198
- super(
14199
- "ServerError" /* ServerError */,
14200
- type,
14201
- code,
14202
- msg,
14203
- paramsUsed,
14204
- fixSuggestion,
14205
- docLink,
14206
- true
14207
- );
14208
- }
14209
- };
14210
- var InternalFailureError = class extends ServerError {
14211
- constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
14212
- super(
14213
- "InternalServerFailure" /* InternalServerFailure */,
14214
- code,
14215
- msg,
14216
- paramsUsed,
14217
- fixSuggestion,
14218
- docLink
14219
- );
14220
- }
14221
- };
13386
+ import {
13387
+ AccessDeniedError,
13388
+ ErrorCode as ErrorCode2,
13389
+ InternalFailureError,
13390
+ InvalidParameterError as InvalidParameterError2,
13391
+ ResourceNotFoundError,
13392
+ ThrottlingError,
13393
+ UserOpFailureError
13394
+ } from "@funkit/utils";
14222
13395
 
14223
13396
  // src/utils/AuthUtils.ts
14224
13397
  import { v4 as uuidv4 } from "uuid";
@@ -14247,6 +13420,7 @@ import {
14247
13420
  toBytes,
14248
13421
  toHex
14249
13422
  } from "viem";
13423
+ import { ErrorCode, InvalidParameterError } from "@funkit/utils";
14250
13424
  var isAddress = (address) => {
14251
13425
  try {
14252
13426
  const [decodedAddr] = decodeAbiParameters(
@@ -14361,7 +13535,8 @@ var useFaucet = async (chainIdentifier, wallet) => {
14361
13535
  const chainName = await chain.getChainName();
14362
13536
  if (chainName !== "goerli") {
14363
13537
  throw new InvalidParameterError(
14364
- "InvalidChainIdentifier" /* InvalidChainIdentifier */,
13538
+ ErrorCode.InvalidChainIdentifier,
13539
+ "Only Goerli is supported",
14365
13540
  "Only Goerli is supported",
14366
13541
  chainIdentifier,
14367
13542
  "Provide the goerli chain, 5, or goerli as the chain identifier",
@@ -14709,6 +13884,7 @@ import {
14709
13884
  toBytes as toBytes2,
14710
13885
  toHex as toHex2
14711
13886
  } from "viem";
13887
+ import { safeParseJson } from "@funkit/utils";
14712
13888
  var calcPreVerificationGas = (userOp) => {
14713
13889
  const ov = DefaultGasOverheads;
14714
13890
  const p = Object.assign(
@@ -14796,7 +13972,7 @@ var stringify = (object) => {
14796
13972
  );
14797
13973
  };
14798
13974
  var objectify = (op) => {
14799
- return JSON.parse(stringify(op));
13975
+ return safeParseJson(stringify(op));
14800
13976
  };
14801
13977
  var DefaultGasOverheads = {
14802
13978
  fixed: 28e3,
@@ -14957,7 +14133,7 @@ var isSignatureMissing = (userId, signatures) => {
14957
14133
 
14958
14134
  // src/utils/ApiUtils.ts
14959
14135
  var errorHandler = (err, context) => {
14960
- if (err instanceof ResourceNotFoundError || err instanceof InvalidParameterError || err instanceof UserOpFailureError) {
14136
+ if (err instanceof ResourceNotFoundError || err instanceof InvalidParameterError2 || err instanceof UserOpFailureError) {
14961
14137
  context.abort();
14962
14138
  }
14963
14139
  };
@@ -14997,68 +14173,82 @@ var sendRequest = async (uri, method, apiKey, body, retryOptions) => {
14997
14173
  const json = await response.json();
14998
14174
  if (response.ok) {
14999
14175
  return json;
15000
- } else if (response.status === 400) {
15001
- throw new InvalidParameterError(
15002
- "InvalidParameter" /* InvalidParameter */,
14176
+ }
14177
+ if (response.status === 400) {
14178
+ throw new InvalidParameterError2(
14179
+ ErrorCode2.InvalidParameter,
14180
+ `bad request ${JSON.stringify(json)}`,
15003
14181
  `bad request ${JSON.stringify(json)}`,
15004
14182
  { body },
15005
14183
  "check the api call parameters. its mostly because some call parameters are wrong",
15006
14184
  "https://docs.fun.xyz"
15007
14185
  );
15008
- } else if (response.status === 403) {
14186
+ }
14187
+ if (response.status === 403) {
15009
14188
  throw new AccessDeniedError(
15010
- "Unauthorized" /* Unauthorized */,
14189
+ ErrorCode2.Unauthorized,
14190
+ "Invalid API key or insufficient access.",
15011
14191
  "Invalid API key or insufficient access.",
15012
14192
  { apiKey },
15013
14193
  "Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
15014
14194
  "https://docs.fun.xyz"
15015
14195
  );
15016
- } else if (response.status === 404) {
14196
+ }
14197
+ if (response.status === 404) {
15017
14198
  throw new ResourceNotFoundError(
15018
- "ServerMissingData" /* ServerMissingData */,
14199
+ ErrorCode2.ServerMissingData,
14200
+ JSON.stringify(json),
15019
14201
  JSON.stringify(json),
15020
14202
  { body },
15021
14203
  "check the api call parameters. its mostly because some call parameters are wrong",
15022
14204
  "https://docs.fun.xyz"
15023
14205
  );
15024
- } else if (response.status === 429) {
14206
+ }
14207
+ if (response.status === 429) {
15025
14208
  throw new ThrottlingError(
15026
- "RequestLimitExceeded" /* RequestLimitExceeded */,
14209
+ ErrorCode2.RequestLimitExceeded,
14210
+ `too many requests ${JSON.stringify(json)}`,
15027
14211
  `too many requests ${JSON.stringify(json)}`,
15028
14212
  { body },
15029
14213
  "you are making too many requests. please slow down. Reach out to fun team if you need more quota",
15030
14214
  "https://docs.fun.xyz"
15031
14215
  );
15032
- } else if (response.status === 500) {
15033
- if (json.errorCode === "UserOpFailureError" /* UserOpFailureError */) {
14216
+ }
14217
+ if (response.status === 500) {
14218
+ if (json.errorCode === ErrorCode2.UserOpFailureError) {
15034
14219
  throw new UserOpFailureError(
15035
- "UserOpFailureError" /* UserOpFailureError */,
14220
+ ErrorCode2.UserOpFailureError,
14221
+ JSON.stringify(json),
15036
14222
  JSON.stringify(json),
15037
14223
  { body },
15038
14224
  "fix user op failure. Most of the time this is due to invalid parameters",
15039
14225
  "https://docs.fun.xyz"
15040
14226
  );
15041
- } else {
15042
- throw new InternalFailureError(
15043
- "ServerFailure" /* ServerFailure */,
15044
- `server failure ${JSON.stringify(json)}`,
15045
- { body },
15046
- "retry later. if it still fails, please contact us.",
15047
- "https://docs.fun.xyz"
15048
- );
15049
14227
  }
15050
- } else if (response.status === 504) {
15051
14228
  throw new InternalFailureError(
15052
- "ServerTimeout" /* ServerTimeout */,
14229
+ ErrorCode2.ServerFailure,
14230
+ `server failure ${JSON.stringify(json)}`,
14231
+ json.errorMsg,
14232
+ { body },
14233
+ "retry later. if it still fails, please contact us.",
14234
+ "https://docs.fun.xyz"
14235
+ );
14236
+ }
14237
+ if (response.status === 504) {
14238
+ throw new InternalFailureError(
14239
+ ErrorCode2.ServerTimeout,
15053
14240
  `server timeout failure ${JSON.stringify(json)}`,
14241
+ json.errorMsg,
15054
14242
  { body },
15055
14243
  "retry later. if it still fails, please contact us.",
15056
14244
  "https://docs.fun.xyz"
15057
14245
  );
15058
- } else if (!response.ok) {
14246
+ }
14247
+ if (!response.ok) {
15059
14248
  throw new InternalFailureError(
15060
- "UnknownServerError" /* UnknownServerError */,
14249
+ ErrorCode2.UnknownServerError,
15061
14250
  `unknown server failure ${JSON.stringify(json)}`,
14251
+ json.errorMsg,
15062
14252
  { body },
15063
14253
  "retry later. if it still fails, please contact us.",
15064
14254
  "https://docs.fun.xyz"
@@ -15068,8 +14258,9 @@ var sendRequest = async (uri, method, apiKey, body, retryOptions) => {
15068
14258
  }, finalRetryOptions);
15069
14259
  } catch (err) {
15070
14260
  throw new InternalFailureError(
15071
- "ServerConnectionError" /* ServerConnectionError */,
14261
+ ErrorCode2.ServerConnectionError,
15072
14262
  `Cannot connect to Fun API Service ${err}`,
14263
+ "",
15073
14264
  { body },
15074
14265
  "retry later. if it still fails, please contact us.",
15075
14266
  "https://docs.fun.xyz"
@@ -15129,6 +14320,7 @@ async function getGroupsByWallet(walletAddr, chainId) {
15129
14320
  }
15130
14321
 
15131
14322
  // src/apis/InfoApis.ts
14323
+ import { ErrorCode as ErrorCode3, ResourceNotFoundError as ResourceNotFoundError2 } from "@funkit/utils";
15132
14324
  async function getTokenInfo(symbol, chainId) {
15133
14325
  const normalizedSymbol = symbol.toLowerCase();
15134
14326
  const body = {
@@ -15147,8 +14339,9 @@ async function getTokenInfo(symbol, chainId) {
15147
14339
  if (tokenInfo.address) {
15148
14340
  return tokenInfo.address;
15149
14341
  }
15150
- throw new ResourceNotFoundError(
15151
- "TokenNotFound" /* TokenNotFound */,
14342
+ throw new ResourceNotFoundError2(
14343
+ ErrorCode3.TokenNotFound,
14344
+ "token symbol does not exist on provided chain",
15152
14345
  "token symbol does not exist on provided chain",
15153
14346
  { symbol, chainId },
15154
14347
  "Provide correct symbol and chainId.",
@@ -15293,8 +14486,9 @@ var Chain = class _Chain {
15293
14486
  this.initialized = false;
15294
14487
  this.addresses = {};
15295
14488
  if (!chainInput.chainIdentifier && !chainInput.rpcUrl) {
15296
- throw new InvalidParameterError(
15297
- "InvalidChainIdentifier" /* InvalidChainIdentifier */,
14489
+ throw new InvalidParameterError3(
14490
+ ErrorCode4.InvalidChainIdentifier,
14491
+ "valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
15298
14492
  "valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
15299
14493
  { chainInput },
15300
14494
  "Please provide valid chain identifier or rpcUrl",
@@ -15389,8 +14583,9 @@ var Chain = class _Chain {
15389
14583
  await this.init();
15390
14584
  const res = this.addresses[name];
15391
14585
  if (!res) {
15392
- throw new ResourceNotFoundError(
15393
- "AddressNotFound" /* AddressNotFound */,
14586
+ throw new ResourceNotFoundError3(
14587
+ ErrorCode4.AddressNotFound,
14588
+ "address not found",
15394
14589
  "address not found",
15395
14590
  { name },
15396
14591
  "Provide correct name to query address",
@@ -15428,9 +14623,10 @@ var Chain = class _Chain {
15428
14623
  async estimateOpGas(partialOp) {
15429
14624
  await this.init();
15430
14625
  if (!this.addresses || !this.addresses.entryPointAddress) {
15431
- throw new InternalFailureError(
15432
- "AddressNotFound" /* AddressNotFound */,
14626
+ throw new InternalFailureError2(
14627
+ ErrorCode4.AddressNotFound,
15433
14628
  "entryPointAddress is required",
14629
+ "",
15434
14630
  { partialOp },
15435
14631
  "This is an internal error, please contact support.",
15436
14632
  "https://docs.fun.xyz"
@@ -15502,12 +14698,14 @@ var Chain = class _Chain {
15502
14698
 
15503
14699
  // src/data/NFT.ts
15504
14700
  import { isAddress as isAddress2 } from "viem";
14701
+ import { ErrorCode as ErrorCode5, InvalidParameterError as InvalidParameterError4 } from "@funkit/utils";
15505
14702
  var NFT = class _NFT {
15506
14703
  constructor(input) {
15507
14704
  this.name = "";
15508
14705
  if (!input) {
15509
- throw new InvalidParameterError(
15510
- "InvalidNFTIdentifier" /* InvalidNFTIdentifier */,
14706
+ throw new InvalidParameterError4(
14707
+ ErrorCode5.InvalidNFTIdentifier,
14708
+ "valid NFT identifier is required, could be address or name",
15511
14709
  "valid NFT identifier is required, could be address or name",
15512
14710
  { input },
15513
14711
  "Please provide valid NFT identifier",
@@ -15550,8 +14748,9 @@ var NFT = class _NFT {
15550
14748
  async getAddress() {
15551
14749
  if (!this.address) {
15552
14750
  if (!this.name) {
15553
- throw new InvalidParameterError(
15554
- "InvalidNFTIdentifier" /* InvalidNFTIdentifier */,
14751
+ throw new InvalidParameterError4(
14752
+ ErrorCode5.InvalidNFTIdentifier,
14753
+ "valid NFT identifier is required, could be address or name",
15555
14754
  "valid NFT identifier is required, could be address or name",
15556
14755
  {},
15557
14756
  "Please provide valid NFT identifier",
@@ -15799,6 +14998,11 @@ function toBytes32Arr(data) {
15799
14998
 
15800
14999
  // src/data/Token.ts
15801
15000
  import { formatUnits as formatUnits2, isAddress as isAddress3, parseUnits as parseUnits2 } from "viem";
15001
+ import {
15002
+ ErrorCode as ErrorCode6,
15003
+ InternalFailureError as InternalFailureError3,
15004
+ InvalidParameterError as InvalidParameterError5
15005
+ } from "@funkit/utils";
15802
15006
  var wrappedNativeTokens = { eth: "weth", matic: "wmatic", mnt: "wmnt" };
15803
15007
  var Token2 = class _Token {
15804
15008
  constructor(input, chain) {
@@ -15818,19 +15022,21 @@ var Token2 = class _Token {
15818
15022
  if (this.isNative) {
15819
15023
  const nativeName = wrappedNativeTokens[this.symbol];
15820
15024
  return await getTokenInfo(nativeName, chainId);
15821
- } else if (this.address) {
15025
+ }
15026
+ if (this.address) {
15822
15027
  return this.address;
15823
- } else if (this.symbol) {
15028
+ }
15029
+ if (this.symbol) {
15824
15030
  return await getTokenInfo(this.symbol, chainId);
15825
- } else {
15826
- throw new InternalFailureError(
15827
- "ServerMissingData" /* ServerMissingData */,
15828
- "server missing token symbol and address info",
15829
- { symbol: this.symbol, address: this.address, isNative: this.isNative },
15830
- "Please check token symbol and address. If things look correct, contract fun support for help",
15831
- "https://docs.fun.xyz"
15832
- );
15833
15031
  }
15032
+ throw new InternalFailureError3(
15033
+ ErrorCode6.ServerMissingData,
15034
+ "server missing token symbol and address info",
15035
+ "",
15036
+ { symbol: this.symbol, address: this.address, isNative: this.isNative },
15037
+ "Please check token symbol and address. If things look correct, contract fun support for help",
15038
+ "https://docs.fun.xyz"
15039
+ );
15834
15040
  }
15835
15041
  async getDecimals() {
15836
15042
  if (this.isNative) {
@@ -15866,8 +15072,9 @@ var Token2 = class _Token {
15866
15072
  }
15867
15073
  async getApproval(owner, spender) {
15868
15074
  if (this.isNative) {
15869
- throw new InvalidParameterError(
15870
- "InvalidParameter" /* InvalidParameter */,
15075
+ throw new InvalidParameterError5(
15076
+ ErrorCode6.InvalidParameter,
15077
+ "Native token can not approve",
15871
15078
  "Native token can not approve",
15872
15079
  { isNative: this.isNative },
15873
15080
  "No need to approve native token",
@@ -16545,7 +15752,7 @@ async function getUserUniqueId(authId) {
16545
15752
  try {
16546
15753
  return (await sendGetRequest(API_URL, `user/auth/${authId}/unique-id`)).userUniqueId;
16547
15754
  } catch (err) {
16548
- if (err instanceof ResourceNotFoundError) {
15755
+ if (err instanceof ResourceNotFoundError4) {
16549
15756
  return "";
16550
15757
  }
16551
15758
  throw err;
@@ -16573,7 +15780,7 @@ async function addUserToWallet(authId, chainId, walletAddr, userIds, walletUniqu
16573
15780
  }
16574
15781
  );
16575
15782
  } catch (err) {
16576
- if (err instanceof InvalidParameterError2) {
15783
+ if (err instanceof InvalidParameterError6) {
16577
15784
  return;
16578
15785
  }
16579
15786
  }
@@ -16702,8 +15909,9 @@ var Auth = class {
16702
15909
  } else if (!isHex2(authInput.privateKey) && authInput.privateKey.length === VALID_PRIVATE_KEY_LENGTH) {
16703
15910
  privateKey = `0x${authInput.privateKey}`;
16704
15911
  } else {
16705
- throw new InvalidParameterError(
16706
- "InvalidParameter" /* InvalidParameter */,
15912
+ throw new InvalidParameterError7(
15913
+ ErrorCode7.InvalidParameter,
15914
+ "privateKey is not a valid one",
16707
15915
  "privateKey is not a valid one",
16708
15916
  authInput.privateKey,
16709
15917
  "Provide valid privateKey string",
@@ -16712,8 +15920,9 @@ var Auth = class {
16712
15920
  }
16713
15921
  this.signer = privateKeyToAccount(privateKey);
16714
15922
  } else {
16715
- throw new InvalidParameterError(
16716
- "MissingParameter" /* MissingParameter */,
15923
+ throw new InvalidParameterError7(
15924
+ ErrorCode7.MissingParameter,
15925
+ "valid authInput is required",
16717
15926
  "valid authInput is required",
16718
15927
  authInput,
16719
15928
  "Provide viem client, privateKey, window eth (check viem.sh), rpc signer, provider, or signer when constructing Auth",
@@ -16834,8 +16043,9 @@ var Auth = class {
16834
16043
  const { to, data } = txData;
16835
16044
  const { value = 0n } = txData;
16836
16045
  if (!chain || !chainId) {
16837
- throw new InvalidParameterError(
16838
- "MissingParameter" /* MissingParameter */,
16046
+ throw new InvalidParameterError7(
16047
+ ErrorCode7.MissingParameter,
16048
+ "chain object is missing or incorrect",
16839
16049
  "chain object is missing or incorrect",
16840
16050
  { options, chainId },
16841
16051
  "Provide proper chain information from options field",
@@ -16935,7 +16145,7 @@ var Auth = class {
16935
16145
  try {
16936
16146
  return await getUserWalletsByAddr(await this.getAddress(), chainId);
16937
16147
  } catch (err) {
16938
- if (err instanceof ResourceNotFoundError) {
16148
+ if (err instanceof ResourceNotFoundError5) {
16939
16149
  return [];
16940
16150
  }
16941
16151
  throw err;
@@ -17205,8 +16415,9 @@ var createTargetSelectorMerkleTree = (params) => {
17205
16415
  };
17206
16416
  var createSessionKeyTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
17207
16417
  if (params.targetWhitelist.length === 0) {
17208
- throw new InvalidParameterError(
17209
- "MissingParameter" /* MissingParameter */,
16418
+ throw new InvalidParameterError8(
16419
+ ErrorCode8.MissingParameter,
16420
+ "targetWhitelist is required",
17210
16421
  "targetWhitelist is required",
17211
16422
  { params },
17212
16423
  "Provide targetWhitelist when creating a session key.",
@@ -17214,8 +16425,9 @@ var createSessionKeyTransactionParams = async (params, txOptions = globalThis.gl
17214
16425
  );
17215
16426
  }
17216
16427
  if (params.userId === void 0) {
17217
- throw new InvalidParameterError(
17218
- "MissingParameter" /* MissingParameter */,
16428
+ throw new InvalidParameterError8(
16429
+ ErrorCode8.MissingParameter,
16430
+ "userId is required",
17219
16431
  "userId is required",
17220
16432
  { params },
17221
16433
  "Provide userId when creating a session key.",
@@ -17347,6 +16559,11 @@ var removeGroupTxParams = async (params, txOptions = globalThis.globalEnvOption)
17347
16559
 
17348
16560
  // src/actions/Stake.ts
17349
16561
  import { isAddress as isAddress4, parseEther as parseEther2 } from "viem";
16562
+ import {
16563
+ ErrorCode as ErrorCode9,
16564
+ InternalFailureError as InternalFailureError4,
16565
+ InvalidParameterError as InvalidParameterError9
16566
+ } from "@funkit/utils";
17350
16567
  var getWithdrawQueueInterface = () => {
17351
16568
  return new ContractInterface(WITHDRAW_QUEUE_ABI);
17352
16569
  };
@@ -17363,8 +16580,9 @@ var stakeTransactionParams = async (params, txOptions = globalThis.globalEnvOpti
17363
16580
  };
17364
16581
  var requestUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
17365
16582
  if (!isAddress4(params.recipient ?? "")) {
17366
- throw new InvalidParameterError(
17367
- "InvalidParameter" /* InvalidParameter */,
16583
+ throw new InvalidParameterError9(
16584
+ ErrorCode9.InvalidParameter,
16585
+ "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17368
16586
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17369
16587
  { params },
17370
16588
  "Please make sure it is a valid checksum address",
@@ -17376,8 +16594,9 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
17376
16594
  const steth = getSteth(chainId);
17377
16595
  const withdrawalQueue = getWithdrawalQueue(chainId);
17378
16596
  if (!steth || !withdrawalQueue || steth.length === 0 || withdrawalQueue.length === 0) {
17379
- throw new InvalidParameterError(
17380
- "ChainNotSupported" /* ChainNotSupported */,
16597
+ throw new InvalidParameterError9(
16598
+ ErrorCode9.ChainNotSupported,
16599
+ "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
17381
16600
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
17382
16601
  { params },
17383
16602
  "Provide correct chainId.",
@@ -17410,8 +16629,9 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
17410
16629
  };
17411
16630
  var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
17412
16631
  if (!isAddress4(params.recipient ?? "")) {
17413
- throw new InvalidParameterError(
17414
- "InvalidParameter" /* InvalidParameter */,
16632
+ throw new InvalidParameterError9(
16633
+ ErrorCode9.InvalidParameter,
16634
+ "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17415
16635
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17416
16636
  { params },
17417
16637
  "Please make sure it is a valid checksum address",
@@ -17422,8 +16642,9 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
17422
16642
  const withdrawQueueAddress = getWithdrawalQueue(await chain.getChainId());
17423
16643
  const readyToWithdrawRequestIds = (await getReadyToWithdrawRequests(params, txOptions)).slice(0, 5);
17424
16644
  if (readyToWithdrawRequestIds.length === 0) {
17425
- throw new InvalidParameterError(
17426
- "InvalidParameter" /* InvalidParameter */,
16645
+ throw new InvalidParameterError9(
16646
+ ErrorCode9.InvalidParameter,
16647
+ "Not ready to withdraw requests",
17427
16648
  "Not ready to withdraw requests",
17428
16649
  { params },
17429
16650
  "Please wait a bit.",
@@ -17443,9 +16664,10 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
17443
16664
  chain
17444
16665
  );
17445
16666
  if (!hints) {
17446
- throw new InternalFailureError(
17447
- "CheckPointHintsNotFound" /* CheckPointHintsNotFound */,
16667
+ throw new InternalFailureError4(
16668
+ ErrorCode9.CheckPointHintsNotFound,
17448
16669
  "lido checkpoint hints are not found when batching the withdrawal",
16670
+ "",
17449
16671
  { params, readyToWithdrawRequestIds, lastCheckpoint, hints },
17450
16672
  "Retry later.",
17451
16673
  "https://docs.fun.xyz"
@@ -17459,8 +16681,9 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
17459
16681
  };
17460
16682
  var getReadyToWithdrawRequests = async (params, txOptions) => {
17461
16683
  if (!isAddress4(params.recipient ?? "")) {
17462
- throw new InvalidParameterError(
17463
- "InvalidParameter" /* InvalidParameter */,
16684
+ throw new InvalidParameterError9(
16685
+ ErrorCode9.InvalidParameter,
16686
+ "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17464
16687
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17465
16688
  { params },
17466
16689
  "Please make sure it is a valid checksum address",
@@ -17503,8 +16726,9 @@ var getWithdrawalQueue = (chainId) => {
17503
16726
  case 36865:
17504
16727
  return "0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1";
17505
16728
  default:
17506
- throw new InvalidParameterError(
17507
- "ChainNotSupported" /* ChainNotSupported */,
16729
+ throw new InvalidParameterError9(
16730
+ ErrorCode9.ChainNotSupported,
16731
+ "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
17508
16732
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
17509
16733
  { chainId },
17510
16734
  "Provide correct chainId.",
@@ -17521,8 +16745,9 @@ var getSteth = (chainId) => {
17521
16745
  case 36865:
17522
16746
  return "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
17523
16747
  default:
17524
- throw new InvalidParameterError(
17525
- "ChainNotSupported" /* ChainNotSupported */,
16748
+ throw new InvalidParameterError9(
16749
+ ErrorCode9.ChainNotSupported,
16750
+ "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
17526
16751
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
17527
16752
  { chainId },
17528
16753
  "Provide correct chainId.",
@@ -17533,6 +16758,7 @@ var getSteth = (chainId) => {
17533
16758
 
17534
16759
  // src/actions/Swap.ts
17535
16760
  import { isAddress as isAddress5 } from "viem";
16761
+ import { ErrorCode as ErrorCode10, InvalidParameterError as InvalidParameterError10 } from "@funkit/utils";
17536
16762
 
17537
16763
  // src/apis/SwapApis.ts
17538
16764
  async function get1InchSwapTx(chainId, src, dst, amount, from, slippage, disableEstimate, allowPartialFill) {
@@ -17637,8 +16863,9 @@ var getOneInchSwapTx = async (oneinchSwapParams) => {
17637
16863
  var oneInchTransactionParams = async (params, walletAddress, txOptions = globalThis.globalEnvOption) => {
17638
16864
  const chain = await Chain.getChain({ chainIdentifier: txOptions.chain });
17639
16865
  if (!oneInchSupported.includes(Number(await chain.getChainId()))) {
17640
- throw new InvalidParameterError(
17641
- "ChainNotSupported" /* ChainNotSupported */,
16866
+ throw new InvalidParameterError10(
16867
+ ErrorCode10.ChainNotSupported,
16868
+ "Incorrect chainId, oneInch only available on Ethereum mainnet and polygon",
17642
16869
  "Incorrect chainId, oneInch only available on Ethereum mainnet and polygon",
17643
16870
  { params },
17644
16871
  "Provide correct chainId.",
@@ -17646,8 +16873,9 @@ var oneInchTransactionParams = async (params, walletAddress, txOptions = globalT
17646
16873
  );
17647
16874
  }
17648
16875
  if (!isAddress5(params.recipient ?? "")) {
17649
- throw new InvalidParameterError(
17650
- "InvalidParameter" /* InvalidParameter */,
16876
+ throw new InvalidParameterError10(
16877
+ ErrorCode10.InvalidParameter,
16878
+ "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17651
16879
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17652
16880
  { params },
17653
16881
  "Please make sure it is a valid checksum address",
@@ -17704,8 +16932,9 @@ var uniswapV3SwapTransactionParams = async (params, txOptions = globalThis.globa
17704
16932
  slippage *= 10;
17705
16933
  }
17706
16934
  if (!isAddress5(params.recipient ?? "")) {
17707
- throw new InvalidParameterError(
17708
- "InvalidParameter" /* InvalidParameter */,
16935
+ throw new InvalidParameterError10(
16936
+ ErrorCode10.InvalidParameter,
16937
+ "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17709
16938
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
17710
16939
  { params },
17711
16940
  "Please make sure it is a valid checksum address",
@@ -17796,6 +17025,7 @@ var uniswapV2SwapTransactionParams = async (params, txOptions = globalThis.globa
17796
17025
 
17797
17026
  // src/actions/Token.ts
17798
17027
  import { isAddress as isAddress6, parseEther as parseEther3 } from "viem";
17028
+ import { ErrorCode as ErrorCode11, InvalidParameterError as InvalidParameterError11 } from "@funkit/utils";
17799
17029
  var isERC721TransferParams = (obj) => {
17800
17030
  return "tokenId" in obj;
17801
17031
  };
@@ -17805,8 +17035,9 @@ var isTokenTransferParams = (obj) => {
17805
17035
  var erc721TransferTransactionParams = async (params) => {
17806
17036
  const { to, tokenId, collection, from } = params;
17807
17037
  if (!isAddress6(to ?? "") || !isAddress6(from ?? "")) {
17808
- throw new InvalidParameterError(
17809
- "InvalidParameter" /* InvalidParameter */,
17038
+ throw new InvalidParameterError11(
17039
+ ErrorCode11.InvalidParameter,
17040
+ "To/from address is not a valid address, please make sure it is a valid checksum address.",
17810
17041
  "To/from address is not a valid address, please make sure it is a valid checksum address.",
17811
17042
  { params },
17812
17043
  "Please make sure it is a valid checksum address",
@@ -17823,8 +17054,9 @@ var erc721TransferTransactionParams = async (params) => {
17823
17054
  var tokenTransferTransactionParams = async (params, chain) => {
17824
17055
  const { to, amount, token } = params;
17825
17056
  if (!isAddress6(to)) {
17826
- throw new InvalidParameterError(
17827
- "InvalidParameter" /* InvalidParameter */,
17057
+ throw new InvalidParameterError11(
17058
+ ErrorCode11.InvalidParameter,
17059
+ "To address is not a valid address, please make sure it is a valid checksum address.",
17828
17060
  "To address is not a valid address, please make sure it is a valid checksum address.",
17829
17061
  { params },
17830
17062
  "Please make sure it is a valid checksum address",
@@ -17838,30 +17070,31 @@ var tokenTransferTransactionParams = async (params, chain) => {
17838
17070
  data: "0x",
17839
17071
  value: parseEther3(`${amount}`)
17840
17072
  };
17841
- } else {
17842
- const tokenAddr = await tokenObj.getAddress();
17843
- if (!tokenAddr) {
17844
- throw new InvalidParameterError(
17845
- "TokenNotFound" /* TokenNotFound */,
17846
- "Token address not found. Please check the token passed in.",
17847
- { params },
17848
- "Provide correct token.",
17849
- "https://docs.fun.xyz"
17850
- );
17851
- }
17852
- const convertedAmount = await tokenObj.getDecimalAmount(amount);
17853
- return ERC20_CONTRACT_INTERFACE.encodeTransactionParams(
17854
- tokenAddr,
17855
- "transfer",
17856
- [to, convertedAmount]
17073
+ }
17074
+ const tokenAddr = await tokenObj.getAddress();
17075
+ if (!tokenAddr) {
17076
+ throw new InvalidParameterError11(
17077
+ ErrorCode11.TokenNotFound,
17078
+ "Token address not found. Please check the token passed in.",
17079
+ "Token address not found. Please check the token passed in.",
17080
+ { params },
17081
+ "Provide correct token.",
17082
+ "https://docs.fun.xyz"
17857
17083
  );
17858
17084
  }
17085
+ const convertedAmount = await tokenObj.getDecimalAmount(amount);
17086
+ return ERC20_CONTRACT_INTERFACE.encodeTransactionParams(
17087
+ tokenAddr,
17088
+ "transfer",
17089
+ [to, convertedAmount]
17090
+ );
17859
17091
  };
17860
17092
  var tokenTransferFromTransactionParams = async (params, chain) => {
17861
17093
  const { to, amount, token, from } = params;
17862
17094
  if (!isAddress6(to ?? "") || !isAddress6(from ?? "")) {
17863
- throw new InvalidParameterError(
17864
- "InvalidParameter" /* InvalidParameter */,
17095
+ throw new InvalidParameterError11(
17096
+ ErrorCode11.InvalidParameter,
17097
+ "To/from address is not a valid address, please make sure it is a valid checksum address.",
17865
17098
  "To/from address is not a valid address, please make sure it is a valid checksum address.",
17866
17099
  { params },
17867
17100
  "Please make sure it is a valid checksum address",
@@ -17875,24 +17108,24 @@ var tokenTransferFromTransactionParams = async (params, chain) => {
17875
17108
  data: "0x",
17876
17109
  value: parseEther3(`${amount}`)
17877
17110
  };
17878
- } else {
17879
- const tokenAddr = await tokenObj.getAddress();
17880
- if (!tokenAddr) {
17881
- throw new InvalidParameterError(
17882
- "TokenNotFound" /* TokenNotFound */,
17883
- "Token address not found. Please check the token passed in.",
17884
- { params },
17885
- "Provide correct token.",
17886
- "https://docs.fun.xyz"
17887
- );
17888
- }
17889
- const convertedAmount = await tokenObj.getDecimalAmount(amount);
17890
- return ERC20_CONTRACT_INTERFACE.encodeTransactionParams(
17891
- tokenAddr,
17892
- "transferFrom",
17893
- [from, to, convertedAmount]
17111
+ }
17112
+ const tokenAddr = await tokenObj.getAddress();
17113
+ if (!tokenAddr) {
17114
+ throw new InvalidParameterError11(
17115
+ ErrorCode11.TokenNotFound,
17116
+ "Token address not found. Please check the token passed in.",
17117
+ "Token address not found. Please check the token passed in.",
17118
+ { params },
17119
+ "Provide correct token.",
17120
+ "https://docs.fun.xyz"
17894
17121
  );
17895
17122
  }
17123
+ const convertedAmount = await tokenObj.getDecimalAmount(amount);
17124
+ return ERC20_CONTRACT_INTERFACE.encodeTransactionParams(
17125
+ tokenAddr,
17126
+ "transferFrom",
17127
+ [from, to, convertedAmount]
17128
+ );
17896
17129
  };
17897
17130
  var isERC20ApproveParams = (obj) => {
17898
17131
  return "amount" in obj && "token" in obj;
@@ -17903,8 +17136,9 @@ var isERC721ApproveParams = (obj) => {
17903
17136
  var erc20ApproveTransactionParams = async (params) => {
17904
17137
  const { spender, amount, token } = params;
17905
17138
  if (!isAddress6(spender ?? "")) {
17906
- throw new InvalidParameterError(
17907
- "InvalidParameter" /* InvalidParameter */,
17139
+ throw new InvalidParameterError11(
17140
+ ErrorCode11.InvalidParameter,
17141
+ "Spender address is not a valid address, please make sure it is a valid checksum address.",
17908
17142
  "Spender address is not a valid address, please make sure it is a valid checksum address.",
17909
17143
  { params },
17910
17144
  "Please make sure it is a valid checksum address",
@@ -17925,8 +17159,9 @@ var erc20ApproveTransactionParams = async (params) => {
17925
17159
  var erc721ApproveTransactionParams = async (params) => {
17926
17160
  const { spender, tokenId, collection } = params;
17927
17161
  if (!isAddress6(spender ?? "")) {
17928
- throw new InvalidParameterError(
17929
- "InvalidParameter" /* InvalidParameter */,
17162
+ throw new InvalidParameterError11(
17163
+ ErrorCode11.InvalidParameter,
17164
+ "Spender address is not a valid address, please make sure it is a valid checksum address.",
17930
17165
  "Spender address is not a valid address, please make sure it is a valid checksum address.",
17931
17166
  { params },
17932
17167
  "Please make sure it is a valid checksum address",
@@ -17942,6 +17177,7 @@ var erc721ApproveTransactionParams = async (params) => {
17942
17177
  };
17943
17178
 
17944
17179
  // src/config/Config.ts
17180
+ import { ErrorCode as ErrorCode12, InvalidParameterError as InvalidParameterError12 } from "@funkit/utils";
17945
17181
  function getEnvOptions() {
17946
17182
  return globalThis.globalEnvOption;
17947
17183
  }
@@ -17957,8 +17193,9 @@ async function configureEnvironment(option) {
17957
17193
  const globalEnvOption = global.globalEnvOption;
17958
17194
  globalEnvOption.apiKey = option.apiKey ? option.apiKey : globalEnvOption.apiKey;
17959
17195
  if (!globalEnvOption.apiKey) {
17960
- throw new InvalidParameterError(
17961
- "MissingParameter" /* MissingParameter */,
17196
+ throw new InvalidParameterError12(
17197
+ ErrorCode12.MissingParameter,
17198
+ "apiKey is required",
17962
17199
  "apiKey is required",
17963
17200
  { option },
17964
17201
  "Provide apiKey when configureEnvironment.",
@@ -17986,6 +17223,22 @@ async function configureEnvironment(option) {
17986
17223
  globalEnvOption.skipDBAction = option.skipDBAction === null || option.skipDBAction === void 0 ? globalEnvOption.skipDBAction : option.skipDBAction;
17987
17224
  }
17988
17225
 
17226
+ // src/errors/clientErrors.ts
17227
+ import { ClientError, ErrorType } from "@funkit/utils";
17228
+ var InvalidActionError = class extends ClientError {
17229
+ constructor(code, msg, paramsUsed, fixSuggestion, docLink) {
17230
+ super(
17231
+ ErrorType.InvalidAction,
17232
+ code,
17233
+ msg,
17234
+ msg,
17235
+ paramsUsed,
17236
+ fixSuggestion,
17237
+ docLink
17238
+ );
17239
+ }
17240
+ };
17241
+
17989
17242
  // src/sponsors/Sponsor.ts
17990
17243
  var Sponsor = class {
17991
17244
  constructor(options, contractInterface, name, paymasterType) {
@@ -18182,6 +17435,7 @@ var CheckoutSponsor = class extends Sponsor {
18182
17435
 
18183
17436
  // src/sponsors/GaslessSponsor.ts
18184
17437
  import { concat as concat3 } from "viem";
17438
+ import { ErrorCode as ErrorCode13, ResourceNotFoundError as ResourceNotFoundError6 } from "@funkit/utils";
18185
17439
  var GaslessSponsor = class extends Sponsor {
18186
17440
  constructor(options = globalThis.globalEnvOption) {
18187
17441
  super(
@@ -18197,8 +17451,9 @@ var GaslessSponsor = class extends Sponsor {
18197
17451
  if (GASLESS_SPONSOR_SUPPORT_CHAINS.includes(await chain.getChainId())) {
18198
17452
  this.sponsorAddress = await chain.getAddress("funGaslessSponsorAddress");
18199
17453
  } else {
18200
- throw new ResourceNotFoundError(
18201
- "MissingParameter" /* MissingParameter */,
17454
+ throw new ResourceNotFoundError6(
17455
+ ErrorCode13.MissingParameter,
17456
+ "The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
18202
17457
  "The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
18203
17458
  {
18204
17459
  gaslessSponsorSupportChains: GASLESS_SPONSOR_SUPPORT_CHAINS,
@@ -18300,6 +17555,11 @@ var GaslessSponsor = class extends Sponsor {
18300
17555
 
18301
17556
  // src/sponsors/TokenSponsor.ts
18302
17557
  import { concat as concat4, encodeAbiParameters as encodeAbiParameters4 } from "viem";
17558
+ import {
17559
+ ErrorCode as ErrorCode14,
17560
+ InvalidParameterError as InvalidParameterError13,
17561
+ ResourceNotFoundError as ResourceNotFoundError7
17562
+ } from "@funkit/utils";
18303
17563
  var TokenSponsor = class extends Sponsor {
18304
17564
  constructor(options = globalThis.globalEnvOption) {
18305
17565
  super(
@@ -18309,8 +17569,9 @@ var TokenSponsor = class extends Sponsor {
18309
17569
  "token" /* TokenSponsor */
18310
17570
  );
18311
17571
  if (!options.gasSponsor?.token) {
18312
- throw new InvalidParameterError(
18313
- "MissingParameter" /* MissingParameter */,
17572
+ throw new InvalidParameterError13(
17573
+ ErrorCode14.MissingParameter,
17574
+ "token field is missing",
18314
17575
  "token field is missing",
18315
17576
  { gasSponsor: options.gasSponsor },
18316
17577
  "Provide correct token name or address.",
@@ -18325,8 +17586,9 @@ var TokenSponsor = class extends Sponsor {
18325
17586
  if (TOKEN_SPONSOR_SUPPORT_CHAINS.includes(await chain.getChainId())) {
18326
17587
  this.sponsorAddress = await chain.getAddress("funTokenSponsorAddress");
18327
17588
  } else {
18328
- throw new ResourceNotFoundError(
18329
- "MissingParameter" /* MissingParameter */,
17589
+ throw new ResourceNotFoundError7(
17590
+ ErrorCode14.MissingParameter,
17591
+ "The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
18330
17592
  "The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
18331
17593
  {
18332
17594
  tokenSponsorSupportChains: TOKEN_SPONSOR_SUPPORT_CHAINS,
@@ -18678,9 +17940,6 @@ import {
18678
17940
  getAllWalletNFTsByChainId,
18679
17941
  getAllWalletTokens,
18680
17942
  getAllWalletTokensByChainId,
18681
- getMoonpayOffRampUrl,
18682
- getMoonpayOnRampSupportedCurrencies,
18683
- getMoonpayOnRampUrl,
18684
17943
  getWalletLidoWithdrawalsByChainId
18685
17944
  } from "@funkit/api-base";
18686
17945
  import {
@@ -18694,9 +17953,20 @@ import {
18694
17953
  pad as pad9,
18695
17954
  toBytes as toBytes7
18696
17955
  } from "viem";
17956
+ import {
17957
+ ErrorCode as ErrorCode18,
17958
+ InternalFailureError as InternalFailureError5,
17959
+ InvalidParameterError as InvalidParameterError16
17960
+ } from "@funkit/utils";
18697
17961
 
18698
17962
  // src/actions/FirstClassActions.ts
18699
17963
  import { pad as pad8 } from "viem";
17964
+ import {
17965
+ ErrorCode as ErrorCode17,
17966
+ InvalidParameterError as InvalidParameterError15,
17967
+ ResourceNotFoundError as ResourceNotFoundError9,
17968
+ safeParseJson as safeParseJson2
17969
+ } from "@funkit/utils";
18700
17970
 
18701
17971
  // src/utils/GroupUtils.ts
18702
17972
  import {
@@ -18735,7 +18005,11 @@ async function getOnChainGroupData(groupId, chain, walletAddr) {
18735
18005
  }
18736
18006
  }
18737
18007
 
18008
+ // src/actions/Bridge.ts
18009
+ import { ErrorCode as ErrorCode16, InvalidParameterError as InvalidParameterError14 } from "@funkit/utils";
18010
+
18738
18011
  // src/apis/BridgeApis.ts
18012
+ import { ErrorCode as ErrorCode15, ResourceNotFoundError as ResourceNotFoundError8 } from "@funkit/utils";
18739
18013
  async function getSocketBridgeQuote(recipient, walletAddress, fromChain, toChain, fromToken, toToken, amount, sort) {
18740
18014
  const params = new URLSearchParams({
18741
18015
  recipient,
@@ -18751,8 +18025,9 @@ async function getSocketBridgeQuote(recipient, walletAddress, fromChain, toChain
18751
18025
  }).toString();
18752
18026
  const quote = await sendGetRequest(API_URL, `bridge/quote/?${params}`);
18753
18027
  if (!quote.success || quote.result.routes.length === 0) {
18754
- throw new ResourceNotFoundError(
18755
- "BridgeRouteNotFound" /* BridgeRouteNotFound */,
18028
+ throw new ResourceNotFoundError8(
18029
+ ErrorCode15.BridgeRouteNotFound,
18030
+ "Unable to find a route for these assets between these chains",
18756
18031
  "Unable to find a route for these assets between these chains",
18757
18032
  { walletAddress, fromChain, toChain, fromToken, toToken, amount, sort },
18758
18033
  "Try another route with a different asset pair",
@@ -18777,8 +18052,9 @@ async function getSocketBridgeAllowance(chainId, sender, allowanceTarget, token)
18777
18052
  `bridge/approval/check-allowance/?${params}`
18778
18053
  );
18779
18054
  if (!json.result.value) {
18780
- throw new ResourceNotFoundError(
18781
- "BridgeAllowanceDataNotFound" /* BridgeAllowanceDataNotFound */,
18055
+ throw new ResourceNotFoundError8(
18056
+ ErrorCode15.BridgeAllowanceDataNotFound,
18057
+ "Unable to get allowance data",
18782
18058
  "Unable to get allowance data",
18783
18059
  { chainId, sender, allowanceTarget, token },
18784
18060
  "Make sure the chainId, sender, allowanceTarget, and token are correct",
@@ -18800,8 +18076,9 @@ async function getSocketBridgeApproveTransaction(chainId, sender, allowanceTarge
18800
18076
  `bridge/approval/build-tx/?${params}`
18801
18077
  );
18802
18078
  if (!json.result) {
18803
- throw new ResourceNotFoundError(
18804
- "BridgeApproveTxDataNotFound" /* BridgeApproveTxDataNotFound */,
18079
+ throw new ResourceNotFoundError8(
18080
+ ErrorCode15.BridgeApproveTxDataNotFound,
18081
+ "Unable to build the approve transaction data",
18805
18082
  "Unable to build the approve transaction data",
18806
18083
  { chainId, sender, allowanceTarget, token, amount },
18807
18084
  "Make sure the token and allowance are valid values",
@@ -18818,8 +18095,9 @@ var bridgeTransactionParams = async (params, walletAddress, chain) => {
18818
18095
  const toTokenObj = new Token2(toToken, chain);
18819
18096
  const amount = await fromTokenObj.getDecimalAmount(params.amount);
18820
18097
  if (!recipient) {
18821
- throw new InvalidParameterError(
18822
- "InvalidParameter" /* InvalidParameter */,
18098
+ throw new InvalidParameterError14(
18099
+ ErrorCode16.InvalidParameter,
18100
+ "Recipient Parameter was undefined",
18823
18101
  "Recipient Parameter was undefined",
18824
18102
  { params },
18825
18103
  "Please provide a recipient",
@@ -18950,7 +18228,17 @@ var FirstClassActions = class {
18950
18228
  this.chain = chain;
18951
18229
  }
18952
18230
  async bridge(auth, userId, params, txOptions = globalThis.globalEnvOption) {
18953
- const paramsCopy = JSON.parse(JSON.stringify(params));
18231
+ const paramsCopy = safeParseJson2(JSON.stringify(params));
18232
+ if (!paramsCopy) {
18233
+ throw new InvalidParameterError15(
18234
+ ErrorCode17.InvalidParameter,
18235
+ "Invalid `params` object provided.",
18236
+ "Invalid `params` object provided.",
18237
+ { params },
18238
+ "",
18239
+ "https://docs.fun.xyz"
18240
+ );
18241
+ }
18954
18242
  paramsCopy.recipient ??= await this.getAddress();
18955
18243
  const transactionParams = await bridgeTransactionParams(
18956
18244
  paramsCopy,
@@ -18969,8 +18257,9 @@ var FirstClassActions = class {
18969
18257
  */
18970
18258
  async swap(auth, userId, params, txOptions = globalThis.globalEnvOption) {
18971
18259
  if (!params.tokenIn) {
18972
- throw new InvalidParameterError(
18973
- "InvalidParameter" /* InvalidParameter */,
18260
+ throw new InvalidParameterError15(
18261
+ ErrorCode17.InvalidParameter,
18262
+ "Missing tokenIn parameter in the swap params object.",
18974
18263
  "Missing tokenIn parameter in the swap params object.",
18975
18264
  { params },
18976
18265
  "",
@@ -18978,8 +18267,9 @@ var FirstClassActions = class {
18978
18267
  );
18979
18268
  }
18980
18269
  if (!params.tokenOut) {
18981
- throw new InvalidParameterError(
18982
- "InvalidParameter" /* InvalidParameter */,
18270
+ throw new InvalidParameterError15(
18271
+ ErrorCode17.InvalidParameter,
18272
+ "Missing tokenOut parameter in the swap params object.",
18983
18273
  "Missing tokenOut parameter in the swap params object.",
18984
18274
  { params },
18985
18275
  "",
@@ -18987,8 +18277,9 @@ var FirstClassActions = class {
18987
18277
  );
18988
18278
  }
18989
18279
  if (!params.inAmount) {
18990
- throw new InvalidParameterError(
18991
- "InvalidParameter" /* InvalidParameter */,
18280
+ throw new InvalidParameterError15(
18281
+ ErrorCode17.InvalidParameter,
18282
+ "Missing inAmount parameter in the swap params object.",
18992
18283
  "Missing inAmount parameter in the swap params object.",
18993
18284
  { params },
18994
18285
  "",
@@ -19011,8 +18302,9 @@ var FirstClassActions = class {
19011
18302
  txOptions
19012
18303
  );
19013
18304
  } else if (chainId === 8453) {
19014
- throw new InvalidParameterError(
19015
- "InvalidParameter" /* InvalidParameter */,
18305
+ throw new InvalidParameterError15(
18306
+ ErrorCode17.InvalidParameter,
18307
+ "Swap is not supported on Base",
19016
18308
  "Swap is not supported on Base",
19017
18309
  { params },
19018
18310
  "Use a different chain or a different first class method",
@@ -19078,8 +18370,9 @@ var FirstClassActions = class {
19078
18370
  );
19079
18371
  }
19080
18372
  } else {
19081
- throw new InvalidParameterError(
19082
- "InvalidParameter" /* InvalidParameter */,
18373
+ throw new InvalidParameterError15(
18374
+ ErrorCode17.InvalidParameter,
18375
+ "Params were missing or incorrect",
19083
18376
  "Params were missing or incorrect",
19084
18377
  { params },
19085
18378
  "Provide correct transfer params.",
@@ -19109,8 +18402,9 @@ var FirstClassActions = class {
19109
18402
  } else if (isERC721ApproveParams(params)) {
19110
18403
  transactionParams = await erc721ApproveTransactionParams(params);
19111
18404
  } else {
19112
- throw new InvalidParameterError(
19113
- "InvalidParameter" /* InvalidParameter */,
18405
+ throw new InvalidParameterError15(
18406
+ ErrorCode17.InvalidParameter,
18407
+ "Params were missing or incorrect",
19114
18408
  "Params were missing or incorrect",
19115
18409
  { params },
19116
18410
  "Provide correct token approve params.",
@@ -19164,8 +18458,9 @@ var FirstClassActions = class {
19164
18458
  txOptions
19165
18459
  );
19166
18460
  } else {
19167
- throw new InvalidParameterError(
19168
- "InvalidParameter" /* InvalidParameter */,
18461
+ throw new InvalidParameterError15(
18462
+ ErrorCode17.InvalidParameter,
18463
+ "Params were missing or incorrect",
19169
18464
  "Params were missing or incorrect",
19170
18465
  { params },
19171
18466
  "Provide correct unstake params.",
@@ -19253,8 +18548,9 @@ var FirstClassActions = class {
19253
18548
  await this.getAddress()
19254
18549
  );
19255
18550
  if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
19256
- throw new ResourceNotFoundError(
19257
- "GroupNotFound" /* GroupNotFound */,
18551
+ throw new ResourceNotFoundError9(
18552
+ ErrorCode17.GroupNotFound,
18553
+ "group is not found",
19258
18554
  "group is not found",
19259
18555
  { params },
19260
18556
  "Provide correct groupId and chainId.",
@@ -19265,8 +18561,9 @@ var FirstClassActions = class {
19265
18561
  const members = new Set(onChainGroupData.memberIds);
19266
18562
  members.add(params.userId);
19267
18563
  if (members.size <= originalMembers.size) {
19268
- throw new InvalidParameterError(
19269
- "UserAlreadyExists" /* UserAlreadyExists */,
18564
+ throw new InvalidParameterError15(
18565
+ ErrorCode17.UserAlreadyExists,
18566
+ "user already exists in group",
19270
18567
  "user already exists in group",
19271
18568
  { params, originalMembers, userId: params.userId },
19272
18569
  "Catch this error and swallow it as the user is already added.",
@@ -19301,8 +18598,9 @@ var FirstClassActions = class {
19301
18598
  await this.getAddress()
19302
18599
  );
19303
18600
  if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
19304
- throw new ResourceNotFoundError(
19305
- "GroupNotFound" /* GroupNotFound */,
18601
+ throw new ResourceNotFoundError9(
18602
+ ErrorCode17.GroupNotFound,
18603
+ "group is not found",
19306
18604
  "group is not found",
19307
18605
  { params },
19308
18606
  "Provide correct groupId and chainId.",
@@ -19313,8 +18611,9 @@ var FirstClassActions = class {
19313
18611
  const members = new Set(onChainGroupData.memberIds);
19314
18612
  members.delete(params.userId);
19315
18613
  if (members.size >= originalMembers.size) {
19316
- throw new ResourceNotFoundError(
19317
- "UserNotFound" /* UserNotFound */,
18614
+ throw new ResourceNotFoundError9(
18615
+ ErrorCode17.UserNotFound,
18616
+ "user does not exist in group",
19318
18617
  "user does not exist in group",
19319
18618
  { params, originalMembers, userId: params.userId },
19320
18619
  "Catch this error and swallow it as the user does not exist in the group.",
@@ -19348,8 +18647,9 @@ var FirstClassActions = class {
19348
18647
  await this.getAddress()
19349
18648
  );
19350
18649
  if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
19351
- throw new ResourceNotFoundError(
19352
- "GroupNotFound" /* GroupNotFound */,
18650
+ throw new ResourceNotFoundError9(
18651
+ ErrorCode17.GroupNotFound,
18652
+ "group is not found",
19353
18653
  "group is not found",
19354
18654
  { params },
19355
18655
  "Provide correct groupId and chainId.",
@@ -19357,8 +18657,9 @@ var FirstClassActions = class {
19357
18657
  );
19358
18658
  }
19359
18659
  if (!Number.isInteger(params.threshold) || params.threshold < 1 || params.threshold > onChainGroupData.memberIds.length) {
19360
- throw new InvalidParameterError(
19361
- "InvalidThreshold" /* InvalidThreshold */,
18660
+ throw new InvalidParameterError15(
18661
+ ErrorCode17.InvalidThreshold,
18662
+ "threshold can not be 0 or bigger than number of members in the group",
19362
18663
  "threshold can not be 0 or bigger than number of members in the group",
19363
18664
  { params, memberIds: onChainGroupData.memberIds },
19364
18665
  "Provide proper threshold number.",
@@ -19425,8 +18726,9 @@ var FunWallet = class extends FirstClassActions {
19425
18726
  if (isAddress7(params)) {
19426
18727
  this.address = params;
19427
18728
  } else {
19428
- throw new InvalidParameterError(
19429
- "InvalidParameter" /* InvalidParameter */,
18729
+ throw new InvalidParameterError16(
18730
+ ErrorCode18.InvalidParameter,
18731
+ "string input must be an address type",
19430
18732
  "string input must be an address type",
19431
18733
  params,
19432
18734
  "Provide either (uniqueId, users) or walletAddr when constructing a FunWallet",
@@ -19436,8 +18738,9 @@ var FunWallet = class extends FirstClassActions {
19436
18738
  } else {
19437
18739
  const { users, uniqueId } = params;
19438
18740
  if (!uniqueId || !isBytes32(uniqueId) || !users || users.length <= 0) {
19439
- throw new InvalidParameterError(
19440
- "InvalidParameter" /* InvalidParameter */,
18741
+ throw new InvalidParameterError16(
18742
+ ErrorCode18.InvalidParameter,
18743
+ "uniqueId must be bytes32 and users must be non-empty",
19441
18744
  "uniqueId must be bytes32 and users must be non-empty",
19442
18745
  params,
19443
18746
  "The uniqueId field should be a 32 byte Hexstring and the users field should be an array of User objects",
@@ -19447,8 +18750,9 @@ var FunWallet = class extends FirstClassActions {
19447
18750
  this.userInfo = new Map(
19448
18751
  users?.map((user) => {
19449
18752
  if (!user.userId || !isHex3(user.userId)) {
19450
- throw new InvalidParameterError(
19451
- "InvalidParameter" /* InvalidParameter */,
18753
+ throw new InvalidParameterError16(
18754
+ ErrorCode18.InvalidParameter,
18755
+ "userId is required and must be a hex string",
19452
18756
  "userId is required and must be a hex string",
19453
18757
  users,
19454
18758
  "Provide hex string userId when creating a FunWallet",
@@ -19456,8 +18760,9 @@ var FunWallet = class extends FirstClassActions {
19456
18760
  );
19457
18761
  }
19458
18762
  if (user.groupInfo && (!Number.isInteger(user.groupInfo.threshold) || !Array.isArray(user.groupInfo.memberIds) || !user.groupInfo.memberIds.every((memberId) => isHex3(memberId)))) {
19459
- throw new InvalidParameterError(
19460
- "InvalidParameter" /* InvalidParameter */,
18763
+ throw new InvalidParameterError16(
18764
+ ErrorCode18.InvalidParameter,
18765
+ "groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
19461
18766
  "groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
19462
18767
  users,
19463
18768
  "Provide valid groupInfo when creating a FunWallet",
@@ -19744,39 +19049,6 @@ var FunWallet = class extends FirstClassActions {
19744
19049
  );
19745
19050
  }
19746
19051
  }
19747
- /**
19748
- * Generates an on-ramp URL for the account address.
19749
- * @param {Address} address - The account address (optional, defaults to the wallet's address).
19750
- * @param {string} currencyCode - The currency code (optional, defaults to undefined to allow users to select).
19751
- * @returns {Promise<string>} The on-ramp URL.
19752
- */
19753
- async onRamp(address, currencyCode) {
19754
- return await getMoonpayOnRampUrl({
19755
- apiKey: globalThis.globalEnvOption.apiKey,
19756
- walletAddr: address ? address : await this.getAddress(),
19757
- currencyCode: currencyCode ? currencyCode : void 0
19758
- });
19759
- }
19760
- /**
19761
- * Generates an off-ramp URL for the account address.
19762
- * @param {Address} address - The account address (optional, defaults to the wallet's address).
19763
- * @returns {Promise<string>} The off-ramp URL.
19764
- */
19765
- async offRamp(address) {
19766
- return await getMoonpayOffRampUrl({
19767
- apiKey: globalThis.globalEnvOption.apiKey,
19768
- walletAddr: address ? address : await this.getAddress()
19769
- });
19770
- }
19771
- /**
19772
- * Retrieves the supported currencies for on-ramp.
19773
- * @returns {Promise<MoonpayCurrency[]>} The supported currencies.
19774
- */
19775
- async getSupportedCurrencies() {
19776
- return await getMoonpayOnRampSupportedCurrencies({
19777
- apiKey: globalThis.globalEnvOption.apiKey
19778
- });
19779
- }
19780
19052
  /**
19781
19053
  * Creates a new operation to be associated with the wallet and prepares it for execution.
19782
19054
  * @param {Auth} auth - The authentication instance for the user.
@@ -19787,8 +19059,9 @@ var FunWallet = class extends FirstClassActions {
19787
19059
  */
19788
19060
  async createOperation(auth, userId, transactionParams, txOptions = globalThis.globalEnvOption) {
19789
19061
  if (!userId || userId === "") {
19790
- throw new InvalidParameterError(
19791
- "MissingParameter" /* MissingParameter */,
19062
+ throw new InvalidParameterError16(
19063
+ ErrorCode18.MissingParameter,
19064
+ "userId is required",
19792
19065
  "userId is required",
19793
19066
  { userId },
19794
19067
  "Provide userId when createOperation",
@@ -19975,8 +19248,9 @@ var FunWallet = class extends FirstClassActions {
19975
19248
  collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
19976
19249
  }
19977
19250
  if (collectedSigCount < threshold) {
19978
- throw new InvalidParameterError(
19979
- "InsufficientSignatures" /* InsufficientSignatures */,
19251
+ throw new InvalidParameterError16(
19252
+ ErrorCode18.InsufficientSignatures,
19253
+ "Signatures are not sufficient to execute the operation",
19980
19254
  "Signatures are not sufficient to execute the operation",
19981
19255
  { threshold, collectedSigCount, chainId },
19982
19256
  "Only execute operation with enough signatures",
@@ -19984,8 +19258,9 @@ var FunWallet = class extends FirstClassActions {
19984
19258
  );
19985
19259
  }
19986
19260
  } else {
19987
- throw new InvalidParameterError(
19988
- "InsufficientSignatures" /* InsufficientSignatures */,
19261
+ throw new InvalidParameterError16(
19262
+ ErrorCode18.InsufficientSignatures,
19263
+ "Signatures are not sufficient to execute the operation",
19989
19264
  "Signatures are not sufficient to execute the operation",
19990
19265
  { threshold, chainId, skipDBAction: finalTxOptions.skipDBAction },
19991
19266
  "Only execute operation with enough signatures",
@@ -20104,8 +19379,9 @@ var FunWallet = class extends FirstClassActions {
20104
19379
  collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
20105
19380
  }
20106
19381
  if (collectedSigCount < threshold) {
20107
- throw new InvalidParameterError(
20108
- "InsufficientSignatures" /* InsufficientSignatures */,
19382
+ throw new InvalidParameterError16(
19383
+ ErrorCode18.InsufficientSignatures,
19384
+ "Signatures are not sufficient to execute the operation",
20109
19385
  "Signatures are not sufficient to execute the operation",
20110
19386
  { threshold, collectedSigCount, chainId },
20111
19387
  "Only execute operation with enough signatures",
@@ -20113,8 +19389,9 @@ var FunWallet = class extends FirstClassActions {
20113
19389
  );
20114
19390
  }
20115
19391
  } else {
20116
- throw new InvalidParameterError(
20117
- "InsufficientSignatures" /* InsufficientSignatures */,
19392
+ throw new InvalidParameterError16(
19393
+ ErrorCode18.InsufficientSignatures,
19394
+ "Signatures are not sufficient to execute the operation",
20118
19395
  "Signatures are not sufficient to execute the operation",
20119
19396
  { threshold, chainId, skipDBAction: finalTxOptions.skipDBAction },
20120
19397
  "Only execute operation with enough signatures",
@@ -20142,9 +19419,10 @@ var FunWallet = class extends FirstClassActions {
20142
19419
  });
20143
19420
  }
20144
19421
  if (!finalOperation.opId) {
20145
- throw new InternalFailureError(
20146
- "ServerFailure" /* ServerFailure */,
19422
+ throw new InternalFailureError5(
19423
+ ErrorCode18.ServerFailure,
20147
19424
  "Operation id is required",
19425
+ "",
20148
19426
  finalOperation,
20149
19427
  "Make sure you are scheduling a valid operation",
20150
19428
  "https://docs.fun.xyz/"
@@ -20281,8 +19559,9 @@ var FunWallet = class extends FirstClassActions {
20281
19559
  options.fee.token = options.gasSponsor.token;
20282
19560
  }
20283
19561
  if (!options.fee.token) {
20284
- throw new InvalidParameterError(
20285
- "MissingParameter" /* MissingParameter */,
19562
+ throw new InvalidParameterError16(
19563
+ ErrorCode18.MissingParameter,
19564
+ "EnvOption.fee.token or EnvOption.gasSponsor.token is required",
20286
19565
  "EnvOption.fee.token or EnvOption.gasSponsor.token is required",
20287
19566
  { options },
20288
19567
  "Provide EnvOption.fee.token or EnvOption.gasSponsor.token when calling wallet.createOperation",
@@ -20290,8 +19569,9 @@ var FunWallet = class extends FirstClassActions {
20290
19569
  );
20291
19570
  }
20292
19571
  if (!options.fee.recipient) {
20293
- throw new InvalidParameterError(
20294
- "MissingParameter" /* MissingParameter */,
19572
+ throw new InvalidParameterError16(
19573
+ ErrorCode18.MissingParameter,
19574
+ "EnvOption.fee.recipient is required",
20295
19575
  "EnvOption.fee.recipient is required",
20296
19576
  { options },
20297
19577
  "Provide EnvOption.fee.recipient when calling wallet.createOperation",
@@ -20301,8 +19581,9 @@ var FunWallet = class extends FirstClassActions {
20301
19581
  const chain = await Chain.getChain({ chainIdentifier: options.chain });
20302
19582
  const token = new Token2(options.fee.token, chain);
20303
19583
  if (options.fee.gasPercent && !token.isNative) {
20304
- throw new InvalidParameterError(
20305
- "InvalidParameterCombination" /* InvalidParameterCombination */,
19584
+ throw new InvalidParameterError16(
19585
+ ErrorCode18.InvalidParameterCombination,
19586
+ "GasPercent is only valid for native tokens",
20306
19587
  "GasPercent is only valid for native tokens",
20307
19588
  { options },
20308
19589
  "Use native token as the fee token if you want to charge fee based on percentage",
@@ -20335,8 +19616,9 @@ var FunWallet = class extends FirstClassActions {
20335
19616
  Number(gasUsed) * options.fee.gasPercent / 100
20336
19617
  );
20337
19618
  } else {
20338
- throw new InvalidParameterError(
20339
- "MissingParameter" /* MissingParameter */,
19619
+ throw new InvalidParameterError16(
19620
+ ErrorCode18.MissingParameter,
19621
+ "EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
20340
19622
  "EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
20341
19623
  { options },
20342
19624
  "Provide either EnvOption.fee.amount or EnvOption.fee.gasPercent when calling wallet.createOperation",
@@ -20368,21 +19650,18 @@ export {
20368
19650
  APPROVE_AND_EXEC_ABI,
20369
19651
  APPROVE_AND_EXEC_CONTRACT_INTERFACE,
20370
19652
  APPROVE_AND_SWAP_ABI,
20371
- AccessDeniedError,
20372
19653
  AddressZero,
20373
19654
  Auth,
20374
19655
  AuthType,
20375
19656
  BASE_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
20376
19657
  BASE_WRAP_TOKEN_ADDR,
20377
19658
  BYTES32_LENGTH,
20378
- BaseError,
20379
19659
  CHECKOUT_PAYMASTER_ABI,
20380
19660
  CHECKOUT_PAYMASTER_CONTRACT_INTERFACE,
20381
19661
  CHECKOUT_SPONSOR_SUPPORT_CHAINS,
20382
19662
  CONTRACT_ADDRESSES,
20383
19663
  Chain,
20384
19664
  CheckoutSponsor,
20385
- ClientError,
20386
19665
  ContractInterface,
20387
19666
  DASHBOARD_API_URL,
20388
19667
  DEFAULT_RETRY_OPTIONS,
@@ -20396,9 +19675,6 @@ export {
20396
19675
  ESTIMATION_PAYMASTER_ABI,
20397
19676
  ETHEREUM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
20398
19677
  ETH_TRANSFER_SELECTOR,
20399
- ErrorBaseType,
20400
- ErrorCode,
20401
- ErrorType,
20402
19678
  FACTORY_ABI,
20403
19679
  FACTORY_CONTRACT_INTERFACE,
20404
19680
  FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS,
@@ -20415,9 +19691,7 @@ export {
20415
19691
  GASLESS_SPONSOR_SUPPORT_CHAINS,
20416
19692
  GaslessSponsor,
20417
19693
  HashZero,
20418
- InternalFailureError,
20419
19694
  InvalidActionError,
20420
- InvalidParameterError,
20421
19695
  LOCAL_API_URL,
20422
19696
  NFT,
20423
19697
  OPTIMISM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
@@ -20427,16 +19701,13 @@ export {
20427
19701
  POOL_CONTRACT_INTERFACE,
20428
19702
  RBAC_CONTRACT_INTERFACE,
20429
19703
  ROLE_BASED_ACCESS_CONTROL_ABI,
20430
- ResourceNotFoundError,
20431
19704
  STABLECOIN_SYMBOLS,
20432
- ServerError,
20433
19705
  SessionKeyAuth,
20434
19706
  SocketSort,
20435
19707
  Sponsor,
20436
19708
  TOKEN_PAYMASTER_ABI,
20437
19709
  TOKEN_PAYMASTER_CONTRACT_INTERFACE,
20438
19710
  TOKEN_SPONSOR_SUPPORT_CHAINS,
20439
- ThrottlingError,
20440
19711
  Token2 as Token,
20441
19712
  TokenSponsor,
20442
19713
  UNISWAPV2FACTORY_ABI,
@@ -20450,7 +19721,6 @@ export {
20450
19721
  USER_AUTHENTICATION_ABI,
20451
19722
  USER_AUTHENTICATION_CONTRACT_INTERFACE,
20452
19723
  UniswapPoolFeeOptions,
20453
- UserOpFailureError,
20454
19724
  VALID_PRIVATE_KEY_LENGTH,
20455
19725
  WALLET_ABI,
20456
19726
  WALLET_CONTRACT_INTERFACE,