@funkit/core 0.9.0 → 0.10.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/dist/fetch-polyfill.js.map +1 -1
- package/dist/index.d.ts +12 -12
- package/dist/src/abis/CheckoutPaymaster.json +1 -0
- package/dist/src/actions/AccessControl.d.ts +6 -6
- package/dist/src/actions/AccessControl.js +19 -15
- package/dist/src/actions/AccessControl.js.map +1 -1
- package/dist/src/actions/BatchActions.d.ts +2 -2
- package/dist/src/actions/BatchActions.js +2 -2
- package/dist/src/actions/BatchActions.js.map +1 -1
- package/dist/src/actions/Bridge.d.ts +4 -4
- package/dist/src/actions/Bridge.js +10 -6
- package/dist/src/actions/Bridge.js.map +1 -1
- package/dist/src/actions/FirstClassActions.d.ts +6 -6
- package/dist/src/actions/FirstClassActions.js +25 -23
- package/dist/src/actions/FirstClassActions.js.map +1 -1
- package/dist/src/actions/Group.d.ts +3 -3
- package/dist/src/actions/Group.js +6 -14
- package/dist/src/actions/Group.js.map +1 -1
- package/dist/src/actions/LimitOrder.d.ts +3 -3
- package/dist/src/actions/LimitOrder.js +16 -13
- package/dist/src/actions/LimitOrder.js.map +1 -1
- package/dist/src/actions/Stake.d.ts +3 -3
- package/dist/src/actions/Stake.js +31 -44
- package/dist/src/actions/Stake.js.map +1 -1
- package/dist/src/actions/Swap.d.ts +4 -4
- package/dist/src/actions/Swap.js +37 -35
- package/dist/src/actions/Swap.js.map +1 -1
- package/dist/src/actions/Token.d.ts +3 -3
- package/dist/src/actions/Token.js +33 -23
- package/dist/src/actions/Token.js.map +1 -1
- package/dist/src/actions/index.d.ts +7 -7
- package/dist/src/actions/types.d.ts +4 -4
- package/dist/src/actions/types.js +2 -2
- package/dist/src/actions/types.js.map +1 -1
- package/dist/src/apis/AccessControlApis.d.ts +1 -1
- package/dist/src/apis/AccessControlApis.js +7 -3
- package/dist/src/apis/AccessControlApis.js.map +1 -1
- package/dist/src/apis/AssetApis.d.ts +10 -0
- package/dist/src/apis/AssetApis.js +11 -1
- package/dist/src/apis/AssetApis.js.map +1 -1
- package/dist/src/apis/BridgeApis.d.ts +1 -1
- package/dist/src/apis/BridgeApis.js +13 -13
- package/dist/src/apis/BridgeApis.js.map +1 -1
- package/dist/src/apis/CheckoutApis.d.ts +43 -0
- package/dist/src/apis/CheckoutApis.js +116 -0
- package/dist/src/apis/CheckoutApis.js.map +1 -0
- package/dist/src/apis/ContractApis.js +1 -1
- package/dist/src/apis/ContractApis.js.map +1 -1
- package/dist/src/apis/FaucetApis.js.map +1 -1
- package/dist/src/apis/GroupApis.d.ts +2 -2
- package/dist/src/apis/GroupApis.js +3 -3
- package/dist/src/apis/GroupApis.js.map +1 -1
- package/dist/src/apis/InfoApis.d.ts +1 -1
- package/dist/src/apis/InfoApis.js +9 -7
- package/dist/src/apis/InfoApis.js.map +1 -1
- package/dist/src/apis/ListenerApis.d.ts +1 -1
- package/dist/src/apis/ListenerApis.js +6 -6
- package/dist/src/apis/ListenerApis.js.map +1 -1
- package/dist/src/apis/MeshApis.d.ts +87 -0
- package/dist/src/apis/MeshApis.js +213 -0
- package/dist/src/apis/MeshApis.js.map +1 -0
- package/dist/src/apis/NFTApis.js.map +1 -1
- package/dist/src/apis/OnOffRampApis.d.ts +2 -0
- package/dist/src/apis/OnOffRampApis.js +24 -5
- package/dist/src/apis/OnOffRampApis.js.map +1 -1
- package/dist/src/apis/OnOffRampUtils.js +2 -2
- package/dist/src/apis/OnOffRampUtils.js.map +1 -1
- package/dist/src/apis/OperationApis.d.ts +4 -4
- package/dist/src/apis/OperationApis.js +21 -12
- package/dist/src/apis/OperationApis.js.map +1 -1
- package/dist/src/apis/PaymasterApis.d.ts +1 -1
- package/dist/src/apis/PaymasterApis.js +2 -2
- package/dist/src/apis/PaymasterApis.js.map +1 -1
- package/dist/src/apis/SwapApis.d.ts +2 -2
- package/dist/src/apis/SwapApis.js +6 -6
- package/dist/src/apis/SwapApis.js.map +1 -1
- package/dist/src/apis/TurnkeyApis.d.ts +1 -1
- package/dist/src/apis/TurnkeyApis.js +3 -3
- package/dist/src/apis/TurnkeyApis.js.map +1 -1
- package/dist/src/apis/UserApis.d.ts +2 -2
- package/dist/src/apis/UserApis.js +10 -7
- package/dist/src/apis/UserApis.js.map +1 -1
- package/dist/src/apis/index.d.ts +13 -11
- package/dist/src/apis/index.js +3 -1
- package/dist/src/apis/index.js.map +1 -1
- package/dist/src/apis/types.d.ts +75 -3
- package/dist/src/apis/types.js +16 -0
- package/dist/src/apis/types.js.map +1 -1
- package/dist/src/auth/Auth.d.ts +6 -6
- package/dist/src/auth/Auth.js +43 -46
- package/dist/src/auth/Auth.js.map +1 -1
- package/dist/src/auth/SessionKeyAuth.d.ts +5 -5
- package/dist/src/auth/SessionKeyAuth.js +29 -24
- package/dist/src/auth/SessionKeyAuth.js.map +1 -1
- package/dist/src/auth/index.d.ts +2 -2
- package/dist/src/auth/types.d.ts +1 -1
- package/dist/src/common/constants.d.ts +110 -17
- package/dist/src/common/constants.js +158 -85
- package/dist/src/common/constants.js.map +1 -1
- package/dist/src/common/index.d.ts +2 -2
- package/dist/src/common/types.d.ts +2 -2
- package/dist/src/config/Config.d.ts +1 -1
- package/dist/src/config/Config.js +10 -4
- package/dist/src/config/Config.js.map +1 -1
- package/dist/src/config/index.d.ts +2 -2
- package/dist/src/config/types.d.ts +4 -2
- package/dist/src/data/Chain.d.ts +4 -4
- package/dist/src/data/Chain.js +38 -27
- package/dist/src/data/Chain.js.map +1 -1
- package/dist/src/data/NFT.d.ts +3 -3
- package/dist/src/data/NFT.js +11 -11
- package/dist/src/data/NFT.js.map +1 -1
- package/dist/src/data/Operation.d.ts +5 -5
- package/dist/src/data/Operation.js +12 -10
- package/dist/src/data/Operation.js.map +1 -1
- package/dist/src/data/SolidityData.d.ts +3 -3
- package/dist/src/data/SolidityData.js +37 -17
- package/dist/src/data/SolidityData.js.map +1 -1
- package/dist/src/data/Token.d.ts +4 -4
- package/dist/src/data/Token.js +9 -9
- package/dist/src/data/Token.js.map +1 -1
- package/dist/src/data/index.d.ts +6 -6
- package/dist/src/data/index.js +2 -2
- package/dist/src/data/index.js.map +1 -1
- package/dist/src/data/types.d.ts +2 -2
- package/dist/src/data/types.js +3 -3
- package/dist/src/data/types.js.map +1 -1
- package/dist/src/errors/BaseError.js +4 -3
- package/dist/src/errors/BaseError.js.map +1 -1
- package/dist/src/errors/ClientError.d.ts +1 -1
- package/dist/src/errors/ClientError.js +3 -3
- package/dist/src/errors/ClientError.js.map +1 -1
- package/dist/src/errors/ServerError.d.ts +1 -1
- package/dist/src/errors/ServerError.js.map +1 -1
- package/dist/src/errors/index.d.ts +4 -4
- package/dist/src/errors/types.d.ts +2 -1
- package/dist/src/errors/types.js +4 -3
- package/dist/src/errors/types.js.map +1 -1
- package/dist/src/sponsors/CheckoutSponsor.d.ts +23 -0
- package/dist/src/sponsors/CheckoutSponsor.js +65 -0
- package/dist/src/sponsors/CheckoutSponsor.js.map +1 -0
- package/dist/src/sponsors/GaslessSponsor.d.ts +4 -4
- package/dist/src/sponsors/GaslessSponsor.js +18 -15
- package/dist/src/sponsors/GaslessSponsor.js.map +1 -1
- package/dist/src/sponsors/Sponsor.d.ts +5 -5
- package/dist/src/sponsors/Sponsor.js +12 -11
- package/dist/src/sponsors/Sponsor.js.map +1 -1
- package/dist/src/sponsors/TokenSponsor.d.ts +7 -7
- package/dist/src/sponsors/TokenSponsor.js +75 -68
- package/dist/src/sponsors/TokenSponsor.js.map +1 -1
- package/dist/src/sponsors/index.d.ts +4 -3
- package/dist/src/sponsors/index.js +2 -1
- package/dist/src/sponsors/index.js.map +1 -1
- package/dist/src/sponsors/types.d.ts +2 -1
- package/dist/src/sponsors/types.js +2 -1
- package/dist/src/sponsors/types.js.map +1 -1
- package/dist/src/utils/ApiUtils.js +21 -19
- package/dist/src/utils/ApiUtils.js.map +1 -1
- package/dist/src/utils/AuthUtils.d.ts +1 -1
- package/dist/src/utils/AuthUtils.js +4 -4
- package/dist/src/utils/AuthUtils.js.map +1 -1
- package/dist/src/utils/ChainUtils.d.ts +5 -5
- package/dist/src/utils/ChainUtils.js +35 -20
- package/dist/src/utils/ChainUtils.js.map +1 -1
- package/dist/src/utils/CheckoutUtils.d.ts +6 -0
- package/dist/src/utils/CheckoutUtils.js +24 -0
- package/dist/src/utils/CheckoutUtils.js.map +1 -0
- package/dist/src/utils/GroupUtils.d.ts +3 -3
- package/dist/src/utils/GroupUtils.js +8 -8
- package/dist/src/utils/GroupUtils.js.map +1 -1
- package/dist/src/utils/MerkleUtils.d.ts +1 -1
- package/dist/src/utils/MerkleUtils.js +5 -5
- package/dist/src/utils/MerkleUtils.js.map +1 -1
- package/dist/src/utils/PaymasterUtils.d.ts +3 -3
- package/dist/src/utils/PaymasterUtils.js +6 -2
- package/dist/src/utils/PaymasterUtils.js.map +1 -1
- package/dist/src/utils/SwapUtils.d.ts +2 -2
- package/dist/src/utils/SwapUtils.js +42 -33
- package/dist/src/utils/SwapUtils.js.map +1 -1
- package/dist/src/utils/TypeUtils.js.map +1 -1
- package/dist/src/utils/UserOpUtils.d.ts +2 -2
- package/dist/src/utils/UserOpUtils.js +77 -65
- package/dist/src/utils/UserOpUtils.js.map +1 -1
- package/dist/src/utils/ViemUtils.d.ts +2 -2
- package/dist/src/utils/ViemUtils.js +10 -6
- package/dist/src/utils/ViemUtils.js.map +1 -1
- package/dist/src/utils/WalletUtils.d.ts +2 -2
- package/dist/src/utils/WalletUtils.js +6 -5
- package/dist/src/utils/WalletUtils.js.map +1 -1
- package/dist/src/utils/index.d.ts +8 -7
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/viem/ContractInterface.d.ts +4 -4
- package/dist/src/viem/ContractInterface.js +8 -8
- package/dist/src/viem/ContractInterface.js.map +1 -1
- package/dist/src/viem/Converter.d.ts +823 -1107
- package/dist/src/viem/Converter.js +11 -11
- package/dist/src/viem/Converter.js.map +1 -1
- package/dist/src/viem/index.d.ts +2 -2
- package/dist/src/wallet/FunWallet.d.ts +8 -8
- package/dist/src/wallet/FunWallet.js +133 -89
- package/dist/src/wallet/FunWallet.js.map +1 -1
- package/dist/src/wallet/index.d.ts +2 -2
- package/dist/src/wallet/types.d.ts +1 -1
- package/package.json +13 -5
|
@@ -5,12 +5,12 @@ const viem_1 = require("viem");
|
|
|
5
5
|
// @ts-ignore
|
|
6
6
|
//eslint-disable-next-line
|
|
7
7
|
const chains_1 = require("viem/chains");
|
|
8
|
-
const convertProviderToClient = ({ provider, viemChain }) => {
|
|
8
|
+
const convertProviderToClient = ({ provider, viemChain, }) => {
|
|
9
9
|
const chain = viemChain ? viemChain : chains_1.mainnet;
|
|
10
10
|
if (provider.request) {
|
|
11
11
|
return (0, viem_1.createWalletClient)({
|
|
12
12
|
chain,
|
|
13
|
-
transport: (0, viem_1.custom)(provider)
|
|
13
|
+
transport: (0, viem_1.custom)(provider),
|
|
14
14
|
});
|
|
15
15
|
}
|
|
16
16
|
if (!provider.send)
|
|
@@ -21,31 +21,31 @@ const convertProviderToClient = ({ provider, viemChain }) => {
|
|
|
21
21
|
async request({ method, params }) {
|
|
22
22
|
const response = await provider.send(method, params);
|
|
23
23
|
return response;
|
|
24
|
-
}
|
|
25
|
-
})
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
26
|
});
|
|
27
27
|
};
|
|
28
28
|
exports.convertProviderToClient = convertProviderToClient;
|
|
29
|
-
const convertSignerToClient = ({ signer, viemChain }) => {
|
|
29
|
+
const convertSignerToClient = ({ signer, viemChain, }) => {
|
|
30
30
|
const chain = viemChain ? viemChain : chains_1.mainnet;
|
|
31
|
-
if (signer.type ===
|
|
31
|
+
if (signer.type === 'local') {
|
|
32
32
|
return (0, viem_1.createWalletClient)({
|
|
33
33
|
chain,
|
|
34
|
-
transport: (0, viem_1.custom)(signer)
|
|
34
|
+
transport: (0, viem_1.custom)(signer),
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
return (0, viem_1.createWalletClient)({
|
|
38
38
|
chain,
|
|
39
39
|
transport: (0, viem_1.custom)({
|
|
40
40
|
async request({ method, params }) {
|
|
41
|
-
if (method ===
|
|
41
|
+
if (method === 'eth_requestAccounts') {
|
|
42
42
|
return [await signer.getAddress()];
|
|
43
43
|
}
|
|
44
|
-
else if (method ===
|
|
44
|
+
else if (method === 'personal_sign') {
|
|
45
45
|
return await signer.signMessage((0, viem_1.toBytes)(params[0]));
|
|
46
46
|
}
|
|
47
|
-
}
|
|
48
|
-
})
|
|
47
|
+
},
|
|
48
|
+
}),
|
|
49
49
|
});
|
|
50
50
|
};
|
|
51
51
|
exports.convertSignerToClient = convertSignerToClient;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Converter.js","sourceRoot":"","sources":["../../../src/viem/Converter.ts"],"names":[],"mappings":";;;AAAA,+BAA0D;AAC1D,aAAa;AACb,0BAA0B;AAC1B,wCAA4C;AAYrC,MAAM,uBAAuB,GAAG,CAAC,
|
|
1
|
+
{"version":3,"file":"Converter.js","sourceRoot":"","sources":["../../../src/viem/Converter.ts"],"names":[],"mappings":";;;AAAA,+BAA0D;AAC1D,aAAa;AACb,0BAA0B;AAC1B,wCAA4C;AAYrC,MAAM,uBAAuB,GAAG,CAAC,EACtC,QAAQ,EACR,SAAS,GACuB,EAAE,EAAE;IACpC,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAO,CAAA;IAC7C,IAAI,QAAQ,CAAC,OAAO,EAAE,CAAC;QACrB,OAAO,IAAA,yBAAkB,EAAC;YACxB,KAAK;YACL,SAAS,EAAE,IAAA,aAAM,EAAC,QAAQ,CAAC;SAC5B,CAAC,CAAA;IACJ,CAAC;IACD,IAAI,CAAC,QAAQ,CAAC,IAAI;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAA;IACxE,OAAO,IAAA,yBAAkB,EAAC;QACxB,KAAK;QACL,SAAS,EAAE,IAAA,aAAM,EAAC;YAChB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;gBAC9B,MAAM,QAAQ,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;gBACpD,OAAO,QAAQ,CAAA;YACjB,CAAC;SACF,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA;AArBY,QAAA,uBAAuB,2BAqBnC;AAEM,MAAM,qBAAqB,GAAG,CAAC,EACpC,MAAM,EACN,SAAS,GACqB,EAAE,EAAE;IAClC,MAAM,KAAK,GAAG,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,gBAAO,CAAA;IAC7C,IAAI,MAAM,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QAC5B,OAAO,IAAA,yBAAkB,EAAC;YACxB,KAAK;YACL,SAAS,EAAE,IAAA,aAAM,EAAC,MAAM,CAAC;SAC1B,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,IAAA,yBAAkB,EAAC;QACxB,KAAK;QACL,SAAS,EAAE,IAAA,aAAM,EAAC;YAChB,KAAK,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;gBAC9B,IAAI,MAAM,KAAK,qBAAqB,EAAE,CAAC;oBACrC,OAAO,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC,CAAA;gBACpC,CAAC;qBAAM,IAAI,MAAM,KAAK,eAAe,EAAE,CAAC;oBACtC,OAAO,MAAM,MAAM,CAAC,WAAW,CAAC,IAAA,cAAO,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAA;gBACrD,CAAC;YACH,CAAC;SACF,CAAC;KACH,CAAC,CAAA;AACJ,CAAC,CAAA;AAvBY,QAAA,qBAAqB,yBAuBjC"}
|
package/dist/src/viem/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from
|
|
2
|
-
export * from
|
|
1
|
+
export * from './ContractInterface';
|
|
2
|
+
export * from './Converter';
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { Address, Hex } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
1
|
+
import { Address, Hex } from 'viem';
|
|
2
|
+
import { FirstClassActions } from '../actions/FirstClassActions';
|
|
3
|
+
import { Currency } from '../apis';
|
|
4
|
+
import { Auth } from '../auth';
|
|
5
|
+
import { ExecutionReceipt, TransactionParams } from '../common';
|
|
6
|
+
import { EnvOption } from '../config';
|
|
7
|
+
import { Operation, OperationStatus } from '../data';
|
|
8
|
+
import { FunWalletParams, User } from './types';
|
|
9
9
|
export declare class FunWallet extends FirstClassActions {
|
|
10
10
|
walletUniqueId?: Hex;
|
|
11
11
|
userInfo?: Map<Hex, User>;
|
|
@@ -27,28 +27,28 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
27
27
|
constructor(params) {
|
|
28
28
|
const chain = globalThis.globalEnvOption.chain;
|
|
29
29
|
super(chain);
|
|
30
|
-
if (typeof params ===
|
|
30
|
+
if (typeof params === 'string') {
|
|
31
31
|
if ((0, viem_1.isAddress)(params)) {
|
|
32
32
|
this.address = params;
|
|
33
33
|
}
|
|
34
34
|
else {
|
|
35
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter,
|
|
35
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, 'string input must be an address type', params, 'Provide either (uniqueId, users) or walletAddr when constructing a FunWallet', 'https://docs.fun.xyz/how-to-guides/execute-transactions/create-funwallet#create-funwallet-manual-funwallet-creation');
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
else {
|
|
39
39
|
const { users, uniqueId } = params;
|
|
40
40
|
if (!uniqueId || !(0, TypeUtils_1.isBytes32)(uniqueId) || !users || users.length <= 0) {
|
|
41
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter,
|
|
41
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, 'uniqueId must be bytes32 and users must be non-empty', params, 'The uniqueId field should be a 32 byte Hexstring and the users field should be an array of User objects', 'https://docs.fun.xyz/how-to-guides/execute-transactions/create-funwallet#create-funwallet-manual-funwallet-creation');
|
|
42
42
|
}
|
|
43
43
|
this.userInfo = new Map(users?.map((user) => {
|
|
44
44
|
if (!user.userId || !(0, viem_1.isHex)(user.userId)) {
|
|
45
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter,
|
|
45
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, 'userId is required and must be a hex string', users, 'Provide hex string userId when creating a FunWallet', 'https://docs.fun.xyz/how-to-guides/execute-transactions/create-funwallet#create-funwallet-manual-funwallet-creation');
|
|
46
46
|
}
|
|
47
47
|
if (user.groupInfo &&
|
|
48
48
|
(!Number.isInteger(user.groupInfo.threshold) ||
|
|
49
49
|
!Array.isArray(user.groupInfo.memberIds) ||
|
|
50
50
|
!user.groupInfo.memberIds.every((memberId) => (0, viem_1.isHex)(memberId)))) {
|
|
51
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter,
|
|
51
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, 'groupInfo must be an object with threshold as integer and memberIds as array of hex strings', users, 'Provide valid groupInfo when creating a FunWallet', 'https://docs.fun.xyz/how-to-guides/execute-transactions/create-funwallet#create-funwallet-manual-funwallet-creation');
|
|
52
52
|
}
|
|
53
53
|
return [(0, viem_1.pad)(user.userId, { size: 32 }), user];
|
|
54
54
|
}));
|
|
@@ -86,9 +86,9 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
86
86
|
*/
|
|
87
87
|
static async getAddressOffline(uniqueId, rpcUrl, factoryAddress) {
|
|
88
88
|
const client = await (0, viem_1.createPublicClient)({
|
|
89
|
-
transport: (0, viem_1.http)(rpcUrl)
|
|
89
|
+
transport: (0, viem_1.http)(rpcUrl),
|
|
90
90
|
});
|
|
91
|
-
return await constants_1.FACTORY_CONTRACT_INTERFACE.readFromChain(factoryAddress,
|
|
91
|
+
return await constants_1.FACTORY_CONTRACT_INTERFACE.readFromChain(factoryAddress, 'getAddress', [(0, viem_1.keccak256)((0, viem_1.toBytes)(uniqueId))], client);
|
|
92
92
|
}
|
|
93
93
|
/**
|
|
94
94
|
* Get all tokens for a specific chain
|
|
@@ -99,13 +99,15 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
99
99
|
async getTokens(chainIdInput, onlyVerifiedTokens = false) {
|
|
100
100
|
let chainId;
|
|
101
101
|
if (!chainIdInput) {
|
|
102
|
-
const chain = await data_1.Chain.getChain({
|
|
102
|
+
const chain = await data_1.Chain.getChain({
|
|
103
|
+
chainIdentifier: globalThis.globalEnvOption.chain,
|
|
104
|
+
});
|
|
103
105
|
chainId = await chain.getChainId();
|
|
104
106
|
}
|
|
105
107
|
else {
|
|
106
108
|
chainId = chainIdInput;
|
|
107
109
|
}
|
|
108
|
-
if (chainId ===
|
|
110
|
+
if (chainId === 'ALL') {
|
|
109
111
|
return await (0, apis_1.getAllTokens)(await this.getAddress(), onlyVerifiedTokens);
|
|
110
112
|
}
|
|
111
113
|
else {
|
|
@@ -120,13 +122,15 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
120
122
|
async getNFTs(chainIdInput) {
|
|
121
123
|
let chainId;
|
|
122
124
|
if (!chainIdInput) {
|
|
123
|
-
const chain = await data_1.Chain.getChain({
|
|
125
|
+
const chain = await data_1.Chain.getChain({
|
|
126
|
+
chainIdentifier: globalThis.globalEnvOption.chain,
|
|
127
|
+
});
|
|
124
128
|
chainId = await chain.getChainId();
|
|
125
129
|
}
|
|
126
130
|
else {
|
|
127
131
|
chainId = chainIdInput;
|
|
128
132
|
}
|
|
129
|
-
if (chainId ===
|
|
133
|
+
if (chainId === 'ALL') {
|
|
130
134
|
return await (0, apis_1.getAllNFTs)(await this.getAddress());
|
|
131
135
|
}
|
|
132
136
|
else {
|
|
@@ -143,20 +147,25 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
143
147
|
async getAssets(chainIdInput, onlyVerifiedTokens = false, checkStatus = false) {
|
|
144
148
|
let chainId;
|
|
145
149
|
if (!chainIdInput) {
|
|
146
|
-
const chain = await data_1.Chain.getChain({
|
|
150
|
+
const chain = await data_1.Chain.getChain({
|
|
151
|
+
chainIdentifier: globalThis.globalEnvOption.chain,
|
|
152
|
+
});
|
|
147
153
|
chainId = await chain.getChainId();
|
|
148
154
|
}
|
|
149
155
|
else {
|
|
150
156
|
chainId = chainIdInput;
|
|
151
157
|
}
|
|
152
158
|
let tokens = {}, nfts = {}, lidoWithdrawals = {};
|
|
153
|
-
if (chainId ===
|
|
159
|
+
if (chainId === 'ALL') {
|
|
154
160
|
tokens = await (0, apis_1.getAllTokens)(await this.getAddress(), onlyVerifiedTokens);
|
|
155
161
|
nfts = await (0, apis_1.getAllNFTs)(await this.getAddress());
|
|
156
162
|
if (checkStatus) {
|
|
157
|
-
const ethMainnetLidoWithdrawals = await (0, apis_1.getLidoWithdrawals)(
|
|
158
|
-
const goerliLidoWithdrawals = await (0, apis_1.getLidoWithdrawals)(
|
|
159
|
-
lidoWithdrawals = {
|
|
163
|
+
const ethMainnetLidoWithdrawals = await (0, apis_1.getLidoWithdrawals)('1', await this.getAddress());
|
|
164
|
+
const goerliLidoWithdrawals = await (0, apis_1.getLidoWithdrawals)('5', await this.getAddress());
|
|
165
|
+
lidoWithdrawals = {
|
|
166
|
+
...ethMainnetLidoWithdrawals,
|
|
167
|
+
...goerliLidoWithdrawals,
|
|
168
|
+
};
|
|
160
169
|
}
|
|
161
170
|
}
|
|
162
171
|
else {
|
|
@@ -178,11 +187,11 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
178
187
|
*/
|
|
179
188
|
async getNonce(sender, key = (0, utils_1.generateRandomNonceKey)(), txOptions = globalThis.globalEnvOption) {
|
|
180
189
|
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
181
|
-
const entryPointAddress = await chain.getAddress(
|
|
190
|
+
const entryPointAddress = await chain.getAddress('entryPointAddress');
|
|
182
191
|
let nonce = undefined;
|
|
183
192
|
let retryCount = 3;
|
|
184
193
|
while ((nonce === undefined || nonce === null) && retryCount > 0) {
|
|
185
|
-
nonce = await common_1.ENTRYPOINT_CONTRACT_INTERFACE.readFromChain(entryPointAddress,
|
|
194
|
+
nonce = await common_1.ENTRYPOINT_CONTRACT_INTERFACE.readFromChain(entryPointAddress, 'getNonce', [sender, key], chain);
|
|
186
195
|
retryCount--;
|
|
187
196
|
}
|
|
188
197
|
if (nonce !== undefined && nonce !== null) {
|
|
@@ -244,8 +253,8 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
244
253
|
userId: group.groupId,
|
|
245
254
|
groupInfo: {
|
|
246
255
|
threshold: group.threshold,
|
|
247
|
-
memberIds: group.memberIds
|
|
248
|
-
}
|
|
256
|
+
memberIds: group.memberIds,
|
|
257
|
+
},
|
|
249
258
|
});
|
|
250
259
|
});
|
|
251
260
|
}
|
|
@@ -268,7 +277,11 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
268
277
|
* @returns {Promise<Operation>} The operation to create the wallet.
|
|
269
278
|
*/
|
|
270
279
|
async create(auth, userId, txOptions = globalThis.globalEnvOption) {
|
|
271
|
-
const transactionParams = {
|
|
280
|
+
const transactionParams = {
|
|
281
|
+
to: await this.getAddress(),
|
|
282
|
+
data: '0x',
|
|
283
|
+
value: 0n,
|
|
284
|
+
};
|
|
272
285
|
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
273
286
|
}
|
|
274
287
|
/**
|
|
@@ -322,17 +335,19 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
322
335
|
* @returns {Promise<Operation>} The created and prepared operation.
|
|
323
336
|
*/
|
|
324
337
|
async createOperation(auth, userId, transactionParams, txOptions = globalThis.globalEnvOption) {
|
|
325
|
-
if (!userId || userId ===
|
|
326
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter,
|
|
338
|
+
if (!userId || userId === '') {
|
|
339
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter, 'userId is required', { userId }, 'Provide userId when createOperation', 'https://docs.fun.xyz/how-to-guides/execute-transactions#execute-transactions');
|
|
327
340
|
}
|
|
328
341
|
userId = (0, viem_1.pad)(userId, { size: 32 }).toLowerCase();
|
|
329
342
|
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
330
343
|
const sender = await this.getAddress();
|
|
331
|
-
const initCode = (await chain.addressIsContract(sender))
|
|
332
|
-
|
|
344
|
+
const initCode = (await chain.addressIsContract(sender))
|
|
345
|
+
? '0x'
|
|
346
|
+
: await this.getThisInitCode(chain);
|
|
347
|
+
let paymasterAndData = '0x';
|
|
333
348
|
let maxFeePerGas, maxPriorityFeePerGas;
|
|
334
349
|
const chainId = await chain.getChainId();
|
|
335
|
-
const OPStackChains = [
|
|
350
|
+
const OPStackChains = ['10', '8453'];
|
|
336
351
|
if (OPStackChains.includes(chainId)) {
|
|
337
352
|
const gasPrice = await chain.getFeeData();
|
|
338
353
|
maxFeePerGas = gasPrice.maxFeePerGas;
|
|
@@ -349,22 +364,26 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
349
364
|
maxFeePerGas,
|
|
350
365
|
maxPriorityFeePerGas,
|
|
351
366
|
initCode,
|
|
352
|
-
nonce: txOptions.nonce !== null && txOptions.nonce !== undefined
|
|
367
|
+
nonce: txOptions.nonce !== null && txOptions.nonce !== undefined
|
|
368
|
+
? txOptions.nonce
|
|
369
|
+
: await this.getNonce(sender),
|
|
353
370
|
preVerificationGas: 100000n,
|
|
354
371
|
callGasLimit: BigInt(10e6),
|
|
355
|
-
verificationGasLimit: BigInt(10e6)
|
|
372
|
+
verificationGasLimit: BigInt(10e6),
|
|
356
373
|
};
|
|
357
|
-
if ((await chain.getChainId()) ===
|
|
374
|
+
if ((await chain.getChainId()) === '36865') {
|
|
358
375
|
partialOp.callGasLimit = BigInt(10e5);
|
|
359
376
|
partialOp.verificationGasLimit = BigInt(10e5);
|
|
360
377
|
}
|
|
361
378
|
const isGroupOp = (await auth.getUserId()) !== userId;
|
|
362
379
|
const operation = new data_1.Operation(partialOp, {
|
|
363
380
|
chainId: await chain.getChainId(),
|
|
364
|
-
opType: isGroupOp
|
|
381
|
+
opType: isGroupOp
|
|
382
|
+
? data_1.OperationType.GROUP_OPERATION
|
|
383
|
+
: data_1.OperationType.SINGLE_OPERATION,
|
|
365
384
|
authType: isGroupOp ? data_1.AuthType.MULTI_SIG : data_1.AuthType.ECDSA,
|
|
366
385
|
walletAddr: await this.getAddress(),
|
|
367
|
-
proposer: await auth.getAddress()
|
|
386
|
+
proposer: await auth.getAddress(),
|
|
368
387
|
});
|
|
369
388
|
if (isGroupOp) {
|
|
370
389
|
operation.groupId = (0, viem_1.pad)(userId, { size: 32 });
|
|
@@ -379,6 +398,10 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
379
398
|
paymasterAndData = (await sponsor.getPaymasterAndData(txOptions)).toLowerCase();
|
|
380
399
|
}
|
|
381
400
|
}
|
|
401
|
+
else if (txOptions.gasSponsor.useCheckoutSponsor) {
|
|
402
|
+
const sponsor = new sponsors_1.CheckoutSponsor(txOptions);
|
|
403
|
+
paymasterAndData = (await sponsor.getPaymasterAndData(txOptions)).toLowerCase();
|
|
404
|
+
}
|
|
382
405
|
else {
|
|
383
406
|
const sponsor = new sponsors_1.GaslessSponsor(txOptions);
|
|
384
407
|
paymasterAndData = (await sponsor.getPaymasterAndData(txOptions)).toLowerCase();
|
|
@@ -386,6 +409,9 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
386
409
|
}
|
|
387
410
|
operation.userOp.paymasterAndData = paymasterAndData;
|
|
388
411
|
const estimatedOperation = await this.estimateOperation(auth, userId, operation, txOptions);
|
|
412
|
+
if (txOptions.bypassInit) {
|
|
413
|
+
estimatedOperation.userOp.initCode = '0x';
|
|
414
|
+
}
|
|
389
415
|
// sign the userOp directly here as we do not have the opId yet
|
|
390
416
|
estimatedOperation.userOp.signature = await auth.signOp(estimatedOperation, chain, (0, utils_1.isGroupOperation)(operation));
|
|
391
417
|
if (txOptions.skipDBAction !== true) {
|
|
@@ -435,15 +461,15 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
435
461
|
userId: operation.groupId,
|
|
436
462
|
groupInfo: {
|
|
437
463
|
threshold: groups[0].threshold,
|
|
438
|
-
memberIds: groups[0].memberIds
|
|
439
|
-
}
|
|
464
|
+
memberIds: groups[0].memberIds,
|
|
465
|
+
},
|
|
440
466
|
});
|
|
441
467
|
}
|
|
442
468
|
}
|
|
443
469
|
}
|
|
444
470
|
const threshold = this.userInfo?.get(operation.groupId)?.groupInfo?.threshold ?? 1;
|
|
445
471
|
if (threshold <= 1) {
|
|
446
|
-
if (!operation.userOp.signature || operation.userOp.signature ===
|
|
472
|
+
if (!operation.userOp.signature || operation.userOp.signature === '0x') {
|
|
447
473
|
operation.userOp.signature = await auth.signOp(operation, chain, (0, utils_1.isGroupOperation)(operation));
|
|
448
474
|
}
|
|
449
475
|
}
|
|
@@ -453,7 +479,9 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
453
479
|
const storedOps = await (0, OperationApis_1.getOps)([operation.opId], chainId);
|
|
454
480
|
let collectedSigCount;
|
|
455
481
|
if ((0, utils_1.isSignatureMissing)(await auth.getUserId(), storedOps[0]?.signatures)) {
|
|
456
|
-
collectedSigCount = storedOps[0]?.signatures?.length
|
|
482
|
+
collectedSigCount = storedOps[0]?.signatures?.length
|
|
483
|
+
? storedOps[0]?.signatures?.length + 1
|
|
484
|
+
: 1;
|
|
457
485
|
if (collectedSigCount >= threshold) {
|
|
458
486
|
operation.userOp.signature = await auth.signOp(operation, chain, (0, utils_1.isGroupOperation)(operation));
|
|
459
487
|
}
|
|
@@ -462,11 +490,11 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
462
490
|
collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
|
|
463
491
|
}
|
|
464
492
|
if (collectedSigCount < threshold) {
|
|
465
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures,
|
|
493
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures, 'Signatures are not sufficient to execute the operation', { threshold, collectedSigCount, chainId }, 'Only execute operation with enough signatures', 'https://docs.fun.xyz/how-to-guides/execute-transactions#execute-transactions');
|
|
466
494
|
}
|
|
467
495
|
}
|
|
468
496
|
else {
|
|
469
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures,
|
|
497
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures, 'Signatures are not sufficient to execute the operation', { threshold, chainId, skipDBAction: txOptions.skipDBAction }, 'Only execute operation with enough signatures', 'https://docs.fun.xyz/how-to-guides/execute-transactions#execute-transactions');
|
|
470
498
|
}
|
|
471
499
|
}
|
|
472
500
|
let receipt;
|
|
@@ -475,9 +503,9 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
475
503
|
opId: operation.opId,
|
|
476
504
|
chainId,
|
|
477
505
|
executedBy: await auth.getAddress(),
|
|
478
|
-
entryPointAddress: await chain.getAddress(
|
|
506
|
+
entryPointAddress: await chain.getAddress('entryPointAddress'),
|
|
479
507
|
signature: operation.userOp.signature,
|
|
480
|
-
groupInfo: this.userInfo?.get(operation.groupId)?.groupInfo
|
|
508
|
+
groupInfo: this.userInfo?.get(operation.groupId)?.groupInfo,
|
|
481
509
|
});
|
|
482
510
|
}
|
|
483
511
|
else {
|
|
@@ -485,9 +513,9 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
485
513
|
opId: operation.opId,
|
|
486
514
|
chainId,
|
|
487
515
|
executedBy: await auth.getAddress(),
|
|
488
|
-
entryPointAddress: await chain.getAddress(
|
|
516
|
+
entryPointAddress: await chain.getAddress('entryPointAddress'),
|
|
489
517
|
signature: operation.userOp.signature,
|
|
490
|
-
userOp: operation.userOp
|
|
518
|
+
userOp: operation.userOp,
|
|
491
519
|
});
|
|
492
520
|
}
|
|
493
521
|
receipt = await (0, OperationApis_1.getFullReceipt)(operation.opId, chainId, receipt.userOpHash);
|
|
@@ -496,12 +524,12 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
496
524
|
if (txOptions?.gasSponsor?.sponsorAddress) {
|
|
497
525
|
const paymasterType = (0, PaymasterUtils_1.getPaymasterType)(txOptions);
|
|
498
526
|
(0, PaymasterApis_1.addTransaction)(await chain.getChainId(), Date.now(), receipt.txId, {
|
|
499
|
-
action:
|
|
500
|
-
amount: -1,
|
|
527
|
+
action: 'sponsor',
|
|
528
|
+
amount: -1, //Get amount from lazy processing
|
|
501
529
|
from: txOptions.gasSponsor.sponsorAddress,
|
|
502
530
|
to: await this.getAddress(),
|
|
503
|
-
token:
|
|
504
|
-
txid: receipt.txId
|
|
531
|
+
token: 'eth',
|
|
532
|
+
txid: receipt.txId,
|
|
505
533
|
}, paymasterType, txOptions.gasSponsor.sponsorAddress);
|
|
506
534
|
}
|
|
507
535
|
}
|
|
@@ -529,15 +557,15 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
529
557
|
userId: operation.groupId,
|
|
530
558
|
groupInfo: {
|
|
531
559
|
threshold: groups[0].threshold,
|
|
532
|
-
memberIds: groups[0].memberIds
|
|
533
|
-
}
|
|
560
|
+
memberIds: groups[0].memberIds,
|
|
561
|
+
},
|
|
534
562
|
});
|
|
535
563
|
}
|
|
536
564
|
}
|
|
537
565
|
}
|
|
538
566
|
const threshold = this.userInfo?.get(operation.groupId)?.groupInfo?.threshold ?? 1;
|
|
539
567
|
if (threshold <= 1) {
|
|
540
|
-
if (!operation.userOp.signature || operation.userOp.signature ===
|
|
568
|
+
if (!operation.userOp.signature || operation.userOp.signature === '0x') {
|
|
541
569
|
operation.userOp.signature = await auth.signOp(operation, chain, (0, utils_1.isGroupOperation)(operation));
|
|
542
570
|
}
|
|
543
571
|
}
|
|
@@ -547,7 +575,9 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
547
575
|
const storedOps = await (0, OperationApis_1.getOps)([operation.opId], chainId);
|
|
548
576
|
let collectedSigCount;
|
|
549
577
|
if ((0, utils_1.isSignatureMissing)(await auth.getUserId(), storedOps[0]?.signatures)) {
|
|
550
|
-
collectedSigCount = storedOps[0]?.signatures?.length
|
|
578
|
+
collectedSigCount = storedOps[0]?.signatures?.length
|
|
579
|
+
? storedOps[0]?.signatures?.length + 1
|
|
580
|
+
: 1;
|
|
551
581
|
if (collectedSigCount >= threshold) {
|
|
552
582
|
operation.userOp.signature = await auth.signOp(operation, chain, (0, utils_1.isGroupOperation)(operation));
|
|
553
583
|
}
|
|
@@ -556,11 +586,11 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
556
586
|
collectedSigCount = storedOps[0]?.signatures?.length ?? 1;
|
|
557
587
|
}
|
|
558
588
|
if (collectedSigCount < threshold) {
|
|
559
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures,
|
|
589
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures, 'Signatures are not sufficient to execute the operation', { threshold, collectedSigCount, chainId }, 'Only execute operation with enough signatures', 'https://docs.fun.xyz/how-to-guides/execute-transactions#execute-transactions');
|
|
560
590
|
}
|
|
561
591
|
}
|
|
562
592
|
else {
|
|
563
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures,
|
|
593
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InsufficientSignatures, 'Signatures are not sufficient to execute the operation', { threshold, chainId, skipDBAction: txOptions.skipDBAction }, 'Only execute operation with enough signatures', 'https://docs.fun.xyz/how-to-guides/execute-transactions#execute-transactions');
|
|
564
594
|
}
|
|
565
595
|
}
|
|
566
596
|
if ((0, utils_1.isGroupOperation)(operation)) {
|
|
@@ -568,9 +598,9 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
568
598
|
opId: operation.opId,
|
|
569
599
|
chainId,
|
|
570
600
|
scheduledBy: await auth.getAddress(),
|
|
571
|
-
entryPointAddress: await chain.getAddress(
|
|
601
|
+
entryPointAddress: await chain.getAddress('entryPointAddress'),
|
|
572
602
|
signature: operation.userOp.signature,
|
|
573
|
-
groupInfo: this.userInfo?.get(operation.groupId)?.groupInfo
|
|
603
|
+
groupInfo: this.userInfo?.get(operation.groupId)?.groupInfo,
|
|
574
604
|
});
|
|
575
605
|
}
|
|
576
606
|
else {
|
|
@@ -578,13 +608,13 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
578
608
|
opId: operation.opId,
|
|
579
609
|
chainId,
|
|
580
610
|
scheduledBy: await auth.getAddress(),
|
|
581
|
-
entryPointAddress: await chain.getAddress(
|
|
611
|
+
entryPointAddress: await chain.getAddress('entryPointAddress'),
|
|
582
612
|
signature: operation.userOp.signature,
|
|
583
|
-
userOp: operation.userOp
|
|
613
|
+
userOp: operation.userOp,
|
|
584
614
|
});
|
|
585
615
|
}
|
|
586
616
|
if (!operation.opId) {
|
|
587
|
-
throw new errors_1.InternalFailureError(errors_1.ErrorCode.ServerFailure,
|
|
617
|
+
throw new errors_1.InternalFailureError(errors_1.ErrorCode.ServerFailure, 'Operation id is required', operation, 'Make sure you are scheduling a valid operation', 'https://docs.fun.xyz/');
|
|
588
618
|
}
|
|
589
619
|
return operation.opId;
|
|
590
620
|
}
|
|
@@ -609,7 +639,11 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
609
639
|
* @returns {Promise<Operation>} The prepared rejection operation.
|
|
610
640
|
*/
|
|
611
641
|
async createRejectOperation(auth, groupId, operation, rejectionMessage, txOptions = globalThis.globalEnvOption) {
|
|
612
|
-
const rejectOperation = await this.transfer(auth, groupId, { to: await this.getAddress(), amount: 0, token:
|
|
642
|
+
const rejectOperation = await this.transfer(auth, groupId, { to: await this.getAddress(), amount: 0, token: 'eth' }, {
|
|
643
|
+
...txOptions,
|
|
644
|
+
skipDBAction: true,
|
|
645
|
+
nonce: BigInt(operation.userOp.nonce),
|
|
646
|
+
});
|
|
613
647
|
if (rejectionMessage)
|
|
614
648
|
rejectOperation.message = rejectionMessage;
|
|
615
649
|
rejectOperation.relatedOpIds = [operation.opId];
|
|
@@ -632,7 +666,7 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
632
666
|
const res = await chain.estimateOpGas(operation.userOp);
|
|
633
667
|
operation.userOp = {
|
|
634
668
|
...operation.userOp,
|
|
635
|
-
...res
|
|
669
|
+
...res,
|
|
636
670
|
};
|
|
637
671
|
const { maxFeePerGas, maxPriorityFeePerGas } = await chain.getFeeData();
|
|
638
672
|
operation.userOp.maxFeePerGas = maxFeePerGas;
|
|
@@ -641,15 +675,15 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
641
675
|
}
|
|
642
676
|
async getThisInitCode(chain) {
|
|
643
677
|
const owners = Array.from(this.userInfo.keys());
|
|
644
|
-
const entryPointAddress = await chain.getAddress(
|
|
645
|
-
const factoryAddress = await chain.getAddress(
|
|
646
|
-
const rbac = await chain.getAddress(
|
|
647
|
-
const userAuth = await chain.getAddress(
|
|
678
|
+
const entryPointAddress = await chain.getAddress('entryPointAddress');
|
|
679
|
+
const factoryAddress = await chain.getAddress('factoryAddress');
|
|
680
|
+
const rbac = await chain.getAddress('rbacAddress');
|
|
681
|
+
const userAuth = await chain.getAddress('userAuthAddress');
|
|
648
682
|
const loginData = {
|
|
649
|
-
salt: this.walletUniqueId
|
|
683
|
+
salt: this.walletUniqueId,
|
|
650
684
|
};
|
|
651
685
|
const rbacInitData = (0, data_1.toBytes32Arr)(owners);
|
|
652
|
-
let userAuthInitData =
|
|
686
|
+
let userAuthInitData = '0x';
|
|
653
687
|
const groupUsers = Array.from(this.userInfo.values()).filter((user) => user.groupInfo !== null && user.groupInfo !== undefined);
|
|
654
688
|
if (groupUsers.length > 0) {
|
|
655
689
|
userAuthInitData = (0, data_1.encodeUserAuthInitData)(groupUsers);
|
|
@@ -658,28 +692,28 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
658
692
|
entryPointAddress,
|
|
659
693
|
factoryAddress,
|
|
660
694
|
implementationAddress: constants_1.AddressZero,
|
|
661
|
-
loginData
|
|
695
|
+
loginData,
|
|
662
696
|
verificationAddresses: [rbac, userAuth],
|
|
663
|
-
verificationData: [rbacInitData, userAuthInitData]
|
|
697
|
+
verificationData: [rbacInitData, userAuthInitData],
|
|
664
698
|
};
|
|
665
699
|
return this.getInitCode(initCodeParams);
|
|
666
700
|
}
|
|
667
701
|
getInitCode(input) {
|
|
668
702
|
const encodedVerificationInitdata = (0, viem_1.encodeAbiParameters)([
|
|
669
703
|
{
|
|
670
|
-
type:
|
|
671
|
-
name:
|
|
704
|
+
type: 'address[]',
|
|
705
|
+
name: 'verificationAddresses',
|
|
672
706
|
},
|
|
673
707
|
{
|
|
674
|
-
type:
|
|
675
|
-
name:
|
|
676
|
-
}
|
|
708
|
+
type: 'bytes[]',
|
|
709
|
+
name: 'verificationData',
|
|
710
|
+
},
|
|
677
711
|
], [input.verificationAddresses, input.verificationData]);
|
|
678
|
-
const initializerCallData = common_1.WALLET_CONTRACT_INTERFACE.encodeData(
|
|
679
|
-
|
|
680
|
-
|
|
712
|
+
const initializerCallData = common_1.WALLET_CONTRACT_INTERFACE.encodeData('initialize', [input.entryPointAddress, encodedVerificationInitdata]);
|
|
713
|
+
const data = constants_1.FACTORY_CONTRACT_INTERFACE.encodeData('createAccount', [
|
|
714
|
+
initializerCallData,
|
|
715
|
+
(0, data_1.encodeLoginData)(input.loginData),
|
|
681
716
|
]);
|
|
682
|
-
const data = constants_1.FACTORY_CONTRACT_INTERFACE.encodeData("createAccount", [initializerCallData, (0, data_1.encodeLoginData)(input.loginData)]);
|
|
683
717
|
return (0, viem_1.concat)([input.factoryAddress, data]);
|
|
684
718
|
}
|
|
685
719
|
/**
|
|
@@ -693,19 +727,21 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
693
727
|
params.value = 0n;
|
|
694
728
|
}
|
|
695
729
|
if (options.fee) {
|
|
696
|
-
if (!options.fee.token &&
|
|
730
|
+
if (!options.fee.token &&
|
|
731
|
+
options.gasSponsor &&
|
|
732
|
+
options.gasSponsor.token) {
|
|
697
733
|
options.fee.token = options.gasSponsor.token;
|
|
698
734
|
}
|
|
699
735
|
if (!options.fee.token) {
|
|
700
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter,
|
|
736
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter, 'EnvOption.fee.token or EnvOption.gasSponsor.token is required', { options }, 'Provide EnvOption.fee.token or EnvOption.gasSponsor.token when calling wallet.createOperation', 'https://docs.fun.xyz/how-to-guides/execute-transactions#execute-transactions');
|
|
701
737
|
}
|
|
702
738
|
if (!options.fee.recipient) {
|
|
703
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter,
|
|
739
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter, 'EnvOption.fee.recipient is required', { options }, 'Provide EnvOption.fee.recipient when calling wallet.createOperation', 'https://docs.fun.xyz/how-to-guides/execute-transactions#execute-transactions');
|
|
704
740
|
}
|
|
705
741
|
const chain = await data_1.Chain.getChain({ chainIdentifier: options.chain });
|
|
706
742
|
const token = new data_1.Token(options.fee.token, chain);
|
|
707
743
|
if (options.fee.gasPercent && !token.isNative) {
|
|
708
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameterCombination,
|
|
744
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameterCombination, 'GasPercent is only valid for native tokens', { options }, 'Use native token as the fee token if you want to charge fee based on percentage', 'https://docs.fun.xyz/how-to-guides/configure-environment/set-developer-fee');
|
|
709
745
|
}
|
|
710
746
|
if (token.isNative) {
|
|
711
747
|
options.fee.token = constants_1.AddressZero;
|
|
@@ -718,24 +754,32 @@ class FunWallet extends FirstClassActions_1.FirstClassActions {
|
|
|
718
754
|
}
|
|
719
755
|
else if (options.fee.gasPercent) {
|
|
720
756
|
const feedata = [options.fee.token, options.fee.recipient, 1];
|
|
721
|
-
const estimateGasCalldata = common_1.WALLET_CONTRACT_INTERFACE.encodeData(
|
|
722
|
-
params.to,
|
|
723
|
-
params.value,
|
|
724
|
-
params.data,
|
|
725
|
-
feedata
|
|
726
|
-
]);
|
|
757
|
+
const estimateGasCalldata = common_1.WALLET_CONTRACT_INTERFACE.encodeData('execFromEntryPointWithFee', [params.to, params.value, params.data, feedata]);
|
|
727
758
|
const operation = await this.createOperation(auth, userId, { to: params.to, value: params.value, data: estimateGasCalldata }, { ...options, fee: undefined });
|
|
728
759
|
const gasUsed = await operation.getMaxTxCost();
|
|
729
760
|
options.fee.amount = Math.ceil((Number(gasUsed) * options.fee.gasPercent) / 100);
|
|
730
761
|
}
|
|
731
762
|
else {
|
|
732
|
-
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter,
|
|
763
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.MissingParameter, 'EnvOption.fee.amount or EnvOption.fee.gasPercent is required', { options }, 'Provide either EnvOption.fee.amount or EnvOption.fee.gasPercent when calling wallet.createOperation', 'https://docs.fun.xyz/how-to-guides/configure-environment/set-developer-fee');
|
|
733
764
|
}
|
|
734
|
-
const feedata = [
|
|
735
|
-
|
|
765
|
+
const feedata = [
|
|
766
|
+
options.fee.token,
|
|
767
|
+
options.fee.recipient,
|
|
768
|
+
options.fee.amount,
|
|
769
|
+
];
|
|
770
|
+
return common_1.WALLET_CONTRACT_INTERFACE.encodeData('execFromEntryPointWithFee', [
|
|
771
|
+
params.to,
|
|
772
|
+
params.value,
|
|
773
|
+
params.data,
|
|
774
|
+
feedata,
|
|
775
|
+
]);
|
|
736
776
|
}
|
|
737
777
|
else {
|
|
738
|
-
return common_1.WALLET_CONTRACT_INTERFACE.encodeData(
|
|
778
|
+
return common_1.WALLET_CONTRACT_INTERFACE.encodeData('execFromEntryPoint', [
|
|
779
|
+
params.to,
|
|
780
|
+
params.value,
|
|
781
|
+
params.data,
|
|
782
|
+
]);
|
|
739
783
|
}
|
|
740
784
|
}
|
|
741
785
|
}
|