@funkit/core 2.3.7 → 2.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +99 -258
- package/dist/index.js.map +4 -4
- package/dist/src/utils/ApiUtils.d.ts +1 -7
- package/dist/src/utils/UserOpUtils.d.ts +0 -6
- package/dist/src/utils/index.d.ts +1 -0
- package/package.json +3 -3
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 ErrorCode7, InvalidParameterError as InvalidParameterError7 } from "@funkit/utils";
|
|
4
4
|
|
|
5
5
|
// src/auth/Auth.ts
|
|
6
6
|
import {
|
|
@@ -19,7 +19,7 @@ import {
|
|
|
19
19
|
getUserWalletsByAddr
|
|
20
20
|
} from "@funkit/api-base";
|
|
21
21
|
import {
|
|
22
|
-
ErrorCode as
|
|
22
|
+
ErrorCode as ErrorCode6,
|
|
23
23
|
InvalidParameterError as InvalidParameterError6,
|
|
24
24
|
ResourceNotFoundError as ResourceNotFoundError4
|
|
25
25
|
} from "@funkit/utils";
|
|
@@ -11498,23 +11498,19 @@ import {
|
|
|
11498
11498
|
} from "@funkit/api-base";
|
|
11499
11499
|
import { FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO } from "@funkit/chains";
|
|
11500
11500
|
import {
|
|
11501
|
-
ErrorCode as
|
|
11502
|
-
InternalFailureError
|
|
11501
|
+
ErrorCode as ErrorCode3,
|
|
11502
|
+
InternalFailureError,
|
|
11503
11503
|
InvalidParameterError as InvalidParameterError3,
|
|
11504
11504
|
ResourceNotFoundError as ResourceNotFoundError3
|
|
11505
11505
|
} from "@funkit/utils";
|
|
11506
11506
|
|
|
11507
|
+
// src/utils/index.ts
|
|
11508
|
+
import { toHex as toHex3 } from "viem";
|
|
11509
|
+
|
|
11507
11510
|
// src/utils/ApiUtils.ts
|
|
11508
11511
|
import {
|
|
11509
|
-
retry
|
|
11510
|
-
} from "@lifeomic/attempt";
|
|
11511
|
-
import {
|
|
11512
|
-
AccessDeniedError,
|
|
11513
|
-
ErrorCode,
|
|
11514
|
-
InternalFailureError,
|
|
11515
11512
|
InvalidParameterError,
|
|
11516
11513
|
ResourceNotFoundError,
|
|
11517
|
-
ThrottlingError,
|
|
11518
11514
|
UserOpFailureError
|
|
11519
11515
|
} from "@funkit/utils";
|
|
11520
11516
|
var errorHandler = (err, context) => {
|
|
@@ -11536,128 +11532,6 @@ var DEFAULT_RETRY_OPTIONS = {
|
|
|
11536
11532
|
beforeAttempt: null,
|
|
11537
11533
|
calculateDelay: null
|
|
11538
11534
|
};
|
|
11539
|
-
var sendRequest = async (uri, method, {
|
|
11540
|
-
apiKey,
|
|
11541
|
-
body,
|
|
11542
|
-
retryOptions,
|
|
11543
|
-
signal
|
|
11544
|
-
}) => {
|
|
11545
|
-
try {
|
|
11546
|
-
const headers = {
|
|
11547
|
-
"Content-Type": "application/json"
|
|
11548
|
-
};
|
|
11549
|
-
if (apiKey) {
|
|
11550
|
-
headers["X-Api-Key"] = apiKey;
|
|
11551
|
-
}
|
|
11552
|
-
const finalRetryOptions = {
|
|
11553
|
-
...DEFAULT_RETRY_OPTIONS,
|
|
11554
|
-
...retryOptions || {}
|
|
11555
|
-
};
|
|
11556
|
-
return retry(async () => {
|
|
11557
|
-
const response = await fetch(uri, {
|
|
11558
|
-
method,
|
|
11559
|
-
headers,
|
|
11560
|
-
redirect: "follow",
|
|
11561
|
-
body: method !== "GET" ? stringify(body) : void 0,
|
|
11562
|
-
signal
|
|
11563
|
-
});
|
|
11564
|
-
const json = await response.json();
|
|
11565
|
-
if (response.ok) {
|
|
11566
|
-
return json;
|
|
11567
|
-
}
|
|
11568
|
-
if (response.status === 400) {
|
|
11569
|
-
throw new InvalidParameterError(
|
|
11570
|
-
ErrorCode.InvalidParameter,
|
|
11571
|
-
`bad request ${JSON.stringify(json)}`,
|
|
11572
|
-
`bad request ${JSON.stringify(json)}`,
|
|
11573
|
-
{ body },
|
|
11574
|
-
"check the api call parameters. its mostly because some call parameters are wrong",
|
|
11575
|
-
"https://docs.fun.xyz"
|
|
11576
|
-
);
|
|
11577
|
-
}
|
|
11578
|
-
if (response.status === 403) {
|
|
11579
|
-
throw new AccessDeniedError(
|
|
11580
|
-
ErrorCode.Unauthorized,
|
|
11581
|
-
"Invalid API key or insufficient access.",
|
|
11582
|
-
"Invalid API key or insufficient access.",
|
|
11583
|
-
{ apiKey },
|
|
11584
|
-
"Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
|
|
11585
|
-
"https://docs.fun.xyz"
|
|
11586
|
-
);
|
|
11587
|
-
}
|
|
11588
|
-
if (response.status === 404) {
|
|
11589
|
-
throw new ResourceNotFoundError(
|
|
11590
|
-
ErrorCode.ServerMissingData,
|
|
11591
|
-
JSON.stringify(json),
|
|
11592
|
-
JSON.stringify(json),
|
|
11593
|
-
{ body },
|
|
11594
|
-
"check the api call parameters. its mostly because some call parameters are wrong",
|
|
11595
|
-
"https://docs.fun.xyz"
|
|
11596
|
-
);
|
|
11597
|
-
}
|
|
11598
|
-
if (response.status === 429) {
|
|
11599
|
-
throw new ThrottlingError(
|
|
11600
|
-
ErrorCode.RequestLimitExceeded,
|
|
11601
|
-
`too many requests ${JSON.stringify(json)}`,
|
|
11602
|
-
`too many requests ${JSON.stringify(json)}`,
|
|
11603
|
-
{ body },
|
|
11604
|
-
"you are making too many requests. please slow down. Reach out to fun team if you need more quota",
|
|
11605
|
-
"https://docs.fun.xyz"
|
|
11606
|
-
);
|
|
11607
|
-
}
|
|
11608
|
-
if (response.status === 500) {
|
|
11609
|
-
if (json.errorCode === ErrorCode.UserOpFailureError) {
|
|
11610
|
-
throw new UserOpFailureError(
|
|
11611
|
-
ErrorCode.UserOpFailureError,
|
|
11612
|
-
JSON.stringify(json),
|
|
11613
|
-
JSON.stringify(json),
|
|
11614
|
-
{ body },
|
|
11615
|
-
"fix user op failure. Most of the time this is due to invalid parameters",
|
|
11616
|
-
"https://docs.fun.xyz"
|
|
11617
|
-
);
|
|
11618
|
-
}
|
|
11619
|
-
throw new InternalFailureError(
|
|
11620
|
-
ErrorCode.ServerFailure,
|
|
11621
|
-
`server failure ${JSON.stringify(json)}`,
|
|
11622
|
-
json.errorMsg,
|
|
11623
|
-
{ body },
|
|
11624
|
-
"retry later. if it still fails, please contact us.",
|
|
11625
|
-
"https://docs.fun.xyz"
|
|
11626
|
-
);
|
|
11627
|
-
}
|
|
11628
|
-
if (response.status === 504) {
|
|
11629
|
-
throw new InternalFailureError(
|
|
11630
|
-
ErrorCode.ServerTimeout,
|
|
11631
|
-
`server timeout failure ${JSON.stringify(json)}`,
|
|
11632
|
-
json.errorMsg,
|
|
11633
|
-
{ body },
|
|
11634
|
-
"retry later. if it still fails, please contact us.",
|
|
11635
|
-
"https://docs.fun.xyz"
|
|
11636
|
-
);
|
|
11637
|
-
}
|
|
11638
|
-
if (!response.ok) {
|
|
11639
|
-
throw new InternalFailureError(
|
|
11640
|
-
ErrorCode.UnknownServerError,
|
|
11641
|
-
`unknown server failure ${JSON.stringify(json)}`,
|
|
11642
|
-
json.errorMsg,
|
|
11643
|
-
{ body },
|
|
11644
|
-
"retry later. if it still fails, please contact us.",
|
|
11645
|
-
"https://docs.fun.xyz"
|
|
11646
|
-
);
|
|
11647
|
-
}
|
|
11648
|
-
return {};
|
|
11649
|
-
}, finalRetryOptions);
|
|
11650
|
-
} catch (err) {
|
|
11651
|
-
throw new InternalFailureError(
|
|
11652
|
-
ErrorCode.ServerConnectionError,
|
|
11653
|
-
`Cannot connect to Fun API Service ${err}`,
|
|
11654
|
-
"",
|
|
11655
|
-
{ body },
|
|
11656
|
-
"retry later. if it still fails, please contact us.",
|
|
11657
|
-
"https://docs.fun.xyz"
|
|
11658
|
-
);
|
|
11659
|
-
}
|
|
11660
|
-
};
|
|
11661
11535
|
|
|
11662
11536
|
// src/utils/AuthUtils.ts
|
|
11663
11537
|
import { v4 as uuidv4 } from "uuid";
|
|
@@ -11688,7 +11562,7 @@ var generatePrivateKey = () => {
|
|
|
11688
11562
|
};
|
|
11689
11563
|
|
|
11690
11564
|
// src/utils/ChainUtils.ts
|
|
11691
|
-
import { getAssetFromFaucet } from "@funkit/api-base";
|
|
11565
|
+
import { getAssetFromFaucet, sendGetRequest } from "@funkit/api-base";
|
|
11692
11566
|
import {
|
|
11693
11567
|
concat,
|
|
11694
11568
|
decodeAbiParameters,
|
|
@@ -11700,7 +11574,7 @@ import {
|
|
|
11700
11574
|
toBytes,
|
|
11701
11575
|
toHex
|
|
11702
11576
|
} from "viem";
|
|
11703
|
-
import { ErrorCode
|
|
11577
|
+
import { ErrorCode, InvalidParameterError as InvalidParameterError2 } from "@funkit/utils";
|
|
11704
11578
|
var isAddress = (address) => {
|
|
11705
11579
|
try {
|
|
11706
11580
|
const [decodedAddr] = decodeAbiParameters(
|
|
@@ -11812,14 +11686,18 @@ var getPermitHash = (token, to, amount, nonce, walletAddr, chainId) => {
|
|
|
11812
11686
|
return keccak256(concat([DOMAIN_SEPARATOR, PERMIT_HASH]));
|
|
11813
11687
|
};
|
|
11814
11688
|
var getGasStation = async (gasStationUrl, options) => {
|
|
11815
|
-
return await
|
|
11689
|
+
return await sendGetRequest({
|
|
11690
|
+
uri: gasStationUrl,
|
|
11691
|
+
apiKey: globalThis.globalEnvOption.apiKey,
|
|
11692
|
+
signal: options?.signal
|
|
11693
|
+
});
|
|
11816
11694
|
};
|
|
11817
11695
|
var useFaucet = async (chainIdentifier, wallet, txOptions) => {
|
|
11818
11696
|
const chain = await Chain.getChain({ chainIdentifier }, txOptions);
|
|
11819
11697
|
const chainName = await chain.getChainName(txOptions);
|
|
11820
11698
|
if (chainName !== "goerli") {
|
|
11821
11699
|
throw new InvalidParameterError2(
|
|
11822
|
-
|
|
11700
|
+
ErrorCode.InvalidChainIdentifier,
|
|
11823
11701
|
"Only Goerli is supported",
|
|
11824
11702
|
"Only Goerli is supported",
|
|
11825
11703
|
chainIdentifier,
|
|
@@ -11889,13 +11767,7 @@ var getPaymasterType = (txOptions) => {
|
|
|
11889
11767
|
};
|
|
11890
11768
|
|
|
11891
11769
|
// src/utils/UserOpUtils.ts
|
|
11892
|
-
import {
|
|
11893
|
-
encodeAbiParameters as encodeAbiParameters2,
|
|
11894
|
-
formatUnits,
|
|
11895
|
-
keccak256 as keccak2562,
|
|
11896
|
-
toBytes as toBytes2,
|
|
11897
|
-
toHex as toHex2
|
|
11898
|
-
} from "viem";
|
|
11770
|
+
import { encodeAbiParameters as encodeAbiParameters2, keccak256 as keccak2562, toBytes as toBytes2, toHex as toHex2 } from "viem";
|
|
11899
11771
|
var calcPreVerificationGas = (userOp) => {
|
|
11900
11772
|
const ov = DefaultGasOverheads;
|
|
11901
11773
|
const p = Object.assign(
|
|
@@ -11935,44 +11807,6 @@ function packUserOp(op, forSignature = true) {
|
|
|
11935
11807
|
}));
|
|
11936
11808
|
return encode(typevalues, forSignature);
|
|
11937
11809
|
}
|
|
11938
|
-
async function gasCalculation(txid, chain, options) {
|
|
11939
|
-
if (!txid || txid === "0x")
|
|
11940
|
-
return { gasUsed: "-1", opFee: "-1", opFeeUSD: "-1" };
|
|
11941
|
-
const provider = await chain.getClient(options);
|
|
11942
|
-
const txReceipt = await provider.waitForTransactionReceipt({
|
|
11943
|
-
hash: txid
|
|
11944
|
-
});
|
|
11945
|
-
const gasUsed = txReceipt.gasUsed;
|
|
11946
|
-
const gasPrice = txReceipt.effectiveGasPrice;
|
|
11947
|
-
const opFee = gasUsed * gasPrice;
|
|
11948
|
-
const chainPrice = BigInt(
|
|
11949
|
-
Math.ceil(
|
|
11950
|
-
await getPriceData(await chain.getCurrency(options), options) * 100
|
|
11951
|
-
)
|
|
11952
|
-
);
|
|
11953
|
-
const opFeeUSD = opFee * BigInt(chainPrice);
|
|
11954
|
-
return {
|
|
11955
|
-
gasUsed: gasUsed.toString(),
|
|
11956
|
-
opFee: formatUnits(opFee, 18).toString(),
|
|
11957
|
-
opFeeUSD: formatUnits(opFeeUSD, 20).toString()
|
|
11958
|
-
};
|
|
11959
|
-
}
|
|
11960
|
-
var PRICE_URL = "https://min-api.cryptocompare.com/data/price";
|
|
11961
|
-
async function getPriceData(chainCurrency, options) {
|
|
11962
|
-
const data = await sendRequest(
|
|
11963
|
-
`${PRICE_URL}?fsym=${chainCurrency}&tsyms=USD`,
|
|
11964
|
-
"GET",
|
|
11965
|
-
{ signal: options?.signal }
|
|
11966
|
-
);
|
|
11967
|
-
return data.USD;
|
|
11968
|
-
}
|
|
11969
|
-
var stringify = (object) => {
|
|
11970
|
-
return JSON.stringify(
|
|
11971
|
-
object,
|
|
11972
|
-
(_, value) => typeof value === "bigint" ? toHex2(value) : value
|
|
11973
|
-
// return everything else unchanged
|
|
11974
|
-
);
|
|
11975
|
-
};
|
|
11976
11810
|
var DefaultGasOverheads = {
|
|
11977
11811
|
fixed: 28e3,
|
|
11978
11812
|
perUserOp: 18300,
|
|
@@ -12075,7 +11909,7 @@ async function getOpHash(chain, userOp, options) {
|
|
|
12075
11909
|
|
|
12076
11910
|
// src/utils/TokenUtils.ts
|
|
12077
11911
|
import { getAssetErc20ByChainAndSymbol } from "@funkit/api-base";
|
|
12078
|
-
import { ErrorCode as
|
|
11912
|
+
import { ErrorCode as ErrorCode2, ResourceNotFoundError as ResourceNotFoundError2 } from "@funkit/utils";
|
|
12079
11913
|
async function getTokenAddressBySymbolAndChainId(inputSymbol, inputChainId, options) {
|
|
12080
11914
|
const normalizedSymbol = inputSymbol.toLowerCase();
|
|
12081
11915
|
if (BASE_WRAP_TOKEN_ADDR?.[inputChainId]?.[normalizedSymbol]) {
|
|
@@ -12092,7 +11926,7 @@ async function getTokenAddressBySymbolAndChainId(inputSymbol, inputChainId, opti
|
|
|
12092
11926
|
return tokenInfo.address;
|
|
12093
11927
|
}
|
|
12094
11928
|
throw new ResourceNotFoundError2(
|
|
12095
|
-
|
|
11929
|
+
ErrorCode2.TokenNotFound,
|
|
12096
11930
|
"token symbol does not exist on provided chain",
|
|
12097
11931
|
"token symbol does not exist on provided chain",
|
|
12098
11932
|
{ symbol: inputSymbol, chainId: inputChainId },
|
|
@@ -12161,6 +11995,15 @@ var isSignatureMissing = (userId, signatures) => {
|
|
|
12161
11995
|
return sigMissing;
|
|
12162
11996
|
};
|
|
12163
11997
|
|
|
11998
|
+
// src/utils/index.ts
|
|
11999
|
+
var stringify = (object) => {
|
|
12000
|
+
return JSON.stringify(
|
|
12001
|
+
object,
|
|
12002
|
+
(_, value) => typeof value === "bigint" ? toHex3(value) : value
|
|
12003
|
+
// return everything else unchanged
|
|
12004
|
+
);
|
|
12005
|
+
};
|
|
12006
|
+
|
|
12164
12007
|
// src/data/Chain.ts
|
|
12165
12008
|
var Chain = class _Chain {
|
|
12166
12009
|
constructor(chainInput) {
|
|
@@ -12168,7 +12011,7 @@ var Chain = class _Chain {
|
|
|
12168
12011
|
this.addresses = {};
|
|
12169
12012
|
if (!chainInput.chainIdentifier && !chainInput.rpcUrl) {
|
|
12170
12013
|
throw new InvalidParameterError3(
|
|
12171
|
-
|
|
12014
|
+
ErrorCode3.InvalidChainIdentifier,
|
|
12172
12015
|
"valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
|
|
12173
12016
|
"valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
|
|
12174
12017
|
{ chainInput },
|
|
@@ -12275,7 +12118,7 @@ var Chain = class _Chain {
|
|
|
12275
12118
|
const res = this.addresses[name];
|
|
12276
12119
|
if (!res) {
|
|
12277
12120
|
throw new ResourceNotFoundError3(
|
|
12278
|
-
|
|
12121
|
+
ErrorCode3.AddressNotFound,
|
|
12279
12122
|
"address not found",
|
|
12280
12123
|
"address not found",
|
|
12281
12124
|
{ name },
|
|
@@ -12315,8 +12158,8 @@ var Chain = class _Chain {
|
|
|
12315
12158
|
async estimateOpGas(partialOp, options) {
|
|
12316
12159
|
await this.init(options);
|
|
12317
12160
|
if (!this.addresses || !this.addresses.entryPointAddress) {
|
|
12318
|
-
throw new
|
|
12319
|
-
|
|
12161
|
+
throw new InternalFailureError(
|
|
12162
|
+
ErrorCode3.AddressNotFound,
|
|
12320
12163
|
"entryPointAddress is required",
|
|
12321
12164
|
"",
|
|
12322
12165
|
{ partialOp },
|
|
@@ -12402,13 +12245,13 @@ var Chain = class _Chain {
|
|
|
12402
12245
|
// src/data/NFT.ts
|
|
12403
12246
|
import { isAddress as isAddress2 } from "viem";
|
|
12404
12247
|
import { getNftAddress, getNftName } from "@funkit/api-base";
|
|
12405
|
-
import { ErrorCode as
|
|
12248
|
+
import { ErrorCode as ErrorCode4, InvalidParameterError as InvalidParameterError4 } from "@funkit/utils";
|
|
12406
12249
|
var NFT = class _NFT {
|
|
12407
12250
|
constructor(input) {
|
|
12408
12251
|
this.name = "";
|
|
12409
12252
|
if (!input) {
|
|
12410
12253
|
throw new InvalidParameterError4(
|
|
12411
|
-
|
|
12254
|
+
ErrorCode4.InvalidNFTIdentifier,
|
|
12412
12255
|
"valid NFT identifier is required, could be address or name",
|
|
12413
12256
|
"valid NFT identifier is required, could be address or name",
|
|
12414
12257
|
{ input },
|
|
@@ -12463,7 +12306,7 @@ var NFT = class _NFT {
|
|
|
12463
12306
|
if (!this.address) {
|
|
12464
12307
|
if (!this.name) {
|
|
12465
12308
|
throw new InvalidParameterError4(
|
|
12466
|
-
|
|
12309
|
+
ErrorCode4.InvalidNFTIdentifier,
|
|
12467
12310
|
"valid NFT identifier is required, could be address or name",
|
|
12468
12311
|
"valid NFT identifier is required, could be address or name",
|
|
12469
12312
|
{},
|
|
@@ -12748,10 +12591,10 @@ function toBytes32Arr(data) {
|
|
|
12748
12591
|
}
|
|
12749
12592
|
|
|
12750
12593
|
// src/data/Token.ts
|
|
12751
|
-
import { formatUnits
|
|
12594
|
+
import { formatUnits, isAddress as isAddress3, parseUnits } from "viem";
|
|
12752
12595
|
import {
|
|
12753
|
-
ErrorCode as
|
|
12754
|
-
InternalFailureError as
|
|
12596
|
+
ErrorCode as ErrorCode5,
|
|
12597
|
+
InternalFailureError as InternalFailureError2,
|
|
12755
12598
|
InvalidParameterError as InvalidParameterError5
|
|
12756
12599
|
} from "@funkit/utils";
|
|
12757
12600
|
var wrappedNativeTokens = {
|
|
@@ -12794,8 +12637,8 @@ var Token = class _Token {
|
|
|
12794
12637
|
options
|
|
12795
12638
|
);
|
|
12796
12639
|
}
|
|
12797
|
-
throw new
|
|
12798
|
-
|
|
12640
|
+
throw new InternalFailureError2(
|
|
12641
|
+
ErrorCode5.ServerMissingData,
|
|
12799
12642
|
"server missing token symbol and address info",
|
|
12800
12643
|
"",
|
|
12801
12644
|
{ symbol: this.symbol, address: this.address, isNative: this.isNative },
|
|
@@ -12818,7 +12661,7 @@ var Token = class _Token {
|
|
|
12818
12661
|
async getBalance(address, options) {
|
|
12819
12662
|
const amount = await this.getBalanceBN(address, options);
|
|
12820
12663
|
const decimals = await this.getDecimals(options);
|
|
12821
|
-
return
|
|
12664
|
+
return formatUnits(amount, Number(decimals));
|
|
12822
12665
|
}
|
|
12823
12666
|
async getBalanceBN(address, options) {
|
|
12824
12667
|
const chain = this.chain;
|
|
@@ -12840,7 +12683,7 @@ var Token = class _Token {
|
|
|
12840
12683
|
async getApproval(owner, spender, options) {
|
|
12841
12684
|
if (this.isNative) {
|
|
12842
12685
|
throw new InvalidParameterError5(
|
|
12843
|
-
|
|
12686
|
+
ErrorCode5.InvalidParameter,
|
|
12844
12687
|
"Native token can not approve",
|
|
12845
12688
|
"Native token can not approve",
|
|
12846
12689
|
{ isNative: this.isNative },
|
|
@@ -13284,7 +13127,7 @@ var Auth = class {
|
|
|
13284
13127
|
privateKey = `0x${authInput.privateKey}`;
|
|
13285
13128
|
} else {
|
|
13286
13129
|
throw new InvalidParameterError6(
|
|
13287
|
-
|
|
13130
|
+
ErrorCode6.InvalidParameter,
|
|
13288
13131
|
"privateKey is not a valid one",
|
|
13289
13132
|
"privateKey is not a valid one",
|
|
13290
13133
|
authInput.privateKey,
|
|
@@ -13295,7 +13138,7 @@ var Auth = class {
|
|
|
13295
13138
|
this.signer = privateKeyToAccount(privateKey);
|
|
13296
13139
|
} else {
|
|
13297
13140
|
throw new InvalidParameterError6(
|
|
13298
|
-
|
|
13141
|
+
ErrorCode6.MissingParameter,
|
|
13299
13142
|
"valid authInput is required",
|
|
13300
13143
|
"valid authInput is required",
|
|
13301
13144
|
authInput,
|
|
@@ -13421,7 +13264,7 @@ var Auth = class {
|
|
|
13421
13264
|
const { value = 0n } = txData;
|
|
13422
13265
|
if (!chain || !chainId) {
|
|
13423
13266
|
throw new InvalidParameterError6(
|
|
13424
|
-
|
|
13267
|
+
ErrorCode6.MissingParameter,
|
|
13425
13268
|
"chain object is missing or incorrect",
|
|
13426
13269
|
"chain object is missing or incorrect",
|
|
13427
13270
|
{ options, chainId },
|
|
@@ -13809,7 +13652,7 @@ var createTargetSelectorMerkleTree = (params) => {
|
|
|
13809
13652
|
var createSessionKeyTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
13810
13653
|
if (params.targetWhitelist.length === 0) {
|
|
13811
13654
|
throw new InvalidParameterError7(
|
|
13812
|
-
|
|
13655
|
+
ErrorCode7.MissingParameter,
|
|
13813
13656
|
"targetWhitelist is required",
|
|
13814
13657
|
"targetWhitelist is required",
|
|
13815
13658
|
{ params },
|
|
@@ -13819,7 +13662,7 @@ var createSessionKeyTransactionParams = async (params, txOptions = globalThis.gl
|
|
|
13819
13662
|
}
|
|
13820
13663
|
if (params.userId === void 0) {
|
|
13821
13664
|
throw new InvalidParameterError7(
|
|
13822
|
-
|
|
13665
|
+
ErrorCode7.MissingParameter,
|
|
13823
13666
|
"userId is required",
|
|
13824
13667
|
"userId is required",
|
|
13825
13668
|
{ params },
|
|
@@ -13970,8 +13813,8 @@ var removeGroupTxParams = async (params, txOptions = globalThis.globalEnvOption)
|
|
|
13970
13813
|
// src/actions/Stake.ts
|
|
13971
13814
|
import { isAddress as isAddress4, parseEther as parseEther2 } from "viem";
|
|
13972
13815
|
import {
|
|
13973
|
-
ErrorCode as
|
|
13974
|
-
InternalFailureError as
|
|
13816
|
+
ErrorCode as ErrorCode8,
|
|
13817
|
+
InternalFailureError as InternalFailureError3,
|
|
13975
13818
|
InvalidParameterError as InvalidParameterError8
|
|
13976
13819
|
} from "@funkit/utils";
|
|
13977
13820
|
var getWithdrawQueueInterface = () => {
|
|
@@ -13994,7 +13837,7 @@ var stakeTransactionParams = async (params, txOptions = globalThis.globalEnvOpti
|
|
|
13994
13837
|
var requestUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
13995
13838
|
if (!isAddress4(params.recipient ?? "")) {
|
|
13996
13839
|
throw new InvalidParameterError8(
|
|
13997
|
-
|
|
13840
|
+
ErrorCode8.InvalidParameter,
|
|
13998
13841
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
13999
13842
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14000
13843
|
{ params },
|
|
@@ -14011,7 +13854,7 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
|
|
|
14011
13854
|
const withdrawalQueue = getWithdrawalQueue(chainId);
|
|
14012
13855
|
if (!steth || !withdrawalQueue || steth.length === 0 || withdrawalQueue.length === 0) {
|
|
14013
13856
|
throw new InvalidParameterError8(
|
|
14014
|
-
|
|
13857
|
+
ErrorCode8.ChainNotSupported,
|
|
14015
13858
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14016
13859
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14017
13860
|
{ params },
|
|
@@ -14049,7 +13892,7 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
|
|
|
14049
13892
|
var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
14050
13893
|
if (!isAddress4(params.recipient ?? "")) {
|
|
14051
13894
|
throw new InvalidParameterError8(
|
|
14052
|
-
|
|
13895
|
+
ErrorCode8.InvalidParameter,
|
|
14053
13896
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14054
13897
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14055
13898
|
{ params },
|
|
@@ -14067,7 +13910,7 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
14067
13910
|
const readyToWithdrawRequestIds = (await getReadyToWithdrawRequests(params, txOptions)).slice(0, 5);
|
|
14068
13911
|
if (readyToWithdrawRequestIds.length === 0) {
|
|
14069
13912
|
throw new InvalidParameterError8(
|
|
14070
|
-
|
|
13913
|
+
ErrorCode8.InvalidParameter,
|
|
14071
13914
|
"Not ready to withdraw requests",
|
|
14072
13915
|
"Not ready to withdraw requests",
|
|
14073
13916
|
{ params },
|
|
@@ -14090,8 +13933,8 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
14090
13933
|
txOptions
|
|
14091
13934
|
);
|
|
14092
13935
|
if (!hints) {
|
|
14093
|
-
throw new
|
|
14094
|
-
|
|
13936
|
+
throw new InternalFailureError3(
|
|
13937
|
+
ErrorCode8.CheckPointHintsNotFound,
|
|
14095
13938
|
"lido checkpoint hints are not found when batching the withdrawal",
|
|
14096
13939
|
"",
|
|
14097
13940
|
{ params, readyToWithdrawRequestIds, lastCheckpoint, hints },
|
|
@@ -14108,7 +13951,7 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
14108
13951
|
var getReadyToWithdrawRequests = async (params, txOptions) => {
|
|
14109
13952
|
if (!isAddress4(params.recipient ?? "")) {
|
|
14110
13953
|
throw new InvalidParameterError8(
|
|
14111
|
-
|
|
13954
|
+
ErrorCode8.InvalidParameter,
|
|
14112
13955
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14113
13956
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14114
13957
|
{ params },
|
|
@@ -14158,7 +14001,7 @@ var getWithdrawalQueue = (chainId) => {
|
|
|
14158
14001
|
return "0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1";
|
|
14159
14002
|
default:
|
|
14160
14003
|
throw new InvalidParameterError8(
|
|
14161
|
-
|
|
14004
|
+
ErrorCode8.ChainNotSupported,
|
|
14162
14005
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14163
14006
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14164
14007
|
{ chainId },
|
|
@@ -14177,7 +14020,7 @@ var getSteth = (chainId) => {
|
|
|
14177
14020
|
return "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
|
|
14178
14021
|
default:
|
|
14179
14022
|
throw new InvalidParameterError8(
|
|
14180
|
-
|
|
14023
|
+
ErrorCode8.ChainNotSupported,
|
|
14181
14024
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14182
14025
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14183
14026
|
{ chainId },
|
|
@@ -14189,7 +14032,7 @@ var getSteth = (chainId) => {
|
|
|
14189
14032
|
|
|
14190
14033
|
// src/actions/Token.ts
|
|
14191
14034
|
import { isAddress as isAddress5, parseEther as parseEther3 } from "viem";
|
|
14192
|
-
import { ErrorCode as
|
|
14035
|
+
import { ErrorCode as ErrorCode9, InvalidParameterError as InvalidParameterError9 } from "@funkit/utils";
|
|
14193
14036
|
var isERC721TransferParams = (obj) => {
|
|
14194
14037
|
return "tokenId" in obj;
|
|
14195
14038
|
};
|
|
@@ -14200,7 +14043,7 @@ var erc721TransferTransactionParams = async (params, options) => {
|
|
|
14200
14043
|
const { to, tokenId, collection, from } = params;
|
|
14201
14044
|
if (!isAddress5(to ?? "") || !isAddress5(from ?? "")) {
|
|
14202
14045
|
throw new InvalidParameterError9(
|
|
14203
|
-
|
|
14046
|
+
ErrorCode9.InvalidParameter,
|
|
14204
14047
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14205
14048
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14206
14049
|
{ params },
|
|
@@ -14219,7 +14062,7 @@ var tokenTransferTransactionParams = async (params, chain, options) => {
|
|
|
14219
14062
|
const { to, amount, token } = params;
|
|
14220
14063
|
if (!isAddress5(to)) {
|
|
14221
14064
|
throw new InvalidParameterError9(
|
|
14222
|
-
|
|
14065
|
+
ErrorCode9.InvalidParameter,
|
|
14223
14066
|
"To address is not a valid address, please make sure it is a valid checksum address.",
|
|
14224
14067
|
"To address is not a valid address, please make sure it is a valid checksum address.",
|
|
14225
14068
|
{ params },
|
|
@@ -14238,7 +14081,7 @@ var tokenTransferTransactionParams = async (params, chain, options) => {
|
|
|
14238
14081
|
const tokenAddr = await tokenObj.getAddress(options);
|
|
14239
14082
|
if (!tokenAddr) {
|
|
14240
14083
|
throw new InvalidParameterError9(
|
|
14241
|
-
|
|
14084
|
+
ErrorCode9.TokenNotFound,
|
|
14242
14085
|
"Token address not found. Please check the token passed in.",
|
|
14243
14086
|
"Token address not found. Please check the token passed in.",
|
|
14244
14087
|
{ params },
|
|
@@ -14257,7 +14100,7 @@ var tokenTransferFromTransactionParams = async (params, chain, options) => {
|
|
|
14257
14100
|
const { to, amount, token, from } = params;
|
|
14258
14101
|
if (!isAddress5(to ?? "") || !isAddress5(from ?? "")) {
|
|
14259
14102
|
throw new InvalidParameterError9(
|
|
14260
|
-
|
|
14103
|
+
ErrorCode9.InvalidParameter,
|
|
14261
14104
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14262
14105
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14263
14106
|
{ params },
|
|
@@ -14276,7 +14119,7 @@ var tokenTransferFromTransactionParams = async (params, chain, options) => {
|
|
|
14276
14119
|
const tokenAddr = await tokenObj.getAddress(options);
|
|
14277
14120
|
if (!tokenAddr) {
|
|
14278
14121
|
throw new InvalidParameterError9(
|
|
14279
|
-
|
|
14122
|
+
ErrorCode9.TokenNotFound,
|
|
14280
14123
|
"Token address not found. Please check the token passed in.",
|
|
14281
14124
|
"Token address not found. Please check the token passed in.",
|
|
14282
14125
|
{ params },
|
|
@@ -14301,7 +14144,7 @@ var erc20ApproveTransactionParams = async (params, options) => {
|
|
|
14301
14144
|
const { spender, amount, token } = params;
|
|
14302
14145
|
if (!isAddress5(spender ?? "")) {
|
|
14303
14146
|
throw new InvalidParameterError9(
|
|
14304
|
-
|
|
14147
|
+
ErrorCode9.InvalidParameter,
|
|
14305
14148
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14306
14149
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14307
14150
|
{ params },
|
|
@@ -14325,7 +14168,7 @@ var erc721ApproveTransactionParams = async (params, options) => {
|
|
|
14325
14168
|
const { spender, tokenId, collection } = params;
|
|
14326
14169
|
if (!isAddress5(spender ?? "")) {
|
|
14327
14170
|
throw new InvalidParameterError9(
|
|
14328
|
-
|
|
14171
|
+
ErrorCode9.InvalidParameter,
|
|
14329
14172
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14330
14173
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14331
14174
|
{ params },
|
|
@@ -14357,7 +14200,7 @@ var SocketSort = /* @__PURE__ */ ((SocketSort2) => {
|
|
|
14357
14200
|
})(SocketSort || {});
|
|
14358
14201
|
|
|
14359
14202
|
// src/config/Config.ts
|
|
14360
|
-
import { ErrorCode as
|
|
14203
|
+
import { ErrorCode as ErrorCode10, InvalidParameterError as InvalidParameterError10 } from "@funkit/utils";
|
|
14361
14204
|
function getEnvOptions() {
|
|
14362
14205
|
return globalThis.globalEnvOption;
|
|
14363
14206
|
}
|
|
@@ -14374,7 +14217,7 @@ async function configureEnvironment(option) {
|
|
|
14374
14217
|
globalEnvOption.apiKey = option.apiKey ? option.apiKey : globalEnvOption.apiKey;
|
|
14375
14218
|
if (!globalEnvOption.apiKey) {
|
|
14376
14219
|
throw new InvalidParameterError10(
|
|
14377
|
-
|
|
14220
|
+
ErrorCode10.MissingParameter,
|
|
14378
14221
|
"apiKey is required",
|
|
14379
14222
|
"apiKey is required",
|
|
14380
14223
|
{ option },
|
|
@@ -14642,7 +14485,7 @@ var CheckoutSponsor = class extends Sponsor {
|
|
|
14642
14485
|
// src/sponsors/GaslessSponsor.ts
|
|
14643
14486
|
import { concat as concat3 } from "viem";
|
|
14644
14487
|
import { PaymasterType as PaymasterType3 } from "@funkit/api-base";
|
|
14645
|
-
import { ErrorCode as
|
|
14488
|
+
import { ErrorCode as ErrorCode11, ResourceNotFoundError as ResourceNotFoundError5 } from "@funkit/utils";
|
|
14646
14489
|
var GaslessSponsor = class extends Sponsor {
|
|
14647
14490
|
constructor(options = globalThis.globalEnvOption) {
|
|
14648
14491
|
super(
|
|
@@ -14665,7 +14508,7 @@ var GaslessSponsor = class extends Sponsor {
|
|
|
14665
14508
|
);
|
|
14666
14509
|
} else {
|
|
14667
14510
|
throw new ResourceNotFoundError5(
|
|
14668
|
-
|
|
14511
|
+
ErrorCode11.MissingParameter,
|
|
14669
14512
|
"The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
|
|
14670
14513
|
"The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
|
|
14671
14514
|
{
|
|
@@ -14801,7 +14644,7 @@ var GaslessSponsor = class extends Sponsor {
|
|
|
14801
14644
|
import { concat as concat4, encodeAbiParameters as encodeAbiParameters4 } from "viem";
|
|
14802
14645
|
import { PaymasterType as PaymasterType4, addTransaction } from "@funkit/api-base";
|
|
14803
14646
|
import {
|
|
14804
|
-
ErrorCode as
|
|
14647
|
+
ErrorCode as ErrorCode12,
|
|
14805
14648
|
InvalidParameterError as InvalidParameterError11,
|
|
14806
14649
|
ResourceNotFoundError as ResourceNotFoundError6
|
|
14807
14650
|
} from "@funkit/utils";
|
|
@@ -14815,7 +14658,7 @@ var TokenSponsor = class extends Sponsor {
|
|
|
14815
14658
|
);
|
|
14816
14659
|
if (!options.gasSponsor?.token) {
|
|
14817
14660
|
throw new InvalidParameterError11(
|
|
14818
|
-
|
|
14661
|
+
ErrorCode12.MissingParameter,
|
|
14819
14662
|
"token field is missing",
|
|
14820
14663
|
"token field is missing",
|
|
14821
14664
|
{ gasSponsor: options.gasSponsor },
|
|
@@ -14838,7 +14681,7 @@ var TokenSponsor = class extends Sponsor {
|
|
|
14838
14681
|
);
|
|
14839
14682
|
} else {
|
|
14840
14683
|
throw new ResourceNotFoundError6(
|
|
14841
|
-
|
|
14684
|
+
ErrorCode12.MissingParameter,
|
|
14842
14685
|
"The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
|
|
14843
14686
|
"The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
|
|
14844
14687
|
{
|
|
@@ -15312,15 +15155,15 @@ import {
|
|
|
15312
15155
|
toBytes as toBytes7
|
|
15313
15156
|
} from "viem";
|
|
15314
15157
|
import {
|
|
15315
|
-
ErrorCode as
|
|
15316
|
-
InternalFailureError as
|
|
15158
|
+
ErrorCode as ErrorCode14,
|
|
15159
|
+
InternalFailureError as InternalFailureError4,
|
|
15317
15160
|
InvalidParameterError as InvalidParameterError13
|
|
15318
15161
|
} from "@funkit/utils";
|
|
15319
15162
|
|
|
15320
15163
|
// src/actions/FirstClassActions.ts
|
|
15321
15164
|
import { pad as pad8 } from "viem";
|
|
15322
15165
|
import {
|
|
15323
|
-
ErrorCode as
|
|
15166
|
+
ErrorCode as ErrorCode13,
|
|
15324
15167
|
InvalidParameterError as InvalidParameterError12,
|
|
15325
15168
|
ResourceNotFoundError as ResourceNotFoundError7
|
|
15326
15169
|
} from "@funkit/utils";
|
|
@@ -15416,7 +15259,7 @@ var FirstClassActions = class {
|
|
|
15416
15259
|
}
|
|
15417
15260
|
} else {
|
|
15418
15261
|
throw new InvalidParameterError12(
|
|
15419
|
-
|
|
15262
|
+
ErrorCode13.InvalidParameter,
|
|
15420
15263
|
"Params were missing or incorrect",
|
|
15421
15264
|
"Params were missing or incorrect",
|
|
15422
15265
|
{ params },
|
|
@@ -15451,7 +15294,7 @@ var FirstClassActions = class {
|
|
|
15451
15294
|
);
|
|
15452
15295
|
} else {
|
|
15453
15296
|
throw new InvalidParameterError12(
|
|
15454
|
-
|
|
15297
|
+
ErrorCode13.InvalidParameter,
|
|
15455
15298
|
"Params were missing or incorrect",
|
|
15456
15299
|
"Params were missing or incorrect",
|
|
15457
15300
|
{ params },
|
|
@@ -15507,7 +15350,7 @@ var FirstClassActions = class {
|
|
|
15507
15350
|
);
|
|
15508
15351
|
} else {
|
|
15509
15352
|
throw new InvalidParameterError12(
|
|
15510
|
-
|
|
15353
|
+
ErrorCode13.InvalidParameter,
|
|
15511
15354
|
"Params were missing or incorrect",
|
|
15512
15355
|
"Params were missing or incorrect",
|
|
15513
15356
|
{ params },
|
|
@@ -15601,7 +15444,7 @@ var FirstClassActions = class {
|
|
|
15601
15444
|
);
|
|
15602
15445
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15603
15446
|
throw new ResourceNotFoundError7(
|
|
15604
|
-
|
|
15447
|
+
ErrorCode13.GroupNotFound,
|
|
15605
15448
|
"group is not found",
|
|
15606
15449
|
"group is not found",
|
|
15607
15450
|
{ params },
|
|
@@ -15614,7 +15457,7 @@ var FirstClassActions = class {
|
|
|
15614
15457
|
members.add(params.userId);
|
|
15615
15458
|
if (members.size <= originalMembers.size) {
|
|
15616
15459
|
throw new InvalidParameterError12(
|
|
15617
|
-
|
|
15460
|
+
ErrorCode13.UserAlreadyExists,
|
|
15618
15461
|
"user already exists in group",
|
|
15619
15462
|
"user already exists in group",
|
|
15620
15463
|
{ params, originalMembers, userId: params.userId },
|
|
@@ -15655,7 +15498,7 @@ var FirstClassActions = class {
|
|
|
15655
15498
|
);
|
|
15656
15499
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15657
15500
|
throw new ResourceNotFoundError7(
|
|
15658
|
-
|
|
15501
|
+
ErrorCode13.GroupNotFound,
|
|
15659
15502
|
"group is not found",
|
|
15660
15503
|
"group is not found",
|
|
15661
15504
|
{ params },
|
|
@@ -15668,7 +15511,7 @@ var FirstClassActions = class {
|
|
|
15668
15511
|
members.delete(params.userId);
|
|
15669
15512
|
if (members.size >= originalMembers.size) {
|
|
15670
15513
|
throw new ResourceNotFoundError7(
|
|
15671
|
-
|
|
15514
|
+
ErrorCode13.UserNotFound,
|
|
15672
15515
|
"user does not exist in group",
|
|
15673
15516
|
"user does not exist in group",
|
|
15674
15517
|
{ params, originalMembers, userId: params.userId },
|
|
@@ -15708,7 +15551,7 @@ var FirstClassActions = class {
|
|
|
15708
15551
|
);
|
|
15709
15552
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15710
15553
|
throw new ResourceNotFoundError7(
|
|
15711
|
-
|
|
15554
|
+
ErrorCode13.GroupNotFound,
|
|
15712
15555
|
"group is not found",
|
|
15713
15556
|
"group is not found",
|
|
15714
15557
|
{ params },
|
|
@@ -15718,7 +15561,7 @@ var FirstClassActions = class {
|
|
|
15718
15561
|
}
|
|
15719
15562
|
if (!Number.isInteger(params.threshold) || params.threshold < 1 || params.threshold > onChainGroupData.memberIds.length) {
|
|
15720
15563
|
throw new InvalidParameterError12(
|
|
15721
|
-
|
|
15564
|
+
ErrorCode13.InvalidThreshold,
|
|
15722
15565
|
"threshold can not be 0 or bigger than number of members in the group",
|
|
15723
15566
|
"threshold can not be 0 or bigger than number of members in the group",
|
|
15724
15567
|
{ params, memberIds: onChainGroupData.memberIds },
|
|
@@ -15779,7 +15622,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15779
15622
|
this.address = params;
|
|
15780
15623
|
} else {
|
|
15781
15624
|
throw new InvalidParameterError13(
|
|
15782
|
-
|
|
15625
|
+
ErrorCode14.InvalidParameter,
|
|
15783
15626
|
"string input must be an address type",
|
|
15784
15627
|
"string input must be an address type",
|
|
15785
15628
|
params,
|
|
@@ -15791,7 +15634,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15791
15634
|
const { users, uniqueId } = params;
|
|
15792
15635
|
if (!uniqueId || !isBytes32(uniqueId) || !users || users.length <= 0) {
|
|
15793
15636
|
throw new InvalidParameterError13(
|
|
15794
|
-
|
|
15637
|
+
ErrorCode14.InvalidParameter,
|
|
15795
15638
|
"uniqueId must be bytes32 and users must be non-empty",
|
|
15796
15639
|
"uniqueId must be bytes32 and users must be non-empty",
|
|
15797
15640
|
params,
|
|
@@ -15803,7 +15646,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15803
15646
|
users?.map((user) => {
|
|
15804
15647
|
if (!user.userId || !isHex3(user.userId)) {
|
|
15805
15648
|
throw new InvalidParameterError13(
|
|
15806
|
-
|
|
15649
|
+
ErrorCode14.InvalidParameter,
|
|
15807
15650
|
"userId is required and must be a hex string",
|
|
15808
15651
|
"userId is required and must be a hex string",
|
|
15809
15652
|
users,
|
|
@@ -15813,7 +15656,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15813
15656
|
}
|
|
15814
15657
|
if (user.groupInfo && (!Number.isInteger(user.groupInfo.threshold) || !Array.isArray(user.groupInfo.memberIds) || !user.groupInfo.memberIds.every((memberId) => isHex3(memberId)))) {
|
|
15815
15658
|
throw new InvalidParameterError13(
|
|
15816
|
-
|
|
15659
|
+
ErrorCode14.InvalidParameter,
|
|
15817
15660
|
"groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
|
|
15818
15661
|
"groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
|
|
15819
15662
|
users,
|
|
@@ -16195,7 +16038,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16195
16038
|
async createOperation(auth, userId, transactionParams, txOptions = globalThis.globalEnvOption) {
|
|
16196
16039
|
if (!userId || userId === "") {
|
|
16197
16040
|
throw new InvalidParameterError13(
|
|
16198
|
-
|
|
16041
|
+
ErrorCode14.MissingParameter,
|
|
16199
16042
|
"userId is required",
|
|
16200
16043
|
"userId is required",
|
|
16201
16044
|
{ userId },
|
|
@@ -16425,7 +16268,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16425
16268
|
}
|
|
16426
16269
|
if (collectedSigCount < threshold) {
|
|
16427
16270
|
throw new InvalidParameterError13(
|
|
16428
|
-
|
|
16271
|
+
ErrorCode14.InsufficientSignatures,
|
|
16429
16272
|
"Signatures are not sufficient to execute the operation",
|
|
16430
16273
|
"Signatures are not sufficient to execute the operation",
|
|
16431
16274
|
{ threshold, collectedSigCount, chainId },
|
|
@@ -16435,7 +16278,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16435
16278
|
}
|
|
16436
16279
|
} else {
|
|
16437
16280
|
throw new InvalidParameterError13(
|
|
16438
|
-
|
|
16281
|
+
ErrorCode14.InsufficientSignatures,
|
|
16439
16282
|
"Signatures are not sufficient to execute the operation",
|
|
16440
16283
|
"Signatures are not sufficient to execute the operation",
|
|
16441
16284
|
{ threshold, chainId, skipDBAction: finalTxOptions.skipDBAction },
|
|
@@ -16595,7 +16438,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16595
16438
|
}
|
|
16596
16439
|
if (collectedSigCount < threshold) {
|
|
16597
16440
|
throw new InvalidParameterError13(
|
|
16598
|
-
|
|
16441
|
+
ErrorCode14.InsufficientSignatures,
|
|
16599
16442
|
"Signatures are not sufficient to execute the operation",
|
|
16600
16443
|
"Signatures are not sufficient to execute the operation",
|
|
16601
16444
|
{ threshold, collectedSigCount, chainId },
|
|
@@ -16605,7 +16448,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16605
16448
|
}
|
|
16606
16449
|
} else {
|
|
16607
16450
|
throw new InvalidParameterError13(
|
|
16608
|
-
|
|
16451
|
+
ErrorCode14.InsufficientSignatures,
|
|
16609
16452
|
"Signatures are not sufficient to execute the operation",
|
|
16610
16453
|
"Signatures are not sufficient to execute the operation",
|
|
16611
16454
|
{ threshold, chainId, skipDBAction: finalTxOptions.skipDBAction },
|
|
@@ -16650,8 +16493,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16650
16493
|
});
|
|
16651
16494
|
}
|
|
16652
16495
|
if (!finalOperation.opId) {
|
|
16653
|
-
throw new
|
|
16654
|
-
|
|
16496
|
+
throw new InternalFailureError4(
|
|
16497
|
+
ErrorCode14.ServerFailure,
|
|
16655
16498
|
"Operation id is required",
|
|
16656
16499
|
"",
|
|
16657
16500
|
finalOperation,
|
|
@@ -16811,7 +16654,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16811
16654
|
}
|
|
16812
16655
|
if (!options.fee.token) {
|
|
16813
16656
|
throw new InvalidParameterError13(
|
|
16814
|
-
|
|
16657
|
+
ErrorCode14.MissingParameter,
|
|
16815
16658
|
"EnvOption.fee.token or EnvOption.gasSponsor.token is required",
|
|
16816
16659
|
"EnvOption.fee.token or EnvOption.gasSponsor.token is required",
|
|
16817
16660
|
{ options },
|
|
@@ -16821,7 +16664,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16821
16664
|
}
|
|
16822
16665
|
if (!options.fee.recipient) {
|
|
16823
16666
|
throw new InvalidParameterError13(
|
|
16824
|
-
|
|
16667
|
+
ErrorCode14.MissingParameter,
|
|
16825
16668
|
"EnvOption.fee.recipient is required",
|
|
16826
16669
|
"EnvOption.fee.recipient is required",
|
|
16827
16670
|
{ options },
|
|
@@ -16836,7 +16679,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16836
16679
|
const token = new Token(options.fee.token, chain);
|
|
16837
16680
|
if (options.fee.gasPercent && !token.isNative) {
|
|
16838
16681
|
throw new InvalidParameterError13(
|
|
16839
|
-
|
|
16682
|
+
ErrorCode14.InvalidParameterCombination,
|
|
16840
16683
|
"GasPercent is only valid for native tokens",
|
|
16841
16684
|
"GasPercent is only valid for native tokens",
|
|
16842
16685
|
{ options },
|
|
@@ -16871,7 +16714,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16871
16714
|
);
|
|
16872
16715
|
} else {
|
|
16873
16716
|
throw new InvalidParameterError13(
|
|
16874
|
-
|
|
16717
|
+
ErrorCode14.MissingParameter,
|
|
16875
16718
|
"EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
|
|
16876
16719
|
"EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
|
|
16877
16720
|
{ options },
|
|
@@ -16980,7 +16823,6 @@ export {
|
|
|
16980
16823
|
erc721TransferTransactionParams,
|
|
16981
16824
|
finishUnstakeTransactionParams,
|
|
16982
16825
|
fundWallet,
|
|
16983
|
-
gasCalculation,
|
|
16984
16826
|
gasSpecificChain,
|
|
16985
16827
|
generatePrivateKey,
|
|
16986
16828
|
generateRandomBytes32,
|
|
@@ -17020,7 +16862,6 @@ export {
|
|
|
17020
16862
|
removeOwnerTxParams,
|
|
17021
16863
|
requestUnstakeTransactionParams,
|
|
17022
16864
|
roundToNearestBottomTenth,
|
|
17023
|
-
sendRequest,
|
|
17024
16865
|
stakeTransactionParams,
|
|
17025
16866
|
stringify,
|
|
17026
16867
|
toBytes32Arr,
|