@funkit/core 2.3.10 → 2.3.12

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
@@ -11767,7 +11767,12 @@ var getPaymasterType = (txOptions) => {
11767
11767
  };
11768
11768
 
11769
11769
  // src/utils/UserOpUtils.ts
11770
- import { encodeAbiParameters as encodeAbiParameters2, keccak256 as keccak2562, toBytes as toBytes2, toHex as toHex2 } from "viem";
11770
+ import {
11771
+ encodeAbiParameters as encodeAbiParameters2,
11772
+ keccak256 as keccak2562,
11773
+ toBytes as toBytes2,
11774
+ toHex as toHex2
11775
+ } from "viem";
11771
11776
  var calcPreVerificationGas = (userOp) => {
11772
11777
  const ov = DefaultGasOverheads;
11773
11778
  const p = Object.assign(
@@ -12023,7 +12028,7 @@ var Chain = class _Chain {
12023
12028
  this.rpcUrl = chainInput.rpcUrl;
12024
12029
  } else if (chainInput.chainIdentifier instanceof _Chain) {
12025
12030
  return chainInput.chainIdentifier;
12026
- } else if (typeof chainInput.chainIdentifier === "number" || Number(chainInput.chainIdentifier)) {
12031
+ } else if (chainInput.chainIdentifier !== void 0 && (typeof chainInput.chainIdentifier === "number" || Number(chainInput.chainIdentifier))) {
12027
12032
  this.id = chainInput.chainIdentifier.toString();
12028
12033
  } else {
12029
12034
  this.name = chainInput.chainIdentifier;
@@ -12103,15 +12108,15 @@ var Chain = class _Chain {
12103
12108
  }
12104
12109
  async getChainId(options) {
12105
12110
  await this.init(options);
12106
- return this.id;
12111
+ return this.id ?? "";
12107
12112
  }
12108
12113
  async getChainName(options) {
12109
12114
  await this.init(options);
12110
- return this.name;
12115
+ return this.name ?? "";
12111
12116
  }
12112
12117
  async getRpcUrl(options) {
12113
12118
  await this.init(options);
12114
- return this.rpcUrl;
12119
+ return this.rpcUrl ?? "";
12115
12120
  }
12116
12121
  async getAddress(name, options) {
12117
12122
  await this.init(options);
@@ -12130,7 +12135,7 @@ var Chain = class _Chain {
12130
12135
  }
12131
12136
  async getCurrency(options) {
12132
12137
  await this.init(options);
12133
- return this.currency;
12138
+ return this.currency ?? "";
12134
12139
  }
12135
12140
  async getClient(options) {
12136
12141
  await this.init(options);
@@ -12141,7 +12146,7 @@ var Chain = class _Chain {
12141
12146
  let result;
12142
12147
  try {
12143
12148
  result = await getUserOpGasPrice({
12144
- chainId: this.id,
12149
+ chainId: this.id ?? "",
12145
12150
  apiKey: globalThis.globalEnvOption.apiKey,
12146
12151
  logger: options?.logger,
12147
12152
  signal: options?.signal
@@ -12177,7 +12182,7 @@ var Chain = class _Chain {
12177
12182
  }
12178
12183
  let { preVerificationGas, callGasLimit, verificationGasLimit } = await estimateOp({
12179
12184
  input: {
12180
- chainId: this.id,
12185
+ chainId: this.id ?? "",
12181
12186
  entryPointAddress: this.addresses.entryPointAddress,
12182
12187
  userOp: estimationUserOp
12183
12188
  },
@@ -12491,7 +12496,7 @@ var Operation = class _Operation {
12491
12496
  maxPriorityFeePerGas: 0n,
12492
12497
  preVerificationGas: 0n,
12493
12498
  callGasLimit: 0n,
12494
- verificationGasLimit: BigInt(1e7)
12499
+ verificationGasLimit: BigInt(DEFAULT_USEROP_GAS_LIMIT)
12495
12500
  },
12496
12501
  options
12497
12502
  );
@@ -12572,11 +12577,11 @@ function encodeWalletSignature(data) {
12572
12577
  function encodeUserAuthInitData(groupUsers) {
12573
12578
  const groupIds = groupUsers.map((user) => user.userId);
12574
12579
  const groupInfos = groupUsers.map((user) => {
12575
- const paddedMemberIds = user.groupInfo.memberIds.map(
12580
+ const paddedMemberIds = user.groupInfo?.memberIds.map(
12576
12581
  (memberId) => pad3(memberId, { size: 32 })
12577
- );
12582
+ ) ?? [];
12578
12583
  const sortedMemberIds = paddedMemberIds.sort((a, b) => a > b ? -1 : 1);
12579
- return [sortedMemberIds, user.groupInfo.threshold];
12584
+ return [sortedMemberIds, user.groupInfo?.threshold ?? 0];
12580
12585
  });
12581
12586
  return defaultAbiCoder.encode(
12582
12587
  ["bytes32[]", "tuple(bytes32[],uint256)[]"],
@@ -13007,6 +13012,7 @@ var BASE_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0xa880eae8900eb59bf7dad9bdb741
13007
13012
  var OPTIMISM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0x4Df91e173A6CdC74EfeF6fC72bb5Df1E8A8d758200000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
13008
13013
  var ETHEREUM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0x67F21bE69A16c314a0b7Da537309b2f3ADdDE03100000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
13009
13014
  var STABLECOIN_SYMBOLS = ["USDC", "USDC.e", "USDT", "DAI"];
13015
+ var DEFAULT_USEROP_GAS_LIMIT = 15e5;
13010
13016
 
13011
13017
  // src/utils/TypeUtils.ts
13012
13018
  import { isHex } from "viem";
@@ -13240,7 +13246,7 @@ var Auth = class {
13240
13246
  async getWalletUniqueId(index = 0, skipDBActions = false, options) {
13241
13247
  await this.init();
13242
13248
  const authUniqueId = await getAuthUniqueId(
13243
- this.authId,
13249
+ this.authId ?? "",
13244
13250
  await this.getAddress(),
13245
13251
  skipDBActions,
13246
13252
  options
@@ -13272,6 +13278,16 @@ var Auth = class {
13272
13278
  "https://docs.fun.xyz"
13273
13279
  );
13274
13280
  }
13281
+ if (!this.signer) {
13282
+ throw new InvalidParameterError6(
13283
+ ErrorCode6.MissingParameter,
13284
+ "signer is missing or incorrect",
13285
+ "signer is missing or incorrect",
13286
+ { options, signer: this.signer },
13287
+ "Provide proper chain information from options field",
13288
+ "https://docs.fun.xyz"
13289
+ );
13290
+ }
13275
13291
  const client = await chain.getClient(options);
13276
13292
  const txClient = this.client ?? createWalletClient2({
13277
13293
  account: this.signer,
@@ -13301,6 +13317,16 @@ var Auth = class {
13301
13317
  } else {
13302
13318
  tx = { to, value: BigInt(value), data };
13303
13319
  }
13320
+ if (!this.account) {
13321
+ throw new InvalidParameterError6(
13322
+ ErrorCode6.MissingParameter,
13323
+ "account is missing or incorrect",
13324
+ "account is missing or incorrect",
13325
+ { options, account: this.account },
13326
+ "Provide proper chain information from options field",
13327
+ "https://docs.fun.xyz"
13328
+ );
13329
+ }
13304
13330
  const hash = await txClient.sendTransaction({
13305
13331
  ...tx,
13306
13332
  account: this.signer ?? this.account,
@@ -13353,7 +13379,7 @@ var Auth = class {
13353
13379
  async getUserIds(wallet, chainId, options) {
13354
13380
  await this.init();
13355
13381
  return await getUserWalletIdentities({
13356
- authId: this.authId,
13382
+ authId: this.authId ?? "",
13357
13383
  chainId,
13358
13384
  walletAddr: wallet,
13359
13385
  apiKey: globalThis.globalEnvOption.apiKey,
@@ -15683,7 +15709,7 @@ var FunWallet = class extends FirstClassActions {
15683
15709
  { chainIdentifier: chainIdentifier ?? 137 },
15684
15710
  txOptions
15685
15711
  ),
15686
- this.walletUniqueId,
15712
+ this.walletUniqueId ?? "0x",
15687
15713
  txOptions
15688
15714
  );
15689
15715
  }
@@ -15820,7 +15846,7 @@ var FunWallet = class extends FirstClassActions {
15820
15846
  chainId = chainIdInput;
15821
15847
  }
15822
15848
  const tokens = await this.getTokens(chainId, onlyVerifiedTokens, options);
15823
- const lidoWithdrawals = checkStatus ? await this.getLidoWithdrawals(options) : {};
15849
+ const lidoWithdrawals = checkStatus ? await this.getLidoWithdrawals(options) : [[], []];
15824
15850
  return { ...lidoWithdrawals, ...tokens };
15825
15851
  }
15826
15852
  /**
@@ -16082,8 +16108,8 @@ var FunWallet = class extends FirstClassActions {
16082
16108
  initCode,
16083
16109
  nonce: txOptions.nonce !== null && txOptions.nonce !== void 0 ? txOptions.nonce : await this.getNonce(sender, void 0, txOptions),
16084
16110
  preVerificationGas: 100000n,
16085
- callGasLimit: BigInt(1e7),
16086
- verificationGasLimit: BigInt(1e7)
16111
+ callGasLimit: BigInt(DEFAULT_USEROP_GAS_LIMIT),
16112
+ verificationGasLimit: BigInt(DEFAULT_USEROP_GAS_LIMIT)
16087
16113
  };
16088
16114
  if (await chain.getChainId(txOptions) === "36865") {
16089
16115
  partialOp.callGasLimit = BigInt(1e6);
@@ -16183,11 +16209,11 @@ var FunWallet = class extends FirstClassActions {
16183
16209
  );
16184
16210
  if (isGroupOperation(finalOperation) && txOptions.skipDBAction !== true) {
16185
16211
  await signOp({
16186
- opId: finalOperation.opId,
16212
+ opId: finalOperation.opId ?? "0x",
16187
16213
  chainId: await chain.getChainId(txOptions),
16188
16214
  signature: finalOperation.userOp.signature,
16189
16215
  signedBy: await auth.getAddress(),
16190
- threshold: this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold,
16216
+ threshold: this.userInfo?.get(finalOperation.groupId ?? "0x")?.groupInfo?.threshold,
16191
16217
  apiKey: globalThis.globalEnvOption.apiKey,
16192
16218
  logger: txOptions?.logger,
16193
16219
  signal: txOptions?.signal
@@ -16213,18 +16239,20 @@ var FunWallet = class extends FirstClassActions {
16213
16239
  txOptions
16214
16240
  );
16215
16241
  const chainId = await chain.getChainId(txOptions);
16242
+ const finalOperationGroupId = finalOperation.groupId ?? "0x";
16243
+ const finalOperationOpId = finalOperation.opId ?? "0x";
16216
16244
  if (finalTxOptions.skipDBAction !== true) {
16217
16245
  if (isGroupOperation(finalOperation)) {
16218
16246
  const groups = await getGroups({
16219
- groupIds: [finalOperation.groupId],
16247
+ groupIds: [finalOperationGroupId],
16220
16248
  chainId,
16221
16249
  apiKey: globalThis.globalEnvOption.apiKey,
16222
16250
  logger: txOptions?.logger,
16223
16251
  signal: txOptions?.signal
16224
16252
  });
16225
16253
  if (groups && groups.length > 0) {
16226
- this.userInfo?.set(finalOperation.groupId, {
16227
- userId: finalOperation.groupId,
16254
+ this.userInfo?.set(finalOperationGroupId, {
16255
+ userId: finalOperationGroupId,
16228
16256
  groupInfo: {
16229
16257
  threshold: groups[0].threshold,
16230
16258
  memberIds: groups[0].memberIds
@@ -16233,7 +16261,7 @@ var FunWallet = class extends FirstClassActions {
16233
16261
  }
16234
16262
  }
16235
16263
  }
16236
- const threshold = this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold ?? 1;
16264
+ const threshold = this.userInfo?.get(finalOperationGroupId)?.groupInfo?.threshold ?? 1;
16237
16265
  if (threshold <= 1) {
16238
16266
  if (!finalOperation.userOp.signature || finalOperation.userOp.signature === "0x") {
16239
16267
  finalOperation.userOp.signature = await auth.signOp(
@@ -16246,7 +16274,7 @@ var FunWallet = class extends FirstClassActions {
16246
16274
  } else {
16247
16275
  if (finalTxOptions.skipDBAction !== true) {
16248
16276
  const storedOps = await getOps({
16249
- opIds: [finalOperation.opId],
16277
+ opIds: [finalOperationOpId],
16250
16278
  chainId,
16251
16279
  apiKey: globalThis.globalEnvOption.apiKey,
16252
16280
  logger: txOptions?.logger,
@@ -16291,7 +16319,7 @@ var FunWallet = class extends FirstClassActions {
16291
16319
  if (isGroupOperation(finalOperation)) {
16292
16320
  receipt = await executeOp({
16293
16321
  input: {
16294
- opId: finalOperation.opId,
16322
+ opId: finalOperationOpId,
16295
16323
  chainId,
16296
16324
  executedBy: await auth.getAddress(),
16297
16325
  entryPointAddress: await chain.getAddress(
@@ -16299,7 +16327,7 @@ var FunWallet = class extends FirstClassActions {
16299
16327
  txOptions
16300
16328
  ),
16301
16329
  signature: finalOperation.userOp.signature,
16302
- groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
16330
+ groupInfo: this.userInfo?.get(finalOperationGroupId)?.groupInfo
16303
16331
  },
16304
16332
  apiKey: globalThis.globalEnvOption.apiKey,
16305
16333
  logger: txOptions.logger,
@@ -16308,7 +16336,7 @@ var FunWallet = class extends FirstClassActions {
16308
16336
  } else {
16309
16337
  receipt = await executeOp({
16310
16338
  input: {
16311
- opId: finalOperation.opId,
16339
+ opId: finalOperationOpId,
16312
16340
  chainId,
16313
16341
  executedBy: await auth.getAddress(),
16314
16342
  entryPointAddress: await chain.getAddress(
@@ -16324,7 +16352,7 @@ var FunWallet = class extends FirstClassActions {
16324
16352
  });
16325
16353
  }
16326
16354
  receipt = await getFullReceipt({
16327
- opId: finalOperation.opId,
16355
+ opId: finalOperationOpId,
16328
16356
  chainId,
16329
16357
  userOpHash: receipt.userOpHash,
16330
16358
  apiKey: globalThis.globalEnvOption.apiKey,
@@ -16336,7 +16364,7 @@ var FunWallet = class extends FirstClassActions {
16336
16364
  authId: await auth.getAddress(),
16337
16365
  chainId,
16338
16366
  walletAddr: await this.getAddress(finalTxOptions),
16339
- userIds: Array.from(this.userInfo.keys()),
16367
+ userIds: this.userInfo ? Array.from(this.userInfo.keys()) : [],
16340
16368
  walletUniqueId: this.walletUniqueId,
16341
16369
  apiKey: globalThis.globalEnvOption.apiKey,
16342
16370
  logger: finalTxOptions.logger,
@@ -16383,18 +16411,20 @@ var FunWallet = class extends FirstClassActions {
16383
16411
  txOptions
16384
16412
  );
16385
16413
  const chainId = await chain.getChainId(txOptions);
16414
+ const finalOperationGroupId = finalOperation.groupId ?? "0x";
16415
+ const finalOperationOpId = finalOperation.opId ?? "0x";
16386
16416
  if (finalTxOptions.skipDBAction !== true) {
16387
16417
  if (isGroupOperation(finalOperation)) {
16388
16418
  const groups = await getGroups({
16389
- groupIds: [finalOperation.groupId],
16419
+ groupIds: [finalOperationGroupId],
16390
16420
  chainId,
16391
16421
  apiKey: globalThis.globalEnvOption.apiKey,
16392
16422
  logger: txOptions.logger,
16393
16423
  signal: txOptions.signal
16394
16424
  });
16395
16425
  if (groups && groups.length > 0) {
16396
- this.userInfo?.set(finalOperation.groupId, {
16397
- userId: finalOperation.groupId,
16426
+ this.userInfo?.set(finalOperationGroupId, {
16427
+ userId: finalOperationGroupId,
16398
16428
  groupInfo: {
16399
16429
  threshold: groups[0].threshold,
16400
16430
  memberIds: groups[0].memberIds
@@ -16403,7 +16433,7 @@ var FunWallet = class extends FirstClassActions {
16403
16433
  }
16404
16434
  }
16405
16435
  }
16406
- const threshold = this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold ?? 1;
16436
+ const threshold = this.userInfo?.get(finalOperationGroupId)?.groupInfo?.threshold ?? 1;
16407
16437
  if (threshold <= 1) {
16408
16438
  if (!finalOperation.userOp.signature || finalOperation.userOp.signature === "0x") {
16409
16439
  finalOperation.userOp.signature = await auth.signOp(
@@ -16416,7 +16446,7 @@ var FunWallet = class extends FirstClassActions {
16416
16446
  } else {
16417
16447
  if (finalTxOptions.skipDBAction !== true) {
16418
16448
  const storedOps = await getOps({
16419
- opIds: [finalOperation.opId],
16449
+ opIds: [finalOperationOpId],
16420
16450
  chainId,
16421
16451
  apiKey: globalThis.globalEnvOption.apiKey,
16422
16452
  logger: txOptions.logger,
@@ -16460,7 +16490,7 @@ var FunWallet = class extends FirstClassActions {
16460
16490
  if (isGroupOperation(finalOperation)) {
16461
16491
  await scheduleOp({
16462
16492
  input: {
16463
- opId: finalOperation.opId,
16493
+ opId: finalOperationOpId,
16464
16494
  chainId,
16465
16495
  scheduledBy: await auth.getAddress(),
16466
16496
  entryPointAddress: await chain.getAddress(
@@ -16468,7 +16498,7 @@ var FunWallet = class extends FirstClassActions {
16468
16498
  txOptions
16469
16499
  ),
16470
16500
  signature: finalOperation.userOp.signature,
16471
- groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
16501
+ groupInfo: this.userInfo?.get(finalOperationGroupId)?.groupInfo
16472
16502
  },
16473
16503
  apiKey: globalThis.globalEnvOption.apiKey,
16474
16504
  logger: txOptions.logger,
@@ -16477,7 +16507,7 @@ var FunWallet = class extends FirstClassActions {
16477
16507
  } else {
16478
16508
  await scheduleOp({
16479
16509
  input: {
16480
- opId: finalOperation.opId,
16510
+ opId: finalOperationOpId,
16481
16511
  chainId,
16482
16512
  scheduledBy: await auth.getAddress(),
16483
16513
  entryPointAddress: await chain.getAddress(
@@ -16545,7 +16575,7 @@ var FunWallet = class extends FirstClassActions {
16545
16575
  }
16546
16576
  );
16547
16577
  if (rejectionMessage) rejectOperation.message = rejectionMessage;
16548
- rejectOperation.relatedOpIds = [operation.opId];
16578
+ rejectOperation.relatedOpIds = [operation.opId ?? "0x"];
16549
16579
  rejectOperation.opType = OperationType.REJECTION;
16550
16580
  rejectOperation.opId = await createOp({
16551
16581
  op: rejectOperation,
@@ -16585,7 +16615,7 @@ var FunWallet = class extends FirstClassActions {
16585
16615
  return operation;
16586
16616
  }
16587
16617
  async getThisInitCode(chain, options) {
16588
- const owners = Array.from(this.userInfo.keys());
16618
+ const owners = this.userInfo ? Array.from(this.userInfo.keys()) : [];
16589
16619
  const entryPointAddress = await chain.getAddress(
16590
16620
  "entryPointAddress",
16591
16621
  options
@@ -16598,9 +16628,9 @@ var FunWallet = class extends FirstClassActions {
16598
16628
  };
16599
16629
  const rbacInitData = toBytes32Arr(owners);
16600
16630
  let userAuthInitData = "0x";
16601
- const groupUsers = Array.from(this.userInfo.values()).filter(
16631
+ const groupUsers = this.userInfo ? Array.from(this.userInfo.values()).filter(
16602
16632
  (user) => user.groupInfo !== null && user.groupInfo !== void 0
16603
- );
16633
+ ) : [];
16604
16634
  if (groupUsers.length > 0) {
16605
16635
  userAuthInitData = encodeUserAuthInitData(groupUsers);
16606
16636
  }
@@ -16758,6 +16788,7 @@ export {
16758
16788
  CheckoutSponsor,
16759
16789
  ContractInterface,
16760
16790
  DEFAULT_RETRY_OPTIONS,
16791
+ DEFAULT_USEROP_GAS_LIMIT,
16761
16792
  ENTRYPOINT_ABI,
16762
16793
  ENTRYPOINT_CONTRACT_INTERFACE,
16763
16794
  ERC20_ABI,