@boostxyz/sdk 0.0.0-alpha.9 → 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 +11 -11
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +14 -14
- 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 +171 -41
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -392
- 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 +92 -37
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +55 -71
- 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 +203 -11
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -112
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +20 -21
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +43 -57
- 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 +748 -77
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1150
- 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 +80 -25
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +165 -83
- 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 +75 -193
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +80 -298
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +223 -89
- 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 +5 -7
- 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 +28 -25
- 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 +38 -16
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +42 -29
- 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 +234 -21
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +45 -32
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +224 -37
- 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 +230 -29
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +56 -43
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +335 -440
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +231 -29
- 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 -296
- 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 +40 -18
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +37 -24
- 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 +16 -16
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +30 -27
- 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.map +1 -1
- package/dist/claiming.d.ts +1 -1
- package/dist/claiming.js.map +1 -1
- 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 +256 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-57_Kffpz.js → generated-CKt2yCQd.js} +3613 -1869
- 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 +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +142 -108
- package/dist/index.js.map +1 -1
- package/dist/transfers.cjs.map +1 -1
- package/dist/transfers.d.ts +1 -1
- package/dist/transfers.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +26 -12
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -23
- package/dist/utils.js.map +1 -1
- package/package.json +20 -10
- package/src/Actions/Action.test.ts +14 -13
- package/src/Actions/ContractAction.test.ts +10 -10
- package/src/Actions/ContractAction.ts +11 -12
- package/src/Actions/ERC721MintAction.test.ts +6 -6
- package/src/Actions/ERC721MintAction.ts +14 -15
- package/src/Actions/EventAction.test.ts +729 -109
- package/src/Actions/EventAction.ts +542 -84
- 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 +39 -61
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +40 -17
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Boost.ts +21 -24
- package/src/BoostCore.test.ts +323 -268
- package/src/BoostCore.ts +396 -219
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +161 -40
- 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 +48 -310
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +34 -106
- package/src/Deployable/Contract.ts +4 -5
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +30 -19
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +5 -5
- package/src/Incentives/AllowListIncentive.ts +29 -15
- package/src/Incentives/CGDAIncentive.test.ts +9 -6
- package/src/Incentives/CGDAIncentive.ts +38 -18
- package/src/Incentives/ERC1155Incentive.test.ts +3 -3
- package/src/Incentives/ERC1155Incentive.ts +28 -29
- package/src/Incentives/ERC20Incentive.test.ts +9 -6
- package/src/Incentives/ERC20Incentive.ts +46 -26
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +8 -11
- package/src/Incentives/ERC20VariableIncentive.ts +49 -26
- package/src/Incentives/Incentive.test.ts +4 -1
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +24 -25
- package/src/Incentives/PointsIncentive.ts +31 -17
- package/src/Validators/SignerValidator.test.ts +6 -6
- package/src/Validators/SignerValidator.ts +19 -17
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +1 -1
- package/src/errors.ts +345 -21
- package/src/index.test.ts +118 -36
- package/src/index.ts +5 -0
- package/src/transfers.ts +1 -1
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -12
- 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-57_Kffpz.js.map +0 -1
- package/dist/generated-wKBNvm48.cjs +0 -3
- package/dist/generated-wKBNvm48.cjs.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -564
package/src/BoostCore.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
boostCoreAbi,
|
|
3
3
|
type iAuthAbi,
|
|
4
|
-
readBoostCoreClaimFee,
|
|
5
4
|
readBoostCoreCreateBoostAuth,
|
|
6
5
|
readBoostCoreGetBoost,
|
|
7
6
|
readBoostCoreGetBoostCount,
|
|
@@ -10,17 +9,22 @@ import {
|
|
|
10
9
|
readIAuthIsAuthorized,
|
|
11
10
|
simulateBoostCoreClaimIncentive,
|
|
12
11
|
simulateBoostCoreClaimIncentiveFor,
|
|
13
|
-
|
|
12
|
+
simulateBoostCoreCreateBoost,
|
|
14
13
|
simulateBoostCoreSetCreateBoostAuth,
|
|
15
14
|
simulateBoostCoreSetProtocolFeeReceiver,
|
|
16
15
|
writeBoostCoreClaimIncentive,
|
|
17
16
|
writeBoostCoreClaimIncentiveFor,
|
|
18
|
-
writeBoostCoreSetClaimFee,
|
|
19
17
|
writeBoostCoreSetCreateBoostAuth,
|
|
20
18
|
writeBoostCoreSetProtocolFeeReceiver,
|
|
21
19
|
} from '@boostxyz/evm';
|
|
22
20
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/BoostCore.sol/BoostCore.json';
|
|
23
|
-
import {
|
|
21
|
+
import {
|
|
22
|
+
type GetTransactionReceiptParameters,
|
|
23
|
+
getAccount,
|
|
24
|
+
getTransactionReceipt,
|
|
25
|
+
waitForTransactionReceipt,
|
|
26
|
+
} from '@wagmi/core';
|
|
27
|
+
import type { SimulateContractReturnType } from '@wagmi/core/actions';
|
|
24
28
|
import { createWriteContract } from '@wagmi/core/codegen';
|
|
25
29
|
import {
|
|
26
30
|
type Address,
|
|
@@ -31,9 +35,11 @@ import {
|
|
|
31
35
|
zeroAddress,
|
|
32
36
|
zeroHash,
|
|
33
37
|
} from 'viem';
|
|
38
|
+
import { BoostCore as BoostCoreBases } from '../dist/deployments.json';
|
|
34
39
|
import { type Action, actionFromAddress } from './Actions/Action';
|
|
35
40
|
import { EventAction, type EventActionPayload } from './Actions/EventAction';
|
|
36
41
|
import { type AllowList, allowListFromAddress } from './AllowLists/AllowList';
|
|
42
|
+
import { OpenAllowList } from './AllowLists/OpenAllowList';
|
|
37
43
|
import {
|
|
38
44
|
SimpleAllowList,
|
|
39
45
|
type SimpleAllowListPayload,
|
|
@@ -46,6 +52,7 @@ import { type Auth, PassthroughAuth } from './Auth/Auth';
|
|
|
46
52
|
import {
|
|
47
53
|
Boost,
|
|
48
54
|
type BoostPayload,
|
|
55
|
+
type RawBoost,
|
|
49
56
|
type Target,
|
|
50
57
|
prepareBoostPayload,
|
|
51
58
|
} from './Boost';
|
|
@@ -72,6 +79,10 @@ import {
|
|
|
72
79
|
ERC20Incentive,
|
|
73
80
|
type ERC20IncentivePayload,
|
|
74
81
|
} from './Incentives/ERC20Incentive';
|
|
82
|
+
import {
|
|
83
|
+
ERC20VariableCriteriaIncentive,
|
|
84
|
+
type ERC20VariableCriteriaIncentivePayload,
|
|
85
|
+
} from './Incentives/ERC20VariableCriteriaIncentive';
|
|
75
86
|
import type { ERC20VariableIncentivePayload } from './Incentives/ERC20VariableIncentive';
|
|
76
87
|
import {
|
|
77
88
|
ERC20VariableIncentive,
|
|
@@ -89,13 +100,24 @@ import {
|
|
|
89
100
|
import { type Validator, validatorFromAddress } from './Validators/Validator';
|
|
90
101
|
import {
|
|
91
102
|
BoostCoreNoIdentifierEmitted,
|
|
103
|
+
BoostNotFoundError,
|
|
92
104
|
BudgetMustAuthorizeBoostCore,
|
|
93
105
|
DeployableUnknownOwnerProvidedError,
|
|
94
106
|
IncentiveNotCloneableError,
|
|
95
107
|
MustInitializeBudgetError,
|
|
96
108
|
} from './errors';
|
|
97
|
-
import
|
|
109
|
+
import {
|
|
110
|
+
type GenericLog,
|
|
111
|
+
type ReadParams,
|
|
112
|
+
type WriteParams,
|
|
113
|
+
assertValidAddressByChainId,
|
|
114
|
+
} from './utils';
|
|
98
115
|
|
|
116
|
+
/**
|
|
117
|
+
* The ABI of the BoostCore contract, if needed for low level operations
|
|
118
|
+
*
|
|
119
|
+
* @type {typeof boostCoreAbi}
|
|
120
|
+
*/
|
|
99
121
|
export { boostCoreAbi };
|
|
100
122
|
|
|
101
123
|
/**
|
|
@@ -106,13 +128,24 @@ export { boostCoreAbi };
|
|
|
106
128
|
export const BOOST_CORE_CLAIM_FEE = parseEther('0.000075');
|
|
107
129
|
|
|
108
130
|
/**
|
|
109
|
-
* The
|
|
110
|
-
* By default, `new BoostCore` will use this address if not otherwise provided.
|
|
131
|
+
* The address of the deployed BoostCore instance. In prerelease mode, this will be its sepolia address
|
|
111
132
|
*
|
|
112
133
|
* @type {Address}
|
|
113
134
|
*/
|
|
114
|
-
export const BOOST_CORE_ADDRESS
|
|
115
|
-
|
|
135
|
+
export const BOOST_CORE_ADDRESS =
|
|
136
|
+
(BoostCoreBases as Record<string, Address>)[__DEFAULT_CHAIN_ID__] ||
|
|
137
|
+
zeroAddress;
|
|
138
|
+
|
|
139
|
+
/**
|
|
140
|
+
* The fixed addresses for the deployed Boost Core.
|
|
141
|
+
* By default, `new BoostCore` will use the address deployed to the currently connected chain, or `BOOST_CORE_ADDRESS` if not provided.
|
|
142
|
+
*
|
|
143
|
+
* @type {Record<number, Address>}
|
|
144
|
+
*/
|
|
145
|
+
export const BOOST_CORE_ADDRESSES: Record<number, Address> = {
|
|
146
|
+
...(BoostCoreBases as Record<number, Address>),
|
|
147
|
+
31337: import.meta.env.VITE_BOOST_CORE_ADDRESS,
|
|
148
|
+
};
|
|
116
149
|
|
|
117
150
|
/**
|
|
118
151
|
* A generic `viem.Log` event with support for `BoostCore` event types.
|
|
@@ -210,11 +243,10 @@ export type BoostCoreConfig =
|
|
|
210
243
|
export type CreateBoostPayload = {
|
|
211
244
|
budget: Budget;
|
|
212
245
|
action: Action;
|
|
213
|
-
validator
|
|
246
|
+
validator?: Validator;
|
|
214
247
|
allowList: AllowList;
|
|
215
248
|
incentives: Array<Incentive>;
|
|
216
249
|
protocolFee?: bigint;
|
|
217
|
-
referralFee?: bigint;
|
|
218
250
|
maxParticipants?: bigint;
|
|
219
251
|
owner?: Address;
|
|
220
252
|
};
|
|
@@ -231,6 +263,26 @@ export class BoostCore extends Deployable<
|
|
|
231
263
|
[Address, Address],
|
|
232
264
|
typeof boostCoreAbi
|
|
233
265
|
> {
|
|
266
|
+
/**
|
|
267
|
+
* A static property representing a map of stringified chain ID's to the address of the deployed implementation on chain
|
|
268
|
+
*
|
|
269
|
+
* @static
|
|
270
|
+
* @readonly
|
|
271
|
+
* @type {Record<string, Address>}
|
|
272
|
+
*/
|
|
273
|
+
static readonly addresses: Record<number, Address> = BOOST_CORE_ADDRESSES;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* A getter that will return Boost core's static addresses by numerical chain ID
|
|
277
|
+
*
|
|
278
|
+
* @public
|
|
279
|
+
* @readonly
|
|
280
|
+
* @type {Record<number, Address>}
|
|
281
|
+
*/
|
|
282
|
+
public get addresses(): Record<number, Address> {
|
|
283
|
+
return (this.constructor as typeof BoostCore).addresses;
|
|
284
|
+
}
|
|
285
|
+
|
|
234
286
|
/**
|
|
235
287
|
* Creates an instance of BoostCore.
|
|
236
288
|
*
|
|
@@ -249,63 +301,155 @@ export class BoostCore extends Deployable<
|
|
|
249
301
|
options.protocolFeeReceiver,
|
|
250
302
|
]);
|
|
251
303
|
} else {
|
|
252
|
-
|
|
304
|
+
const { address } = assertValidAddressByChainId(
|
|
305
|
+
config,
|
|
306
|
+
BOOST_CORE_ADDRESSES,
|
|
307
|
+
);
|
|
308
|
+
super({ account, config }, address);
|
|
253
309
|
}
|
|
254
310
|
//@ts-expect-error I can't set this property on the class because for some reason it takes super out of constructor scope?
|
|
255
311
|
this.abi = boostCoreAbi;
|
|
256
312
|
}
|
|
313
|
+
|
|
257
314
|
/**
|
|
258
315
|
* Create a new Boost.
|
|
259
316
|
*
|
|
260
317
|
* @public
|
|
261
318
|
* @async
|
|
262
319
|
* @param {CreateBoostPayload} _boostPayload
|
|
263
|
-
* @param {?DeployableOptions} [
|
|
264
|
-
* @returns {Boost}
|
|
320
|
+
* @param {?DeployableOptions} [_params]
|
|
321
|
+
* @returns {Promise<Boost>}
|
|
265
322
|
*/
|
|
266
323
|
public async createBoost(
|
|
267
324
|
_boostPayload: CreateBoostPayload,
|
|
268
|
-
|
|
325
|
+
_params?: DeployableOptions &
|
|
326
|
+
WriteParams<typeof boostCoreAbi, 'createBoost'>,
|
|
269
327
|
) {
|
|
270
|
-
const coreAddress = this.assertValidAddress();
|
|
271
328
|
const [payload, options] =
|
|
272
|
-
this.validateDeploymentConfig<CreateBoostPayload>(
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
action,
|
|
280
|
-
validator,
|
|
281
|
-
allowList,
|
|
282
|
-
incentives,
|
|
283
|
-
protocolFee = 0n,
|
|
284
|
-
referralFee = 0n,
|
|
285
|
-
maxParticipants = 0n,
|
|
286
|
-
owner,
|
|
287
|
-
} = payload;
|
|
329
|
+
this.validateDeploymentConfig<CreateBoostPayload>(_boostPayload, _params);
|
|
330
|
+
const desiredChainId = _params?.chain?.id || _params?.chainId;
|
|
331
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
332
|
+
options.config,
|
|
333
|
+
this.addresses,
|
|
334
|
+
desiredChainId,
|
|
335
|
+
);
|
|
288
336
|
|
|
289
337
|
const boostFactory = createWriteContract({
|
|
290
338
|
abi: boostCoreAbi,
|
|
291
339
|
functionName: 'createBoost',
|
|
292
|
-
address:
|
|
340
|
+
address: coreAddress,
|
|
293
341
|
});
|
|
294
342
|
|
|
295
|
-
|
|
296
|
-
|
|
343
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
344
|
+
coreAddress,
|
|
345
|
+
chainId,
|
|
346
|
+
payload,
|
|
347
|
+
options,
|
|
348
|
+
);
|
|
349
|
+
|
|
350
|
+
const boostHash = await boostFactory(options.config, {
|
|
351
|
+
...this.optionallyAttachAccount(options.account),
|
|
352
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
353
|
+
...(_params as any),
|
|
354
|
+
chainId,
|
|
355
|
+
args: [prepareBoostPayload(onChainPayload)],
|
|
356
|
+
});
|
|
357
|
+
const receipt = await waitForTransactionReceipt(options.config, {
|
|
358
|
+
hash: boostHash,
|
|
359
|
+
});
|
|
360
|
+
const boostCreatedLog = parseEventLogs({
|
|
361
|
+
abi: boostCoreAbi,
|
|
362
|
+
eventName: 'BoostCreated',
|
|
363
|
+
logs: receipt.logs,
|
|
364
|
+
}).at(0);
|
|
365
|
+
let boostId = 0n;
|
|
366
|
+
if (!boostCreatedLog) throw new BoostCoreNoIdentifierEmitted();
|
|
367
|
+
boostId = boostCreatedLog?.args.boostId;
|
|
368
|
+
const boost = await this.readBoost(boostId);
|
|
369
|
+
return new Boost({
|
|
370
|
+
id: boostId,
|
|
371
|
+
budget: payload.budget.at(boost.budget),
|
|
372
|
+
action: payload.action.at(boost.action),
|
|
373
|
+
validator: payload.validator!.at(boost.validator),
|
|
374
|
+
allowList: payload.allowList.at(boost.allowList),
|
|
375
|
+
incentives: payload.incentives.map((incentive, i) =>
|
|
376
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
377
|
+
incentive.at(boost.incentives.at(i)!),
|
|
378
|
+
),
|
|
379
|
+
protocolFee: boost.protocolFee,
|
|
380
|
+
maxParticipants: boost.maxParticipants,
|
|
381
|
+
owner: boost.owner,
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/**
|
|
386
|
+
* Returns a simulated Boost creation.
|
|
387
|
+
*
|
|
388
|
+
* @public
|
|
389
|
+
* @async
|
|
390
|
+
* @param {CreateBoostPayload} _boostPayload
|
|
391
|
+
* @param {?DeployableOptions} [_params]
|
|
392
|
+
* @returns {Promise<SimulateContractReturnType>}
|
|
393
|
+
*/
|
|
394
|
+
public async simulateCreateBoost(
|
|
395
|
+
_boostPayload: CreateBoostPayload,
|
|
396
|
+
_params?: DeployableOptions &
|
|
397
|
+
WriteParams<typeof boostCoreAbi, 'createBoost'>,
|
|
398
|
+
) {
|
|
399
|
+
const [payload, options] =
|
|
400
|
+
this.validateDeploymentConfig<CreateBoostPayload>(_boostPayload, _params);
|
|
401
|
+
const desiredChainId = _params?.chain?.id || _params?.chainId;
|
|
402
|
+
const { chainId, address: coreAddress } = assertValidAddressByChainId(
|
|
403
|
+
options.config,
|
|
404
|
+
this.addresses,
|
|
405
|
+
desiredChainId,
|
|
406
|
+
);
|
|
407
|
+
|
|
408
|
+
const onChainPayload = await this.prepareCreateBoostPayload(
|
|
409
|
+
coreAddress,
|
|
410
|
+
chainId,
|
|
411
|
+
payload,
|
|
412
|
+
options,
|
|
413
|
+
);
|
|
414
|
+
|
|
415
|
+
return await simulateBoostCoreCreateBoost(this._config, {
|
|
416
|
+
...this.optionallyAttachAccount(),
|
|
417
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
418
|
+
...(_params as any),
|
|
419
|
+
address: coreAddress,
|
|
420
|
+
chainId,
|
|
421
|
+
args: [prepareBoostPayload(onChainPayload)],
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
// This function mutates payload, which isn't awesome but it's fine
|
|
426
|
+
private async prepareCreateBoostPayload(
|
|
427
|
+
coreAddress: Address,
|
|
428
|
+
chainId: number,
|
|
429
|
+
payload: CreateBoostPayload,
|
|
430
|
+
options: DeployableOptions,
|
|
431
|
+
): Promise<BoostPayload> {
|
|
432
|
+
if (!payload.owner) {
|
|
433
|
+
payload.owner =
|
|
297
434
|
this._account?.address ||
|
|
298
435
|
getAccount(options.config).address ||
|
|
299
436
|
zeroAddress;
|
|
300
|
-
if (owner === zeroAddress) {
|
|
437
|
+
if (payload.owner === zeroAddress) {
|
|
301
438
|
throw new DeployableUnknownOwnerProvidedError();
|
|
302
439
|
}
|
|
303
440
|
}
|
|
304
441
|
|
|
442
|
+
if (!payload.validator) {
|
|
443
|
+
payload.validator = this.SignerValidator({
|
|
444
|
+
signers: [payload.owner],
|
|
445
|
+
validatorCaller: coreAddress,
|
|
446
|
+
});
|
|
447
|
+
}
|
|
448
|
+
|
|
305
449
|
let budgetPayload: BoostPayload['budget'] = zeroAddress;
|
|
306
|
-
if (budget.address) {
|
|
307
|
-
budgetPayload = budget.address;
|
|
308
|
-
if (!(await budget.isAuthorized(coreAddress))) {
|
|
450
|
+
if (payload.budget.address) {
|
|
451
|
+
budgetPayload = payload.budget.address;
|
|
452
|
+
if (!(await payload.budget.isAuthorized(coreAddress))) {
|
|
309
453
|
throw new BudgetMustAuthorizeBoostCore(coreAddress);
|
|
310
454
|
}
|
|
311
455
|
} else {
|
|
@@ -319,19 +463,25 @@ export class BoostCore extends Deployable<
|
|
|
319
463
|
isBase: true,
|
|
320
464
|
parameters: zeroHash,
|
|
321
465
|
};
|
|
322
|
-
if (action.address) {
|
|
323
|
-
const isBase =
|
|
466
|
+
if (payload.action.address) {
|
|
467
|
+
const isBase = payload.action.isBase;
|
|
324
468
|
actionPayload = {
|
|
325
469
|
isBase: isBase,
|
|
326
|
-
instance: action.address,
|
|
470
|
+
instance: payload.action.address,
|
|
327
471
|
parameters: isBase
|
|
328
|
-
? action.buildParameters(undefined, options).args.at(0) ||
|
|
472
|
+
? payload.action.buildParameters(undefined, options).args.at(0) ||
|
|
473
|
+
zeroHash
|
|
329
474
|
: zeroHash,
|
|
330
475
|
};
|
|
331
476
|
} else {
|
|
332
477
|
actionPayload.parameters =
|
|
333
|
-
action.buildParameters(undefined, options).args.at(0) ||
|
|
334
|
-
|
|
478
|
+
payload.action.buildParameters(undefined, options).args.at(0) ||
|
|
479
|
+
zeroHash;
|
|
480
|
+
actionPayload.instance = assertValidAddressByChainId(
|
|
481
|
+
options.config,
|
|
482
|
+
payload.action.bases,
|
|
483
|
+
chainId,
|
|
484
|
+
).address;
|
|
335
485
|
}
|
|
336
486
|
|
|
337
487
|
let validatorPayload: BoostPayload['validator'] = {
|
|
@@ -339,35 +489,25 @@ export class BoostCore extends Deployable<
|
|
|
339
489
|
isBase: true,
|
|
340
490
|
parameters: zeroHash,
|
|
341
491
|
};
|
|
342
|
-
if (validator.address) {
|
|
343
|
-
const isBase =
|
|
492
|
+
if (payload.validator.address) {
|
|
493
|
+
const isBase = payload.validator.isBase;
|
|
344
494
|
validatorPayload = {
|
|
345
495
|
isBase: isBase,
|
|
346
|
-
instance: validator.address,
|
|
496
|
+
instance: payload.validator.address,
|
|
347
497
|
parameters: isBase
|
|
348
|
-
? validator
|
|
349
|
-
|
|
350
|
-
{
|
|
351
|
-
signers: [owner],
|
|
352
|
-
validatorCaller: coreAddress,
|
|
353
|
-
},
|
|
354
|
-
options,
|
|
355
|
-
)
|
|
356
|
-
.args.at(0) || zeroHash
|
|
498
|
+
? payload.validator.buildParameters(undefined, options).args.at(0) ||
|
|
499
|
+
zeroHash
|
|
357
500
|
: zeroHash,
|
|
358
501
|
};
|
|
359
502
|
} else {
|
|
360
503
|
validatorPayload.parameters =
|
|
361
|
-
validator
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
)
|
|
369
|
-
.args.at(0) || zeroHash;
|
|
370
|
-
validatorPayload.instance = validator.base;
|
|
504
|
+
payload.validator.buildParameters(undefined, options).args.at(0) ||
|
|
505
|
+
zeroHash;
|
|
506
|
+
validatorPayload.instance = assertValidAddressByChainId(
|
|
507
|
+
options.config,
|
|
508
|
+
payload.validator.bases,
|
|
509
|
+
chainId,
|
|
510
|
+
).address;
|
|
371
511
|
}
|
|
372
512
|
|
|
373
513
|
let allowListPayload: BoostPayload['allowList'] = {
|
|
@@ -375,31 +515,36 @@ export class BoostCore extends Deployable<
|
|
|
375
515
|
isBase: true,
|
|
376
516
|
parameters: zeroHash,
|
|
377
517
|
};
|
|
378
|
-
if (allowList.address) {
|
|
379
|
-
const isBase =
|
|
518
|
+
if (payload.allowList.address) {
|
|
519
|
+
const isBase = payload.allowList.isBase;
|
|
380
520
|
allowListPayload = {
|
|
381
521
|
isBase: isBase,
|
|
382
|
-
instance: allowList.address,
|
|
522
|
+
instance: payload.allowList.address,
|
|
383
523
|
parameters: isBase
|
|
384
524
|
? zeroHash // allowList.buildParameters(undefined, options).args.at(0) || zeroHash
|
|
385
525
|
: zeroHash,
|
|
386
526
|
};
|
|
387
527
|
} else {
|
|
388
528
|
allowListPayload.parameters =
|
|
389
|
-
allowList.buildParameters(undefined, options).args.at(0) ||
|
|
390
|
-
|
|
529
|
+
payload.allowList.buildParameters(undefined, options).args.at(0) ||
|
|
530
|
+
zeroHash;
|
|
531
|
+
allowListPayload.instance = assertValidAddressByChainId(
|
|
532
|
+
options.config,
|
|
533
|
+
payload.allowList.bases,
|
|
534
|
+
chainId,
|
|
535
|
+
).address;
|
|
391
536
|
}
|
|
392
537
|
|
|
393
|
-
|
|
538
|
+
const incentivesPayloads: Array<Target> = payload.incentives.map(() => ({
|
|
394
539
|
instance: zeroAddress,
|
|
395
540
|
isBase: true,
|
|
396
541
|
parameters: zeroHash,
|
|
397
542
|
}));
|
|
398
|
-
for (let i = 0; i < incentives.length; i++) {
|
|
543
|
+
for (let i = 0; i < payload.incentives.length; i++) {
|
|
399
544
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
400
|
-
const incentive = incentives.at(i)!;
|
|
545
|
+
const incentive = payload.incentives.at(i)!;
|
|
401
546
|
if (incentive.address) {
|
|
402
|
-
const isBase = incentive.
|
|
547
|
+
const isBase = incentive.isBase;
|
|
403
548
|
if (!isBase) throw new IncentiveNotCloneableError(incentive);
|
|
404
549
|
incentivesPayloads[i] = {
|
|
405
550
|
isBase: isBase,
|
|
@@ -414,7 +559,11 @@ export class BoostCore extends Deployable<
|
|
|
414
559
|
incentivesPayloads[i]!.parameters =
|
|
415
560
|
incentive.buildParameters(undefined, options).args.at(0) || zeroHash;
|
|
416
561
|
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
417
|
-
incentivesPayloads[i]!.instance =
|
|
562
|
+
incentivesPayloads[i]!.instance = assertValidAddressByChainId(
|
|
563
|
+
options.config,
|
|
564
|
+
incentive.bases,
|
|
565
|
+
chainId,
|
|
566
|
+
).address;
|
|
418
567
|
}
|
|
419
568
|
}
|
|
420
569
|
|
|
@@ -424,43 +573,12 @@ export class BoostCore extends Deployable<
|
|
|
424
573
|
validator: validatorPayload,
|
|
425
574
|
allowList: allowListPayload,
|
|
426
575
|
incentives: incentivesPayloads,
|
|
427
|
-
protocolFee,
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
owner,
|
|
576
|
+
protocolFee: payload.protocolFee || 0n,
|
|
577
|
+
maxParticipants: payload.maxParticipants || 0n,
|
|
578
|
+
owner: payload.owner,
|
|
431
579
|
};
|
|
432
580
|
|
|
433
|
-
|
|
434
|
-
args: [prepareBoostPayload(onChainPayload)],
|
|
435
|
-
...this.optionallyAttachAccount(options.account),
|
|
436
|
-
});
|
|
437
|
-
const receipt = await waitForTransactionReceipt(options.config, {
|
|
438
|
-
hash: boostHash,
|
|
439
|
-
});
|
|
440
|
-
const boostCreatedLog = parseEventLogs({
|
|
441
|
-
abi: boostCoreAbi,
|
|
442
|
-
eventName: 'BoostCreated',
|
|
443
|
-
logs: receipt.logs,
|
|
444
|
-
}).at(0);
|
|
445
|
-
let boostId = 0n;
|
|
446
|
-
if (!boostCreatedLog) throw new BoostCoreNoIdentifierEmitted();
|
|
447
|
-
boostId = boostCreatedLog?.args.boostIndex;
|
|
448
|
-
const boost = await this.readBoost(boostId);
|
|
449
|
-
return new Boost({
|
|
450
|
-
id: boostId,
|
|
451
|
-
budget: budget.at(boost.budget),
|
|
452
|
-
action: action.at(boost.action),
|
|
453
|
-
validator: validator.at(boost.validator),
|
|
454
|
-
allowList: allowList.at(boost.allowList),
|
|
455
|
-
incentives: incentives.map((incentive, i) =>
|
|
456
|
-
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
457
|
-
incentive.at(boost.incentives.at(i)!),
|
|
458
|
-
),
|
|
459
|
-
protocolFee: boost.protocolFee,
|
|
460
|
-
referralFee: boost.referralFee,
|
|
461
|
-
maxParticipants: boost.maxParticipants,
|
|
462
|
-
owner: boost.owner,
|
|
463
|
-
});
|
|
581
|
+
return onChainPayload;
|
|
464
582
|
}
|
|
465
583
|
|
|
466
584
|
/**
|
|
@@ -472,8 +590,8 @@ export class BoostCore extends Deployable<
|
|
|
472
590
|
* @param {bigint} incentiveId
|
|
473
591
|
* @param {Address} address
|
|
474
592
|
* @param {Hex} data
|
|
475
|
-
* @param {?WriteParams
|
|
476
|
-
* @returns {
|
|
593
|
+
* @param {?WriteParams} [params]
|
|
594
|
+
* @returns {Promise<void>}
|
|
477
595
|
*/
|
|
478
596
|
public async claimIncentive(
|
|
479
597
|
boostId: bigint,
|
|
@@ -496,8 +614,8 @@ export class BoostCore extends Deployable<
|
|
|
496
614
|
* @param {bigint} incentiveId - The ID of the Incentive
|
|
497
615
|
* @param {Address} referrer - The address of the referrer (if any)
|
|
498
616
|
* @param {Hex} data- The data for the claim
|
|
499
|
-
* @param {?WriteParams
|
|
500
|
-
* @returns {
|
|
617
|
+
* @param {?WriteParams} [params]
|
|
618
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
501
619
|
*/
|
|
502
620
|
public async claimIncentiveRaw(
|
|
503
621
|
boostId: bigint,
|
|
@@ -509,7 +627,11 @@ export class BoostCore extends Deployable<
|
|
|
509
627
|
const { request, result } = await simulateBoostCoreClaimIncentive(
|
|
510
628
|
this._config,
|
|
511
629
|
{
|
|
512
|
-
|
|
630
|
+
...assertValidAddressByChainId(
|
|
631
|
+
this._config,
|
|
632
|
+
this.addresses,
|
|
633
|
+
params?.chain?.id || params?.chainId,
|
|
634
|
+
),
|
|
513
635
|
args: [boostId, incentiveId, referrer, data],
|
|
514
636
|
...this.optionallyAttachAccount(),
|
|
515
637
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -530,8 +652,8 @@ export class BoostCore extends Deployable<
|
|
|
530
652
|
* @param {Address} referrer
|
|
531
653
|
* @param {Hex} data
|
|
532
654
|
* @param {Address} claimant
|
|
533
|
-
* @param {?WriteParams
|
|
534
|
-
* @returns {
|
|
655
|
+
* @param {?WriteParams} [params]
|
|
656
|
+
* @returns {Promise<void>}
|
|
535
657
|
*/
|
|
536
658
|
public async claimIncentiveFor(
|
|
537
659
|
boostId: bigint,
|
|
@@ -563,8 +685,8 @@ export class BoostCore extends Deployable<
|
|
|
563
685
|
* @param {Address} referrer - The address of the referrer (if any)
|
|
564
686
|
* @param {Hex} data - The data for the claim
|
|
565
687
|
* @param {Address} claimant - The address of the user eligible for the incentive payout
|
|
566
|
-
* @param {?WriteParams
|
|
567
|
-
* @returns {
|
|
688
|
+
* @param {?WriteParams} [params]
|
|
689
|
+
* @returns {Promise<{ hash: Hex; result: void; }>}
|
|
568
690
|
*/
|
|
569
691
|
public async claimIncentiveForRaw(
|
|
570
692
|
boostId: bigint,
|
|
@@ -577,7 +699,11 @@ export class BoostCore extends Deployable<
|
|
|
577
699
|
const { request, result } = await simulateBoostCoreClaimIncentiveFor(
|
|
578
700
|
this._config,
|
|
579
701
|
{
|
|
580
|
-
|
|
702
|
+
...assertValidAddressByChainId(
|
|
703
|
+
this._config,
|
|
704
|
+
this.addresses,
|
|
705
|
+
params?.chain?.id || params?.chainId,
|
|
706
|
+
),
|
|
581
707
|
args: [boostId, incentiveId, referrer, data, claimant],
|
|
582
708
|
...this.optionallyAttachAccount(),
|
|
583
709
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -593,21 +719,37 @@ export class BoostCore extends Deployable<
|
|
|
593
719
|
*
|
|
594
720
|
* @public
|
|
595
721
|
* @async
|
|
596
|
-
* @param {bigint} id
|
|
597
|
-
* @param {?ReadParams
|
|
598
|
-
* @returns {
|
|
722
|
+
* @param {bigint | string} id
|
|
723
|
+
* @param {?ReadParams} [params]
|
|
724
|
+
* @returns {Promise<RawBoost>}
|
|
725
|
+
* @throws {@link BoostNotFoundError}
|
|
599
726
|
*/
|
|
600
727
|
public async readBoost(
|
|
601
|
-
|
|
728
|
+
_id: string | bigint,
|
|
602
729
|
params?: ReadParams<typeof boostCoreAbi, 'getBoost'>,
|
|
603
|
-
) {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
730
|
+
): Promise<RawBoost> {
|
|
731
|
+
try {
|
|
732
|
+
let id: bigint;
|
|
733
|
+
if (typeof _id === 'string') {
|
|
734
|
+
id = BigInt(_id);
|
|
735
|
+
} else id = _id;
|
|
736
|
+
return await readBoostCoreGetBoost(this._config, {
|
|
737
|
+
...assertValidAddressByChainId(
|
|
738
|
+
this._config,
|
|
739
|
+
this.addresses,
|
|
740
|
+
params?.chainId,
|
|
741
|
+
),
|
|
742
|
+
args: [id],
|
|
743
|
+
...this.optionallyAttachAccount(),
|
|
744
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
745
|
+
...(params as any),
|
|
746
|
+
});
|
|
747
|
+
// biome-ignore lint/suspicious/noExplicitAny: unknown error
|
|
748
|
+
} catch (e: any) {
|
|
749
|
+
if (e?.message?.includes('bounds'))
|
|
750
|
+
throw new BoostNotFoundError(String(_id));
|
|
751
|
+
throw e;
|
|
752
|
+
}
|
|
611
753
|
}
|
|
612
754
|
|
|
613
755
|
/**
|
|
@@ -616,8 +758,9 @@ export class BoostCore extends Deployable<
|
|
|
616
758
|
* @public
|
|
617
759
|
* @async
|
|
618
760
|
* @param {(string | bigint)} _id
|
|
619
|
-
* @param {?ReadParams
|
|
620
|
-
* @returns {
|
|
761
|
+
* @param {?ReadParams} [params]
|
|
762
|
+
* @returns {Promise<Boost>}
|
|
763
|
+
* @throws {@link BoostNotFoundError}
|
|
621
764
|
*/
|
|
622
765
|
public async getBoost(
|
|
623
766
|
_id: string | bigint,
|
|
@@ -627,13 +770,8 @@ export class BoostCore extends Deployable<
|
|
|
627
770
|
if (typeof _id === 'string') {
|
|
628
771
|
id = BigInt(_id);
|
|
629
772
|
} else id = _id;
|
|
630
|
-
const {
|
|
631
|
-
|
|
632
|
-
referralFee,
|
|
633
|
-
maxParticipants,
|
|
634
|
-
owner,
|
|
635
|
-
...boostPayload
|
|
636
|
-
} = await this.readBoost(id, params);
|
|
773
|
+
const { protocolFee, maxParticipants, owner, ...boostPayload } =
|
|
774
|
+
await this.readBoost(id, params);
|
|
637
775
|
const options: DeployableOptions = {
|
|
638
776
|
config: this._config,
|
|
639
777
|
account: this._account,
|
|
@@ -658,7 +796,6 @@ export class BoostCore extends Deployable<
|
|
|
658
796
|
allowList,
|
|
659
797
|
incentives,
|
|
660
798
|
protocolFee,
|
|
661
|
-
referralFee,
|
|
662
799
|
maxParticipants,
|
|
663
800
|
owner,
|
|
664
801
|
});
|
|
@@ -669,14 +806,18 @@ export class BoostCore extends Deployable<
|
|
|
669
806
|
*
|
|
670
807
|
* @public
|
|
671
808
|
* @async
|
|
672
|
-
* @param {?ReadParams
|
|
809
|
+
* @param {?ReadParams} [params]
|
|
673
810
|
* @returns {Promise<bigint>}
|
|
674
811
|
*/
|
|
675
812
|
public async getBoostCount(
|
|
676
813
|
params?: ReadParams<typeof boostCoreAbi, 'getBoostCount'>,
|
|
677
814
|
) {
|
|
678
815
|
return await readBoostCoreGetBoostCount(this._config, {
|
|
679
|
-
|
|
816
|
+
...assertValidAddressByChainId(
|
|
817
|
+
this._config,
|
|
818
|
+
this.addresses,
|
|
819
|
+
params?.chainId,
|
|
820
|
+
),
|
|
680
821
|
args: [],
|
|
681
822
|
...this.optionallyAttachAccount(),
|
|
682
823
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -690,7 +831,7 @@ export class BoostCore extends Deployable<
|
|
|
690
831
|
* @public
|
|
691
832
|
* @async
|
|
692
833
|
* @param {Address} address
|
|
693
|
-
* @param {?ReadParams
|
|
834
|
+
* @param {?ReadParams &
|
|
694
835
|
* ReadParams<typeof iAuthAbi, 'isAuthorized'>} [params]
|
|
695
836
|
* @returns {Promise<boolean>}
|
|
696
837
|
*/
|
|
@@ -699,7 +840,7 @@ export class BoostCore extends Deployable<
|
|
|
699
840
|
params?: ReadParams<typeof boostCoreAbi, 'createBoostAuth'> &
|
|
700
841
|
ReadParams<typeof iAuthAbi, 'isAuthorized'>,
|
|
701
842
|
) {
|
|
702
|
-
const auth = await this.createBoostAuth();
|
|
843
|
+
const auth = await this.createBoostAuth(params);
|
|
703
844
|
return readIAuthIsAuthorized(this._config, {
|
|
704
845
|
address: auth,
|
|
705
846
|
args: [address],
|
|
@@ -714,14 +855,18 @@ export class BoostCore extends Deployable<
|
|
|
714
855
|
*
|
|
715
856
|
* @public
|
|
716
857
|
* @async
|
|
717
|
-
* @param {?ReadParams
|
|
718
|
-
* @returns {
|
|
858
|
+
* @param {?ReadParams} [params]
|
|
859
|
+
* @returns {Promise<Address>}
|
|
719
860
|
*/
|
|
720
861
|
public async createBoostAuth(
|
|
721
862
|
params?: ReadParams<typeof boostCoreAbi, 'createBoostAuth'>,
|
|
722
863
|
) {
|
|
723
864
|
return await readBoostCoreCreateBoostAuth(this._config, {
|
|
724
|
-
|
|
865
|
+
...assertValidAddressByChainId(
|
|
866
|
+
this._config,
|
|
867
|
+
this.addresses,
|
|
868
|
+
params?.chainId,
|
|
869
|
+
),
|
|
725
870
|
args: [],
|
|
726
871
|
...this.optionallyAttachAccount(),
|
|
727
872
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -735,8 +880,8 @@ export class BoostCore extends Deployable<
|
|
|
735
880
|
* @public
|
|
736
881
|
* @async
|
|
737
882
|
* @param {Auth} auth
|
|
738
|
-
* @param {?WriteParams
|
|
739
|
-
* @returns {
|
|
883
|
+
* @param {?WriteParams} [params]
|
|
884
|
+
* @returns {Promise<void>}
|
|
740
885
|
*/
|
|
741
886
|
public async setCreateBoostAuth(
|
|
742
887
|
auth: Auth,
|
|
@@ -755,8 +900,8 @@ export class BoostCore extends Deployable<
|
|
|
755
900
|
* @public
|
|
756
901
|
* @async
|
|
757
902
|
* @param {Address} address
|
|
758
|
-
* @param {?WriteParams
|
|
759
|
-
* @returns {
|
|
903
|
+
* @param {?WriteParams} [params]
|
|
904
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
760
905
|
*/
|
|
761
906
|
public async setCreateBoostAuthRaw(
|
|
762
907
|
address: Address,
|
|
@@ -765,7 +910,11 @@ export class BoostCore extends Deployable<
|
|
|
765
910
|
const { request, result } = await simulateBoostCoreSetCreateBoostAuth(
|
|
766
911
|
this._config,
|
|
767
912
|
{
|
|
768
|
-
|
|
913
|
+
...assertValidAddressByChainId(
|
|
914
|
+
this._config,
|
|
915
|
+
this.addresses,
|
|
916
|
+
params?.chainId,
|
|
917
|
+
),
|
|
769
918
|
args: [address],
|
|
770
919
|
...this.optionallyAttachAccount(),
|
|
771
920
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -781,14 +930,18 @@ export class BoostCore extends Deployable<
|
|
|
781
930
|
*
|
|
782
931
|
* @public
|
|
783
932
|
* @async
|
|
784
|
-
* @param {?ReadParams
|
|
933
|
+
* @param {?ReadParams} [params]
|
|
785
934
|
* @returns {unknown}
|
|
786
935
|
*/
|
|
787
936
|
public async protocolFee(
|
|
788
937
|
params?: ReadParams<typeof boostCoreAbi, 'protocolFee'>,
|
|
789
938
|
) {
|
|
790
939
|
return await readBoostCoreProtocolFee(this._config, {
|
|
791
|
-
|
|
940
|
+
...assertValidAddressByChainId(
|
|
941
|
+
this._config,
|
|
942
|
+
this.addresses,
|
|
943
|
+
params?.chainId,
|
|
944
|
+
),
|
|
792
945
|
args: [],
|
|
793
946
|
...this.optionallyAttachAccount(),
|
|
794
947
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -801,14 +954,18 @@ export class BoostCore extends Deployable<
|
|
|
801
954
|
*
|
|
802
955
|
* @public
|
|
803
956
|
* @async
|
|
804
|
-
* @param {?ReadParams
|
|
805
|
-
* @returns {
|
|
957
|
+
* @param {?ReadParams} [params]
|
|
958
|
+
* @returns {Promise<Address>}
|
|
806
959
|
*/
|
|
807
960
|
public async protocolFeeReceiver(
|
|
808
961
|
params?: ReadParams<typeof boostCoreAbi, 'protocolFeeReceiver'>,
|
|
809
962
|
) {
|
|
810
963
|
return await readBoostCoreProtocolFeeReceiver(this._config, {
|
|
811
|
-
|
|
964
|
+
...assertValidAddressByChainId(
|
|
965
|
+
this._config,
|
|
966
|
+
this.addresses,
|
|
967
|
+
params?.chainId,
|
|
968
|
+
),
|
|
812
969
|
args: [],
|
|
813
970
|
...this.optionallyAttachAccount(),
|
|
814
971
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -822,8 +979,8 @@ export class BoostCore extends Deployable<
|
|
|
822
979
|
* @public
|
|
823
980
|
* @async
|
|
824
981
|
* @param {Address} address
|
|
825
|
-
* @param {?WriteParams
|
|
826
|
-
* @returns {
|
|
982
|
+
* @param {?WriteParams} [params]
|
|
983
|
+
* @returns {Promise<void>}
|
|
827
984
|
*/
|
|
828
985
|
public async setProcolFeeReceiver(
|
|
829
986
|
address: Address,
|
|
@@ -842,8 +999,8 @@ export class BoostCore extends Deployable<
|
|
|
842
999
|
* @public
|
|
843
1000
|
* @async
|
|
844
1001
|
* @param {Address} address
|
|
845
|
-
* @param {?WriteParams
|
|
846
|
-
* @returns {
|
|
1002
|
+
* @param {?WriteParams} [params]
|
|
1003
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
847
1004
|
*/
|
|
848
1005
|
public async setProcolFeeReceiverRaw(
|
|
849
1006
|
address: Address,
|
|
@@ -852,7 +1009,11 @@ export class BoostCore extends Deployable<
|
|
|
852
1009
|
const { request, result } = await simulateBoostCoreSetProtocolFeeReceiver(
|
|
853
1010
|
this._config,
|
|
854
1011
|
{
|
|
855
|
-
|
|
1012
|
+
...assertValidAddressByChainId(
|
|
1013
|
+
this._config,
|
|
1014
|
+
this.addresses,
|
|
1015
|
+
params?.chainId,
|
|
1016
|
+
),
|
|
856
1017
|
args: [address],
|
|
857
1018
|
...this.optionallyAttachAccount(),
|
|
858
1019
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -867,64 +1028,38 @@ export class BoostCore extends Deployable<
|
|
|
867
1028
|
}
|
|
868
1029
|
|
|
869
1030
|
/**
|
|
870
|
-
*
|
|
1031
|
+
* Retrieves the claim information from a transaction receipt.
|
|
871
1032
|
*
|
|
872
|
-
* @
|
|
873
|
-
* @
|
|
874
|
-
* @param {?ReadParams<typeof boostCoreAbi, 'claimFee'>} [params]
|
|
875
|
-
* @returns {unknown}
|
|
876
|
-
*/
|
|
877
|
-
public async claimFee(params?: ReadParams<typeof boostCoreAbi, 'claimFee'>) {
|
|
878
|
-
return await readBoostCoreClaimFee(this._config, {
|
|
879
|
-
address: this.assertValidAddress(),
|
|
880
|
-
args: [],
|
|
881
|
-
...this.optionallyAttachAccount(),
|
|
882
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
883
|
-
...(params as any),
|
|
884
|
-
});
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
/**
|
|
888
|
-
* Sets the claim fee.
|
|
1033
|
+
* @param {GetTransactionReceiptParameters} params - The parameters required to get the transaction receipt.
|
|
1034
|
+
* @returns {Promise<{ boostId: bigint, incentiveId: bigint, claimer: Address, amount: bigint } | undefined>} The claim information if found, undefined otherwise.
|
|
889
1035
|
*
|
|
890
|
-
* @
|
|
891
|
-
*
|
|
892
|
-
*
|
|
893
|
-
*
|
|
894
|
-
*
|
|
895
|
-
*/
|
|
896
|
-
public async setClaimFee(
|
|
897
|
-
claimFee: bigint,
|
|
898
|
-
params?: WriteParams<typeof boostCoreAbi, 'setClaimFee'>,
|
|
899
|
-
) {
|
|
900
|
-
return await this.awaitResult(this.setClaimFeeRaw(claimFee, params));
|
|
901
|
-
}
|
|
902
|
-
|
|
903
|
-
/**
|
|
904
|
-
* Sets the claim fee.
|
|
1036
|
+
* @description
|
|
1037
|
+
* This method retrieves the transaction receipt using the provided parameters,
|
|
1038
|
+
* then parses the logs to find the 'BoostClaimed' event.
|
|
1039
|
+
* If found, it returns the arguments of the event, which include the boost ID,
|
|
1040
|
+
* incentive ID, claimer address, and claimed amount.
|
|
905
1041
|
*
|
|
906
|
-
* @
|
|
907
|
-
*
|
|
908
|
-
*
|
|
909
|
-
*
|
|
910
|
-
*
|
|
1042
|
+
* @example
|
|
1043
|
+
* ```ts
|
|
1044
|
+
* const claimInfo = await boostCore.getClaimFromTransaction({
|
|
1045
|
+
* hash: '0x...',
|
|
1046
|
+
* chainId: 1
|
|
1047
|
+
* });
|
|
1048
|
+
* if (claimInfo) {
|
|
1049
|
+
* console.log(`Boost ${claimInfo.boostId} claimed by ${claimInfo.claimer}`);
|
|
1050
|
+
* }
|
|
1051
|
+
* ```
|
|
911
1052
|
*/
|
|
912
|
-
public async
|
|
913
|
-
|
|
914
|
-
params?: WriteParams<typeof boostCoreAbi, 'setClaimFee'>,
|
|
1053
|
+
public async getClaimFromTransaction(
|
|
1054
|
+
params: GetTransactionReceiptParameters,
|
|
915
1055
|
) {
|
|
916
|
-
const
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
...(params as any),
|
|
924
|
-
},
|
|
925
|
-
);
|
|
926
|
-
const hash = await writeBoostCoreSetClaimFee(this._config, request);
|
|
927
|
-
return { hash, result };
|
|
1056
|
+
const receipt = await getTransactionReceipt(this._config, params);
|
|
1057
|
+
const logs = parseEventLogs({
|
|
1058
|
+
abi: boostCoreAbi,
|
|
1059
|
+
eventName: 'BoostClaimed',
|
|
1060
|
+
logs: receipt.logs,
|
|
1061
|
+
});
|
|
1062
|
+
return logs.at(0)?.args;
|
|
928
1063
|
}
|
|
929
1064
|
|
|
930
1065
|
/**
|
|
@@ -1008,6 +1143,24 @@ export class BoostCore extends Deployable<
|
|
|
1008
1143
|
// isBase,
|
|
1009
1144
|
// );
|
|
1010
1145
|
// }
|
|
1146
|
+
/**
|
|
1147
|
+
* Bound {@link OpenAllowList} constructor that reuses the same configuration as the Boost Core instance.
|
|
1148
|
+
*
|
|
1149
|
+
* @example
|
|
1150
|
+
* ```ts
|
|
1151
|
+
* const list = core.OpenAllowList('0x') // is roughly equivalent to
|
|
1152
|
+
* const list = new OpenAllowList({ config: core._config, account: core._account }, '0x')
|
|
1153
|
+
* ```
|
|
1154
|
+
* @param {?boolean} [isBase]
|
|
1155
|
+
* @returns {OpenAllowList}
|
|
1156
|
+
*/
|
|
1157
|
+
OpenAllowList(isBase?: boolean) {
|
|
1158
|
+
return new OpenAllowList(
|
|
1159
|
+
{ config: this._config, account: this._account },
|
|
1160
|
+
undefined,
|
|
1161
|
+
isBase,
|
|
1162
|
+
);
|
|
1163
|
+
}
|
|
1011
1164
|
/**
|
|
1012
1165
|
* Bound {@link SimpleAllowList} constructor that reuses the same configuration as the Boost Core instance.
|
|
1013
1166
|
*
|
|
@@ -1212,6 +1365,30 @@ export class BoostCore extends Deployable<
|
|
|
1212
1365
|
isBase,
|
|
1213
1366
|
);
|
|
1214
1367
|
}
|
|
1368
|
+
|
|
1369
|
+
/**
|
|
1370
|
+
* Bound {@link ERC20VariableCriteriaIncentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1371
|
+
*
|
|
1372
|
+
* @example
|
|
1373
|
+
* ```ts
|
|
1374
|
+
* const validator = core.ERC20VariableCrtieriaIncentive({ ... }) // is roughly equivalent to
|
|
1375
|
+
* const validator = new ERC20VariableCrtieriaIncentive({ config: core._config, account: core._account }, { ... })
|
|
1376
|
+
* ```
|
|
1377
|
+
* @param {DeployablePayloadOrAddress<ERC20VariableCrtieriaIncentivePayload>} options
|
|
1378
|
+
* @param {?boolean} [isBase]
|
|
1379
|
+
* @returns {ERC20VariableCrtieriaIncentive}
|
|
1380
|
+
* */
|
|
1381
|
+
ERC20VariableCriteriaIncentive(
|
|
1382
|
+
options: DeployablePayloadOrAddress<ERC20VariableCriteriaIncentivePayload>,
|
|
1383
|
+
isBase?: boolean,
|
|
1384
|
+
) {
|
|
1385
|
+
return new ERC20VariableCriteriaIncentive(
|
|
1386
|
+
{ config: this._config, account: this._account },
|
|
1387
|
+
options,
|
|
1388
|
+
isBase,
|
|
1389
|
+
);
|
|
1390
|
+
}
|
|
1391
|
+
|
|
1215
1392
|
/**
|
|
1216
1393
|
* Bound {@link ERC20VariableIncentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1217
1394
|
*
|