@funkit/core 0.8.0
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/README.md +110 -0
- package/dist/fetch-polyfill.d.ts +1 -0
- package/dist/fetch-polyfill.js +35 -0
- package/dist/fetch-polyfill.js.map +1 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/src/abis/ApproveAndExec.json +1 -0
- package/dist/src/abis/ApproveAndSwap.json +1 -0
- package/dist/src/abis/ERC20.json +1 -0
- package/dist/src/abis/ERC721.json +1 -0
- package/dist/src/abis/EntryPoint.json +1 -0
- package/dist/src/abis/EstimationPaymaster.json +1 -0
- package/dist/src/abis/FeePercentOracle.json +1 -0
- package/dist/src/abis/FunWallet.json +1 -0
- package/dist/src/abis/FunWalletFactory.json +1 -0
- package/dist/src/abis/GaslessPaymaster.json +1 -0
- package/dist/src/abis/LidoWithdrawQueue.json +1 -0
- package/dist/src/abis/RoleBasedAccessControl.json +1 -0
- package/dist/src/abis/TestNFT.json +1 -0
- package/dist/src/abis/TokenPaymaster.json +1 -0
- package/dist/src/abis/TokenPriceOracle.json +1 -0
- package/dist/src/abis/UniswapV2Factory.json +1 -0
- package/dist/src/abis/UniswapV2Router02.json +1 -0
- package/dist/src/abis/UniswapV3LimitOrder.json +1 -0
- package/dist/src/abis/UserAuthentication.json +1 -0
- package/dist/src/abis/univ3factory.json +1 -0
- package/dist/src/abis/univ3quoter.json +1 -0
- package/dist/src/abis/univ3router.json +1 -0
- package/dist/src/actions/AccessControl.d.ts +9 -0
- package/dist/src/actions/AccessControl.js +88 -0
- package/dist/src/actions/AccessControl.js.map +1 -0
- package/dist/src/actions/BatchActions.d.ts +3 -0
- package/dist/src/actions/BatchActions.js +12 -0
- package/dist/src/actions/BatchActions.js.map +1 -0
- package/dist/src/actions/FirstClassActions.d.ts +161 -0
- package/dist/src/actions/FirstClassActions.js +347 -0
- package/dist/src/actions/FirstClassActions.js.map +1 -0
- package/dist/src/actions/Group.d.ts +6 -0
- package/dist/src/actions/Group.js +44 -0
- package/dist/src/actions/Group.js.map +1 -0
- package/dist/src/actions/LimitOrder.d.ts +4 -0
- package/dist/src/actions/LimitOrder.js +45 -0
- package/dist/src/actions/LimitOrder.js.map +1 -0
- package/dist/src/actions/Stake.d.ts +8 -0
- package/dist/src/actions/Stake.js +124 -0
- package/dist/src/actions/Stake.js.map +1 -0
- package/dist/src/actions/Swap.d.ts +9 -0
- package/dist/src/actions/Swap.js +169 -0
- package/dist/src/actions/Swap.js.map +1 -0
- package/dist/src/actions/Token.d.ts +12 -0
- package/dist/src/actions/Token.js +102 -0
- package/dist/src/actions/Token.js.map +1 -0
- package/dist/src/actions/index.d.ts +7 -0
- package/dist/src/actions/index.js +24 -0
- package/dist/src/actions/index.js.map +1 -0
- package/dist/src/actions/types.d.ts +117 -0
- package/dist/src/actions/types.js +11 -0
- package/dist/src/actions/types.js.map +1 -0
- package/dist/src/apis/AccessControlApis.d.ts +5 -0
- package/dist/src/apis/AccessControlApis.js +22 -0
- package/dist/src/apis/AccessControlApis.js.map +1 -0
- package/dist/src/apis/AssetApis.d.ts +79 -0
- package/dist/src/apis/AssetApis.js +100 -0
- package/dist/src/apis/AssetApis.js.map +1 -0
- package/dist/src/apis/ContractApis.d.ts +1 -0
- package/dist/src/apis/ContractApis.js +11 -0
- package/dist/src/apis/ContractApis.js.map +1 -0
- package/dist/src/apis/GroupApis.d.ts +8 -0
- package/dist/src/apis/GroupApis.js +45 -0
- package/dist/src/apis/GroupApis.js.map +1 -0
- package/dist/src/apis/InfoApis.d.ts +6 -0
- package/dist/src/apis/InfoApis.js +59 -0
- package/dist/src/apis/InfoApis.js.map +1 -0
- package/dist/src/apis/ListenerApis.d.ts +3 -0
- package/dist/src/apis/ListenerApis.js +36 -0
- package/dist/src/apis/ListenerApis.js.map +1 -0
- package/dist/src/apis/NFTApis.d.ts +22 -0
- package/dist/src/apis/NFTApis.js +34 -0
- package/dist/src/apis/NFTApis.js.map +1 -0
- package/dist/src/apis/OnOffRampApis.d.ts +2 -0
- package/dist/src/apis/OnOffRampApis.js +23 -0
- package/dist/src/apis/OnOffRampApis.js.map +1 -0
- package/dist/src/apis/OnOffRampUtils.d.ts +2 -0
- package/dist/src/apis/OnOffRampUtils.js +23 -0
- package/dist/src/apis/OnOffRampUtils.js.map +1 -0
- package/dist/src/apis/OperationApis.d.ts +14 -0
- package/dist/src/apis/OperationApis.js +77 -0
- package/dist/src/apis/OperationApis.js.map +1 -0
- package/dist/src/apis/PaymasterApis.d.ts +15 -0
- package/dist/src/apis/PaymasterApis.js +89 -0
- package/dist/src/apis/PaymasterApis.js.map +1 -0
- package/dist/src/apis/UserApis.d.ts +12 -0
- package/dist/src/apis/UserApis.js +77 -0
- package/dist/src/apis/UserApis.js.map +1 -0
- package/dist/src/apis/index.d.ts +10 -0
- package/dist/src/apis/index.js +27 -0
- package/dist/src/apis/index.js.map +1 -0
- package/dist/src/apis/types.d.ts +49 -0
- package/dist/src/apis/types.js +3 -0
- package/dist/src/apis/types.js.map +1 -0
- package/dist/src/auth/Auth.d.ts +81 -0
- package/dist/src/auth/Auth.js +317 -0
- package/dist/src/auth/Auth.js.map +1 -0
- package/dist/src/auth/SessionKeyAuth.d.ts +19 -0
- package/dist/src/auth/SessionKeyAuth.js +118 -0
- package/dist/src/auth/SessionKeyAuth.js.map +1 -0
- package/dist/src/auth/index.d.ts +2 -0
- package/dist/src/auth/index.js +19 -0
- package/dist/src/auth/index.js.map +1 -0
- package/dist/src/auth/types.d.ts +20 -0
- package/dist/src/auth/types.js +3 -0
- package/dist/src/auth/types.js.map +1 -0
- package/dist/src/common/constants.d.ts +1072 -0
- package/dist/src/common/constants.js +153 -0
- package/dist/src/common/constants.js.map +1 -0
- package/dist/src/common/index.d.ts +2 -0
- package/dist/src/common/index.js +19 -0
- package/dist/src/common/index.js.map +1 -0
- package/dist/src/common/types.d.ts +32 -0
- package/dist/src/common/types.js +3 -0
- package/dist/src/common/types.js.map +1 -0
- package/dist/src/config/Config.d.ts +3 -0
- package/dist/src/config/Config.js +46 -0
- package/dist/src/config/Config.js.map +1 -0
- package/dist/src/config/index.d.ts +2 -0
- package/dist/src/config/index.js +19 -0
- package/dist/src/config/index.js.map +1 -0
- package/dist/src/config/types.d.ts +21 -0
- package/dist/src/config/types.js +3 -0
- package/dist/src/config/types.js.map +1 -0
- package/dist/src/data/Chain.d.ts +29 -0
- package/dist/src/data/Chain.js +174 -0
- package/dist/src/data/Chain.js.map +1 -0
- package/dist/src/data/NFT.d.ts +24 -0
- package/dist/src/data/NFT.js +104 -0
- package/dist/src/data/NFT.js.map +1 -0
- package/dist/src/data/Operation.d.ts +33 -0
- package/dist/src/data/Operation.js +68 -0
- package/dist/src/data/Operation.js.map +1 -0
- package/dist/src/data/SolidityData.d.ts +8 -0
- package/dist/src/data/SolidityData.js +72 -0
- package/dist/src/data/SolidityData.js.map +1 -0
- package/dist/src/data/Token.d.ts +26 -0
- package/dist/src/data/Token.js +122 -0
- package/dist/src/data/Token.js.map +1 -0
- package/dist/src/data/index.d.ts +6 -0
- package/dist/src/data/index.js +23 -0
- package/dist/src/data/index.js.map +1 -0
- package/dist/src/data/types.d.ts +112 -0
- package/dist/src/data/types.js +25 -0
- package/dist/src/data/types.js.map +1 -0
- package/dist/src/errors/BaseError.d.ts +9 -0
- package/dist/src/errors/BaseError.js +23 -0
- package/dist/src/errors/BaseError.js.map +1 -0
- package/dist/src/errors/ClientError.d.ts +22 -0
- package/dist/src/errors/ClientError.js +75 -0
- package/dist/src/errors/ClientError.js.map +1 -0
- package/dist/src/errors/ServerError.d.ts +7 -0
- package/dist/src/errors/ServerError.js +18 -0
- package/dist/src/errors/ServerError.js.map +1 -0
- package/dist/src/errors/index.d.ts +4 -0
- package/dist/src/errors/index.js +21 -0
- package/dist/src/errors/index.js.map +1 -0
- package/dist/src/errors/types.d.ts +54 -0
- package/dist/src/errors/types.js +45 -0
- package/dist/src/errors/types.js.map +1 -0
- package/dist/src/sponsors/GaslessSponsor.d.ts +19 -0
- package/dist/src/sponsors/GaslessSponsor.js +91 -0
- package/dist/src/sponsors/GaslessSponsor.js.map +1 -0
- package/dist/src/sponsors/Sponsor.d.ts +31 -0
- package/dist/src/sponsors/Sponsor.js +94 -0
- package/dist/src/sponsors/Sponsor.js.map +1 -0
- package/dist/src/sponsors/TokenSponsor.d.ts +40 -0
- package/dist/src/sponsors/TokenSponsor.js +271 -0
- package/dist/src/sponsors/TokenSponsor.js.map +1 -0
- package/dist/src/sponsors/index.d.ts +3 -0
- package/dist/src/sponsors/index.js +20 -0
- package/dist/src/sponsors/index.js.map +1 -0
- package/dist/src/sponsors/types.d.ts +9 -0
- package/dist/src/sponsors/types.js +10 -0
- package/dist/src/sponsors/types.js.map +1 -0
- package/dist/src/utils/ApiUtils.d.ts +19 -0
- package/dist/src/utils/ApiUtils.js +97 -0
- package/dist/src/utils/ApiUtils.js.map +1 -0
- package/dist/src/utils/AuthUtils.d.ts +4 -0
- package/dist/src/utils/AuthUtils.js +54 -0
- package/dist/src/utils/AuthUtils.js.map +1 -0
- package/dist/src/utils/ChainUtils.d.ts +12 -0
- package/dist/src/utils/ChainUtils.js +89 -0
- package/dist/src/utils/ChainUtils.js.map +1 -0
- package/dist/src/utils/MerkleUtils.d.ts +18 -0
- package/dist/src/utils/MerkleUtils.js +96 -0
- package/dist/src/utils/MerkleUtils.js.map +1 -0
- package/dist/src/utils/PaymasterUtils.d.ts +3 -0
- package/dist/src/utils/PaymasterUtils.js +17 -0
- package/dist/src/utils/PaymasterUtils.js.map +1 -0
- package/dist/src/utils/SwapUtils.d.ts +35 -0
- package/dist/src/utils/SwapUtils.js +193 -0
- package/dist/src/utils/SwapUtils.js.map +1 -0
- package/dist/src/utils/TypeUtils.d.ts +1 -0
- package/dist/src/utils/TypeUtils.js +13 -0
- package/dist/src/utils/TypeUtils.js.map +1 -0
- package/dist/src/utils/UserOpUtils.d.ts +12 -0
- package/dist/src/utils/UserOpUtils.js +166 -0
- package/dist/src/utils/UserOpUtils.js.map +1 -0
- package/dist/src/utils/ViemUtils.d.ts +9 -0
- package/dist/src/utils/ViemUtils.js +30 -0
- package/dist/src/utils/ViemUtils.js.map +1 -0
- package/dist/src/utils/WalletUtils.d.ts +11 -0
- package/dist/src/utils/WalletUtils.js +61 -0
- package/dist/src/utils/WalletUtils.js.map +1 -0
- package/dist/src/utils/index.d.ts +7 -0
- package/dist/src/utils/index.js +24 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/src/viem/ContractInterface.d.ts +19 -0
- package/dist/src/viem/ContractInterface.js +88 -0
- package/dist/src/viem/ContractInterface.js.map +1 -0
- package/dist/src/viem/Converter.d.ts +1770 -0
- package/dist/src/viem/Converter.js +50 -0
- package/dist/src/viem/Converter.js.map +1 -0
- package/dist/src/viem/index.d.ts +2 -0
- package/dist/src/viem/index.js +19 -0
- package/dist/src/viem/index.js.map +1 -0
- package/dist/src/wallet/FunWallet.d.ts +185 -0
- package/dist/src/wallet/FunWallet.js +720 -0
- package/dist/src/wallet/FunWallet.js.map +1 -0
- package/dist/src/wallet/index.d.ts +2 -0
- package/dist/src/wallet/index.js +19 -0
- package/dist/src/wallet/index.js.map +1 -0
- package/dist/src/wallet/types.d.ts +13 -0
- package/dist/src/wallet/types.js +3 -0
- package/dist/src/wallet/types.js.map +1 -0
- package/package.json +89 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.NFT = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const Chain_1 = require("./Chain");
|
|
6
|
+
const NFTApis_1 = require("../apis/NFTApis");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
class NFT {
|
|
10
|
+
constructor(input) {
|
|
11
|
+
this.name = "";
|
|
12
|
+
if (!input) {
|
|
13
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidNFTIdentifier, "valid NFT identifier is required, could be address or name", { input }, "Please provide valid NFT identifier", "https://docs.fun.xyz");
|
|
14
|
+
}
|
|
15
|
+
if ((0, viem_1.isAddress)(input)) {
|
|
16
|
+
this.address = input;
|
|
17
|
+
}
|
|
18
|
+
else {
|
|
19
|
+
this.name = input;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
async approve(spender, tokenId, options = globalThis.globalEnvOption) {
|
|
23
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
24
|
+
const data = common_1.ERC721_CONTRACT_INTERFACE.encodeTransactionParams(await this.getAddress(), "approve", [spender, tokenId]);
|
|
25
|
+
return { ...data, chain };
|
|
26
|
+
}
|
|
27
|
+
async ownerOf(tokenId, options = globalThis.globalEnvOption) {
|
|
28
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
29
|
+
return await common_1.ERC721_CONTRACT_INTERFACE.readFromChain(await this.getAddress(), "ownerOf", [tokenId], chain);
|
|
30
|
+
}
|
|
31
|
+
async approveForAll(spender, options = globalThis.globalEnvOption) {
|
|
32
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
33
|
+
const data = common_1.ERC721_CONTRACT_INTERFACE.encodeTransactionParams(await this.getAddress(), "setApprovalForAll", [spender, true]);
|
|
34
|
+
return { ...data, chain };
|
|
35
|
+
}
|
|
36
|
+
async getAddress() {
|
|
37
|
+
if (!this.address) {
|
|
38
|
+
if (!this.name) {
|
|
39
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidNFTIdentifier, "valid NFT identifier is required, could be address or name", {}, "Please provide valid NFT identifier", "https://docs.fun.xyz");
|
|
40
|
+
}
|
|
41
|
+
const nft = await (0, NFTApis_1.getNftAddress)(this.name);
|
|
42
|
+
return nft.address;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
return this.address;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async getName(options = globalThis.globalEnvOption) {
|
|
49
|
+
if (!this.name && this.address) {
|
|
50
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
51
|
+
const nft = await (0, NFTApis_1.getNftName)(await chain.getChainId(), this.address);
|
|
52
|
+
return nft.name;
|
|
53
|
+
}
|
|
54
|
+
return this.name;
|
|
55
|
+
}
|
|
56
|
+
async getBalance(address, options = globalThis.globalEnvOption) {
|
|
57
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
58
|
+
return await common_1.ERC721_CONTRACT_INTERFACE.readFromChain(await this.getAddress(), "balanceOf", [address], chain);
|
|
59
|
+
}
|
|
60
|
+
async getApproved(tokenId, options = globalThis.globalEnvOption) {
|
|
61
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
62
|
+
return await common_1.ERC721_CONTRACT_INTERFACE.readFromChain(await this.getAddress(), "getApproved", [tokenId], chain);
|
|
63
|
+
}
|
|
64
|
+
async revokeForAll(spender, options = globalThis.globalEnvOption) {
|
|
65
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
66
|
+
const data = common_1.ERC721_CONTRACT_INTERFACE.encodeTransactionParams(await this.getAddress(), "setApprovalForAll", [spender, false]);
|
|
67
|
+
return { ...data, chain };
|
|
68
|
+
}
|
|
69
|
+
async transfer(sender, spender, tokenId, options = globalThis.globalEnvOption) {
|
|
70
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
71
|
+
const data = common_1.ERC721_CONTRACT_INTERFACE.encodeTransactionParams(await this.getAddress(), "transferFrom", [sender, spender, tokenId]);
|
|
72
|
+
return { ...data, chain };
|
|
73
|
+
}
|
|
74
|
+
static async approve(data, spender, tokenId, options = globalThis.globalEnvOption) {
|
|
75
|
+
const nft = new NFT(data);
|
|
76
|
+
return await nft.approve(spender, tokenId, options);
|
|
77
|
+
}
|
|
78
|
+
static async approveForAll(data, spender, options = globalThis.globalEnvOption) {
|
|
79
|
+
const nft = new NFT(data);
|
|
80
|
+
return await nft.approveForAll(spender, options);
|
|
81
|
+
}
|
|
82
|
+
static async getAddress(data) {
|
|
83
|
+
const nft = new NFT(data);
|
|
84
|
+
return await nft.getAddress();
|
|
85
|
+
}
|
|
86
|
+
static async getApproved(data, tokenId, options = globalThis.globalEnvOption) {
|
|
87
|
+
const nft = new NFT(data);
|
|
88
|
+
return await nft.getApproved(tokenId, options);
|
|
89
|
+
}
|
|
90
|
+
static async revokeForAll(data, spender, options = globalThis.globalEnvOption) {
|
|
91
|
+
const nft = new NFT(data);
|
|
92
|
+
return await nft.revokeForAll(spender, options);
|
|
93
|
+
}
|
|
94
|
+
static async transfer(data, sender, spender, tokenId, options = globalThis.globalEnvOption) {
|
|
95
|
+
const nft = new NFT(data);
|
|
96
|
+
return await nft.transfer(sender, spender, tokenId, options);
|
|
97
|
+
}
|
|
98
|
+
static async ownerOf(data, tokenId, options = globalThis.globalEnvOption) {
|
|
99
|
+
const nft = new NFT(data);
|
|
100
|
+
return await nft.ownerOf(tokenId, options);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.NFT = NFT;
|
|
104
|
+
//# sourceMappingURL=NFT.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NFT.js","sourceRoot":"","sources":["../../../src/data/NFT.ts"],"names":[],"mappings":";;;AAAA,+BAAyC;AACzC,mCAA+B;AAC/B,6CAA2D;AAC3D,sCAAsE;AAEtE,sCAA4D;AAE5D,MAAa,GAAG;IAIZ,YAAY,KAAa;QAFzB,SAAI,GAAG,EAAE,CAAA;QAGL,IAAI,CAAC,KAAK,EAAE;YACR,MAAM,IAAI,8BAAqB,CAC3B,kBAAS,CAAC,oBAAoB,EAC9B,4DAA4D,EAC5D,EAAE,KAAK,EAAE,EACT,qCAAqC,EACrC,sBAAsB,CACzB,CAAA;SACJ;QAED,IAAI,IAAA,gBAAS,EAAC,KAAK,CA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AAE,OAAO,CAAC,CAAA;IAChE,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,IAAY,EAAE,OAAe,EAAE,UAAsB,UAAkB,CAAC,eAAe;QACxG,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,IAAI,CAAC,CAAA;QACzB,OAAO,MAAM,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;IAC9C,CAAC;CACJ;AAlJD,kBAkJC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
import { Chain } from "./Chain";
|
|
3
|
+
import { AuthType, OperationMetadata, OperationStatus, OperationType, Signature, UserOperation } from "./types";
|
|
4
|
+
import { Auth } from "../auth";
|
|
5
|
+
import { EnvOption } from "../config";
|
|
6
|
+
export declare class Operation {
|
|
7
|
+
opId?: Hex;
|
|
8
|
+
chainId: string;
|
|
9
|
+
opType: OperationType;
|
|
10
|
+
authType: AuthType;
|
|
11
|
+
groupId?: Hex;
|
|
12
|
+
message?: string;
|
|
13
|
+
walletAddr: Address;
|
|
14
|
+
userOp: UserOperation;
|
|
15
|
+
status?: OperationStatus;
|
|
16
|
+
proposer: string;
|
|
17
|
+
proposedTime?: number;
|
|
18
|
+
executedBy?: string;
|
|
19
|
+
executedTime?: number;
|
|
20
|
+
relatedOpIds?: Hex[];
|
|
21
|
+
signatures?: Signature[];
|
|
22
|
+
txid?: string;
|
|
23
|
+
gasUsed?: string;
|
|
24
|
+
opFeeUSD?: string;
|
|
25
|
+
opFee?: string;
|
|
26
|
+
executedBlockNumber?: number;
|
|
27
|
+
executedBlockTimeStamp?: number;
|
|
28
|
+
constructor(userOp: UserOperation, metadata: OperationMetadata);
|
|
29
|
+
static convertTypeToObject(op: Operation): Operation;
|
|
30
|
+
getOpHash(chain: Chain): Promise<Hex>;
|
|
31
|
+
getMaxTxCost(): bigint;
|
|
32
|
+
estimateGas(auth: Auth, userId: string, options?: EnvOption): Promise<Operation>;
|
|
33
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Operation = void 0;
|
|
4
|
+
const Chain_1 = require("./Chain");
|
|
5
|
+
const constants_1 = require("../common/constants");
|
|
6
|
+
const utils_1 = require("../utils");
|
|
7
|
+
class Operation {
|
|
8
|
+
constructor(userOp, metadata) {
|
|
9
|
+
this.userOp = userOp;
|
|
10
|
+
this.userOp.preVerificationGas = userOp.preVerificationGas ? userOp.preVerificationGas : (0, utils_1.calcPreVerificationGas)(this.userOp);
|
|
11
|
+
this.opId = metadata.opId;
|
|
12
|
+
this.chainId = metadata.chainId;
|
|
13
|
+
this.opType = metadata.opType;
|
|
14
|
+
this.authType = metadata.authType;
|
|
15
|
+
this.groupId = metadata.groupId;
|
|
16
|
+
this.message = metadata.message;
|
|
17
|
+
this.walletAddr = metadata.walletAddr;
|
|
18
|
+
this.status = metadata.status;
|
|
19
|
+
this.proposer = metadata.proposer;
|
|
20
|
+
this.proposedTime = metadata.proposedTime;
|
|
21
|
+
this.executedBy = metadata.executedBy;
|
|
22
|
+
this.executedTime = metadata.executedTime;
|
|
23
|
+
this.relatedOpIds = metadata.relatedOpIds;
|
|
24
|
+
this.signatures = metadata.signatures;
|
|
25
|
+
this.txid = metadata.txid;
|
|
26
|
+
this.gasUsed = metadata.gasUsed;
|
|
27
|
+
this.opFeeUSD = metadata.opFeeUSD;
|
|
28
|
+
this.opFee = metadata.opFee;
|
|
29
|
+
this.executedBlockNumber = metadata.executedBlockNumber;
|
|
30
|
+
this.executedBlockTimeStamp = metadata.executedBlockTimeStamp;
|
|
31
|
+
}
|
|
32
|
+
static convertTypeToObject(op) {
|
|
33
|
+
return new Operation(op.userOp, {
|
|
34
|
+
...op
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
async getOpHash(chain) {
|
|
38
|
+
const entryPointAddress = await chain.getAddress("entryPointAddress");
|
|
39
|
+
return await constants_1.ENTRYPOINT_CONTRACT_INTERFACE.readFromChain(entryPointAddress, "getUserOpHash", [this.userOp], chain);
|
|
40
|
+
}
|
|
41
|
+
getMaxTxCost() {
|
|
42
|
+
const { maxFeePerGas, preVerificationGas, callGasLimit, verificationGasLimit } = this.userOp;
|
|
43
|
+
const mul = this.userOp.paymasterAndData !== "0x" ? 3 : 1;
|
|
44
|
+
const requiredGas = callGasLimit + verificationGasLimit * BigInt(mul) + preVerificationGas ? preVerificationGas : 0n;
|
|
45
|
+
return maxFeePerGas * requiredGas;
|
|
46
|
+
}
|
|
47
|
+
async estimateGas(auth, userId, options = globalThis.globalEnvOption) {
|
|
48
|
+
if (!this.userOp.signature || this.userOp.signature === "0x") {
|
|
49
|
+
this.userOp.signature = await auth.getEstimateGasSignature(userId, this);
|
|
50
|
+
}
|
|
51
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
52
|
+
const res = await chain.estimateOpGas({
|
|
53
|
+
...this.userOp,
|
|
54
|
+
paymasterAndData: "0x",
|
|
55
|
+
maxFeePerGas: 0n,
|
|
56
|
+
maxPriorityFeePerGas: 0n,
|
|
57
|
+
preVerificationGas: 0n,
|
|
58
|
+
callGasLimit: 0n,
|
|
59
|
+
verificationGasLimit: BigInt(10e6)
|
|
60
|
+
});
|
|
61
|
+
this.userOp.preVerificationGas = res.preVerificationGas;
|
|
62
|
+
this.userOp.verificationGasLimit = res.verificationGasLimit;
|
|
63
|
+
this.userOp.callGasLimit = res.callGasLimit;
|
|
64
|
+
return this;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.Operation = Operation;
|
|
68
|
+
//# sourceMappingURL=Operation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Operation.js","sourceRoot":"","sources":["../../../src/data/Operation.ts"],"names":[],"mappings":";;;AACA,mCAA+B;AAG/B,mDAAmE;AAEnE,oCAAiD;AAEjD,MAAa,SAAS;IAuBlB,Y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,EAAE,IAAI,CAAC,CAAA;SAC3E;QACD,MAAM,KAAK,GAAG,MAAM,aAAK,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACtE,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,aAAa,CAAC;YAClC,GAAG,IAAI,CAAC,MAAM;YACd,gBAAgB,EAAE,IAAI;YACtB,YAAY,EAAE,EAAE;YAChB,oBAAoB,EAAE,EAAE;YACxB,kBAAkB,EAAE,EAAE;YACtB,YAAY,EAAE,EAAE;YAChB,oBAAoB,EAAE,MAAM,CAAC,IAAI,CAAC;SACrC,CAAC,CAAA;QAEF,IAAI,CAAC,MAAM,CAAC,kBAAkB,GAAG,GAAG,CAAC,kBAAkB,CAAA;QACvD,IAAI,CAAC,MAAM,CAAC,oBAAoB,GAAG,GAAG,CAAC,oBAAoB,CAAA;QAC3D,IAAI,CAAC,MAAM,CAAC,YAAY,GAAG,GAAG,CAAC,YAAY,CAAA;QAE3C,OAAO,IAAI,CAAA;IACf,CAAC;CACJ;AAvFD,8BAuFC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
import { LoginData, WalletSignature } from "./types";
|
|
3
|
+
import { User } from "../wallet/types";
|
|
4
|
+
export declare function encodeLoginData(data: LoginData): Hex;
|
|
5
|
+
export declare function encodeWalletSignature(data: WalletSignature): Hex;
|
|
6
|
+
export declare function encodeUserAuthInitData(groupUsers: User[]): Hex;
|
|
7
|
+
export declare function addresstoBytes32(data: Address): Hex;
|
|
8
|
+
export declare function toBytes32Arr(data: Hex[]): Hex;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toBytes32Arr = exports.addresstoBytes32 = exports.encodeUserAuthInitData = exports.encodeWalletSignature = exports.encodeLoginData = void 0;
|
|
4
|
+
const abi_1 = require("@ethersproject/abi");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const common_1 = require("../common");
|
|
7
|
+
const extraDataStructType = {
|
|
8
|
+
type: "tuple",
|
|
9
|
+
components: [{ type: "bytes32[]" }, { type: "bytes32[]" }, { type: "bytes32[]" }, { type: "bytes32[]" }]
|
|
10
|
+
};
|
|
11
|
+
const walletSigEncodingTypes = [
|
|
12
|
+
{ type: "uint8" },
|
|
13
|
+
{ type: "bytes32" },
|
|
14
|
+
{ type: "bytes32" },
|
|
15
|
+
{ type: "bytes32" },
|
|
16
|
+
{ type: "bytes" },
|
|
17
|
+
extraDataStructType
|
|
18
|
+
];
|
|
19
|
+
function encodeLoginData(data) {
|
|
20
|
+
let { loginType, newFunWalletOwner, index, socialHandle, salt } = data;
|
|
21
|
+
newFunWalletOwner = newFunWalletOwner ? newFunWalletOwner : common_1.AddressZero;
|
|
22
|
+
index = index ? BigInt(index) : 0n;
|
|
23
|
+
socialHandle = socialHandle ? socialHandle : "0x";
|
|
24
|
+
salt = salt ? salt : common_1.HashZero;
|
|
25
|
+
loginType = loginType ? loginType : 0;
|
|
26
|
+
return (0, viem_1.encodeAbiParameters)([
|
|
27
|
+
{
|
|
28
|
+
type: "tuple",
|
|
29
|
+
components: [{ type: "uint8" }, { type: "address" }, { type: "bytes32" }, { type: "uint256" }, { type: "bytes" }]
|
|
30
|
+
}
|
|
31
|
+
], [[loginType, newFunWalletOwner, salt, index, socialHandle]]);
|
|
32
|
+
}
|
|
33
|
+
exports.encodeLoginData = encodeLoginData;
|
|
34
|
+
const parseExtraData = (data) => {
|
|
35
|
+
let { targetPath, selectorPath, feeRecipientPath, tokenPath } = data;
|
|
36
|
+
targetPath ?? (targetPath = []);
|
|
37
|
+
selectorPath ?? (selectorPath = []);
|
|
38
|
+
feeRecipientPath ?? (feeRecipientPath = []);
|
|
39
|
+
tokenPath ?? (tokenPath = []);
|
|
40
|
+
return [targetPath, selectorPath, feeRecipientPath, tokenPath];
|
|
41
|
+
};
|
|
42
|
+
function encodeWalletSignature(data) {
|
|
43
|
+
const { userId, signature, extraData } = data;
|
|
44
|
+
let { authType, roleId, ruleId } = data;
|
|
45
|
+
roleId ?? (roleId = common_1.HashZero);
|
|
46
|
+
ruleId ?? (ruleId = common_1.HashZero);
|
|
47
|
+
authType ?? (authType = 0);
|
|
48
|
+
const extraDataEncoded = extraData ? parseExtraData(extraData) : [[], [], [], []];
|
|
49
|
+
return (0, viem_1.encodeAbiParameters)(walletSigEncodingTypes, [authType, userId, roleId, ruleId, signature, extraDataEncoded]).toLowerCase();
|
|
50
|
+
}
|
|
51
|
+
exports.encodeWalletSignature = encodeWalletSignature;
|
|
52
|
+
function encodeUserAuthInitData(groupUsers) {
|
|
53
|
+
const groupIds = [];
|
|
54
|
+
const groupInfos = [];
|
|
55
|
+
groupUsers.forEach((user) => {
|
|
56
|
+
groupIds.push(user.userId);
|
|
57
|
+
const paddedMemberIds = user.groupInfo.memberIds.map((memberId) => (0, viem_1.pad)(memberId, { size: 32 }));
|
|
58
|
+
const sortedMemberIds = paddedMemberIds.sort((a, b) => (a > b ? -1 : 1));
|
|
59
|
+
groupInfos.push([sortedMemberIds, user.groupInfo.threshold]);
|
|
60
|
+
});
|
|
61
|
+
return abi_1.defaultAbiCoder.encode(["bytes32[]", "tuple(bytes32[],uint256)[]"], [groupIds, groupInfos]);
|
|
62
|
+
}
|
|
63
|
+
exports.encodeUserAuthInitData = encodeUserAuthInitData;
|
|
64
|
+
function addresstoBytes32(data) {
|
|
65
|
+
return (0, viem_1.encodeAbiParameters)([{ type: "address" }], [data]);
|
|
66
|
+
}
|
|
67
|
+
exports.addresstoBytes32 = addresstoBytes32;
|
|
68
|
+
function toBytes32Arr(data) {
|
|
69
|
+
return (0, viem_1.encodeAbiParameters)([{ type: "bytes32[]" }], [data]);
|
|
70
|
+
}
|
|
71
|
+
exports.toBytes32Arr = toBytes32Arr;
|
|
72
|
+
//# sourceMappingURL=SolidityData.js.map
|
|
@@ -0,0 +1 @@
|
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CAAC,EAAE,IAAI,EAAE,WAAW,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAA;AAC/D,CAAC;AAFD,oCAEC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { TransactionParams } from "../common";
|
|
3
|
+
import { EnvOption } from "../config";
|
|
4
|
+
export declare class Token {
|
|
5
|
+
address?: Address;
|
|
6
|
+
isNative: boolean;
|
|
7
|
+
symbol: string;
|
|
8
|
+
constructor(input: Address | string);
|
|
9
|
+
getAddress(options?: EnvOption): Promise<Address>;
|
|
10
|
+
getDecimals(options?: EnvOption): Promise<bigint>;
|
|
11
|
+
getBalance(address: Address, options?: EnvOption): Promise<string>;
|
|
12
|
+
getBalanceBN(address: Address, options?: EnvOption): Promise<bigint>;
|
|
13
|
+
getApproval(owner: string, spender: string, options?: EnvOption): Promise<bigint>;
|
|
14
|
+
getDecimalAmount(amount: number, options?: EnvOption): Promise<bigint>;
|
|
15
|
+
approve(spender: string, amount: number, options?: EnvOption): Promise<TransactionParams>;
|
|
16
|
+
transfer(spender: string, amount: number, options?: EnvOption): Promise<TransactionParams>;
|
|
17
|
+
static getAddress(data: string, options?: EnvOption): Promise<Address>;
|
|
18
|
+
static getDecimals(data: string, options?: EnvOption): Promise<bigint>;
|
|
19
|
+
static getBalance(data: string, address: Address, options?: EnvOption): Promise<string>;
|
|
20
|
+
static getBalanceBN(data: string, address: Address, options?: EnvOption): Promise<bigint>;
|
|
21
|
+
static getApproval(data: string, owner: string, spender: string, options?: EnvOption): Promise<bigint>;
|
|
22
|
+
static getDecimalAmount(data: string, amount: number, options?: EnvOption): Promise<bigint>;
|
|
23
|
+
static approve(data: string, spender: string, amount: number, options?: EnvOption): Promise<TransactionParams>;
|
|
24
|
+
static transfer(data: string, spender: string, amount: number, options?: EnvOption): Promise<TransactionParams>;
|
|
25
|
+
static isNative(data: string): boolean;
|
|
26
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Token = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const Chain_1 = require("./Chain");
|
|
6
|
+
const apis_1 = require("../apis");
|
|
7
|
+
const common_1 = require("../common");
|
|
8
|
+
const errors_1 = require("../errors");
|
|
9
|
+
const wrappedNativeTokens = { eth: "weth", matic: "wmatic" };
|
|
10
|
+
class Token {
|
|
11
|
+
constructor(input) {
|
|
12
|
+
this.isNative = false;
|
|
13
|
+
this.symbol = "";
|
|
14
|
+
if ((0, viem_1.isAddress)(input)) {
|
|
15
|
+
this.address = input;
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
else if (input.toLowerCase() in wrappedNativeTokens) {
|
|
19
|
+
this.isNative = true;
|
|
20
|
+
}
|
|
21
|
+
this.symbol = input;
|
|
22
|
+
}
|
|
23
|
+
async getAddress(options = globalThis.globalEnvOption) {
|
|
24
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
25
|
+
const chainId = await chain.getChainId();
|
|
26
|
+
if (this.isNative) {
|
|
27
|
+
const nativeName = wrappedNativeTokens[this.symbol];
|
|
28
|
+
return await (0, apis_1.getTokenInfo)(nativeName, chainId);
|
|
29
|
+
}
|
|
30
|
+
else if (this.address) {
|
|
31
|
+
return this.address;
|
|
32
|
+
}
|
|
33
|
+
else if (this.symbol) {
|
|
34
|
+
return await (0, apis_1.getTokenInfo)(this.symbol, chainId);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw new errors_1.InternalFailureError(errors_1.ErrorCode.ServerMissingData, "server missing token symbol and address info", { symbol: this.symbol, address: this.address, isNative: this.isNative }, "Please check token symbol and address. If things look correct, contract fun support for help", "https://docs.fun.xyz");
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async getDecimals(options = globalThis.globalEnvOption) {
|
|
41
|
+
if (this.isNative) {
|
|
42
|
+
return 18n;
|
|
43
|
+
}
|
|
44
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
45
|
+
return await common_1.ERC20_CONTRACT_INTERFACE.readFromChain(await this.getAddress(options), "decimals", [], chain);
|
|
46
|
+
}
|
|
47
|
+
async getBalance(address, options = globalThis.globalEnvOption) {
|
|
48
|
+
const amount = await this.getBalanceBN(address, options);
|
|
49
|
+
const decimals = await this.getDecimals(options);
|
|
50
|
+
return (0, viem_1.formatUnits)(amount, Number(decimals));
|
|
51
|
+
}
|
|
52
|
+
async getBalanceBN(address, options = globalThis.globalEnvOption) {
|
|
53
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
54
|
+
let amount = 0n;
|
|
55
|
+
if (this.isNative) {
|
|
56
|
+
const client = await chain.getClient();
|
|
57
|
+
amount = await client.getBalance({ address });
|
|
58
|
+
}
|
|
59
|
+
else {
|
|
60
|
+
amount = await common_1.ERC20_CONTRACT_INTERFACE.readFromChain(await this.getAddress(), "balanceOf", [address], chain);
|
|
61
|
+
}
|
|
62
|
+
return amount;
|
|
63
|
+
}
|
|
64
|
+
async getApproval(owner, spender, options = globalThis.globalEnvOption) {
|
|
65
|
+
if (this.isNative) {
|
|
66
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Native token can not approve", { isNative: this.isNative }, "No need to approve native token", "https://docs.fun.xyz");
|
|
67
|
+
}
|
|
68
|
+
const chain = await Chain_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
69
|
+
return BigInt(await common_1.ERC20_CONTRACT_INTERFACE.readFromChain(await this.getAddress(options), "allowance", [owner, spender], chain));
|
|
70
|
+
}
|
|
71
|
+
async getDecimalAmount(amount, options = globalThis.globalEnvOption) {
|
|
72
|
+
const decimals = await this.getDecimals(options);
|
|
73
|
+
return (0, viem_1.parseUnits)(`${amount}`, Number(decimals));
|
|
74
|
+
}
|
|
75
|
+
async approve(spender, amount, options = globalThis.globalEnvOption) {
|
|
76
|
+
const amountDec = await this.getDecimalAmount(amount);
|
|
77
|
+
const calldata = common_1.ERC20_CONTRACT_INTERFACE.encodeTransactionParams(await this.getAddress(options), "approve", [spender, amountDec]);
|
|
78
|
+
const { to, data, value } = calldata;
|
|
79
|
+
return { to: to, data: data, value: value };
|
|
80
|
+
}
|
|
81
|
+
async transfer(spender, amount, options = globalThis.globalEnvOption) {
|
|
82
|
+
const amountDec = await this.getDecimalAmount(amount);
|
|
83
|
+
return common_1.ERC20_CONTRACT_INTERFACE.encodeTransactionParams(await this.getAddress(options), "transfer", [spender, amountDec]);
|
|
84
|
+
}
|
|
85
|
+
static async getAddress(data, options = globalThis.globalEnvOption) {
|
|
86
|
+
const token = new Token(data);
|
|
87
|
+
return await token.getAddress(options);
|
|
88
|
+
}
|
|
89
|
+
static async getDecimals(data, options = globalThis.globalEnvOption) {
|
|
90
|
+
const token = new Token(data);
|
|
91
|
+
return await token.getDecimals(options);
|
|
92
|
+
}
|
|
93
|
+
static async getBalance(data, address, options = globalThis.globalEnvOption) {
|
|
94
|
+
const token = new Token(data);
|
|
95
|
+
return await token.getBalance(address, options);
|
|
96
|
+
}
|
|
97
|
+
static async getBalanceBN(data, address, options = globalThis.globalEnvOption) {
|
|
98
|
+
const token = new Token(data);
|
|
99
|
+
return await token.getBalanceBN(address, options);
|
|
100
|
+
}
|
|
101
|
+
static async getApproval(data, owner, spender, options = globalThis.globalEnvOption) {
|
|
102
|
+
const token = new Token(data);
|
|
103
|
+
return await token.getApproval(owner, spender, options);
|
|
104
|
+
}
|
|
105
|
+
static async getDecimalAmount(data, amount, options = globalThis.globalEnvOption) {
|
|
106
|
+
const token = new Token(data);
|
|
107
|
+
return await token.getDecimalAmount(amount, options);
|
|
108
|
+
}
|
|
109
|
+
static async approve(data, spender, amount, options = globalThis.globalEnvOption) {
|
|
110
|
+
const token = new Token(data);
|
|
111
|
+
return await token.approve(spender, amount, options);
|
|
112
|
+
}
|
|
113
|
+
static async transfer(data, spender, amount, options = globalThis.globalEnvOption) {
|
|
114
|
+
const token = new Token(data);
|
|
115
|
+
return await token.transfer(spender, amount, options);
|
|
116
|
+
}
|
|
117
|
+
static isNative(data) {
|
|
118
|
+
return data.toLowerCase() in wrappedNativeTokens;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
exports.Token = Token;
|
|
122
|
+
//# sourceMappingURL=Token.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Token.js","sourceRoot":"","sources":["../../../src/data/Token.ts"],"names":[],"mappings":";;;AAAA,+BAAkE;AAClE,mCAA+B;AAC/B,kCAAsC;AACtC,sCAAuE;AAEvE,sCAAkF;AAElF,MAAM,mBAAmB,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAA;AAE5D,MAAa,KAAK;IAKd,YAAY,KAAuB;QAHnC,aAAQ,GAAG,KAAK,CAAA;QAChB,WAAM,GAAG,EAAE,CAAA;QAGP,IAAI,IAAA,gBAAS,EAAC,KAAK,CAAC,EAAE;YAClB,IAAI,CAAC,OAAO,GAAG,KAAK,CAAA;YACpB,OAAM;SACT;aAAM,IAAI,KAAK,CAAC,WAAW,EAAE,IAAI,mBAAmB,EAAE;YACnD,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAA;SACvB;QAED,IAAI,CAAC,MAAM,GAAG,KAAK,CAAA;IACvB,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAsB,UAAkB,CAAC,eAAe;QACrE,MAAM,KAAK,GAAG,MAAM,aAAK,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,OAAO,CAAC,KAAK,EAAE,CAAC,CAAA;QACtE,MAAM,OAAO,GAAG,MAAM,KAAK,CAAC,UAAU,EAAE,CAAA;QAExC,IAAI,IAAI,CAAC,QAAQ,EAAE;YACf,MAAM,UAAU,GAAI,mBAA2B,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;YAC5D,OAAO,MAAM,IAAA,mBAAY,E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,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;QAC7B,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACxD,CAAC;IAED,MAAM,CAAC,KAAK,CAAC,QAAQ,CACjB,IAAY,EACZ,OAAe,EACf,MAAc,EACd,UAAsB,UAAkB,CAAC,eAAe;QAExD,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,CAAC,CAAA;QAC7B,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,CAAC,CAAA;IACzD,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAY;QACxB,OAAO,IAAI,CAAC,WAAW,EAAE,IAAI,mBAAmB,CAAA;IACpD,CAAC;CACJ;AAxJD,sBAwJC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./Chain"), exports);
|
|
18
|
+
__exportStar(require("./Token"), exports);
|
|
19
|
+
__exportStar(require("./Operation"), exports);
|
|
20
|
+
__exportStar(require("./SolidityData"), exports);
|
|
21
|
+
__exportStar(require("./NFT"), exports);
|
|
22
|
+
__exportStar(require("./types"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/data/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAuB;AACvB,0CAAuB;AACvB,8CAA2B;AAC3B,iDAA8B;AAC9B,wCAAqB;AACrB,0CAAuB"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
2
|
+
import { Chain } from "./Chain";
|
|
3
|
+
export interface ChainInput {
|
|
4
|
+
chainIdentifier?: string | Chain | number;
|
|
5
|
+
rpcUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export type FactoryCreateAccountParams = {
|
|
8
|
+
initializerCallData: string;
|
|
9
|
+
implementation: string;
|
|
10
|
+
data: string;
|
|
11
|
+
};
|
|
12
|
+
export type InitCodeParams = {
|
|
13
|
+
entryPointAddress: Address;
|
|
14
|
+
factoryAddress: Address;
|
|
15
|
+
implementationAddress?: Address;
|
|
16
|
+
loginData: LoginData;
|
|
17
|
+
verificationData: readonly Hex[];
|
|
18
|
+
verificationAddresses: readonly Address[];
|
|
19
|
+
};
|
|
20
|
+
export type Addresses = {
|
|
21
|
+
[key: string]: Address;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* @param loginType 0 = EOA, 1 = Twitter
|
|
25
|
+
* @param newFunWalletOwner *social login* Address of the new FunWallet owner, used to stop frontrunning
|
|
26
|
+
* @param index *social login* Hashed with socialHandle and loginType to generate salt
|
|
27
|
+
* @param socialHandle *social login*
|
|
28
|
+
* @param salt *EOA login* Hashed with loginType to generate salt
|
|
29
|
+
*/
|
|
30
|
+
export type LoginData = {
|
|
31
|
+
loginType?: number;
|
|
32
|
+
newFunWalletOwner?: Hex;
|
|
33
|
+
index?: number | bigint;
|
|
34
|
+
socialHandle?: Hex;
|
|
35
|
+
salt?: Hex;
|
|
36
|
+
};
|
|
37
|
+
export type WalletInitialzeParams = {
|
|
38
|
+
_newEntryPoint: string;
|
|
39
|
+
validationInitData: string;
|
|
40
|
+
};
|
|
41
|
+
export type WalletSignature = {
|
|
42
|
+
authType?: number;
|
|
43
|
+
userId: Hex;
|
|
44
|
+
roleId?: Hex;
|
|
45
|
+
ruleId?: Hex;
|
|
46
|
+
signature: Hex;
|
|
47
|
+
extraData?: ExtraDataType;
|
|
48
|
+
};
|
|
49
|
+
export type ExtraDataType = {
|
|
50
|
+
targetPath?: Hex[];
|
|
51
|
+
selectorPath?: Hex[];
|
|
52
|
+
feeRecipientPath?: Hex[];
|
|
53
|
+
tokenPath?: Hex[];
|
|
54
|
+
};
|
|
55
|
+
export type UserOperation = {
|
|
56
|
+
sender: string;
|
|
57
|
+
nonce: bigint;
|
|
58
|
+
initCode?: string;
|
|
59
|
+
callData: string;
|
|
60
|
+
callGasLimit: bigint;
|
|
61
|
+
verificationGasLimit: bigint;
|
|
62
|
+
preVerificationGas?: bigint;
|
|
63
|
+
maxFeePerGas: bigint;
|
|
64
|
+
maxPriorityFeePerGas: bigint;
|
|
65
|
+
paymasterAndData?: string;
|
|
66
|
+
signature?: string;
|
|
67
|
+
};
|
|
68
|
+
export declare enum AuthType {
|
|
69
|
+
ECDSA = 0,
|
|
70
|
+
MULTI_SIG = 1
|
|
71
|
+
}
|
|
72
|
+
export type Signature = {
|
|
73
|
+
userId: Hex;
|
|
74
|
+
signature: Hex;
|
|
75
|
+
signedTime: number;
|
|
76
|
+
};
|
|
77
|
+
export declare enum OperationType {
|
|
78
|
+
SINGLE_OPERATION = "SINGLE_OPERATION",
|
|
79
|
+
GROUP_OPERATION = "GROUP_OPERATION",
|
|
80
|
+
REJECTION = "REJECTION"
|
|
81
|
+
}
|
|
82
|
+
export declare enum OperationStatus {
|
|
83
|
+
ALL = "",
|
|
84
|
+
PENDING_APPROVED = "PENDING_APPROVED",
|
|
85
|
+
APPROVED = "APPROVED",
|
|
86
|
+
PENDING = "PENDING",
|
|
87
|
+
OP_SUCCEED = "OP_SUCCEED",
|
|
88
|
+
OP_REVERTED = "OP_REVERTED",
|
|
89
|
+
SCHEDULED = "SCHEDULED"
|
|
90
|
+
}
|
|
91
|
+
export type OperationMetadata = {
|
|
92
|
+
opId?: Hex;
|
|
93
|
+
chainId: string;
|
|
94
|
+
opType: OperationType;
|
|
95
|
+
authType: AuthType;
|
|
96
|
+
groupId?: Hex;
|
|
97
|
+
message?: string;
|
|
98
|
+
walletAddr: Address;
|
|
99
|
+
status?: OperationStatus;
|
|
100
|
+
proposer: string;
|
|
101
|
+
proposedTime?: number;
|
|
102
|
+
executedBy?: string;
|
|
103
|
+
executedTime?: number;
|
|
104
|
+
relatedOpIds?: Hex[];
|
|
105
|
+
signatures?: Signature[];
|
|
106
|
+
txid?: string;
|
|
107
|
+
gasUsed?: string;
|
|
108
|
+
opFeeUSD?: string;
|
|
109
|
+
opFee?: string;
|
|
110
|
+
executedBlockNumber?: number;
|
|
111
|
+
executedBlockTimeStamp?: number;
|
|
112
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OperationStatus = exports.OperationType = exports.AuthType = void 0;
|
|
4
|
+
var AuthType;
|
|
5
|
+
(function (AuthType) {
|
|
6
|
+
AuthType[AuthType["ECDSA"] = 0] = "ECDSA";
|
|
7
|
+
AuthType[AuthType["MULTI_SIG"] = 1] = "MULTI_SIG";
|
|
8
|
+
})(AuthType || (exports.AuthType = AuthType = {}));
|
|
9
|
+
var OperationType;
|
|
10
|
+
(function (OperationType) {
|
|
11
|
+
OperationType["SINGLE_OPERATION"] = "SINGLE_OPERATION";
|
|
12
|
+
OperationType["GROUP_OPERATION"] = "GROUP_OPERATION";
|
|
13
|
+
OperationType["REJECTION"] = "REJECTION";
|
|
14
|
+
})(OperationType || (exports.OperationType = OperationType = {}));
|
|
15
|
+
var OperationStatus;
|
|
16
|
+
(function (OperationStatus) {
|
|
17
|
+
OperationStatus["ALL"] = "";
|
|
18
|
+
OperationStatus["PENDING_APPROVED"] = "PENDING_APPROVED";
|
|
19
|
+
OperationStatus["APPROVED"] = "APPROVED";
|
|
20
|
+
OperationStatus["PENDING"] = "PENDING";
|
|
21
|
+
OperationStatus["OP_SUCCEED"] = "OP_SUCCEED";
|
|
22
|
+
OperationStatus["OP_REVERTED"] = "OP_REVERTED";
|
|
23
|
+
OperationStatus["SCHEDULED"] = "SCHEDULED";
|
|
24
|
+
})(OperationStatus || (exports.OperationStatus = OperationStatus = {}));
|
|
25
|
+
//# sourceMappingURL=types.js.map
|