@funkit/core 2.3.54 → 2.3.56
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 +119 -392
- package/dist/index.js.map +4 -4
- package/dist/src/actions/FirstClassActions.d.ts.map +1 -1
- package/dist/src/actions/Token.d.ts +1 -5
- package/dist/src/actions/Token.d.ts.map +1 -1
- package/dist/src/actions/types.d.ts +1 -7
- package/dist/src/actions/types.d.ts.map +1 -1
- package/dist/src/common/constants.d.ts.map +1 -1
- package/dist/src/data/index.d.ts +0 -1
- package/dist/src/data/index.d.ts.map +1 -1
- package/dist/src/wallet/FunWallet.d.ts +0 -6
- package/dist/src/wallet/FunWallet.d.ts.map +1 -1
- package/package.json +3 -3
- package/dist/src/data/NFT.d.ts +0 -30
- package/dist/src/data/NFT.d.ts.map +0 -1
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
|
|
3
|
+
import { ErrorCode as ErrorCode6, InvalidParameterError as InvalidParameterError6 } from "@funkit/utils";
|
|
4
4
|
|
|
5
5
|
// src/auth/Auth.ts
|
|
6
6
|
import {
|
|
@@ -19,8 +19,8 @@ import {
|
|
|
19
19
|
getUserWalletsByAddr
|
|
20
20
|
} from "@funkit/api-base";
|
|
21
21
|
import {
|
|
22
|
-
ErrorCode as
|
|
23
|
-
InvalidParameterError as
|
|
22
|
+
ErrorCode as ErrorCode5,
|
|
23
|
+
InvalidParameterError as InvalidParameterError5,
|
|
24
24
|
ResourceNotFoundError as ResourceNotFoundError4
|
|
25
25
|
} from "@funkit/utils";
|
|
26
26
|
|
|
@@ -12249,185 +12249,6 @@ var Chain = class _Chain {
|
|
|
12249
12249
|
}
|
|
12250
12250
|
};
|
|
12251
12251
|
|
|
12252
|
-
// src/data/NFT.ts
|
|
12253
|
-
import { isAddress as isAddress2 } from "viem";
|
|
12254
|
-
import { getNftAddress, getNftName } from "@funkit/api-base";
|
|
12255
|
-
import { ErrorCode as ErrorCode4, InvalidParameterError as InvalidParameterError4 } from "@funkit/utils";
|
|
12256
|
-
var NFT = class _NFT {
|
|
12257
|
-
constructor(input) {
|
|
12258
|
-
this.name = "";
|
|
12259
|
-
if (!input) {
|
|
12260
|
-
throw new InvalidParameterError4(
|
|
12261
|
-
ErrorCode4.InvalidNFTIdentifier,
|
|
12262
|
-
"valid NFT identifier is required, could be address or name",
|
|
12263
|
-
"valid NFT identifier is required, could be address or name",
|
|
12264
|
-
{ input },
|
|
12265
|
-
"Please provide valid NFT identifier",
|
|
12266
|
-
"https://docs.fun.xyz"
|
|
12267
|
-
);
|
|
12268
|
-
}
|
|
12269
|
-
if (isAddress2(input)) {
|
|
12270
|
-
this.address = input;
|
|
12271
|
-
} else {
|
|
12272
|
-
this.name = input;
|
|
12273
|
-
}
|
|
12274
|
-
}
|
|
12275
|
-
async approve(spender, tokenId, options = globalThis.globalEnvOption) {
|
|
12276
|
-
const chain = await Chain.getChain(
|
|
12277
|
-
{ chainIdentifier: options.chain },
|
|
12278
|
-
options
|
|
12279
|
-
);
|
|
12280
|
-
const data = ERC721_CONTRACT_INTERFACE.encodeTransactionParams(
|
|
12281
|
-
await this.getAddress(options),
|
|
12282
|
-
"approve",
|
|
12283
|
-
[spender, tokenId]
|
|
12284
|
-
);
|
|
12285
|
-
return { ...data, chain };
|
|
12286
|
-
}
|
|
12287
|
-
async ownerOf(tokenId, options = globalThis.globalEnvOption) {
|
|
12288
|
-
const chain = await Chain.getChain(
|
|
12289
|
-
{ chainIdentifier: options.chain },
|
|
12290
|
-
options
|
|
12291
|
-
);
|
|
12292
|
-
return await ERC721_CONTRACT_INTERFACE.readFromChain(
|
|
12293
|
-
await this.getAddress(options),
|
|
12294
|
-
"ownerOf",
|
|
12295
|
-
[tokenId],
|
|
12296
|
-
chain,
|
|
12297
|
-
options
|
|
12298
|
-
);
|
|
12299
|
-
}
|
|
12300
|
-
async approveForAll(spender, options = globalThis.globalEnvOption) {
|
|
12301
|
-
const chain = await Chain.getChain(
|
|
12302
|
-
{ chainIdentifier: options.chain },
|
|
12303
|
-
options
|
|
12304
|
-
);
|
|
12305
|
-
const data = ERC721_CONTRACT_INTERFACE.encodeTransactionParams(
|
|
12306
|
-
await this.getAddress(options),
|
|
12307
|
-
"setApprovalForAll",
|
|
12308
|
-
[spender, true]
|
|
12309
|
-
);
|
|
12310
|
-
return { ...data, chain };
|
|
12311
|
-
}
|
|
12312
|
-
async getAddress(options) {
|
|
12313
|
-
if (!this.address) {
|
|
12314
|
-
if (!this.name) {
|
|
12315
|
-
throw new InvalidParameterError4(
|
|
12316
|
-
ErrorCode4.InvalidNFTIdentifier,
|
|
12317
|
-
"valid NFT identifier is required, could be address or name",
|
|
12318
|
-
"valid NFT identifier is required, could be address or name",
|
|
12319
|
-
{},
|
|
12320
|
-
"Please provide valid NFT identifier",
|
|
12321
|
-
"https://docs.fun.xyz"
|
|
12322
|
-
);
|
|
12323
|
-
}
|
|
12324
|
-
const nft = await getNftAddress({
|
|
12325
|
-
name: this.name,
|
|
12326
|
-
apiKey: globalThis.globalEnvOption.apiKey,
|
|
12327
|
-
logger: options?.logger,
|
|
12328
|
-
signal: options?.signal
|
|
12329
|
-
});
|
|
12330
|
-
return nft.address;
|
|
12331
|
-
}
|
|
12332
|
-
return this.address;
|
|
12333
|
-
}
|
|
12334
|
-
async getName(options = globalThis.globalEnvOption) {
|
|
12335
|
-
if (!this.name && this.address) {
|
|
12336
|
-
const chain = await Chain.getChain(
|
|
12337
|
-
{ chainIdentifier: options.chain },
|
|
12338
|
-
options
|
|
12339
|
-
);
|
|
12340
|
-
const nft = await getNftName({
|
|
12341
|
-
chainId: await chain.getChainId(options),
|
|
12342
|
-
nftAddress: this.address,
|
|
12343
|
-
apiKey: globalThis.globalEnvOption.apiKey,
|
|
12344
|
-
logger: options.logger,
|
|
12345
|
-
signal: options.signal
|
|
12346
|
-
});
|
|
12347
|
-
return nft.name;
|
|
12348
|
-
}
|
|
12349
|
-
return this.name;
|
|
12350
|
-
}
|
|
12351
|
-
async getBalance(address, options = globalThis.globalEnvOption) {
|
|
12352
|
-
const chain = await Chain.getChain(
|
|
12353
|
-
{ chainIdentifier: options.chain },
|
|
12354
|
-
options
|
|
12355
|
-
);
|
|
12356
|
-
return await ERC721_CONTRACT_INTERFACE.readFromChain(
|
|
12357
|
-
await this.getAddress(options),
|
|
12358
|
-
"balanceOf",
|
|
12359
|
-
[address],
|
|
12360
|
-
chain,
|
|
12361
|
-
options
|
|
12362
|
-
);
|
|
12363
|
-
}
|
|
12364
|
-
async getApproved(tokenId, options = globalThis.globalEnvOption) {
|
|
12365
|
-
const chain = await Chain.getChain(
|
|
12366
|
-
{ chainIdentifier: options.chain },
|
|
12367
|
-
options
|
|
12368
|
-
);
|
|
12369
|
-
return await ERC721_CONTRACT_INTERFACE.readFromChain(
|
|
12370
|
-
await this.getAddress(options),
|
|
12371
|
-
"getApproved",
|
|
12372
|
-
[tokenId],
|
|
12373
|
-
chain,
|
|
12374
|
-
options
|
|
12375
|
-
);
|
|
12376
|
-
}
|
|
12377
|
-
async revokeForAll(spender, options = globalThis.globalEnvOption) {
|
|
12378
|
-
const chain = await Chain.getChain(
|
|
12379
|
-
{ chainIdentifier: options.chain },
|
|
12380
|
-
options
|
|
12381
|
-
);
|
|
12382
|
-
const data = ERC721_CONTRACT_INTERFACE.encodeTransactionParams(
|
|
12383
|
-
await this.getAddress(options),
|
|
12384
|
-
"setApprovalForAll",
|
|
12385
|
-
[spender, false]
|
|
12386
|
-
);
|
|
12387
|
-
return { ...data, chain };
|
|
12388
|
-
}
|
|
12389
|
-
async transfer(sender, spender, tokenId, options = globalThis.globalEnvOption) {
|
|
12390
|
-
const chain = await Chain.getChain(
|
|
12391
|
-
{ chainIdentifier: options.chain },
|
|
12392
|
-
options
|
|
12393
|
-
);
|
|
12394
|
-
const data = ERC721_CONTRACT_INTERFACE.encodeTransactionParams(
|
|
12395
|
-
await this.getAddress(options),
|
|
12396
|
-
"transferFrom",
|
|
12397
|
-
[sender, spender, tokenId]
|
|
12398
|
-
);
|
|
12399
|
-
return { ...data, chain };
|
|
12400
|
-
}
|
|
12401
|
-
static async approve(data, spender, tokenId, options = globalThis.globalEnvOption) {
|
|
12402
|
-
const nft = new _NFT(data);
|
|
12403
|
-
return await nft.approve(spender, tokenId, options);
|
|
12404
|
-
}
|
|
12405
|
-
static async approveForAll(data, spender, options = globalThis.globalEnvOption) {
|
|
12406
|
-
const nft = new _NFT(data);
|
|
12407
|
-
return await nft.approveForAll(spender, options);
|
|
12408
|
-
}
|
|
12409
|
-
static async getAddress(data, options) {
|
|
12410
|
-
const nft = new _NFT(data);
|
|
12411
|
-
return await nft.getAddress(options);
|
|
12412
|
-
}
|
|
12413
|
-
static async getApproved(data, tokenId, options = globalThis.globalEnvOption) {
|
|
12414
|
-
const nft = new _NFT(data);
|
|
12415
|
-
return await nft.getApproved(tokenId, options);
|
|
12416
|
-
}
|
|
12417
|
-
static async revokeForAll(data, spender, options = globalThis.globalEnvOption) {
|
|
12418
|
-
const nft = new _NFT(data);
|
|
12419
|
-
return await nft.revokeForAll(spender, options);
|
|
12420
|
-
}
|
|
12421
|
-
static async transfer(data, sender, spender, tokenId, options = globalThis.globalEnvOption) {
|
|
12422
|
-
const nft = new _NFT(data);
|
|
12423
|
-
return await nft.transfer(sender, spender, tokenId, options);
|
|
12424
|
-
}
|
|
12425
|
-
static async ownerOf(data, tokenId, options = globalThis.globalEnvOption) {
|
|
12426
|
-
const nft = new _NFT(data);
|
|
12427
|
-
return await nft.ownerOf(tokenId, options);
|
|
12428
|
-
}
|
|
12429
|
-
};
|
|
12430
|
-
|
|
12431
12252
|
// src/data/Operation.ts
|
|
12432
12253
|
var Operation = class _Operation {
|
|
12433
12254
|
constructor(userOp, metadata) {
|
|
@@ -12598,11 +12419,11 @@ function toBytes32Arr(data) {
|
|
|
12598
12419
|
}
|
|
12599
12420
|
|
|
12600
12421
|
// src/data/Token.ts
|
|
12601
|
-
import { formatUnits, isAddress as
|
|
12422
|
+
import { formatUnits, isAddress as isAddress2, parseUnits } from "viem";
|
|
12602
12423
|
import {
|
|
12603
|
-
ErrorCode as
|
|
12424
|
+
ErrorCode as ErrorCode4,
|
|
12604
12425
|
InternalFailureError as InternalFailureError2,
|
|
12605
|
-
InvalidParameterError as
|
|
12426
|
+
InvalidParameterError as InvalidParameterError4
|
|
12606
12427
|
} from "@funkit/utils";
|
|
12607
12428
|
var wrappedNativeTokens = {
|
|
12608
12429
|
eth: "weth",
|
|
@@ -12615,7 +12436,7 @@ var Token = class _Token {
|
|
|
12615
12436
|
this.isNative = false;
|
|
12616
12437
|
this.symbol = "";
|
|
12617
12438
|
this.chain = chain;
|
|
12618
|
-
if (
|
|
12439
|
+
if (isAddress2(input)) {
|
|
12619
12440
|
this.address = input;
|
|
12620
12441
|
return;
|
|
12621
12442
|
}
|
|
@@ -12645,7 +12466,7 @@ var Token = class _Token {
|
|
|
12645
12466
|
);
|
|
12646
12467
|
}
|
|
12647
12468
|
throw new InternalFailureError2(
|
|
12648
|
-
|
|
12469
|
+
ErrorCode4.ServerMissingData,
|
|
12649
12470
|
"server missing token symbol and address info",
|
|
12650
12471
|
"",
|
|
12651
12472
|
{ symbol: this.symbol, address: this.address, isNative: this.isNative },
|
|
@@ -12689,8 +12510,8 @@ var Token = class _Token {
|
|
|
12689
12510
|
}
|
|
12690
12511
|
async getApproval(owner, spender, options) {
|
|
12691
12512
|
if (this.isNative) {
|
|
12692
|
-
throw new
|
|
12693
|
-
|
|
12513
|
+
throw new InvalidParameterError4(
|
|
12514
|
+
ErrorCode4.InvalidParameter,
|
|
12694
12515
|
"Native token can not approve",
|
|
12695
12516
|
"Native token can not approve",
|
|
12696
12517
|
{ isNative: this.isNative },
|
|
@@ -13019,7 +12840,7 @@ var BYTES32_LENGTH = 66;
|
|
|
13019
12840
|
var BASE_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0xa880eae8900eb59bf7dad9bdb741a086238adca900000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
|
|
13020
12841
|
var OPTIMISM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0x4Df91e173A6CdC74EfeF6fC72bb5Df1E8A8d758200000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
|
|
13021
12842
|
var ETHEREUM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0x67F21bE69A16c314a0b7Da537309b2f3ADdDE03100000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
|
|
13022
|
-
var STABLECOIN_SYMBOLS = ["USDC", "USDC.e", "USDT", "DAI"];
|
|
12843
|
+
var STABLECOIN_SYMBOLS = ["USDC", "USDC.e", "USDT", "DAI", "USDe"];
|
|
13023
12844
|
var DEFAULT_USEROP_GAS_LIMIT = 15e5;
|
|
13024
12845
|
|
|
13025
12846
|
// src/utils/TypeUtils.ts
|
|
@@ -13142,8 +12963,8 @@ var Auth = class {
|
|
|
13142
12963
|
} else if (!isHex2(authInput.privateKey) && authInput.privateKey.length === VALID_PRIVATE_KEY_LENGTH) {
|
|
13143
12964
|
privateKey = `0x${authInput.privateKey}`;
|
|
13144
12965
|
} else {
|
|
13145
|
-
throw new
|
|
13146
|
-
|
|
12966
|
+
throw new InvalidParameterError5(
|
|
12967
|
+
ErrorCode5.InvalidParameter,
|
|
13147
12968
|
"privateKey is not a valid one",
|
|
13148
12969
|
"privateKey is not a valid one",
|
|
13149
12970
|
authInput.privateKey,
|
|
@@ -13153,8 +12974,8 @@ var Auth = class {
|
|
|
13153
12974
|
}
|
|
13154
12975
|
this.signer = privateKeyToAccount(privateKey);
|
|
13155
12976
|
} else {
|
|
13156
|
-
throw new
|
|
13157
|
-
|
|
12977
|
+
throw new InvalidParameterError5(
|
|
12978
|
+
ErrorCode5.MissingParameter,
|
|
13158
12979
|
"valid authInput is required",
|
|
13159
12980
|
"valid authInput is required",
|
|
13160
12981
|
authInput,
|
|
@@ -13283,8 +13104,8 @@ var Auth = class {
|
|
|
13283
13104
|
const { to, data } = txData;
|
|
13284
13105
|
const { value = 0n } = txData;
|
|
13285
13106
|
if (!chain || !chainId) {
|
|
13286
|
-
throw new
|
|
13287
|
-
|
|
13107
|
+
throw new InvalidParameterError5(
|
|
13108
|
+
ErrorCode5.MissingParameter,
|
|
13288
13109
|
"chain object is missing or incorrect",
|
|
13289
13110
|
"chain object is missing or incorrect",
|
|
13290
13111
|
{ options, chainId },
|
|
@@ -13293,8 +13114,8 @@ var Auth = class {
|
|
|
13293
13114
|
);
|
|
13294
13115
|
}
|
|
13295
13116
|
if (!this.signer) {
|
|
13296
|
-
throw new
|
|
13297
|
-
|
|
13117
|
+
throw new InvalidParameterError5(
|
|
13118
|
+
ErrorCode5.MissingParameter,
|
|
13298
13119
|
"signer is missing or incorrect",
|
|
13299
13120
|
"signer is missing or incorrect",
|
|
13300
13121
|
{ options, signer: this.signer },
|
|
@@ -13332,8 +13153,8 @@ var Auth = class {
|
|
|
13332
13153
|
tx = { to, value: BigInt(value), data };
|
|
13333
13154
|
}
|
|
13334
13155
|
if (!this.account) {
|
|
13335
|
-
throw new
|
|
13336
|
-
|
|
13156
|
+
throw new InvalidParameterError5(
|
|
13157
|
+
ErrorCode5.MissingParameter,
|
|
13337
13158
|
"account is missing or incorrect",
|
|
13338
13159
|
"account is missing or incorrect",
|
|
13339
13160
|
{ options, account: this.account },
|
|
@@ -13696,8 +13517,8 @@ var createTargetSelectorMerkleTree = (params) => {
|
|
|
13696
13517
|
};
|
|
13697
13518
|
var createSessionKeyTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
13698
13519
|
if (params.targetWhitelist.length === 0) {
|
|
13699
|
-
throw new
|
|
13700
|
-
|
|
13520
|
+
throw new InvalidParameterError6(
|
|
13521
|
+
ErrorCode6.MissingParameter,
|
|
13701
13522
|
"targetWhitelist is required",
|
|
13702
13523
|
"targetWhitelist is required",
|
|
13703
13524
|
{ params },
|
|
@@ -13706,8 +13527,8 @@ var createSessionKeyTransactionParams = async (params, txOptions = globalThis.gl
|
|
|
13706
13527
|
);
|
|
13707
13528
|
}
|
|
13708
13529
|
if (params.userId === void 0) {
|
|
13709
|
-
throw new
|
|
13710
|
-
|
|
13530
|
+
throw new InvalidParameterError6(
|
|
13531
|
+
ErrorCode6.MissingParameter,
|
|
13711
13532
|
"userId is required",
|
|
13712
13533
|
"userId is required",
|
|
13713
13534
|
{ params },
|
|
@@ -13856,11 +13677,11 @@ var removeGroupTxParams = async (params, txOptions = globalThis.globalEnvOption)
|
|
|
13856
13677
|
};
|
|
13857
13678
|
|
|
13858
13679
|
// src/actions/Stake.ts
|
|
13859
|
-
import { isAddress as
|
|
13680
|
+
import { isAddress as isAddress3, parseEther as parseEther2 } from "viem";
|
|
13860
13681
|
import {
|
|
13861
|
-
ErrorCode as
|
|
13682
|
+
ErrorCode as ErrorCode7,
|
|
13862
13683
|
InternalFailureError as InternalFailureError3,
|
|
13863
|
-
InvalidParameterError as
|
|
13684
|
+
InvalidParameterError as InvalidParameterError7
|
|
13864
13685
|
} from "@funkit/utils";
|
|
13865
13686
|
var getWithdrawQueueInterface = () => {
|
|
13866
13687
|
return new ContractInterface(WITHDRAW_QUEUE_ABI);
|
|
@@ -13880,9 +13701,9 @@ var stakeTransactionParams = async (params, txOptions = globalThis.globalEnvOpti
|
|
|
13880
13701
|
return { to: lidoAddress, value: parseEther2(`${params.amount}`), data: "0x" };
|
|
13881
13702
|
};
|
|
13882
13703
|
var requestUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
13883
|
-
if (!
|
|
13884
|
-
throw new
|
|
13885
|
-
|
|
13704
|
+
if (!isAddress3(params.recipient ?? "")) {
|
|
13705
|
+
throw new InvalidParameterError7(
|
|
13706
|
+
ErrorCode7.InvalidParameter,
|
|
13886
13707
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
13887
13708
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
13888
13709
|
{ params },
|
|
@@ -13898,8 +13719,8 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
|
|
|
13898
13719
|
const steth = getSteth(chainId);
|
|
13899
13720
|
const withdrawalQueue = getWithdrawalQueue(chainId);
|
|
13900
13721
|
if (!steth || !withdrawalQueue || steth.length === 0 || withdrawalQueue.length === 0) {
|
|
13901
|
-
throw new
|
|
13902
|
-
|
|
13722
|
+
throw new InvalidParameterError7(
|
|
13723
|
+
ErrorCode7.ChainNotSupported,
|
|
13903
13724
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
13904
13725
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
13905
13726
|
{ params },
|
|
@@ -13935,9 +13756,9 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
|
|
|
13935
13756
|
);
|
|
13936
13757
|
};
|
|
13937
13758
|
var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
13938
|
-
if (!
|
|
13939
|
-
throw new
|
|
13940
|
-
|
|
13759
|
+
if (!isAddress3(params.recipient ?? "")) {
|
|
13760
|
+
throw new InvalidParameterError7(
|
|
13761
|
+
ErrorCode7.InvalidParameter,
|
|
13941
13762
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
13942
13763
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
13943
13764
|
{ params },
|
|
@@ -13954,8 +13775,8 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
13954
13775
|
);
|
|
13955
13776
|
const readyToWithdrawRequestIds = (await getReadyToWithdrawRequests(params, txOptions)).slice(0, 5);
|
|
13956
13777
|
if (readyToWithdrawRequestIds.length === 0) {
|
|
13957
|
-
throw new
|
|
13958
|
-
|
|
13778
|
+
throw new InvalidParameterError7(
|
|
13779
|
+
ErrorCode7.InvalidParameter,
|
|
13959
13780
|
"Not ready to withdraw requests",
|
|
13960
13781
|
"Not ready to withdraw requests",
|
|
13961
13782
|
{ params },
|
|
@@ -13979,7 +13800,7 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
13979
13800
|
);
|
|
13980
13801
|
if (!hints) {
|
|
13981
13802
|
throw new InternalFailureError3(
|
|
13982
|
-
|
|
13803
|
+
ErrorCode7.CheckPointHintsNotFound,
|
|
13983
13804
|
"lido checkpoint hints are not found when batching the withdrawal",
|
|
13984
13805
|
"",
|
|
13985
13806
|
{ params, readyToWithdrawRequestIds, lastCheckpoint, hints },
|
|
@@ -13994,9 +13815,9 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
13994
13815
|
);
|
|
13995
13816
|
};
|
|
13996
13817
|
var getReadyToWithdrawRequests = async (params, txOptions) => {
|
|
13997
|
-
if (!
|
|
13998
|
-
throw new
|
|
13999
|
-
|
|
13818
|
+
if (!isAddress3(params.recipient ?? "")) {
|
|
13819
|
+
throw new InvalidParameterError7(
|
|
13820
|
+
ErrorCode7.InvalidParameter,
|
|
14000
13821
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14001
13822
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14002
13823
|
{ params },
|
|
@@ -14045,8 +13866,8 @@ var getWithdrawalQueue = (chainId) => {
|
|
|
14045
13866
|
case 36865:
|
|
14046
13867
|
return "0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1";
|
|
14047
13868
|
default:
|
|
14048
|
-
throw new
|
|
14049
|
-
|
|
13869
|
+
throw new InvalidParameterError7(
|
|
13870
|
+
ErrorCode7.ChainNotSupported,
|
|
14050
13871
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14051
13872
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14052
13873
|
{ chainId },
|
|
@@ -14064,8 +13885,8 @@ var getSteth = (chainId) => {
|
|
|
14064
13885
|
case 36865:
|
|
14065
13886
|
return "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
|
|
14066
13887
|
default:
|
|
14067
|
-
throw new
|
|
14068
|
-
|
|
13888
|
+
throw new InvalidParameterError7(
|
|
13889
|
+
ErrorCode7.ChainNotSupported,
|
|
14069
13890
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14070
13891
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14071
13892
|
{ chainId },
|
|
@@ -14076,38 +13897,16 @@ var getSteth = (chainId) => {
|
|
|
14076
13897
|
};
|
|
14077
13898
|
|
|
14078
13899
|
// src/actions/Token.ts
|
|
14079
|
-
import { isAddress as
|
|
14080
|
-
import { ErrorCode as
|
|
14081
|
-
var isERC721TransferParams = (obj) => {
|
|
14082
|
-
return "tokenId" in obj;
|
|
14083
|
-
};
|
|
13900
|
+
import { isAddress as isAddress4, parseEther as parseEther3 } from "viem";
|
|
13901
|
+
import { ErrorCode as ErrorCode8, InvalidParameterError as InvalidParameterError8 } from "@funkit/utils";
|
|
14084
13902
|
var isTokenTransferParams = (obj) => {
|
|
14085
13903
|
return "amount" in obj && "token" in obj && "to" in obj;
|
|
14086
13904
|
};
|
|
14087
|
-
var erc721TransferTransactionParams = async (params, options) => {
|
|
14088
|
-
const { to, tokenId, collection, from } = params;
|
|
14089
|
-
if (!isAddress5(to ?? "") || !isAddress5(from ?? "")) {
|
|
14090
|
-
throw new InvalidParameterError9(
|
|
14091
|
-
ErrorCode9.InvalidParameter,
|
|
14092
|
-
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14093
|
-
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14094
|
-
{ params },
|
|
14095
|
-
"Please make sure it is a valid checksum address",
|
|
14096
|
-
"https://docs.fun.xyz"
|
|
14097
|
-
);
|
|
14098
|
-
}
|
|
14099
|
-
const tokenAddr = isAddress5(collection) ? collection : await NFT.getAddress(collection, options);
|
|
14100
|
-
return ERC721_CONTRACT_INTERFACE.encodeTransactionParams(
|
|
14101
|
-
tokenAddr,
|
|
14102
|
-
"transferFrom",
|
|
14103
|
-
[from, to, tokenId]
|
|
14104
|
-
);
|
|
14105
|
-
};
|
|
14106
13905
|
var tokenTransferTransactionParams = async (params, chain, options) => {
|
|
14107
13906
|
const { to, amount, token } = params;
|
|
14108
|
-
if (!
|
|
14109
|
-
throw new
|
|
14110
|
-
|
|
13907
|
+
if (!isAddress4(to)) {
|
|
13908
|
+
throw new InvalidParameterError8(
|
|
13909
|
+
ErrorCode8.InvalidParameter,
|
|
14111
13910
|
"To address is not a valid address, please make sure it is a valid checksum address.",
|
|
14112
13911
|
"To address is not a valid address, please make sure it is a valid checksum address.",
|
|
14113
13912
|
{ params },
|
|
@@ -14125,8 +13924,8 @@ var tokenTransferTransactionParams = async (params, chain, options) => {
|
|
|
14125
13924
|
}
|
|
14126
13925
|
const tokenAddr = await tokenObj.getAddress(options);
|
|
14127
13926
|
if (!tokenAddr) {
|
|
14128
|
-
throw new
|
|
14129
|
-
|
|
13927
|
+
throw new InvalidParameterError8(
|
|
13928
|
+
ErrorCode8.TokenNotFound,
|
|
14130
13929
|
"Token address not found. Please check the token passed in.",
|
|
14131
13930
|
"Token address not found. Please check the token passed in.",
|
|
14132
13931
|
{ params },
|
|
@@ -14143,9 +13942,9 @@ var tokenTransferTransactionParams = async (params, chain, options) => {
|
|
|
14143
13942
|
};
|
|
14144
13943
|
var tokenTransferFromTransactionParams = async (params, chain, options) => {
|
|
14145
13944
|
const { to, amount, token, from } = params;
|
|
14146
|
-
if (!
|
|
14147
|
-
throw new
|
|
14148
|
-
|
|
13945
|
+
if (!isAddress4(to ?? "") || !isAddress4(from ?? "")) {
|
|
13946
|
+
throw new InvalidParameterError8(
|
|
13947
|
+
ErrorCode8.InvalidParameter,
|
|
14149
13948
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14150
13949
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14151
13950
|
{ params },
|
|
@@ -14163,8 +13962,8 @@ var tokenTransferFromTransactionParams = async (params, chain, options) => {
|
|
|
14163
13962
|
}
|
|
14164
13963
|
const tokenAddr = await tokenObj.getAddress(options);
|
|
14165
13964
|
if (!tokenAddr) {
|
|
14166
|
-
throw new
|
|
14167
|
-
|
|
13965
|
+
throw new InvalidParameterError8(
|
|
13966
|
+
ErrorCode8.TokenNotFound,
|
|
14168
13967
|
"Token address not found. Please check the token passed in.",
|
|
14169
13968
|
"Token address not found. Please check the token passed in.",
|
|
14170
13969
|
{ params },
|
|
@@ -14182,14 +13981,11 @@ var tokenTransferFromTransactionParams = async (params, chain, options) => {
|
|
|
14182
13981
|
var isERC20ApproveParams = (obj) => {
|
|
14183
13982
|
return "amount" in obj && "token" in obj;
|
|
14184
13983
|
};
|
|
14185
|
-
var isERC721ApproveParams = (obj) => {
|
|
14186
|
-
return "tokenId" in obj && "collection" in obj;
|
|
14187
|
-
};
|
|
14188
13984
|
var erc20ApproveTransactionParams = async (params, options) => {
|
|
14189
13985
|
const { spender, amount, token } = params;
|
|
14190
|
-
if (!
|
|
14191
|
-
throw new
|
|
14192
|
-
|
|
13986
|
+
if (!isAddress4(spender ?? "")) {
|
|
13987
|
+
throw new InvalidParameterError8(
|
|
13988
|
+
ErrorCode8.InvalidParameter,
|
|
14193
13989
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14194
13990
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14195
13991
|
{ params },
|
|
@@ -14209,25 +14005,6 @@ var erc20ApproveTransactionParams = async (params, options) => {
|
|
|
14209
14005
|
[spender, convertedAmount]
|
|
14210
14006
|
);
|
|
14211
14007
|
};
|
|
14212
|
-
var erc721ApproveTransactionParams = async (params, options) => {
|
|
14213
|
-
const { spender, tokenId, collection } = params;
|
|
14214
|
-
if (!isAddress5(spender ?? "")) {
|
|
14215
|
-
throw new InvalidParameterError9(
|
|
14216
|
-
ErrorCode9.InvalidParameter,
|
|
14217
|
-
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14218
|
-
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14219
|
-
{ params },
|
|
14220
|
-
"Please make sure it is a valid checksum address",
|
|
14221
|
-
"https://docs.fun.xyz"
|
|
14222
|
-
);
|
|
14223
|
-
}
|
|
14224
|
-
const tokenAddr = isAddress5(collection) ? collection : await NFT.getAddress(collection, options);
|
|
14225
|
-
return ERC721_CONTRACT_INTERFACE.encodeTransactionParams(
|
|
14226
|
-
tokenAddr,
|
|
14227
|
-
"approve",
|
|
14228
|
-
[spender, tokenId]
|
|
14229
|
-
);
|
|
14230
|
-
};
|
|
14231
14008
|
|
|
14232
14009
|
// src/actions/types.ts
|
|
14233
14010
|
var UniswapPoolFeeOptions = /* @__PURE__ */ ((UniswapPoolFeeOptions2) => {
|
|
@@ -14245,7 +14022,7 @@ var SocketSort = /* @__PURE__ */ ((SocketSort2) => {
|
|
|
14245
14022
|
})(SocketSort || {});
|
|
14246
14023
|
|
|
14247
14024
|
// src/config/Config.ts
|
|
14248
|
-
import { ErrorCode as
|
|
14025
|
+
import { ErrorCode as ErrorCode9, InvalidParameterError as InvalidParameterError9 } from "@funkit/utils";
|
|
14249
14026
|
function getEnvOptions() {
|
|
14250
14027
|
return globalThis.globalEnvOption;
|
|
14251
14028
|
}
|
|
@@ -14261,8 +14038,8 @@ async function configureEnvironment(option) {
|
|
|
14261
14038
|
const globalEnvOption = global.globalEnvOption;
|
|
14262
14039
|
globalEnvOption.apiKey = option.apiKey ? option.apiKey : globalEnvOption.apiKey;
|
|
14263
14040
|
if (!globalEnvOption.apiKey) {
|
|
14264
|
-
throw new
|
|
14265
|
-
|
|
14041
|
+
throw new InvalidParameterError9(
|
|
14042
|
+
ErrorCode9.MissingParameter,
|
|
14266
14043
|
"apiKey is required",
|
|
14267
14044
|
"apiKey is required",
|
|
14268
14045
|
{ option },
|
|
@@ -14530,7 +14307,7 @@ var CheckoutSponsor = class extends Sponsor {
|
|
|
14530
14307
|
// src/sponsors/GaslessSponsor.ts
|
|
14531
14308
|
import { concat as concat3 } from "viem";
|
|
14532
14309
|
import { PaymasterType as PaymasterType3 } from "@funkit/api-base";
|
|
14533
|
-
import { ErrorCode as
|
|
14310
|
+
import { ErrorCode as ErrorCode10, ResourceNotFoundError as ResourceNotFoundError5 } from "@funkit/utils";
|
|
14534
14311
|
var GaslessSponsor = class extends Sponsor {
|
|
14535
14312
|
constructor(options = globalThis.globalEnvOption) {
|
|
14536
14313
|
super(
|
|
@@ -14553,7 +14330,7 @@ var GaslessSponsor = class extends Sponsor {
|
|
|
14553
14330
|
);
|
|
14554
14331
|
} else {
|
|
14555
14332
|
throw new ResourceNotFoundError5(
|
|
14556
|
-
|
|
14333
|
+
ErrorCode10.MissingParameter,
|
|
14557
14334
|
"The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
|
|
14558
14335
|
"The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
|
|
14559
14336
|
{
|
|
@@ -14689,8 +14466,8 @@ var GaslessSponsor = class extends Sponsor {
|
|
|
14689
14466
|
import { concat as concat4, encodeAbiParameters as encodeAbiParameters4 } from "viem";
|
|
14690
14467
|
import { PaymasterType as PaymasterType4, addTransaction } from "@funkit/api-base";
|
|
14691
14468
|
import {
|
|
14692
|
-
ErrorCode as
|
|
14693
|
-
InvalidParameterError as
|
|
14469
|
+
ErrorCode as ErrorCode11,
|
|
14470
|
+
InvalidParameterError as InvalidParameterError10,
|
|
14694
14471
|
ResourceNotFoundError as ResourceNotFoundError6
|
|
14695
14472
|
} from "@funkit/utils";
|
|
14696
14473
|
var TokenSponsor = class extends Sponsor {
|
|
@@ -14702,8 +14479,8 @@ var TokenSponsor = class extends Sponsor {
|
|
|
14702
14479
|
PaymasterType4.TokenSponsor
|
|
14703
14480
|
);
|
|
14704
14481
|
if (!options.gasSponsor?.token) {
|
|
14705
|
-
throw new
|
|
14706
|
-
|
|
14482
|
+
throw new InvalidParameterError10(
|
|
14483
|
+
ErrorCode11.MissingParameter,
|
|
14707
14484
|
"token field is missing",
|
|
14708
14485
|
"token field is missing",
|
|
14709
14486
|
{ gasSponsor: options.gasSponsor },
|
|
@@ -14726,7 +14503,7 @@ var TokenSponsor = class extends Sponsor {
|
|
|
14726
14503
|
);
|
|
14727
14504
|
} else {
|
|
14728
14505
|
throw new ResourceNotFoundError6(
|
|
14729
|
-
|
|
14506
|
+
ErrorCode11.MissingParameter,
|
|
14730
14507
|
"The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
|
|
14731
14508
|
"The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
|
|
14732
14509
|
{
|
|
@@ -15175,8 +14952,6 @@ import {
|
|
|
15175
14952
|
createOp,
|
|
15176
14953
|
deleteOp,
|
|
15177
14954
|
executeOp,
|
|
15178
|
-
getAllWalletNFTs,
|
|
15179
|
-
getAllWalletNFTsByChainId,
|
|
15180
14955
|
getAllWalletTokens,
|
|
15181
14956
|
getAllWalletTokensByChainId,
|
|
15182
14957
|
getFullReceipt,
|
|
@@ -15193,23 +14968,23 @@ import {
|
|
|
15193
14968
|
concat as concat6,
|
|
15194
14969
|
createPublicClient as createPublicClient2,
|
|
15195
14970
|
encodeAbiParameters as encodeAbiParameters5,
|
|
15196
|
-
isAddress as
|
|
14971
|
+
isAddress as isAddress5,
|
|
15197
14972
|
isHex as isHex3,
|
|
15198
14973
|
keccak256 as keccak2567,
|
|
15199
14974
|
pad as pad9,
|
|
15200
14975
|
toBytes as toBytes7
|
|
15201
14976
|
} from "viem";
|
|
15202
14977
|
import {
|
|
15203
|
-
ErrorCode as
|
|
14978
|
+
ErrorCode as ErrorCode13,
|
|
15204
14979
|
InternalFailureError as InternalFailureError4,
|
|
15205
|
-
InvalidParameterError as
|
|
14980
|
+
InvalidParameterError as InvalidParameterError12
|
|
15206
14981
|
} from "@funkit/utils";
|
|
15207
14982
|
|
|
15208
14983
|
// src/actions/FirstClassActions.ts
|
|
15209
14984
|
import { pad as pad8 } from "viem";
|
|
15210
14985
|
import {
|
|
15211
|
-
ErrorCode as
|
|
15212
|
-
InvalidParameterError as
|
|
14986
|
+
ErrorCode as ErrorCode12,
|
|
14987
|
+
InvalidParameterError as InvalidParameterError11,
|
|
15213
14988
|
ResourceNotFoundError as ResourceNotFoundError7
|
|
15214
14989
|
} from "@funkit/utils";
|
|
15215
14990
|
|
|
@@ -15282,13 +15057,7 @@ var FirstClassActions = class {
|
|
|
15282
15057
|
txOptions
|
|
15283
15058
|
);
|
|
15284
15059
|
let transactionParams;
|
|
15285
|
-
if (
|
|
15286
|
-
params.from = params.from ? params.from : await this.getAddress(txOptions);
|
|
15287
|
-
transactionParams = await erc721TransferTransactionParams(
|
|
15288
|
-
params,
|
|
15289
|
-
txOptions
|
|
15290
|
-
);
|
|
15291
|
-
} else if (isTokenTransferParams(params)) {
|
|
15060
|
+
if (isTokenTransferParams(params)) {
|
|
15292
15061
|
if (params.from) {
|
|
15293
15062
|
transactionParams = await tokenTransferFromTransactionParams(
|
|
15294
15063
|
params,
|
|
@@ -15303,8 +15072,8 @@ var FirstClassActions = class {
|
|
|
15303
15072
|
);
|
|
15304
15073
|
}
|
|
15305
15074
|
} else {
|
|
15306
|
-
throw new
|
|
15307
|
-
|
|
15075
|
+
throw new InvalidParameterError11(
|
|
15076
|
+
ErrorCode12.InvalidParameter,
|
|
15308
15077
|
"Params were missing or incorrect",
|
|
15309
15078
|
"Params were missing or incorrect",
|
|
15310
15079
|
{ params },
|
|
@@ -15332,14 +15101,9 @@ var FirstClassActions = class {
|
|
|
15332
15101
|
let transactionParams;
|
|
15333
15102
|
if (isERC20ApproveParams(params)) {
|
|
15334
15103
|
transactionParams = await erc20ApproveTransactionParams(params, txOptions);
|
|
15335
|
-
} else if (isERC721ApproveParams(params)) {
|
|
15336
|
-
transactionParams = await erc721ApproveTransactionParams(
|
|
15337
|
-
params,
|
|
15338
|
-
txOptions
|
|
15339
|
-
);
|
|
15340
15104
|
} else {
|
|
15341
|
-
throw new
|
|
15342
|
-
|
|
15105
|
+
throw new InvalidParameterError11(
|
|
15106
|
+
ErrorCode12.InvalidParameter,
|
|
15343
15107
|
"Params were missing or incorrect",
|
|
15344
15108
|
"Params were missing or incorrect",
|
|
15345
15109
|
{ params },
|
|
@@ -15394,8 +15158,8 @@ var FirstClassActions = class {
|
|
|
15394
15158
|
txOptions
|
|
15395
15159
|
);
|
|
15396
15160
|
} else {
|
|
15397
|
-
throw new
|
|
15398
|
-
|
|
15161
|
+
throw new InvalidParameterError11(
|
|
15162
|
+
ErrorCode12.InvalidParameter,
|
|
15399
15163
|
"Params were missing or incorrect",
|
|
15400
15164
|
"Params were missing or incorrect",
|
|
15401
15165
|
{ params },
|
|
@@ -15489,7 +15253,7 @@ var FirstClassActions = class {
|
|
|
15489
15253
|
);
|
|
15490
15254
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15491
15255
|
throw new ResourceNotFoundError7(
|
|
15492
|
-
|
|
15256
|
+
ErrorCode12.GroupNotFound,
|
|
15493
15257
|
"group is not found",
|
|
15494
15258
|
"group is not found",
|
|
15495
15259
|
{ params },
|
|
@@ -15501,8 +15265,8 @@ var FirstClassActions = class {
|
|
|
15501
15265
|
const members = new Set(onChainGroupData.memberIds);
|
|
15502
15266
|
members.add(params.userId);
|
|
15503
15267
|
if (members.size <= originalMembers.size) {
|
|
15504
|
-
throw new
|
|
15505
|
-
|
|
15268
|
+
throw new InvalidParameterError11(
|
|
15269
|
+
ErrorCode12.UserAlreadyExists,
|
|
15506
15270
|
"user already exists in group",
|
|
15507
15271
|
"user already exists in group",
|
|
15508
15272
|
{ params, originalMembers, userId: params.userId },
|
|
@@ -15543,7 +15307,7 @@ var FirstClassActions = class {
|
|
|
15543
15307
|
);
|
|
15544
15308
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15545
15309
|
throw new ResourceNotFoundError7(
|
|
15546
|
-
|
|
15310
|
+
ErrorCode12.GroupNotFound,
|
|
15547
15311
|
"group is not found",
|
|
15548
15312
|
"group is not found",
|
|
15549
15313
|
{ params },
|
|
@@ -15556,7 +15320,7 @@ var FirstClassActions = class {
|
|
|
15556
15320
|
members.delete(params.userId);
|
|
15557
15321
|
if (members.size >= originalMembers.size) {
|
|
15558
15322
|
throw new ResourceNotFoundError7(
|
|
15559
|
-
|
|
15323
|
+
ErrorCode12.UserNotFound,
|
|
15560
15324
|
"user does not exist in group",
|
|
15561
15325
|
"user does not exist in group",
|
|
15562
15326
|
{ params, originalMembers, userId: params.userId },
|
|
@@ -15596,7 +15360,7 @@ var FirstClassActions = class {
|
|
|
15596
15360
|
);
|
|
15597
15361
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15598
15362
|
throw new ResourceNotFoundError7(
|
|
15599
|
-
|
|
15363
|
+
ErrorCode12.GroupNotFound,
|
|
15600
15364
|
"group is not found",
|
|
15601
15365
|
"group is not found",
|
|
15602
15366
|
{ params },
|
|
@@ -15605,8 +15369,8 @@ var FirstClassActions = class {
|
|
|
15605
15369
|
);
|
|
15606
15370
|
}
|
|
15607
15371
|
if (!Number.isInteger(params.threshold) || params.threshold < 1 || params.threshold > onChainGroupData.memberIds.length) {
|
|
15608
|
-
throw new
|
|
15609
|
-
|
|
15372
|
+
throw new InvalidParameterError11(
|
|
15373
|
+
ErrorCode12.InvalidThreshold,
|
|
15610
15374
|
"threshold can not be 0 or bigger than number of members in the group",
|
|
15611
15375
|
"threshold can not be 0 or bigger than number of members in the group",
|
|
15612
15376
|
{ params, memberIds: onChainGroupData.memberIds },
|
|
@@ -15663,11 +15427,11 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15663
15427
|
const chain = globalThis.globalEnvOption.chain;
|
|
15664
15428
|
super(chain);
|
|
15665
15429
|
if (typeof params === "string") {
|
|
15666
|
-
if (
|
|
15430
|
+
if (isAddress5(params)) {
|
|
15667
15431
|
this.address = params;
|
|
15668
15432
|
} else {
|
|
15669
|
-
throw new
|
|
15670
|
-
|
|
15433
|
+
throw new InvalidParameterError12(
|
|
15434
|
+
ErrorCode13.InvalidParameter,
|
|
15671
15435
|
"string input must be an address type",
|
|
15672
15436
|
"string input must be an address type",
|
|
15673
15437
|
params,
|
|
@@ -15678,8 +15442,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15678
15442
|
} else {
|
|
15679
15443
|
const { users, uniqueId } = params;
|
|
15680
15444
|
if (!uniqueId || !isBytes32(uniqueId) || !users || users.length <= 0) {
|
|
15681
|
-
throw new
|
|
15682
|
-
|
|
15445
|
+
throw new InvalidParameterError12(
|
|
15446
|
+
ErrorCode13.InvalidParameter,
|
|
15683
15447
|
"uniqueId must be bytes32 and users must be non-empty",
|
|
15684
15448
|
"uniqueId must be bytes32 and users must be non-empty",
|
|
15685
15449
|
params,
|
|
@@ -15690,8 +15454,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15690
15454
|
this.userInfo = new Map(
|
|
15691
15455
|
users?.map((user) => {
|
|
15692
15456
|
if (!user.userId || !isHex3(user.userId)) {
|
|
15693
|
-
throw new
|
|
15694
|
-
|
|
15457
|
+
throw new InvalidParameterError12(
|
|
15458
|
+
ErrorCode13.InvalidParameter,
|
|
15695
15459
|
"userId is required and must be a hex string",
|
|
15696
15460
|
"userId is required and must be a hex string",
|
|
15697
15461
|
users,
|
|
@@ -15700,8 +15464,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15700
15464
|
);
|
|
15701
15465
|
}
|
|
15702
15466
|
if (user.groupInfo && (!Number.isInteger(user.groupInfo.threshold) || !Array.isArray(user.groupInfo.memberIds) || !user.groupInfo.memberIds.every((memberId) => isHex3(memberId)))) {
|
|
15703
|
-
throw new
|
|
15704
|
-
|
|
15467
|
+
throw new InvalidParameterError12(
|
|
15468
|
+
ErrorCode13.InvalidParameter,
|
|
15705
15469
|
"groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
|
|
15706
15470
|
"groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
|
|
15707
15471
|
users,
|
|
@@ -15802,38 +15566,6 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15802
15566
|
signal: options?.signal
|
|
15803
15567
|
});
|
|
15804
15568
|
}
|
|
15805
|
-
/**
|
|
15806
|
-
* Given an address and a chain, returns all NFTs owned by that address
|
|
15807
|
-
* @param {string} chainId string version of the chainId or ALL. If empty, then default to the one in globalEnvOption
|
|
15808
|
-
* @returns array
|
|
15809
|
-
*/
|
|
15810
|
-
async getNFTs(chainIdInput, options) {
|
|
15811
|
-
let chainId;
|
|
15812
|
-
if (!chainIdInput) {
|
|
15813
|
-
const chain = await Chain.getChain(
|
|
15814
|
-
{
|
|
15815
|
-
chainIdentifier: globalThis.globalEnvOption.chain
|
|
15816
|
-
},
|
|
15817
|
-
options
|
|
15818
|
-
);
|
|
15819
|
-
chainId = await chain.getChainId(options);
|
|
15820
|
-
} else {
|
|
15821
|
-
chainId = chainIdInput;
|
|
15822
|
-
}
|
|
15823
|
-
const walletAddress = await this.getAddress(options);
|
|
15824
|
-
return chainId === "ALL" ? await getAllWalletNFTs({
|
|
15825
|
-
walletAddress,
|
|
15826
|
-
apiKey: globalThis.globalEnvOption.apiKey,
|
|
15827
|
-
logger: options?.logger,
|
|
15828
|
-
signal: options?.signal
|
|
15829
|
-
}) : await getAllWalletNFTsByChainId({
|
|
15830
|
-
chainId,
|
|
15831
|
-
walletAddress,
|
|
15832
|
-
apiKey: globalThis.globalEnvOption.apiKey,
|
|
15833
|
-
logger: options?.logger,
|
|
15834
|
-
signal: options?.signal
|
|
15835
|
-
});
|
|
15836
|
-
}
|
|
15837
15569
|
async getLidoWithdrawals(options) {
|
|
15838
15570
|
const walletAddress = await this.getAddress(options);
|
|
15839
15571
|
return await getWalletLidoWithdrawalsByChainId({
|
|
@@ -16082,8 +15814,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16082
15814
|
*/
|
|
16083
15815
|
async createOperation(auth, userId, transactionParams, txOptions = globalThis.globalEnvOption) {
|
|
16084
15816
|
if (!userId || userId === "") {
|
|
16085
|
-
throw new
|
|
16086
|
-
|
|
15817
|
+
throw new InvalidParameterError12(
|
|
15818
|
+
ErrorCode13.MissingParameter,
|
|
16087
15819
|
"userId is required",
|
|
16088
15820
|
"userId is required",
|
|
16089
15821
|
{ userId },
|
|
@@ -16314,8 +16046,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16314
16046
|
collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
|
|
16315
16047
|
}
|
|
16316
16048
|
if (collectedSigCount < threshold) {
|
|
16317
|
-
throw new
|
|
16318
|
-
|
|
16049
|
+
throw new InvalidParameterError12(
|
|
16050
|
+
ErrorCode13.InsufficientSignatures,
|
|
16319
16051
|
"Signatures are not sufficient to execute the operation",
|
|
16320
16052
|
"Signatures are not sufficient to execute the operation",
|
|
16321
16053
|
{ threshold, collectedSigCount, chainId },
|
|
@@ -16324,8 +16056,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16324
16056
|
);
|
|
16325
16057
|
}
|
|
16326
16058
|
} else {
|
|
16327
|
-
throw new
|
|
16328
|
-
|
|
16059
|
+
throw new InvalidParameterError12(
|
|
16060
|
+
ErrorCode13.InsufficientSignatures,
|
|
16329
16061
|
"Signatures are not sufficient to execute the operation",
|
|
16330
16062
|
"Signatures are not sufficient to execute the operation",
|
|
16331
16063
|
{ threshold, chainId, skipDBAction: finalTxOptions.skipDBAction },
|
|
@@ -16486,8 +16218,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16486
16218
|
collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
|
|
16487
16219
|
}
|
|
16488
16220
|
if (collectedSigCount < threshold) {
|
|
16489
|
-
throw new
|
|
16490
|
-
|
|
16221
|
+
throw new InvalidParameterError12(
|
|
16222
|
+
ErrorCode13.InsufficientSignatures,
|
|
16491
16223
|
"Signatures are not sufficient to execute the operation",
|
|
16492
16224
|
"Signatures are not sufficient to execute the operation",
|
|
16493
16225
|
{ threshold, collectedSigCount, chainId },
|
|
@@ -16496,8 +16228,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16496
16228
|
);
|
|
16497
16229
|
}
|
|
16498
16230
|
} else {
|
|
16499
|
-
throw new
|
|
16500
|
-
|
|
16231
|
+
throw new InvalidParameterError12(
|
|
16232
|
+
ErrorCode13.InsufficientSignatures,
|
|
16501
16233
|
"Signatures are not sufficient to execute the operation",
|
|
16502
16234
|
"Signatures are not sufficient to execute the operation",
|
|
16503
16235
|
{ threshold, chainId, skipDBAction: finalTxOptions.skipDBAction },
|
|
@@ -16543,7 +16275,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16543
16275
|
}
|
|
16544
16276
|
if (!finalOperation.opId) {
|
|
16545
16277
|
throw new InternalFailureError4(
|
|
16546
|
-
|
|
16278
|
+
ErrorCode13.ServerFailure,
|
|
16547
16279
|
"Operation id is required",
|
|
16548
16280
|
"",
|
|
16549
16281
|
finalOperation,
|
|
@@ -16704,8 +16436,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16704
16436
|
options.fee.token = options.gasSponsor.token;
|
|
16705
16437
|
}
|
|
16706
16438
|
if (!options.fee.token) {
|
|
16707
|
-
throw new
|
|
16708
|
-
|
|
16439
|
+
throw new InvalidParameterError12(
|
|
16440
|
+
ErrorCode13.MissingParameter,
|
|
16709
16441
|
"EnvOption.fee.token or EnvOption.gasSponsor.token is required",
|
|
16710
16442
|
"EnvOption.fee.token or EnvOption.gasSponsor.token is required",
|
|
16711
16443
|
{ options },
|
|
@@ -16714,8 +16446,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16714
16446
|
);
|
|
16715
16447
|
}
|
|
16716
16448
|
if (!options.fee.recipient) {
|
|
16717
|
-
throw new
|
|
16718
|
-
|
|
16449
|
+
throw new InvalidParameterError12(
|
|
16450
|
+
ErrorCode13.MissingParameter,
|
|
16719
16451
|
"EnvOption.fee.recipient is required",
|
|
16720
16452
|
"EnvOption.fee.recipient is required",
|
|
16721
16453
|
{ options },
|
|
@@ -16729,8 +16461,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16729
16461
|
);
|
|
16730
16462
|
const token = new Token(options.fee.token, chain);
|
|
16731
16463
|
if (options.fee.gasPercent && !token.isNative) {
|
|
16732
|
-
throw new
|
|
16733
|
-
|
|
16464
|
+
throw new InvalidParameterError12(
|
|
16465
|
+
ErrorCode13.InvalidParameterCombination,
|
|
16734
16466
|
"GasPercent is only valid for native tokens",
|
|
16735
16467
|
"GasPercent is only valid for native tokens",
|
|
16736
16468
|
{ options },
|
|
@@ -16764,8 +16496,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16764
16496
|
Number(gasUsed) * options.fee.gasPercent / 100
|
|
16765
16497
|
);
|
|
16766
16498
|
} else {
|
|
16767
|
-
throw new
|
|
16768
|
-
|
|
16499
|
+
throw new InvalidParameterError12(
|
|
16500
|
+
ErrorCode13.MissingParameter,
|
|
16769
16501
|
"EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
|
|
16770
16502
|
"EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
|
|
16771
16503
|
{ options },
|
|
@@ -16831,7 +16563,6 @@ export {
|
|
|
16831
16563
|
GaslessSponsor,
|
|
16832
16564
|
HashZero,
|
|
16833
16565
|
InvalidActionError,
|
|
16834
|
-
NFT,
|
|
16835
16566
|
OPTIMISM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
|
|
16836
16567
|
Operation,
|
|
16837
16568
|
RBAC_CONTRACT_INTERFACE,
|
|
@@ -16871,8 +16602,6 @@ export {
|
|
|
16871
16602
|
encodeUserAuthInitData,
|
|
16872
16603
|
encodeWalletSignature,
|
|
16873
16604
|
erc20ApproveTransactionParams,
|
|
16874
|
-
erc721ApproveTransactionParams,
|
|
16875
|
-
erc721TransferTransactionParams,
|
|
16876
16605
|
finishUnstakeTransactionParams,
|
|
16877
16606
|
fundWallet,
|
|
16878
16607
|
gasSpecificChain,
|
|
@@ -16899,8 +16628,6 @@ export {
|
|
|
16899
16628
|
isAddress,
|
|
16900
16629
|
isContract,
|
|
16901
16630
|
isERC20ApproveParams,
|
|
16902
|
-
isERC721ApproveParams,
|
|
16903
|
-
isERC721TransferParams,
|
|
16904
16631
|
isFinishUnstakeParams,
|
|
16905
16632
|
isGroupOperation,
|
|
16906
16633
|
isRequestUnstakeParams,
|