@funkit/core 2.3.9 → 2.3.11
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 +68 -39
- package/dist/index.js.map +2 -2
- package/dist/src/wallet/FunWallet.d.ts +174 -3
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -11767,7 +11767,12 @@ var getPaymasterType = (txOptions) => {
|
|
|
11767
11767
|
};
|
|
11768
11768
|
|
|
11769
11769
|
// src/utils/UserOpUtils.ts
|
|
11770
|
-
import {
|
|
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
|
},
|
|
@@ -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
|
|
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
|
|
12584
|
+
return [sortedMemberIds, user.groupInfo?.threshold ?? 0];
|
|
12580
12585
|
});
|
|
12581
12586
|
return defaultAbiCoder.encode(
|
|
12582
12587
|
["bytes32[]", "tuple(bytes32[],uint256)[]"],
|
|
@@ -13240,7 +13245,7 @@ var Auth = class {
|
|
|
13240
13245
|
async getWalletUniqueId(index = 0, skipDBActions = false, options) {
|
|
13241
13246
|
await this.init();
|
|
13242
13247
|
const authUniqueId = await getAuthUniqueId(
|
|
13243
|
-
this.authId,
|
|
13248
|
+
this.authId ?? "",
|
|
13244
13249
|
await this.getAddress(),
|
|
13245
13250
|
skipDBActions,
|
|
13246
13251
|
options
|
|
@@ -13272,6 +13277,16 @@ var Auth = class {
|
|
|
13272
13277
|
"https://docs.fun.xyz"
|
|
13273
13278
|
);
|
|
13274
13279
|
}
|
|
13280
|
+
if (!this.signer) {
|
|
13281
|
+
throw new InvalidParameterError6(
|
|
13282
|
+
ErrorCode6.MissingParameter,
|
|
13283
|
+
"signer is missing or incorrect",
|
|
13284
|
+
"signer is missing or incorrect",
|
|
13285
|
+
{ options, signer: this.signer },
|
|
13286
|
+
"Provide proper chain information from options field",
|
|
13287
|
+
"https://docs.fun.xyz"
|
|
13288
|
+
);
|
|
13289
|
+
}
|
|
13275
13290
|
const client = await chain.getClient(options);
|
|
13276
13291
|
const txClient = this.client ?? createWalletClient2({
|
|
13277
13292
|
account: this.signer,
|
|
@@ -13301,6 +13316,16 @@ var Auth = class {
|
|
|
13301
13316
|
} else {
|
|
13302
13317
|
tx = { to, value: BigInt(value), data };
|
|
13303
13318
|
}
|
|
13319
|
+
if (!this.account) {
|
|
13320
|
+
throw new InvalidParameterError6(
|
|
13321
|
+
ErrorCode6.MissingParameter,
|
|
13322
|
+
"account is missing or incorrect",
|
|
13323
|
+
"account is missing or incorrect",
|
|
13324
|
+
{ options, account: this.account },
|
|
13325
|
+
"Provide proper chain information from options field",
|
|
13326
|
+
"https://docs.fun.xyz"
|
|
13327
|
+
);
|
|
13328
|
+
}
|
|
13304
13329
|
const hash = await txClient.sendTransaction({
|
|
13305
13330
|
...tx,
|
|
13306
13331
|
account: this.signer ?? this.account,
|
|
@@ -13353,7 +13378,7 @@ var Auth = class {
|
|
|
13353
13378
|
async getUserIds(wallet, chainId, options) {
|
|
13354
13379
|
await this.init();
|
|
13355
13380
|
return await getUserWalletIdentities({
|
|
13356
|
-
authId: this.authId,
|
|
13381
|
+
authId: this.authId ?? "",
|
|
13357
13382
|
chainId,
|
|
13358
13383
|
walletAddr: wallet,
|
|
13359
13384
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
@@ -15683,7 +15708,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15683
15708
|
{ chainIdentifier: chainIdentifier ?? 137 },
|
|
15684
15709
|
txOptions
|
|
15685
15710
|
),
|
|
15686
|
-
this.walletUniqueId,
|
|
15711
|
+
this.walletUniqueId ?? "0x",
|
|
15687
15712
|
txOptions
|
|
15688
15713
|
);
|
|
15689
15714
|
}
|
|
@@ -15820,7 +15845,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15820
15845
|
chainId = chainIdInput;
|
|
15821
15846
|
}
|
|
15822
15847
|
const tokens = await this.getTokens(chainId, onlyVerifiedTokens, options);
|
|
15823
|
-
const lidoWithdrawals = checkStatus ? await this.getLidoWithdrawals(options) :
|
|
15848
|
+
const lidoWithdrawals = checkStatus ? await this.getLidoWithdrawals(options) : [[], []];
|
|
15824
15849
|
return { ...lidoWithdrawals, ...tokens };
|
|
15825
15850
|
}
|
|
15826
15851
|
/**
|
|
@@ -16183,11 +16208,11 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16183
16208
|
);
|
|
16184
16209
|
if (isGroupOperation(finalOperation) && txOptions.skipDBAction !== true) {
|
|
16185
16210
|
await signOp({
|
|
16186
|
-
opId: finalOperation.opId,
|
|
16211
|
+
opId: finalOperation.opId ?? "0x",
|
|
16187
16212
|
chainId: await chain.getChainId(txOptions),
|
|
16188
16213
|
signature: finalOperation.userOp.signature,
|
|
16189
16214
|
signedBy: await auth.getAddress(),
|
|
16190
|
-
threshold: this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold,
|
|
16215
|
+
threshold: this.userInfo?.get(finalOperation.groupId ?? "0x")?.groupInfo?.threshold,
|
|
16191
16216
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16192
16217
|
logger: txOptions?.logger,
|
|
16193
16218
|
signal: txOptions?.signal
|
|
@@ -16213,18 +16238,20 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16213
16238
|
txOptions
|
|
16214
16239
|
);
|
|
16215
16240
|
const chainId = await chain.getChainId(txOptions);
|
|
16241
|
+
const finalOperationGroupId = finalOperation.groupId ?? "0x";
|
|
16242
|
+
const finalOperationOpId = finalOperation.opId ?? "0x";
|
|
16216
16243
|
if (finalTxOptions.skipDBAction !== true) {
|
|
16217
16244
|
if (isGroupOperation(finalOperation)) {
|
|
16218
16245
|
const groups = await getGroups({
|
|
16219
|
-
groupIds: [
|
|
16246
|
+
groupIds: [finalOperationGroupId],
|
|
16220
16247
|
chainId,
|
|
16221
16248
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16222
16249
|
logger: txOptions?.logger,
|
|
16223
16250
|
signal: txOptions?.signal
|
|
16224
16251
|
});
|
|
16225
16252
|
if (groups && groups.length > 0) {
|
|
16226
|
-
this.userInfo?.set(
|
|
16227
|
-
userId:
|
|
16253
|
+
this.userInfo?.set(finalOperationGroupId, {
|
|
16254
|
+
userId: finalOperationGroupId,
|
|
16228
16255
|
groupInfo: {
|
|
16229
16256
|
threshold: groups[0].threshold,
|
|
16230
16257
|
memberIds: groups[0].memberIds
|
|
@@ -16233,7 +16260,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16233
16260
|
}
|
|
16234
16261
|
}
|
|
16235
16262
|
}
|
|
16236
|
-
const threshold = this.userInfo?.get(
|
|
16263
|
+
const threshold = this.userInfo?.get(finalOperationGroupId)?.groupInfo?.threshold ?? 1;
|
|
16237
16264
|
if (threshold <= 1) {
|
|
16238
16265
|
if (!finalOperation.userOp.signature || finalOperation.userOp.signature === "0x") {
|
|
16239
16266
|
finalOperation.userOp.signature = await auth.signOp(
|
|
@@ -16246,7 +16273,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16246
16273
|
} else {
|
|
16247
16274
|
if (finalTxOptions.skipDBAction !== true) {
|
|
16248
16275
|
const storedOps = await getOps({
|
|
16249
|
-
opIds: [
|
|
16276
|
+
opIds: [finalOperationOpId],
|
|
16250
16277
|
chainId,
|
|
16251
16278
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16252
16279
|
logger: txOptions?.logger,
|
|
@@ -16291,7 +16318,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16291
16318
|
if (isGroupOperation(finalOperation)) {
|
|
16292
16319
|
receipt = await executeOp({
|
|
16293
16320
|
input: {
|
|
16294
|
-
opId:
|
|
16321
|
+
opId: finalOperationOpId,
|
|
16295
16322
|
chainId,
|
|
16296
16323
|
executedBy: await auth.getAddress(),
|
|
16297
16324
|
entryPointAddress: await chain.getAddress(
|
|
@@ -16299,7 +16326,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16299
16326
|
txOptions
|
|
16300
16327
|
),
|
|
16301
16328
|
signature: finalOperation.userOp.signature,
|
|
16302
|
-
groupInfo: this.userInfo?.get(
|
|
16329
|
+
groupInfo: this.userInfo?.get(finalOperationGroupId)?.groupInfo
|
|
16303
16330
|
},
|
|
16304
16331
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16305
16332
|
logger: txOptions.logger,
|
|
@@ -16308,7 +16335,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16308
16335
|
} else {
|
|
16309
16336
|
receipt = await executeOp({
|
|
16310
16337
|
input: {
|
|
16311
|
-
opId:
|
|
16338
|
+
opId: finalOperationOpId,
|
|
16312
16339
|
chainId,
|
|
16313
16340
|
executedBy: await auth.getAddress(),
|
|
16314
16341
|
entryPointAddress: await chain.getAddress(
|
|
@@ -16324,7 +16351,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16324
16351
|
});
|
|
16325
16352
|
}
|
|
16326
16353
|
receipt = await getFullReceipt({
|
|
16327
|
-
opId:
|
|
16354
|
+
opId: finalOperationOpId,
|
|
16328
16355
|
chainId,
|
|
16329
16356
|
userOpHash: receipt.userOpHash,
|
|
16330
16357
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
@@ -16336,7 +16363,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16336
16363
|
authId: await auth.getAddress(),
|
|
16337
16364
|
chainId,
|
|
16338
16365
|
walletAddr: await this.getAddress(finalTxOptions),
|
|
16339
|
-
userIds: Array.from(this.userInfo.keys()),
|
|
16366
|
+
userIds: this.userInfo ? Array.from(this.userInfo.keys()) : [],
|
|
16340
16367
|
walletUniqueId: this.walletUniqueId,
|
|
16341
16368
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16342
16369
|
logger: finalTxOptions.logger,
|
|
@@ -16383,18 +16410,20 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16383
16410
|
txOptions
|
|
16384
16411
|
);
|
|
16385
16412
|
const chainId = await chain.getChainId(txOptions);
|
|
16413
|
+
const finalOperationGroupId = finalOperation.groupId ?? "0x";
|
|
16414
|
+
const finalOperationOpId = finalOperation.opId ?? "0x";
|
|
16386
16415
|
if (finalTxOptions.skipDBAction !== true) {
|
|
16387
16416
|
if (isGroupOperation(finalOperation)) {
|
|
16388
16417
|
const groups = await getGroups({
|
|
16389
|
-
groupIds: [
|
|
16418
|
+
groupIds: [finalOperationGroupId],
|
|
16390
16419
|
chainId,
|
|
16391
16420
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16392
16421
|
logger: txOptions.logger,
|
|
16393
16422
|
signal: txOptions.signal
|
|
16394
16423
|
});
|
|
16395
16424
|
if (groups && groups.length > 0) {
|
|
16396
|
-
this.userInfo?.set(
|
|
16397
|
-
userId:
|
|
16425
|
+
this.userInfo?.set(finalOperationGroupId, {
|
|
16426
|
+
userId: finalOperationGroupId,
|
|
16398
16427
|
groupInfo: {
|
|
16399
16428
|
threshold: groups[0].threshold,
|
|
16400
16429
|
memberIds: groups[0].memberIds
|
|
@@ -16403,7 +16432,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16403
16432
|
}
|
|
16404
16433
|
}
|
|
16405
16434
|
}
|
|
16406
|
-
const threshold = this.userInfo?.get(
|
|
16435
|
+
const threshold = this.userInfo?.get(finalOperationGroupId)?.groupInfo?.threshold ?? 1;
|
|
16407
16436
|
if (threshold <= 1) {
|
|
16408
16437
|
if (!finalOperation.userOp.signature || finalOperation.userOp.signature === "0x") {
|
|
16409
16438
|
finalOperation.userOp.signature = await auth.signOp(
|
|
@@ -16416,7 +16445,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16416
16445
|
} else {
|
|
16417
16446
|
if (finalTxOptions.skipDBAction !== true) {
|
|
16418
16447
|
const storedOps = await getOps({
|
|
16419
|
-
opIds: [
|
|
16448
|
+
opIds: [finalOperationOpId],
|
|
16420
16449
|
chainId,
|
|
16421
16450
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16422
16451
|
logger: txOptions.logger,
|
|
@@ -16460,7 +16489,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16460
16489
|
if (isGroupOperation(finalOperation)) {
|
|
16461
16490
|
await scheduleOp({
|
|
16462
16491
|
input: {
|
|
16463
|
-
opId:
|
|
16492
|
+
opId: finalOperationOpId,
|
|
16464
16493
|
chainId,
|
|
16465
16494
|
scheduledBy: await auth.getAddress(),
|
|
16466
16495
|
entryPointAddress: await chain.getAddress(
|
|
@@ -16468,7 +16497,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16468
16497
|
txOptions
|
|
16469
16498
|
),
|
|
16470
16499
|
signature: finalOperation.userOp.signature,
|
|
16471
|
-
groupInfo: this.userInfo?.get(
|
|
16500
|
+
groupInfo: this.userInfo?.get(finalOperationGroupId)?.groupInfo
|
|
16472
16501
|
},
|
|
16473
16502
|
apiKey: globalThis.globalEnvOption.apiKey,
|
|
16474
16503
|
logger: txOptions.logger,
|
|
@@ -16477,7 +16506,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16477
16506
|
} else {
|
|
16478
16507
|
await scheduleOp({
|
|
16479
16508
|
input: {
|
|
16480
|
-
opId:
|
|
16509
|
+
opId: finalOperationOpId,
|
|
16481
16510
|
chainId,
|
|
16482
16511
|
scheduledBy: await auth.getAddress(),
|
|
16483
16512
|
entryPointAddress: await chain.getAddress(
|
|
@@ -16545,7 +16574,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16545
16574
|
}
|
|
16546
16575
|
);
|
|
16547
16576
|
if (rejectionMessage) rejectOperation.message = rejectionMessage;
|
|
16548
|
-
rejectOperation.relatedOpIds = [operation.opId];
|
|
16577
|
+
rejectOperation.relatedOpIds = [operation.opId ?? "0x"];
|
|
16549
16578
|
rejectOperation.opType = OperationType.REJECTION;
|
|
16550
16579
|
rejectOperation.opId = await createOp({
|
|
16551
16580
|
op: rejectOperation,
|
|
@@ -16585,7 +16614,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16585
16614
|
return operation;
|
|
16586
16615
|
}
|
|
16587
16616
|
async getThisInitCode(chain, options) {
|
|
16588
|
-
const owners = Array.from(this.userInfo.keys());
|
|
16617
|
+
const owners = this.userInfo ? Array.from(this.userInfo.keys()) : [];
|
|
16589
16618
|
const entryPointAddress = await chain.getAddress(
|
|
16590
16619
|
"entryPointAddress",
|
|
16591
16620
|
options
|
|
@@ -16598,9 +16627,9 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16598
16627
|
};
|
|
16599
16628
|
const rbacInitData = toBytes32Arr(owners);
|
|
16600
16629
|
let userAuthInitData = "0x";
|
|
16601
|
-
const groupUsers = Array.from(this.userInfo.values()).filter(
|
|
16630
|
+
const groupUsers = this.userInfo ? Array.from(this.userInfo.values()).filter(
|
|
16602
16631
|
(user) => user.groupInfo !== null && user.groupInfo !== void 0
|
|
16603
|
-
);
|
|
16632
|
+
) : [];
|
|
16604
16633
|
if (groupUsers.length > 0) {
|
|
16605
16634
|
userAuthInitData = encodeUserAuthInitData(groupUsers);
|
|
16606
16635
|
}
|