@funkit/core 2.3.0 → 2.3.2
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.d.ts +0 -1
- package/dist/index.js +467 -926
- package/dist/index.js.map +4 -4
- package/dist/src/auth/Auth.d.ts +1 -1
- package/dist/src/common/constants.d.ts +1 -3793
- package/dist/src/common/types.d.ts +0 -7
- package/dist/src/data/Chain.d.ts +2 -3
- package/dist/src/data/Operation.d.ts +1 -4
- package/dist/src/data/types.d.ts +0 -58
- package/dist/src/utils/ChainUtils.d.ts +1 -1
- package/dist/src/utils/GroupUtils.d.ts +1 -1
- package/dist/src/utils/TokenUtils.d.ts +1 -0
- package/dist/src/utils/UserOpUtils.d.ts +2 -1
- package/dist/src/utils/WalletUtils.d.ts +2 -1
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/wallet/FunWallet.d.ts +8 -7
- package/dist/src/wallet/types.d.ts +1 -4
- package/package.json +4 -13
- package/dist/src/apis/InfoApis.d.ts +0 -6
- package/dist/src/apis/OperationApis.d.ts +0 -15
- package/dist/src/apis/UserApis.d.ts +0 -9
- package/dist/src/apis/index.d.ts +0 -4
- package/dist/src/apis/types.d.ts +0 -42
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/actions/AccessControl.ts
|
|
2
2
|
import { getAddress, pad as pad6 } from "viem";
|
|
3
|
-
import { ErrorCode as ErrorCode8, InvalidParameterError as
|
|
3
|
+
import { ErrorCode as ErrorCode8, InvalidParameterError as InvalidParameterError7 } from "@funkit/utils";
|
|
4
4
|
|
|
5
5
|
// src/auth/Auth.ts
|
|
6
6
|
import {
|
|
@@ -14,30 +14,18 @@ import {
|
|
|
14
14
|
} from "viem";
|
|
15
15
|
import { privateKeyToAccount } from "viem/accounts";
|
|
16
16
|
import * as viemChains from "viem/chains";
|
|
17
|
+
import {
|
|
18
|
+
getUserWalletIdentities,
|
|
19
|
+
getUserWalletsByAddr
|
|
20
|
+
} from "@funkit/api-base";
|
|
17
21
|
import {
|
|
18
22
|
ErrorCode as ErrorCode7,
|
|
19
|
-
InvalidParameterError as
|
|
20
|
-
ResourceNotFoundError as
|
|
23
|
+
InvalidParameterError as InvalidParameterError6,
|
|
24
|
+
ResourceNotFoundError as ResourceNotFoundError4
|
|
21
25
|
} from "@funkit/utils";
|
|
22
26
|
|
|
23
|
-
// src/apis/UserApis.ts
|
|
24
|
-
import { InvalidParameterError as InvalidParameterError6 } from "viem";
|
|
25
|
-
import { ResourceNotFoundError as ResourceNotFoundError4 } from "@funkit/utils";
|
|
26
|
-
|
|
27
27
|
// src/common/constants.ts
|
|
28
28
|
import { padHex } from "viem";
|
|
29
|
-
import {
|
|
30
|
-
arbitrum,
|
|
31
|
-
arbitrumSepolia,
|
|
32
|
-
base,
|
|
33
|
-
goerli,
|
|
34
|
-
mainnet,
|
|
35
|
-
mantle,
|
|
36
|
-
optimism,
|
|
37
|
-
polygon,
|
|
38
|
-
scroll,
|
|
39
|
-
zkSync
|
|
40
|
-
} from "viem/chains";
|
|
41
29
|
|
|
42
30
|
// src/abis/ApproveAndExec.json
|
|
43
31
|
var ApproveAndExec_default = {
|
|
@@ -11502,6 +11490,13 @@ import {
|
|
|
11502
11490
|
http,
|
|
11503
11491
|
createPublicClient
|
|
11504
11492
|
} from "viem";
|
|
11493
|
+
import {
|
|
11494
|
+
estimateOp,
|
|
11495
|
+
getChainFromId,
|
|
11496
|
+
getChainFromName,
|
|
11497
|
+
getUserOpGasPrice
|
|
11498
|
+
} from "@funkit/api-base";
|
|
11499
|
+
import { FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO } from "@funkit/chains";
|
|
11505
11500
|
import {
|
|
11506
11501
|
ErrorCode as ErrorCode4,
|
|
11507
11502
|
InternalFailureError as InternalFailureError2,
|
|
@@ -11509,29 +11504,195 @@ import {
|
|
|
11509
11504
|
ResourceNotFoundError as ResourceNotFoundError3
|
|
11510
11505
|
} from "@funkit/utils";
|
|
11511
11506
|
|
|
11512
|
-
// src/apis/InfoApis.ts
|
|
11513
|
-
import { ErrorCode as ErrorCode3, ResourceNotFoundError as ResourceNotFoundError2 } from "@funkit/utils";
|
|
11514
|
-
|
|
11515
11507
|
// src/utils/ApiUtils.ts
|
|
11516
11508
|
import { retry } from "@lifeomic/attempt";
|
|
11517
11509
|
import {
|
|
11518
11510
|
AccessDeniedError,
|
|
11519
|
-
ErrorCode
|
|
11511
|
+
ErrorCode,
|
|
11520
11512
|
InternalFailureError,
|
|
11521
|
-
InvalidParameterError
|
|
11513
|
+
InvalidParameterError,
|
|
11522
11514
|
ResourceNotFoundError,
|
|
11523
11515
|
ThrottlingError,
|
|
11524
11516
|
UserOpFailureError
|
|
11525
11517
|
} from "@funkit/utils";
|
|
11518
|
+
var errorHandler = (err, context) => {
|
|
11519
|
+
if (err instanceof ResourceNotFoundError || err instanceof InvalidParameterError || err instanceof UserOpFailureError) {
|
|
11520
|
+
context.abort();
|
|
11521
|
+
}
|
|
11522
|
+
};
|
|
11523
|
+
var DEFAULT_RETRY_OPTIONS = {
|
|
11524
|
+
delay: 100,
|
|
11525
|
+
initialDelay: 0,
|
|
11526
|
+
maxDelay: 3e3,
|
|
11527
|
+
factor: 2,
|
|
11528
|
+
maxAttempts: 5,
|
|
11529
|
+
timeout: 0,
|
|
11530
|
+
jitter: true,
|
|
11531
|
+
minDelay: 0,
|
|
11532
|
+
handleError: errorHandler,
|
|
11533
|
+
handleTimeout: null,
|
|
11534
|
+
beforeAttempt: null,
|
|
11535
|
+
calculateDelay: null
|
|
11536
|
+
};
|
|
11537
|
+
var sendRequest = async (uri, method, apiKey, body, retryOptions) => {
|
|
11538
|
+
try {
|
|
11539
|
+
const headers = {
|
|
11540
|
+
"Content-Type": "application/json"
|
|
11541
|
+
};
|
|
11542
|
+
if (apiKey) {
|
|
11543
|
+
headers["X-Api-Key"] = apiKey;
|
|
11544
|
+
}
|
|
11545
|
+
const finalRetryOptions = {
|
|
11546
|
+
...DEFAULT_RETRY_OPTIONS,
|
|
11547
|
+
...retryOptions || {}
|
|
11548
|
+
};
|
|
11549
|
+
return retry(async () => {
|
|
11550
|
+
const response = await fetch(uri, {
|
|
11551
|
+
method,
|
|
11552
|
+
headers,
|
|
11553
|
+
redirect: "follow",
|
|
11554
|
+
body: method !== "GET" ? stringify(body) : void 0
|
|
11555
|
+
});
|
|
11556
|
+
const json = await response.json();
|
|
11557
|
+
if (response.ok) {
|
|
11558
|
+
return json;
|
|
11559
|
+
}
|
|
11560
|
+
if (response.status === 400) {
|
|
11561
|
+
throw new InvalidParameterError(
|
|
11562
|
+
ErrorCode.InvalidParameter,
|
|
11563
|
+
`bad request ${JSON.stringify(json)}`,
|
|
11564
|
+
`bad request ${JSON.stringify(json)}`,
|
|
11565
|
+
{ body },
|
|
11566
|
+
"check the api call parameters. its mostly because some call parameters are wrong",
|
|
11567
|
+
"https://docs.fun.xyz"
|
|
11568
|
+
);
|
|
11569
|
+
}
|
|
11570
|
+
if (response.status === 403) {
|
|
11571
|
+
throw new AccessDeniedError(
|
|
11572
|
+
ErrorCode.Unauthorized,
|
|
11573
|
+
"Invalid API key or insufficient access.",
|
|
11574
|
+
"Invalid API key or insufficient access.",
|
|
11575
|
+
{ apiKey },
|
|
11576
|
+
"Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
|
|
11577
|
+
"https://docs.fun.xyz"
|
|
11578
|
+
);
|
|
11579
|
+
}
|
|
11580
|
+
if (response.status === 404) {
|
|
11581
|
+
throw new ResourceNotFoundError(
|
|
11582
|
+
ErrorCode.ServerMissingData,
|
|
11583
|
+
JSON.stringify(json),
|
|
11584
|
+
JSON.stringify(json),
|
|
11585
|
+
{ body },
|
|
11586
|
+
"check the api call parameters. its mostly because some call parameters are wrong",
|
|
11587
|
+
"https://docs.fun.xyz"
|
|
11588
|
+
);
|
|
11589
|
+
}
|
|
11590
|
+
if (response.status === 429) {
|
|
11591
|
+
throw new ThrottlingError(
|
|
11592
|
+
ErrorCode.RequestLimitExceeded,
|
|
11593
|
+
`too many requests ${JSON.stringify(json)}`,
|
|
11594
|
+
`too many requests ${JSON.stringify(json)}`,
|
|
11595
|
+
{ body },
|
|
11596
|
+
"you are making too many requests. please slow down. Reach out to fun team if you need more quota",
|
|
11597
|
+
"https://docs.fun.xyz"
|
|
11598
|
+
);
|
|
11599
|
+
}
|
|
11600
|
+
if (response.status === 500) {
|
|
11601
|
+
if (json.errorCode === ErrorCode.UserOpFailureError) {
|
|
11602
|
+
throw new UserOpFailureError(
|
|
11603
|
+
ErrorCode.UserOpFailureError,
|
|
11604
|
+
JSON.stringify(json),
|
|
11605
|
+
JSON.stringify(json),
|
|
11606
|
+
{ body },
|
|
11607
|
+
"fix user op failure. Most of the time this is due to invalid parameters",
|
|
11608
|
+
"https://docs.fun.xyz"
|
|
11609
|
+
);
|
|
11610
|
+
}
|
|
11611
|
+
throw new InternalFailureError(
|
|
11612
|
+
ErrorCode.ServerFailure,
|
|
11613
|
+
`server failure ${JSON.stringify(json)}`,
|
|
11614
|
+
json.errorMsg,
|
|
11615
|
+
{ body },
|
|
11616
|
+
"retry later. if it still fails, please contact us.",
|
|
11617
|
+
"https://docs.fun.xyz"
|
|
11618
|
+
);
|
|
11619
|
+
}
|
|
11620
|
+
if (response.status === 504) {
|
|
11621
|
+
throw new InternalFailureError(
|
|
11622
|
+
ErrorCode.ServerTimeout,
|
|
11623
|
+
`server timeout failure ${JSON.stringify(json)}`,
|
|
11624
|
+
json.errorMsg,
|
|
11625
|
+
{ body },
|
|
11626
|
+
"retry later. if it still fails, please contact us.",
|
|
11627
|
+
"https://docs.fun.xyz"
|
|
11628
|
+
);
|
|
11629
|
+
}
|
|
11630
|
+
if (!response.ok) {
|
|
11631
|
+
throw new InternalFailureError(
|
|
11632
|
+
ErrorCode.UnknownServerError,
|
|
11633
|
+
`unknown server failure ${JSON.stringify(json)}`,
|
|
11634
|
+
json.errorMsg,
|
|
11635
|
+
{ body },
|
|
11636
|
+
"retry later. if it still fails, please contact us.",
|
|
11637
|
+
"https://docs.fun.xyz"
|
|
11638
|
+
);
|
|
11639
|
+
}
|
|
11640
|
+
return {};
|
|
11641
|
+
}, finalRetryOptions);
|
|
11642
|
+
} catch (err) {
|
|
11643
|
+
throw new InternalFailureError(
|
|
11644
|
+
ErrorCode.ServerConnectionError,
|
|
11645
|
+
`Cannot connect to Fun API Service ${err}`,
|
|
11646
|
+
"",
|
|
11647
|
+
{ body },
|
|
11648
|
+
"retry later. if it still fails, please contact us.",
|
|
11649
|
+
"https://docs.fun.xyz"
|
|
11650
|
+
);
|
|
11651
|
+
}
|
|
11652
|
+
};
|
|
11653
|
+
async function sendGetRequest(uri, endpoint, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
|
|
11654
|
+
return await sendRequest(
|
|
11655
|
+
`${uri}/${endpoint}`,
|
|
11656
|
+
"GET",
|
|
11657
|
+
apiKey,
|
|
11658
|
+
void 0,
|
|
11659
|
+
retryOptions
|
|
11660
|
+
);
|
|
11661
|
+
}
|
|
11662
|
+
async function sendPostRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
|
|
11663
|
+
return await sendRequest(
|
|
11664
|
+
`${uri}/${endpoint}`,
|
|
11665
|
+
"POST",
|
|
11666
|
+
apiKey,
|
|
11667
|
+
body,
|
|
11668
|
+
retryOptions
|
|
11669
|
+
);
|
|
11670
|
+
}
|
|
11671
|
+
async function sendDeleteRequest(uri, endpoint, apiKey = globalThis.globalEnvOption.apiKey) {
|
|
11672
|
+
await sendRequest(`${uri}/${endpoint}`, "DELETE", apiKey);
|
|
11673
|
+
}
|
|
11674
|
+
async function sendPutRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption.apiKey) {
|
|
11675
|
+
await sendRequest(`${uri}/${endpoint}`, "PUT", apiKey, body);
|
|
11676
|
+
}
|
|
11526
11677
|
|
|
11527
11678
|
// src/utils/AuthUtils.ts
|
|
11528
11679
|
import { v4 as uuidv4 } from "uuid";
|
|
11529
11680
|
import { generatePrivateKey as generateRandomPrivateKey } from "viem/accounts";
|
|
11681
|
+
import { createUser, getUserUniqueId } from "@funkit/api-base";
|
|
11530
11682
|
var getAuthUniqueId = async (authId, addr = "NO_ADDRESS", skipDBActions = false) => {
|
|
11531
|
-
const authUniqueId = (skipDBActions ? addr : await getUserUniqueId(
|
|
11683
|
+
const authUniqueId = (skipDBActions ? addr : await getUserUniqueId({
|
|
11684
|
+
authId,
|
|
11685
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
11686
|
+
})) || uuidv4();
|
|
11532
11687
|
const words = authId.split("###");
|
|
11533
11688
|
const method = words[0].startsWith("0x") ? "eoa" : words[0];
|
|
11534
|
-
await createUser(
|
|
11689
|
+
await createUser({
|
|
11690
|
+
authId,
|
|
11691
|
+
addr,
|
|
11692
|
+
method,
|
|
11693
|
+
userUniqueId: authUniqueId,
|
|
11694
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
11695
|
+
});
|
|
11535
11696
|
return authUniqueId;
|
|
11536
11697
|
};
|
|
11537
11698
|
var generatePrivateKey = () => {
|
|
@@ -11551,7 +11712,7 @@ import {
|
|
|
11551
11712
|
toBytes,
|
|
11552
11713
|
toHex
|
|
11553
11714
|
} from "viem";
|
|
11554
|
-
import { ErrorCode, InvalidParameterError } from "@funkit/utils";
|
|
11715
|
+
import { ErrorCode as ErrorCode2, InvalidParameterError as InvalidParameterError2 } from "@funkit/utils";
|
|
11555
11716
|
var isAddress = (address) => {
|
|
11556
11717
|
try {
|
|
11557
11718
|
const [decodedAddr] = decodeAbiParameters(
|
|
@@ -11665,8 +11826,8 @@ var useFaucet = async (chainIdentifier, wallet) => {
|
|
|
11665
11826
|
const chain = await Chain.getChain({ chainIdentifier });
|
|
11666
11827
|
const chainName = await chain.getChainName();
|
|
11667
11828
|
if (chainName !== "goerli") {
|
|
11668
|
-
throw new
|
|
11669
|
-
|
|
11829
|
+
throw new InvalidParameterError2(
|
|
11830
|
+
ErrorCode2.InvalidChainIdentifier,
|
|
11670
11831
|
"Only Goerli is supported",
|
|
11671
11832
|
"Only Goerli is supported",
|
|
11672
11833
|
chainIdentifier,
|
|
@@ -11924,9 +12085,36 @@ async function getOpHash(chain, userOp) {
|
|
|
11924
12085
|
);
|
|
11925
12086
|
}
|
|
11926
12087
|
|
|
12088
|
+
// src/utils/TokenUtils.ts
|
|
12089
|
+
import { getAssetErc20ByChainAndSymbol } from "@funkit/api-base";
|
|
12090
|
+
import { ErrorCode as ErrorCode3, ResourceNotFoundError as ResourceNotFoundError2 } from "@funkit/utils";
|
|
12091
|
+
async function getTokenAddressBySymbolAndChainId(inputSymbol, inputChainId) {
|
|
12092
|
+
const normalizedSymbol = inputSymbol.toLowerCase();
|
|
12093
|
+
if (BASE_WRAP_TOKEN_ADDR?.[inputChainId]?.[normalizedSymbol]) {
|
|
12094
|
+
return BASE_WRAP_TOKEN_ADDR[inputChainId][normalizedSymbol];
|
|
12095
|
+
}
|
|
12096
|
+
const tokenInfo = await getAssetErc20ByChainAndSymbol({
|
|
12097
|
+
chainId: inputChainId,
|
|
12098
|
+
symbol: normalizedSymbol,
|
|
12099
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
12100
|
+
});
|
|
12101
|
+
if (tokenInfo.address) {
|
|
12102
|
+
return tokenInfo.address;
|
|
12103
|
+
}
|
|
12104
|
+
throw new ResourceNotFoundError2(
|
|
12105
|
+
ErrorCode3.TokenNotFound,
|
|
12106
|
+
"token symbol does not exist on provided chain",
|
|
12107
|
+
"token symbol does not exist on provided chain",
|
|
12108
|
+
{ symbol: inputSymbol, chainId: inputChainId },
|
|
12109
|
+
"Provide correct symbol and chainId.",
|
|
12110
|
+
"https://docs.fun.xyz"
|
|
12111
|
+
);
|
|
12112
|
+
}
|
|
12113
|
+
|
|
11927
12114
|
// src/utils/WalletUtils.ts
|
|
11928
12115
|
import { v4 as uuidv42 } from "uuid";
|
|
11929
12116
|
import { keccak256 as keccak2563, pad as pad2, toBytes as toBytes3 } from "viem";
|
|
12117
|
+
import { AuthType } from "@funkit/api-base";
|
|
11930
12118
|
var generateRandomBytes32 = () => {
|
|
11931
12119
|
return keccak2563(toBytes3(uuidv42()));
|
|
11932
12120
|
};
|
|
@@ -11963,7 +12151,7 @@ var isWalletInitOp = (userOp) => {
|
|
|
11963
12151
|
return userOp.initCode !== "0x";
|
|
11964
12152
|
};
|
|
11965
12153
|
var isGroupOperation = (operation) => {
|
|
11966
|
-
if (operation.groupId && operation.authType ===
|
|
12154
|
+
if (operation.groupId && operation.authType === AuthType.MULTI_SIG) {
|
|
11967
12155
|
return true;
|
|
11968
12156
|
}
|
|
11969
12157
|
return false;
|
|
@@ -11982,335 +12170,41 @@ var isSignatureMissing = (userId, signatures) => {
|
|
|
11982
12170
|
return sigMissing;
|
|
11983
12171
|
};
|
|
11984
12172
|
|
|
11985
|
-
// src/
|
|
11986
|
-
var
|
|
11987
|
-
|
|
11988
|
-
|
|
12173
|
+
// src/data/Chain.ts
|
|
12174
|
+
var Chain = class _Chain {
|
|
12175
|
+
constructor(chainInput) {
|
|
12176
|
+
this.initialized = false;
|
|
12177
|
+
this.addresses = {};
|
|
12178
|
+
if (!chainInput.chainIdentifier && !chainInput.rpcUrl) {
|
|
12179
|
+
throw new InvalidParameterError3(
|
|
12180
|
+
ErrorCode4.InvalidChainIdentifier,
|
|
12181
|
+
"valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
|
|
12182
|
+
"valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
|
|
12183
|
+
{ chainInput },
|
|
12184
|
+
"Please provide valid chain identifier or rpcUrl",
|
|
12185
|
+
"https://docs.fun.xyz"
|
|
12186
|
+
);
|
|
12187
|
+
}
|
|
12188
|
+
if (chainInput.rpcUrl) {
|
|
12189
|
+
this.rpcUrl = chainInput.rpcUrl;
|
|
12190
|
+
} else if (chainInput.chainIdentifier instanceof _Chain) {
|
|
12191
|
+
return chainInput.chainIdentifier;
|
|
12192
|
+
} else if (typeof chainInput.chainIdentifier === "number" || Number(chainInput.chainIdentifier)) {
|
|
12193
|
+
this.id = chainInput.chainIdentifier.toString();
|
|
12194
|
+
} else {
|
|
12195
|
+
this.name = chainInput.chainIdentifier;
|
|
12196
|
+
}
|
|
11989
12197
|
}
|
|
11990
|
-
|
|
11991
|
-
|
|
11992
|
-
|
|
11993
|
-
initialDelay: 0,
|
|
11994
|
-
maxDelay: 3e3,
|
|
11995
|
-
factor: 2,
|
|
11996
|
-
maxAttempts: 5,
|
|
11997
|
-
timeout: 0,
|
|
11998
|
-
jitter: true,
|
|
11999
|
-
minDelay: 0,
|
|
12000
|
-
handleError: errorHandler,
|
|
12001
|
-
handleTimeout: null,
|
|
12002
|
-
beforeAttempt: null,
|
|
12003
|
-
calculateDelay: null
|
|
12004
|
-
};
|
|
12005
|
-
var sendRequest = async (uri, method, apiKey, body, retryOptions) => {
|
|
12006
|
-
try {
|
|
12007
|
-
const headers = {
|
|
12008
|
-
"Content-Type": "application/json"
|
|
12009
|
-
};
|
|
12010
|
-
if (apiKey) {
|
|
12011
|
-
headers["X-Api-Key"] = apiKey;
|
|
12198
|
+
static async getChain(chainInput) {
|
|
12199
|
+
if (chainInput.chainIdentifier instanceof _Chain) {
|
|
12200
|
+
return chainInput.chainIdentifier;
|
|
12012
12201
|
}
|
|
12013
|
-
|
|
12014
|
-
|
|
12015
|
-
|
|
12016
|
-
|
|
12017
|
-
|
|
12018
|
-
|
|
12019
|
-
method,
|
|
12020
|
-
headers,
|
|
12021
|
-
redirect: "follow",
|
|
12022
|
-
body: method !== "GET" ? stringify(body) : void 0
|
|
12023
|
-
});
|
|
12024
|
-
const json = await response.json();
|
|
12025
|
-
if (response.ok) {
|
|
12026
|
-
return json;
|
|
12027
|
-
}
|
|
12028
|
-
if (response.status === 400) {
|
|
12029
|
-
throw new InvalidParameterError2(
|
|
12030
|
-
ErrorCode2.InvalidParameter,
|
|
12031
|
-
`bad request ${JSON.stringify(json)}`,
|
|
12032
|
-
`bad request ${JSON.stringify(json)}`,
|
|
12033
|
-
{ body },
|
|
12034
|
-
"check the api call parameters. its mostly because some call parameters are wrong",
|
|
12035
|
-
"https://docs.fun.xyz"
|
|
12036
|
-
);
|
|
12037
|
-
}
|
|
12038
|
-
if (response.status === 403) {
|
|
12039
|
-
throw new AccessDeniedError(
|
|
12040
|
-
ErrorCode2.Unauthorized,
|
|
12041
|
-
"Invalid API key or insufficient access.",
|
|
12042
|
-
"Invalid API key or insufficient access.",
|
|
12043
|
-
{ apiKey },
|
|
12044
|
-
"Check your api key at https://app.fun.xyz and check with fun team if you believe something is off",
|
|
12045
|
-
"https://docs.fun.xyz"
|
|
12046
|
-
);
|
|
12047
|
-
}
|
|
12048
|
-
if (response.status === 404) {
|
|
12049
|
-
throw new ResourceNotFoundError(
|
|
12050
|
-
ErrorCode2.ServerMissingData,
|
|
12051
|
-
JSON.stringify(json),
|
|
12052
|
-
JSON.stringify(json),
|
|
12053
|
-
{ body },
|
|
12054
|
-
"check the api call parameters. its mostly because some call parameters are wrong",
|
|
12055
|
-
"https://docs.fun.xyz"
|
|
12056
|
-
);
|
|
12057
|
-
}
|
|
12058
|
-
if (response.status === 429) {
|
|
12059
|
-
throw new ThrottlingError(
|
|
12060
|
-
ErrorCode2.RequestLimitExceeded,
|
|
12061
|
-
`too many requests ${JSON.stringify(json)}`,
|
|
12062
|
-
`too many requests ${JSON.stringify(json)}`,
|
|
12063
|
-
{ body },
|
|
12064
|
-
"you are making too many requests. please slow down. Reach out to fun team if you need more quota",
|
|
12065
|
-
"https://docs.fun.xyz"
|
|
12066
|
-
);
|
|
12067
|
-
}
|
|
12068
|
-
if (response.status === 500) {
|
|
12069
|
-
if (json.errorCode === ErrorCode2.UserOpFailureError) {
|
|
12070
|
-
throw new UserOpFailureError(
|
|
12071
|
-
ErrorCode2.UserOpFailureError,
|
|
12072
|
-
JSON.stringify(json),
|
|
12073
|
-
JSON.stringify(json),
|
|
12074
|
-
{ body },
|
|
12075
|
-
"fix user op failure. Most of the time this is due to invalid parameters",
|
|
12076
|
-
"https://docs.fun.xyz"
|
|
12077
|
-
);
|
|
12078
|
-
}
|
|
12079
|
-
throw new InternalFailureError(
|
|
12080
|
-
ErrorCode2.ServerFailure,
|
|
12081
|
-
`server failure ${JSON.stringify(json)}`,
|
|
12082
|
-
json.errorMsg,
|
|
12083
|
-
{ body },
|
|
12084
|
-
"retry later. if it still fails, please contact us.",
|
|
12085
|
-
"https://docs.fun.xyz"
|
|
12086
|
-
);
|
|
12087
|
-
}
|
|
12088
|
-
if (response.status === 504) {
|
|
12089
|
-
throw new InternalFailureError(
|
|
12090
|
-
ErrorCode2.ServerTimeout,
|
|
12091
|
-
`server timeout failure ${JSON.stringify(json)}`,
|
|
12092
|
-
json.errorMsg,
|
|
12093
|
-
{ body },
|
|
12094
|
-
"retry later. if it still fails, please contact us.",
|
|
12095
|
-
"https://docs.fun.xyz"
|
|
12096
|
-
);
|
|
12097
|
-
}
|
|
12098
|
-
if (!response.ok) {
|
|
12099
|
-
throw new InternalFailureError(
|
|
12100
|
-
ErrorCode2.UnknownServerError,
|
|
12101
|
-
`unknown server failure ${JSON.stringify(json)}`,
|
|
12102
|
-
json.errorMsg,
|
|
12103
|
-
{ body },
|
|
12104
|
-
"retry later. if it still fails, please contact us.",
|
|
12105
|
-
"https://docs.fun.xyz"
|
|
12106
|
-
);
|
|
12107
|
-
}
|
|
12108
|
-
return {};
|
|
12109
|
-
}, finalRetryOptions);
|
|
12110
|
-
} catch (err) {
|
|
12111
|
-
throw new InternalFailureError(
|
|
12112
|
-
ErrorCode2.ServerConnectionError,
|
|
12113
|
-
`Cannot connect to Fun API Service ${err}`,
|
|
12114
|
-
"",
|
|
12115
|
-
{ body },
|
|
12116
|
-
"retry later. if it still fails, please contact us.",
|
|
12117
|
-
"https://docs.fun.xyz"
|
|
12118
|
-
);
|
|
12119
|
-
}
|
|
12120
|
-
};
|
|
12121
|
-
async function sendGetRequest(uri, endpoint, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
|
|
12122
|
-
return await sendRequest(
|
|
12123
|
-
`${uri}/${endpoint}`,
|
|
12124
|
-
"GET",
|
|
12125
|
-
apiKey,
|
|
12126
|
-
void 0,
|
|
12127
|
-
retryOptions
|
|
12128
|
-
);
|
|
12129
|
-
}
|
|
12130
|
-
async function sendPostRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption?.apiKey, retryOptions = {}) {
|
|
12131
|
-
return await sendRequest(
|
|
12132
|
-
`${uri}/${endpoint}`,
|
|
12133
|
-
"POST",
|
|
12134
|
-
apiKey,
|
|
12135
|
-
body,
|
|
12136
|
-
retryOptions
|
|
12137
|
-
);
|
|
12138
|
-
}
|
|
12139
|
-
async function sendDeleteRequest(uri, endpoint, apiKey = globalThis.globalEnvOption.apiKey) {
|
|
12140
|
-
await sendRequest(`${uri}/${endpoint}`, "DELETE", apiKey);
|
|
12141
|
-
}
|
|
12142
|
-
async function sendPutRequest(uri, endpoint, body, apiKey = globalThis.globalEnvOption.apiKey) {
|
|
12143
|
-
await sendRequest(`${uri}/${endpoint}`, "PUT", apiKey, body);
|
|
12144
|
-
}
|
|
12145
|
-
|
|
12146
|
-
// src/apis/InfoApis.ts
|
|
12147
|
-
async function getTokenInfo(symbol, chainId) {
|
|
12148
|
-
const normalizedSymbol = symbol.toLowerCase();
|
|
12149
|
-
const body = {
|
|
12150
|
-
symbol: normalizedSymbol,
|
|
12151
|
-
chain: chainId
|
|
12152
|
-
};
|
|
12153
|
-
if (normalizedSymbol === "weth" && chainId !== "137" && Object.keys(BASE_WRAP_TOKEN_ADDR).includes(chainId)) {
|
|
12154
|
-
return BASE_WRAP_TOKEN_ADDR[chainId][normalizedSymbol];
|
|
12155
|
-
} else if (normalizedSymbol === "wmatic" && chainId === "137") {
|
|
12156
|
-
return BASE_WRAP_TOKEN_ADDR[chainId][normalizedSymbol];
|
|
12157
|
-
}
|
|
12158
|
-
const tokenInfo = await sendGetRequest(
|
|
12159
|
-
API_URL,
|
|
12160
|
-
`asset/erc20/${body.chain}/${body.symbol}`
|
|
12161
|
-
);
|
|
12162
|
-
if (tokenInfo.address) {
|
|
12163
|
-
return tokenInfo.address;
|
|
12164
|
-
}
|
|
12165
|
-
throw new ResourceNotFoundError2(
|
|
12166
|
-
ErrorCode3.TokenNotFound,
|
|
12167
|
-
"token symbol does not exist on provided chain",
|
|
12168
|
-
"token symbol does not exist on provided chain",
|
|
12169
|
-
{ symbol, chainId },
|
|
12170
|
-
"Provide correct symbol and chainId.",
|
|
12171
|
-
"https://docs.fun.xyz"
|
|
12172
|
-
);
|
|
12173
|
-
}
|
|
12174
|
-
async function getChainFromId(chainId) {
|
|
12175
|
-
return await sendGetRequest(API_URL, `chain-info/${chainId}`).then((r) => {
|
|
12176
|
-
if (!r) {
|
|
12177
|
-
throw new Error(JSON.stringify(r));
|
|
12178
|
-
}
|
|
12179
|
-
return r;
|
|
12180
|
-
});
|
|
12181
|
-
}
|
|
12182
|
-
async function getChainFromName(name) {
|
|
12183
|
-
return await sendGetRequest(API_URL, `chain-info?name=${name}`).then((r) => {
|
|
12184
|
-
if (!r) {
|
|
12185
|
-
throw new Error(JSON.stringify(r));
|
|
12186
|
-
}
|
|
12187
|
-
return r;
|
|
12188
|
-
});
|
|
12189
|
-
}
|
|
12190
|
-
async function getModuleInfo(moduleName, chainId) {
|
|
12191
|
-
const body = {
|
|
12192
|
-
module: moduleName,
|
|
12193
|
-
chain: chainId
|
|
12194
|
-
};
|
|
12195
|
-
return await sendPostRequest(API_URL, "get-module-info", body).then((r) => {
|
|
12196
|
-
return r.data;
|
|
12197
|
-
});
|
|
12198
|
-
}
|
|
12199
|
-
async function getPaymasterAddress(chainId) {
|
|
12200
|
-
const {
|
|
12201
|
-
moduleAddresses: {
|
|
12202
|
-
paymaster: { paymasterAddress }
|
|
12203
|
-
}
|
|
12204
|
-
} = await getChainFromId(chainId);
|
|
12205
|
-
return paymasterAddress;
|
|
12206
|
-
}
|
|
12207
|
-
|
|
12208
|
-
// src/apis/OperationApis.ts
|
|
12209
|
-
async function createOp(op) {
|
|
12210
|
-
return (await sendPostRequest(API_URL, "operation", { ...op })).opId;
|
|
12211
|
-
}
|
|
12212
|
-
async function getOpsOfGroup(groupId, chainId, status) {
|
|
12213
|
-
const endpoint = status === "" /* ALL */ ? `operation/group/${groupId}/${chainId}` : `operation/group/${groupId}/chain/${chainId}?status=${status}`;
|
|
12214
|
-
return (await sendGetRequest(API_URL, endpoint)).operations;
|
|
12215
|
-
}
|
|
12216
|
-
async function getOpsOfWallet(walletAddr, chainId, status) {
|
|
12217
|
-
const endpoint = status ? `operation/wallet/${walletAddr}/chain/${chainId}?status=${status}` : `operation/wallet/${walletAddr}/chain/${chainId}`;
|
|
12218
|
-
return (await sendGetRequest(API_URL, endpoint)).operations;
|
|
12219
|
-
}
|
|
12220
|
-
async function getOps(opIds, chainId) {
|
|
12221
|
-
return (await sendPostRequest(API_URL, "operation/get-operations", {
|
|
12222
|
-
opIds,
|
|
12223
|
-
chainId
|
|
12224
|
-
})).operations;
|
|
12225
|
-
}
|
|
12226
|
-
async function deleteOp(opId, chainId) {
|
|
12227
|
-
await sendDeleteRequest(API_URL, `operation/${opId}/chain/${chainId}`);
|
|
12228
|
-
}
|
|
12229
|
-
async function signOp(opId, chainId, signature, signedBy, threshold) {
|
|
12230
|
-
await sendPostRequest(API_URL, "operation/sign", {
|
|
12231
|
-
opId,
|
|
12232
|
-
chainId,
|
|
12233
|
-
signature,
|
|
12234
|
-
signedBy,
|
|
12235
|
-
threshold
|
|
12236
|
-
});
|
|
12237
|
-
}
|
|
12238
|
-
async function executeOp(executeOpInput) {
|
|
12239
|
-
return await sendPostRequest(API_URL, "operation/execute", executeOpInput);
|
|
12240
|
-
}
|
|
12241
|
-
async function estimateOp(estimateOpInput) {
|
|
12242
|
-
return await sendPostRequest(API_URL, "operation/estimate", estimateOpInput);
|
|
12243
|
-
}
|
|
12244
|
-
async function scheduleOp(scheduleOpInput) {
|
|
12245
|
-
await sendPostRequest(API_URL, "operation/schedule", scheduleOpInput);
|
|
12246
|
-
}
|
|
12247
|
-
var getFullReceipt = async (opId, chainId, userOpHash) => {
|
|
12248
|
-
const retries = 20;
|
|
12249
|
-
let result;
|
|
12250
|
-
for (let i = 0; i < retries; i++) {
|
|
12251
|
-
try {
|
|
12252
|
-
result = await sendGetRequest(
|
|
12253
|
-
API_URL,
|
|
12254
|
-
`operation/${opId}/chain/${chainId}/receipt?userOpHash=${userOpHash}`
|
|
12255
|
-
);
|
|
12256
|
-
if (result.status === "included") {
|
|
12257
|
-
break;
|
|
12258
|
-
}
|
|
12259
|
-
} catch (_err) {
|
|
12260
|
-
}
|
|
12261
|
-
await new Promise((resolve) => setTimeout(resolve, 2500));
|
|
12262
|
-
}
|
|
12263
|
-
if (!result.receipt) {
|
|
12264
|
-
result.receipt = {
|
|
12265
|
-
txId: "Failed to find.",
|
|
12266
|
-
gasUsed: "Failed to find.",
|
|
12267
|
-
opFeeUSD: "Failed to find.",
|
|
12268
|
-
opFee: "Failed to find."
|
|
12269
|
-
};
|
|
12270
|
-
}
|
|
12271
|
-
return {
|
|
12272
|
-
...result.receipt
|
|
12273
|
-
};
|
|
12274
|
-
};
|
|
12275
|
-
var getGasPrice = async (chainId) => {
|
|
12276
|
-
return await sendGetRequest(API_URL, `operation/chain/${chainId}/gas-price`);
|
|
12277
|
-
};
|
|
12278
|
-
|
|
12279
|
-
// src/data/Chain.ts
|
|
12280
|
-
var Chain = class _Chain {
|
|
12281
|
-
constructor(chainInput) {
|
|
12282
|
-
this.initialized = false;
|
|
12283
|
-
this.addresses = {};
|
|
12284
|
-
if (!chainInput.chainIdentifier && !chainInput.rpcUrl) {
|
|
12285
|
-
throw new InvalidParameterError3(
|
|
12286
|
-
ErrorCode4.InvalidChainIdentifier,
|
|
12287
|
-
"valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
|
|
12288
|
-
"valid chain identifier or rpcUrl is required, could be chainId, chainName, Fun Chain object, or rpcUrl",
|
|
12289
|
-
{ chainInput },
|
|
12290
|
-
"Please provide valid chain identifier or rpcUrl",
|
|
12291
|
-
"https://docs.fun.xyz"
|
|
12292
|
-
);
|
|
12293
|
-
}
|
|
12294
|
-
if (chainInput.rpcUrl) {
|
|
12295
|
-
this.rpcUrl = chainInput.rpcUrl;
|
|
12296
|
-
} else if (chainInput.chainIdentifier instanceof _Chain) {
|
|
12297
|
-
return chainInput.chainIdentifier;
|
|
12298
|
-
} else if (typeof chainInput.chainIdentifier === "number" || Number(chainInput.chainIdentifier)) {
|
|
12299
|
-
this.id = chainInput.chainIdentifier.toString();
|
|
12300
|
-
} else {
|
|
12301
|
-
this.name = chainInput.chainIdentifier;
|
|
12302
|
-
}
|
|
12303
|
-
}
|
|
12304
|
-
static async getChain(chainInput) {
|
|
12305
|
-
if (chainInput.chainIdentifier instanceof _Chain) {
|
|
12306
|
-
return chainInput.chainIdentifier;
|
|
12307
|
-
}
|
|
12308
|
-
if (!_Chain.chain || await _Chain.chain.getChainId() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getChainName() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getRpcUrl() !== chainInput.rpcUrl) {
|
|
12309
|
-
if (typeof chainInput.chainIdentifier === "string") {
|
|
12310
|
-
chainInput.chainIdentifier = chainInput.chainIdentifier.replace(
|
|
12311
|
-
/\s/g,
|
|
12312
|
-
""
|
|
12313
|
-
);
|
|
12202
|
+
if (!_Chain.chain || await _Chain.chain.getChainId() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getChainName() !== chainInput.chainIdentifier?.toString() && await _Chain.chain.getRpcUrl() !== chainInput.rpcUrl) {
|
|
12203
|
+
if (typeof chainInput.chainIdentifier === "string") {
|
|
12204
|
+
chainInput.chainIdentifier = chainInput.chainIdentifier.replace(
|
|
12205
|
+
/\s/g,
|
|
12206
|
+
""
|
|
12207
|
+
);
|
|
12314
12208
|
}
|
|
12315
12209
|
if (chainInput.chainIdentifier === "ethereum-goerli") {
|
|
12316
12210
|
chainInput.chainIdentifier = "goerli";
|
|
@@ -12343,9 +12237,15 @@ var Chain = class _Chain {
|
|
|
12343
12237
|
async loadChain(identifier) {
|
|
12344
12238
|
let chain;
|
|
12345
12239
|
if (!Number(identifier)) {
|
|
12346
|
-
chain = await getChainFromName(
|
|
12240
|
+
chain = await getChainFromName({
|
|
12241
|
+
name: identifier,
|
|
12242
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
12243
|
+
});
|
|
12347
12244
|
} else {
|
|
12348
|
-
chain = await getChainFromId(
|
|
12245
|
+
chain = await getChainFromId({
|
|
12246
|
+
chainId: identifier,
|
|
12247
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
12248
|
+
});
|
|
12349
12249
|
}
|
|
12350
12250
|
this.id = chain.id;
|
|
12351
12251
|
this.name = chain.name;
|
|
@@ -12390,10 +12290,6 @@ var Chain = class _Chain {
|
|
|
12390
12290
|
}
|
|
12391
12291
|
return res;
|
|
12392
12292
|
}
|
|
12393
|
-
async getModuleAddresses(name) {
|
|
12394
|
-
await this.init();
|
|
12395
|
-
return await getModuleInfo(name, this.id);
|
|
12396
|
-
}
|
|
12397
12293
|
async getCurrency() {
|
|
12398
12294
|
await this.init();
|
|
12399
12295
|
return this.currency;
|
|
@@ -12406,7 +12302,10 @@ var Chain = class _Chain {
|
|
|
12406
12302
|
await this.init();
|
|
12407
12303
|
let result;
|
|
12408
12304
|
try {
|
|
12409
|
-
result = await
|
|
12305
|
+
result = await getUserOpGasPrice({
|
|
12306
|
+
chainId: this.id,
|
|
12307
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
12308
|
+
});
|
|
12410
12309
|
} catch (_err) {
|
|
12411
12310
|
const fallBackGasPrice = await this.client.getGasPrice();
|
|
12412
12311
|
result = {
|
|
@@ -12437,9 +12336,12 @@ var Chain = class _Chain {
|
|
|
12437
12336
|
estimationUserOp.paymasterAndData = ETHEREUM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION;
|
|
12438
12337
|
}
|
|
12439
12338
|
let { preVerificationGas, callGasLimit, verificationGasLimit } = await estimateOp({
|
|
12440
|
-
|
|
12441
|
-
|
|
12442
|
-
|
|
12339
|
+
input: {
|
|
12340
|
+
chainId: this.id,
|
|
12341
|
+
entryPointAddress: this.addresses.entryPointAddress,
|
|
12342
|
+
userOp: estimationUserOp
|
|
12343
|
+
},
|
|
12344
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
12443
12345
|
});
|
|
12444
12346
|
if (!preVerificationGas || !verificationGasLimit || !callGasLimit) {
|
|
12445
12347
|
throw new Error(
|
|
@@ -12806,7 +12708,12 @@ import {
|
|
|
12806
12708
|
InternalFailureError as InternalFailureError3,
|
|
12807
12709
|
InvalidParameterError as InvalidParameterError5
|
|
12808
12710
|
} from "@funkit/utils";
|
|
12809
|
-
var wrappedNativeTokens = {
|
|
12711
|
+
var wrappedNativeTokens = {
|
|
12712
|
+
eth: "weth",
|
|
12713
|
+
matic: "wmatic",
|
|
12714
|
+
pol: "wpol",
|
|
12715
|
+
mnt: "wmnt"
|
|
12716
|
+
};
|
|
12810
12717
|
var Token = class _Token {
|
|
12811
12718
|
constructor(input, chain) {
|
|
12812
12719
|
this.isNative = false;
|
|
@@ -12815,7 +12722,8 @@ var Token = class _Token {
|
|
|
12815
12722
|
if (isAddress3(input)) {
|
|
12816
12723
|
this.address = input;
|
|
12817
12724
|
return;
|
|
12818
|
-
}
|
|
12725
|
+
}
|
|
12726
|
+
if (input.toLowerCase() in wrappedNativeTokens) {
|
|
12819
12727
|
this.isNative = true;
|
|
12820
12728
|
}
|
|
12821
12729
|
this.symbol = input.toLowerCase();
|
|
@@ -12824,13 +12732,13 @@ var Token = class _Token {
|
|
|
12824
12732
|
const chainId = await this.chain.getChainId();
|
|
12825
12733
|
if (this.isNative) {
|
|
12826
12734
|
const nativeName = wrappedNativeTokens[this.symbol];
|
|
12827
|
-
return await
|
|
12735
|
+
return await getTokenAddressBySymbolAndChainId(nativeName, chainId);
|
|
12828
12736
|
}
|
|
12829
12737
|
if (this.address) {
|
|
12830
12738
|
return this.address;
|
|
12831
12739
|
}
|
|
12832
12740
|
if (this.symbol) {
|
|
12833
|
-
return await
|
|
12741
|
+
return await getTokenAddressBySymbolAndChainId(this.symbol, chainId);
|
|
12834
12742
|
}
|
|
12835
12743
|
throw new InternalFailureError3(
|
|
12836
12744
|
ErrorCode6.ServerMissingData,
|
|
@@ -12953,29 +12861,6 @@ var Token = class _Token {
|
|
|
12953
12861
|
}
|
|
12954
12862
|
};
|
|
12955
12863
|
|
|
12956
|
-
// src/data/types.ts
|
|
12957
|
-
var AuthType = /* @__PURE__ */ ((AuthType2) => {
|
|
12958
|
-
AuthType2[AuthType2["ECDSA"] = 0] = "ECDSA";
|
|
12959
|
-
AuthType2[AuthType2["MULTI_SIG"] = 1] = "MULTI_SIG";
|
|
12960
|
-
return AuthType2;
|
|
12961
|
-
})(AuthType || {});
|
|
12962
|
-
var OperationType = /* @__PURE__ */ ((OperationType2) => {
|
|
12963
|
-
OperationType2["SINGLE_OPERATION"] = "SINGLE_OPERATION";
|
|
12964
|
-
OperationType2["GROUP_OPERATION"] = "GROUP_OPERATION";
|
|
12965
|
-
OperationType2["REJECTION"] = "REJECTION";
|
|
12966
|
-
return OperationType2;
|
|
12967
|
-
})(OperationType || {});
|
|
12968
|
-
var OperationStatus = /* @__PURE__ */ ((OperationStatus2) => {
|
|
12969
|
-
OperationStatus2["ALL"] = "";
|
|
12970
|
-
OperationStatus2["PENDING_APPROVED"] = "PENDING_APPROVED";
|
|
12971
|
-
OperationStatus2["APPROVED"] = "APPROVED";
|
|
12972
|
-
OperationStatus2["PENDING"] = "PENDING";
|
|
12973
|
-
OperationStatus2["OP_SUCCEED"] = "OP_SUCCEED";
|
|
12974
|
-
OperationStatus2["OP_REVERTED"] = "OP_REVERTED";
|
|
12975
|
-
OperationStatus2["SCHEDULED"] = "SCHEDULED";
|
|
12976
|
-
return OperationStatus2;
|
|
12977
|
-
})(OperationStatus || {});
|
|
12978
|
-
|
|
12979
12864
|
// src/viem/ContractInterface.ts
|
|
12980
12865
|
var ContractInterface = class {
|
|
12981
12866
|
constructor(abi) {
|
|
@@ -13071,8 +12956,6 @@ var getItemFromAbi = (abi, name, type) => {
|
|
|
13071
12956
|
};
|
|
13072
12957
|
|
|
13073
12958
|
// src/common/constants.ts
|
|
13074
|
-
var LOCAL_API_URL = "http://127.0.0.1:3000";
|
|
13075
|
-
var API_URL = "https://api.fun.xyz/v1";
|
|
13076
12959
|
var BASE_WRAP_TOKEN_ADDR = {
|
|
13077
12960
|
"1": {
|
|
13078
12961
|
weth: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"
|
|
@@ -13084,7 +12967,8 @@ var BASE_WRAP_TOKEN_ADDR = {
|
|
|
13084
12967
|
weth: "0x4200000000000000000000000000000000000006"
|
|
13085
12968
|
},
|
|
13086
12969
|
"137": {
|
|
13087
|
-
wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"
|
|
12970
|
+
wmatic: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270",
|
|
12971
|
+
wpol: "0x0d500b1d8e8ef31e21c99d1db9a6444d3adf1270"
|
|
13088
12972
|
},
|
|
13089
12973
|
"5000": {
|
|
13090
12974
|
weth: "0xdEAddEaDdeadDEadDEADDEAddEADDEAddead1111"
|
|
@@ -13220,376 +13104,7 @@ var BYTES32_LENGTH = 66;
|
|
|
13220
13104
|
var BASE_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0xa880eae8900eb59bf7dad9bdb741a086238adca900000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
|
|
13221
13105
|
var OPTIMISM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0x4Df91e173A6CdC74EfeF6fC72bb5Df1E8A8d758200000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
|
|
13222
13106
|
var ETHEREUM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION = "0x67F21bE69A16c314a0b7Da537309b2f3ADdDE03100000000000000000000000000000000000000000000000000000101010101010000000000000000000000000000000000000000000000000000000000000000cd91f19f0f19ce862d7bec7b7d9b95457145afc6f639c28fd0360f488937bfa41e6eedcd3a46054fd95fcd0e3ef6b0bc0a615c4d975eef55c8a3517257904d5b1c";
|
|
13223
|
-
var DYDX_MAINNET_CHAIN_ID = 1511490300;
|
|
13224
|
-
var dydxChain = {
|
|
13225
|
-
id: DYDX_MAINNET_CHAIN_ID,
|
|
13226
|
-
name: "dYdX",
|
|
13227
|
-
nativeCurrency: {
|
|
13228
|
-
symbol: "DYDX",
|
|
13229
|
-
decimals: 18,
|
|
13230
|
-
name: "dYdX Staking Coin"
|
|
13231
|
-
},
|
|
13232
|
-
rpcUrls: {
|
|
13233
|
-
default: {
|
|
13234
|
-
http: ["https://dydx-dao-rpc.polkachu.com:443 "]
|
|
13235
|
-
}
|
|
13236
|
-
},
|
|
13237
|
-
blockExplorers: {
|
|
13238
|
-
default: {
|
|
13239
|
-
name: "Mintscan",
|
|
13240
|
-
url: "https://www.mintscan.io/dydx",
|
|
13241
|
-
apiUrl: ""
|
|
13242
|
-
}
|
|
13243
|
-
},
|
|
13244
|
-
contracts: {
|
|
13245
|
-
ensRegistry: {
|
|
13246
|
-
address: "0x"
|
|
13247
|
-
},
|
|
13248
|
-
ensUniversalResolver: {
|
|
13249
|
-
address: "0x",
|
|
13250
|
-
blockCreated: -1
|
|
13251
|
-
},
|
|
13252
|
-
multicall3: {
|
|
13253
|
-
address: "0x",
|
|
13254
|
-
blockCreated: -1
|
|
13255
|
-
}
|
|
13256
|
-
}
|
|
13257
|
-
};
|
|
13258
13107
|
var STABLECOIN_SYMBOLS = ["USDC", "USDC.e", "USDT", "DAI"];
|
|
13259
|
-
var FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO = {
|
|
13260
|
-
/** MAINNETS **/
|
|
13261
|
-
[mainnet.id.toString()]: {
|
|
13262
|
-
name: mainnet.name,
|
|
13263
|
-
nativeCurrency: {
|
|
13264
|
-
symbol: mainnet.nativeCurrency.symbol,
|
|
13265
|
-
decimals: mainnet.nativeCurrency.decimals,
|
|
13266
|
-
name: mainnet.nativeCurrency.name
|
|
13267
|
-
},
|
|
13268
|
-
chainInfo: mainnet,
|
|
13269
|
-
explorerInfo: mainnet.blockExplorers.default,
|
|
13270
|
-
isCheckoutSupported: true,
|
|
13271
|
-
checkoutAssetWhitelist: ["*"],
|
|
13272
|
-
isFunWalletSupported: true,
|
|
13273
|
-
isMainnet: true,
|
|
13274
|
-
moonpayChainName: "",
|
|
13275
|
-
pickPriority: 4,
|
|
13276
|
-
isStandardEvmAddress: true,
|
|
13277
|
-
fallbackRpcUrls: ["https://eth.llamarpc.com", "https://rpc.ankr.com/eth"]
|
|
13278
|
-
},
|
|
13279
|
-
[base.id.toString()]: {
|
|
13280
|
-
name: base.name,
|
|
13281
|
-
nativeCurrency: {
|
|
13282
|
-
symbol: base.nativeCurrency.symbol,
|
|
13283
|
-
decimals: base.nativeCurrency.decimals,
|
|
13284
|
-
name: base.nativeCurrency.name
|
|
13285
|
-
},
|
|
13286
|
-
chainInfo: base,
|
|
13287
|
-
explorerInfo: base.blockExplorers.default,
|
|
13288
|
-
isCheckoutSupported: true,
|
|
13289
|
-
checkoutAssetWhitelist: ["*"],
|
|
13290
|
-
isFunWalletSupported: true,
|
|
13291
|
-
isMainnet: true,
|
|
13292
|
-
moonpayChainName: "base",
|
|
13293
|
-
pickPriority: 2,
|
|
13294
|
-
isStandardEvmAddress: true,
|
|
13295
|
-
fallbackRpcUrls: [
|
|
13296
|
-
"https://base.llamarpc.com",
|
|
13297
|
-
"https://base-rpc.publicnode.com"
|
|
13298
|
-
]
|
|
13299
|
-
},
|
|
13300
|
-
[polygon.id.toString()]: {
|
|
13301
|
-
name: polygon.name,
|
|
13302
|
-
nativeCurrency: {
|
|
13303
|
-
symbol: polygon.nativeCurrency.symbol,
|
|
13304
|
-
decimals: polygon.nativeCurrency.decimals,
|
|
13305
|
-
name: polygon.nativeCurrency.name
|
|
13306
|
-
},
|
|
13307
|
-
coreToken: {
|
|
13308
|
-
symbol: "MATIC",
|
|
13309
|
-
decimals: 18,
|
|
13310
|
-
name: "MATIC"
|
|
13311
|
-
},
|
|
13312
|
-
chainInfo: polygon,
|
|
13313
|
-
explorerInfo: polygon.blockExplorers.default,
|
|
13314
|
-
isCheckoutSupported: true,
|
|
13315
|
-
checkoutAssetWhitelist: ["*"],
|
|
13316
|
-
isFunWalletSupported: true,
|
|
13317
|
-
isMainnet: true,
|
|
13318
|
-
moonpayChainName: "polygon",
|
|
13319
|
-
pickPriority: 1,
|
|
13320
|
-
isStandardEvmAddress: true,
|
|
13321
|
-
fallbackRpcUrls: [
|
|
13322
|
-
"https://polygon.llamarpc.com",
|
|
13323
|
-
"https://api.zan.top/polygon-mainnet"
|
|
13324
|
-
]
|
|
13325
|
-
},
|
|
13326
|
-
[arbitrum.id.toString()]: {
|
|
13327
|
-
name: "Arbitrum",
|
|
13328
|
-
// arbitrum.name returns 'Arbitrum One' which is too wordy for us.
|
|
13329
|
-
nativeCurrency: {
|
|
13330
|
-
symbol: arbitrum.nativeCurrency.symbol,
|
|
13331
|
-
decimals: arbitrum.nativeCurrency.decimals,
|
|
13332
|
-
name: arbitrum.nativeCurrency.name
|
|
13333
|
-
},
|
|
13334
|
-
coreToken: {
|
|
13335
|
-
symbol: "ARB",
|
|
13336
|
-
decimals: 18,
|
|
13337
|
-
name: "Arbitrium"
|
|
13338
|
-
},
|
|
13339
|
-
chainInfo: arbitrum,
|
|
13340
|
-
explorerInfo: arbitrum.blockExplorers.default,
|
|
13341
|
-
isCheckoutSupported: true,
|
|
13342
|
-
checkoutAssetWhitelist: ["*"],
|
|
13343
|
-
isFunWalletSupported: true,
|
|
13344
|
-
isMainnet: true,
|
|
13345
|
-
moonpayChainName: "arbitrum",
|
|
13346
|
-
pickPriority: 3,
|
|
13347
|
-
isStandardEvmAddress: true,
|
|
13348
|
-
fallbackRpcUrls: ["https://arbitrum.llamarpc.com"]
|
|
13349
|
-
},
|
|
13350
|
-
[optimism.id.toString()]: {
|
|
13351
|
-
name: optimism.name,
|
|
13352
|
-
nativeCurrency: {
|
|
13353
|
-
symbol: optimism.nativeCurrency.symbol,
|
|
13354
|
-
decimals: optimism.nativeCurrency.decimals,
|
|
13355
|
-
name: optimism.nativeCurrency.name
|
|
13356
|
-
},
|
|
13357
|
-
coreToken: {
|
|
13358
|
-
symbol: "OP",
|
|
13359
|
-
decimals: 18,
|
|
13360
|
-
name: "Optimism"
|
|
13361
|
-
},
|
|
13362
|
-
chainInfo: optimism,
|
|
13363
|
-
explorerInfo: optimism.blockExplorers.default,
|
|
13364
|
-
// Not supported for checkouts on backend yet
|
|
13365
|
-
isCheckoutSupported: false,
|
|
13366
|
-
checkoutAssetWhitelist: [],
|
|
13367
|
-
isFunWalletSupported: true,
|
|
13368
|
-
isMainnet: true,
|
|
13369
|
-
moonpayChainName: "optimism",
|
|
13370
|
-
// Not supported for checkouts yet
|
|
13371
|
-
pickPriority: Number.MAX_SAFE_INTEGER,
|
|
13372
|
-
isStandardEvmAddress: true,
|
|
13373
|
-
fallbackRpcUrls: [
|
|
13374
|
-
"https://optimism.llamarpc.com",
|
|
13375
|
-
"https://optimism.gateway.tenderly.co"
|
|
13376
|
-
]
|
|
13377
|
-
},
|
|
13378
|
-
[zkSync.id.toString()]: {
|
|
13379
|
-
name: "zkSync",
|
|
13380
|
-
nativeCurrency: {
|
|
13381
|
-
symbol: zkSync.nativeCurrency.symbol,
|
|
13382
|
-
decimals: zkSync.nativeCurrency.decimals,
|
|
13383
|
-
name: zkSync.nativeCurrency.name
|
|
13384
|
-
},
|
|
13385
|
-
coreToken: {
|
|
13386
|
-
symbol: "ZK",
|
|
13387
|
-
decimals: 18,
|
|
13388
|
-
name: "zkSync"
|
|
13389
|
-
},
|
|
13390
|
-
chainInfo: zkSync,
|
|
13391
|
-
explorerInfo: zkSync.blockExplorers.default,
|
|
13392
|
-
isCheckoutSupported: false,
|
|
13393
|
-
checkoutAssetWhitelist: ["*"],
|
|
13394
|
-
isFunWalletSupported: false,
|
|
13395
|
-
isMainnet: true,
|
|
13396
|
-
moonpayChainName: "base",
|
|
13397
|
-
// default to base for zksync era on moonpay
|
|
13398
|
-
pickPriority: 5,
|
|
13399
|
-
isStandardEvmAddress: true,
|
|
13400
|
-
fallbackRpcUrls: [
|
|
13401
|
-
"https://1rpc.io/zksync2-era",
|
|
13402
|
-
"https://zksync.meowrpc.com"
|
|
13403
|
-
]
|
|
13404
|
-
},
|
|
13405
|
-
[mantle.id.toString()]: {
|
|
13406
|
-
name: mantle.name,
|
|
13407
|
-
nativeCurrency: {
|
|
13408
|
-
symbol: mantle.nativeCurrency.symbol,
|
|
13409
|
-
decimals: mantle.nativeCurrency.decimals,
|
|
13410
|
-
name: mantle.nativeCurrency.name
|
|
13411
|
-
},
|
|
13412
|
-
coreToken: {
|
|
13413
|
-
symbol: "MNT",
|
|
13414
|
-
decimals: 18,
|
|
13415
|
-
name: "Mantle"
|
|
13416
|
-
},
|
|
13417
|
-
chainInfo: mantle,
|
|
13418
|
-
explorerInfo: mantle.blockExplorers.default,
|
|
13419
|
-
isCheckoutSupported: true,
|
|
13420
|
-
checkoutAssetWhitelist: [
|
|
13421
|
-
// USDC.e
|
|
13422
|
-
"0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9".toLowerCase(),
|
|
13423
|
-
// USDe
|
|
13424
|
-
"0x5d3a1Ff2b6BAb83b63cd9AD0787074081a52ef34".toLowerCase()
|
|
13425
|
-
],
|
|
13426
|
-
isFunWalletSupported: true,
|
|
13427
|
-
isMainnet: true,
|
|
13428
|
-
moonpayChainName: "base",
|
|
13429
|
-
// default to base for mantle on moonpay
|
|
13430
|
-
pickPriority: 6,
|
|
13431
|
-
isStandardEvmAddress: false,
|
|
13432
|
-
fallbackRpcUrls: [
|
|
13433
|
-
"https://mantle.drpc.org",
|
|
13434
|
-
"https://mantle-rpc.publicnode.com"
|
|
13435
|
-
]
|
|
13436
|
-
},
|
|
13437
|
-
[dydxChain.id.toString()]: {
|
|
13438
|
-
name: dydxChain.name,
|
|
13439
|
-
nativeCurrency: {
|
|
13440
|
-
symbol: dydxChain.nativeCurrency.symbol,
|
|
13441
|
-
decimals: dydxChain.nativeCurrency.decimals,
|
|
13442
|
-
name: dydxChain.nativeCurrency.name
|
|
13443
|
-
},
|
|
13444
|
-
chainInfo: dydxChain,
|
|
13445
|
-
explorerInfo: dydxChain.blockExplorers.default,
|
|
13446
|
-
// We cannot pay with dYdX / cosmos tokens yet
|
|
13447
|
-
isCheckoutSupported: false,
|
|
13448
|
-
checkoutAssetWhitelist: [
|
|
13449
|
-
// USDC
|
|
13450
|
-
"0x8E27BA2D5493AF5636760E354E46004562C46AB7EC0CC4C1CA14E9E20E2545B5".toLowerCase()
|
|
13451
|
-
],
|
|
13452
|
-
isFunWalletSupported: false,
|
|
13453
|
-
isMainnet: true,
|
|
13454
|
-
moonpayChainName: "base",
|
|
13455
|
-
// default to base for dydx on moonpay
|
|
13456
|
-
pickPriority: Number.MAX_SAFE_INTEGER,
|
|
13457
|
-
isStandardEvmAddress: false,
|
|
13458
|
-
fallbackRpcUrls: []
|
|
13459
|
-
},
|
|
13460
|
-
[scroll.id.toString()]: {
|
|
13461
|
-
name: scroll.name,
|
|
13462
|
-
nativeCurrency: {
|
|
13463
|
-
symbol: scroll.nativeCurrency.symbol,
|
|
13464
|
-
decimals: scroll.nativeCurrency.decimals,
|
|
13465
|
-
name: scroll.nativeCurrency.name
|
|
13466
|
-
},
|
|
13467
|
-
chainInfo: scroll,
|
|
13468
|
-
explorerInfo: scroll.blockExplorers.default,
|
|
13469
|
-
isCheckoutSupported: false,
|
|
13470
|
-
checkoutAssetWhitelist: [
|
|
13471
|
-
// USDC
|
|
13472
|
-
"0x06eFdBFf2a14a7c8E15944D1F4A48F9F95F663A4".toLowerCase(),
|
|
13473
|
-
// USDT
|
|
13474
|
-
"0xf55bec9cafdbe8730f096aa55dad6d22d44099df".toLowerCase()
|
|
13475
|
-
],
|
|
13476
|
-
isFunWalletSupported: true,
|
|
13477
|
-
isMainnet: true,
|
|
13478
|
-
moonpayChainName: "base",
|
|
13479
|
-
// default to base for scroll on moonpay
|
|
13480
|
-
pickPriority: 7,
|
|
13481
|
-
isStandardEvmAddress: false,
|
|
13482
|
-
fallbackRpcUrls: [
|
|
13483
|
-
"https://rpc.ankr.com/scroll",
|
|
13484
|
-
"https://scroll-mainnet.public.blastapi.io"
|
|
13485
|
-
]
|
|
13486
|
-
},
|
|
13487
|
-
/** TESTNETS **/
|
|
13488
|
-
[goerli.id.toString()]: {
|
|
13489
|
-
name: goerli.name,
|
|
13490
|
-
nativeCurrency: {
|
|
13491
|
-
symbol: goerli.nativeCurrency.symbol,
|
|
13492
|
-
decimals: goerli.nativeCurrency.decimals,
|
|
13493
|
-
name: goerli.nativeCurrency.name
|
|
13494
|
-
},
|
|
13495
|
-
chainInfo: goerli,
|
|
13496
|
-
explorerInfo: goerli.blockExplorers.default,
|
|
13497
|
-
isCheckoutSupported: true,
|
|
13498
|
-
checkoutAssetWhitelist: ["*"],
|
|
13499
|
-
isFunWalletSupported: true,
|
|
13500
|
-
// testnet has no fiat checkouts supported
|
|
13501
|
-
isMainnet: false,
|
|
13502
|
-
moonpayChainName: null,
|
|
13503
|
-
pickPriority: Number.MAX_SAFE_INTEGER,
|
|
13504
|
-
isStandardEvmAddress: true,
|
|
13505
|
-
fallbackRpcUrls: []
|
|
13506
|
-
},
|
|
13507
|
-
[arbitrumSepolia.id.toString()]: {
|
|
13508
|
-
name: arbitrumSepolia.name,
|
|
13509
|
-
nativeCurrency: {
|
|
13510
|
-
symbol: arbitrumSepolia.nativeCurrency.symbol,
|
|
13511
|
-
decimals: arbitrumSepolia.nativeCurrency.decimals,
|
|
13512
|
-
name: arbitrumSepolia.nativeCurrency.name
|
|
13513
|
-
},
|
|
13514
|
-
chainInfo: arbitrumSepolia,
|
|
13515
|
-
explorerInfo: {
|
|
13516
|
-
name: "Arbiscan",
|
|
13517
|
-
url: "https://sepolia.arbiscan.io"
|
|
13518
|
-
},
|
|
13519
|
-
isCheckoutSupported: true,
|
|
13520
|
-
checkoutAssetWhitelist: ["*"],
|
|
13521
|
-
isFunWalletSupported: true,
|
|
13522
|
-
// testnet has no fiat checkouts supported
|
|
13523
|
-
isMainnet: false,
|
|
13524
|
-
moonpayChainName: null,
|
|
13525
|
-
pickPriority: Number.MAX_SAFE_INTEGER,
|
|
13526
|
-
isStandardEvmAddress: false,
|
|
13527
|
-
fallbackRpcUrls: []
|
|
13528
|
-
}
|
|
13529
|
-
};
|
|
13530
|
-
var FUNKIT_CONNECT_SUPPORTED_CHAINS_ID_LIST = Object.keys(
|
|
13531
|
-
FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO
|
|
13532
|
-
);
|
|
13533
|
-
var FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO_LIST = Object.values(
|
|
13534
|
-
FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO
|
|
13535
|
-
).map((item) => item.chainInfo);
|
|
13536
|
-
var FUNKIT_CONNECT_SUPPORTED_CHECKOUT_CHAINS_INFO_LIST = FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO_LIST.filter(
|
|
13537
|
-
(chainInfo) => FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO[chainInfo.id]?.isCheckoutSupported && FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO[chainInfo.id]?.isMainnet
|
|
13538
|
-
);
|
|
13539
|
-
var FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
13540
|
-
|
|
13541
|
-
// src/apis/UserApis.ts
|
|
13542
|
-
async function createUser(authId, addr, method, userUniqueId) {
|
|
13543
|
-
await sendPostRequest(API_URL, "user", {
|
|
13544
|
-
authId,
|
|
13545
|
-
addr,
|
|
13546
|
-
method,
|
|
13547
|
-
userUniqueId
|
|
13548
|
-
});
|
|
13549
|
-
}
|
|
13550
|
-
async function getUserUniqueId(authId) {
|
|
13551
|
-
try {
|
|
13552
|
-
return (await sendGetRequest(API_URL, `user/auth/${authId}/unique-id`)).userUniqueId;
|
|
13553
|
-
} catch (err) {
|
|
13554
|
-
if (err instanceof ResourceNotFoundError4) {
|
|
13555
|
-
return "";
|
|
13556
|
-
}
|
|
13557
|
-
throw err;
|
|
13558
|
-
}
|
|
13559
|
-
}
|
|
13560
|
-
async function getUserAddr(authId) {
|
|
13561
|
-
return (await sendGetRequest(API_URL, `user/auth/${authId}/addr`)).addr;
|
|
13562
|
-
}
|
|
13563
|
-
async function getUserWalletsByAddr(addr, chainId) {
|
|
13564
|
-
const endpoint = chainId ? `user/addr/${addr}/wallets?chainId=${chainId}` : `user/addr/${addr}/wallets`;
|
|
13565
|
-
return (await sendGetRequest(API_URL, endpoint)).wallets;
|
|
13566
|
-
}
|
|
13567
|
-
async function getUserAuthIdByAddr(addr) {
|
|
13568
|
-
return (await sendGetRequest(API_URL, `user/addr/${addr}/authId`)).authId;
|
|
13569
|
-
}
|
|
13570
|
-
async function addUserToWallet(authId, chainId, walletAddr, userIds, walletUniqueId) {
|
|
13571
|
-
try {
|
|
13572
|
-
await sendPostRequest(
|
|
13573
|
-
API_URL,
|
|
13574
|
-
`user/auth/${authId}/chain/${chainId}/wallet`,
|
|
13575
|
-
{
|
|
13576
|
-
walletAddr,
|
|
13577
|
-
userIds,
|
|
13578
|
-
walletUniqueId
|
|
13579
|
-
}
|
|
13580
|
-
);
|
|
13581
|
-
} catch (err) {
|
|
13582
|
-
if (err instanceof InvalidParameterError6) {
|
|
13583
|
-
return;
|
|
13584
|
-
}
|
|
13585
|
-
}
|
|
13586
|
-
}
|
|
13587
|
-
async function getUserWalletIdentities(authId, chainId, walletAddr) {
|
|
13588
|
-
return (await sendGetRequest(
|
|
13589
|
-
API_URL,
|
|
13590
|
-
`user/auth/${authId}/chain/${chainId}/wallet/${walletAddr}/identities`
|
|
13591
|
-
)).ids ?? [];
|
|
13592
|
-
}
|
|
13593
13108
|
|
|
13594
13109
|
// src/utils/TypeUtils.ts
|
|
13595
13110
|
import { isHex } from "viem";
|
|
@@ -13602,12 +13117,12 @@ var isBytes32 = (input) => {
|
|
|
13602
13117
|
|
|
13603
13118
|
// src/viem/Converter.ts
|
|
13604
13119
|
import { createWalletClient, custom, toBytes as toBytes4 } from "viem";
|
|
13605
|
-
import { mainnet
|
|
13120
|
+
import { mainnet } from "viem/chains";
|
|
13606
13121
|
var convertProviderToClient = ({
|
|
13607
13122
|
provider,
|
|
13608
13123
|
viemChain
|
|
13609
13124
|
}) => {
|
|
13610
|
-
const chain = viemChain ? viemChain :
|
|
13125
|
+
const chain = viemChain ? viemChain : mainnet;
|
|
13611
13126
|
if (provider.request) {
|
|
13612
13127
|
return createWalletClient({
|
|
13613
13128
|
chain,
|
|
@@ -13629,7 +13144,7 @@ var convertSignerToClient = ({
|
|
|
13629
13144
|
signer,
|
|
13630
13145
|
viemChain
|
|
13631
13146
|
}) => {
|
|
13632
|
-
const chain = viemChain ? viemChain :
|
|
13147
|
+
const chain = viemChain ? viemChain : mainnet;
|
|
13633
13148
|
if (signer.type === "local") {
|
|
13634
13149
|
return createWalletClient({
|
|
13635
13150
|
chain,
|
|
@@ -13708,7 +13223,7 @@ var Auth = class {
|
|
|
13708
13223
|
} else if (!isHex2(authInput.privateKey) && authInput.privateKey.length === VALID_PRIVATE_KEY_LENGTH) {
|
|
13709
13224
|
privateKey = `0x${authInput.privateKey}`;
|
|
13710
13225
|
} else {
|
|
13711
|
-
throw new
|
|
13226
|
+
throw new InvalidParameterError6(
|
|
13712
13227
|
ErrorCode7.InvalidParameter,
|
|
13713
13228
|
"privateKey is not a valid one",
|
|
13714
13229
|
"privateKey is not a valid one",
|
|
@@ -13719,7 +13234,7 @@ var Auth = class {
|
|
|
13719
13234
|
}
|
|
13720
13235
|
this.signer = privateKeyToAccount(privateKey);
|
|
13721
13236
|
} else {
|
|
13722
|
-
throw new
|
|
13237
|
+
throw new InvalidParameterError6(
|
|
13723
13238
|
ErrorCode7.MissingParameter,
|
|
13724
13239
|
"valid authInput is required",
|
|
13725
13240
|
"valid authInput is required",
|
|
@@ -13842,7 +13357,7 @@ var Auth = class {
|
|
|
13842
13357
|
const { to, data } = txData;
|
|
13843
13358
|
const { value = 0n } = txData;
|
|
13844
13359
|
if (!chain || !chainId) {
|
|
13845
|
-
throw new
|
|
13360
|
+
throw new InvalidParameterError6(
|
|
13846
13361
|
ErrorCode7.MissingParameter,
|
|
13847
13362
|
"chain object is missing or incorrect",
|
|
13848
13363
|
"chain object is missing or incorrect",
|
|
@@ -13932,7 +13447,12 @@ var Auth = class {
|
|
|
13932
13447
|
*/
|
|
13933
13448
|
async getUserIds(wallet, chainId) {
|
|
13934
13449
|
await this.init();
|
|
13935
|
-
return await getUserWalletIdentities(
|
|
13450
|
+
return await getUserWalletIdentities({
|
|
13451
|
+
authId: this.authId,
|
|
13452
|
+
chainId,
|
|
13453
|
+
walletAddr: wallet,
|
|
13454
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
13455
|
+
});
|
|
13936
13456
|
}
|
|
13937
13457
|
/**
|
|
13938
13458
|
* Retrieves the wallets associated with the current auth object.
|
|
@@ -13942,9 +13462,13 @@ var Auth = class {
|
|
|
13942
13462
|
async getWallets(chainId) {
|
|
13943
13463
|
await this.init();
|
|
13944
13464
|
try {
|
|
13945
|
-
return await getUserWalletsByAddr(
|
|
13465
|
+
return await getUserWalletsByAddr({
|
|
13466
|
+
addr: await this.getAddress(),
|
|
13467
|
+
chainId,
|
|
13468
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
13469
|
+
});
|
|
13946
13470
|
} catch (err) {
|
|
13947
|
-
if (err instanceof
|
|
13471
|
+
if (err instanceof ResourceNotFoundError4) {
|
|
13948
13472
|
return [];
|
|
13949
13473
|
}
|
|
13950
13474
|
throw err;
|
|
@@ -14214,7 +13738,7 @@ var createTargetSelectorMerkleTree = (params) => {
|
|
|
14214
13738
|
};
|
|
14215
13739
|
var createSessionKeyTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
14216
13740
|
if (params.targetWhitelist.length === 0) {
|
|
14217
|
-
throw new
|
|
13741
|
+
throw new InvalidParameterError7(
|
|
14218
13742
|
ErrorCode8.MissingParameter,
|
|
14219
13743
|
"targetWhitelist is required",
|
|
14220
13744
|
"targetWhitelist is required",
|
|
@@ -14224,7 +13748,7 @@ var createSessionKeyTransactionParams = async (params, txOptions = globalThis.gl
|
|
|
14224
13748
|
);
|
|
14225
13749
|
}
|
|
14226
13750
|
if (params.userId === void 0) {
|
|
14227
|
-
throw new
|
|
13751
|
+
throw new InvalidParameterError7(
|
|
14228
13752
|
ErrorCode8.MissingParameter,
|
|
14229
13753
|
"userId is required",
|
|
14230
13754
|
"userId is required",
|
|
@@ -14361,7 +13885,7 @@ import { isAddress as isAddress4, parseEther as parseEther2 } from "viem";
|
|
|
14361
13885
|
import {
|
|
14362
13886
|
ErrorCode as ErrorCode9,
|
|
14363
13887
|
InternalFailureError as InternalFailureError4,
|
|
14364
|
-
InvalidParameterError as
|
|
13888
|
+
InvalidParameterError as InvalidParameterError8
|
|
14365
13889
|
} from "@funkit/utils";
|
|
14366
13890
|
var getWithdrawQueueInterface = () => {
|
|
14367
13891
|
return new ContractInterface(WITHDRAW_QUEUE_ABI);
|
|
@@ -14379,7 +13903,7 @@ var stakeTransactionParams = async (params, txOptions = globalThis.globalEnvOpti
|
|
|
14379
13903
|
};
|
|
14380
13904
|
var requestUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
14381
13905
|
if (!isAddress4(params.recipient ?? "")) {
|
|
14382
|
-
throw new
|
|
13906
|
+
throw new InvalidParameterError8(
|
|
14383
13907
|
ErrorCode9.InvalidParameter,
|
|
14384
13908
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14385
13909
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14393,7 +13917,7 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
|
|
|
14393
13917
|
const steth = getSteth(chainId);
|
|
14394
13918
|
const withdrawalQueue = getWithdrawalQueue(chainId);
|
|
14395
13919
|
if (!steth || !withdrawalQueue || steth.length === 0 || withdrawalQueue.length === 0) {
|
|
14396
|
-
throw new
|
|
13920
|
+
throw new InvalidParameterError8(
|
|
14397
13921
|
ErrorCode9.ChainNotSupported,
|
|
14398
13922
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14399
13923
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
@@ -14428,7 +13952,7 @@ var requestUnstakeTransactionParams = async (params, txOptions = globalThis.glob
|
|
|
14428
13952
|
};
|
|
14429
13953
|
var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
14430
13954
|
if (!isAddress4(params.recipient ?? "")) {
|
|
14431
|
-
throw new
|
|
13955
|
+
throw new InvalidParameterError8(
|
|
14432
13956
|
ErrorCode9.InvalidParameter,
|
|
14433
13957
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14434
13958
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14441,7 +13965,7 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
14441
13965
|
const withdrawQueueAddress = getWithdrawalQueue(await chain.getChainId());
|
|
14442
13966
|
const readyToWithdrawRequestIds = (await getReadyToWithdrawRequests(params, txOptions)).slice(0, 5);
|
|
14443
13967
|
if (readyToWithdrawRequestIds.length === 0) {
|
|
14444
|
-
throw new
|
|
13968
|
+
throw new InvalidParameterError8(
|
|
14445
13969
|
ErrorCode9.InvalidParameter,
|
|
14446
13970
|
"Not ready to withdraw requests",
|
|
14447
13971
|
"Not ready to withdraw requests",
|
|
@@ -14480,7 +14004,7 @@ var finishUnstakeTransactionParams = async (params, txOptions = globalThis.globa
|
|
|
14480
14004
|
};
|
|
14481
14005
|
var getReadyToWithdrawRequests = async (params, txOptions) => {
|
|
14482
14006
|
if (!isAddress4(params.recipient ?? "")) {
|
|
14483
|
-
throw new
|
|
14007
|
+
throw new InvalidParameterError8(
|
|
14484
14008
|
ErrorCode9.InvalidParameter,
|
|
14485
14009
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
14486
14010
|
"Recipient address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14525,7 +14049,7 @@ var getWithdrawalQueue = (chainId) => {
|
|
|
14525
14049
|
case 36865:
|
|
14526
14050
|
return "0x889edC2eDab5f40e902b864aD4d7AdE8E412F9B1";
|
|
14527
14051
|
default:
|
|
14528
|
-
throw new
|
|
14052
|
+
throw new InvalidParameterError8(
|
|
14529
14053
|
ErrorCode9.ChainNotSupported,
|
|
14530
14054
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14531
14055
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
@@ -14544,7 +14068,7 @@ var getSteth = (chainId) => {
|
|
|
14544
14068
|
case 36865:
|
|
14545
14069
|
return "0xae7ab96520DE3A18E5e111B5EaAb095312D7fE84";
|
|
14546
14070
|
default:
|
|
14547
|
-
throw new
|
|
14071
|
+
throw new InvalidParameterError8(
|
|
14548
14072
|
ErrorCode9.ChainNotSupported,
|
|
14549
14073
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
14550
14074
|
"Incorrect chainId, staking only available on Ethereum mainnet and Goerli",
|
|
@@ -14557,7 +14081,7 @@ var getSteth = (chainId) => {
|
|
|
14557
14081
|
|
|
14558
14082
|
// src/actions/Token.ts
|
|
14559
14083
|
import { isAddress as isAddress5, parseEther as parseEther3 } from "viem";
|
|
14560
|
-
import { ErrorCode as ErrorCode10, InvalidParameterError as
|
|
14084
|
+
import { ErrorCode as ErrorCode10, InvalidParameterError as InvalidParameterError9 } from "@funkit/utils";
|
|
14561
14085
|
var isERC721TransferParams = (obj) => {
|
|
14562
14086
|
return "tokenId" in obj;
|
|
14563
14087
|
};
|
|
@@ -14567,7 +14091,7 @@ var isTokenTransferParams = (obj) => {
|
|
|
14567
14091
|
var erc721TransferTransactionParams = async (params) => {
|
|
14568
14092
|
const { to, tokenId, collection, from } = params;
|
|
14569
14093
|
if (!isAddress5(to ?? "") || !isAddress5(from ?? "")) {
|
|
14570
|
-
throw new
|
|
14094
|
+
throw new InvalidParameterError9(
|
|
14571
14095
|
ErrorCode10.InvalidParameter,
|
|
14572
14096
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14573
14097
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14586,7 +14110,7 @@ var erc721TransferTransactionParams = async (params) => {
|
|
|
14586
14110
|
var tokenTransferTransactionParams = async (params, chain) => {
|
|
14587
14111
|
const { to, amount, token } = params;
|
|
14588
14112
|
if (!isAddress5(to)) {
|
|
14589
|
-
throw new
|
|
14113
|
+
throw new InvalidParameterError9(
|
|
14590
14114
|
ErrorCode10.InvalidParameter,
|
|
14591
14115
|
"To address is not a valid address, please make sure it is a valid checksum address.",
|
|
14592
14116
|
"To address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14605,7 +14129,7 @@ var tokenTransferTransactionParams = async (params, chain) => {
|
|
|
14605
14129
|
}
|
|
14606
14130
|
const tokenAddr = await tokenObj.getAddress();
|
|
14607
14131
|
if (!tokenAddr) {
|
|
14608
|
-
throw new
|
|
14132
|
+
throw new InvalidParameterError9(
|
|
14609
14133
|
ErrorCode10.TokenNotFound,
|
|
14610
14134
|
"Token address not found. Please check the token passed in.",
|
|
14611
14135
|
"Token address not found. Please check the token passed in.",
|
|
@@ -14624,7 +14148,7 @@ var tokenTransferTransactionParams = async (params, chain) => {
|
|
|
14624
14148
|
var tokenTransferFromTransactionParams = async (params, chain) => {
|
|
14625
14149
|
const { to, amount, token, from } = params;
|
|
14626
14150
|
if (!isAddress5(to ?? "") || !isAddress5(from ?? "")) {
|
|
14627
|
-
throw new
|
|
14151
|
+
throw new InvalidParameterError9(
|
|
14628
14152
|
ErrorCode10.InvalidParameter,
|
|
14629
14153
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
14630
14154
|
"To/from address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14643,7 +14167,7 @@ var tokenTransferFromTransactionParams = async (params, chain) => {
|
|
|
14643
14167
|
}
|
|
14644
14168
|
const tokenAddr = await tokenObj.getAddress();
|
|
14645
14169
|
if (!tokenAddr) {
|
|
14646
|
-
throw new
|
|
14170
|
+
throw new InvalidParameterError9(
|
|
14647
14171
|
ErrorCode10.TokenNotFound,
|
|
14648
14172
|
"Token address not found. Please check the token passed in.",
|
|
14649
14173
|
"Token address not found. Please check the token passed in.",
|
|
@@ -14668,7 +14192,7 @@ var isERC721ApproveParams = (obj) => {
|
|
|
14668
14192
|
var erc20ApproveTransactionParams = async (params) => {
|
|
14669
14193
|
const { spender, amount, token } = params;
|
|
14670
14194
|
if (!isAddress5(spender ?? "")) {
|
|
14671
|
-
throw new
|
|
14195
|
+
throw new InvalidParameterError9(
|
|
14672
14196
|
ErrorCode10.InvalidParameter,
|
|
14673
14197
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14674
14198
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14691,7 +14215,7 @@ var erc20ApproveTransactionParams = async (params) => {
|
|
|
14691
14215
|
var erc721ApproveTransactionParams = async (params) => {
|
|
14692
14216
|
const { spender, tokenId, collection } = params;
|
|
14693
14217
|
if (!isAddress5(spender ?? "")) {
|
|
14694
|
-
throw new
|
|
14218
|
+
throw new InvalidParameterError9(
|
|
14695
14219
|
ErrorCode10.InvalidParameter,
|
|
14696
14220
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
14697
14221
|
"Spender address is not a valid address, please make sure it is a valid checksum address.",
|
|
@@ -14724,7 +14248,7 @@ var SocketSort = /* @__PURE__ */ ((SocketSort2) => {
|
|
|
14724
14248
|
})(SocketSort || {});
|
|
14725
14249
|
|
|
14726
14250
|
// src/config/Config.ts
|
|
14727
|
-
import { ErrorCode as ErrorCode11, InvalidParameterError as
|
|
14251
|
+
import { ErrorCode as ErrorCode11, InvalidParameterError as InvalidParameterError10 } from "@funkit/utils";
|
|
14728
14252
|
function getEnvOptions() {
|
|
14729
14253
|
return globalThis.globalEnvOption;
|
|
14730
14254
|
}
|
|
@@ -14740,7 +14264,7 @@ async function configureEnvironment(option) {
|
|
|
14740
14264
|
const globalEnvOption = global.globalEnvOption;
|
|
14741
14265
|
globalEnvOption.apiKey = option.apiKey ? option.apiKey : globalEnvOption.apiKey;
|
|
14742
14266
|
if (!globalEnvOption.apiKey) {
|
|
14743
|
-
throw new
|
|
14267
|
+
throw new InvalidParameterError10(
|
|
14744
14268
|
ErrorCode11.MissingParameter,
|
|
14745
14269
|
"apiKey is required",
|
|
14746
14270
|
"apiKey is required",
|
|
@@ -14986,7 +14510,7 @@ var CheckoutSponsor = class extends Sponsor {
|
|
|
14986
14510
|
// src/sponsors/GaslessSponsor.ts
|
|
14987
14511
|
import { concat as concat3 } from "viem";
|
|
14988
14512
|
import { PaymasterType as PaymasterType3 } from "@funkit/api-base";
|
|
14989
|
-
import { ErrorCode as ErrorCode12, ResourceNotFoundError as
|
|
14513
|
+
import { ErrorCode as ErrorCode12, ResourceNotFoundError as ResourceNotFoundError5 } from "@funkit/utils";
|
|
14990
14514
|
var GaslessSponsor = class extends Sponsor {
|
|
14991
14515
|
constructor(options = globalThis.globalEnvOption) {
|
|
14992
14516
|
super(
|
|
@@ -15002,7 +14526,7 @@ var GaslessSponsor = class extends Sponsor {
|
|
|
15002
14526
|
if (GASLESS_SPONSOR_SUPPORT_CHAINS.includes(await chain.getChainId())) {
|
|
15003
14527
|
this.sponsorAddress = await chain.getAddress("funGaslessSponsorAddress");
|
|
15004
14528
|
} else {
|
|
15005
|
-
throw new
|
|
14529
|
+
throw new ResourceNotFoundError5(
|
|
15006
14530
|
ErrorCode12.MissingParameter,
|
|
15007
14531
|
"The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
|
|
15008
14532
|
"The network you are working with does not support gasless Fun Sponsor. You will need to run and manage your own gasless sponsor.",
|
|
@@ -15109,8 +14633,8 @@ import { concat as concat4, encodeAbiParameters as encodeAbiParameters4 } from "
|
|
|
15109
14633
|
import { PaymasterType as PaymasterType4, addTransaction } from "@funkit/api-base";
|
|
15110
14634
|
import {
|
|
15111
14635
|
ErrorCode as ErrorCode13,
|
|
15112
|
-
InvalidParameterError as
|
|
15113
|
-
ResourceNotFoundError as
|
|
14636
|
+
InvalidParameterError as InvalidParameterError11,
|
|
14637
|
+
ResourceNotFoundError as ResourceNotFoundError6
|
|
15114
14638
|
} from "@funkit/utils";
|
|
15115
14639
|
var TokenSponsor = class extends Sponsor {
|
|
15116
14640
|
constructor(options = globalThis.globalEnvOption) {
|
|
@@ -15121,7 +14645,7 @@ var TokenSponsor = class extends Sponsor {
|
|
|
15121
14645
|
PaymasterType4.TokenSponsor
|
|
15122
14646
|
);
|
|
15123
14647
|
if (!options.gasSponsor?.token) {
|
|
15124
|
-
throw new
|
|
14648
|
+
throw new InvalidParameterError11(
|
|
15125
14649
|
ErrorCode13.MissingParameter,
|
|
15126
14650
|
"token field is missing",
|
|
15127
14651
|
"token field is missing",
|
|
@@ -15138,7 +14662,7 @@ var TokenSponsor = class extends Sponsor {
|
|
|
15138
14662
|
if (TOKEN_SPONSOR_SUPPORT_CHAINS.includes(await chain.getChainId())) {
|
|
15139
14663
|
this.sponsorAddress = await chain.getAddress("funTokenSponsorAddress");
|
|
15140
14664
|
} else {
|
|
15141
|
-
throw new
|
|
14665
|
+
throw new ResourceNotFoundError6(
|
|
15142
14666
|
ErrorCode13.MissingParameter,
|
|
15143
14667
|
"The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
|
|
15144
14668
|
"The network you are working with does not support token Fun Sponsor. You will need to run and manage your own token sponsor.",
|
|
@@ -15489,15 +15013,27 @@ var TokenSponsor = class extends Sponsor {
|
|
|
15489
15013
|
|
|
15490
15014
|
// src/wallet/FunWallet.ts
|
|
15491
15015
|
import {
|
|
15016
|
+
AuthType as AuthType2,
|
|
15017
|
+
OperationStatus,
|
|
15018
|
+
OperationType,
|
|
15492
15019
|
addTransaction as addTransaction2,
|
|
15020
|
+
addUserToWallet,
|
|
15493
15021
|
checkWalletAccessInitialization,
|
|
15022
|
+
createOp,
|
|
15023
|
+
deleteOp,
|
|
15024
|
+
executeOp,
|
|
15494
15025
|
getAllWalletNFTs,
|
|
15495
15026
|
getAllWalletNFTsByChainId,
|
|
15496
15027
|
getAllWalletTokens,
|
|
15497
15028
|
getAllWalletTokensByChainId,
|
|
15029
|
+
getFullReceipt,
|
|
15498
15030
|
getGroups,
|
|
15031
|
+
getOps,
|
|
15032
|
+
getOpsOfWallet,
|
|
15499
15033
|
getWalletLidoWithdrawalsByChainId,
|
|
15500
|
-
initializeWalletAccess
|
|
15034
|
+
initializeWalletAccess,
|
|
15035
|
+
scheduleOp,
|
|
15036
|
+
signOp
|
|
15501
15037
|
} from "@funkit/api-base";
|
|
15502
15038
|
import {
|
|
15503
15039
|
http as http3,
|
|
@@ -15513,15 +15049,15 @@ import {
|
|
|
15513
15049
|
import {
|
|
15514
15050
|
ErrorCode as ErrorCode15,
|
|
15515
15051
|
InternalFailureError as InternalFailureError5,
|
|
15516
|
-
InvalidParameterError as
|
|
15052
|
+
InvalidParameterError as InvalidParameterError13
|
|
15517
15053
|
} from "@funkit/utils";
|
|
15518
15054
|
|
|
15519
15055
|
// src/actions/FirstClassActions.ts
|
|
15520
15056
|
import { pad as pad8 } from "viem";
|
|
15521
15057
|
import {
|
|
15522
15058
|
ErrorCode as ErrorCode14,
|
|
15523
|
-
InvalidParameterError as
|
|
15524
|
-
ResourceNotFoundError as
|
|
15059
|
+
InvalidParameterError as InvalidParameterError12,
|
|
15060
|
+
ResourceNotFoundError as ResourceNotFoundError7
|
|
15525
15061
|
} from "@funkit/utils";
|
|
15526
15062
|
|
|
15527
15063
|
// src/utils/GroupUtils.ts
|
|
@@ -15596,7 +15132,7 @@ var FirstClassActions = class {
|
|
|
15596
15132
|
);
|
|
15597
15133
|
}
|
|
15598
15134
|
} else {
|
|
15599
|
-
throw new
|
|
15135
|
+
throw new InvalidParameterError12(
|
|
15600
15136
|
ErrorCode14.InvalidParameter,
|
|
15601
15137
|
"Params were missing or incorrect",
|
|
15602
15138
|
"Params were missing or incorrect",
|
|
@@ -15628,7 +15164,7 @@ var FirstClassActions = class {
|
|
|
15628
15164
|
} else if (isERC721ApproveParams(params)) {
|
|
15629
15165
|
transactionParams = await erc721ApproveTransactionParams(params);
|
|
15630
15166
|
} else {
|
|
15631
|
-
throw new
|
|
15167
|
+
throw new InvalidParameterError12(
|
|
15632
15168
|
ErrorCode14.InvalidParameter,
|
|
15633
15169
|
"Params were missing or incorrect",
|
|
15634
15170
|
"Params were missing or incorrect",
|
|
@@ -15684,7 +15220,7 @@ var FirstClassActions = class {
|
|
|
15684
15220
|
txOptions
|
|
15685
15221
|
);
|
|
15686
15222
|
} else {
|
|
15687
|
-
throw new
|
|
15223
|
+
throw new InvalidParameterError12(
|
|
15688
15224
|
ErrorCode14.InvalidParameter,
|
|
15689
15225
|
"Params were missing or incorrect",
|
|
15690
15226
|
"Params were missing or incorrect",
|
|
@@ -15774,7 +15310,7 @@ var FirstClassActions = class {
|
|
|
15774
15310
|
await this.getAddress()
|
|
15775
15311
|
);
|
|
15776
15312
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15777
|
-
throw new
|
|
15313
|
+
throw new ResourceNotFoundError7(
|
|
15778
15314
|
ErrorCode14.GroupNotFound,
|
|
15779
15315
|
"group is not found",
|
|
15780
15316
|
"group is not found",
|
|
@@ -15787,7 +15323,7 @@ var FirstClassActions = class {
|
|
|
15787
15323
|
const members = new Set(onChainGroupData.memberIds);
|
|
15788
15324
|
members.add(params.userId);
|
|
15789
15325
|
if (members.size <= originalMembers.size) {
|
|
15790
|
-
throw new
|
|
15326
|
+
throw new InvalidParameterError12(
|
|
15791
15327
|
ErrorCode14.UserAlreadyExists,
|
|
15792
15328
|
"user already exists in group",
|
|
15793
15329
|
"user already exists in group",
|
|
@@ -15824,7 +15360,7 @@ var FirstClassActions = class {
|
|
|
15824
15360
|
await this.getAddress()
|
|
15825
15361
|
);
|
|
15826
15362
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15827
|
-
throw new
|
|
15363
|
+
throw new ResourceNotFoundError7(
|
|
15828
15364
|
ErrorCode14.GroupNotFound,
|
|
15829
15365
|
"group is not found",
|
|
15830
15366
|
"group is not found",
|
|
@@ -15837,7 +15373,7 @@ var FirstClassActions = class {
|
|
|
15837
15373
|
const members = new Set(onChainGroupData.memberIds);
|
|
15838
15374
|
members.delete(params.userId);
|
|
15839
15375
|
if (members.size >= originalMembers.size) {
|
|
15840
|
-
throw new
|
|
15376
|
+
throw new ResourceNotFoundError7(
|
|
15841
15377
|
ErrorCode14.UserNotFound,
|
|
15842
15378
|
"user does not exist in group",
|
|
15843
15379
|
"user does not exist in group",
|
|
@@ -15873,7 +15409,7 @@ var FirstClassActions = class {
|
|
|
15873
15409
|
await this.getAddress()
|
|
15874
15410
|
);
|
|
15875
15411
|
if (!onChainGroupData || onChainGroupData.memberIds.length === 0) {
|
|
15876
|
-
throw new
|
|
15412
|
+
throw new ResourceNotFoundError7(
|
|
15877
15413
|
ErrorCode14.GroupNotFound,
|
|
15878
15414
|
"group is not found",
|
|
15879
15415
|
"group is not found",
|
|
@@ -15883,7 +15419,7 @@ var FirstClassActions = class {
|
|
|
15883
15419
|
);
|
|
15884
15420
|
}
|
|
15885
15421
|
if (!Number.isInteger(params.threshold) || params.threshold < 1 || params.threshold > onChainGroupData.memberIds.length) {
|
|
15886
|
-
throw new
|
|
15422
|
+
throw new InvalidParameterError12(
|
|
15887
15423
|
ErrorCode14.InvalidThreshold,
|
|
15888
15424
|
"threshold can not be 0 or bigger than number of members in the group",
|
|
15889
15425
|
"threshold can not be 0 or bigger than number of members in the group",
|
|
@@ -15944,7 +15480,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15944
15480
|
if (isAddress6(params)) {
|
|
15945
15481
|
this.address = params;
|
|
15946
15482
|
} else {
|
|
15947
|
-
throw new
|
|
15483
|
+
throw new InvalidParameterError13(
|
|
15948
15484
|
ErrorCode15.InvalidParameter,
|
|
15949
15485
|
"string input must be an address type",
|
|
15950
15486
|
"string input must be an address type",
|
|
@@ -15956,7 +15492,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15956
15492
|
} else {
|
|
15957
15493
|
const { users, uniqueId } = params;
|
|
15958
15494
|
if (!uniqueId || !isBytes32(uniqueId) || !users || users.length <= 0) {
|
|
15959
|
-
throw new
|
|
15495
|
+
throw new InvalidParameterError13(
|
|
15960
15496
|
ErrorCode15.InvalidParameter,
|
|
15961
15497
|
"uniqueId must be bytes32 and users must be non-empty",
|
|
15962
15498
|
"uniqueId must be bytes32 and users must be non-empty",
|
|
@@ -15968,7 +15504,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15968
15504
|
this.userInfo = new Map(
|
|
15969
15505
|
users?.map((user) => {
|
|
15970
15506
|
if (!user.userId || !isHex3(user.userId)) {
|
|
15971
|
-
throw new
|
|
15507
|
+
throw new InvalidParameterError13(
|
|
15972
15508
|
ErrorCode15.InvalidParameter,
|
|
15973
15509
|
"userId is required and must be a hex string",
|
|
15974
15510
|
"userId is required and must be a hex string",
|
|
@@ -15978,7 +15514,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
15978
15514
|
);
|
|
15979
15515
|
}
|
|
15980
15516
|
if (user.groupInfo && (!Number.isInteger(user.groupInfo.threshold) || !Array.isArray(user.groupInfo.memberIds) || !user.groupInfo.memberIds.every((memberId) => isHex3(memberId)))) {
|
|
15981
|
-
throw new
|
|
15517
|
+
throw new InvalidParameterError13(
|
|
15982
15518
|
ErrorCode15.InvalidParameter,
|
|
15983
15519
|
"groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
|
|
15984
15520
|
"groupInfo must be an object with threshold as integer and memberIds as array of hex strings",
|
|
@@ -16153,25 +15689,30 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16153
15689
|
* Retrieves a list of operations associated with the wallet.
|
|
16154
15690
|
* @param {OperationStatus} status - The status of operations to retrieve (default: OperationStatus.ALL).
|
|
16155
15691
|
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
16156
|
-
* @returns {Promise<
|
|
15692
|
+
* @returns {Promise<OperationData[]>} A list of operations.
|
|
16157
15693
|
*/
|
|
16158
|
-
async getOperations(status =
|
|
15694
|
+
async getOperations(status = OperationStatus.ALL, txOptions = globalThis.globalEnvOption) {
|
|
16159
15695
|
const chain = await Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
16160
|
-
return await getOpsOfWallet(
|
|
16161
|
-
await this.getAddress(txOptions),
|
|
16162
|
-
await chain.getChainId(),
|
|
16163
|
-
status
|
|
16164
|
-
|
|
15696
|
+
return await getOpsOfWallet({
|
|
15697
|
+
walletAddr: await this.getAddress(txOptions),
|
|
15698
|
+
chainId: await chain.getChainId(),
|
|
15699
|
+
status,
|
|
15700
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
15701
|
+
});
|
|
16165
15702
|
}
|
|
16166
15703
|
/**
|
|
16167
15704
|
* Retrieves a specific operation by its ID.
|
|
16168
15705
|
* @param {Hex} opId - The ID of the operation to retrieve.
|
|
16169
15706
|
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
16170
|
-
* @returns {Promise<
|
|
15707
|
+
* @returns {Promise<OperationData>} The requested operation.
|
|
16171
15708
|
*/
|
|
16172
15709
|
async getOperation(opId, txOptions = globalThis.globalEnvOption) {
|
|
16173
15710
|
const chain = await Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
16174
|
-
return (await getOps(
|
|
15711
|
+
return (await getOps({
|
|
15712
|
+
opIds: [opId],
|
|
15713
|
+
chainId: await chain.getChainId(),
|
|
15714
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
15715
|
+
}))[0];
|
|
16175
15716
|
}
|
|
16176
15717
|
/**
|
|
16177
15718
|
* Retrieves a list of users associated with the wallet and their potential corresponding group information.
|
|
@@ -16269,13 +15810,14 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16269
15810
|
apiKey: globalThis.globalEnvOption.apiKey
|
|
16270
15811
|
});
|
|
16271
15812
|
}
|
|
16272
|
-
await addUserToWallet(
|
|
16273
|
-
await auth.getAddress(),
|
|
16274
|
-
await chain.getChainId(),
|
|
15813
|
+
await addUserToWallet({
|
|
15814
|
+
authId: await auth.getAddress(),
|
|
15815
|
+
chainId: await chain.getChainId(),
|
|
16275
15816
|
walletAddr,
|
|
16276
|
-
[userId],
|
|
16277
|
-
this.walletUniqueId
|
|
16278
|
-
|
|
15817
|
+
userIds: [userId],
|
|
15818
|
+
walletUniqueId: this.walletUniqueId,
|
|
15819
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
15820
|
+
});
|
|
16279
15821
|
}
|
|
16280
15822
|
}
|
|
16281
15823
|
/**
|
|
@@ -16288,7 +15830,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16288
15830
|
*/
|
|
16289
15831
|
async createOperation(auth, userId, transactionParams, txOptions = globalThis.globalEnvOption) {
|
|
16290
15832
|
if (!userId || userId === "") {
|
|
16291
|
-
throw new
|
|
15833
|
+
throw new InvalidParameterError13(
|
|
16292
15834
|
ErrorCode15.MissingParameter,
|
|
16293
15835
|
"userId is required",
|
|
16294
15836
|
"userId is required",
|
|
@@ -16340,8 +15882,8 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16340
15882
|
const isGroupOp = await auth.getUserId() !== normalizedUserId;
|
|
16341
15883
|
const operation = new Operation(partialOp, {
|
|
16342
15884
|
chainId: await chain.getChainId(),
|
|
16343
|
-
opType: isGroupOp ?
|
|
16344
|
-
authType: isGroupOp ?
|
|
15885
|
+
opType: isGroupOp ? OperationType.GROUP_OPERATION : OperationType.SINGLE_OPERATION,
|
|
15886
|
+
authType: isGroupOp ? AuthType2.MULTI_SIG : AuthType2.ECDSA,
|
|
16345
15887
|
walletAddr: await this.getAddress(txOptions),
|
|
16346
15888
|
proposer: await auth.getAddress()
|
|
16347
15889
|
});
|
|
@@ -16385,7 +15927,10 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16385
15927
|
isGroupOperation(operation)
|
|
16386
15928
|
);
|
|
16387
15929
|
if (txOptions.skipDBAction !== true) {
|
|
16388
|
-
const opId = await createOp(
|
|
15930
|
+
const opId = await createOp({
|
|
15931
|
+
op: estimatedOperation,
|
|
15932
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
15933
|
+
});
|
|
16389
15934
|
estimatedOperation.opId = opId;
|
|
16390
15935
|
if (!await checkWalletAccessInitialization({
|
|
16391
15936
|
walletAddr: sender,
|
|
@@ -16416,13 +15961,14 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16416
15961
|
isGroupOperation(finalOperation)
|
|
16417
15962
|
);
|
|
16418
15963
|
if (isGroupOperation(finalOperation) && txOptions.skipDBAction !== true) {
|
|
16419
|
-
await signOp(
|
|
16420
|
-
finalOperation.opId,
|
|
16421
|
-
await chain.getChainId(),
|
|
16422
|
-
finalOperation.userOp.signature,
|
|
16423
|
-
await auth.getAddress(),
|
|
16424
|
-
this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold
|
|
16425
|
-
|
|
15964
|
+
await signOp({
|
|
15965
|
+
opId: finalOperation.opId,
|
|
15966
|
+
chainId: await chain.getChainId(),
|
|
15967
|
+
signature: finalOperation.userOp.signature,
|
|
15968
|
+
signedBy: await auth.getAddress(),
|
|
15969
|
+
threshold: this.userInfo?.get(finalOperation.groupId)?.groupInfo?.threshold,
|
|
15970
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
15971
|
+
});
|
|
16426
15972
|
}
|
|
16427
15973
|
return finalOperation;
|
|
16428
15974
|
}
|
|
@@ -16470,7 +16016,11 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16470
16016
|
}
|
|
16471
16017
|
} else {
|
|
16472
16018
|
if (finalTxOptions.skipDBAction !== true) {
|
|
16473
|
-
const storedOps = await getOps(
|
|
16019
|
+
const storedOps = await getOps({
|
|
16020
|
+
opIds: [finalOperation.opId],
|
|
16021
|
+
chainId,
|
|
16022
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16023
|
+
});
|
|
16474
16024
|
let collectedSigCount;
|
|
16475
16025
|
if (isSignatureMissing(await auth.getUserId(), storedOps[0]?.signatures)) {
|
|
16476
16026
|
collectedSigCount = storedOps[0]?.signatures?.length ? storedOps[0]?.signatures?.length + 1 : 1;
|
|
@@ -16485,7 +16035,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16485
16035
|
collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
|
|
16486
16036
|
}
|
|
16487
16037
|
if (collectedSigCount < threshold) {
|
|
16488
|
-
throw new
|
|
16038
|
+
throw new InvalidParameterError13(
|
|
16489
16039
|
ErrorCode15.InsufficientSignatures,
|
|
16490
16040
|
"Signatures are not sufficient to execute the operation",
|
|
16491
16041
|
"Signatures are not sufficient to execute the operation",
|
|
@@ -16495,7 +16045,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16495
16045
|
);
|
|
16496
16046
|
}
|
|
16497
16047
|
} else {
|
|
16498
|
-
throw new
|
|
16048
|
+
throw new InvalidParameterError13(
|
|
16499
16049
|
ErrorCode15.InsufficientSignatures,
|
|
16500
16050
|
"Signatures are not sufficient to execute the operation",
|
|
16501
16051
|
"Signatures are not sufficient to execute the operation",
|
|
@@ -16508,36 +16058,44 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16508
16058
|
let receipt;
|
|
16509
16059
|
if (isGroupOperation(finalOperation)) {
|
|
16510
16060
|
receipt = await executeOp({
|
|
16511
|
-
|
|
16512
|
-
|
|
16513
|
-
|
|
16514
|
-
|
|
16515
|
-
|
|
16516
|
-
|
|
16061
|
+
input: {
|
|
16062
|
+
opId: finalOperation.opId,
|
|
16063
|
+
chainId,
|
|
16064
|
+
executedBy: await auth.getAddress(),
|
|
16065
|
+
entryPointAddress: await chain.getAddress("entryPointAddress"),
|
|
16066
|
+
signature: finalOperation.userOp.signature,
|
|
16067
|
+
groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
|
|
16068
|
+
},
|
|
16069
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16517
16070
|
});
|
|
16518
16071
|
} else {
|
|
16519
16072
|
receipt = await executeOp({
|
|
16520
|
-
|
|
16521
|
-
|
|
16522
|
-
|
|
16523
|
-
|
|
16524
|
-
|
|
16525
|
-
|
|
16073
|
+
input: {
|
|
16074
|
+
opId: finalOperation.opId,
|
|
16075
|
+
chainId,
|
|
16076
|
+
executedBy: await auth.getAddress(),
|
|
16077
|
+
entryPointAddress: await chain.getAddress("entryPointAddress"),
|
|
16078
|
+
signature: finalOperation.userOp.signature,
|
|
16079
|
+
userOp: finalOperation.userOp
|
|
16080
|
+
},
|
|
16081
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16526
16082
|
});
|
|
16527
16083
|
}
|
|
16528
|
-
receipt = await getFullReceipt(
|
|
16529
|
-
finalOperation.opId,
|
|
16084
|
+
receipt = await getFullReceipt({
|
|
16085
|
+
opId: finalOperation.opId,
|
|
16530
16086
|
chainId,
|
|
16531
|
-
receipt.userOpHash
|
|
16532
|
-
|
|
16087
|
+
userOpHash: receipt.userOpHash,
|
|
16088
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16089
|
+
});
|
|
16533
16090
|
if (isWalletInitOp(finalOperation.userOp) && finalTxOptions.skipDBAction !== true) {
|
|
16534
|
-
await addUserToWallet(
|
|
16535
|
-
await auth.getAddress(),
|
|
16091
|
+
await addUserToWallet({
|
|
16092
|
+
authId: await auth.getAddress(),
|
|
16536
16093
|
chainId,
|
|
16537
|
-
await this.getAddress(finalTxOptions),
|
|
16538
|
-
Array.from(this.userInfo.keys()),
|
|
16539
|
-
this.walletUniqueId
|
|
16540
|
-
|
|
16094
|
+
walletAddr: await this.getAddress(finalTxOptions),
|
|
16095
|
+
userIds: Array.from(this.userInfo.keys()),
|
|
16096
|
+
walletUniqueId: this.walletUniqueId,
|
|
16097
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16098
|
+
});
|
|
16541
16099
|
if (finalTxOptions?.gasSponsor?.sponsorAddress) {
|
|
16542
16100
|
const paymasterType = getPaymasterType(finalTxOptions);
|
|
16543
16101
|
addTransaction2({
|
|
@@ -16603,7 +16161,11 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16603
16161
|
}
|
|
16604
16162
|
} else {
|
|
16605
16163
|
if (finalTxOptions.skipDBAction !== true) {
|
|
16606
|
-
const storedOps = await getOps(
|
|
16164
|
+
const storedOps = await getOps({
|
|
16165
|
+
opIds: [finalOperation.opId],
|
|
16166
|
+
chainId,
|
|
16167
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16168
|
+
});
|
|
16607
16169
|
let collectedSigCount;
|
|
16608
16170
|
if (isSignatureMissing(await auth.getUserId(), storedOps[0]?.signatures)) {
|
|
16609
16171
|
collectedSigCount = storedOps[0]?.signatures?.length ? storedOps[0]?.signatures?.length + 1 : 1;
|
|
@@ -16618,7 +16180,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16618
16180
|
collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
|
|
16619
16181
|
}
|
|
16620
16182
|
if (collectedSigCount < threshold) {
|
|
16621
|
-
throw new
|
|
16183
|
+
throw new InvalidParameterError13(
|
|
16622
16184
|
ErrorCode15.InsufficientSignatures,
|
|
16623
16185
|
"Signatures are not sufficient to execute the operation",
|
|
16624
16186
|
"Signatures are not sufficient to execute the operation",
|
|
@@ -16628,7 +16190,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16628
16190
|
);
|
|
16629
16191
|
}
|
|
16630
16192
|
} else {
|
|
16631
|
-
throw new
|
|
16193
|
+
throw new InvalidParameterError13(
|
|
16632
16194
|
ErrorCode15.InsufficientSignatures,
|
|
16633
16195
|
"Signatures are not sufficient to execute the operation",
|
|
16634
16196
|
"Signatures are not sufficient to execute the operation",
|
|
@@ -16640,21 +16202,27 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16640
16202
|
}
|
|
16641
16203
|
if (isGroupOperation(finalOperation)) {
|
|
16642
16204
|
await scheduleOp({
|
|
16643
|
-
|
|
16644
|
-
|
|
16645
|
-
|
|
16646
|
-
|
|
16647
|
-
|
|
16648
|
-
|
|
16205
|
+
input: {
|
|
16206
|
+
opId: finalOperation.opId,
|
|
16207
|
+
chainId,
|
|
16208
|
+
scheduledBy: await auth.getAddress(),
|
|
16209
|
+
entryPointAddress: await chain.getAddress("entryPointAddress"),
|
|
16210
|
+
signature: finalOperation.userOp.signature,
|
|
16211
|
+
groupInfo: this.userInfo?.get(finalOperation.groupId)?.groupInfo
|
|
16212
|
+
},
|
|
16213
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16649
16214
|
});
|
|
16650
16215
|
} else {
|
|
16651
16216
|
await scheduleOp({
|
|
16652
|
-
|
|
16653
|
-
|
|
16654
|
-
|
|
16655
|
-
|
|
16656
|
-
|
|
16657
|
-
|
|
16217
|
+
input: {
|
|
16218
|
+
opId: finalOperation.opId,
|
|
16219
|
+
chainId,
|
|
16220
|
+
scheduledBy: await auth.getAddress(),
|
|
16221
|
+
entryPointAddress: await chain.getAddress("entryPointAddress"),
|
|
16222
|
+
signature: finalOperation.userOp.signature,
|
|
16223
|
+
userOp: finalOperation.userOp
|
|
16224
|
+
},
|
|
16225
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16658
16226
|
});
|
|
16659
16227
|
}
|
|
16660
16228
|
if (!finalOperation.opId) {
|
|
@@ -16678,7 +16246,11 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16678
16246
|
*/
|
|
16679
16247
|
async removeOperation(_, operationId, txOptions = globalThis.globalEnvOption) {
|
|
16680
16248
|
const chain = await Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
16681
|
-
await deleteOp(
|
|
16249
|
+
await deleteOp({
|
|
16250
|
+
opId: operationId,
|
|
16251
|
+
chainId: await chain.getChainId(),
|
|
16252
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16253
|
+
});
|
|
16682
16254
|
}
|
|
16683
16255
|
/**
|
|
16684
16256
|
* Creates and prepares a rejection operation for an existing operation.
|
|
@@ -16702,8 +16274,11 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16702
16274
|
);
|
|
16703
16275
|
if (rejectionMessage) rejectOperation.message = rejectionMessage;
|
|
16704
16276
|
rejectOperation.relatedOpIds = [operation.opId];
|
|
16705
|
-
rejectOperation.opType =
|
|
16706
|
-
rejectOperation.opId = await createOp(
|
|
16277
|
+
rejectOperation.opType = OperationType.REJECTION;
|
|
16278
|
+
rejectOperation.opId = await createOp({
|
|
16279
|
+
op: rejectOperation,
|
|
16280
|
+
apiKey: globalThis.globalEnvOption.apiKey
|
|
16281
|
+
});
|
|
16707
16282
|
return rejectOperation;
|
|
16708
16283
|
}
|
|
16709
16284
|
/**
|
|
@@ -16798,7 +16373,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16798
16373
|
options.fee.token = options.gasSponsor.token;
|
|
16799
16374
|
}
|
|
16800
16375
|
if (!options.fee.token) {
|
|
16801
|
-
throw new
|
|
16376
|
+
throw new InvalidParameterError13(
|
|
16802
16377
|
ErrorCode15.MissingParameter,
|
|
16803
16378
|
"EnvOption.fee.token or EnvOption.gasSponsor.token is required",
|
|
16804
16379
|
"EnvOption.fee.token or EnvOption.gasSponsor.token is required",
|
|
@@ -16808,7 +16383,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16808
16383
|
);
|
|
16809
16384
|
}
|
|
16810
16385
|
if (!options.fee.recipient) {
|
|
16811
|
-
throw new
|
|
16386
|
+
throw new InvalidParameterError13(
|
|
16812
16387
|
ErrorCode15.MissingParameter,
|
|
16813
16388
|
"EnvOption.fee.recipient is required",
|
|
16814
16389
|
"EnvOption.fee.recipient is required",
|
|
@@ -16820,7 +16395,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16820
16395
|
const chain = await Chain.getChain({ chainIdentifier: options.chain });
|
|
16821
16396
|
const token = new Token(options.fee.token, chain);
|
|
16822
16397
|
if (options.fee.gasPercent && !token.isNative) {
|
|
16823
|
-
throw new
|
|
16398
|
+
throw new InvalidParameterError13(
|
|
16824
16399
|
ErrorCode15.InvalidParameterCombination,
|
|
16825
16400
|
"GasPercent is only valid for native tokens",
|
|
16826
16401
|
"GasPercent is only valid for native tokens",
|
|
@@ -16855,7 +16430,7 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16855
16430
|
Number(gasUsed) * options.fee.gasPercent / 100
|
|
16856
16431
|
);
|
|
16857
16432
|
} else {
|
|
16858
|
-
throw new
|
|
16433
|
+
throw new InvalidParameterError13(
|
|
16859
16434
|
ErrorCode15.MissingParameter,
|
|
16860
16435
|
"EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
|
|
16861
16436
|
"EnvOption.fee.amount or EnvOption.fee.gasPercent is required",
|
|
@@ -16885,13 +16460,11 @@ var FunWallet = class extends FirstClassActions {
|
|
|
16885
16460
|
}
|
|
16886
16461
|
};
|
|
16887
16462
|
export {
|
|
16888
|
-
API_URL,
|
|
16889
16463
|
APPROVE_AND_EXEC_ABI,
|
|
16890
16464
|
APPROVE_AND_EXEC_CONTRACT_INTERFACE,
|
|
16891
16465
|
APPROVE_AND_SWAP_ABI,
|
|
16892
16466
|
AddressZero,
|
|
16893
16467
|
Auth,
|
|
16894
|
-
AuthType,
|
|
16895
16468
|
BASE_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
|
|
16896
16469
|
BASE_WRAP_TOKEN_ADDR,
|
|
16897
16470
|
BYTES32_LENGTH,
|
|
@@ -16903,7 +16476,6 @@ export {
|
|
|
16903
16476
|
CheckoutSponsor,
|
|
16904
16477
|
ContractInterface,
|
|
16905
16478
|
DEFAULT_RETRY_OPTIONS,
|
|
16906
|
-
DYDX_MAINNET_CHAIN_ID,
|
|
16907
16479
|
ENTRYPOINT_ABI,
|
|
16908
16480
|
ENTRYPOINT_CONTRACT_INTERFACE,
|
|
16909
16481
|
ERC20_ABI,
|
|
@@ -16915,11 +16487,6 @@ export {
|
|
|
16915
16487
|
ETH_TRANSFER_SELECTOR,
|
|
16916
16488
|
FACTORY_ABI,
|
|
16917
16489
|
FACTORY_CONTRACT_INTERFACE,
|
|
16918
|
-
FUNKIT_CONNECT_CHECKOUT_NATIVE_CURRENCY_ADDRESS,
|
|
16919
|
-
FUNKIT_CONNECT_SUPPORTED_CHAINS_ID_LIST,
|
|
16920
|
-
FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO,
|
|
16921
|
-
FUNKIT_CONNECT_SUPPORTED_CHAINS_INFO_LIST,
|
|
16922
|
-
FUNKIT_CONNECT_SUPPORTED_CHECKOUT_CHAINS_INFO_LIST,
|
|
16923
16490
|
FUN_FAUCET_URL,
|
|
16924
16491
|
FUN_GASLESS_SPONSOR_ADDRESS,
|
|
16925
16492
|
FUN_TOKEN_SPONSOR_ADDRESS,
|
|
@@ -16930,12 +16497,9 @@ export {
|
|
|
16930
16497
|
GaslessSponsor,
|
|
16931
16498
|
HashZero,
|
|
16932
16499
|
InvalidActionError,
|
|
16933
|
-
LOCAL_API_URL,
|
|
16934
16500
|
NFT,
|
|
16935
16501
|
OPTIMISM_PIMLICO_PAYMASTER_AND_DATA_ESTIMATION,
|
|
16936
16502
|
Operation,
|
|
16937
|
-
OperationStatus,
|
|
16938
|
-
OperationType,
|
|
16939
16503
|
RBAC_CONTRACT_INTERFACE,
|
|
16940
16504
|
ROLE_BASED_ACCESS_CONTROL_ABI,
|
|
16941
16505
|
STABLECOIN_SYMBOLS,
|
|
@@ -16957,7 +16521,6 @@ export {
|
|
|
16957
16521
|
WALLET_CONTRACT_INTERFACE,
|
|
16958
16522
|
WITHDRAW_QUEUE_ABI,
|
|
16959
16523
|
addOwnerTxParams,
|
|
16960
|
-
addUserToWallet,
|
|
16961
16524
|
addresstoBytes32,
|
|
16962
16525
|
calcPreVerificationGas,
|
|
16963
16526
|
configureEnvironment,
|
|
@@ -16966,22 +16529,16 @@ export {
|
|
|
16966
16529
|
createExecuteBatchTxParams,
|
|
16967
16530
|
createFeeRecipientAndTokenMerkleTree,
|
|
16968
16531
|
createGroupTxParams,
|
|
16969
|
-
createOp,
|
|
16970
16532
|
createSessionKeyTransactionParams,
|
|
16971
16533
|
createSessionUser,
|
|
16972
16534
|
createTargetSelectorMerkleTree,
|
|
16973
|
-
createUser,
|
|
16974
16535
|
decodeCalldata,
|
|
16975
|
-
deleteOp,
|
|
16976
|
-
dydxChain,
|
|
16977
16536
|
encodeLoginData,
|
|
16978
16537
|
encodeUserAuthInitData,
|
|
16979
16538
|
encodeWalletSignature,
|
|
16980
16539
|
erc20ApproveTransactionParams,
|
|
16981
16540
|
erc721ApproveTransactionParams,
|
|
16982
16541
|
erc721TransferTransactionParams,
|
|
16983
|
-
estimateOp,
|
|
16984
|
-
executeOp,
|
|
16985
16542
|
finishUnstakeTransactionParams,
|
|
16986
16543
|
fundWallet,
|
|
16987
16544
|
gasCalculation,
|
|
@@ -16996,29 +16553,15 @@ export {
|
|
|
16996
16553
|
generateRoleId,
|
|
16997
16554
|
generateRuleId,
|
|
16998
16555
|
getAuthUniqueId,
|
|
16999
|
-
getChainFromId,
|
|
17000
|
-
getChainFromName,
|
|
17001
16556
|
getEnvOptions,
|
|
17002
|
-
getFullReceipt,
|
|
17003
|
-
getGasPrice,
|
|
17004
16557
|
getGasStation,
|
|
17005
|
-
getModuleInfo,
|
|
17006
16558
|
getOpHash,
|
|
17007
|
-
getOps,
|
|
17008
|
-
getOpsOfGroup,
|
|
17009
|
-
getOpsOfWallet,
|
|
17010
|
-
getPaymasterAddress,
|
|
17011
16559
|
getPaymasterType,
|
|
17012
16560
|
getPermitHash,
|
|
17013
16561
|
getPromiseFromOp,
|
|
17014
16562
|
getSelectorFromCall,
|
|
17015
16563
|
getTargetFromCall,
|
|
17016
|
-
|
|
17017
|
-
getUserAddr,
|
|
17018
|
-
getUserAuthIdByAddr,
|
|
17019
|
-
getUserUniqueId,
|
|
17020
|
-
getUserWalletIdentities,
|
|
17021
|
-
getUserWalletsByAddr,
|
|
16564
|
+
getTokenAddressBySymbolAndChainId,
|
|
17022
16565
|
getWalletAddress,
|
|
17023
16566
|
getWalletPermitNonce,
|
|
17024
16567
|
isAddress,
|
|
@@ -17040,13 +16583,11 @@ export {
|
|
|
17040
16583
|
removeOwnerTxParams,
|
|
17041
16584
|
requestUnstakeTransactionParams,
|
|
17042
16585
|
roundToNearestBottomTenth,
|
|
17043
|
-
scheduleOp,
|
|
17044
16586
|
sendDeleteRequest,
|
|
17045
16587
|
sendGetRequest,
|
|
17046
16588
|
sendPostRequest,
|
|
17047
16589
|
sendPutRequest,
|
|
17048
16590
|
sendRequest,
|
|
17049
|
-
signOp,
|
|
17050
16591
|
stakeTransactionParams,
|
|
17051
16592
|
stringify,
|
|
17052
16593
|
toBytes32Arr,
|