@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,161 @@
|
|
|
1
|
+
import { Address } from "viem";
|
|
2
|
+
import { AddOwnerParams, AddUserToGroupParams, ApproveParams, CreateGroupParams, FinishUnstakeParams, LimitOrderParam, RemoveGroupParams, RemoveOwnerParams, RemoveUserFromGroupParams, RequestUnstakeParams, SessionKeyParams, StakeParams, SwapParams, TransferParams, UpdateThresholdOfGroupParams } from "./types";
|
|
3
|
+
import { Auth } from "../auth";
|
|
4
|
+
import { TransactionParams } from "../common";
|
|
5
|
+
import { EnvOption } from "../config";
|
|
6
|
+
import { Operation } from "../data";
|
|
7
|
+
export declare abstract class FirstClassActions {
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new operation to be associated with the wallet and prepares it for execution.
|
|
10
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
11
|
+
* @param {string} userId - The ID of the user initiating the operation.
|
|
12
|
+
* @param {TransactionParams} transactionParams - The parameters for the transaction.
|
|
13
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
14
|
+
* @returns {Promise<Operation>} The created and prepared operation.
|
|
15
|
+
*/
|
|
16
|
+
abstract createOperation(auth: Auth, userId: string, transactionParams: TransactionParams, txOptions: EnvOption): Promise<Operation>;
|
|
17
|
+
/**
|
|
18
|
+
* Retrieves the wallet address associated with this FunWallet. The address should be the same for all EVM chains so no input is needed
|
|
19
|
+
* If the address is not already cached, it fetches it using the wallet's unique ID and chain information.
|
|
20
|
+
* @returns {Promise<Address>} The wallet address.
|
|
21
|
+
*/
|
|
22
|
+
abstract getAddress(): Promise<Address>;
|
|
23
|
+
/**
|
|
24
|
+
* Initiates a swap operation and returns the prepared operation for execution.
|
|
25
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
26
|
+
* @param {string} userId - The ID of the user initiating the swap.
|
|
27
|
+
* @param {SwapParams} params - The parameters for the swap operation.
|
|
28
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
29
|
+
* @returns {Promise<Operation>} The prepared swap operation.
|
|
30
|
+
*/
|
|
31
|
+
swap(auth: Auth, userId: string, params: SwapParams, txOptions?: EnvOption): Promise<Operation>;
|
|
32
|
+
/**
|
|
33
|
+
* Initiates a limit swap order operation and returns the prepared operation for execution.
|
|
34
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
35
|
+
* @param {string} userId - The ID of the user initiating the limit swap order.
|
|
36
|
+
* @param {LimitOrderParam} params - The parameters for the limit swap order.
|
|
37
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
38
|
+
* @returns {Promise<Operation>} The prepared limit swap order operation.
|
|
39
|
+
*/
|
|
40
|
+
limitSwapOrder(auth: Auth, userId: string, params: LimitOrderParam, txOptions?: EnvOption): Promise<Operation>;
|
|
41
|
+
/**
|
|
42
|
+
* Initiates a transfer operation and returns the prepared operation for execution.
|
|
43
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
44
|
+
* @param {string} userId - The ID of the user initiating the transfer.
|
|
45
|
+
* @param {TransferParams} params - The parameters for the transfer.
|
|
46
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
47
|
+
* @returns {Promise<Operation>} The prepared transfer operation.
|
|
48
|
+
* @throws {InvalidParameterError} When provided parameters are missing or incorrect.
|
|
49
|
+
*/
|
|
50
|
+
transfer(auth: Auth, userId: string, params: TransferParams, txOptions?: EnvOption): Promise<Operation>;
|
|
51
|
+
/**
|
|
52
|
+
* Initiates a erc20/erc721 token approval operation and returns the prepared operation for execution.
|
|
53
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
54
|
+
* @param {string} userId - The ID of the user initiating the token approval.
|
|
55
|
+
* @param {ApproveParams} params - The parameters for the token approval.
|
|
56
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
57
|
+
* @returns {Promise<Operation>} The prepared token approval operation.
|
|
58
|
+
* @throws {InvalidParameterError} When provided parameters are missing or incorrect.
|
|
59
|
+
*/
|
|
60
|
+
tokenApprove(auth: Auth, userId: string, params: ApproveParams, txOptions?: EnvOption): Promise<Operation>;
|
|
61
|
+
/**
|
|
62
|
+
* Initiates a stake operation and returns the prepared operation for execution.
|
|
63
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
64
|
+
* @param {string} userId - The ID of the user initiating the stake operation.
|
|
65
|
+
* @param {StakeParams} params - The parameters for the stake operation.
|
|
66
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
67
|
+
* @returns {Promise<Operation>} The prepared stake operation.
|
|
68
|
+
*/
|
|
69
|
+
stake(auth: Auth, userId: string, params: StakeParams, txOptions?: EnvOption): Promise<Operation>;
|
|
70
|
+
/**
|
|
71
|
+
* Initiates an unstake operation and returns the prepared operation for execution.
|
|
72
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
73
|
+
* @param {string} userId - The ID of the user initiating the unstake operation.
|
|
74
|
+
* @param {RequestUnstakeParams | FinishUnstakeParams} params - The parameters for the unstake operation.
|
|
75
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
76
|
+
* @returns {Promise<Operation>} The prepared unstake operation.
|
|
77
|
+
* @throws {InvalidParameterError} When provided parameters are missing or incorrect.
|
|
78
|
+
*/
|
|
79
|
+
unstake(auth: Auth, userId: string, params: RequestUnstakeParams | FinishUnstakeParams, txOptions?: EnvOption): Promise<Operation>;
|
|
80
|
+
/**
|
|
81
|
+
* Initiates a session key creation operation and returns the prepared operation for execution.
|
|
82
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
83
|
+
* @param {string} userId - The ID of the user initiating the session key creation.
|
|
84
|
+
* @param {SessionKeyParams} params - The parameters for the session key creation.
|
|
85
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
86
|
+
* @returns {Promise<Operation>} The prepared session key creation operation.
|
|
87
|
+
*/
|
|
88
|
+
createSessionKey(auth: Auth, userId: string, params: SessionKeyParams, txOptions?: EnvOption): Promise<Operation>;
|
|
89
|
+
/**
|
|
90
|
+
* Initiates an add owner operation and returns the prepared operation for execution.
|
|
91
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
92
|
+
* @param {string} userId - The ID of the user initiating the add owner operation.
|
|
93
|
+
* @param {AddOwnerParams} params - The parameters for the add owner operation.
|
|
94
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
95
|
+
* @returns {Promise<Operation>} The prepared add owner operation.
|
|
96
|
+
*/
|
|
97
|
+
addOwner(auth: Auth, userId: string, params: AddOwnerParams, txOptions?: EnvOption): Promise<Operation>;
|
|
98
|
+
/**
|
|
99
|
+
* Initiates a remove owner operation and returns the prepared operation for execution.
|
|
100
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
101
|
+
* @param {string} userId - The ID of the user initiating the remove owner operation.
|
|
102
|
+
* @param {RemoveOwnerParams} params - The parameters for the remove owner operation.
|
|
103
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
104
|
+
* @returns {Promise<Operation>} The prepared remove owner operation.
|
|
105
|
+
*/
|
|
106
|
+
removeOwner(auth: Auth, userId: string, params: RemoveOwnerParams, txOptions?: EnvOption): Promise<Operation>;
|
|
107
|
+
/**
|
|
108
|
+
* Initiates a create group operation and returns the prepared operation for execution.
|
|
109
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
110
|
+
* @param {string} userId - The ID of the user initiating the create group operation.
|
|
111
|
+
* @param {CreateGroupParams} params - The parameters for the create group operation.
|
|
112
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
113
|
+
* @returns {Promise<Operation>} The prepared create group operation.
|
|
114
|
+
*/
|
|
115
|
+
createGroup(auth: Auth, userId: string, params: CreateGroupParams, txOptions?: EnvOption): Promise<Operation>;
|
|
116
|
+
/**
|
|
117
|
+
* Initiates an add user to group operation and returns the prepared operation for execution.
|
|
118
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
119
|
+
* @param {string} userId - The ID of the user initiating the add user to group operation.
|
|
120
|
+
* @param {AddUserToGroupParams} params - The parameters for the add user to group operation.
|
|
121
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
122
|
+
* @returns {Promise<Operation>} The prepared add user to group operation.
|
|
123
|
+
*/
|
|
124
|
+
addUserToGroup(auth: Auth, userId: string, params: AddUserToGroupParams, txOptions?: EnvOption): Promise<Operation>;
|
|
125
|
+
/**
|
|
126
|
+
* Initiates a remove user from group operation and returns the prepared operation for execution.
|
|
127
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
128
|
+
* @param {string} userId - The ID of the user initiating the remove user from group operation.
|
|
129
|
+
* @param {RemoveUserFromGroupParams} params - The parameters for the remove user from group operation.
|
|
130
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
131
|
+
* @returns {Promise<Operation>} The prepared remove user from group operation.
|
|
132
|
+
*/
|
|
133
|
+
removeUserFromGroup(auth: Auth, userId: string, params: RemoveUserFromGroupParams, txOptions?: EnvOption): Promise<Operation>;
|
|
134
|
+
/**
|
|
135
|
+
* Initiates an update threshold of group operation and returns the prepared operation for execution.
|
|
136
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
137
|
+
* @param {string} userId - The ID of the user initiating the update threshold of group operation.
|
|
138
|
+
* @param {UpdateThresholdOfGroupParams} params - The parameters for the update threshold of group operation.
|
|
139
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
140
|
+
* @returns {Promise<Operation>} The prepared update threshold of group operation.
|
|
141
|
+
*/
|
|
142
|
+
updateThresholdOfGroup(auth: Auth, userId: string, params: UpdateThresholdOfGroupParams, txOptions?: EnvOption): Promise<Operation>;
|
|
143
|
+
/**
|
|
144
|
+
* Initiates a remove group operation and returns the prepared operation for execution.
|
|
145
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
146
|
+
* @param {string} userId - The ID of the user initiating the remove group operation.
|
|
147
|
+
* @param {RemoveGroupParams} params - The parameters for the remove group operation.
|
|
148
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
149
|
+
* @returns {Promise<Operation>} The prepared remove group operation.
|
|
150
|
+
*/
|
|
151
|
+
removeGroup(auth: Auth, userId: string, params: RemoveGroupParams, txOptions?: EnvOption): Promise<Operation>;
|
|
152
|
+
/**
|
|
153
|
+
* Initiates a batch operation and returns the prepared operation for execution.
|
|
154
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
155
|
+
* @param {string} userId - The ID of the user initiating the batch operation.
|
|
156
|
+
* @param {TransactionParams[]} params - An array of transaction parameters for the batch operation.
|
|
157
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
158
|
+
* @returns {Promise<Operation>} The prepared batch operation.
|
|
159
|
+
*/
|
|
160
|
+
createBatchOperation(auth: Auth, userId: string, params: TransactionParams[], txOptions?: EnvOption): Promise<Operation>;
|
|
161
|
+
}
|
|
@@ -0,0 +1,347 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FirstClassActions = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const AccessControl_1 = require("./AccessControl");
|
|
6
|
+
const BatchActions_1 = require("./BatchActions");
|
|
7
|
+
const Group_1 = require("./Group");
|
|
8
|
+
const LimitOrder_1 = require("./LimitOrder");
|
|
9
|
+
const Stake_1 = require("./Stake");
|
|
10
|
+
const Swap_1 = require("./Swap");
|
|
11
|
+
const Token_1 = require("./Token");
|
|
12
|
+
const GroupApis_1 = require("../apis/GroupApis");
|
|
13
|
+
const UserApis_1 = require("../apis/UserApis");
|
|
14
|
+
const data_1 = require("../data");
|
|
15
|
+
const errors_1 = require("../errors");
|
|
16
|
+
const utils_1 = require("../utils");
|
|
17
|
+
class FirstClassActions {
|
|
18
|
+
/**
|
|
19
|
+
* Initiates a swap operation and returns the prepared operation for execution.
|
|
20
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
21
|
+
* @param {string} userId - The ID of the user initiating the swap.
|
|
22
|
+
* @param {SwapParams} params - The parameters for the swap operation.
|
|
23
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
24
|
+
* @returns {Promise<Operation>} The prepared swap operation.
|
|
25
|
+
*/
|
|
26
|
+
async swap(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
27
|
+
if (!params.tokenIn) {
|
|
28
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Missing tokenIn parameter in the swap params object.", { params }, "", "https://docs.fun.xyz");
|
|
29
|
+
}
|
|
30
|
+
if (!params.tokenOut) {
|
|
31
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Missing tokenOut parameter in the swap params object.", { params }, "", "https://docs.fun.xyz");
|
|
32
|
+
}
|
|
33
|
+
if (!params.inAmount) {
|
|
34
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Missing inAmount parameter in the swap params object.", { params }, "", "https://docs.fun.xyz");
|
|
35
|
+
}
|
|
36
|
+
let transactionParams;
|
|
37
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
38
|
+
const chainId = Number(await chain.getChainId());
|
|
39
|
+
params.recipient ?? (params.recipient = await this.getAddress());
|
|
40
|
+
if (Swap_1.oneInchSupported.includes(chainId)) {
|
|
41
|
+
transactionParams = await (0, Swap_1.oneInchTransactionParams)(params, await this.getAddress(), txOptions);
|
|
42
|
+
}
|
|
43
|
+
else if (Swap_1.uniswapV3Supported.includes(chainId)) {
|
|
44
|
+
transactionParams = await (0, Swap_1.uniswapV3SwapTransactionParams)(params, txOptions);
|
|
45
|
+
}
|
|
46
|
+
else if (chainId === 8453) {
|
|
47
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Swap is not supported on Base", { params }, "Use a different chain or a different first class method", "https://docs.fun.xyz");
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
transactionParams = await (0, Swap_1.uniswapV2SwapTransactionParams)(params, txOptions);
|
|
51
|
+
}
|
|
52
|
+
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Initiates a limit swap order operation and returns the prepared operation for execution.
|
|
56
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
57
|
+
* @param {string} userId - The ID of the user initiating the limit swap order.
|
|
58
|
+
* @param {LimitOrderParam} params - The parameters for the limit swap order.
|
|
59
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
60
|
+
* @returns {Promise<Operation>} The prepared limit swap order operation.
|
|
61
|
+
*/
|
|
62
|
+
async limitSwapOrder(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
63
|
+
const transactionParams = await (0, LimitOrder_1.limitSwapOrderTransactionParams)(params, txOptions);
|
|
64
|
+
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Initiates a transfer operation and returns the prepared operation for execution.
|
|
68
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
69
|
+
* @param {string} userId - The ID of the user initiating the transfer.
|
|
70
|
+
* @param {TransferParams} params - The parameters for the transfer.
|
|
71
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
72
|
+
* @returns {Promise<Operation>} The prepared transfer operation.
|
|
73
|
+
* @throws {InvalidParameterError} When provided parameters are missing or incorrect.
|
|
74
|
+
*/
|
|
75
|
+
async transfer(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
76
|
+
let transactionParams;
|
|
77
|
+
if ((0, Token_1.isERC721TransferParams)(params)) {
|
|
78
|
+
params.from = params.from ? params.from : await this.getAddress();
|
|
79
|
+
transactionParams = await (0, Token_1.erc721TransferTransactionParams)(params);
|
|
80
|
+
}
|
|
81
|
+
else if ((0, Token_1.isTokenTransferParams)(params)) {
|
|
82
|
+
if (params.from) {
|
|
83
|
+
transactionParams = await (0, Token_1.tokenTransferFromTransactionParams)(params, txOptions);
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
transactionParams = await (0, Token_1.tokenTransferTransactionParams)(params, txOptions);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
else {
|
|
90
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Params were missing or incorrect", { params }, "Provide correct transfer params.", "https://docs.fun.xyz");
|
|
91
|
+
}
|
|
92
|
+
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Initiates a erc20/erc721 token approval operation and returns the prepared operation for execution.
|
|
96
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
97
|
+
* @param {string} userId - The ID of the user initiating the token approval.
|
|
98
|
+
* @param {ApproveParams} params - The parameters for the token approval.
|
|
99
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
100
|
+
* @returns {Promise<Operation>} The prepared token approval operation.
|
|
101
|
+
* @throws {InvalidParameterError} When provided parameters are missing or incorrect.
|
|
102
|
+
*/
|
|
103
|
+
async tokenApprove(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
104
|
+
let transactionParams;
|
|
105
|
+
if ((0, Token_1.isERC20ApproveParams)(params)) {
|
|
106
|
+
transactionParams = await (0, Token_1.erc20ApproveTransactionParams)(params, txOptions);
|
|
107
|
+
}
|
|
108
|
+
else if ((0, Token_1.isERC721ApproveParams)(params)) {
|
|
109
|
+
transactionParams = await (0, Token_1.erc721ApproveTransactionParams)(params);
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Params were missing or incorrect", { params }, "Provide correct token approve params.", "https://docs.fun.xyz");
|
|
113
|
+
}
|
|
114
|
+
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Initiates a stake operation and returns the prepared operation for execution.
|
|
118
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
119
|
+
* @param {string} userId - The ID of the user initiating the stake operation.
|
|
120
|
+
* @param {StakeParams} params - The parameters for the stake operation.
|
|
121
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
122
|
+
* @returns {Promise<Operation>} The prepared stake operation.
|
|
123
|
+
*/
|
|
124
|
+
async stake(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
125
|
+
const transactionParams = await (0, Stake_1.stakeTransactionParams)(params, txOptions);
|
|
126
|
+
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
127
|
+
}
|
|
128
|
+
/**
|
|
129
|
+
* Initiates an unstake operation and returns the prepared operation for execution.
|
|
130
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
131
|
+
* @param {string} userId - The ID of the user initiating the unstake operation.
|
|
132
|
+
* @param {RequestUnstakeParams | FinishUnstakeParams} params - The parameters for the unstake operation.
|
|
133
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
134
|
+
* @returns {Promise<Operation>} The prepared unstake operation.
|
|
135
|
+
* @throws {InvalidParameterError} When provided parameters are missing or incorrect.
|
|
136
|
+
*/
|
|
137
|
+
async unstake(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
138
|
+
params.recipient ?? (params.recipient = await this.getAddress());
|
|
139
|
+
let transactionParams;
|
|
140
|
+
if ((0, Stake_1.isRequestUnstakeParams)(params)) {
|
|
141
|
+
transactionParams = await (0, Stake_1.requestUnstakeTransactionParams)(params, txOptions);
|
|
142
|
+
}
|
|
143
|
+
else if ((0, Stake_1.isFinishUnstakeParams)(params)) {
|
|
144
|
+
transactionParams = await (0, Stake_1.finishUnstakeTransactionParams)(params, txOptions);
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidParameter, "Params were missing or incorrect", { params }, "Provide correct unstake params.", "https://docs.fun.xyz");
|
|
148
|
+
}
|
|
149
|
+
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Initiates a session key creation operation and returns the prepared operation for execution.
|
|
153
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
154
|
+
* @param {string} userId - The ID of the user initiating the session key creation.
|
|
155
|
+
* @param {SessionKeyParams} params - The parameters for the session key creation.
|
|
156
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
157
|
+
* @returns {Promise<Operation>} The prepared session key creation operation.
|
|
158
|
+
*/
|
|
159
|
+
async createSessionKey(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
160
|
+
const transactionParams = await (0, AccessControl_1.createSessionKeyTransactionParams)(params, txOptions);
|
|
161
|
+
return await this.createOperation(auth, userId, transactionParams, txOptions);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Initiates an add owner operation and returns the prepared operation for execution.
|
|
165
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
166
|
+
* @param {string} userId - The ID of the user initiating the add owner operation.
|
|
167
|
+
* @param {AddOwnerParams} params - The parameters for the add owner operation.
|
|
168
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
169
|
+
* @returns {Promise<Operation>} The prepared add owner operation.
|
|
170
|
+
*/
|
|
171
|
+
async addOwner(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
172
|
+
if ((0, utils_1.isAddress)(params.ownerId)) {
|
|
173
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
174
|
+
const authId = await (0, utils_1.getAuthIdFromAddr)(params.ownerId);
|
|
175
|
+
await (0, UserApis_1.addUserToWallet)(authId, await chain.getChainId(), await this.getAddress(), [(0, viem_1.pad)(params.ownerId, { size: 32 })]);
|
|
176
|
+
}
|
|
177
|
+
const txParams = await (0, AccessControl_1.addOwnerTxParams)(params, txOptions);
|
|
178
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Initiates a remove owner operation and returns the prepared operation for execution.
|
|
182
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
183
|
+
* @param {string} userId - The ID of the user initiating the remove owner operation.
|
|
184
|
+
* @param {RemoveOwnerParams} params - The parameters for the remove owner operation.
|
|
185
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
186
|
+
* @returns {Promise<Operation>} The prepared remove owner operation.
|
|
187
|
+
*/
|
|
188
|
+
async removeOwner(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
189
|
+
if ((0, utils_1.isAddress)(params.ownerId)) {
|
|
190
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
191
|
+
const authId = await (0, utils_1.getAuthIdFromAddr)(params.ownerId);
|
|
192
|
+
await (0, UserApis_1.removeUserWalletIdentity)(authId, await chain.getChainId(), await this.getAddress(), (0, viem_1.pad)(params.ownerId, { size: 32 }));
|
|
193
|
+
}
|
|
194
|
+
const txParams = await (0, AccessControl_1.removeOwnerTxParams)(params, txOptions);
|
|
195
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Initiates a create group operation and returns the prepared operation for execution.
|
|
199
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
200
|
+
* @param {string} userId - The ID of the user initiating the create group operation.
|
|
201
|
+
* @param {CreateGroupParams} params - The parameters for the create group operation.
|
|
202
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
203
|
+
* @returns {Promise<Operation>} The prepared create group operation.
|
|
204
|
+
*/
|
|
205
|
+
async createGroup(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
206
|
+
const walletAddr = await this.getAddress();
|
|
207
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
208
|
+
const chainId = await chain.getChainId();
|
|
209
|
+
await (0, GroupApis_1.createGroup)(params.groupId, chainId, Number(params.group.threshold), walletAddr, params.group.userIds);
|
|
210
|
+
params.group.userIds.forEach(async (userId) => {
|
|
211
|
+
const authId = await (0, utils_1.getAuthIdFromAddr)(userId);
|
|
212
|
+
await (0, UserApis_1.addUserToGroup)(authId, chainId, walletAddr, params.groupId);
|
|
213
|
+
});
|
|
214
|
+
const txParams = await (0, Group_1.createGroupTxParams)(params, txOptions);
|
|
215
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Initiates an add user to group operation and returns the prepared operation for execution.
|
|
219
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
220
|
+
* @param {string} userId - The ID of the user initiating the add user to group operation.
|
|
221
|
+
* @param {AddUserToGroupParams} params - The parameters for the add user to group operation.
|
|
222
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
223
|
+
* @returns {Promise<Operation>} The prepared add user to group operation.
|
|
224
|
+
*/
|
|
225
|
+
async addUserToGroup(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
226
|
+
params.userId = (0, viem_1.pad)(params.userId, { size: 32 });
|
|
227
|
+
params.groupId = (0, viem_1.pad)(params.groupId, { size: 32 });
|
|
228
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
229
|
+
const chainId = await chain.getChainId();
|
|
230
|
+
const groups = await (0, GroupApis_1.getGroups)([params.groupId], chainId);
|
|
231
|
+
if (!groups || groups.length === 0) {
|
|
232
|
+
throw new errors_1.ResourceNotFoundError(errors_1.ErrorCode.GroupNotFound, "group is not found", { params }, "Provide correct groupId and chainId.", "https://docs.fun.xyz");
|
|
233
|
+
}
|
|
234
|
+
const originalMembers = new Set(groups[0].memberIds);
|
|
235
|
+
const members = new Set(groups[0].memberIds);
|
|
236
|
+
members.add(params.userId);
|
|
237
|
+
if (members.size <= originalMembers.size) {
|
|
238
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.UserAlreadyExists, "user already exists in group", { params, originalMembers, userId: params.userId }, "Catch this error and swallow it as the user is already added.", "https://docs.fun.xyz");
|
|
239
|
+
}
|
|
240
|
+
const authId = await (0, utils_1.getAuthIdFromAddr)(params.userId);
|
|
241
|
+
await (0, UserApis_1.addUserToGroup)(authId, chainId, await this.getAddress(), params.groupId);
|
|
242
|
+
const updateGroupParams = {
|
|
243
|
+
groupId: params.groupId,
|
|
244
|
+
group: {
|
|
245
|
+
userIds: Array.from(members),
|
|
246
|
+
threshold: groups[0].threshold
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const txParams = await (0, Group_1.updateGroupTxParams)(updateGroupParams, txOptions);
|
|
250
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
251
|
+
}
|
|
252
|
+
/**
|
|
253
|
+
* Initiates a remove user from group operation and returns the prepared operation for execution.
|
|
254
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
255
|
+
* @param {string} userId - The ID of the user initiating the remove user from group operation.
|
|
256
|
+
* @param {RemoveUserFromGroupParams} params - The parameters for the remove user from group operation.
|
|
257
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
258
|
+
* @returns {Promise<Operation>} The prepared remove user from group operation.
|
|
259
|
+
*/
|
|
260
|
+
async removeUserFromGroup(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
261
|
+
params.userId = (0, viem_1.pad)(params.userId, { size: 32 });
|
|
262
|
+
params.groupId = (0, viem_1.pad)(params.groupId, { size: 32 });
|
|
263
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
264
|
+
const chainId = await chain.getChainId();
|
|
265
|
+
const groups = await (0, GroupApis_1.getGroups)([params.groupId], chainId);
|
|
266
|
+
if (!groups || groups.length === 0) {
|
|
267
|
+
throw new errors_1.ResourceNotFoundError(errors_1.ErrorCode.GroupNotFound, "group is not found", { params }, "Provide correct groupId and chainId.", "https://docs.fun.xyz");
|
|
268
|
+
}
|
|
269
|
+
const originalMembers = new Set(groups[0].memberIds);
|
|
270
|
+
const members = new Set(groups[0].memberIds);
|
|
271
|
+
members.delete(params.userId);
|
|
272
|
+
if (members.size >= originalMembers.size) {
|
|
273
|
+
throw new errors_1.ResourceNotFoundError(errors_1.ErrorCode.UserNotFound, "user does not exist in group", { params, originalMembers, userId: params.userId }, "Catch this error and swallow it as the user does not exist in the group.", "https://docs.fun.xyz");
|
|
274
|
+
}
|
|
275
|
+
const authId = await (0, utils_1.getAuthIdFromAddr)(params.userId);
|
|
276
|
+
await (0, UserApis_1.removeUserFromGroup)(authId, chainId, await this.getAddress(), params.groupId);
|
|
277
|
+
const updateGroupParams = {
|
|
278
|
+
groupId: params.groupId,
|
|
279
|
+
group: {
|
|
280
|
+
userIds: Array.from(members),
|
|
281
|
+
threshold: groups[0].threshold
|
|
282
|
+
}
|
|
283
|
+
};
|
|
284
|
+
const txParams = await (0, Group_1.updateGroupTxParams)(updateGroupParams, txOptions);
|
|
285
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Initiates an update threshold of group operation and returns the prepared operation for execution.
|
|
289
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
290
|
+
* @param {string} userId - The ID of the user initiating the update threshold of group operation.
|
|
291
|
+
* @param {UpdateThresholdOfGroupParams} params - The parameters for the update threshold of group operation.
|
|
292
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
293
|
+
* @returns {Promise<Operation>} The prepared update threshold of group operation.
|
|
294
|
+
*/
|
|
295
|
+
async updateThresholdOfGroup(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
296
|
+
params.groupId = (0, viem_1.pad)(params.groupId, { size: 32 });
|
|
297
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
298
|
+
const chainId = await chain.getChainId();
|
|
299
|
+
const groups = await (0, GroupApis_1.getGroups)([params.groupId], chainId);
|
|
300
|
+
if (!groups || groups.length === 0) {
|
|
301
|
+
throw new errors_1.ResourceNotFoundError(errors_1.ErrorCode.GroupNotFound, "group is not found", { params }, "Provide correct groupId and chainId.", "https://docs.fun.xyz");
|
|
302
|
+
}
|
|
303
|
+
if (!Number.isInteger(params.threshold) || params.threshold < 1 || params.threshold > groups[0].memberIds.length) {
|
|
304
|
+
throw new errors_1.InvalidParameterError(errors_1.ErrorCode.InvalidThreshold, "threshold can not be 0 or bigger than number of members in the group", { params, memberIds: groups[0].memberIds }, "Provide proper threshold number.", "https://docs.fun.xyz");
|
|
305
|
+
}
|
|
306
|
+
await (0, GroupApis_1.updateGroup)(params.groupId, chainId, { threshold: Number(params.threshold) });
|
|
307
|
+
const updateGroupParams = {
|
|
308
|
+
groupId: params.groupId,
|
|
309
|
+
group: {
|
|
310
|
+
userIds: groups[0].memberIds,
|
|
311
|
+
threshold: params.threshold
|
|
312
|
+
}
|
|
313
|
+
};
|
|
314
|
+
const txParams = await (0, Group_1.updateGroupTxParams)(updateGroupParams, txOptions);
|
|
315
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Initiates a remove group operation and returns the prepared operation for execution.
|
|
319
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
320
|
+
* @param {string} userId - The ID of the user initiating the remove group operation.
|
|
321
|
+
* @param {RemoveGroupParams} params - The parameters for the remove group operation.
|
|
322
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
323
|
+
* @returns {Promise<Operation>} The prepared remove group operation.
|
|
324
|
+
*/
|
|
325
|
+
async removeGroup(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
326
|
+
params.groupId = (0, viem_1.pad)(params.groupId, { size: 32 });
|
|
327
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
328
|
+
await (0, GroupApis_1.deleteGroup)(params.groupId, await chain.getChainId());
|
|
329
|
+
const txParams = await (0, Group_1.removeGroupTxParams)(params, txOptions);
|
|
330
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Initiates a batch operation and returns the prepared operation for execution.
|
|
334
|
+
* @param {Auth} auth - The authentication instance for the user.
|
|
335
|
+
* @param {string} userId - The ID of the user initiating the batch operation.
|
|
336
|
+
* @param {TransactionParams[]} params - An array of transaction parameters for the batch operation.
|
|
337
|
+
* @param {EnvOption} txOptions - Transaction environment options (default: global environment options).
|
|
338
|
+
* @returns {Promise<Operation>} The prepared batch operation.
|
|
339
|
+
*/
|
|
340
|
+
async createBatchOperation(auth, userId, params, txOptions = globalThis.globalEnvOption) {
|
|
341
|
+
const walletAddress = await this.getAddress();
|
|
342
|
+
const txParams = (0, BatchActions_1.createExecuteBatchTxParams)(params, walletAddress);
|
|
343
|
+
return await this.createOperation(auth, userId, txParams, txOptions);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
exports.FirstClassActions = FirstClassActions;
|
|
347
|
+
//# sourceMappingURL=FirstClassActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"FirstClassActions.js","sourceRoot":"","sources":["../../../src/actions/FirstClassActions.ts"],"names":[],"mappings":";;;AAAA,+BAAmC;AACnC,mDAA0G;AAC1G,iDAA2D;AAC3D,mCAAuF;AACvF,6CAA8D;AAC9D,mCAMgB;AAChB,iCAMe;AACf,mCAUgB;AAmBhB,iDAAoF;AACpF,+CAAiH;AAIjH,kCAA0C;AAC1C,sCAAmF;AACnF,oCAAuD;AAEvD,MAAsB,iBAAiB;IAkBnC;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CACN,IAAU,EACV,MAAc,EACd,MAAkB,EAClB,YAAwB,UAAkB,CAAC,eAAe;QAE1D,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,8BAAqB,CAC3B,kBAAS,CAAC,gBAAgB,EAC1B,sDAAsD,EACtD,EAAE,MAAM,EAAE,EACV,EAAE,EACF,sBAAsB,CACzB,CAAA;SACJ;QACD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,8BAAqB,CAC3B,kBAAS,CAAC,gBAAgB,EAC1B,uDAAuD,EACvD,EAAE,MAAM,EAAE,EACV,EAAE,EACF,sBAAsB,CACzB,CAAA;SACJ;QACD,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;YAClB,MAAM,IAAI,8BAAqB,CAC3B,kBAAS,CAAC,gBAAgB,EAC1B,uDAAuD,EACvD,EAAE,MAA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c,EACd,MAAyB,EACzB,YAAwB,UAAkB,CAAC,eAAe;QAE1D,MAAM,CAAC,OAAO,GAAG,IAAA,UAAG,EAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;QAClD,MAAM,KAAK,GAAG,MAAM,YAAK,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;QACxE,MAAM,IAAA,uBAAW,EAAC,MAAM,CAAC,OAAO,EAAE,MAAM,KAAK,CAAC,UAAU,EAAE,CAAC,CAAA;QAC3D,MAAM,QAAQ,GAAG,MAAM,IAAA,2BAAmB,EAAC,MAAM,EAAE,SAAS,CAAC,CAAA;QAC7D,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;IACxE,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,oBAAoB,CACtB,IAAU,EACV,MAAc,EACd,MAA2B,EAC3B,YAAwB,UAAkB,CAAC,eAAe;QAE1D,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,UAAU,EAAE,CAAA;QAC7C,MAAM,QAAQ,GAAG,IAAA,yCAA0B,EAAC,MAAM,EAAE,aAAa,CAAC,CAAA;QAClE,OAAO,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAA;IACxE,CAAC;CACJ;AAjgBD,8CAigBC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CreateGroupParams, RemoveGroupParams, UpdateGroupParams } from "./types";
|
|
2
|
+
import { TransactionParams } from "../common";
|
|
3
|
+
import { EnvOption } from "../config";
|
|
4
|
+
export declare const createGroupTxParams: (params: CreateGroupParams, txOptions?: EnvOption) => Promise<TransactionParams>;
|
|
5
|
+
export declare const updateGroupTxParams: (params: UpdateGroupParams, txOptions?: EnvOption) => Promise<TransactionParams>;
|
|
6
|
+
export declare const removeGroupTxParams: (params: RemoveGroupParams, txOptions?: EnvOption) => Promise<TransactionParams>;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.removeGroupTxParams = exports.updateGroupTxParams = exports.createGroupTxParams = void 0;
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const common_1 = require("../common");
|
|
6
|
+
const data_1 = require("../data");
|
|
7
|
+
const createGroupTxParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
8
|
+
const { groupId, group } = params;
|
|
9
|
+
group.userIds = group.userIds.map((userId) => {
|
|
10
|
+
return (0, viem_1.pad)(userId, { size: 32 });
|
|
11
|
+
});
|
|
12
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
13
|
+
const userAuthAddress = await chain.getAddress("userAuthAddress");
|
|
14
|
+
return common_1.USER_AUTHENTICATION_CONTRACT_INTERFACE.encodeTransactionParams(userAuthAddress, "createMultiSigGroup", [
|
|
15
|
+
(0, viem_1.pad)(groupId, { size: 32 }),
|
|
16
|
+
group
|
|
17
|
+
]);
|
|
18
|
+
};
|
|
19
|
+
exports.createGroupTxParams = createGroupTxParams;
|
|
20
|
+
const updateGroupTxParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
21
|
+
const { groupId, group } = params;
|
|
22
|
+
group.userIds = group.userIds
|
|
23
|
+
.map((userId) => {
|
|
24
|
+
return (0, viem_1.pad)(userId, { size: 32 });
|
|
25
|
+
})
|
|
26
|
+
.sort((a, b) => b.localeCompare(a));
|
|
27
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
28
|
+
const userAuthAddress = await chain.getAddress("userAuthAddress");
|
|
29
|
+
return common_1.USER_AUTHENTICATION_CONTRACT_INTERFACE.encodeTransactionParams(userAuthAddress, "updateMultiSigGroup", [
|
|
30
|
+
(0, viem_1.pad)(groupId, { size: 32 }),
|
|
31
|
+
group
|
|
32
|
+
]);
|
|
33
|
+
};
|
|
34
|
+
exports.updateGroupTxParams = updateGroupTxParams;
|
|
35
|
+
const removeGroupTxParams = async (params, txOptions = globalThis.globalEnvOption) => {
|
|
36
|
+
const { groupId } = params;
|
|
37
|
+
const chain = await data_1.Chain.getChain({ chainIdentifier: txOptions.chain });
|
|
38
|
+
const userAuthAddress = await chain.getAddress("userAuthAddress");
|
|
39
|
+
return common_1.USER_AUTHENTICATION_CONTRACT_INTERFACE.encodeTransactionParams(userAuthAddress, "deleteMultiSigGroup", [
|
|
40
|
+
(0, viem_1.pad)(groupId, { size: 32 })
|
|
41
|
+
]);
|
|
42
|
+
};
|
|
43
|
+
exports.removeGroupTxParams = removeGroupTxParams;
|
|
44
|
+
//# sourceMappingURL=Group.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Group.js","sourceRoot":"","sources":["../../../src/actions/Group.ts"],"names":[],"mappings":";;;AAAA,+BAA0B;AAE1B,sCAAqF;AAErF,kCAA+B;AAExB,MAAM,mBAAmB,GAAG,KAAK,EACpC,MAAyB,EACzB,YAAwB,UAAkB,CAAC,eAAe,EAChC,EAAE;IAC5B,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACjC,KAAK,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;QACzC,OAAO,IAAA,UAAG,EAAC,MAAM,EAAE,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAA;IACpC,CAAC,CAAC,CAAA;IACF,MAAM,KAAK,GAAG,MAAM,YAAK,CAAC,QAAQ,CAAC,EAAE,eAAe,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAA;IACxE,MAAM,eAAe,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAA;IACjE,OAAO,+CAAsC,CAAC,uBAAuB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