@boostxyz/sdk 0.0.0-alpha.8 → 1.1.0-alpha.22
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/Actions/Action.cjs +1 -1
- package/dist/Actions/Action.cjs.map +1 -1
- package/dist/Actions/Action.js +7 -7
- package/dist/Actions/ContractAction.d.ts +57 -14
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +50 -23
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +420 -45
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -225
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -1
- package/dist/AllowLists/AllowList.d.ts +6 -4
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +45 -23
- package/dist/AllowLists/AllowList.js.map +1 -1
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +123 -39
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +75 -76
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -200
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -1
- package/dist/Auth/PassthroughAuth.js +4 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +137 -5
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BVZExPPu.js +1462 -0
- package/dist/BoostCore-BVZExPPu.js.map +1 -0
- package/dist/BoostCore-D-E-cnGI.cjs +3 -0
- package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +759 -82
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1148
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +83 -28
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +170 -93
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.cjs.map +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/Budget.js.map +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +89 -290
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +1 -1
- package/dist/Deployable/Contract.cjs.map +1 -1
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +6 -8
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +1 -1
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +3 -5
- package/dist/Deployable/Deployable.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.d.ts +13 -13
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +30 -27
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/EventAction-BZt5cjbe.cjs +2 -0
- package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
- package/dist/EventAction-C_-hJXWm.js +1541 -0
- package/dist/EventAction-C_-hJXWm.js.map +1 -0
- package/dist/Incentive-BhHaK3PZ.cjs +2 -0
- package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
- package/dist/Incentive-Cqg1w6wD.js +312 -0
- package/dist/Incentive-Cqg1w6wD.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +73 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +61 -36
- package/dist/Incentives/AllowListIncentive.js.map +1 -1
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
- package/dist/Incentives/CGDAIncentive.d.ts +323 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +73 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +278 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +79 -47
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +346 -420
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +271 -32
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.d.ts +4 -4
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +16 -280
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +89 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +66 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +164 -36
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/Validators/Validator.js.map +1 -1
- package/dist/claiming.cjs +2 -0
- package/dist/claiming.cjs.map +1 -0
- package/dist/claiming.d.ts +43 -0
- package/dist/claiming.d.ts.map +1 -0
- package/dist/claiming.js +17 -0
- package/dist/claiming.js.map +1 -0
- package/dist/componentInterfaces-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +257 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-Cbv8zFkf.js → generated-CKt2yCQd.js} +3615 -1868
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -126
- package/dist/index.js.map +1 -1
- package/dist/transfers.cjs +2 -0
- package/dist/transfers.cjs.map +1 -0
- package/dist/transfers.d.ts +198 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +84 -0
- package/dist/transfers.js.map +1 -0
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +25 -1380
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +36 -648
- package/dist/utils.js.map +1 -1
- package/package.json +34 -10
- package/src/Actions/Action.test.ts +19 -17
- package/src/Actions/ContractAction.test.ts +14 -16
- package/src/Actions/ContractAction.ts +84 -22
- package/src/Actions/ERC721MintAction.test.ts +8 -8
- package/src/Actions/ERC721MintAction.ts +83 -30
- package/src/Actions/EventAction.test.ts +759 -113
- package/src/Actions/EventAction.ts +991 -116
- package/src/AllowLists/AllowList.test.ts +7 -7
- package/src/AllowLists/AllowList.ts +5 -3
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +4 -4
- package/src/AllowLists/SimpleAllowList.ts +86 -65
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +87 -126
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Auth/PassthroughAuth.ts +1 -1
- package/src/Boost.ts +147 -15
- package/src/BoostCore.test.ts +326 -278
- package/src/BoostCore.ts +425 -242
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +168 -50
- package/src/Budgets/Budget.test.ts +2 -2
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.test.ts +82 -19
- package/src/Budgets/ManagedBudget.ts +106 -315
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +110 -112
- package/src/Deployable/Contract.ts +5 -6
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +32 -21
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +7 -10
- package/src/Incentives/AllowListIncentive.ts +88 -30
- package/src/Incentives/CGDAIncentive.test.ts +11 -12
- package/src/Incentives/CGDAIncentive.ts +161 -37
- package/src/Incentives/ERC1155Incentive.test.ts +5 -16
- package/src/Incentives/ERC1155Incentive.ts +132 -51
- package/src/Incentives/ERC20Incentive.test.ts +15 -23
- package/src/Incentives/ERC20Incentive.ts +131 -46
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +12 -35
- package/src/Incentives/ERC20VariableIncentive.ts +118 -43
- package/src/Incentives/Incentive.test.ts +5 -2
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +26 -30
- package/src/Incentives/PointsIncentive.ts +110 -34
- package/src/Validators/SignerValidator.test.ts +9 -13
- package/src/Validators/SignerValidator.ts +437 -26
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +56 -0
- package/src/errors.ts +346 -22
- package/src/index.test.ts +118 -36
- package/src/index.ts +15 -7
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -2061
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-DYkaxBda.js +0 -13
- package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
- package/dist/generated-BzszviNp.cjs +0 -3
- package/dist/generated-BzszviNp.cjs.map +0 -1
- package/dist/generated-Cbv8zFkf.js.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -521
package/src/utils.ts
CHANGED
|
@@ -3,10 +3,11 @@ import {
|
|
|
3
3
|
type ReadContractParameters,
|
|
4
4
|
type WatchContractEventParameters,
|
|
5
5
|
type WriteContractParameters,
|
|
6
|
+
getAccount,
|
|
7
|
+
getClient,
|
|
6
8
|
waitForTransactionReceipt,
|
|
7
9
|
} from '@wagmi/core';
|
|
8
10
|
import type { ExtractAbiEvent } from 'abitype';
|
|
9
|
-
import { LibZip } from 'solady';
|
|
10
11
|
import type {
|
|
11
12
|
Abi,
|
|
12
13
|
AbiEvent,
|
|
@@ -17,31 +18,30 @@ import type {
|
|
|
17
18
|
Hash,
|
|
18
19
|
Hex,
|
|
19
20
|
Log,
|
|
20
|
-
PrivateKeyAccount,
|
|
21
21
|
WaitForTransactionReceiptParameters,
|
|
22
22
|
} from 'viem';
|
|
23
|
+
import { isHex, keccak256, slice, toHex } from 'viem';
|
|
23
24
|
import {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
import { NoContractAddressUponReceiptError } from './errors';
|
|
25
|
+
InvalidProtocolChainIdError,
|
|
26
|
+
NoConnectedChainIdError,
|
|
27
|
+
NoContractAddressUponReceiptError,
|
|
28
|
+
} from './errors';
|
|
29
|
+
|
|
30
|
+
export type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Enum encapsulating all the different types of targets used in the Boost V2 Protocol.
|
|
34
|
+
*
|
|
35
|
+
* @export
|
|
36
|
+
* @enum {number}
|
|
37
|
+
*/
|
|
38
|
+
export enum RegistryType {
|
|
39
|
+
ACTION = 0,
|
|
40
|
+
ALLOW_LIST = 1,
|
|
41
|
+
BUDGET = 2,
|
|
42
|
+
INCENTIVE = 3,
|
|
43
|
+
VALIDATOR = 4,
|
|
44
|
+
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.
|
|
@@ -53,8 +53,8 @@ import { NoContractAddressUponReceiptError } from './errors';
|
|
|
53
53
|
* @template {ContractFunctionName<abi>} functionName
|
|
54
54
|
*/
|
|
55
55
|
export type WriteParams<
|
|
56
|
-
abi extends Abi,
|
|
57
|
-
functionName extends ContractFunctionName<abi>,
|
|
56
|
+
abi extends Abi = Abi,
|
|
57
|
+
functionName extends ContractFunctionName<abi> = ContractFunctionName<abi>,
|
|
58
58
|
> = Partial<
|
|
59
59
|
Omit<
|
|
60
60
|
WriteContractParameters<abi, functionName>,
|
|
@@ -154,7 +154,7 @@ export function bytes4(input: string) {
|
|
|
154
154
|
* @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
|
|
155
155
|
* @param {Promise<Hash>} hash - A transaction hash promise
|
|
156
156
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}
|
|
157
|
-
* @returns {
|
|
157
|
+
* @returns {Promise<Address>}
|
|
158
158
|
* @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received
|
|
159
159
|
*/
|
|
160
160
|
export async function getDeployedContractAddress(
|
|
@@ -205,2043 +205,43 @@ export async function awaitResult<Result = unknown>(
|
|
|
205
205
|
}
|
|
206
206
|
|
|
207
207
|
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
210
|
-
* @export
|
|
211
|
-
* @enum {number}
|
|
212
|
-
*/
|
|
213
|
-
export enum RegistryType {
|
|
214
|
-
ACTION = 0,
|
|
215
|
-
ALLOW_LIST = 1,
|
|
216
|
-
BUDGET = 2,
|
|
217
|
-
INCENTIVE = 3,
|
|
218
|
-
VALIDATOR = 4,
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Enum representing incentive disbursement strategies.
|
|
223
|
-
*
|
|
224
|
-
* @export
|
|
225
|
-
* @enum {number}
|
|
226
|
-
*/
|
|
227
|
-
export enum StrategyType {
|
|
228
|
-
POOL = 0,
|
|
229
|
-
MINT = 1,
|
|
230
|
-
RAFFLE = 2,
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
* Enum representing inventive disbursement strategies for {@link ERC1155Incentive}
|
|
235
|
-
*
|
|
236
|
-
* @export
|
|
237
|
-
* @enum {number}
|
|
238
|
-
*/
|
|
239
|
-
export enum ERC1155StrategyType {
|
|
240
|
-
POOL = 0,
|
|
241
|
-
MINT = 1,
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Object representation of `BoostLib.Target` struct. Used for low level Boost creation operations.
|
|
246
|
-
* This is used to pass the base contract and its initialization parameters in an efficient manner
|
|
247
|
-
*
|
|
248
|
-
* @export
|
|
249
|
-
* @typedef {Target}
|
|
250
|
-
*/
|
|
251
|
-
export type Target = {
|
|
252
|
-
isBase: boolean;
|
|
253
|
-
instance: Address;
|
|
254
|
-
parameters: Hex;
|
|
255
|
-
};
|
|
256
|
-
|
|
257
|
-
/*
|
|
258
|
-
* Action Event Payloads
|
|
259
|
-
*/
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* Filter types used to determine how criteria are evaluated.
|
|
263
|
-
*
|
|
264
|
-
* @export
|
|
265
|
-
* @enum {number}
|
|
266
|
-
*/
|
|
267
|
-
export enum FilterType {
|
|
268
|
-
EQUAL = 0,
|
|
269
|
-
NOT_EQUAL = 1,
|
|
270
|
-
GREATER_THAN = 2,
|
|
271
|
-
LESS_THAN = 3,
|
|
272
|
-
CONTAINS = 4,
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* The primitive types supported for filtering.
|
|
208
|
+
* Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.
|
|
277
209
|
*
|
|
278
210
|
* @export
|
|
279
|
-
* @
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
BYTES = 2,
|
|
285
|
-
STRING = 3,
|
|
286
|
-
}
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* Object representation of a `Criteria` struct used in event actions.
|
|
290
|
-
*
|
|
291
|
-
* @export
|
|
292
|
-
* @interface Criteria
|
|
293
|
-
* @typedef {Criteria}
|
|
294
|
-
*/
|
|
295
|
-
export interface Criteria {
|
|
296
|
-
/**
|
|
297
|
-
* The filter type used in this criteria.
|
|
298
|
-
*
|
|
299
|
-
* @type {FilterType}
|
|
300
|
-
*/
|
|
301
|
-
filterType: FilterType;
|
|
302
|
-
/**
|
|
303
|
-
* The primitive type of the field being filtered.
|
|
304
|
-
*
|
|
305
|
-
* @type {PrimitiveType}
|
|
306
|
-
*/
|
|
307
|
-
fieldType: PrimitiveType;
|
|
308
|
-
/**
|
|
309
|
-
* The index in the logs argument array where the field is located.
|
|
310
|
-
*
|
|
311
|
-
* @type {number}
|
|
312
|
-
*/
|
|
313
|
-
fieldIndex: number;
|
|
314
|
-
/**
|
|
315
|
-
* The filter data used for complex filtering.
|
|
316
|
-
*
|
|
317
|
-
* @type {Hex}
|
|
318
|
-
*/
|
|
319
|
-
filterData: Hex;
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
/**
|
|
323
|
-
* Whether a given signature is an event or function
|
|
324
|
-
*
|
|
325
|
-
* @export
|
|
326
|
-
* @enum {number}
|
|
327
|
-
*/
|
|
328
|
-
export enum SignatureType {
|
|
329
|
-
EVENT = 0,
|
|
330
|
-
FUNC = 1,
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
/**
|
|
334
|
-
* The payload describing how claimants are identified
|
|
335
|
-
*
|
|
336
|
-
* @export
|
|
337
|
-
* @interface ActionClaimant
|
|
338
|
-
* @typedef {ActionClaimant}
|
|
339
|
-
*/
|
|
340
|
-
export interface ActionClaimant {
|
|
341
|
-
/**
|
|
342
|
-
* Whether claimaint is inferred from event or function
|
|
343
|
-
*
|
|
344
|
-
* @type {SignatureType}
|
|
345
|
-
*/
|
|
346
|
-
signatureType: SignatureType;
|
|
347
|
-
/**
|
|
348
|
-
* The 4 byte signature of the event or function
|
|
349
|
-
*
|
|
350
|
-
* @type {Hex}
|
|
351
|
-
*/
|
|
352
|
-
signature: Hex;
|
|
353
|
-
/**
|
|
354
|
-
* The index corresponding to claimant.
|
|
355
|
-
*
|
|
356
|
-
* @type {number}
|
|
357
|
-
*/
|
|
358
|
-
fieldIndex: number;
|
|
359
|
-
/**
|
|
360
|
-
* The address of the target contract
|
|
361
|
-
*
|
|
362
|
-
* @type {Address}
|
|
363
|
-
*/
|
|
364
|
-
targetContract: Address;
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
/**
|
|
368
|
-
* Object representation of an `ActionStep` struct used in event actions.
|
|
369
|
-
*
|
|
370
|
-
* @export
|
|
371
|
-
* @interface ActionStep
|
|
372
|
-
* @typedef {ActionStep}
|
|
373
|
-
*/
|
|
374
|
-
export interface ActionStep {
|
|
375
|
-
/**
|
|
376
|
-
* The signature of the event.
|
|
377
|
-
*
|
|
378
|
-
* @type {Hex}
|
|
379
|
-
*/
|
|
380
|
-
signature: Hex;
|
|
381
|
-
/**
|
|
382
|
-
* Whether claimaint is inferred from event or function
|
|
383
|
-
*
|
|
384
|
-
* @type {SignatureType}
|
|
385
|
-
*/
|
|
386
|
-
signatureType: SignatureType;
|
|
387
|
-
/**
|
|
388
|
-
* The type of action being performed.
|
|
389
|
-
*
|
|
390
|
-
* @type {number}
|
|
391
|
-
*/
|
|
392
|
-
actionType: number;
|
|
393
|
-
/**
|
|
394
|
-
* The address of the target contract.
|
|
395
|
-
*
|
|
396
|
-
* @type {Address}
|
|
397
|
-
*/
|
|
398
|
-
targetContract: Address;
|
|
399
|
-
/**
|
|
400
|
-
* The criteria used for this action step.
|
|
401
|
-
*
|
|
402
|
-
* @type {Criteria}
|
|
403
|
-
*/
|
|
404
|
-
actionParameter: Criteria;
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
/**
|
|
408
|
-
* You can either supply a simplified version of the payload, or one that explicitly declares action steps.
|
|
409
|
-
*
|
|
410
|
-
* @export
|
|
411
|
-
* @typedef {EventActionPayload}
|
|
412
|
-
*/
|
|
413
|
-
export type EventActionPayload =
|
|
414
|
-
| EventActionPayloadSimple
|
|
415
|
-
| EventActionPayloadRaw;
|
|
416
|
-
|
|
417
|
-
export interface EventActionPayloadSimple {
|
|
418
|
-
/**
|
|
419
|
-
* The payload describing how claimants are identified
|
|
420
|
-
*
|
|
421
|
-
* @type {ActionClaimant}
|
|
422
|
-
*/
|
|
423
|
-
actionClaimant: ActionClaimant;
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Up to 4 action steps.
|
|
427
|
-
* If you supply less than 4, then the last step will be reused to satisfy the EventAction.InitPayload
|
|
428
|
-
* Any more than 4 will throw an error.
|
|
429
|
-
*
|
|
430
|
-
* @type {ActionStep[]}
|
|
431
|
-
*/
|
|
432
|
-
actionSteps: ActionStep[];
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Typeguard to determine if a user is supplying a simple or raw EventActionPayload
|
|
437
|
-
*
|
|
438
|
-
* @param {*} opts
|
|
439
|
-
* @returns {opts is EventActionPayloadSimple}
|
|
440
|
-
*/
|
|
441
|
-
export function isEventActionPayloadSimple(
|
|
442
|
-
opts: EventActionPayload,
|
|
443
|
-
): opts is EventActionPayloadSimple {
|
|
444
|
-
return Array.isArray((opts as EventActionPayloadSimple).actionSteps);
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
/**
|
|
448
|
-
* Object representation of an `InitPayload` struct used to initialize event actions.
|
|
449
|
-
*
|
|
450
|
-
* @export
|
|
451
|
-
* @interface EventActionPayloadRaw
|
|
452
|
-
* @typedef {EventActionPayloadRaw}
|
|
453
|
-
*/
|
|
454
|
-
export interface EventActionPayloadRaw {
|
|
455
|
-
/**
|
|
456
|
-
* The payload describing how claimants are identified
|
|
457
|
-
*
|
|
458
|
-
* @type {ActionClaimant}
|
|
459
|
-
*/
|
|
460
|
-
actionClaimant: ActionClaimant;
|
|
461
|
-
/**
|
|
462
|
-
* The first action step.
|
|
463
|
-
*
|
|
464
|
-
* @type {ActionStep}
|
|
465
|
-
*/
|
|
466
|
-
actionStepOne: ActionStep;
|
|
467
|
-
/**
|
|
468
|
-
* The second action step.
|
|
469
|
-
*
|
|
470
|
-
* @type {ActionStep}
|
|
471
|
-
*/
|
|
472
|
-
actionStepTwo: ActionStep;
|
|
473
|
-
/**
|
|
474
|
-
* The third action step.
|
|
475
|
-
*
|
|
476
|
-
* @type {ActionStep}
|
|
477
|
-
*/
|
|
478
|
-
actionStepThree: ActionStep;
|
|
479
|
-
/**
|
|
480
|
-
* The fourth action step.
|
|
481
|
-
*
|
|
482
|
-
* @type {ActionStep}
|
|
483
|
-
*/
|
|
484
|
-
actionStepFour: ActionStep;
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
/**
|
|
488
|
-
* Function to properly encode an event action payload.
|
|
489
|
-
*
|
|
490
|
-
* @param {InitPayload} param0
|
|
491
|
-
* @param {ActionStep} param0.actionStepOne - The first action step to initialize.
|
|
492
|
-
* @param {ActionStep} param0.actionStepTwo - The second action step to initialize.
|
|
493
|
-
* @param {ActionStep} param0.actionStepThree - The third action step to initialize.
|
|
494
|
-
* @param {ActionStep} param0.actionStepFour - The fourth action step to initialize.
|
|
495
|
-
* @returns {Hex}
|
|
496
|
-
*/
|
|
497
|
-
export const prepareEventActionPayload = ({
|
|
498
|
-
actionClaimant,
|
|
499
|
-
actionStepOne,
|
|
500
|
-
actionStepTwo,
|
|
501
|
-
actionStepThree,
|
|
502
|
-
actionStepFour,
|
|
503
|
-
}: EventActionPayloadRaw) => {
|
|
504
|
-
return encodeAbiParameters(
|
|
505
|
-
[
|
|
506
|
-
{
|
|
507
|
-
type: 'tuple',
|
|
508
|
-
name: 'initPayload',
|
|
509
|
-
components: [
|
|
510
|
-
{
|
|
511
|
-
type: 'tuple',
|
|
512
|
-
name: 'actionClaimant',
|
|
513
|
-
components: [
|
|
514
|
-
{ type: 'uint8', name: 'signatureType' },
|
|
515
|
-
{ type: 'bytes4', name: 'signature' },
|
|
516
|
-
{ type: 'uint8', name: 'fieldIndex' },
|
|
517
|
-
{ type: 'address', name: 'targetContract' },
|
|
518
|
-
],
|
|
519
|
-
},
|
|
520
|
-
{
|
|
521
|
-
type: 'tuple',
|
|
522
|
-
name: 'actionStepOne',
|
|
523
|
-
components: [
|
|
524
|
-
{ type: 'bytes4', name: 'signature' },
|
|
525
|
-
{ type: 'uint8', name: 'signatureType' },
|
|
526
|
-
{ type: 'uint8', name: 'actionType' },
|
|
527
|
-
{ type: 'address', name: 'targetContract' },
|
|
528
|
-
{
|
|
529
|
-
type: 'tuple',
|
|
530
|
-
name: 'actionParameter',
|
|
531
|
-
components: [
|
|
532
|
-
{ type: 'uint8', name: 'filterType' },
|
|
533
|
-
{ type: 'uint8', name: 'fieldType' },
|
|
534
|
-
{ type: 'uint8', name: 'fieldIndex' },
|
|
535
|
-
{ type: 'bytes', name: 'filterData' },
|
|
536
|
-
],
|
|
537
|
-
},
|
|
538
|
-
],
|
|
539
|
-
},
|
|
540
|
-
{
|
|
541
|
-
type: 'tuple',
|
|
542
|
-
name: 'actionStepTwo',
|
|
543
|
-
components: [
|
|
544
|
-
{ type: 'bytes4', name: 'signature' },
|
|
545
|
-
{ type: 'uint8', name: 'signatureType' },
|
|
546
|
-
{ type: 'uint8', name: 'actionType' },
|
|
547
|
-
{ type: 'address', name: 'targetContract' },
|
|
548
|
-
{
|
|
549
|
-
type: 'tuple',
|
|
550
|
-
name: 'actionParameter',
|
|
551
|
-
components: [
|
|
552
|
-
{ type: 'uint8', name: 'filterType' },
|
|
553
|
-
{ type: 'uint8', name: 'fieldType' },
|
|
554
|
-
{ type: 'uint8', name: 'fieldIndex' },
|
|
555
|
-
{ type: 'bytes', name: 'filterData' },
|
|
556
|
-
],
|
|
557
|
-
},
|
|
558
|
-
],
|
|
559
|
-
},
|
|
560
|
-
{
|
|
561
|
-
type: 'tuple',
|
|
562
|
-
name: 'actionStepThree',
|
|
563
|
-
components: [
|
|
564
|
-
{ type: 'bytes4', name: 'signature' },
|
|
565
|
-
{ type: 'uint8', name: 'signatureType' },
|
|
566
|
-
{ type: 'uint8', name: 'actionType' },
|
|
567
|
-
{ type: 'address', name: 'targetContract' },
|
|
568
|
-
{
|
|
569
|
-
type: 'tuple',
|
|
570
|
-
name: 'actionParameter',
|
|
571
|
-
components: [
|
|
572
|
-
{ type: 'uint8', name: 'filterType' },
|
|
573
|
-
{ type: 'uint8', name: 'fieldType' },
|
|
574
|
-
{ type: 'uint8', name: 'fieldIndex' },
|
|
575
|
-
{ type: 'bytes', name: 'filterData' },
|
|
576
|
-
],
|
|
577
|
-
},
|
|
578
|
-
],
|
|
579
|
-
},
|
|
580
|
-
{
|
|
581
|
-
type: 'tuple',
|
|
582
|
-
name: 'actionStepFour',
|
|
583
|
-
components: [
|
|
584
|
-
{ type: 'bytes4', name: 'signature' },
|
|
585
|
-
{ type: 'uint8', name: 'signatureType' },
|
|
586
|
-
{ type: 'uint8', name: 'actionType' },
|
|
587
|
-
{ type: 'address', name: 'targetContract' },
|
|
588
|
-
{
|
|
589
|
-
type: 'tuple',
|
|
590
|
-
name: 'actionParameter',
|
|
591
|
-
components: [
|
|
592
|
-
{ type: 'uint8', name: 'filterType' },
|
|
593
|
-
{ type: 'uint8', name: 'fieldType' },
|
|
594
|
-
{ type: 'uint8', name: 'fieldIndex' },
|
|
595
|
-
{ type: 'bytes', name: 'filterData' },
|
|
596
|
-
],
|
|
597
|
-
},
|
|
598
|
-
],
|
|
599
|
-
},
|
|
600
|
-
],
|
|
601
|
-
},
|
|
602
|
-
],
|
|
603
|
-
[
|
|
604
|
-
{
|
|
605
|
-
actionClaimant,
|
|
606
|
-
actionStepOne,
|
|
607
|
-
actionStepTwo,
|
|
608
|
-
actionStepThree,
|
|
609
|
-
actionStepFour,
|
|
610
|
-
},
|
|
611
|
-
],
|
|
612
|
-
);
|
|
613
|
-
};
|
|
614
|
-
|
|
615
|
-
/**
|
|
616
|
-
* Object representation of the `ERC20Incentive.InitPayload`.
|
|
617
|
-
*
|
|
618
|
-
* @export
|
|
619
|
-
* @interface ERC20IncentivePayload
|
|
620
|
-
* @typedef {ERC20IncentivePayload}
|
|
621
|
-
*/
|
|
622
|
-
export interface ERC20IncentivePayload {
|
|
623
|
-
/**
|
|
624
|
-
* The address of the incentivized asset.
|
|
625
|
-
*
|
|
626
|
-
* @type {Address}
|
|
627
|
-
*/
|
|
628
|
-
asset: Address;
|
|
629
|
-
/**
|
|
630
|
-
* The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
631
|
-
*
|
|
632
|
-
* @type {StrategyType}
|
|
633
|
-
*/
|
|
634
|
-
strategy: StrategyType;
|
|
635
|
-
/**
|
|
636
|
-
* The amount of the asset to distribute.
|
|
637
|
-
*
|
|
638
|
-
* @type {bigint}
|
|
639
|
-
*/
|
|
640
|
-
reward: bigint;
|
|
641
|
-
/**
|
|
642
|
-
* How many times can this incentive be claimed.
|
|
643
|
-
*
|
|
644
|
-
* @type {bigint}
|
|
645
|
-
*/
|
|
646
|
-
limit: bigint;
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
/**
|
|
650
|
-
* Object representing the payload for signing before validaton.
|
|
651
|
-
*
|
|
652
|
-
* @export
|
|
653
|
-
* @interface SignerValidatorSignaturePayload
|
|
654
|
-
* @typedef {SignerValidatorSignaturePayload}
|
|
655
|
-
*/
|
|
656
|
-
export interface SignerValidatorSignaturePayload {
|
|
657
|
-
/**
|
|
658
|
-
* The ID of the boost.
|
|
659
|
-
*
|
|
660
|
-
* @type {bigint}
|
|
661
|
-
*/
|
|
662
|
-
boostId: bigint;
|
|
663
|
-
/**
|
|
664
|
-
* The ID of the incentive.
|
|
665
|
-
*
|
|
666
|
-
* @type {number}
|
|
667
|
-
*/
|
|
668
|
-
incentiveQuantity: number;
|
|
669
|
-
/**
|
|
670
|
-
* The address of the claimant.
|
|
671
|
-
*
|
|
672
|
-
* @type {Address}
|
|
673
|
-
*/
|
|
674
|
-
claimant: Address;
|
|
675
|
-
/**
|
|
676
|
-
* The claim data.
|
|
677
|
-
*
|
|
678
|
-
* @type {Hex}
|
|
679
|
-
*/
|
|
680
|
-
incentiveData: Hex;
|
|
681
|
-
}
|
|
682
|
-
|
|
683
|
-
// /**
|
|
684
|
-
// * Function to properly encode a validation payload.
|
|
685
|
-
// *
|
|
686
|
-
// * @param {SignerValidatorValidatePayload} param0
|
|
687
|
-
// * @param {Address} param0.signer - The address of the signer with which to validate.
|
|
688
|
-
// * @param {Hex} param0.hash - The transaction 558 to associate with the validation.
|
|
689
|
-
// * @param {Hex} param0.signature - The signature is expected to be a valid ECDSA or EIP-1271 signature of a unique hash by an authorized signer
|
|
690
|
-
// * @param {Address} param0.validator - Address of the validator module.
|
|
691
|
-
// * @returns {*}
|
|
692
|
-
// */
|
|
693
|
-
// export const prepareSignerValidatorSignaturePayload = ({
|
|
694
|
-
// boostId,
|
|
695
|
-
// incentiveId,
|
|
696
|
-
// claimant,
|
|
697
|
-
// claimData,
|
|
698
|
-
// validator,
|
|
699
|
-
// chainId,
|
|
700
|
-
// }: SignerValidatorSignaturePayload) => {
|
|
701
|
-
// const domain = {
|
|
702
|
-
// name: 'SignerValidator',
|
|
703
|
-
// version: '1',
|
|
704
|
-
// chainId: chainId,
|
|
705
|
-
// verifyingContract: validator,
|
|
706
|
-
// };
|
|
707
|
-
// return hashTypedData({
|
|
708
|
-
// domain,
|
|
709
|
-
// types: {
|
|
710
|
-
// SignerValidatorData: [
|
|
711
|
-
// { name: 'incentiveId', type: 'uint256' },
|
|
712
|
-
// { name: 'claimant', type: 'address' },
|
|
713
|
-
// { name: 'boostId', type: 'uint256' },
|
|
714
|
-
// { name: 'claimData', type: 'bytes32' },
|
|
715
|
-
// ],
|
|
716
|
-
// },
|
|
717
|
-
// primaryType: 'SignerValidatorData',
|
|
718
|
-
// message: {
|
|
719
|
-
// incentiveId,
|
|
720
|
-
// claimant,
|
|
721
|
-
// boostId,
|
|
722
|
-
// claimData,
|
|
723
|
-
// },
|
|
724
|
-
// });
|
|
725
|
-
// };
|
|
726
|
-
|
|
727
|
-
/**
|
|
728
|
-
* Object reprentation of a {@link SignerValidator} initialization payload
|
|
729
|
-
*
|
|
730
|
-
* @export
|
|
731
|
-
* @interface SignerValidatorPayload
|
|
732
|
-
* @typedef {SignerValidatorPayload}
|
|
733
|
-
*/
|
|
734
|
-
export interface SignerValidatorPayload {
|
|
735
|
-
/**
|
|
736
|
-
* The list of authorized signers. The first address in the list will be the initial owner of the contract.
|
|
737
|
-
*
|
|
738
|
-
* @type {Address[]}
|
|
739
|
-
*/
|
|
740
|
-
signers: Address[];
|
|
741
|
-
/**
|
|
742
|
-
* The authorized caller of the {@link prepareSignerValidator} function
|
|
743
|
-
* @type {Address}
|
|
744
|
-
*/
|
|
745
|
-
validatorCaller: Address;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
/**
|
|
749
|
-
* Description placeholder
|
|
750
|
-
*
|
|
751
|
-
* @export
|
|
752
|
-
* @interface SignerValidatorValidatePayload
|
|
753
|
-
* @typedef {SignerValidatorValidatePayload}
|
|
754
|
-
*/
|
|
755
|
-
export interface SignerValidatorValidatePayload {
|
|
756
|
-
/**
|
|
757
|
-
* The ID of the boost.
|
|
758
|
-
*
|
|
759
|
-
* @type {bigint}
|
|
760
|
-
*/
|
|
761
|
-
boostId: bigint;
|
|
762
|
-
/**
|
|
763
|
-
* The ID of the incentive.
|
|
764
|
-
*
|
|
765
|
-
* @type {bigint}
|
|
766
|
-
*/
|
|
767
|
-
incentiveId: bigint;
|
|
768
|
-
/**
|
|
769
|
-
* The address of the claimant.
|
|
770
|
-
*
|
|
771
|
-
* @type {Address}
|
|
772
|
-
*/
|
|
773
|
-
claimant: Address;
|
|
774
|
-
/**
|
|
775
|
-
* The claim data.
|
|
776
|
-
*
|
|
777
|
-
* @type {Hex}
|
|
778
|
-
*/
|
|
779
|
-
claimData: Hex;
|
|
780
|
-
}
|
|
781
|
-
|
|
782
|
-
/**
|
|
783
|
-
* Given a {@link SignerValidatorPayload}, properly encode the initialization payload.
|
|
784
|
-
*
|
|
785
|
-
* @param {SignerValidatorPayload} param0
|
|
786
|
-
* @param {Address[]} param0.signers
|
|
787
|
-
* @param {Address} param0.validatorCaller
|
|
788
|
-
* @returns {Hex}
|
|
789
|
-
*/
|
|
790
|
-
export const prepareSignerValidatorPayload = ({
|
|
791
|
-
signers,
|
|
792
|
-
validatorCaller,
|
|
793
|
-
}: SignerValidatorPayload) => {
|
|
794
|
-
return encodeAbiParameters(
|
|
795
|
-
[
|
|
796
|
-
{ type: 'address[]', name: 'signers' },
|
|
797
|
-
{ type: 'address', name: 'validatorCaller' },
|
|
798
|
-
],
|
|
799
|
-
[signers, validatorCaller],
|
|
800
|
-
);
|
|
801
|
-
};
|
|
802
|
-
|
|
803
|
-
/**
|
|
804
|
-
* Object representation of a {@link BoostClaimData} initialization payload
|
|
805
|
-
*
|
|
806
|
-
* @export
|
|
807
|
-
* @interface BoostClaimData
|
|
808
|
-
* @typedef {BoostClaimData}
|
|
809
|
-
*/
|
|
810
|
-
export interface BoostClaimData {
|
|
811
|
-
/**
|
|
812
|
-
* The validator data.
|
|
813
|
-
*
|
|
814
|
-
* @type {Hex}
|
|
815
|
-
*/
|
|
816
|
-
validatorData: Hex;
|
|
817
|
-
|
|
818
|
-
/**
|
|
819
|
-
* The incentive data.
|
|
820
|
-
*
|
|
821
|
-
* @type {Hex}
|
|
822
|
-
*/
|
|
823
|
-
incentiveData: Hex;
|
|
824
|
-
}
|
|
825
|
-
|
|
826
|
-
/**
|
|
827
|
-
* Given a {@link BoostClaimData}, properly encode the initialization payload.
|
|
828
|
-
*
|
|
829
|
-
* @param {BoostClaimData} param0
|
|
830
|
-
* @param {Hex} param0.validatorData
|
|
831
|
-
* @param {Hex} param0.incentiveData
|
|
832
|
-
* @returns {Hex}
|
|
833
|
-
*/
|
|
834
|
-
export const prepareBoostClaimData = ({
|
|
835
|
-
validatorData,
|
|
836
|
-
incentiveData,
|
|
837
|
-
}: BoostClaimData) => {
|
|
838
|
-
return encodeAbiParameters(
|
|
839
|
-
[
|
|
840
|
-
{ type: 'bytes', name: 'validatorData' },
|
|
841
|
-
{ type: 'bytes', name: 'incentiveData' },
|
|
842
|
-
],
|
|
843
|
-
[validatorData, incentiveData],
|
|
844
|
-
);
|
|
845
|
-
};
|
|
846
|
-
|
|
847
|
-
/**
|
|
848
|
-
* Object representation of a {@link SignerValidatorInputParams} initialization payload
|
|
849
|
-
*
|
|
850
|
-
* @export
|
|
851
|
-
* @interface SignerValidatorInputParams
|
|
852
|
-
* @typedef {SignerValidatorInputParams}
|
|
853
|
-
*/
|
|
854
|
-
export interface SignerValidatorInputParams {
|
|
855
|
-
/**
|
|
856
|
-
* The signer address.
|
|
857
|
-
*
|
|
858
|
-
* @type {Address}
|
|
859
|
-
*/
|
|
860
|
-
signer: Address;
|
|
861
|
-
|
|
862
|
-
/**
|
|
863
|
-
* The signature data.
|
|
864
|
-
*
|
|
865
|
-
* @type {string}
|
|
866
|
-
*/
|
|
867
|
-
signature: Hex;
|
|
868
|
-
|
|
869
|
-
/**
|
|
870
|
-
* The incentive quantity.
|
|
871
|
-
*
|
|
872
|
-
* @type {number}
|
|
873
|
-
*/
|
|
874
|
-
incentiveQuantity: number;
|
|
875
|
-
}
|
|
876
|
-
|
|
877
|
-
/**
|
|
878
|
-
* Given a {@link SignerValidatorInputParams}, properly encode the initialization payload.
|
|
879
|
-
*
|
|
880
|
-
* @param {SignerValidatorInputParams} param0
|
|
881
|
-
* @param {Address} param0.signer
|
|
882
|
-
* @param {Hex} param0.signature
|
|
883
|
-
* @param {number} param0.incentiveQuantity
|
|
884
|
-
* @returns {Hex}
|
|
885
|
-
*/
|
|
886
|
-
export const prepareSignerValidatorInputParams = ({
|
|
887
|
-
signer,
|
|
888
|
-
signature,
|
|
889
|
-
incentiveQuantity,
|
|
890
|
-
}: SignerValidatorInputParams) => {
|
|
891
|
-
return encodeAbiParameters(
|
|
892
|
-
[
|
|
893
|
-
{
|
|
894
|
-
type: 'tuple',
|
|
895
|
-
name: 'SignerValidatorInputParams',
|
|
896
|
-
components: [
|
|
897
|
-
{ type: 'address', name: 'signer' },
|
|
898
|
-
{ type: 'bytes', name: 'signature' },
|
|
899
|
-
{ type: 'uint8', name: 'incentiveQuantity' },
|
|
900
|
-
],
|
|
901
|
-
},
|
|
902
|
-
],
|
|
903
|
-
[{ signer, signature, incentiveQuantity }],
|
|
904
|
-
);
|
|
905
|
-
};
|
|
906
|
-
|
|
907
|
-
/**
|
|
908
|
-
* Signer Validator Claim Data Payload
|
|
909
|
-
*
|
|
910
|
-
* @export
|
|
911
|
-
* @interface SignerValidatorClaimDataParams
|
|
912
|
-
* @typedef {SignerValidatorClaimDataParams}
|
|
913
|
-
*/
|
|
914
|
-
export interface SignerValidatorClaimDataParams {
|
|
915
|
-
/**
|
|
916
|
-
* The signer with which to sign the input
|
|
917
|
-
*
|
|
918
|
-
* @type {{
|
|
919
|
-
* account: Address;
|
|
920
|
-
* key: Hex;
|
|
921
|
-
* privateKey: PrivateKeyAccount;
|
|
922
|
-
* }}
|
|
923
|
-
*/
|
|
924
|
-
signer: {
|
|
925
|
-
account: Address;
|
|
926
|
-
key: Hex;
|
|
927
|
-
privateKey: PrivateKeyAccount;
|
|
928
|
-
};
|
|
929
|
-
/**
|
|
930
|
-
* The encoded data to provide the underlying incentive. You can use {@link prepareAllowListIncentivePayload}, {@link prepareCGDAIncentivePayload}, {@link prepareERC20IncentivePayload}, {@link prepareERC1155IncentivePayload}, or {@link preparePointsIncentivePayload}
|
|
931
|
-
*
|
|
932
|
-
* @type {Hex}
|
|
933
|
-
*/
|
|
934
|
-
incentiveData: Hex;
|
|
935
|
-
/**
|
|
936
|
-
* The chain id to target
|
|
937
|
-
*
|
|
938
|
-
* @type {number}
|
|
939
|
-
*/
|
|
940
|
-
chainId: number;
|
|
941
|
-
/**
|
|
942
|
-
* The address of the validator
|
|
943
|
-
*
|
|
944
|
-
* @type {Address}
|
|
945
|
-
*/
|
|
946
|
-
validator: Address;
|
|
947
|
-
/**
|
|
948
|
-
* The incentive quantity.
|
|
949
|
-
*
|
|
950
|
-
* @type {number}
|
|
951
|
-
*/
|
|
952
|
-
incentiveQuantity: number;
|
|
953
|
-
/**
|
|
954
|
-
* The address of the claimant
|
|
955
|
-
*
|
|
956
|
-
* @type {Address}
|
|
957
|
-
*/
|
|
958
|
-
claimant: Address;
|
|
959
|
-
/**
|
|
960
|
-
* The ID of the boost
|
|
961
|
-
*
|
|
962
|
-
* @type {bigint}
|
|
963
|
-
*/
|
|
964
|
-
boostId: bigint;
|
|
965
|
-
}
|
|
966
|
-
|
|
967
|
-
/**
|
|
968
|
-
* Signer Validator Claim Data Payload Preparation
|
|
969
|
-
*
|
|
970
|
-
* @export
|
|
971
|
-
* @async
|
|
972
|
-
* @param {SignerValidatorClaimDataParams} param0
|
|
973
|
-
* @param {{ account: Address; key: Hex; privateKey: PrivateKeyAccount; }} param0.signer
|
|
974
|
-
* @param {Hex} param0.incentiveData
|
|
975
|
-
* @param {number} param0.chainId
|
|
976
|
-
* @param {Address} param0.validator
|
|
977
|
-
* @param {number} param0.incentiveQuantity
|
|
978
|
-
* @param {Address} param0.claimant
|
|
979
|
-
* @param {bigint} param0.boostId
|
|
980
|
-
* @returns {Promise<Hex>}
|
|
981
|
-
*/
|
|
982
|
-
export async function prepareSignerValidatorClaimDataPayload({
|
|
983
|
-
signer,
|
|
984
|
-
incentiveData,
|
|
985
|
-
chainId,
|
|
986
|
-
validator,
|
|
987
|
-
incentiveQuantity,
|
|
988
|
-
claimant,
|
|
989
|
-
boostId,
|
|
990
|
-
}: SignerValidatorClaimDataParams): Promise<Hex> {
|
|
991
|
-
const domain = {
|
|
992
|
-
name: 'SignerValidator',
|
|
993
|
-
version: '1',
|
|
994
|
-
chainId: chainId,
|
|
995
|
-
verifyingContract: validator,
|
|
996
|
-
};
|
|
997
|
-
const typedData = {
|
|
998
|
-
domain,
|
|
999
|
-
types: {
|
|
1000
|
-
SignerValidatorData: [
|
|
1001
|
-
{ name: 'boostId', type: 'uint256' },
|
|
1002
|
-
{ name: 'incentiveQuantity', type: 'uint8' },
|
|
1003
|
-
{ name: 'claimant', type: 'address' },
|
|
1004
|
-
{ name: 'incentiveData', type: 'bytes' },
|
|
1005
|
-
],
|
|
1006
|
-
},
|
|
1007
|
-
primaryType: 'SignerValidatorData' as const,
|
|
1008
|
-
message: {
|
|
1009
|
-
boostId,
|
|
1010
|
-
incentiveQuantity,
|
|
1011
|
-
claimant,
|
|
1012
|
-
incentiveData: incentiveData,
|
|
1013
|
-
},
|
|
1014
|
-
};
|
|
1015
|
-
|
|
1016
|
-
const trustedSignature = await signTypedData({
|
|
1017
|
-
...typedData,
|
|
1018
|
-
privateKey: signer.key,
|
|
1019
|
-
});
|
|
1020
|
-
|
|
1021
|
-
// Prepare the claim data payload using the new helper
|
|
1022
|
-
const validatorData = prepareSignerValidatorInputParams({
|
|
1023
|
-
signer: signer.account,
|
|
1024
|
-
signature: trustedSignature,
|
|
1025
|
-
incentiveQuantity, // Adjust incentive quantity as necessary
|
|
1026
|
-
});
|
|
1027
|
-
|
|
1028
|
-
const boostClaimDataPayload = encodeAbiParameters(
|
|
1029
|
-
[
|
|
1030
|
-
{
|
|
1031
|
-
type: 'tuple',
|
|
1032
|
-
name: 'BoostClaimData',
|
|
1033
|
-
components: [
|
|
1034
|
-
{ type: 'bytes', name: 'validatorData' },
|
|
1035
|
-
{ type: 'bytes', name: 'incentiveData' },
|
|
1036
|
-
],
|
|
1037
|
-
},
|
|
1038
|
-
],
|
|
1039
|
-
[{ validatorData, incentiveData }],
|
|
1040
|
-
);
|
|
1041
|
-
|
|
1042
|
-
return boostClaimDataPayload;
|
|
1043
|
-
}
|
|
1044
|
-
|
|
1045
|
-
/**
|
|
1046
|
-
* Object representation of a {@link SimpleAllowList} initialization payload.
|
|
1047
|
-
*
|
|
1048
|
-
* @export
|
|
1049
|
-
* @interface SimpleAllowListPayload
|
|
1050
|
-
* @typedef {SimpleAllowListPayload}
|
|
1051
|
-
*/
|
|
1052
|
-
export interface SimpleAllowListPayload {
|
|
1053
|
-
/**
|
|
1054
|
-
* The allow list's owner, given the {@link LIST_MANAGER_ROLE} role.
|
|
1055
|
-
*
|
|
1056
|
-
* @type {Address}
|
|
1057
|
-
*/
|
|
1058
|
-
owner: Address;
|
|
1059
|
-
/**
|
|
1060
|
-
* List of allowed addresses.
|
|
1061
|
-
*
|
|
1062
|
-
* @type {Address[]}
|
|
1063
|
-
*/
|
|
1064
|
-
allowed: Address[];
|
|
1065
|
-
}
|
|
1066
|
-
|
|
1067
|
-
/**
|
|
1068
|
-
* Given a {@link SimpleAllowListPayload}, properly encode the initialization payload.
|
|
1069
|
-
*
|
|
1070
|
-
* @param {SimpleAllowListPayload} param0
|
|
1071
|
-
* @param {Address} param0.owner - The allow list's owner, given the {@link LIST_MANAGER_ROLE} role.
|
|
1072
|
-
* @param {Address[]} param0.allowed - List of allowed addresses.
|
|
1073
|
-
* @returns {Hex}
|
|
1074
|
-
*/
|
|
1075
|
-
export const prepareSimpleAllowListPayload = ({
|
|
1076
|
-
owner,
|
|
1077
|
-
allowed,
|
|
1078
|
-
}: SimpleAllowListPayload) => {
|
|
1079
|
-
return encodeAbiParameters(
|
|
1080
|
-
[
|
|
1081
|
-
{ type: 'address', name: 'owner' },
|
|
1082
|
-
{ type: 'address[]', name: 'allowed' },
|
|
1083
|
-
],
|
|
1084
|
-
[owner, allowed],
|
|
1085
|
-
);
|
|
1086
|
-
};
|
|
1087
|
-
|
|
1088
|
-
/**
|
|
1089
|
-
* Object representation of a {@link SimpleDenyList} initialization payload.
|
|
1090
|
-
*
|
|
1091
|
-
* @export
|
|
1092
|
-
* @interface SimpleDenyListPayload
|
|
1093
|
-
* @typedef {SimpleDenyListPayload}
|
|
1094
|
-
*/
|
|
1095
|
-
export interface SimpleDenyListPayload {
|
|
1096
|
-
/**
|
|
1097
|
-
* The allow list's owner
|
|
1098
|
-
*
|
|
1099
|
-
* @type {Address}
|
|
1100
|
-
*/
|
|
1101
|
-
owner: Address;
|
|
1102
|
-
/**
|
|
1103
|
-
* List of denied addresses.
|
|
1104
|
-
*
|
|
1105
|
-
* @type {Address[]}
|
|
1106
|
-
*/
|
|
1107
|
-
denied: Address[];
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
/**
|
|
1111
|
-
* Given a {@link SimpleDenyListPayload}, properly encode the initialization payload.
|
|
1112
|
-
*
|
|
1113
|
-
* @param {SimpleDenyListPayload} param0
|
|
1114
|
-
* @param {Address} param0.owner - The allow list's owner
|
|
1115
|
-
* @param {Address[]} param0.denied - List of denied addresses.
|
|
1116
|
-
* @returns {Hex}
|
|
1117
|
-
*/
|
|
1118
|
-
export const prepareSimpleDenyListPayload = ({
|
|
1119
|
-
owner,
|
|
1120
|
-
denied,
|
|
1121
|
-
}: SimpleDenyListPayload) => {
|
|
1122
|
-
return encodeAbiParameters(
|
|
1123
|
-
[
|
|
1124
|
-
{ type: 'address', name: 'owner' },
|
|
1125
|
-
{ type: 'address[]', name: 'denied' },
|
|
1126
|
-
],
|
|
1127
|
-
[owner, denied],
|
|
1128
|
-
);
|
|
1129
|
-
};
|
|
1130
|
-
|
|
1131
|
-
/**
|
|
1132
|
-
* Object representation of `BoostCore.InitPayload` struct.
|
|
1133
|
-
*
|
|
1134
|
-
* @export
|
|
1135
|
-
* @interface BoostPayload
|
|
1136
|
-
* @typedef {BoostPayload}
|
|
1137
|
-
*/
|
|
1138
|
-
export interface BoostPayload {
|
|
1139
|
-
/**
|
|
1140
|
-
* Address to valid budget.
|
|
1141
|
-
*
|
|
1142
|
-
* @type {Address}
|
|
1143
|
-
*/
|
|
1144
|
-
budget: Address;
|
|
1145
|
-
/**
|
|
1146
|
-
* Target for existing action, or base with initialization payload.
|
|
1147
|
-
*
|
|
1148
|
-
* @type {Target}
|
|
1149
|
-
*/
|
|
1150
|
-
action: Target;
|
|
1151
|
-
/**
|
|
1152
|
-
* Target for existing validator, or base with initialization payload.
|
|
1153
|
-
*
|
|
1154
|
-
* @type {Target}
|
|
1155
|
-
*/
|
|
1156
|
-
validator: Target;
|
|
1157
|
-
/**
|
|
1158
|
-
* Target for existing allowList, or base with initialization payload.
|
|
1159
|
-
*
|
|
1160
|
-
* @type {Target}
|
|
1161
|
-
*/
|
|
1162
|
-
allowList: Target;
|
|
1163
|
-
/**
|
|
1164
|
-
* Targets for new incentives, with initialization payloads.
|
|
1165
|
-
*
|
|
1166
|
-
* @type {Target[]}
|
|
1167
|
-
*/
|
|
1168
|
-
incentives: Target[];
|
|
1169
|
-
/**
|
|
1170
|
-
* The base protocol fee (in bps)
|
|
1171
|
-
*
|
|
1172
|
-
* @type {?bigint}
|
|
1173
|
-
*/
|
|
1174
|
-
protocolFee?: bigint;
|
|
1175
|
-
/**
|
|
1176
|
-
* The base referral fee (in bps)
|
|
1177
|
-
*
|
|
1178
|
-
* @type {?bigint}
|
|
1179
|
-
*/
|
|
1180
|
-
referralFee?: bigint;
|
|
1181
|
-
/**
|
|
1182
|
-
* Optional maximum amount of participants in the Boost.
|
|
1183
|
-
*
|
|
1184
|
-
* @type {?bigint}
|
|
1185
|
-
*/
|
|
1186
|
-
maxParticipants?: bigint;
|
|
1187
|
-
/**
|
|
1188
|
-
* The owner of the Boost.
|
|
1189
|
-
*
|
|
1190
|
-
* @type {Address}
|
|
1191
|
-
*/
|
|
1192
|
-
owner: Address;
|
|
1193
|
-
}
|
|
1194
|
-
|
|
1195
|
-
/**
|
|
1196
|
-
* Given a valid {@link BoostPayload}, properly encode and compress the payload for use with `createBoost`
|
|
1197
|
-
*
|
|
1198
|
-
* @export
|
|
1199
|
-
* @param {BoostPayload} param0
|
|
1200
|
-
* @param {Address} param0.budget - Address to valid budget.
|
|
1201
|
-
* @param {Target} param0.action - Target for existing action, or base with initialization payload.
|
|
1202
|
-
* @param {Target} param0.validator - Target for existing validator, or base with initialization payload.
|
|
1203
|
-
* @param {Target} param0.allowList - Target for existing allowList, or base with initialization payload.
|
|
1204
|
-
* @param {Target[]} param0.incentives - Targets for new incentives, with initialization payloads.
|
|
1205
|
-
* @param {bigint} [param0.protocolFee=0n] - The base protocol fee (in bps)
|
|
1206
|
-
* @param {bigint} [param0.referralFee=0n] - The base referral fee (in bps)
|
|
1207
|
-
* @param {bigint} [param0.maxParticipants=0n] - Optional maximum amount of participants in the Boost.
|
|
1208
|
-
* @param {Address} param0.owner - The owner of the Boost.
|
|
1209
|
-
* @returns {Hex}
|
|
211
|
+
* @param {Config} config
|
|
212
|
+
* @param {Record<string, Address>} addressByChainId
|
|
213
|
+
* @param {number} desiredChainId
|
|
214
|
+
* @returns {{ chainId: number, address: Address }}
|
|
215
|
+
* @throws {@link InvalidProtocolChainIdError}
|
|
1210
216
|
*/
|
|
1211
|
-
export function
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
}
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
{
|
|
1231
|
-
budget,
|
|
1232
|
-
action,
|
|
1233
|
-
validator,
|
|
1234
|
-
allowList,
|
|
1235
|
-
incentives,
|
|
1236
|
-
protocolFee,
|
|
1237
|
-
referralFee,
|
|
1238
|
-
maxParticipants,
|
|
1239
|
-
owner,
|
|
1240
|
-
},
|
|
1241
|
-
],
|
|
1242
|
-
),
|
|
1243
|
-
) as Hex;
|
|
1244
|
-
}
|
|
1245
|
-
|
|
1246
|
-
/**
|
|
1247
|
-
* Object representation of
|
|
1248
|
-
*
|
|
1249
|
-
* @export
|
|
1250
|
-
* @interface ERC1155Payload
|
|
1251
|
-
* @typedef {ERC1155Payload}
|
|
1252
|
-
*/
|
|
1253
|
-
export interface ERC1155Payload {
|
|
1254
|
-
/**
|
|
1255
|
-
* The ERC1155 token ID for the incentive
|
|
1256
|
-
*
|
|
1257
|
-
* @type {bigint}
|
|
1258
|
-
*/
|
|
1259
|
-
tokenId: bigint;
|
|
1260
|
-
/**
|
|
1261
|
-
* The amount to transfer
|
|
1262
|
-
*
|
|
1263
|
-
* @type {bigint}
|
|
1264
|
-
*/
|
|
1265
|
-
amount: bigint;
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
/**
|
|
1269
|
-
* Given a token ID and amount, properly encode a `ERC1155Incentive.ERC1155Payload` for use with {@link ERC1155Incentive} initialization.
|
|
1270
|
-
*
|
|
1271
|
-
* @export
|
|
1272
|
-
* @param {ERC1155Payload} param0
|
|
1273
|
-
* @param {bigint} param0.tokenId - The ERC1155 token ID for the incentive
|
|
1274
|
-
* @param {bigint} param0.amount - The amount to transfer
|
|
1275
|
-
* @returns {Hex}
|
|
1276
|
-
*/
|
|
1277
|
-
export function prepareERC1155Payload({ tokenId, amount }: ERC1155Payload) {
|
|
1278
|
-
return encodeAbiParameters(
|
|
1279
|
-
parseAbiParameters([
|
|
1280
|
-
'ERC1155Payload payload',
|
|
1281
|
-
'struct ERC1155Payload { uint256 tokenId; uint256 amount; bytes data; }',
|
|
1282
|
-
]),
|
|
1283
|
-
[{ tokenId, amount, data: '0x' }],
|
|
1284
|
-
);
|
|
1285
|
-
}
|
|
1286
|
-
|
|
1287
|
-
/**
|
|
1288
|
-
* The object representation of a `PointsIncentive.InitPayload`
|
|
1289
|
-
*
|
|
1290
|
-
* @export
|
|
1291
|
-
* @interface PointsIncentivePayload
|
|
1292
|
-
* @typedef {PointsIncentivePayload}
|
|
1293
|
-
*/
|
|
1294
|
-
export interface PointsIncentivePayload {
|
|
1295
|
-
/**
|
|
1296
|
-
* The address of the points contract
|
|
1297
|
-
*
|
|
1298
|
-
* @type {Address}
|
|
1299
|
-
*/
|
|
1300
|
-
venue: Address;
|
|
1301
|
-
/**
|
|
1302
|
-
* The selector for the issuance function on the points contract
|
|
1303
|
-
*
|
|
1304
|
-
* @type {Hex}
|
|
1305
|
-
*/
|
|
1306
|
-
selector: Hex;
|
|
1307
|
-
/**
|
|
1308
|
-
* The reward amount issued for each claim
|
|
1309
|
-
*
|
|
1310
|
-
* @type {bigint}
|
|
1311
|
-
*/
|
|
1312
|
-
reward: bigint;
|
|
1313
|
-
/**
|
|
1314
|
-
* The maximum number of claims that can be made (one per address)
|
|
1315
|
-
*
|
|
1316
|
-
* @type {bigint}
|
|
1317
|
-
*/
|
|
1318
|
-
limit: bigint;
|
|
1319
|
-
}
|
|
1320
|
-
|
|
1321
|
-
/**
|
|
1322
|
-
* Given a {@link PointsIncentivePayload}, properly encode a `PointsIncentive.InitPayload` for use with {@link PointsIncentive} initialization.
|
|
1323
|
-
*
|
|
1324
|
-
* @param {PointsIncentivePayload} param0
|
|
1325
|
-
* @param {Address} param0.venue - The address of the points contract
|
|
1326
|
-
* @param {Hex} param0.selector - The selector for the issuance function on the points contract
|
|
1327
|
-
* @param {bigint} param0.reward - The reward amount issued for each claim
|
|
1328
|
-
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
1329
|
-
* @returns {*}
|
|
1330
|
-
*/
|
|
1331
|
-
export const preparePointsIncentivePayload = ({
|
|
1332
|
-
venue,
|
|
1333
|
-
selector,
|
|
1334
|
-
reward,
|
|
1335
|
-
limit,
|
|
1336
|
-
}: PointsIncentivePayload) => {
|
|
1337
|
-
return encodeAbiParameters(
|
|
1338
|
-
[
|
|
1339
|
-
{ type: 'address', name: 'venue' },
|
|
1340
|
-
{ type: 'bytes4', name: 'selector' },
|
|
1341
|
-
{ type: 'uint256', name: 'reward' },
|
|
1342
|
-
{ type: 'uint256', name: 'limit' },
|
|
1343
|
-
],
|
|
1344
|
-
[venue, selector, reward, limit],
|
|
1345
|
-
);
|
|
1346
|
-
};
|
|
1347
|
-
|
|
1348
|
-
/**
|
|
1349
|
-
* The configuration parameters for the CGDAIncentive
|
|
1350
|
-
*
|
|
1351
|
-
* @export
|
|
1352
|
-
* @interface CGDAParameters
|
|
1353
|
-
* @typedef {CGDAParameters}
|
|
1354
|
-
*/
|
|
1355
|
-
export interface CGDAParameters {
|
|
1356
|
-
/**
|
|
1357
|
-
* The amount to subtract from the current reward after each claim
|
|
1358
|
-
*
|
|
1359
|
-
* @type {bigint}
|
|
1360
|
-
*/
|
|
1361
|
-
rewardDecay: bigint;
|
|
1362
|
-
/**
|
|
1363
|
-
* The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
1364
|
-
*
|
|
1365
|
-
* @type {bigint}
|
|
1366
|
-
*/
|
|
1367
|
-
rewardBoost: bigint;
|
|
1368
|
-
/**
|
|
1369
|
-
* The timestamp of the last claim
|
|
1370
|
-
*
|
|
1371
|
-
* @type {bigint}
|
|
1372
|
-
*/
|
|
1373
|
-
lastClaimTime: bigint;
|
|
1374
|
-
/**
|
|
1375
|
-
* The current reward amount
|
|
1376
|
-
*
|
|
1377
|
-
* @type {bigint}
|
|
1378
|
-
*/
|
|
1379
|
-
currentReward: bigint;
|
|
1380
|
-
}
|
|
1381
|
-
|
|
1382
|
-
/**
|
|
1383
|
-
* The object representation of a `CGDAIncentive.InitPayload`
|
|
1384
|
-
*
|
|
1385
|
-
* @export
|
|
1386
|
-
* @interface CGDAIncentivePayload
|
|
1387
|
-
* @typedef {CGDAIncentivePayload}
|
|
1388
|
-
*/
|
|
1389
|
-
export interface CGDAIncentivePayload {
|
|
1390
|
-
/**
|
|
1391
|
-
* The address of the ERC20-like token
|
|
1392
|
-
*
|
|
1393
|
-
* @type {Address}
|
|
1394
|
-
*/
|
|
1395
|
-
asset: Address;
|
|
1396
|
-
/**
|
|
1397
|
-
* The initial reward amount
|
|
1398
|
-
*
|
|
1399
|
-
* @type {bigint}
|
|
1400
|
-
*/
|
|
1401
|
-
initialReward: bigint;
|
|
1402
|
-
/**
|
|
1403
|
-
* The amount to subtract from the current reward after each claim
|
|
1404
|
-
*
|
|
1405
|
-
* @type {bigint}
|
|
1406
|
-
*/
|
|
1407
|
-
rewardDecay: bigint;
|
|
1408
|
-
/**
|
|
1409
|
-
* The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
1410
|
-
*
|
|
1411
|
-
* @type {bigint}
|
|
1412
|
-
*/
|
|
1413
|
-
rewardBoost: bigint;
|
|
1414
|
-
/**
|
|
1415
|
-
* The total budget for the incentive
|
|
1416
|
-
*
|
|
1417
|
-
* @type {bigint}
|
|
1418
|
-
*/
|
|
1419
|
-
totalBudget: bigint;
|
|
1420
|
-
}
|
|
1421
|
-
|
|
1422
|
-
/**
|
|
1423
|
-
* Given a {@link CGDAIncentivePayload}, properly encode a `CGDAIncentive.InitPayload` for use with {@link CGDAIncentive} initialization.
|
|
1424
|
-
*
|
|
1425
|
-
* @param {CGDAIncentivePayload} param0
|
|
1426
|
-
* @param {Address} param0.asset - The address of the ERC20-like token
|
|
1427
|
-
* @param {bigint} param0.initialReward - The initial reward amount
|
|
1428
|
-
* @param {bigint} param0.rewardDecay - The amount to subtract from the current reward after each claim
|
|
1429
|
-
* @param {bigint} param0.rewardBoost - The amount by which the reward increases for each hour without a claim (continuous linear increase)
|
|
1430
|
-
* @param {bigint} param0.totalBudget - The total budget for the incentive
|
|
1431
|
-
* @returns {Hex}
|
|
1432
|
-
*/
|
|
1433
|
-
export const prepareCGDAIncentivePayload = ({
|
|
1434
|
-
asset,
|
|
1435
|
-
initialReward,
|
|
1436
|
-
rewardDecay,
|
|
1437
|
-
rewardBoost,
|
|
1438
|
-
totalBudget,
|
|
1439
|
-
}: CGDAIncentivePayload) => {
|
|
1440
|
-
return encodeAbiParameters(
|
|
1441
|
-
[
|
|
1442
|
-
{ type: 'address', name: 'asset' },
|
|
1443
|
-
{ type: 'uint256', name: 'initialReward' },
|
|
1444
|
-
{ type: 'uint256', name: 'rewardDecay' },
|
|
1445
|
-
{ type: 'uint256', name: 'rewardBoost' },
|
|
1446
|
-
{ type: 'uint256', name: 'totalBudget' },
|
|
1447
|
-
],
|
|
1448
|
-
[asset, initialReward, rewardDecay, rewardBoost, totalBudget],
|
|
1449
|
-
);
|
|
1450
|
-
};
|
|
1451
|
-
|
|
1452
|
-
/**
|
|
1453
|
-
* The object representation of a `ERC1155Incentive.InitPayload`
|
|
1454
|
-
*
|
|
1455
|
-
* @export
|
|
1456
|
-
* @interface ERC1155IncentivePayload
|
|
1457
|
-
* @typedef {ERC1155IncentivePayload}
|
|
1458
|
-
*/
|
|
1459
|
-
export interface ERC1155IncentivePayload {
|
|
1460
|
-
/**
|
|
1461
|
-
* The address of the `ERC1155` asset
|
|
1462
|
-
*
|
|
1463
|
-
* @type {Address}
|
|
1464
|
-
*/
|
|
1465
|
-
asset: Address;
|
|
1466
|
-
/**
|
|
1467
|
-
* Should be `Strategy.POOL`
|
|
1468
|
-
*
|
|
1469
|
-
* @type {ERC1155StrategyType}
|
|
1470
|
-
*/
|
|
1471
|
-
strategy: ERC1155StrategyType;
|
|
1472
|
-
/**
|
|
1473
|
-
* The token ID to target
|
|
1474
|
-
*
|
|
1475
|
-
* @type {bigint}
|
|
1476
|
-
*/
|
|
1477
|
-
tokenId: bigint;
|
|
1478
|
-
/**
|
|
1479
|
-
* The maximum number of claims that can be made (one per address)
|
|
1480
|
-
*
|
|
1481
|
-
* @type {bigint}
|
|
1482
|
-
*/
|
|
1483
|
-
limit: bigint;
|
|
1484
|
-
/**
|
|
1485
|
-
* Any extra data to accompany the claim, if applicable.
|
|
1486
|
-
*
|
|
1487
|
-
* @type {Hex}
|
|
1488
|
-
*/
|
|
1489
|
-
extraData: Hex;
|
|
1490
|
-
}
|
|
1491
|
-
|
|
1492
|
-
/**
|
|
1493
|
-
* Given a {@link ERC1155IncentivePayload}, properly encode a `ERC1155Incentive.InitPayload` for use with {@link ERC1155Incentive} initialization.
|
|
1494
|
-
*
|
|
1495
|
-
* @param {ERC1155IncentivePayload} param0
|
|
1496
|
-
* @param {Address} param0.asset - The address of the `ERC1155` asset
|
|
1497
|
-
* @param {ERC1155StrategyType} param0.strategy - Should be `Strategy.POOL`
|
|
1498
|
-
* @param {bigint} param0.tokenId - The token ID to target
|
|
1499
|
-
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
1500
|
-
* @param {Hex} param0.extraData - Any extra data to accompany the claim, if applicable.
|
|
1501
|
-
* @returns {Hex}
|
|
1502
|
-
*/
|
|
1503
|
-
export const prepareERC1155IncentivePayload = ({
|
|
1504
|
-
asset,
|
|
1505
|
-
strategy,
|
|
1506
|
-
tokenId,
|
|
1507
|
-
limit,
|
|
1508
|
-
extraData,
|
|
1509
|
-
}: ERC1155IncentivePayload) => {
|
|
1510
|
-
return encodeAbiParameters(
|
|
1511
|
-
parseAbiParameters([
|
|
1512
|
-
'InitPayload payload',
|
|
1513
|
-
'struct InitPayload { address asset; uint8 strategy; uint256 tokenId; uint256 limit; bytes extraData; }',
|
|
1514
|
-
]),
|
|
1515
|
-
[{ asset, strategy, tokenId, limit, extraData }],
|
|
1516
|
-
);
|
|
1517
|
-
// return encodeAbiParameters(
|
|
1518
|
-
// [
|
|
1519
|
-
// { type: 'address', name: 'asset' },
|
|
1520
|
-
// { type: 'uint8', name: 'strategy' },
|
|
1521
|
-
// { type: 'uint256', name: 'tokenId' },
|
|
1522
|
-
// { type: 'uint256', name: 'limit' },
|
|
1523
|
-
// { type: 'bytes', name: 'extraData' },
|
|
1524
|
-
// ],
|
|
1525
|
-
// [asset, strategy, tokenId, limit, extraData],
|
|
1526
|
-
// );
|
|
1527
|
-
};
|
|
1528
|
-
|
|
1529
|
-
/**
|
|
1530
|
-
* The object representation of a `AllowListIncentive.InitPayload`
|
|
1531
|
-
*
|
|
1532
|
-
* @export
|
|
1533
|
-
* @interface AllowListIncentivePayload
|
|
1534
|
-
* @typedef {AllowListIncentivePayload}
|
|
1535
|
-
*/
|
|
1536
|
-
export interface AllowListIncentivePayload {
|
|
1537
|
-
/**
|
|
1538
|
-
* The address to the allowlist to add claimers to.
|
|
1539
|
-
*
|
|
1540
|
-
* @type {Address}
|
|
1541
|
-
*/
|
|
1542
|
-
allowList: Address;
|
|
1543
|
-
/**
|
|
1544
|
-
* The maximum number of claims that can be made (one per address)
|
|
1545
|
-
*
|
|
1546
|
-
* @type {bigint}
|
|
1547
|
-
*/
|
|
1548
|
-
limit: bigint;
|
|
1549
|
-
}
|
|
1550
|
-
|
|
1551
|
-
/**
|
|
1552
|
-
* Given a {@link AllowListIncentivePayload}, properly encode a `AllowListIncentive.InitPayload` for use with {@link AllowListIncentive} initialization.
|
|
1553
|
-
*
|
|
1554
|
-
* @param {AllowListIncentivePayload} param0
|
|
1555
|
-
* @param {Address} param0.allowList - The address to the allowlist to add claimers to.
|
|
1556
|
-
* @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
|
|
1557
|
-
* @returns {Hex}
|
|
1558
|
-
*/
|
|
1559
|
-
export const prepareAllowListIncentivePayload = ({
|
|
1560
|
-
allowList,
|
|
1561
|
-
limit,
|
|
1562
|
-
}: AllowListIncentivePayload) => {
|
|
1563
|
-
return encodeAbiParameters(
|
|
1564
|
-
[
|
|
1565
|
-
{ type: 'address', name: 'allowList' },
|
|
1566
|
-
{ type: 'uint256', name: 'limit' },
|
|
1567
|
-
],
|
|
1568
|
-
[allowList, limit],
|
|
1569
|
-
);
|
|
1570
|
-
};
|
|
1571
|
-
|
|
1572
|
-
/**
|
|
1573
|
-
* The object representation of a `ERC20Incentive.InitPayload`
|
|
1574
|
-
*
|
|
1575
|
-
* @export
|
|
1576
|
-
* @interface ERC20IncentivePayload
|
|
1577
|
-
* @typedef {ERC20IncentivePayload}
|
|
1578
|
-
*/
|
|
1579
|
-
export interface ERC20IncentivePayload {
|
|
1580
|
-
/**
|
|
1581
|
-
* The address of the incentivized asset.
|
|
1582
|
-
*
|
|
1583
|
-
* @type {Address}
|
|
1584
|
-
*/
|
|
1585
|
-
asset: Address;
|
|
1586
|
-
/**
|
|
1587
|
-
* The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
1588
|
-
*
|
|
1589
|
-
* @type {StrategyType}
|
|
1590
|
-
*/
|
|
1591
|
-
strategy: StrategyType;
|
|
1592
|
-
/**
|
|
1593
|
-
* The amount of the asset to distribute.
|
|
1594
|
-
*
|
|
1595
|
-
* @type {bigint}
|
|
1596
|
-
*/
|
|
1597
|
-
reward: bigint;
|
|
1598
|
-
/**
|
|
1599
|
-
* How many times can this incentive be claimed.
|
|
1600
|
-
*
|
|
1601
|
-
* @type {bigint}
|
|
1602
|
-
*/
|
|
1603
|
-
limit: bigint;
|
|
1604
|
-
}
|
|
1605
|
-
|
|
1606
|
-
/**
|
|
1607
|
-
* Given a {@link ERC20IncentivePayload}, properly encode a `ERC20Incentive.InitPayload` for use with {@link ERC20Incentive} initialization.
|
|
1608
|
-
*
|
|
1609
|
-
* @param {ERC20IncentivePayload} param0
|
|
1610
|
-
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
1611
|
-
* @param {StrategyType} param0.strategy - The type of disbursement strategy for the incentive. `StrategyType.MINT` is not supported for `ERC20Incentives`
|
|
1612
|
-
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
1613
|
-
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
1614
|
-
* @returns {*}
|
|
1615
|
-
*/
|
|
1616
|
-
export const prepareERC20IncentivePayload = ({
|
|
1617
|
-
asset,
|
|
1618
|
-
strategy,
|
|
1619
|
-
reward,
|
|
1620
|
-
limit,
|
|
1621
|
-
}: ERC20IncentivePayload) => {
|
|
1622
|
-
return encodeAbiParameters(
|
|
1623
|
-
[
|
|
1624
|
-
{ type: 'address', name: 'asset' },
|
|
1625
|
-
{ type: 'uint8', name: 'strategy' },
|
|
1626
|
-
{ type: 'uint256', name: 'reward' },
|
|
1627
|
-
{ type: 'uint256', name: 'limit' },
|
|
1628
|
-
],
|
|
1629
|
-
[asset, strategy, reward, limit],
|
|
1630
|
-
);
|
|
1631
|
-
};
|
|
1632
|
-
|
|
1633
|
-
/**
|
|
1634
|
-
* The object representation of a `ERC20VariableIncentivePayload.InitPayload`
|
|
1635
|
-
*
|
|
1636
|
-
* @export
|
|
1637
|
-
* @interface ERC20VariableIncentivePayload
|
|
1638
|
-
* @typedef {ERC20VariableIncentivePayload}
|
|
1639
|
-
*/
|
|
1640
|
-
export interface ERC20VariableIncentivePayload {
|
|
1641
|
-
/**
|
|
1642
|
-
* The address of the incentivized asset.
|
|
1643
|
-
*
|
|
1644
|
-
* @type {Address}
|
|
1645
|
-
*/
|
|
1646
|
-
asset: Address;
|
|
1647
|
-
/**
|
|
1648
|
-
* The amount of the asset to distribute.
|
|
1649
|
-
*
|
|
1650
|
-
* @type {bigint}
|
|
1651
|
-
*/
|
|
1652
|
-
reward: bigint;
|
|
1653
|
-
/**
|
|
1654
|
-
* How many times can this incentive be claimed.
|
|
1655
|
-
*
|
|
1656
|
-
* @type {bigint}
|
|
1657
|
-
*/
|
|
1658
|
-
limit: bigint;
|
|
1659
|
-
}
|
|
1660
|
-
|
|
1661
|
-
/**
|
|
1662
|
-
* Given a {@link ERC20VariableIncentivePayload}, properly encode a ` ERC20VariableIncentive.InitPayload` for use with {@link ERC20VariableIncentive} initialization.
|
|
1663
|
-
*
|
|
1664
|
-
* @param {ERC20VariableIncentivePayload} param0
|
|
1665
|
-
* @param {Address} param0.asset - The address of the incentivized asset.
|
|
1666
|
-
* @param {bigint} param0.reward - The amount of the asset to distribute.
|
|
1667
|
-
* @param {bigint} param0.limit - How many times can this incentive be claimed.
|
|
1668
|
-
* @returns {*}
|
|
1669
|
-
*/
|
|
1670
|
-
export const prepareERC20VariableIncentivePayload = ({
|
|
1671
|
-
asset,
|
|
1672
|
-
reward,
|
|
1673
|
-
limit,
|
|
1674
|
-
}: ERC20VariableIncentivePayload) => {
|
|
1675
|
-
return encodeAbiParameters(
|
|
1676
|
-
[
|
|
1677
|
-
{ type: 'address', name: 'asset' },
|
|
1678
|
-
{ type: 'uint256', name: 'reward' },
|
|
1679
|
-
{ type: 'uint256', name: 'limit' },
|
|
1680
|
-
],
|
|
1681
|
-
[asset, reward, limit],
|
|
1682
|
-
);
|
|
1683
|
-
};
|
|
1684
|
-
|
|
1685
|
-
/**
|
|
1686
|
-
* The object representation of a `ContractAction.InitPayload`
|
|
1687
|
-
*
|
|
1688
|
-
* @export
|
|
1689
|
-
* @interface ContractActionPayload
|
|
1690
|
-
* @typedef {ContractActionPayload}
|
|
1691
|
-
*/
|
|
1692
|
-
export interface ContractActionPayload {
|
|
1693
|
-
/**
|
|
1694
|
-
* The chain ID on which the target exists
|
|
1695
|
-
*
|
|
1696
|
-
* @type {bigint}
|
|
1697
|
-
*/
|
|
1698
|
-
chainId: bigint;
|
|
1699
|
-
/**
|
|
1700
|
-
* The target contract address
|
|
1701
|
-
*
|
|
1702
|
-
* @type {Address}
|
|
1703
|
-
*/
|
|
1704
|
-
target: Address;
|
|
1705
|
-
/**
|
|
1706
|
-
* The selector for the function to be called
|
|
1707
|
-
*
|
|
1708
|
-
* @type {Hex}
|
|
1709
|
-
*/
|
|
1710
|
-
selector: Hex;
|
|
1711
|
-
/**
|
|
1712
|
-
* The native token value to send with the function call
|
|
1713
|
-
*
|
|
1714
|
-
* @type {bigint}
|
|
1715
|
-
*/
|
|
1716
|
-
value: bigint;
|
|
1717
|
-
}
|
|
1718
|
-
|
|
1719
|
-
/**
|
|
1720
|
-
* `ERC721MintActionPayload` is a re-exported `ContractActionPayload`
|
|
1721
|
-
*
|
|
1722
|
-
* @export
|
|
1723
|
-
* @typedef {ERC721MintActionPayload}
|
|
1724
|
-
*/
|
|
1725
|
-
export type ERC721MintActionPayload = ContractActionPayload;
|
|
1726
|
-
|
|
1727
|
-
/**
|
|
1728
|
-
* The object representation of a `SimpleBudgetPayload.InitPayload`
|
|
1729
|
-
*
|
|
1730
|
-
* @export
|
|
1731
|
-
* @interface SimpleBudgetPayload
|
|
1732
|
-
* @typedef {SimpleBudgetPayload}
|
|
1733
|
-
*/
|
|
1734
|
-
export interface SimpleBudgetPayload {
|
|
1735
|
-
/**
|
|
1736
|
-
* The budget's owner
|
|
1737
|
-
*
|
|
1738
|
-
* @type {Address}
|
|
1739
|
-
*/
|
|
1740
|
-
owner: Address;
|
|
1741
|
-
/**
|
|
1742
|
-
* List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
1743
|
-
*
|
|
1744
|
-
* @type {Address[]}
|
|
1745
|
-
*/
|
|
1746
|
-
authorized: Address[];
|
|
1747
|
-
}
|
|
1748
|
-
|
|
1749
|
-
/**
|
|
1750
|
-
* Given a {@link SimpleBudgetPayload}, properly encode a `SimpleBudget.InitPayload` for use with {@link SimpleBudget} initialization.
|
|
1751
|
-
*
|
|
1752
|
-
* @param {SimpleBudgetPayload} param0
|
|
1753
|
-
* @param {Address} param0.owner - The budget's owner
|
|
1754
|
-
* @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
1755
|
-
* @returns {*}
|
|
1756
|
-
*/
|
|
1757
|
-
export const prepareSimpleBudgetPayload = ({
|
|
1758
|
-
owner,
|
|
1759
|
-
authorized,
|
|
1760
|
-
}: SimpleBudgetPayload) => {
|
|
1761
|
-
return encodeAbiParameters(
|
|
1762
|
-
parseAbiParameters([
|
|
1763
|
-
'SimpleBudgetPayload payload',
|
|
1764
|
-
'struct SimpleBudgetPayload { address owner; address[] authorized; }',
|
|
1765
|
-
]),
|
|
1766
|
-
[{ owner, authorized }],
|
|
1767
|
-
);
|
|
1768
|
-
};
|
|
1769
|
-
|
|
1770
|
-
/**
|
|
1771
|
-
* The object representation of a `ManagedBudgetPayload.InitPayload`
|
|
1772
|
-
*
|
|
1773
|
-
* @export
|
|
1774
|
-
* @interface ManagedBudgetPayload
|
|
1775
|
-
* @typedef {ManagedBudgetPayload}
|
|
1776
|
-
*/
|
|
1777
|
-
export interface ManagedBudgetPayload {
|
|
1778
|
-
/**
|
|
1779
|
-
* The budget's owner
|
|
1780
|
-
*
|
|
1781
|
-
* @type {Address}
|
|
1782
|
-
*/
|
|
1783
|
-
owner: Address;
|
|
1784
|
-
/**
|
|
1785
|
-
* List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
1786
|
-
*
|
|
1787
|
-
* @type {Address[]}
|
|
1788
|
-
*/
|
|
1789
|
-
authorized: Address[];
|
|
1790
|
-
/**
|
|
1791
|
-
* List of roles to assign to the corresponding account by index.
|
|
1792
|
-
*
|
|
1793
|
-
* @type {bigint[]}
|
|
1794
|
-
*/
|
|
1795
|
-
roles: bigint[];
|
|
1796
|
-
}
|
|
1797
|
-
|
|
1798
|
-
/**
|
|
1799
|
-
* Given a {@link ManagedBudgetPayload}, properly encode a `ManagedBudget.InitPayload` for use with {@link ManagedBudget} initialization.
|
|
1800
|
-
*
|
|
1801
|
-
* @param {ManagedBudgetPayload} param0
|
|
1802
|
-
* @param {Address} param0.owner - The budget's owner
|
|
1803
|
-
* @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
1804
|
-
* @param {{}} param0.roles - List of roles to assign to the corresponding account by index.
|
|
1805
|
-
* @returns {*}
|
|
1806
|
-
*/
|
|
1807
|
-
export const prepareManagedBudgetPayload = ({
|
|
1808
|
-
owner,
|
|
1809
|
-
authorized,
|
|
1810
|
-
roles,
|
|
1811
|
-
}: ManagedBudgetPayload) => {
|
|
1812
|
-
return encodeAbiParameters(
|
|
1813
|
-
parseAbiParameters([
|
|
1814
|
-
'ManagedBudgetPayload payload',
|
|
1815
|
-
'struct ManagedBudgetPayload { address owner; address[] authorized; uint256[] roles; }',
|
|
1816
|
-
]),
|
|
1817
|
-
[{ owner, authorized, roles }],
|
|
1818
|
-
);
|
|
1819
|
-
};
|
|
1820
|
-
|
|
1821
|
-
/**
|
|
1822
|
-
* The object representation of a `VestingBudget.InitPayload`
|
|
1823
|
-
*
|
|
1824
|
-
* @export
|
|
1825
|
-
* @interface VestingBudgetPayload
|
|
1826
|
-
* @typedef {VestingBudgetPayload}
|
|
1827
|
-
*/
|
|
1828
|
-
export interface VestingBudgetPayload {
|
|
1829
|
-
/**
|
|
1830
|
-
* The budget's owner.
|
|
1831
|
-
*
|
|
1832
|
-
* @type {Address}
|
|
1833
|
-
*/
|
|
1834
|
-
owner: Address;
|
|
1835
|
-
/**
|
|
1836
|
-
* List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
1837
|
-
*
|
|
1838
|
-
* @type {Address[]}
|
|
1839
|
-
*/
|
|
1840
|
-
authorized: Address[];
|
|
1841
|
-
/**
|
|
1842
|
-
* The timestamp at which the vesting schedule begins
|
|
1843
|
-
*
|
|
1844
|
-
* @type {bigint}
|
|
1845
|
-
*/
|
|
1846
|
-
start: bigint;
|
|
1847
|
-
/**
|
|
1848
|
-
* The duration of the vesting schedule (in seconds)
|
|
1849
|
-
*
|
|
1850
|
-
* @type {bigint}
|
|
1851
|
-
*/
|
|
1852
|
-
duration: bigint;
|
|
1853
|
-
/**
|
|
1854
|
-
* The duration of the cliff period (in seconds)
|
|
1855
|
-
*
|
|
1856
|
-
* @type {bigint}
|
|
1857
|
-
*/
|
|
1858
|
-
cliff: bigint;
|
|
1859
|
-
}
|
|
1860
|
-
|
|
1861
|
-
/**
|
|
1862
|
-
* Given a {@link VestingBudgetPayload}, properly encode a `VestingBudget.InitPayload` for use with {@link VestingBudget} initialization.
|
|
1863
|
-
*
|
|
1864
|
-
* @param {VestingBudgetPayload} param0
|
|
1865
|
-
* @param {Address} param0.owner - The budget's owner.
|
|
1866
|
-
* @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.
|
|
1867
|
-
* @param {bigint} param0.start - The timestamp at which the vesting schedule begins
|
|
1868
|
-
* @param {bigint} param0.duration - The duration of the vesting schedule (in seconds)
|
|
1869
|
-
* @param {bigint} param0.cliff - The duration of the cliff period (in seconds)
|
|
1870
|
-
* @returns {Hex}
|
|
1871
|
-
*/
|
|
1872
|
-
export const prepareVestingBudgetPayload = ({
|
|
1873
|
-
owner,
|
|
1874
|
-
authorized,
|
|
1875
|
-
start,
|
|
1876
|
-
duration,
|
|
1877
|
-
cliff,
|
|
1878
|
-
}: VestingBudgetPayload) => {
|
|
1879
|
-
return encodeAbiParameters(
|
|
1880
|
-
parseAbiParameters([
|
|
1881
|
-
'VestingBudgetPayload payload',
|
|
1882
|
-
'struct VestingBudgetPayload { address owner; address[] authorized; uint64 start; uint64 duration; uint64 cliff; }',
|
|
1883
|
-
]),
|
|
1884
|
-
[{ owner, authorized, start, duration, cliff }],
|
|
1885
|
-
);
|
|
1886
|
-
};
|
|
1887
|
-
|
|
1888
|
-
/**
|
|
1889
|
-
* Given a {@link ContractActionPayload}, properly encode a `ContractAction.InitPayload` for use with {@link ContractAction} initialization.
|
|
1890
|
-
*
|
|
1891
|
-
* @param {ContractActionPayload} param0
|
|
1892
|
-
* @param {bigint} param0.chainId - The chain ID on which the target exists
|
|
1893
|
-
* @param {Address} param0.target - The target contract address
|
|
1894
|
-
* @param {Hex} param0.selector - The selector for the function to be called
|
|
1895
|
-
* @param {bigint} param0.value - The native token value to send with the function call
|
|
1896
|
-
* @returns {Hex}
|
|
1897
|
-
*/
|
|
1898
|
-
export const prepareContractActionPayload = ({
|
|
1899
|
-
chainId,
|
|
1900
|
-
target,
|
|
1901
|
-
selector,
|
|
1902
|
-
value,
|
|
1903
|
-
}: ContractActionPayload) => {
|
|
1904
|
-
return encodeAbiParameters(
|
|
1905
|
-
parseAbiParameters([
|
|
1906
|
-
'ContractActionPayload payload',
|
|
1907
|
-
'struct ContractActionPayload { uint256 chainId; address target; bytes4 selector; uint256 value; }',
|
|
1908
|
-
]),
|
|
1909
|
-
[{ chainId, target, selector, value }],
|
|
1910
|
-
);
|
|
1911
|
-
};
|
|
1912
|
-
|
|
1913
|
-
/**
|
|
1914
|
-
* Given a {@link ContractActionPayload}, properly encode a `ContractAction.InitPayload` for use with {@link ERC721MintAction} initialization.
|
|
1915
|
-
*
|
|
1916
|
-
* @param {ContractActionPayload} param0
|
|
1917
|
-
* @param {bigint} param0.chainId - The chain ID on which the target exists
|
|
1918
|
-
* @param {Address} param0.target - The target contract address
|
|
1919
|
-
* @param {Hex} param0.selector - The selector for the function to be called
|
|
1920
|
-
* @param {bigint} param0.value - The native token value to send with the function call
|
|
1921
|
-
* @returns {*}
|
|
1922
|
-
*/
|
|
1923
|
-
export const prepareERC721MintActionPayload = ({
|
|
1924
|
-
chainId,
|
|
1925
|
-
target,
|
|
1926
|
-
selector,
|
|
1927
|
-
value,
|
|
1928
|
-
}: ContractActionPayload) => {
|
|
1929
|
-
return prepareContractActionPayload({ chainId, target, selector, value });
|
|
1930
|
-
};
|
|
1931
|
-
|
|
1932
|
-
/**
|
|
1933
|
-
* The object representation of an `Incentive.ClaimPayload`
|
|
1934
|
-
*
|
|
1935
|
-
* @export
|
|
1936
|
-
* @interface ClaimPayload
|
|
1937
|
-
* @typedef {ClaimPayload}
|
|
1938
|
-
*/
|
|
1939
|
-
export interface ClaimPayload {
|
|
1940
|
-
/**
|
|
1941
|
-
* The address of the recipient
|
|
1942
|
-
*
|
|
1943
|
-
* @type {Address}
|
|
1944
|
-
*/
|
|
1945
|
-
target: Address;
|
|
1946
|
-
/**
|
|
1947
|
-
* The implementation-specific data for the claim, if needed
|
|
1948
|
-
*
|
|
1949
|
-
* @type {?Hex}
|
|
1950
|
-
*/
|
|
1951
|
-
data?: Hex;
|
|
1952
|
-
}
|
|
1953
|
-
|
|
1954
|
-
/**
|
|
1955
|
-
* Given a valid {@link ClaimPayload}, encode the payload for use with Incentive operations.
|
|
1956
|
-
*
|
|
1957
|
-
* @param {ClaimPayload} param0
|
|
1958
|
-
* @param {Address} param0.target - The address of the recipient
|
|
1959
|
-
* @param {Hex} [param0.data=zeroHash] - The implementation-specific data for the claim, if needed
|
|
1960
|
-
* @returns {*}
|
|
1961
|
-
*/
|
|
1962
|
-
export const prepareClaimPayload = ({
|
|
1963
|
-
target,
|
|
1964
|
-
data = zeroHash,
|
|
1965
|
-
}: ClaimPayload) => {
|
|
1966
|
-
return encodeAbiParameters(
|
|
1967
|
-
[
|
|
1968
|
-
{ type: 'address', name: 'target' },
|
|
1969
|
-
{ type: 'bytes', name: 'data' },
|
|
1970
|
-
],
|
|
1971
|
-
[target, data],
|
|
1972
|
-
);
|
|
1973
|
-
};
|
|
1974
|
-
|
|
1975
|
-
/*
|
|
1976
|
-
* Transfer Payloads
|
|
1977
|
-
*/
|
|
1978
|
-
|
|
1979
|
-
/**
|
|
1980
|
-
* The various types of assets supported in Budgets and Incentives.
|
|
1981
|
-
*
|
|
1982
|
-
* @export
|
|
1983
|
-
* @enum {number}
|
|
1984
|
-
*/
|
|
1985
|
-
export enum AssetType {
|
|
1986
|
-
ETH,
|
|
1987
|
-
ERC20,
|
|
1988
|
-
ERC1155,
|
|
1989
|
-
}
|
|
1990
|
-
|
|
1991
|
-
/**
|
|
1992
|
-
* Object representation of a generic `Transfer` struct.
|
|
1993
|
-
*
|
|
1994
|
-
* @export
|
|
1995
|
-
* @interface TransferPayload
|
|
1996
|
-
* @typedef {TransferPayload}
|
|
1997
|
-
*/
|
|
1998
|
-
export interface TransferPayload {
|
|
1999
|
-
/**
|
|
2000
|
-
* The type of the asset being transferred.
|
|
2001
|
-
*
|
|
2002
|
-
* @type {AssetType}
|
|
2003
|
-
*/
|
|
2004
|
-
assetType: AssetType;
|
|
2005
|
-
/**
|
|
2006
|
-
* The address of the asset to transfer, zero address for ETH.
|
|
2007
|
-
*
|
|
2008
|
-
* @type {Address}
|
|
2009
|
-
*/
|
|
2010
|
-
address: Address;
|
|
2011
|
-
/**
|
|
2012
|
-
* The account from which to transfer the assets.
|
|
2013
|
-
*
|
|
2014
|
-
* @type {Address}
|
|
2015
|
-
*/
|
|
2016
|
-
target: Address;
|
|
2017
|
-
/**
|
|
2018
|
-
* An encoded {@link FungiblePayload}, use {@link prepareFungiblePayload} to construct.
|
|
2019
|
-
*
|
|
2020
|
-
* @type {Hex}
|
|
2021
|
-
*/
|
|
2022
|
-
data: Hex;
|
|
2023
|
-
}
|
|
2024
|
-
|
|
2025
|
-
/**
|
|
2026
|
-
* Encodes parameters for transferring the transfer of Fungible and ERC1155 assets, used for {@link Budget} operations.
|
|
2027
|
-
* Typically you'd use {@link prepareFungibleTransfer} or {@link prepareERC1155Transfer}
|
|
2028
|
-
*
|
|
2029
|
-
* @param {TransferPayload} param0
|
|
2030
|
-
* @param {AssetType} param0.assetType - The asset type being transferred.
|
|
2031
|
-
* @param {Address} param0.address - The address of the asset, use zero address for ETH transfers.
|
|
2032
|
-
* @param {Address} param0.target - The address of the account being transferred from
|
|
2033
|
-
* @param {Hex} param0.data - Use {@link prepareFungiblePayload} to properly encode an amount to transfer
|
|
2034
|
-
* @returns {Hex}
|
|
2035
|
-
*/
|
|
2036
|
-
export const prepareTransferPayload = ({
|
|
2037
|
-
assetType,
|
|
2038
|
-
address,
|
|
2039
|
-
target,
|
|
2040
|
-
data,
|
|
2041
|
-
}: TransferPayload) => {
|
|
2042
|
-
return encodeAbiParameters(
|
|
2043
|
-
[
|
|
2044
|
-
{ type: 'uint8', name: 'assetType' },
|
|
2045
|
-
{ type: 'address', name: 'asset' },
|
|
2046
|
-
{ type: 'address', name: 'target' },
|
|
2047
|
-
{ type: 'bytes', name: 'data' },
|
|
2048
|
-
],
|
|
2049
|
-
[assetType, address, target, data],
|
|
2050
|
-
);
|
|
2051
|
-
};
|
|
2052
|
-
|
|
2053
|
-
/**
|
|
2054
|
-
* An object representation of the `Budget.Transfer` contract struct for transfers of ERC1155 assets.
|
|
2055
|
-
*
|
|
2056
|
-
* @export
|
|
2057
|
-
* @interface ERC1155TransferPayload
|
|
2058
|
-
* @typedef {ERC1155TransferPayload}
|
|
2059
|
-
*/
|
|
2060
|
-
export interface ERC1155TransferPayload {
|
|
2061
|
-
/**
|
|
2062
|
-
* The token ID to transfer
|
|
2063
|
-
*
|
|
2064
|
-
* @type {bigint}
|
|
2065
|
-
*/
|
|
2066
|
-
tokenId: bigint;
|
|
2067
|
-
/**
|
|
2068
|
-
* The amount to transfer
|
|
2069
|
-
*
|
|
2070
|
-
* @type {bigint}
|
|
2071
|
-
*/
|
|
2072
|
-
amount: bigint;
|
|
2073
|
-
/**
|
|
2074
|
-
* The address of the asset to target
|
|
2075
|
-
*
|
|
2076
|
-
* @type {Address}
|
|
2077
|
-
*/
|
|
2078
|
-
asset: Address;
|
|
2079
|
-
/**
|
|
2080
|
-
* The account to transfer from
|
|
2081
|
-
*
|
|
2082
|
-
* @type {Address}
|
|
2083
|
-
*/
|
|
2084
|
-
target: Address;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
/**
|
|
2088
|
-
* Encodes parameters for transferring the transfer of ERC1155 assets, used for {@link Budget} operations.
|
|
2089
|
-
* The caller must have already approved the contract to transfer the asset.
|
|
2090
|
-
*
|
|
2091
|
-
* @export
|
|
2092
|
-
* @param {ERC1155TransferPayload} param0
|
|
2093
|
-
* @param {bigint} param0.tokenId - The token ID to transfer
|
|
2094
|
-
* @param {bigint} param0.amount - The amount to transfer
|
|
2095
|
-
* @param {Address} param0.asset - The address of the asset to target
|
|
2096
|
-
* @param {Address} param0.target - The account to transfer from
|
|
2097
|
-
* @returns {Hex}
|
|
2098
|
-
*/
|
|
2099
|
-
export function prepareERC1155Transfer({
|
|
2100
|
-
tokenId,
|
|
2101
|
-
amount,
|
|
2102
|
-
asset,
|
|
2103
|
-
target,
|
|
2104
|
-
}: ERC1155TransferPayload) {
|
|
2105
|
-
return encodeAbiParameters(
|
|
2106
|
-
parseAbiParameters([
|
|
2107
|
-
'Transfer request',
|
|
2108
|
-
'struct Transfer { uint8 assetType; address asset; address target; bytes data; }',
|
|
2109
|
-
]),
|
|
2110
|
-
[
|
|
2111
|
-
{
|
|
2112
|
-
assetType: AssetType.ERC1155,
|
|
2113
|
-
asset,
|
|
2114
|
-
data: prepareERC1155Payload({ tokenId, amount }),
|
|
2115
|
-
target,
|
|
2116
|
-
},
|
|
2117
|
-
],
|
|
2118
|
-
);
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
/**
|
|
2122
|
-
* An object representation of the `FungiblePayload` struct
|
|
2123
|
-
*
|
|
2124
|
-
* @export
|
|
2125
|
-
* @interface FungiblePayload
|
|
2126
|
-
* @typedef {FungiblePayload}
|
|
2127
|
-
*/
|
|
2128
|
-
export interface FungiblePayload {
|
|
2129
|
-
/**
|
|
2130
|
-
* The amount being transferred
|
|
2131
|
-
*
|
|
2132
|
-
* @type {bigint}
|
|
2133
|
-
*/
|
|
2134
|
-
amount: bigint;
|
|
2135
|
-
}
|
|
2136
|
-
|
|
2137
|
-
/**
|
|
2138
|
-
* Encodes an amount for the `FungiblePayload` struct
|
|
2139
|
-
*
|
|
2140
|
-
* @export
|
|
2141
|
-
* @param {FungiblePayload} param0
|
|
2142
|
-
* @param {bigint} param0.amount - The amount being transferred
|
|
2143
|
-
* @returns {*}
|
|
2144
|
-
*/
|
|
2145
|
-
export function prepareFungiblePayload({ amount }: FungiblePayload) {
|
|
2146
|
-
return encodeAbiParameters(
|
|
2147
|
-
parseAbiParameters([
|
|
2148
|
-
'FungiblePayload payload',
|
|
2149
|
-
'struct FungiblePayload { uint256 amount; }',
|
|
2150
|
-
]),
|
|
2151
|
-
[{ amount }],
|
|
2152
|
-
);
|
|
2153
|
-
}
|
|
2154
|
-
|
|
2155
|
-
/**
|
|
2156
|
-
* An object representation of the `Budget.Transfer` contract struct for transfers of fungible assets.
|
|
2157
|
-
*
|
|
2158
|
-
* @export
|
|
2159
|
-
* @interface FungibleTransferPayload
|
|
2160
|
-
* @typedef {FungibleTransferPayload}
|
|
2161
|
-
*/
|
|
2162
|
-
export interface FungibleTransferPayload {
|
|
2163
|
-
/**
|
|
2164
|
-
* The amount to transfer
|
|
2165
|
-
*
|
|
2166
|
-
* @type {bigint}
|
|
2167
|
-
*/
|
|
2168
|
-
amount: bigint;
|
|
2169
|
-
/**
|
|
2170
|
-
* The address of the asset. Use zero address for ETH transfers.
|
|
2171
|
-
*
|
|
2172
|
-
* @type {Address}
|
|
2173
|
-
*/
|
|
2174
|
-
asset: Address;
|
|
2175
|
-
/**
|
|
2176
|
-
* The account to transfer from
|
|
2177
|
-
*
|
|
2178
|
-
* @type {Address}
|
|
2179
|
-
*/
|
|
2180
|
-
target: Address;
|
|
2181
|
-
}
|
|
2182
|
-
|
|
2183
|
-
/**
|
|
2184
|
-
* Encodes parameters for a Fungible transfer, used for Budget allocations.
|
|
2185
|
-
* The caller must have already approved the contract to transfer the asset.
|
|
2186
|
-
*
|
|
2187
|
-
* @export
|
|
2188
|
-
* @param {FungibleTransferPayload} param0
|
|
2189
|
-
* @param {bigint} param0.amount - The amount to transfer
|
|
2190
|
-
* @param {Address} param0.asset - The address of the asset. Use zero address for ETH transfers.
|
|
2191
|
-
* @param {Address} param0.target - The account to transfer from
|
|
2192
|
-
* @returns {Hex}
|
|
2193
|
-
*/
|
|
2194
|
-
export function prepareFungibleTransfer({
|
|
2195
|
-
amount,
|
|
2196
|
-
asset,
|
|
2197
|
-
target,
|
|
2198
|
-
}: FungibleTransferPayload) {
|
|
2199
|
-
return encodeAbiParameters(
|
|
2200
|
-
parseAbiParameters([
|
|
2201
|
-
'Transfer request',
|
|
2202
|
-
'struct Transfer { uint8 assetType; address asset; address target; bytes data; }',
|
|
2203
|
-
]),
|
|
2204
|
-
[
|
|
2205
|
-
{
|
|
2206
|
-
assetType: asset == zeroAddress ? AssetType.ETH : AssetType.ERC20,
|
|
2207
|
-
asset,
|
|
2208
|
-
data: prepareFungiblePayload({ amount }),
|
|
2209
|
-
target,
|
|
2210
|
-
},
|
|
2211
|
-
],
|
|
2212
|
-
);
|
|
2213
|
-
}
|
|
2214
|
-
|
|
2215
|
-
/**
|
|
2216
|
-
* Encodes a payload to validate that an action has been completed successfully.
|
|
2217
|
-
*
|
|
2218
|
-
*
|
|
2219
|
-
* @export
|
|
2220
|
-
* @param {Address} holder - The holder address
|
|
2221
|
-
* @param {bigint} payload - The token ID
|
|
2222
|
-
* @returns {Hex} - The first 20 bytes of the payload will be the holder address and the remaining bytes must be an encoded token ID (uint256)
|
|
2223
|
-
*/
|
|
2224
|
-
export function prepareERC721MintActionValidate(
|
|
2225
|
-
holder: Address,
|
|
2226
|
-
payload: bigint,
|
|
2227
|
-
) {
|
|
2228
|
-
return encodeAbiParameters(
|
|
2229
|
-
[
|
|
2230
|
-
{ type: 'address', name: 'holder' },
|
|
2231
|
-
{ type: 'bytes', name: 'payload' },
|
|
2232
|
-
],
|
|
2233
|
-
[holder, toHex(payload)],
|
|
2234
|
-
);
|
|
2235
|
-
}
|
|
2236
|
-
|
|
2237
|
-
export function dedupeActionSteps(_steps: ActionStep[]): ActionStep[] {
|
|
2238
|
-
const steps: ActionStep[] = [],
|
|
2239
|
-
signatures: Record<string, boolean> = {};
|
|
2240
|
-
for (let step of _steps) {
|
|
2241
|
-
const signature = JSON.stringify(step);
|
|
2242
|
-
if (signatures[signature]) continue;
|
|
2243
|
-
steps.push(step);
|
|
2244
|
-
signatures[signature] = true;
|
|
217
|
+
export function assertValidAddressByChainId(
|
|
218
|
+
config: Config,
|
|
219
|
+
addressByChainId: Record<number, Address>,
|
|
220
|
+
desiredChainId?: number,
|
|
221
|
+
): { chainId: number; address: Address } {
|
|
222
|
+
let chainId: number | undefined = undefined;
|
|
223
|
+
const wagmiAccount = getAccount(config);
|
|
224
|
+
// if manually providing a chain id for some contract operation, try to use it
|
|
225
|
+
if (desiredChainId !== undefined) {
|
|
226
|
+
if (addressByChainId[desiredChainId]) chainId = desiredChainId;
|
|
227
|
+
} else if (wagmiAccount.chainId !== undefined) {
|
|
228
|
+
// otherwise if we can get the current chain id off the connected account and it matches one of ours, use it
|
|
229
|
+
if (addressByChainId[wagmiAccount.chainId]) chainId = wagmiAccount.chainId;
|
|
230
|
+
}
|
|
231
|
+
// chainId is still undefined, try to get chain id off viem client
|
|
232
|
+
if (chainId === undefined) {
|
|
233
|
+
const client = getClient(config);
|
|
234
|
+
if (client?.chain.id && addressByChainId[client?.chain.id])
|
|
235
|
+
chainId = client.chain.id;
|
|
2245
236
|
}
|
|
2246
|
-
|
|
237
|
+
// if chainId is STILL undefined, use our default addresses
|
|
238
|
+
// TODO: update this when on prod network
|
|
239
|
+
if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);
|
|
240
|
+
if (!addressByChainId[chainId])
|
|
241
|
+
throw new InvalidProtocolChainIdError(
|
|
242
|
+
chainId,
|
|
243
|
+
Object.keys(addressByChainId).map(Number),
|
|
244
|
+
);
|
|
245
|
+
// biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?
|
|
246
|
+
return { chainId, address: addressByChainId[chainId]! };
|
|
2247
247
|
}
|