@funkit/core 2.3.0 → 2.3.1

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,6 +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
+ import { ErrorCode as ErrorCode8, InvalidParameterError as InvalidParameterError7 } from "@funkit/utils";
4
4
 
5
5
  // src/auth/Auth.ts
6
6
  import {
@@ -14,16 +14,16 @@ import {
14
14
  } from "viem";
15
15
  import { privateKeyToAccount } from "viem/accounts";
16
16
  import * as viemChains from "viem/chains";
17
+ import {
18
+ getUserWalletIdentities,
19
+ getUserWalletsByAddr
20
+ } from "@funkit/api-base";
17
21
  import {
18
22
  ErrorCode as ErrorCode7,
19
- InvalidParameterError as InvalidParameterError7,
20
- ResourceNotFoundError as ResourceNotFoundError5
23
+ InvalidParameterError as InvalidParameterError6,
24
+ ResourceNotFoundError as ResourceNotFoundError4
21
25
  } from "@funkit/utils";
22
26
 
23
- // src/apis/UserApis.ts
24
- import { InvalidParameterError as InvalidParameterError6 } from "viem";
25
- import { ResourceNotFoundError as ResourceNotFoundError4 } from "@funkit/utils";
26
-
27
27
  // src/common/constants.ts
28
28
  import { padHex } from "viem";
29
29
  import {
@@ -11502,6 +11502,12 @@ import {
11502
11502
  http,
11503
11503
  createPublicClient
11504
11504
  } from "viem";
11505
+ import {
11506
+ estimateOp,
11507
+ getChainFromId,
11508
+ getChainFromName,
11509
+ getUserOpGasPrice
11510
+ } from "@funkit/api-base";
11505
11511
  import {
11506
11512
  ErrorCode as ErrorCode4,
11507
11513
  InternalFailureError as InternalFailureError2,
@@ -11509,29 +11515,195 @@ import {
11509
11515
  ResourceNotFoundError as ResourceNotFoundError3
11510
11516
  } from "@funkit/utils";
11511
11517
 
11512
- // src/apis/InfoApis.ts
11513
- import { ErrorCode as ErrorCode3, ResourceNotFoundError as ResourceNotFoundError2 } from "@funkit/utils";
11514
-
11515
11518
  // src/utils/ApiUtils.ts
11516
11519
  import { retry } from "@lifeomic/attempt";
11517
11520
  import {
11518
11521
  AccessDeniedError,
11519
- ErrorCode as ErrorCode2,
11522
+ ErrorCode,
11520
11523
  InternalFailureError,
11521
- InvalidParameterError as InvalidParameterError2,
11524
+ InvalidParameterError,
11522
11525
  ResourceNotFoundError,
11523
11526
  ThrottlingError,
11524
11527
  UserOpFailureError
11525
11528
  } from "@funkit/utils";
11529
+ var errorHandler = (err, context) => {
11530
+ if (err instanceof ResourceNotFoundError || err instanceof InvalidParameterError || err instanceof UserOpFailureError) {
11531
+ context.abort();
11532
+ }
11533
+ };
11534
+ var DEFAULT_RETRY_OPTIONS = {
11535
+ delay: 100,
11536
+ initialDelay: 0,
11537
+ maxDelay: 3e3,
11538
+ factor: 2,
11539
+ maxAttempts: 5,
11540
+ timeout: 0,
11541
+ jitter: true,
11542
+ minDelay: 0,
11543
+ handleError: errorHandler,
11544
+ handleTimeout: null,
11545
+ beforeAttempt: null,
11546
+ calculateDelay: null
11547
+ };
11548
+ var sendRequest = async (uri, method, apiKey, body, retryOptions) => {
11549
+ try {
11550
+ const headers = {
11551
+ "Content-Type": "application/json"
11552
+ };
11553
+ if (apiKey) {
11554
+ headers["X-Api-Key"] = apiKey;
11555
+ }
11556
+ const finalRetryOptions = {
11557
+ ...DEFAULT_RETRY_OPTIONS,
11558
+ ...retryOptions || {}
11559
+ };
11560
+ return retry(async () => {
11561
+ const response = await fetch(uri, {
11562
+ method,
11563
+ headers,
11564
+ redirect: "follow",
11565
+ body: method !== "GET" ? stringify(body) : void 0
11566
+ });
11567
+ const json = await response.json();
11568
+ if (response.ok) {
11569
+ return json;
11570
+ }
11571
+ if (response.status === 400) {
11572
+ throw new InvalidParameterError(
11573
+ ErrorCode.InvalidParameter,
11574
+ `bad request ${JSON.stringify(json)}`,
11575
+ `bad request ${JSON.stringify(json)}`,
11576
+ { body },
11577
+ "check the api call parameters. its mostly because some call parameters are wrong",
11578
+ "https://docs.fun.xyz"
11579
+ );
11580
+ }
11581
+ if (response.status === 403) {
11582
+ throw new AccessDeniedError(
11583
+ ErrorCode.Unauthorized,
11584
+ "Invalid API key or insufficient access.",
11585
+ "Invalid API key or insufficient access.",
11586
+ { apiKey },
11587
+ "Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
11588
+ "https://docs.fun.xyz"
11589
+ );
11590
+ }
11591
+ if (response.status === 404) {
11592
+ throw new ResourceNotFoundError(
11593
+ ErrorCode.ServerMissingData,
11594
+ JSON.stringify(json),
11595
+ JSON.stringify(json),
11596
+ { body },
11597
+ "check the api call parameters. its mostly because some call parameters are wrong",
11598
+ "https://docs.fun.xyz"
11599
+ );
11600
+ }
11601
+ if (response.status === 429) {
11602
+ throw new ThrottlingError(
11603
+ ErrorCode.RequestLimitExceeded,
11604
+ `too many requests ${JSON.stringify(json)}`,
11605
+ `too many requests ${JSON.stringify(json)}`,
11606
+ { body },
11607
+ "you are making too many requests. please slow down. Reach out to fun team if you need more quota",
11608
+ "https://docs.fun.xyz"
11609
+ );
11610
+ }
11611
+ if (response.status === 500) {
11612
+ if (json.errorCode === ErrorCode.UserOpFailureError) {
11613
+ throw new UserOpFailureError(
11614
+ ErrorCode.UserOpFailureError,
11615
+ JSON.stringify(json),
11616
+ JSON.stringify(json),
11617
+ { body },
11618
+ "fix user op failure. Most of the time this is due to invalid parameters",
11619
+ "https://docs.fun.xyz"
11620
+ );
11621
+ }
11622
+ throw new InternalFailureError(
11623
+ ErrorCode.ServerFailure,
11624
+ `server failure ${JSON.stringify(json)}`,
11625
+ json.errorMsg,
11626
+ { body },
11627
+ "retry later. if it still fails, please contact us.",
11628
+ "https://docs.fun.xyz"
11629
+ );
11630
+ }
11631
+ if (response.status === 504) {
11632
+ throw new InternalFailureError(
11633
+ ErrorCode.ServerTimeout,
11634
+ `server timeout failure ${JSON.stringify(json)}`,
11635
+ json.errorMsg,
11636
+ { body },
11637
+ "retry later. if it still fails, please contact us.",
11638
+ "https://docs.fun.xyz"
11639
+ );
11640
+ }
11641
+ if (!response.ok) {
11642
+ throw new InternalFailureError(
11643
+ ErrorCode.UnknownServerError,
11644
+ `unknown server failure ${JSON.stringify(json)}`,
11645
+ json.errorMsg,
11646
+ { body },
11647
+ "retry later. if it still fails, please contact us.",
11648
+ "https://docs.fun.xyz"
11649
+ );
11650
+ }
11651
+ return {};
11652
+ }, finalRetryOptions);
11653
+ } catch (err) {
11654
+ throw new InternalFailureError(
11655
+ ErrorCode.ServerConnectionError,
11656
+ `Cannot connect to Fun API Service ${err}`,
11657
+ "",
11658
+ { body },
11659
+ "retry later. if it still fails, please contact us.",
11660
+ "https://docs.fun.xyz"
11661
+ );
11662
+ }
11663
+ };
11664
+ async function sendGetRequest(uri, endpoint, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
11665
+ return await sendRequest(
11666
+ `${uri}/${endpoint}`,
11667
+ "GET",
11668
+ apiKey,
11669
+ void 0,
11670
+ retryOptions
11671
+ );
11672
+ }
11673
+ async function sendPostRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
11674
+ return await sendRequest(
11675
+ `${uri}/${endpoint}`,
11676
+ "POST",
11677
+ apiKey,
11678
+ body,
11679
+ retryOptions
11680
+ );
11681
+ }
11682
+ async function sendDeleteRequest(uri, endpoint, apiKey = globalThis.globalEnvOption.apiKey) {
11683
+ await sendRequest(`${uri}/${endpoint}`, "DELETE", apiKey);
11684
+ }
11685
+ async function sendPutRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption.apiKey) {
11686
+ await sendRequest(`${uri}/${endpoint}`, "PUT", apiKey, body);
11687
+ }
11526
11688
 
11527
11689
  // src/utils/AuthUtils.ts
11528
11690
  import { v4 as uuidv4 } from "uuid";
11529
11691
  import { generatePrivateKey as generateRandomPrivateKey } from "viem/accounts";
11692
+ import { createUser, getUserUniqueId } from "@funkit/api-base";
11530
11693
  var getAuthUniqueId = async (authId, addr = "NO_ADDRESS", skipDBActions = false) => {
11531
- const authUniqueId = (skipDBActions ? addr : await getUserUniqueId(authId)) || uuidv4();
11694
+ const authUniqueId = (skipDBActions ? addr : await getUserUniqueId({
11695
+ authId,
11696
+ apiKey: globalThis.globalEnvOption.apiKey
11697
+ })) || uuidv4();
11532
11698
  const words = authId.split("###");
11533
11699
  const method = words[0].startsWith("0x") ? "eoa" : words[0];
11534
- await createUser(authId, addr, method, authUniqueId);
11700
+ await createUser({
11701
+ authId,
11702
+ addr,
11703
+ method,
11704
+ userUniqueId: authUniqueId,
11705
+ apiKey: globalThis.globalEnvOption.apiKey
11706
+ });
11535
11707
  return authUniqueId;
11536
11708
  };
11537
11709
  var generatePrivateKey = () => {
@@ -11551,7 +11723,7 @@ import {
11551
11723
  toBytes,
11552
11724
  toHex
11553
11725
  } from "viem";
11554
- import { ErrorCode, InvalidParameterError } from "@funkit/utils";
11726
+ import { ErrorCode as ErrorCode2, InvalidParameterError as InvalidParameterError2 } from "@funkit/utils";
11555
11727
  var isAddress = (address) => {
11556
11728
  try {
11557
11729
  const [decodedAddr] = decodeAbiParameters(
@@ -11665,8 +11837,8 @@ var useFaucet = async (chainIdentifier, wallet) => {
11665
11837
  const chain = await Chain.getChain({ chainIdentifier });
11666
11838
  const chainName = await chain.getChainName();
11667
11839
  if (chainName !== "goerli") {
11668
- throw new InvalidParameterError(
11669
- ErrorCode.InvalidChainIdentifier,
11840
+ throw new InvalidParameterError2(
11841
+ ErrorCode2.InvalidChainIdentifier,
11670
11842
  "Only Goerli is supported",
11671
11843
  "Only Goerli is supported",
11672
11844
  chainIdentifier,
@@ -11924,9 +12096,36 @@ async function getOpHash(chain, userOp) {
11924
12096
  );
11925
12097
  }
11926
12098
 
12099
+ // src/utils/TokenUtils.ts
12100
+ import { getAssetErc20ByChainAndSymbol } from "@funkit/api-base";
12101
+ import { ErrorCode as ErrorCode3, ResourceNotFoundError as ResourceNotFoundError2 } from "@funkit/utils";
12102
+ async function getTokenAddressBySymbolAndChainId(inputSymbol, inputChainId) {
12103
+ const normalizedSymbol = inputSymbol.toLowerCase();
12104
+ if (BASE_WRAP_TOKEN_ADDR?.[inputChainId]?.[normalizedSymbol]) {
12105
+ return BASE_WRAP_TOKEN_ADDR[inputChainId][normalizedSymbol];
12106
+ }
12107
+ const tokenInfo = await getAssetErc20ByChainAndSymbol({
12108
+ chainId: inputChainId,
12109
+ symbol: normalizedSymbol,
12110
+ apiKey: globalThis.globalEnvOption.apiKey
12111
+ });
12112
+ if (tokenInfo.address) {
12113
+ return tokenInfo.address;
12114
+ }
12115
+ throw new ResourceNotFoundError2(
12116
+ ErrorCode3.TokenNotFound,
12117
+ "token symbol does not exist on provided chain",
12118
+ "token symbol does not exist on provided chain",
12119
+ { symbol: inputSymbol, chainId: inputChainId },
12120
+ "Provide correct symbol and chainId.",
12121
+ "https://docs.fun.xyz"
12122
+ );
12123
+ }
12124
+
11927
12125
  // src/utils/WalletUtils.ts
11928
12126
  import { v4 as uuidv42 } from "uuid";
11929
12127
  import { keccak256 as keccak2563, pad as pad2, toBytes as toBytes3 } from "viem";
12128
+ import { AuthType } from "@funkit/api-base";
11930
12129
  var generateRandomBytes32 = () => {
11931
12130
  return keccak2563(toBytes3(uuidv42()));
11932
12131
  };
@@ -11963,7 +12162,7 @@ var isWalletInitOp = (userOp) => {
11963
12162
  return userOp.initCode !== "0x";
11964
12163
  };
11965
12164
  var isGroupOperation = (operation) => {
11966
- if (operation.groupId && operation.authType === 1 /* MULTI_SIG */) {
12165
+ if (operation.groupId && operation.authType === AuthType.MULTI_SIG) {
11967
12166
  return true;
11968
12167
  }
11969
12168
  return false;
@@ -11982,335 +12181,41 @@ var isSignatureMissing = (userId, signatures) => {
11982
12181
  return sigMissing;
11983
12182
  };
11984
12183
 
11985
- // src/utils/ApiUtils.ts
11986
- var errorHandler = (err, context) => {
11987
- if (err instanceof ResourceNotFoundError || err instanceof InvalidParameterError2 || err instanceof UserOpFailureError) {
11988
- context.abort();
12184
+ // src/data/Chain.ts
12185
+ var Chain = class _Chain {
12186
+ constructor(chainInput) {
12187
+ this.initialized = false;
12188
+ this.addresses = {};
12189
+ if (!chainInput.chainIdentifier && !chainInput.rpcUrl) {
12190
+ throw new InvalidParameterError3(
12191
+ ErrorCode4.InvalidChainIdentifier,
12192
+ "valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
12193
+ "valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
12194
+ { chainInput },
12195
+ "Please provide valid chain identifier or rpcUrl",
12196
+ "https://docs.fun.xyz"
12197
+ );
12198
+ }
12199
+ if (chainInput.rpcUrl) {
12200
+ this.rpcUrl = chainInput.rpcUrl;
12201
+ } else if (chainInput.chainIdentifier instanceof _Chain) {
12202
+ return chainInput.chainIdentifier;
12203
+ } else if (typeof chainInput.chainIdentifier === "number" || Number(chainInput.chainIdentifier)) {
12204
+ this.id = chainInput.chainIdentifier.toString();
12205
+ } else {
12206
+ this.name = chainInput.chainIdentifier;
12207
+ }
11989
12208
  }
11990
- };
11991
- var DEFAULT_RETRY_OPTIONS = {
11992
- delay: 100,
11993
- initialDelay: 0,
11994
- maxDelay: 3e3,
11995
- factor: 2,
11996
- maxAttempts: 5,
11997
- timeout: 0,
11998
- jitter: true,
11999
- minDelay: 0,
12000
- handleError: errorHandler,
12001
- handleTimeout: null,
12002
- beforeAttempt: null,
12003
- calculateDelay: null
12004
- };
12005
- var sendRequest = async (uri, method, apiKey, body, retryOptions) => {
12006
- try {
12007
- const headers = {
12008
- "Content-Type": "application/json"
12009
- };
12010
- if (apiKey) {
12011
- headers["X-Api-Key"] = apiKey;
12209
+ static async getChain(chainInput) {
12210
+ if (chainInput.chainIdentifier instanceof _Chain) {
12211
+ return chainInput.chainIdentifier;
12012
12212
  }
12013
- const finalRetryOptions = {
12014
- ...DEFAULT_RETRY_OPTIONS,
12015
- ...retryOptions || {}
12016
- };
12017
- return retry(async () => {
12018
- const response = await fetch(uri, {
12019
- method,
12020
- headers,
12021
- redirect: "follow",
12022
- body: method !== "GET" ? stringify(body) : void 0
12023
- });
12024
- const json = await response.json();
12025
- if (response.ok) {
12026
- return json;
12027
- }
12028
- if (response.status === 400) {
12029
- throw new InvalidParameterError2(
12030
- ErrorCode2.InvalidParameter,
12031
- `bad request ${JSON.stringify(json)}`,
12032
- `bad request ${JSON.stringify(json)}`,
12033
- { body },
12034
- "check the api call parameters. its mostly because some call parameters are wrong",
12035
- "https://docs.fun.xyz"
12036
- );
12037
- }
12038
- if (response.status === 403) {
12039
- throw new AccessDeniedError(
12040
- ErrorCode2.Unauthorized,
12041
- "Invalid API key or insufficient access.",
12042
- "Invalid API key or insufficient access.",
12043
- { apiKey },
12044
- "Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
12045
- "https://docs.fun.xyz"
12046
- );
12047
- }
12048
- if (response.status === 404) {
12049
- throw new ResourceNotFoundError(
12050
- ErrorCode2.ServerMissingData,
12051
- JSON.stringify(json),
12052
- JSON.stringify(json),
12053
- { body },
12054
- "check the api call parameters. its mostly because some call parameters are wrong",
12055
- "https://docs.fun.xyz"
12056
- );
12057
- }
12058
- if (response.status === 429) {
12059
- throw new ThrottlingError(
12060
- ErrorCode2.RequestLimitExceeded,
12061
- `too many requests ${JSON.stringify(json)}`,
12062
- `too many requests ${JSON.stringify(json)}`,
12063
- { body },
12064
- "you are making too many requests. please slow down. Reach out to fun team if you need more quota",
12065
- "https://docs.fun.xyz"
12066
- );
12067
- }
12068
- if (response.status === 500) {
12069
- if (json.errorCode === ErrorCode2.UserOpFailureError) {
12070
- throw new UserOpFailureError(
12071
- ErrorCode2.UserOpFailureError,
12072
- JSON.stringify(json),
12073
- JSON.stringify(json),
12074
- { body },
12075
- "fix user op failure. Most of the time this is due to invalid parameters",
12076
- "https://docs.fun.xyz"
12077
- );
12078
- }
12079
- throw new InternalFailureError(
12080
- ErrorCode2.ServerFailure,
12081
- `server failure ${JSON.stringify(json)}`,
12082
- json.errorMsg,
12083
- { body },
12084
- "retry later. if it still fails, please contact us.",
12085
- "https://docs.fun.xyz"
12086
- );
12087
- }
12088
- if (response.status === 504) {
12089
- throw new InternalFailureError(
12090
- ErrorCode2.ServerTimeout,
12091
- `server timeout failure ${JSON.stringify(json)}`,
12092
- json.errorMsg,
12093
- { body },
12094
- "retry later. if it still fails, please contact us.",
12095
- "https://docs.fun.xyz"
12096
- );
12097
- }
12098
- if (!response.ok) {
12099
- throw new InternalFailureError(
12100
- ErrorCode2.UnknownServerError,
12101
- `unknown server failure ${JSON.stringify(json)}`,
12102
- json.errorMsg,
12103
- { body },
12104
- "retry later. if it still fails, please contact us.",
12105
- "https://docs.fun.xyz"
12106
- );
12107
- }
12108
- return {};
12109
- }, finalRetryOptions);
12110
- } catch (err) {
12111
- throw new InternalFailureError(
12112
- ErrorCode2.ServerConnectionError,
12113
- `Cannot connect to Fun API Service ${err}`,
12114
- "",
12115
- { body },
12116
- "retry later. if it still fails, please contact us.",
12117
- "https://docs.fun.xyz"
12118
- );
12119
- }
12120
- };
12121
- async function sendGetRequest(uri, endpoint, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
12122
- return await sendRequest(
12123
- `${uri}/${endpoint}`,
12124
- "GET",
12125
- apiKey,
12126
- void 0,
12127
- retryOptions
12128
- );
12129
- }
12130
- async function sendPostRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
12131
- return await sendRequest(
12132
- `${uri}/${endpoint}`,
12133
- "POST",
12134
- apiKey,
12135
- body,
12136
- retryOptions
12137
- );
12138
- }
12139
- async function sendDeleteRequest(uri, endpoint, apiKey = globalThis.globalEnvOption.apiKey) {
12140
- await sendRequest(`${uri}/${endpoint}`, "DELETE", apiKey);
12141
- }
12142
- async function sendPutRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption.apiKey) {
12143
- await sendRequest(`${uri}/${endpoint}`, "PUT", apiKey, body);
12144
- }
12145
-
12146
- // src/apis/InfoApis.ts
12147
- async function getTokenInfo(symbol, chainId) {
12148
- const normalizedSymbol = symbol.toLowerCase();
12149
- const body = {
12150
- symbol: normalizedSymbol,
12151
- chain: chainId
12152
- };
12153
- if (normalizedSymbol === "weth" && chainId !== "137" && Object.keys(BASE_WRAP_TOKEN_ADDR).includes(chainId)) {
12154
- return BASE_WRAP_TOKEN_ADDR[chainId][normalizedSymbol];
12155
- } else if (normalizedSymbol === "wmatic" && chainId === "137") {
12156
- return BASE_WRAP_TOKEN_ADDR[chainId][normalizedSymbol];
12157
- }
12158
- const tokenInfo = await sendGetRequest(
12159
- API_URL,
12160
- `asset/erc20/${body.chain}/${body.symbol}`
12161
- );
12162
- if (tokenInfo.address) {
12163
- return tokenInfo.address;
12164
- }
12165
- throw new ResourceNotFoundError2(
12166
- ErrorCode3.TokenNotFound,
12167
- "token symbol does not exist on provided chain",
12168
- "token symbol does not exist on provided chain",
12169
- { symbol, chainId },
12170
- "Provide correct symbol and chainId.",
12171
- "https://docs.fun.xyz"
12172
- );
12173
- }
12174
- async function getChainFromId(chainId) {
12175
- return await sendGetRequest(API_URL, `chain-info/${chainId}`).then((r) => {
12176
- if (!r) {
12177
- throw new Error(JSON.stringify(r));
12178
- }
12179
- return r;
12180
- });
12181
- }
12182
- async function getChainFromName(name) {
12183
- return await sendGetRequest(API_URL, `chain-info?name=${name}`).then((r) => {
12184
- if (!r) {
12185
- throw new Error(JSON.stringify(r));
12186
- }
12187
- return r;
12188
- });
12189
- }
12190
- async function getModuleInfo(moduleName, chainId) {
12191
- const body = {
12192
- module: moduleName,
12193
- chain: chainId
12194
- };
12195
- return await sendPostRequest(API_URL, "get-module-info", body).then((r) => {
12196
- return r.data;
12197
- });
12198
- }
12199
- async function getPaymasterAddress(chainId) {
12200
- const {
12201
- moduleAddresses: {
12202
- paymaster: { paymasterAddress }
12203
- }
12204
- } = await getChainFromId(chainId);
12205
- return paymasterAddress;
12206
- }
12207
-
12208
- // src/apis/OperationApis.ts
12209
- async function createOp(op) {
12210
- return (await sendPostRequest(API_URL, "operation", { ...op })).opId;
12211
- }
12212
- async function getOpsOfGroup(groupId, chainId, status) {
12213
- const endpoint = status === "" /* ALL */ ? `operation/group/${groupId}/${chainId}` : `operation/group/${groupId}/chain/${chainId}?status=${status}`;
12214
- return (await sendGetRequest(API_URL, endpoint)).operations;
12215
- }
12216
- async function getOpsOfWallet(walletAddr, chainId, status) {
12217
- const endpoint = status ? `operation/wallet/${walletAddr}/chain/${chainId}?status=${status}` : `operation/wallet/${walletAddr}/chain/${chainId}`;
12218
- return (await sendGetRequest(API_URL, endpoint)).operations;
12219
- }
12220
- async function getOps(opIds, chainId) {
12221
- return (await sendPostRequest(API_URL, "operation/get-operations", {
12222
- opIds,
12223
- chainId
12224
- })).operations;
12225
- }
12226
- async function deleteOp(opId, chainId) {
12227
- await sendDeleteRequest(API_URL, `operation/${opId}/chain/${chainId}`);
12228
- }
12229
- async function signOp(opId, chainId, signature, signedBy, threshold) {
12230
- await sendPostRequest(API_URL, "operation/sign", {
12231
- opId,
12232
- chainId,
12233
- signature,
12234
- signedBy,
12235
- threshold
12236
- });
12237
- }
12238
- async function executeOp(executeOpInput) {
12239
- return await sendPostRequest(API_URL, "operation/execute", executeOpInput);
12240
- }
12241
- async function estimateOp(estimateOpInput) {
12242
- return await sendPostRequest(API_URL, "operation/estimate", estimateOpInput);
12243
- }
12244
- async function scheduleOp(scheduleOpInput) {
12245
- await sendPostRequest(API_URL, "operation/schedule", scheduleOpInput);
12246
- }
12247
- var getFullReceipt = async (opId, chainId, userOpHash) => {
12248
- const retries = 20;
12249
- let result;
12250
- for (let i = 0; i < retries; i++) {
12251
- try {
12252
- result = await sendGetRequest(
12253
- API_URL,
12254
- `operation/${opId}/chain/${chainId}/receipt?userOpHash=${userOpHash}`
12255
- );
12256
- if (result.status === "included") {
12257
- break;
12258
- }
12259
- } catch (_err) {
12260
- }
12261
- await new Promise((resolve) => setTimeout(resolve, 2500));
12262
- }
12263
- if (!result.receipt) {
12264
- result.receipt = {
12265
- txId: "Failed to find.",
12266
- gasUsed: "Failed to find.",
12267
- opFeeUSD: "Failed to find.",
12268
- opFee: "Failed to find."
12269
- };
12270
- }
12271
- return {
12272
- ...result.receipt
12273
- };
12274
- };
12275
- var getGasPrice = async (chainId) => {
12276
- return await sendGetRequest(API_URL, `operation/chain/${chainId}/gas-price`);
12277
- };
12278
-
12279
- // src/data/Chain.ts
12280
- var Chain = class _Chain {
12281
- constructor(chainInput) {
12282
- this.initialized = false;
12283
- this.addresses = {};
12284
- if (!chainInput.chainIdentifier && !chainInput.rpcUrl) {
12285
- throw new InvalidParameterError3(
12286
- ErrorCode4.InvalidChainIdentifier,
12287
- "valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
12288
- "valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
12289
- { chainInput },
12290
- "Please provide valid chain identifier or rpcUrl",
12291
- "https://docs.fun.xyz"
12292
- );
12293
- }
12294
- if (chainInput.rpcUrl) {
12295
- this.rpcUrl = chainInput.rpcUrl;
12296
- } else if (chainInput.chainIdentifier instanceof _Chain) {
12297
- return chainInput.chainIdentifier;
12298
- } else if (typeof chainInput.chainIdentifier === "number" || Number(chainInput.chainIdentifier)) {
12299
- this.id = chainInput.chainIdentifier.toString();
12300
- } else {
12301
- this.name = chainInput.chainIdentifier;
12302
- }
12303
- }
12304
- static async getChain(chainInput) {
12305
- if (chainInput.chainIdentifier instanceof _Chain) {
12306
- return chainInput.chainIdentifier;
12307
- }
12308
- if (!_Chain.chain || await _Chain.chain.getChainId() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getChainName() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getRpcUrl() !== chainInput.rpcUrl) {
12309
- if (typeof chainInput.chainIdentifier === "string") {
12310
- chainInput.chainIdentifier = chainInput.chainIdentifier.replace(
12311
- /\s/g,
12312
- ""
12313
- );
12213
+ if (!_Chain.chain || await _Chain.chain.getChainId() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getChainName() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getRpcUrl() !== chainInput.rpcUrl) {
12214
+ if (typeof chainInput.chainIdentifier === "string") {
12215
+ chainInput.chainIdentifier = chainInput.chainIdentifier.replace(
12216
+ /\s/g,
12217
+ ""
12218
+ );
12314
12219
  }
12315
12220
  if (chainInput.chainIdentifier === "ethereum-goerli") {
12316
12221
  chainInput.chainIdentifier = "goerli";
@@ -12343,9 +12248,15 @@ var Chain = class _Chain {
12343
12248
  async loadChain(identifier) {
12344
12249
  let chain;
12345
12250
  if (!Number(identifier)) {
12346
- chain = await getChainFromName(identifier);
12251
+ chain = await getChainFromName({
12252
+ name: identifier,
12253
+ apiKey: globalThis.globalEnvOption.apiKey
12254
+ });
12347
12255
  } else {
12348
- chain = await getChainFromId(identifier);
12256
+ chain = await getChainFromId({
12257
+ chainId: identifier,
12258
+ apiKey: globalThis.globalEnvOption.apiKey
12259
+ });
12349
12260
  }
12350
12261
  this.id = chain.id;
12351
12262
  this.name = chain.name;
@@ -12390,10 +12301,6 @@ var Chain = class _Chain {
12390
12301
  }
12391
12302
  return res;
12392
12303
  }
12393
- async getModuleAddresses(name) {
12394
- await this.init();
12395
- return await getModuleInfo(name, this.id);
12396
- }
12397
12304
  async getCurrency() {
12398
12305
  await this.init();
12399
12306
  return this.currency;
@@ -12406,7 +12313,10 @@ var Chain = class _Chain {
12406
12313
  await this.init();
12407
12314
  let result;
12408
12315
  try {
12409
- result = await getGasPrice(this.id);
12316
+ result = await getUserOpGasPrice({
12317
+ chainId: this.id,
12318
+ apiKey: globalThis.globalEnvOption.apiKey
12319
+ });
12410
12320
  } catch (_err) {
12411
12321
  const fallBackGasPrice = await this.client.getGasPrice();
12412
12322
  result = {
@@ -12437,9 +12347,12 @@ var Chain = class _Chain {
12437
12347
  estimationUserOp.paymasterAndData = ETHEREUM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION;
12438
12348
  }
12439
12349
  let { preVerificationGas, callGasLimit, verificationGasLimit } = await estimateOp({
12440
- chainId: this.id,
12441
- entryPointAddress: this.addresses.entryPointAddress,
12442
- userOp: estimationUserOp
12350
+ input: {
12351
+ chainId: this.id,
12352
+ entryPointAddress: this.addresses.entryPointAddress,
12353
+ userOp: estimationUserOp
12354
+ },
12355
+ apiKey: globalThis.globalEnvOption.apiKey
12443
12356
  });
12444
12357
  if (!preVerificationGas || !verificationGasLimit || !callGasLimit) {
12445
12358
  throw new Error(
@@ -12806,7 +12719,12 @@ import {
12806
12719
  InternalFailureError as InternalFailureError3,
12807
12720
  InvalidParameterError as InvalidParameterError5
12808
12721
  } from "@funkit/utils";
12809
- var wrappedNativeTokens = { eth: "weth", matic: "wmatic", mnt: "wmnt" };
12722
+ var wrappedNativeTokens = {
12723
+ eth: "weth",
12724
+ matic: "wmatic",
12725
+ pol: "wpol",
12726
+ mnt: "wmnt"
12727
+ };
12810
12728
  var Token = class _Token {
12811
12729
  constructor(input, chain) {
12812
12730
  this.isNative = false;
@@ -12815,7 +12733,8 @@ var Token = class _Token {
12815
12733
  if (isAddress3(input)) {
12816
12734
  this.address = input;
12817
12735
  return;
12818
- } else if (input.toLowerCase() in wrappedNativeTokens) {
12736
+ }
12737
+ if (input.toLowerCase() in wrappedNativeTokens) {
12819
12738
  this.isNative = true;
12820
12739
  }
12821
12740
  this.symbol = input.toLowerCase();
@@ -12824,13 +12743,13 @@ var Token = class _Token {
12824
12743
  const chainId = await this.chain.getChainId();
12825
12744
  if (this.isNative) {
12826
12745
  const nativeName = wrappedNativeTokens[this.symbol];
12827
- return await getTokenInfo(nativeName, chainId);
12746
+ return await getTokenAddressBySymbolAndChainId(nativeName, chainId);
12828
12747
  }
12829
12748
  if (this.address) {
12830
12749
  return this.address;
12831
12750
  }
12832
12751
  if (this.symbol) {
12833
- return await getTokenInfo(this.symbol, chainId);
12752
+ return await getTokenAddressBySymbolAndChainId(this.symbol, chainId);
12834
12753
  }
12835
12754
  throw new InternalFailureError3(
12836
12755
  ErrorCode6.ServerMissingData,
@@ -12953,29 +12872,6 @@ var Token = class _Token {
12953
12872
  }
12954
12873
  };
12955
12874
 
12956
- // src/data/types.ts
12957
- var AuthType = /* @__PURE__ */ ((AuthType2) => {
12958
- AuthType2[AuthType2["ECDSA"] = 0] = "ECDSA";
12959
- AuthType2[AuthType2["MULTI_SIG"] = 1] = "MULTI_SIG";
12960
- return AuthType2;
12961
- })(AuthType || {});
12962
- var OperationType = /* @__PURE__ */ ((OperationType2) => {
12963
- OperationType2["SINGLE_OPERATION"] = "SINGLE_OPERATION";
12964
- OperationType2["GROUP_OPERATION"] = "GROUP_OPERATION";
12965
- OperationType2["REJECTION"] = "REJECTION";
12966
- return OperationType2;
12967
- })(OperationType || {});
12968
- var OperationStatus = /* @__PURE__ */ ((OperationStatus2) => {
12969
- OperationStatus2["ALL"] = "";
12970
- OperationStatus2["PENDING_APPROVED"] = "PENDING_APPROVED";
12971
- OperationStatus2["APPROVED"] = "APPROVED";
12972
- OperationStatus2["PENDING"] = "PENDING";
12973
- OperationStatus2["OP_SUCCEED"] = "OP_SUCCEED";
12974
- OperationStatus2["OP_REVERTED"] = "OP_REVERTED";
12975
- OperationStatus2["SCHEDULED"] = "SCHEDULED";
12976
- return OperationStatus2;
12977
- })(OperationStatus || {});
12978
-
12979
12875
  // src/viem/ContractInterface.ts
12980
12876
  var ContractInterface = class {
12981
12877
  constructor(abi) {
@@ -13071,8 +12967,6 @@ var getItemFromAbi = (abi, name, type) => {
13071
12967
  };
13072
12968
 
13073
12969
  // src/common/constants.ts
13074
- var LOCAL_API_URL = "http://127.0.0.1:3000";
13075
- var API_URL = "https://api.fun.xyz/v1";
13076
12970
  var BASE_WRAP_TOKEN_ADDR = {
13077
12971
  "1": {
13078
12972
  weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
@@ -13084,7 +12978,8 @@ var BASE_WRAP_TOKEN_ADDR = {
13084
12978
  weth: "0x4200000000000000000000000000000000000006"
13085
12979
  },
13086
12980
  "137": {
13087
- wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"
12981
+ wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
12982
+ wpol: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"
13088
12983
  },
13089
12984
  "5000": {
13090
12985
  weth: "0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111"
@@ -13538,59 +13433,6 @@ var FUNKIT_CONNECT_SUPPORTED_CHECKOUT_CHAINS_INFO_LIST = FUNKIT_CONNECT_SUPPORTE
13538
13433
  );
13539
13434
  var FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
13540
13435
 
13541
- // src/apis/UserApis.ts
13542
- async function createUser(authId, addr, method, userUniqueId) {
13543
- await sendPostRequest(API_URL, "user", {
13544
- authId,
13545
- addr,
13546
- method,
13547
- userUniqueId
13548
- });
13549
- }
13550
- async function getUserUniqueId(authId) {
13551
- try {
13552
- return (await sendGetRequest(API_URL, `user/auth/${authId}/unique-id`)).userUniqueId;
13553
- } catch (err) {
13554
- if (err instanceof ResourceNotFoundError4) {
13555
- return "";
13556
- }
13557
- throw err;
13558
- }
13559
- }
13560
- async function getUserAddr(authId) {
13561
- return (await sendGetRequest(API_URL, `user/auth/${authId}/addr`)).addr;
13562
- }
13563
- async function getUserWalletsByAddr(addr, chainId) {
13564
- const endpoint = chainId ? `user/addr/${addr}/wallets?chainId=${chainId}` : `user/addr/${addr}/wallets`;
13565
- return (await sendGetRequest(API_URL, endpoint)).wallets;
13566
- }
13567
- async function getUserAuthIdByAddr(addr) {
13568
- return (await sendGetRequest(API_URL, `user/addr/${addr}/authId`)).authId;
13569
- }
13570
- async function addUserToWallet(authId, chainId, walletAddr, userIds, walletUniqueId) {
13571
- try {
13572
- await sendPostRequest(
13573
- API_URL,
13574
- `user/auth/${authId}/chain/${chainId}/wallet`,
13575
- {
13576
- walletAddr,
13577
- userIds,
13578
- walletUniqueId
13579
- }
13580
- );
13581
- } catch (err) {
13582
- if (err instanceof InvalidParameterError6) {
13583
- return;
13584
- }
13585
- }
13586
- }
13587
- async function getUserWalletIdentities(authId, chainId, walletAddr) {
13588
- return (await sendGetRequest(
13589
- API_URL,
13590
- `user/auth/${authId}/chain/${chainId}/wallet/${walletAddr}/identities`
13591
- )).ids ?? [];
13592
- }
13593
-
13594
13436
  // src/utils/TypeUtils.ts
13595
13437
  import { isHex } from "viem";
13596
13438
  var isBytes32 = (input) => {
@@ -13708,7 +13550,7 @@ var Auth = class {
13708
13550
  } else if (!isHex2(authInput.privateKey) && authInput.privateKey.length === VALID_PRIVATE_KEY_LENGTH) {
13709
13551
  privateKey = `0x${authInput.privateKey}`;
13710
13552
  } else {
13711
- throw new InvalidParameterError7(
13553
+ throw new InvalidParameterError6(
13712
13554
  ErrorCode7.InvalidParameter,
13713
13555
  "privateKey is not a valid one",
13714
13556
  "privateKey is not a valid one",
@@ -13719,7 +13561,7 @@ var Auth = class {
13719
13561
  }
13720
13562
  this.signer = privateKeyToAccount(privateKey);
13721
13563
  } else {
13722
- throw new InvalidParameterError7(
13564
+ throw new InvalidParameterError6(
13723
13565
  ErrorCode7.MissingParameter,
13724
13566
  "valid authInput is required",
13725
13567
  "valid authInput is required",
@@ -13842,7 +13684,7 @@ var Auth = class {
13842
13684
  const { to, data } = txData;
13843
13685
  const { value = 0n } = txData;
13844
13686
  if (!chain || !chainId) {
13845
- throw new InvalidParameterError7(
13687
+ throw new InvalidParameterError6(
13846
13688
  ErrorCode7.MissingParameter,
13847
13689
  "chain object is missing or incorrect",
13848
13690
  "chain object is missing or incorrect",
@@ -13932,7 +13774,12 @@ var Auth = class {
13932
13774
  */
13933
13775
  async getUserIds(wallet, chainId) {
13934
13776
  await this.init();
13935
- return await getUserWalletIdentities(this.authId, chainId, wallet);
13777
+ return await getUserWalletIdentities({
13778
+ authId: this.authId,
13779
+ chainId,
13780
+ walletAddr: wallet,
13781
+ apiKey: globalThis.globalEnvOption.apiKey
13782
+ });
13936
13783
  }
13937
13784
  /**
13938
13785
  * Retrieves the wallets associated with the current auth object.
@@ -13942,9 +13789,13 @@ var Auth = class {
13942
13789
  async getWallets(chainId) {
13943
13790
  await this.init();
13944
13791
  try {
13945
- return await getUserWalletsByAddr(await this.getAddress(), chainId);
13792
+ return await getUserWalletsByAddr({
13793
+ addr: await this.getAddress(),
13794
+ chainId,
13795
+ apiKey: globalThis.globalEnvOption.apiKey
13796
+ });
13946
13797
  } catch (err) {
13947
- if (err instanceof ResourceNotFoundError5) {
13798
+ if (err instanceof ResourceNotFoundError4) {
13948
13799
  return [];
13949
13800
  }
13950
13801
  throw err;
@@ -14214,7 +14065,7 @@ var createTargetSelectorMerkleTree = (params) => {
14214
14065
  };
14215
14066
  var createSessionKeyTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
14216
14067
  if (params.targetWhitelist.length === 0) {
14217
- throw new InvalidParameterError8(
14068
+ throw new InvalidParameterError7(
14218
14069
  ErrorCode8.MissingParameter,
14219
14070
  "targetWhitelist is required",
14220
14071
  "targetWhitelist is required",
@@ -14224,7 +14075,7 @@ var createSessionKeyTransactionParams = async (params, txOptions = globalThis.gl
14224
14075
  );
14225
14076
  }
14226
14077
  if (params.userId === void 0) {
14227
- throw new InvalidParameterError8(
14078
+ throw new InvalidParameterError7(
14228
14079
  ErrorCode8.MissingParameter,
14229
14080
  "userId is required",
14230
14081
  "userId is required",
@@ -14361,7 +14212,7 @@ import { isAddress as isAddress4, parseEther as parseEther2 } from "viem";
14361
14212
  import {
14362
14213
  ErrorCode as ErrorCode9,
14363
14214
  InternalFailureError as InternalFailureError4,
14364
- InvalidParameterError as InvalidParameterError9
14215
+ InvalidParameterError as InvalidParameterError8
14365
14216
  } from "@funkit/utils";
14366
14217
  var getWithdrawQueueInterface = () => {
14367
14218
  return new ContractInterface(WITHDRAW_QUEUE_ABI);
@@ -14379,7 +14230,7 @@ var stakeTransactionParams = async (params, txOptions = globalThis.globalEnvOpti
14379
14230
  };
14380
14231
  var requestUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
14381
14232
  if (!isAddress4(params.recipient ?? "")) {
14382
- throw new InvalidParameterError9(
14233
+ throw new InvalidParameterError8(
14383
14234
  ErrorCode9.InvalidParameter,
14384
14235
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
14385
14236
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
@@ -14393,7 +14244,7 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
14393
14244
  const steth = getSteth(chainId);
14394
14245
  const withdrawalQueue = getWithdrawalQueue(chainId);
14395
14246
  if (!steth || !withdrawalQueue || steth.length === 0 || withdrawalQueue.length === 0) {
14396
- throw new InvalidParameterError9(
14247
+ throw new InvalidParameterError8(
14397
14248
  ErrorCode9.ChainNotSupported,
14398
14249
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
14399
14250
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
@@ -14428,7 +14279,7 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
14428
14279
  };
14429
14280
  var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
14430
14281
  if (!isAddress4(params.recipient ?? "")) {
14431
- throw new InvalidParameterError9(
14282
+ throw new InvalidParameterError8(
14432
14283
  ErrorCode9.InvalidParameter,
14433
14284
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
14434
14285
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
@@ -14441,7 +14292,7 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
14441
14292
  const withdrawQueueAddress = getWithdrawalQueue(await chain.getChainId());
14442
14293
  const readyToWithdrawRequestIds = (await getReadyToWithdrawRequests(params, txOptions)).slice(0, 5);
14443
14294
  if (readyToWithdrawRequestIds.length === 0) {
14444
- throw new InvalidParameterError9(
14295
+ throw new InvalidParameterError8(
14445
14296
  ErrorCode9.InvalidParameter,
14446
14297
  "Not ready to withdraw requests",
14447
14298
  "Not ready to withdraw requests",
@@ -14480,7 +14331,7 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
14480
14331
  };
14481
14332
  var getReadyToWithdrawRequests = async (params, txOptions) => {
14482
14333
  if (!isAddress4(params.recipient ?? "")) {
14483
- throw new InvalidParameterError9(
14334
+ throw new InvalidParameterError8(
14484
14335
  ErrorCode9.InvalidParameter,
14485
14336
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
14486
14337
  "Recipient address is not a valid address, please make sure it is a valid checksum address.",
@@ -14525,7 +14376,7 @@ var getWithdrawalQueue = (chainId) => {
14525
14376
  case 36865:
14526
14377
  return "0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1";
14527
14378
  default:
14528
- throw new InvalidParameterError9(
14379
+ throw new InvalidParameterError8(
14529
14380
  ErrorCode9.ChainNotSupported,
14530
14381
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
14531
14382
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
@@ -14544,7 +14395,7 @@ var getSteth = (chainId) => {
14544
14395
  case 36865:
14545
14396
  return "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
14546
14397
  default:
14547
- throw new InvalidParameterError9(
14398
+ throw new InvalidParameterError8(
14548
14399
  ErrorCode9.ChainNotSupported,
14549
14400
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
14550
14401
  "Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
@@ -14557,7 +14408,7 @@ var getSteth = (chainId) => {
14557
14408
 
14558
14409
  // src/actions/Token.ts
14559
14410
  import { isAddress as isAddress5, parseEther as parseEther3 } from "viem";
14560
- import { ErrorCode as ErrorCode10, InvalidParameterError as InvalidParameterError10 } from "@funkit/utils";
14411
+ import { ErrorCode as ErrorCode10, InvalidParameterError as InvalidParameterError9 } from "@funkit/utils";
14561
14412
  var isERC721TransferParams = (obj) => {
14562
14413
  return "tokenId" in obj;
14563
14414
  };
@@ -14567,7 +14418,7 @@ var isTokenTransferParams = (obj) => {
14567
14418
  var erc721TransferTransactionParams = async (params) => {
14568
14419
  const { to, tokenId, collection, from } = params;
14569
14420
  if (!isAddress5(to ?? "") || !isAddress5(from ?? "")) {
14570
- throw new InvalidParameterError10(
14421
+ throw new InvalidParameterError9(
14571
14422
  ErrorCode10.InvalidParameter,
14572
14423
  "To/from address is not a valid address, please make sure it is a valid checksum address.",
14573
14424
  "To/from address is not a valid address, please make sure it is a valid checksum address.",
@@ -14586,7 +14437,7 @@ var erc721TransferTransactionParams = async (params) => {
14586
14437
  var tokenTransferTransactionParams = async (params, chain) => {
14587
14438
  const { to, amount, token } = params;
14588
14439
  if (!isAddress5(to)) {
14589
- throw new InvalidParameterError10(
14440
+ throw new InvalidParameterError9(
14590
14441
  ErrorCode10.InvalidParameter,
14591
14442
  "To address is not a valid address, please make sure it is a valid checksum address.",
14592
14443
  "To address is not a valid address, please make sure it is a valid checksum address.",
@@ -14605,7 +14456,7 @@ var tokenTransferTransactionParams = async (params, chain) => {
14605
14456
  }
14606
14457
  const tokenAddr = await tokenObj.getAddress();
14607
14458
  if (!tokenAddr) {
14608
- throw new InvalidParameterError10(
14459
+ throw new InvalidParameterError9(
14609
14460
  ErrorCode10.TokenNotFound,
14610
14461
  "Token address not found. Please check the token passed in.",
14611
14462
  "Token address not found. Please check the token passed in.",
@@ -14624,7 +14475,7 @@ var tokenTransferTransactionParams = async (params, chain) => {
14624
14475
  var tokenTransferFromTransactionParams = async (params, chain) => {
14625
14476
  const { to, amount, token, from } = params;
14626
14477
  if (!isAddress5(to ?? "") || !isAddress5(from ?? "")) {
14627
- throw new InvalidParameterError10(
14478
+ throw new InvalidParameterError9(
14628
14479
  ErrorCode10.InvalidParameter,
14629
14480
  "To/from address is not a valid address, please make sure it is a valid checksum address.",
14630
14481
  "To/from address is not a valid address, please make sure it is a valid checksum address.",
@@ -14643,7 +14494,7 @@ var tokenTransferFromTransactionParams = async (params, chain) => {
14643
14494
  }
14644
14495
  const tokenAddr = await tokenObj.getAddress();
14645
14496
  if (!tokenAddr) {
14646
- throw new InvalidParameterError10(
14497
+ throw new InvalidParameterError9(
14647
14498
  ErrorCode10.TokenNotFound,
14648
14499
  "Token address not found. Please check the token passed in.",
14649
14500
  "Token address not found. Please check the token passed in.",
@@ -14668,7 +14519,7 @@ var isERC721ApproveParams = (obj) => {
14668
14519
  var erc20ApproveTransactionParams = async (params) => {
14669
14520
  const { spender, amount, token } = params;
14670
14521
  if (!isAddress5(spender ?? "")) {
14671
- throw new InvalidParameterError10(
14522
+ throw new InvalidParameterError9(
14672
14523
  ErrorCode10.InvalidParameter,
14673
14524
  "Spender address is not a valid address, please make sure it is a valid checksum address.",
14674
14525
  "Spender address is not a valid address, please make sure it is a valid checksum address.",
@@ -14691,7 +14542,7 @@ var erc20ApproveTransactionParams = async (params) => {
14691
14542
  var erc721ApproveTransactionParams = async (params) => {
14692
14543
  const { spender, tokenId, collection } = params;
14693
14544
  if (!isAddress5(spender ?? "")) {
14694
- throw new InvalidParameterError10(
14545
+ throw new InvalidParameterError9(
14695
14546
  ErrorCode10.InvalidParameter,
14696
14547
  "Spender address is not a valid address, please make sure it is a valid checksum address.",
14697
14548
  "Spender address is not a valid address, please make sure it is a valid checksum address.",
@@ -14724,7 +14575,7 @@ var SocketSort = /* @__PURE__ */ ((SocketSort2) => {
14724
14575
  })(SocketSort || {});
14725
14576
 
14726
14577
  // src/config/Config.ts
14727
- import { ErrorCode as ErrorCode11, InvalidParameterError as InvalidParameterError11 } from "@funkit/utils";
14578
+ import { ErrorCode as ErrorCode11, InvalidParameterError as InvalidParameterError10 } from "@funkit/utils";
14728
14579
  function getEnvOptions() {
14729
14580
  return globalThis.globalEnvOption;
14730
14581
  }
@@ -14740,7 +14591,7 @@ async function configureEnvironment(option) {
14740
14591
  const globalEnvOption = global.globalEnvOption;
14741
14592
  globalEnvOption.apiKey = option.apiKey ? option.apiKey : globalEnvOption.apiKey;
14742
14593
  if (!globalEnvOption.apiKey) {
14743
- throw new InvalidParameterError11(
14594
+ throw new InvalidParameterError10(
14744
14595
  ErrorCode11.MissingParameter,
14745
14596
  "apiKey is required",
14746
14597
  "apiKey is required",
@@ -14986,7 +14837,7 @@ var CheckoutSponsor = class extends Sponsor {
14986
14837
  // src/sponsors/GaslessSponsor.ts
14987
14838
  import { concat as concat3 } from "viem";
14988
14839
  import { PaymasterType as PaymasterType3 } from "@funkit/api-base";
14989
- import { ErrorCode as ErrorCode12, ResourceNotFoundError as ResourceNotFoundError6 } from "@funkit/utils";
14840
+ import { ErrorCode as ErrorCode12, ResourceNotFoundError as ResourceNotFoundError5 } from "@funkit/utils";
14990
14841
  var GaslessSponsor = class extends Sponsor {
14991
14842
  constructor(options = globalThis.globalEnvOption) {
14992
14843
  super(
@@ -15002,7 +14853,7 @@ var GaslessSponsor = class extends Sponsor {
15002
14853
  if (GASLESS_SPONSOR_SUPPORT_CHAINS.includes(await chain.getChainId())) {
15003
14854
  this.sponsorAddress = await chain.getAddress("funGaslessSponsorAddress");
15004
14855
  } else {
15005
- throw new ResourceNotFoundError6(
14856
+ throw new ResourceNotFoundError5(
15006
14857
  ErrorCode12.MissingParameter,
15007
14858
  "The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
15008
14859
  "The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
@@ -15109,8 +14960,8 @@ import { concat as concat4, encodeAbiParameters as encodeAbiParameters4 } from "
15109
14960
  import { PaymasterType as PaymasterType4, addTransaction } from "@funkit/api-base";
15110
14961
  import {
15111
14962
  ErrorCode as ErrorCode13,
15112
- InvalidParameterError as InvalidParameterError12,
15113
- ResourceNotFoundError as ResourceNotFoundError7
14963
+ InvalidParameterError as InvalidParameterError11,
14964
+ ResourceNotFoundError as ResourceNotFoundError6
15114
14965
  } from "@funkit/utils";
15115
14966
  var TokenSponsor = class extends Sponsor {
15116
14967
  constructor(options = globalThis.globalEnvOption) {
@@ -15121,7 +14972,7 @@ var TokenSponsor = class extends Sponsor {
15121
14972
  PaymasterType4.TokenSponsor
15122
14973
  );
15123
14974
  if (!options.gasSponsor?.token) {
15124
- throw new InvalidParameterError12(
14975
+ throw new InvalidParameterError11(
15125
14976
  ErrorCode13.MissingParameter,
15126
14977
  "token field is missing",
15127
14978
  "token field is missing",
@@ -15138,7 +14989,7 @@ var TokenSponsor = class extends Sponsor {
15138
14989
  if (TOKEN_SPONSOR_SUPPORT_CHAINS.includes(await chain.getChainId())) {
15139
14990
  this.sponsorAddress = await chain.getAddress("funTokenSponsorAddress");
15140
14991
  } else {
15141
- throw new ResourceNotFoundError7(
14992
+ throw new ResourceNotFoundError6(
15142
14993
  ErrorCode13.MissingParameter,
15143
14994
  "The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
15144
14995
  "The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
@@ -15489,15 +15340,27 @@ var TokenSponsor = class extends Sponsor {
15489
15340
 
15490
15341
  // src/wallet/FunWallet.ts
15491
15342
  import {
15343
+ AuthType as AuthType2,
15344
+ OperationStatus,
15345
+ OperationType,
15492
15346
  addTransaction as addTransaction2,
15347
+ addUserToWallet,
15493
15348
  checkWalletAccessInitialization,
15349
+ createOp,
15350
+ deleteOp,
15351
+ executeOp,
15494
15352
  getAllWalletNFTs,
15495
15353
  getAllWalletNFTsByChainId,
15496
15354
  getAllWalletTokens,
15497
15355
  getAllWalletTokensByChainId,
15356
+ getFullReceipt,
15498
15357
  getGroups,
15358
+ getOps,
15359
+ getOpsOfWallet,
15499
15360
  getWalletLidoWithdrawalsByChainId,
15500
- initializeWalletAccess
15361
+ initializeWalletAccess,
15362
+ scheduleOp,
15363
+ signOp
15501
15364
  } from "@funkit/api-base";
15502
15365
  import {
15503
15366
  http as http3,
@@ -15513,15 +15376,15 @@ import {
15513
15376
  import {
15514
15377
  ErrorCode as ErrorCode15,
15515
15378
  InternalFailureError as InternalFailureError5,
15516
- InvalidParameterError as InvalidParameterError14
15379
+ InvalidParameterError as InvalidParameterError13
15517
15380
  } from "@funkit/utils";
15518
15381
 
15519
15382
  // src/actions/FirstClassActions.ts
15520
15383
  import { pad as pad8 } from "viem";
15521
15384
  import {
15522
15385
  ErrorCode as ErrorCode14,
15523
- InvalidParameterError as InvalidParameterError13,
15524
- ResourceNotFoundError as ResourceNotFoundError8
15386
+ InvalidParameterError as InvalidParameterError12,
15387
+ ResourceNotFoundError as ResourceNotFoundError7
15525
15388
  } from "@funkit/utils";
15526
15389
 
15527
15390
  // src/utils/GroupUtils.ts
@@ -15596,7 +15459,7 @@ var FirstClassActions = class {
15596
15459
  );
15597
15460
  }
15598
15461
  } else {
15599
- throw new InvalidParameterError13(
15462
+ throw new InvalidParameterError12(
15600
15463
  ErrorCode14.InvalidParameter,
15601
15464
  "Params were missing or incorrect",
15602
15465
  "Params were missing or incorrect",
@@ -15628,7 +15491,7 @@ var FirstClassActions = class {
15628
15491
  } else if (isERC721ApproveParams(params)) {
15629
15492
  transactionParams = await erc721ApproveTransactionParams(params);
15630
15493
  } else {
15631
- throw new InvalidParameterError13(
15494
+ throw new InvalidParameterError12(
15632
15495
  ErrorCode14.InvalidParameter,
15633
15496
  "Params were missing or incorrect",
15634
15497
  "Params were missing or incorrect",
@@ -15684,7 +15547,7 @@ var FirstClassActions = class {
15684
15547
  txOptions
15685
15548
  );
15686
15549
  } else {
15687
- throw new InvalidParameterError13(
15550
+ throw new InvalidParameterError12(
15688
15551
  ErrorCode14.InvalidParameter,
15689
15552
  "Params were missing or incorrect",
15690
15553
  "Params were missing or incorrect",
@@ -15774,7 +15637,7 @@ var FirstClassActions = class {
15774
15637
  await this.getAddress()
15775
15638
  );
15776
15639
  if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
15777
- throw new ResourceNotFoundError8(
15640
+ throw new ResourceNotFoundError7(
15778
15641
  ErrorCode14.GroupNotFound,
15779
15642
  "group is not found",
15780
15643
  "group is not found",
@@ -15787,7 +15650,7 @@ var FirstClassActions = class {
15787
15650
  const members = new Set(onChainGroupData.memberIds);
15788
15651
  members.add(params.userId);
15789
15652
  if (members.size <= originalMembers.size) {
15790
- throw new InvalidParameterError13(
15653
+ throw new InvalidParameterError12(
15791
15654
  ErrorCode14.UserAlreadyExists,
15792
15655
  "user already exists in group",
15793
15656
  "user already exists in group",
@@ -15824,7 +15687,7 @@ var FirstClassActions = class {
15824
15687
  await this.getAddress()
15825
15688
  );
15826
15689
  if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
15827
- throw new ResourceNotFoundError8(
15690
+ throw new ResourceNotFoundError7(
15828
15691
  ErrorCode14.GroupNotFound,
15829
15692
  "group is not found",
15830
15693
  "group is not found",
@@ -15837,7 +15700,7 @@ var FirstClassActions = class {
15837
15700
  const members = new Set(onChainGroupData.memberIds);
15838
15701
  members.delete(params.userId);
15839
15702
  if (members.size >= originalMembers.size) {
15840
- throw new ResourceNotFoundError8(
15703
+ throw new ResourceNotFoundError7(
15841
15704
  ErrorCode14.UserNotFound,
15842
15705
  "user does not exist in group",
15843
15706
  "user does not exist in group",
@@ -15873,7 +15736,7 @@ var FirstClassActions = class {
15873
15736
  await this.getAddress()
15874
15737
  );
15875
15738
  if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
15876
- throw new ResourceNotFoundError8(
15739
+ throw new ResourceNotFoundError7(
15877
15740
  ErrorCode14.GroupNotFound,
15878
15741
  "group is not found",
15879
15742
  "group is not found",
@@ -15883,7 +15746,7 @@ var FirstClassActions = class {
15883
15746
  );
15884
15747
  }
15885
15748
  if (!Number.isInteger(params.threshold) || params.threshold < 1 || params.threshold > onChainGroupData.memberIds.length) {
15886
- throw new InvalidParameterError13(
15749
+ throw new InvalidParameterError12(
15887
15750
  ErrorCode14.InvalidThreshold,
15888
15751
  "threshold can not be 0 or bigger than number of members in the group",
15889
15752
  "threshold can not be 0 or bigger than number of members in the group",
@@ -15944,7 +15807,7 @@ var FunWallet = class extends FirstClassActions {
15944
15807
  if (isAddress6(params)) {
15945
15808
  this.address = params;
15946
15809
  } else {
15947
- throw new InvalidParameterError14(
15810
+ throw new InvalidParameterError13(
15948
15811
  ErrorCode15.InvalidParameter,
15949
15812
  "string input must be an address type",
15950
15813
  "string input must be an address type",
@@ -15956,7 +15819,7 @@ var FunWallet = class extends FirstClassActions {
15956
15819
  } else {
15957
15820
  const { users, uniqueId } = params;
15958
15821
  if (!uniqueId || !isBytes32(uniqueId) || !users || users.length <= 0) {
15959
- throw new InvalidParameterError14(
15822
+ throw new InvalidParameterError13(
15960
15823
  ErrorCode15.InvalidParameter,
15961
15824
  "uniqueId must be bytes32 and users must be non-empty",
15962
15825
  "uniqueId must be bytes32 and users must be non-empty",
@@ -15968,7 +15831,7 @@ var FunWallet = class extends FirstClassActions {
15968
15831
  this.userInfo = new Map(
15969
15832
  users?.map((user) => {
15970
15833
  if (!user.userId || !isHex3(user.userId)) {
15971
- throw new InvalidParameterError14(
15834
+ throw new InvalidParameterError13(
15972
15835
  ErrorCode15.InvalidParameter,
15973
15836
  "userId is required and must be a hex string",
15974
15837
  "userId is required and must be a hex string",
@@ -15978,7 +15841,7 @@ var FunWallet = class extends FirstClassActions {
15978
15841
  );
15979
15842
  }
15980
15843
  if (user.groupInfo && (!Number.isInteger(user.groupInfo.threshold) || !Array.isArray(user.groupInfo.memberIds) || !user.groupInfo.memberIds.every((memberId) => isHex3(memberId)))) {
15981
- throw new InvalidParameterError14(
15844
+ throw new InvalidParameterError13(
15982
15845
  ErrorCode15.InvalidParameter,
15983
15846
  "groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
15984
15847
  "groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
@@ -16153,25 +16016,30 @@ var FunWallet = class extends FirstClassActions {
16153
16016
  * Retrieves a list of operations associated with the wallet.
16154
16017
  * @param {OperationStatus} status - The status of operations to retrieve (default: OperationStatus.ALL).
16155
16018
  * @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
16156
- * @returns {Promise<Operation[]>} A list of operations.
16019
+ * @returns {Promise<OperationData[]>} A list of operations.
16157
16020
  */
16158
- async getOperations(status = "" /* ALL */, txOptions = globalThis.globalEnvOption) {
16021
+ async getOperations(status = OperationStatus.ALL, txOptions = globalThis.globalEnvOption) {
16159
16022
  const chain = await Chain.getChain({ chainIdentifier: txOptions.chain });
16160
- return await getOpsOfWallet(
16161
- await this.getAddress(txOptions),
16162
- await chain.getChainId(),
16163
- status
16164
- );
16023
+ return await getOpsOfWallet({
16024
+ walletAddr: await this.getAddress(txOptions),
16025
+ chainId: await chain.getChainId(),
16026
+ status,
16027
+ apiKey: globalThis.globalEnvOption.apiKey
16028
+ });
16165
16029
  }
16166
16030
  /**
16167
16031
  * Retrieves a specific operation by its ID.
16168
16032
  * @param {Hex} opId - The ID of the operation to retrieve.
16169
16033
  * @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
16170
- * @returns {Promise<Operation>} The requested operation.
16034
+ * @returns {Promise<OperationData>} The requested operation.
16171
16035
  */
16172
16036
  async getOperation(opId, txOptions = globalThis.globalEnvOption) {
16173
16037
  const chain = await Chain.getChain({ chainIdentifier: txOptions.chain });
16174
- return (await getOps([opId], await chain.getChainId()))[0];
16038
+ return (await getOps({
16039
+ opIds: [opId],
16040
+ chainId: await chain.getChainId(),
16041
+ apiKey: globalThis.globalEnvOption.apiKey
16042
+ }))[0];
16175
16043
  }
16176
16044
  /**
16177
16045
  * Retrieves a list of users associated with the wallet and their potential corresponding group information.
@@ -16269,13 +16137,14 @@ var FunWallet = class extends FirstClassActions {
16269
16137
  apiKey: globalThis.globalEnvOption.apiKey
16270
16138
  });
16271
16139
  }
16272
- await addUserToWallet(
16273
- await auth.getAddress(),
16274
- await chain.getChainId(),
16140
+ await addUserToWallet({
16141
+ authId: await auth.getAddress(),
16142
+ chainId: await chain.getChainId(),
16275
16143
  walletAddr,
16276
- [userId],
16277
- this.walletUniqueId
16278
- );
16144
+ userIds: [userId],
16145
+ walletUniqueId: this.walletUniqueId,
16146
+ apiKey: globalThis.globalEnvOption.apiKey
16147
+ });
16279
16148
  }
16280
16149
  }
16281
16150
  /**
@@ -16288,7 +16157,7 @@ var FunWallet = class extends FirstClassActions {
16288
16157
  */
16289
16158
  async createOperation(auth, userId, transactionParams, txOptions = globalThis.globalEnvOption) {
16290
16159
  if (!userId || userId === "") {
16291
- throw new InvalidParameterError14(
16160
+ throw new InvalidParameterError13(
16292
16161
  ErrorCode15.MissingParameter,
16293
16162
  "userId is required",
16294
16163
  "userId is required",
@@ -16340,8 +16209,8 @@ var FunWallet = class extends FirstClassActions {
16340
16209
  const isGroupOp = await auth.getUserId() !== normalizedUserId;
16341
16210
  const operation = new Operation(partialOp, {
16342
16211
  chainId: await chain.getChainId(),
16343
- opType: isGroupOp ? "GROUP_OPERATION" /* GROUP_OPERATION */ : "SINGLE_OPERATION" /* SINGLE_OPERATION */,
16344
- authType: isGroupOp ? 1 /* MULTI_SIG */ : 0 /* ECDSA */,
16212
+ opType: isGroupOp ? OperationType.GROUP_OPERATION : OperationType.SINGLE_OPERATION,
16213
+ authType: isGroupOp ? AuthType2.MULTI_SIG : AuthType2.ECDSA,
16345
16214
  walletAddr: await this.getAddress(txOptions),
16346
16215
  proposer: await auth.getAddress()
16347
16216
  });
@@ -16385,7 +16254,10 @@ var FunWallet = class extends FirstClassActions {
16385
16254
  isGroupOperation(operation)
16386
16255
  );
16387
16256
  if (txOptions.skipDBAction !== true) {
16388
- const opId = await createOp(estimatedOperation);
16257
+ const opId = await createOp({
16258
+ op: estimatedOperation,
16259
+ apiKey: globalThis.globalEnvOption.apiKey
16260
+ });
16389
16261
  estimatedOperation.opId = opId;
16390
16262
  if (!await checkWalletAccessInitialization({
16391
16263
  walletAddr: sender,
@@ -16416,13 +16288,14 @@ var FunWallet = class extends FirstClassActions {
16416
16288
  isGroupOperation(finalOperation)
16417
16289
  );
16418
16290
  if (isGroupOperation(finalOperation) && txOptions.skipDBAction !== true) {
16419
- await signOp(
16420
- finalOperation.opId,
16421
- await chain.getChainId(),
16422
- finalOperation.userOp.signature,
16423
- await auth.getAddress(),
16424
- this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold
16425
- );
16291
+ await signOp({
16292
+ opId: finalOperation.opId,
16293
+ chainId: await chain.getChainId(),
16294
+ signature: finalOperation.userOp.signature,
16295
+ signedBy: await auth.getAddress(),
16296
+ threshold: this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold,
16297
+ apiKey: globalThis.globalEnvOption.apiKey
16298
+ });
16426
16299
  }
16427
16300
  return finalOperation;
16428
16301
  }
@@ -16470,7 +16343,11 @@ var FunWallet = class extends FirstClassActions {
16470
16343
  }
16471
16344
  } else {
16472
16345
  if (finalTxOptions.skipDBAction !== true) {
16473
- const storedOps = await getOps([finalOperation.opId], chainId);
16346
+ const storedOps = await getOps({
16347
+ opIds: [finalOperation.opId],
16348
+ chainId,
16349
+ apiKey: globalThis.globalEnvOption.apiKey
16350
+ });
16474
16351
  let collectedSigCount;
16475
16352
  if (isSignatureMissing(await auth.getUserId(), storedOps[0]?.signatures)) {
16476
16353
  collectedSigCount = storedOps[0]?.signatures?.length ? storedOps[0]?.signatures?.length + 1 : 1;
@@ -16485,7 +16362,7 @@ var FunWallet = class extends FirstClassActions {
16485
16362
  collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
16486
16363
  }
16487
16364
  if (collectedSigCount < threshold) {
16488
- throw new InvalidParameterError14(
16365
+ throw new InvalidParameterError13(
16489
16366
  ErrorCode15.InsufficientSignatures,
16490
16367
  "Signatures are not sufficient to execute the operation",
16491
16368
  "Signatures are not sufficient to execute the operation",
@@ -16495,7 +16372,7 @@ var FunWallet = class extends FirstClassActions {
16495
16372
  );
16496
16373
  }
16497
16374
  } else {
16498
- throw new InvalidParameterError14(
16375
+ throw new InvalidParameterError13(
16499
16376
  ErrorCode15.InsufficientSignatures,
16500
16377
  "Signatures are not sufficient to execute the operation",
16501
16378
  "Signatures are not sufficient to execute the operation",
@@ -16508,36 +16385,44 @@ var FunWallet = class extends FirstClassActions {
16508
16385
  let receipt;
16509
16386
  if (isGroupOperation(finalOperation)) {
16510
16387
  receipt = await executeOp({
16511
- opId: finalOperation.opId,
16512
- chainId,
16513
- executedBy: await auth.getAddress(),
16514
- entryPointAddress: await chain.getAddress("entryPointAddress"),
16515
- signature: finalOperation.userOp.signature,
16516
- groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
16388
+ input: {
16389
+ opId: finalOperation.opId,
16390
+ chainId,
16391
+ executedBy: await auth.getAddress(),
16392
+ entryPointAddress: await chain.getAddress("entryPointAddress"),
16393
+ signature: finalOperation.userOp.signature,
16394
+ groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
16395
+ },
16396
+ apiKey: globalThis.globalEnvOption.apiKey
16517
16397
  });
16518
16398
  } else {
16519
16399
  receipt = await executeOp({
16520
- opId: finalOperation.opId,
16521
- chainId,
16522
- executedBy: await auth.getAddress(),
16523
- entryPointAddress: await chain.getAddress("entryPointAddress"),
16524
- signature: finalOperation.userOp.signature,
16525
- userOp: finalOperation.userOp
16400
+ input: {
16401
+ opId: finalOperation.opId,
16402
+ chainId,
16403
+ executedBy: await auth.getAddress(),
16404
+ entryPointAddress: await chain.getAddress("entryPointAddress"),
16405
+ signature: finalOperation.userOp.signature,
16406
+ userOp: finalOperation.userOp
16407
+ },
16408
+ apiKey: globalThis.globalEnvOption.apiKey
16526
16409
  });
16527
16410
  }
16528
- receipt = await getFullReceipt(
16529
- finalOperation.opId,
16411
+ receipt = await getFullReceipt({
16412
+ opId: finalOperation.opId,
16530
16413
  chainId,
16531
- receipt.userOpHash
16532
- );
16414
+ userOpHash: receipt.userOpHash,
16415
+ apiKey: globalThis.globalEnvOption.apiKey
16416
+ });
16533
16417
  if (isWalletInitOp(finalOperation.userOp) && finalTxOptions.skipDBAction !== true) {
16534
- await addUserToWallet(
16535
- await auth.getAddress(),
16418
+ await addUserToWallet({
16419
+ authId: await auth.getAddress(),
16536
16420
  chainId,
16537
- await this.getAddress(finalTxOptions),
16538
- Array.from(this.userInfo.keys()),
16539
- this.walletUniqueId
16540
- );
16421
+ walletAddr: await this.getAddress(finalTxOptions),
16422
+ userIds: Array.from(this.userInfo.keys()),
16423
+ walletUniqueId: this.walletUniqueId,
16424
+ apiKey: globalThis.globalEnvOption.apiKey
16425
+ });
16541
16426
  if (finalTxOptions?.gasSponsor?.sponsorAddress) {
16542
16427
  const paymasterType = getPaymasterType(finalTxOptions);
16543
16428
  addTransaction2({
@@ -16603,7 +16488,11 @@ var FunWallet = class extends FirstClassActions {
16603
16488
  }
16604
16489
  } else {
16605
16490
  if (finalTxOptions.skipDBAction !== true) {
16606
- const storedOps = await getOps([finalOperation.opId], chainId);
16491
+ const storedOps = await getOps({
16492
+ opIds: [finalOperation.opId],
16493
+ chainId,
16494
+ apiKey: globalThis.globalEnvOption.apiKey
16495
+ });
16607
16496
  let collectedSigCount;
16608
16497
  if (isSignatureMissing(await auth.getUserId(), storedOps[0]?.signatures)) {
16609
16498
  collectedSigCount = storedOps[0]?.signatures?.length ? storedOps[0]?.signatures?.length + 1 : 1;
@@ -16618,7 +16507,7 @@ var FunWallet = class extends FirstClassActions {
16618
16507
  collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
16619
16508
  }
16620
16509
  if (collectedSigCount < threshold) {
16621
- throw new InvalidParameterError14(
16510
+ throw new InvalidParameterError13(
16622
16511
  ErrorCode15.InsufficientSignatures,
16623
16512
  "Signatures are not sufficient to execute the operation",
16624
16513
  "Signatures are not sufficient to execute the operation",
@@ -16628,7 +16517,7 @@ var FunWallet = class extends FirstClassActions {
16628
16517
  );
16629
16518
  }
16630
16519
  } else {
16631
- throw new InvalidParameterError14(
16520
+ throw new InvalidParameterError13(
16632
16521
  ErrorCode15.InsufficientSignatures,
16633
16522
  "Signatures are not sufficient to execute the operation",
16634
16523
  "Signatures are not sufficient to execute the operation",
@@ -16640,21 +16529,27 @@ var FunWallet = class extends FirstClassActions {
16640
16529
  }
16641
16530
  if (isGroupOperation(finalOperation)) {
16642
16531
  await scheduleOp({
16643
- opId: finalOperation.opId,
16644
- chainId,
16645
- scheduledBy: await auth.getAddress(),
16646
- entryPointAddress: await chain.getAddress("entryPointAddress"),
16647
- signature: finalOperation.userOp.signature,
16648
- groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
16532
+ input: {
16533
+ opId: finalOperation.opId,
16534
+ chainId,
16535
+ scheduledBy: await auth.getAddress(),
16536
+ entryPointAddress: await chain.getAddress("entryPointAddress"),
16537
+ signature: finalOperation.userOp.signature,
16538
+ groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
16539
+ },
16540
+ apiKey: globalThis.globalEnvOption.apiKey
16649
16541
  });
16650
16542
  } else {
16651
16543
  await scheduleOp({
16652
- opId: finalOperation.opId,
16653
- chainId,
16654
- scheduledBy: await auth.getAddress(),
16655
- entryPointAddress: await chain.getAddress("entryPointAddress"),
16656
- signature: finalOperation.userOp.signature,
16657
- userOp: finalOperation.userOp
16544
+ input: {
16545
+ opId: finalOperation.opId,
16546
+ chainId,
16547
+ scheduledBy: await auth.getAddress(),
16548
+ entryPointAddress: await chain.getAddress("entryPointAddress"),
16549
+ signature: finalOperation.userOp.signature,
16550
+ userOp: finalOperation.userOp
16551
+ },
16552
+ apiKey: globalThis.globalEnvOption.apiKey
16658
16553
  });
16659
16554
  }
16660
16555
  if (!finalOperation.opId) {
@@ -16678,7 +16573,11 @@ var FunWallet = class extends FirstClassActions {
16678
16573
  */
16679
16574
  async removeOperation(_, operationId, txOptions = globalThis.globalEnvOption) {
16680
16575
  const chain = await Chain.getChain({ chainIdentifier: txOptions.chain });
16681
- await deleteOp(operationId, await chain.getChainId());
16576
+ await deleteOp({
16577
+ opId: operationId,
16578
+ chainId: await chain.getChainId(),
16579
+ apiKey: globalThis.globalEnvOption.apiKey
16580
+ });
16682
16581
  }
16683
16582
  /**
16684
16583
  * Creates and prepares a rejection operation for an existing operation.
@@ -16702,8 +16601,11 @@ var FunWallet = class extends FirstClassActions {
16702
16601
  );
16703
16602
  if (rejectionMessage) rejectOperation.message = rejectionMessage;
16704
16603
  rejectOperation.relatedOpIds = [operation.opId];
16705
- rejectOperation.opType = "REJECTION" /* REJECTION */;
16706
- rejectOperation.opId = await createOp(rejectOperation);
16604
+ rejectOperation.opType = OperationType.REJECTION;
16605
+ rejectOperation.opId = await createOp({
16606
+ op: rejectOperation,
16607
+ apiKey: globalThis.globalEnvOption.apiKey
16608
+ });
16707
16609
  return rejectOperation;
16708
16610
  }
16709
16611
  /**
@@ -16798,7 +16700,7 @@ var FunWallet = class extends FirstClassActions {
16798
16700
  options.fee.token = options.gasSponsor.token;
16799
16701
  }
16800
16702
  if (!options.fee.token) {
16801
- throw new InvalidParameterError14(
16703
+ throw new InvalidParameterError13(
16802
16704
  ErrorCode15.MissingParameter,
16803
16705
  "EnvOption.fee.token or EnvOption.gasSponsor.token is required",
16804
16706
  "EnvOption.fee.token or EnvOption.gasSponsor.token is required",
@@ -16808,7 +16710,7 @@ var FunWallet = class extends FirstClassActions {
16808
16710
  );
16809
16711
  }
16810
16712
  if (!options.fee.recipient) {
16811
- throw new InvalidParameterError14(
16713
+ throw new InvalidParameterError13(
16812
16714
  ErrorCode15.MissingParameter,
16813
16715
  "EnvOption.fee.recipient is required",
16814
16716
  "EnvOption.fee.recipient is required",
@@ -16820,7 +16722,7 @@ var FunWallet = class extends FirstClassActions {
16820
16722
  const chain = await Chain.getChain({ chainIdentifier: options.chain });
16821
16723
  const token = new Token(options.fee.token, chain);
16822
16724
  if (options.fee.gasPercent && !token.isNative) {
16823
- throw new InvalidParameterError14(
16725
+ throw new InvalidParameterError13(
16824
16726
  ErrorCode15.InvalidParameterCombination,
16825
16727
  "GasPercent is only valid for native tokens",
16826
16728
  "GasPercent is only valid for native tokens",
@@ -16855,7 +16757,7 @@ var FunWallet = class extends FirstClassActions {
16855
16757
  Number(gasUsed) * options.fee.gasPercent / 100
16856
16758
  );
16857
16759
  } else {
16858
- throw new InvalidParameterError14(
16760
+ throw new InvalidParameterError13(
16859
16761
  ErrorCode15.MissingParameter,
16860
16762
  "EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
16861
16763
  "EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
@@ -16885,13 +16787,11 @@ var FunWallet = class extends FirstClassActions {
16885
16787
  }
16886
16788
  };
16887
16789
  export {
16888
- API_URL,
16889
16790
  APPROVE_AND_EXEC_ABI,
16890
16791
  APPROVE_AND_EXEC_CONTRACT_INTERFACE,
16891
16792
  APPROVE_AND_SWAP_ABI,
16892
16793
  AddressZero,
16893
16794
  Auth,
16894
- AuthType,
16895
16795
  BASE_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
16896
16796
  BASE_WRAP_TOKEN_ADDR,
16897
16797
  BYTES32_LENGTH,
@@ -16930,12 +16830,9 @@ export {
16930
16830
  GaslessSponsor,
16931
16831
  HashZero,
16932
16832
  InvalidActionError,
16933
- LOCAL_API_URL,
16934
16833
  NFT,
16935
16834
  OPTIMISM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
16936
16835
  Operation,
16937
- OperationStatus,
16938
- OperationType,
16939
16836
  RBAC_CONTRACT_INTERFACE,
16940
16837
  ROLE_BASED_ACCESS_CONTROL_ABI,
16941
16838
  STABLECOIN_SYMBOLS,
@@ -16957,7 +16854,6 @@ export {
16957
16854
  WALLET_CONTRACT_INTERFACE,
16958
16855
  WITHDRAW_QUEUE_ABI,
16959
16856
  addOwnerTxParams,
16960
- addUserToWallet,
16961
16857
  addresstoBytes32,
16962
16858
  calcPreVerificationGas,
16963
16859
  configureEnvironment,
@@ -16966,13 +16862,10 @@ export {
16966
16862
  createExecuteBatchTxParams,
16967
16863
  createFeeRecipientAndTokenMerkleTree,
16968
16864
  createGroupTxParams,
16969
- createOp,
16970
16865
  createSessionKeyTransactionParams,
16971
16866
  createSessionUser,
16972
16867
  createTargetSelectorMerkleTree,
16973
- createUser,
16974
16868
  decodeCalldata,
16975
- deleteOp,
16976
16869
  dydxChain,
16977
16870
  encodeLoginData,
16978
16871
  encodeUserAuthInitData,
@@ -16980,8 +16873,6 @@ export {
16980
16873
  erc20ApproveTransactionParams,
16981
16874
  erc721ApproveTransactionParams,
16982
16875
  erc721TransferTransactionParams,
16983
- estimateOp,
16984
- executeOp,
16985
16876
  finishUnstakeTransactionParams,
16986
16877
  fundWallet,
16987
16878
  gasCalculation,
@@ -16996,29 +16887,15 @@ export {
16996
16887
  generateRoleId,
16997
16888
  generateRuleId,
16998
16889
  getAuthUniqueId,
16999
- getChainFromId,
17000
- getChainFromName,
17001
16890
  getEnvOptions,
17002
- getFullReceipt,
17003
- getGasPrice,
17004
16891
  getGasStation,
17005
- getModuleInfo,
17006
16892
  getOpHash,
17007
- getOps,
17008
- getOpsOfGroup,
17009
- getOpsOfWallet,
17010
- getPaymasterAddress,
17011
16893
  getPaymasterType,
17012
16894
  getPermitHash,
17013
16895
  getPromiseFromOp,
17014
16896
  getSelectorFromCall,
17015
16897
  getTargetFromCall,
17016
- getTokenInfo,
17017
- getUserAddr,
17018
- getUserAuthIdByAddr,
17019
- getUserUniqueId,
17020
- getUserWalletIdentities,
17021
- getUserWalletsByAddr,
16898
+ getTokenAddressBySymbolAndChainId,
17022
16899
  getWalletAddress,
17023
16900
  getWalletPermitNonce,
17024
16901
  isAddress,
@@ -17040,13 +16917,11 @@ export {
17040
16917
  removeOwnerTxParams,
17041
16918
  requestUnstakeTransactionParams,
17042
16919
  roundToNearestBottomTenth,
17043
- scheduleOp,
17044
16920
  sendDeleteRequest,
17045
16921
  sendGetRequest,
17046
16922
  sendPostRequest,
17047
16923
  sendPutRequest,
17048
16924
  sendRequest,
17049
- signOp,
17050
16925
  stakeTransactionParams,
17051
16926
  stringify,
17052
16927
  toBytes32Arr,