@boostxyz/sdk 0.0.0-alpha.5 → 0.0.0-alpha.6
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 -0
- package/dist/Actions/Action.cjs.map +1 -0
- package/dist/Actions/Action.js +1 -0
- package/dist/Actions/Action.js.map +1 -0
- package/dist/Actions/EventAction.cjs +1 -0
- package/dist/Actions/EventAction.cjs.map +1 -0
- package/dist/Actions/EventAction.js +1 -0
- package/dist/Actions/EventAction.js.map +1 -0
- package/dist/AllowLists/AllowList.cjs +1 -0
- package/dist/AllowLists/AllowList.cjs.map +1 -0
- package/dist/AllowLists/AllowList.js +1 -0
- package/dist/AllowLists/AllowList.js.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
- package/dist/AllowLists/SimpleAllowList.js +1 -0
- package/dist/AllowLists/SimpleAllowList.js.map +1 -0
- package/dist/AllowLists/SimpleDenyList.cjs +1 -0
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
- package/dist/AllowLists/SimpleDenyList.js +1 -0
- package/dist/AllowLists/SimpleDenyList.js.map +1 -0
- package/dist/Auth/Auth.cjs +1 -0
- package/dist/Auth/Auth.cjs.map +1 -0
- package/dist/Auth/Auth.js +1 -0
- package/dist/Auth/Auth.js.map +1 -0
- package/dist/Auth/PassthroughAuth.cjs +1 -0
- package/dist/Auth/PassthroughAuth.cjs.map +1 -0
- package/dist/Auth/PassthroughAuth.js +1 -0
- package/dist/Auth/PassthroughAuth.js.map +1 -0
- package/dist/Boost.cjs +1 -0
- package/dist/Boost.cjs.map +1 -0
- package/dist/Boost.js +1 -0
- package/dist/Boost.js.map +1 -0
- package/dist/BoostCore.cjs +1 -0
- package/dist/BoostCore.cjs.map +1 -0
- package/dist/BoostCore.js +1 -0
- package/dist/BoostCore.js.map +1 -0
- package/dist/BoostRegistry.cjs +1 -0
- package/dist/BoostRegistry.cjs.map +1 -0
- package/dist/BoostRegistry.js +1 -0
- package/dist/BoostRegistry.js.map +1 -0
- package/dist/Budgets/Budget.cjs +1 -0
- package/dist/Budgets/Budget.cjs.map +1 -0
- package/dist/Budgets/Budget.js +1 -0
- package/dist/Budgets/Budget.js.map +1 -0
- package/dist/Budgets/ManagedBudget.cjs +1 -0
- package/dist/Budgets/ManagedBudget.cjs.map +1 -0
- package/dist/Budgets/ManagedBudget.js +1 -0
- package/dist/Budgets/ManagedBudget.js.map +1 -0
- package/dist/Deployable/Contract.cjs +1 -0
- package/dist/Deployable/Contract.cjs.map +1 -0
- package/dist/Deployable/Contract.js +1 -0
- package/dist/Deployable/Contract.js.map +1 -0
- package/dist/Deployable/Deployable.cjs +1 -0
- package/dist/Deployable/Deployable.cjs.map +1 -0
- package/dist/Deployable/Deployable.js +1 -0
- package/dist/Deployable/Deployable.js.map +1 -0
- package/dist/Deployable/DeployableTarget.cjs +1 -0
- package/dist/Deployable/DeployableTarget.cjs.map +1 -0
- package/dist/Deployable/DeployableTarget.js +1 -0
- package/dist/Deployable/DeployableTarget.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -0
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.js +1 -0
- package/dist/Incentives/AllowListIncentive.js.map +1 -0
- package/dist/Incentives/CGDAIncentive.cjs +1 -0
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
- package/dist/Incentives/CGDAIncentive.js +1 -0
- package/dist/Incentives/CGDAIncentive.js.map +1 -0
- package/dist/Incentives/ERC20Incentive.cjs +1 -0
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
- package/dist/Incentives/ERC20Incentive.js +1 -0
- package/dist/Incentives/ERC20Incentive.js.map +1 -0
- package/dist/Incentives/Incentive.cjs +1 -0
- package/dist/Incentives/Incentive.cjs.map +1 -0
- package/dist/Incentives/Incentive.js +1 -0
- package/dist/Incentives/Incentive.js.map +1 -0
- package/dist/Incentives/PointsIncentive.cjs +1 -0
- package/dist/Incentives/PointsIncentive.cjs.map +1 -0
- package/dist/Incentives/PointsIncentive.js +1 -0
- package/dist/Incentives/PointsIncentive.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -0
- package/dist/Validators/SignerValidator.cjs.map +1 -0
- package/dist/Validators/SignerValidator.js +1 -0
- package/dist/Validators/SignerValidator.js.map +1 -0
- package/dist/Validators/Validator.cjs +1 -0
- package/dist/Validators/Validator.cjs.map +1 -0
- package/dist/Validators/Validator.js +1 -0
- package/dist/Validators/Validator.js.map +1 -0
- package/dist/componentInterfaces-CKCBwG16.cjs +1 -0
- package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
- package/dist/componentInterfaces-DYkaxBda.js +1 -0
- package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
- package/dist/errors.cjs +1 -0
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.js +1 -0
- package/dist/errors.js.map +1 -0
- package/dist/generated-Cd-Fe7W7.cjs +1 -0
- package/dist/generated-Cd-Fe7W7.cjs.map +1 -0
- package/dist/generated-DGpIVcv5.js +1 -0
- package/dist/generated-DGpIVcv5.js.map +1 -0
- package/dist/index.cjs +1 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.js +1 -0
- package/dist/utils.js.map +1 -0
- package/package.json +3 -2
- package/src/Actions/Action.test.ts +77 -0
- package/src/Actions/Action.ts +61 -0
- package/src/Actions/ContractAction.test.ts +199 -0
- package/src/Actions/ContractAction.ts +238 -0
- package/src/Actions/ERC721MintAction.test.ts +112 -0
- package/src/Actions/ERC721MintAction.ts +238 -0
- package/src/Actions/EventAction.test.ts +182 -0
- package/src/Actions/EventAction.ts +382 -0
- package/src/AllowLists/AllowList.test.ts +64 -0
- package/src/AllowLists/AllowList.ts +60 -0
- package/src/AllowLists/SimpleAllowList.test.ts +52 -0
- package/src/AllowLists/SimpleAllowList.ts +240 -0
- package/src/AllowLists/SimpleDenyList.test.ts +52 -0
- package/src/AllowLists/SimpleDenyList.ts +289 -0
- package/src/Auth/Auth.ts +11 -0
- package/src/Auth/PassthroughAuth.test.ts +12 -0
- package/src/Auth/PassthroughAuth.ts +80 -0
- package/src/Boost.ts +155 -0
- package/src/BoostCore.test.ts +846 -0
- package/src/BoostCore.ts +1192 -0
- package/src/BoostRegistry.ts +449 -0
- package/src/Budgets/Budget.test.ts +27 -0
- package/src/Budgets/Budget.ts +61 -0
- package/src/Budgets/ManagedBudget.test.ts +154 -0
- package/src/Budgets/ManagedBudget.ts +743 -0
- package/src/Budgets/SimpleBudget.test.ts +152 -0
- package/src/Budgets/SimpleBudget.ts +521 -0
- package/src/Budgets/VestingBudget.test.ts +123 -0
- package/src/Budgets/VestingBudget.ts +532 -0
- package/src/Deployable/Contract.ts +229 -0
- package/src/Deployable/Deployable.ts +244 -0
- package/src/Deployable/DeployableTarget.ts +210 -0
- package/src/Incentives/AllowListIncentive.test.ts +146 -0
- package/src/Incentives/AllowListIncentive.ts +290 -0
- package/src/Incentives/CGDAIncentive.test.ts +136 -0
- package/src/Incentives/CGDAIncentive.ts +364 -0
- package/src/Incentives/ERC1155Incentive.test.ts +98 -0
- package/src/Incentives/ERC1155Incentive.ts +384 -0
- package/src/Incentives/ERC20Incentive.test.ts +141 -0
- package/src/Incentives/ERC20Incentive.ts +417 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +156 -0
- package/src/Incentives/ERC20VariableIncentive.ts +368 -0
- package/src/Incentives/Incentive.test.ts +92 -0
- package/src/Incentives/Incentive.ts +85 -0
- package/src/Incentives/PointsIncentive.test.ts +142 -0
- package/src/Incentives/PointsIncentive.ts +303 -0
- package/src/Validators/SignerValidator.test.ts +163 -0
- package/src/Validators/SignerValidator.ts +272 -0
- package/src/Validators/Validator.test.ts +21 -0
- package/src/Validators/Validator.ts +55 -0
- package/src/errors.ts +524 -0
- package/src/index.test.ts +40 -0
- package/src/index.ts +50 -0
- package/src/utils.test.ts +44 -0
- package/src/utils.ts +2247 -0
package/src/BoostCore.ts
ADDED
|
@@ -0,0 +1,1192 @@
|
|
|
1
|
+
import {
|
|
2
|
+
boostCoreAbi,
|
|
3
|
+
type iAuthAbi,
|
|
4
|
+
readBoostCoreClaimFee,
|
|
5
|
+
readBoostCoreCreateBoostAuth,
|
|
6
|
+
readBoostCoreGetBoost,
|
|
7
|
+
readBoostCoreGetBoostCount,
|
|
8
|
+
readBoostCoreProtocolFee,
|
|
9
|
+
readBoostCoreProtocolFeeReceiver,
|
|
10
|
+
readIAuthIsAuthorized,
|
|
11
|
+
simulateBoostCoreClaimIncentive,
|
|
12
|
+
simulateBoostCoreSetClaimFee,
|
|
13
|
+
simulateBoostCoreSetCreateBoostAuth,
|
|
14
|
+
simulateBoostCoreSetProtocolFeeReceiver,
|
|
15
|
+
writeBoostCoreClaimIncentive,
|
|
16
|
+
writeBoostCoreSetClaimFee,
|
|
17
|
+
writeBoostCoreSetCreateBoostAuth,
|
|
18
|
+
writeBoostCoreSetProtocolFeeReceiver,
|
|
19
|
+
} from '@boostxyz/evm';
|
|
20
|
+
import { bytecode } from '@boostxyz/evm/artifacts/contracts/BoostCore.sol/BoostCore.json';
|
|
21
|
+
import { getAccount, waitForTransactionReceipt } from '@wagmi/core';
|
|
22
|
+
import { createWriteContract } from '@wagmi/core/codegen';
|
|
23
|
+
import {
|
|
24
|
+
type Address,
|
|
25
|
+
type ContractEventName,
|
|
26
|
+
type Hex,
|
|
27
|
+
parseEventLogs,
|
|
28
|
+
zeroAddress,
|
|
29
|
+
zeroHash,
|
|
30
|
+
} from 'viem';
|
|
31
|
+
import { type Action, actionFromAddress } from './Actions/Action';
|
|
32
|
+
import { EventAction } from './Actions/EventAction';
|
|
33
|
+
import { type AllowList, allowListFromAddress } from './AllowLists/AllowList';
|
|
34
|
+
import {
|
|
35
|
+
SimpleAllowList,
|
|
36
|
+
type SimpleAllowListPayload,
|
|
37
|
+
} from './AllowLists/SimpleAllowList';
|
|
38
|
+
import {
|
|
39
|
+
SimpleDenyList,
|
|
40
|
+
type SimpleDenyListPayload,
|
|
41
|
+
} from './AllowLists/SimpleDenyList';
|
|
42
|
+
import { type Auth, PassthroughAuth } from './Auth/Auth';
|
|
43
|
+
import { Boost } from './Boost';
|
|
44
|
+
import { type Budget, budgetFromAddress } from './Budgets/Budget';
|
|
45
|
+
import {
|
|
46
|
+
ManagedBudget,
|
|
47
|
+
type ManagedBudgetPayload,
|
|
48
|
+
} from './Budgets/ManagedBudget';
|
|
49
|
+
import {
|
|
50
|
+
Deployable,
|
|
51
|
+
type DeployableOptions,
|
|
52
|
+
type DeployablePayloadOrAddress,
|
|
53
|
+
type GenericDeployableParams,
|
|
54
|
+
} from './Deployable/Deployable';
|
|
55
|
+
import {
|
|
56
|
+
AllowListIncentive,
|
|
57
|
+
type AllowListIncentivePayload,
|
|
58
|
+
} from './Incentives/AllowListIncentive';
|
|
59
|
+
import {
|
|
60
|
+
CGDAIncentive,
|
|
61
|
+
type CGDAIncentivePayload,
|
|
62
|
+
} from './Incentives/CGDAIncentive';
|
|
63
|
+
import {
|
|
64
|
+
ERC20Incentive,
|
|
65
|
+
type ERC20IncentivePayload,
|
|
66
|
+
} from './Incentives/ERC20Incentive';
|
|
67
|
+
import {
|
|
68
|
+
ERC20VariableIncentive,
|
|
69
|
+
type Incentive,
|
|
70
|
+
incentiveFromAddress,
|
|
71
|
+
} from './Incentives/Incentive';
|
|
72
|
+
import {
|
|
73
|
+
PointsIncentive,
|
|
74
|
+
type PointsIncentivePayload,
|
|
75
|
+
} from './Incentives/PointsIncentive';
|
|
76
|
+
import {
|
|
77
|
+
SignerValidator,
|
|
78
|
+
type SignerValidatorPayload,
|
|
79
|
+
} from './Validators/SignerValidator';
|
|
80
|
+
import { type Validator, validatorFromAddress } from './Validators/Validator';
|
|
81
|
+
import {
|
|
82
|
+
BoostCoreNoIdentifierEmitted,
|
|
83
|
+
BudgetMustAuthorizeBoostCore,
|
|
84
|
+
DeployableUnknownOwnerProvidedError,
|
|
85
|
+
NoContractAddressUponReceiptError,
|
|
86
|
+
} from './errors';
|
|
87
|
+
import {
|
|
88
|
+
type ERC20VariableIncentivePayload,
|
|
89
|
+
type EventActionPayload,
|
|
90
|
+
type GenericLog,
|
|
91
|
+
type BoostPayload as OnChainBoostPayload,
|
|
92
|
+
type ReadParams,
|
|
93
|
+
type Target,
|
|
94
|
+
type WriteParams,
|
|
95
|
+
prepareBoostPayload,
|
|
96
|
+
} from './utils';
|
|
97
|
+
|
|
98
|
+
export { boostCoreAbi };
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* The fixed address for the deployed Boost Core.
|
|
102
|
+
* By default, `new BoostCore` will use this address if not otherwise provided.
|
|
103
|
+
*
|
|
104
|
+
* @type {Address}
|
|
105
|
+
*/
|
|
106
|
+
export const BOOST_CORE_ADDRESS: Address = import.meta.env
|
|
107
|
+
.VITE_BOOST_CORE_ADDRESS;
|
|
108
|
+
|
|
109
|
+
/**
|
|
110
|
+
* A generic `viem.Log` event with support for `BoostCore` event types.
|
|
111
|
+
*
|
|
112
|
+
* @export
|
|
113
|
+
* @typedef {BoostCoreLog}
|
|
114
|
+
* @template {ContractEventName<typeof boostCoreAbi>} [event=ContractEventName<
|
|
115
|
+
* typeof boostCoreAbi
|
|
116
|
+
* >]
|
|
117
|
+
*/
|
|
118
|
+
export type BoostCoreLog<
|
|
119
|
+
event extends ContractEventName<typeof boostCoreAbi> = ContractEventName<
|
|
120
|
+
typeof boostCoreAbi
|
|
121
|
+
>,
|
|
122
|
+
> = GenericLog<typeof boostCoreAbi, event>;
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Boost Core instantiation options for a custom deployed instance.
|
|
126
|
+
*
|
|
127
|
+
* @export
|
|
128
|
+
* @interface BoostCoreDeployedOptions
|
|
129
|
+
* @typedef {BoostCoreDeployedOptions}
|
|
130
|
+
* @extends {DeployableOptions}
|
|
131
|
+
*/
|
|
132
|
+
export interface BoostCoreDeployedOptions extends DeployableOptions {
|
|
133
|
+
/**
|
|
134
|
+
* The address of a deployed, custom Boost Core contract.
|
|
135
|
+
*
|
|
136
|
+
* @type {?Address}
|
|
137
|
+
*/
|
|
138
|
+
address?: Address;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Typeguard to determine if a user is supplying a custom address for a Boost Core contract.
|
|
143
|
+
*
|
|
144
|
+
* @param {*} opts
|
|
145
|
+
* @returns {opts is BoostCoreDeployedOptions}
|
|
146
|
+
*/
|
|
147
|
+
// biome-ignore lint/suspicious/noExplicitAny: type guard
|
|
148
|
+
function isBoostCoreDeployed(opts: any): opts is BoostCoreDeployedOptions {
|
|
149
|
+
return opts.address;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Boost Core instantiation options when a user intends to deploy a new instance of Boost Core, setting their own registry address and protocol fee receiver.
|
|
154
|
+
*
|
|
155
|
+
* @export
|
|
156
|
+
* @interface BoostCoreOptionsWithPayload
|
|
157
|
+
* @typedef {BoostCoreOptionsWithPayload}
|
|
158
|
+
* @extends {DeployableOptions}
|
|
159
|
+
*/
|
|
160
|
+
export interface BoostCoreOptionsWithPayload extends DeployableOptions {
|
|
161
|
+
/**
|
|
162
|
+
* The address of a deployed Boost Registry contract.
|
|
163
|
+
*
|
|
164
|
+
* @type {Address}
|
|
165
|
+
*/
|
|
166
|
+
registryAddress: Address;
|
|
167
|
+
/**
|
|
168
|
+
* The address to send fees.
|
|
169
|
+
*
|
|
170
|
+
* @type {Address}
|
|
171
|
+
*/
|
|
172
|
+
protocolFeeReceiver: Address;
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* Typeguard to determine if a user is intending to deploy a new instance of the Boost Core contracts with {@link BoostCoreOptionsWithPayload}.
|
|
177
|
+
*
|
|
178
|
+
* @param {*} opts
|
|
179
|
+
* @returns {opts is BoostCoreOptionsWithPayload}
|
|
180
|
+
*/
|
|
181
|
+
// biome-ignore lint/suspicious/noExplicitAny: type guard
|
|
182
|
+
function isBoostCoreDeployable(opts: any): opts is BoostCoreOptionsWithPayload {
|
|
183
|
+
return opts.registryAddress && opts.protocolFeeReceiver;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* A union representing both of the valid Boost Core instantiation parameters.
|
|
188
|
+
*
|
|
189
|
+
* @export
|
|
190
|
+
* @typedef {BoostCoreConfig}
|
|
191
|
+
*/
|
|
192
|
+
export type BoostCoreConfig =
|
|
193
|
+
| BoostCoreDeployedOptions
|
|
194
|
+
| BoostCoreOptionsWithPayload;
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* The interface required to create a new Boost.
|
|
198
|
+
*
|
|
199
|
+
* @export
|
|
200
|
+
* @typedef {CreateBoostPayload}
|
|
201
|
+
*/
|
|
202
|
+
export type CreateBoostPayload = {
|
|
203
|
+
budget: Budget;
|
|
204
|
+
action: Action;
|
|
205
|
+
validator: Validator;
|
|
206
|
+
allowList: AllowList;
|
|
207
|
+
incentives: Array<Incentive>;
|
|
208
|
+
protocolFee?: bigint;
|
|
209
|
+
referralFee?: bigint;
|
|
210
|
+
maxParticipants?: bigint;
|
|
211
|
+
owner?: Address;
|
|
212
|
+
};
|
|
213
|
+
|
|
214
|
+
/**
|
|
215
|
+
* The core contract for the Boost protocol. Used to create and retrieve deployed Boosts.
|
|
216
|
+
*
|
|
217
|
+
* @export
|
|
218
|
+
* @class BoostCore
|
|
219
|
+
* @typedef {BoostCore}
|
|
220
|
+
* @extends {Deployable<[Address, Address]>}
|
|
221
|
+
*/
|
|
222
|
+
export class BoostCore extends Deployable<
|
|
223
|
+
[Address, Address],
|
|
224
|
+
typeof boostCoreAbi
|
|
225
|
+
> {
|
|
226
|
+
/**
|
|
227
|
+
* Creates an instance of BoostCore.
|
|
228
|
+
*
|
|
229
|
+
* @constructor
|
|
230
|
+
* @param {BoostCoreConfig} param0
|
|
231
|
+
* @param {Config} param0.config
|
|
232
|
+
* @param {?Account} [param0.account]
|
|
233
|
+
* @param {({ address?: Address; } | { registryAddress: Address; protocolFeeReceiver: Address; })} param0....options
|
|
234
|
+
*/
|
|
235
|
+
constructor({ config, account, ...options }: BoostCoreConfig) {
|
|
236
|
+
if (isBoostCoreDeployed(options) && options.address) {
|
|
237
|
+
super({ account, config }, options.address);
|
|
238
|
+
} else if (isBoostCoreDeployable(options)) {
|
|
239
|
+
super({ account, config }, [
|
|
240
|
+
options.registryAddress,
|
|
241
|
+
options.protocolFeeReceiver,
|
|
242
|
+
]);
|
|
243
|
+
} else {
|
|
244
|
+
super({ account, config }, BOOST_CORE_ADDRESS);
|
|
245
|
+
}
|
|
246
|
+
//@ts-expect-error I can't set this property on the class because for some reason it takes super out of constructor scope?
|
|
247
|
+
this.abi = boostCoreAbi;
|
|
248
|
+
} /**
|
|
249
|
+
* Create a new Boost.
|
|
250
|
+
*
|
|
251
|
+
* @public
|
|
252
|
+
* @async
|
|
253
|
+
* @param {CreateBoostPayload} _boostPayload
|
|
254
|
+
* @param {?DeployableOptions} [_options]
|
|
255
|
+
* @returns {Boost}
|
|
256
|
+
*/
|
|
257
|
+
public async createBoost(
|
|
258
|
+
_boostPayload: CreateBoostPayload,
|
|
259
|
+
_options?: DeployableOptions,
|
|
260
|
+
) {
|
|
261
|
+
const coreAddress = this.assertValidAddress();
|
|
262
|
+
const [payload, options] =
|
|
263
|
+
this.validateDeploymentConfig<CreateBoostPayload>(
|
|
264
|
+
_boostPayload,
|
|
265
|
+
_options,
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
let {
|
|
269
|
+
budget,
|
|
270
|
+
action,
|
|
271
|
+
validator,
|
|
272
|
+
allowList,
|
|
273
|
+
incentives,
|
|
274
|
+
protocolFee = 0n,
|
|
275
|
+
referralFee = 0n,
|
|
276
|
+
maxParticipants = 0n,
|
|
277
|
+
owner,
|
|
278
|
+
} = payload;
|
|
279
|
+
|
|
280
|
+
const boostFactory = createWriteContract({
|
|
281
|
+
abi: boostCoreAbi,
|
|
282
|
+
functionName: 'createBoost',
|
|
283
|
+
address: this.address,
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
if (!owner) {
|
|
287
|
+
owner =
|
|
288
|
+
this._account?.address ||
|
|
289
|
+
getAccount(options.config).address ||
|
|
290
|
+
zeroAddress;
|
|
291
|
+
if (owner === zeroAddress) {
|
|
292
|
+
throw new DeployableUnknownOwnerProvidedError();
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
let budgetPayload: OnChainBoostPayload['budget'] = zeroAddress;
|
|
297
|
+
if (budget.address) {
|
|
298
|
+
budgetPayload = budget.address;
|
|
299
|
+
if (!(await budget.isAuthorized(coreAddress))) {
|
|
300
|
+
throw new BudgetMustAuthorizeBoostCore(coreAddress);
|
|
301
|
+
}
|
|
302
|
+
} else {
|
|
303
|
+
// budgets are either instantiated with an address or payload, so in this branch payload will exist
|
|
304
|
+
const authorized = budget.payload?.authorized || [];
|
|
305
|
+
if (!authorized.includes(coreAddress)) {
|
|
306
|
+
throw new BudgetMustAuthorizeBoostCore(coreAddress);
|
|
307
|
+
}
|
|
308
|
+
const budgetHash = await budget.deployRaw(undefined, options);
|
|
309
|
+
const receipt = await waitForTransactionReceipt(options.config, {
|
|
310
|
+
hash: budgetHash,
|
|
311
|
+
});
|
|
312
|
+
if (!receipt.contractAddress)
|
|
313
|
+
throw new NoContractAddressUponReceiptError(receipt);
|
|
314
|
+
budgetPayload = receipt.contractAddress;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// if we're supplying an address, it could be a pre-initialized target
|
|
318
|
+
// if base is explicitly set to false, then it will not be initialized, and it will be referenced as is if it implements interface correctly
|
|
319
|
+
let actionPayload: OnChainBoostPayload['action'] = {
|
|
320
|
+
instance: zeroAddress,
|
|
321
|
+
isBase: true,
|
|
322
|
+
parameters: zeroHash,
|
|
323
|
+
};
|
|
324
|
+
if (action.address) {
|
|
325
|
+
const isBase = action.address === action.base || action.isBase;
|
|
326
|
+
actionPayload = {
|
|
327
|
+
isBase: isBase,
|
|
328
|
+
instance: action.address,
|
|
329
|
+
parameters: isBase
|
|
330
|
+
? action.buildParameters(undefined, options).args.at(0) || zeroHash
|
|
331
|
+
: zeroHash,
|
|
332
|
+
};
|
|
333
|
+
} else {
|
|
334
|
+
actionPayload.parameters =
|
|
335
|
+
action.buildParameters(undefined, options).args.at(0) || zeroHash;
|
|
336
|
+
actionPayload.instance = action.base;
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
let validatorPayload: OnChainBoostPayload['validator'] = {
|
|
340
|
+
instance: zeroAddress,
|
|
341
|
+
isBase: true,
|
|
342
|
+
parameters: zeroHash,
|
|
343
|
+
};
|
|
344
|
+
if (validator.address) {
|
|
345
|
+
const isBase = validator.address === validator.base || validator.isBase;
|
|
346
|
+
validatorPayload = {
|
|
347
|
+
isBase: isBase,
|
|
348
|
+
instance: validator.address,
|
|
349
|
+
parameters: isBase
|
|
350
|
+
? validator
|
|
351
|
+
.buildParameters(
|
|
352
|
+
{
|
|
353
|
+
signers: [owner],
|
|
354
|
+
validatorCaller: coreAddress,
|
|
355
|
+
},
|
|
356
|
+
options,
|
|
357
|
+
)
|
|
358
|
+
.args.at(0) || zeroHash
|
|
359
|
+
: zeroHash,
|
|
360
|
+
};
|
|
361
|
+
} else {
|
|
362
|
+
validatorPayload.parameters =
|
|
363
|
+
validator
|
|
364
|
+
.buildParameters(
|
|
365
|
+
{
|
|
366
|
+
signers: [owner],
|
|
367
|
+
validatorCaller: coreAddress,
|
|
368
|
+
},
|
|
369
|
+
options,
|
|
370
|
+
)
|
|
371
|
+
.args.at(0) || zeroHash;
|
|
372
|
+
validatorPayload.instance = validator.base;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
let allowListPayload: OnChainBoostPayload['allowList'] = {
|
|
376
|
+
instance: zeroAddress,
|
|
377
|
+
isBase: true,
|
|
378
|
+
parameters: zeroHash,
|
|
379
|
+
};
|
|
380
|
+
if (allowList.address) {
|
|
381
|
+
const isBase = allowList.address === allowList.base || allowList.isBase;
|
|
382
|
+
allowListPayload = {
|
|
383
|
+
isBase: isBase,
|
|
384
|
+
instance: allowList.address,
|
|
385
|
+
parameters: isBase
|
|
386
|
+
? zeroHash // allowList.buildParameters(undefined, options).args.at(0) || zeroHash
|
|
387
|
+
: zeroHash,
|
|
388
|
+
};
|
|
389
|
+
} else {
|
|
390
|
+
allowListPayload.parameters =
|
|
391
|
+
allowList.buildParameters(undefined, options).args.at(0) || zeroHash;
|
|
392
|
+
allowListPayload.instance = allowList.base;
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
let incentivesPayloads: Array<Target> = incentives.map(() => ({
|
|
396
|
+
instance: zeroAddress,
|
|
397
|
+
isBase: true,
|
|
398
|
+
parameters: zeroHash,
|
|
399
|
+
}));
|
|
400
|
+
for (let i = 0; i < incentives.length; i++) {
|
|
401
|
+
// biome-ignore lint/style/noNonNullAssertion: this will never be undefined
|
|
402
|
+
const incentive = incentives.at(i)!;
|
|
403
|
+
if (incentive.address) {
|
|
404
|
+
const isBase = incentive.address === incentive.base || incentive.isBase;
|
|
405
|
+
incentivesPayloads[i] = {
|
|
406
|
+
isBase: isBase,
|
|
407
|
+
instance: incentive.address,
|
|
408
|
+
parameters: isBase
|
|
409
|
+
? incentive.buildParameters(undefined, options).args.at(0) ||
|
|
410
|
+
zeroHash
|
|
411
|
+
: zeroHash,
|
|
412
|
+
};
|
|
413
|
+
} else {
|
|
414
|
+
incentivesPayloads[i]!.parameters =
|
|
415
|
+
incentive.buildParameters(undefined, options).args.at(0) || zeroHash;
|
|
416
|
+
incentivesPayloads[i]!.instance = incentive.base;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
const onChainPayload = {
|
|
421
|
+
budget: budgetPayload,
|
|
422
|
+
action: actionPayload,
|
|
423
|
+
validator: validatorPayload,
|
|
424
|
+
allowList: allowListPayload,
|
|
425
|
+
incentives: incentivesPayloads,
|
|
426
|
+
protocolFee,
|
|
427
|
+
referralFee,
|
|
428
|
+
maxParticipants,
|
|
429
|
+
owner,
|
|
430
|
+
};
|
|
431
|
+
|
|
432
|
+
const boostHash = await boostFactory(options.config, {
|
|
433
|
+
args: [prepareBoostPayload(onChainPayload)],
|
|
434
|
+
...this.optionallyAttachAccount(options.account),
|
|
435
|
+
});
|
|
436
|
+
const receipt = await waitForTransactionReceipt(options.config, {
|
|
437
|
+
hash: boostHash,
|
|
438
|
+
});
|
|
439
|
+
const boostCreatedLog = parseEventLogs({
|
|
440
|
+
abi: boostCoreAbi,
|
|
441
|
+
eventName: 'BoostCreated',
|
|
442
|
+
logs: receipt.logs,
|
|
443
|
+
}).at(0);
|
|
444
|
+
let boostId = 0n;
|
|
445
|
+
if (!boostCreatedLog) throw new BoostCoreNoIdentifierEmitted();
|
|
446
|
+
boostId = boostCreatedLog?.args.boostIndex;
|
|
447
|
+
const boost = await this.readBoost(boostId);
|
|
448
|
+
return new Boost({
|
|
449
|
+
id: boostId,
|
|
450
|
+
budget: budget.at(boost.budget),
|
|
451
|
+
action: action.at(boost.action),
|
|
452
|
+
validator: validator.at(boost.validator),
|
|
453
|
+
allowList: allowList.at(boost.allowList),
|
|
454
|
+
incentives: incentives.map((incentive, i) =>
|
|
455
|
+
incentive.at(boost.incentives.at(i)!),
|
|
456
|
+
),
|
|
457
|
+
protocolFee: boost.protocolFee,
|
|
458
|
+
referralFee: boost.referralFee,
|
|
459
|
+
maxParticipants: boost.maxParticipants,
|
|
460
|
+
owner: boost.owner,
|
|
461
|
+
});
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
/**
|
|
465
|
+
* Claims one incentive from a given `Boost` by `boostId` and `incentiveId`
|
|
466
|
+
*
|
|
467
|
+
* @public
|
|
468
|
+
* @async
|
|
469
|
+
* @param {bigint} boostId
|
|
470
|
+
* @param {bigint} incentiveId
|
|
471
|
+
* @param {Address} address
|
|
472
|
+
* @param {Hex} data
|
|
473
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'claimIncentive'>} [params]
|
|
474
|
+
* @returns {unknown}
|
|
475
|
+
*/
|
|
476
|
+
public async claimIncentive(
|
|
477
|
+
boostId: bigint,
|
|
478
|
+
incentiveId: bigint,
|
|
479
|
+
address: Address,
|
|
480
|
+
data: Hex,
|
|
481
|
+
params?: WriteParams<typeof boostCoreAbi, 'claimIncentive'>,
|
|
482
|
+
) {
|
|
483
|
+
return this.awaitResult(
|
|
484
|
+
this.claimIncentiveRaw(boostId, incentiveId, address, data, params),
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Claim an incentive for a Boost
|
|
490
|
+
*
|
|
491
|
+
* @public
|
|
492
|
+
* @async
|
|
493
|
+
* @param {bigint} boostId - The ID of the Boost
|
|
494
|
+
* @param {bigint} incentiveId - The ID of the Incentive
|
|
495
|
+
* @param {Address} address - The address of the referrer (if any)
|
|
496
|
+
* @param {Hex} data- The data for the claim
|
|
497
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'claimIncentive'>} [params]
|
|
498
|
+
* @returns {unknown}
|
|
499
|
+
*/
|
|
500
|
+
public async claimIncentiveRaw(
|
|
501
|
+
boostId: bigint,
|
|
502
|
+
incentiveId: bigint,
|
|
503
|
+
address: Address,
|
|
504
|
+
data: Hex,
|
|
505
|
+
params?: WriteParams<typeof boostCoreAbi, 'claimIncentive'>,
|
|
506
|
+
) {
|
|
507
|
+
const { request, result } = await simulateBoostCoreClaimIncentive(
|
|
508
|
+
this._config,
|
|
509
|
+
{
|
|
510
|
+
address: this.assertValidAddress(),
|
|
511
|
+
args: [boostId, incentiveId, address, data],
|
|
512
|
+
...this.optionallyAttachAccount(),
|
|
513
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
514
|
+
...(params as any),
|
|
515
|
+
},
|
|
516
|
+
);
|
|
517
|
+
const hash = await writeBoostCoreClaimIncentive(this._config, request);
|
|
518
|
+
return { hash, result };
|
|
519
|
+
}
|
|
520
|
+
|
|
521
|
+
/**
|
|
522
|
+
* Get a Boost by index, will return the raw on chain representation of a Boost.
|
|
523
|
+
*
|
|
524
|
+
* @public
|
|
525
|
+
* @async
|
|
526
|
+
* @param {bigint} id
|
|
527
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'getBoost'>} [params]
|
|
528
|
+
* @returns {unknown}
|
|
529
|
+
*/
|
|
530
|
+
public async readBoost(
|
|
531
|
+
id: bigint,
|
|
532
|
+
params?: ReadParams<typeof boostCoreAbi, 'getBoost'>,
|
|
533
|
+
) {
|
|
534
|
+
return readBoostCoreGetBoost(this._config, {
|
|
535
|
+
address: this.assertValidAddress(),
|
|
536
|
+
args: [id],
|
|
537
|
+
...this.optionallyAttachAccount(),
|
|
538
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
539
|
+
...(params as any),
|
|
540
|
+
});
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
/**
|
|
544
|
+
* Get a Boost by index, will return a new {@link Boost} with correct target implementations instantiated, ie `(await core.getBoost(0n)).allowList instanceof SimpleAllowList` vs `SimpleDenyList`
|
|
545
|
+
*
|
|
546
|
+
* @public
|
|
547
|
+
* @async
|
|
548
|
+
* @param {(string | bigint)} _id
|
|
549
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'getBoost'>} [params]
|
|
550
|
+
* @returns {unknown}
|
|
551
|
+
*/
|
|
552
|
+
public async getBoost(
|
|
553
|
+
_id: string | bigint,
|
|
554
|
+
params?: ReadParams<typeof boostCoreAbi, 'getBoost'>,
|
|
555
|
+
) {
|
|
556
|
+
let id: bigint;
|
|
557
|
+
if (typeof _id === 'string') {
|
|
558
|
+
id = BigInt(_id);
|
|
559
|
+
} else id = _id;
|
|
560
|
+
const {
|
|
561
|
+
protocolFee,
|
|
562
|
+
referralFee,
|
|
563
|
+
maxParticipants,
|
|
564
|
+
owner,
|
|
565
|
+
...boostPayload
|
|
566
|
+
} = await this.readBoost(id, params);
|
|
567
|
+
const options: DeployableOptions = {
|
|
568
|
+
config: this._config,
|
|
569
|
+
account: this._account,
|
|
570
|
+
};
|
|
571
|
+
const [action, budget, validator, allowList, incentives] =
|
|
572
|
+
await Promise.all([
|
|
573
|
+
actionFromAddress(options, boostPayload.action),
|
|
574
|
+
budgetFromAddress(options, boostPayload.budget),
|
|
575
|
+
validatorFromAddress(options, boostPayload.validator),
|
|
576
|
+
allowListFromAddress(options, boostPayload.allowList),
|
|
577
|
+
Promise.all(
|
|
578
|
+
boostPayload.incentives.map((incentiveAddress) =>
|
|
579
|
+
incentiveFromAddress(options, incentiveAddress),
|
|
580
|
+
),
|
|
581
|
+
),
|
|
582
|
+
]);
|
|
583
|
+
return new Boost({
|
|
584
|
+
id,
|
|
585
|
+
action,
|
|
586
|
+
budget,
|
|
587
|
+
validator,
|
|
588
|
+
allowList,
|
|
589
|
+
incentives,
|
|
590
|
+
protocolFee,
|
|
591
|
+
referralFee,
|
|
592
|
+
maxParticipants,
|
|
593
|
+
owner,
|
|
594
|
+
});
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
/**
|
|
598
|
+
* Retrieve the total number of deployed Boosts
|
|
599
|
+
*
|
|
600
|
+
* @public
|
|
601
|
+
* @async
|
|
602
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'getBoostCount'>} [params]
|
|
603
|
+
* @returns {Promise<bigint>}
|
|
604
|
+
*/
|
|
605
|
+
public async getBoostCount(
|
|
606
|
+
params?: ReadParams<typeof boostCoreAbi, 'getBoostCount'>,
|
|
607
|
+
) {
|
|
608
|
+
return readBoostCoreGetBoostCount(this._config, {
|
|
609
|
+
address: this.assertValidAddress(),
|
|
610
|
+
args: [],
|
|
611
|
+
...this.optionallyAttachAccount(),
|
|
612
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
613
|
+
...(params as any),
|
|
614
|
+
});
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
/**
|
|
618
|
+
* Checks if an address is authorized
|
|
619
|
+
*
|
|
620
|
+
* @public
|
|
621
|
+
* @async
|
|
622
|
+
* @param {Address} address
|
|
623
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'createBoostAuth'> &
|
|
624
|
+
* ReadParams<typeof iAuthAbi, 'isAuthorized'>} [params]
|
|
625
|
+
* @returns {Promise<boolean>}
|
|
626
|
+
*/
|
|
627
|
+
public async isAuthorized(
|
|
628
|
+
address: Address,
|
|
629
|
+
params?: ReadParams<typeof boostCoreAbi, 'createBoostAuth'> &
|
|
630
|
+
ReadParams<typeof iAuthAbi, 'isAuthorized'>,
|
|
631
|
+
) {
|
|
632
|
+
const auth = await this.createBoostAuth();
|
|
633
|
+
return readIAuthIsAuthorized(this._config, {
|
|
634
|
+
address: auth,
|
|
635
|
+
args: [address],
|
|
636
|
+
...this.optionallyAttachAccount(),
|
|
637
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
638
|
+
...(params as any),
|
|
639
|
+
});
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
/**
|
|
643
|
+
* Retrieve the address of the current creation auth provider.
|
|
644
|
+
*
|
|
645
|
+
* @public
|
|
646
|
+
* @async
|
|
647
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'createBoostAuth'>} [params]
|
|
648
|
+
* @returns {unknown}
|
|
649
|
+
*/
|
|
650
|
+
public async createBoostAuth(
|
|
651
|
+
params?: ReadParams<typeof boostCoreAbi, 'createBoostAuth'>,
|
|
652
|
+
) {
|
|
653
|
+
return readBoostCoreCreateBoostAuth(this._config, {
|
|
654
|
+
address: this.assertValidAddress(),
|
|
655
|
+
args: [],
|
|
656
|
+
...this.optionallyAttachAccount(),
|
|
657
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
658
|
+
...(params as any),
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
|
|
662
|
+
/**
|
|
663
|
+
* Replace the current auth scheme.
|
|
664
|
+
*
|
|
665
|
+
* @public
|
|
666
|
+
* @async
|
|
667
|
+
* @param {Auth} auth
|
|
668
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'setCreateBoostAuth'>} [params]
|
|
669
|
+
* @returns {unknown}
|
|
670
|
+
*/
|
|
671
|
+
public async setCreateBoostAuth(
|
|
672
|
+
auth: Auth,
|
|
673
|
+
params?: WriteParams<typeof boostCoreAbi, 'setCreateBoostAuth'>,
|
|
674
|
+
) {
|
|
675
|
+
return this.awaitResult(
|
|
676
|
+
this.setCreateBoostAuthRaw(auth.assertValidAddress(), {
|
|
677
|
+
...params,
|
|
678
|
+
}),
|
|
679
|
+
);
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
/**
|
|
683
|
+
* Set the createBoostAuth address
|
|
684
|
+
*
|
|
685
|
+
* @public
|
|
686
|
+
* @async
|
|
687
|
+
* @param {Address} address
|
|
688
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'setCreateBoostAuth'>} [params]
|
|
689
|
+
* @returns {unknown}
|
|
690
|
+
*/
|
|
691
|
+
public async setCreateBoostAuthRaw(
|
|
692
|
+
address: Address,
|
|
693
|
+
params?: WriteParams<typeof boostCoreAbi, 'setCreateBoostAuth'>,
|
|
694
|
+
) {
|
|
695
|
+
const { request, result } = await simulateBoostCoreSetCreateBoostAuth(
|
|
696
|
+
this._config,
|
|
697
|
+
{
|
|
698
|
+
address: this.assertValidAddress(),
|
|
699
|
+
args: [address],
|
|
700
|
+
...this.optionallyAttachAccount(),
|
|
701
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
702
|
+
...(params as any),
|
|
703
|
+
},
|
|
704
|
+
);
|
|
705
|
+
const hash = await writeBoostCoreSetCreateBoostAuth(this._config, request);
|
|
706
|
+
return { hash, result };
|
|
707
|
+
}
|
|
708
|
+
|
|
709
|
+
/**
|
|
710
|
+
* Get the protocol fee.
|
|
711
|
+
*
|
|
712
|
+
* @public
|
|
713
|
+
* @async
|
|
714
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'protocolFee'>} [params]
|
|
715
|
+
* @returns {unknown}
|
|
716
|
+
*/
|
|
717
|
+
public async protocolFee(
|
|
718
|
+
params?: ReadParams<typeof boostCoreAbi, 'protocolFee'>,
|
|
719
|
+
) {
|
|
720
|
+
return readBoostCoreProtocolFee(this._config, {
|
|
721
|
+
address: this.assertValidAddress(),
|
|
722
|
+
args: [],
|
|
723
|
+
...this.optionallyAttachAccount(),
|
|
724
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
725
|
+
...(params as any),
|
|
726
|
+
});
|
|
727
|
+
}
|
|
728
|
+
|
|
729
|
+
/**
|
|
730
|
+
* Get the protocol fee receiver.
|
|
731
|
+
*
|
|
732
|
+
* @public
|
|
733
|
+
* @async
|
|
734
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'protocolFeeReceiver'>} [params]
|
|
735
|
+
* @returns {unknown}
|
|
736
|
+
*/
|
|
737
|
+
public async protocolFeeReceiver(
|
|
738
|
+
params?: ReadParams<typeof boostCoreAbi, 'protocolFeeReceiver'>,
|
|
739
|
+
) {
|
|
740
|
+
return readBoostCoreProtocolFeeReceiver(this._config, {
|
|
741
|
+
address: this.assertValidAddress(),
|
|
742
|
+
args: [],
|
|
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
|
+
}
|
|
748
|
+
|
|
749
|
+
/**
|
|
750
|
+
* Set the protocol fee receiver address. This function is only callable by the owner.
|
|
751
|
+
*
|
|
752
|
+
* @public
|
|
753
|
+
* @async
|
|
754
|
+
* @param {Address} address
|
|
755
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'setProtocolFeeReceiver'>} [params]
|
|
756
|
+
* @returns {unknown}
|
|
757
|
+
*/
|
|
758
|
+
public async setProcolFeeReceiver(
|
|
759
|
+
address: Address,
|
|
760
|
+
params?: WriteParams<typeof boostCoreAbi, 'setProtocolFeeReceiver'>,
|
|
761
|
+
) {
|
|
762
|
+
return this.awaitResult(
|
|
763
|
+
this.setProcolFeeReceiverRaw(address, {
|
|
764
|
+
...params,
|
|
765
|
+
}),
|
|
766
|
+
);
|
|
767
|
+
}
|
|
768
|
+
|
|
769
|
+
/**
|
|
770
|
+
* Set the protocol fee receiver address. This function is only callable by the owner.
|
|
771
|
+
*
|
|
772
|
+
* @public
|
|
773
|
+
* @async
|
|
774
|
+
* @param {Address} address
|
|
775
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'setProtocolFeeReceiver'>} [params]
|
|
776
|
+
* @returns {unknown}
|
|
777
|
+
*/
|
|
778
|
+
public async setProcolFeeReceiverRaw(
|
|
779
|
+
address: Address,
|
|
780
|
+
params?: WriteParams<typeof boostCoreAbi, 'setProtocolFeeReceiver'>,
|
|
781
|
+
) {
|
|
782
|
+
const { request, result } = await simulateBoostCoreSetProtocolFeeReceiver(
|
|
783
|
+
this._config,
|
|
784
|
+
{
|
|
785
|
+
address: this.assertValidAddress(),
|
|
786
|
+
args: [address],
|
|
787
|
+
...this.optionallyAttachAccount(),
|
|
788
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
789
|
+
...(params as any),
|
|
790
|
+
},
|
|
791
|
+
);
|
|
792
|
+
const hash = await writeBoostCoreSetProtocolFeeReceiver(
|
|
793
|
+
this._config,
|
|
794
|
+
request,
|
|
795
|
+
);
|
|
796
|
+
return { hash, result };
|
|
797
|
+
}
|
|
798
|
+
|
|
799
|
+
/**
|
|
800
|
+
* Get the claim fee.
|
|
801
|
+
*
|
|
802
|
+
* @public
|
|
803
|
+
* @async
|
|
804
|
+
* @param {?ReadParams<typeof boostCoreAbi, 'claimFee'>} [params]
|
|
805
|
+
* @returns {unknown}
|
|
806
|
+
*/
|
|
807
|
+
public async claimFee(params?: ReadParams<typeof boostCoreAbi, 'claimFee'>) {
|
|
808
|
+
return readBoostCoreClaimFee(this._config, {
|
|
809
|
+
address: this.assertValidAddress(),
|
|
810
|
+
args: [],
|
|
811
|
+
...this.optionallyAttachAccount(),
|
|
812
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
813
|
+
...(params as any),
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
|
|
817
|
+
/**
|
|
818
|
+
* Sets the claim fee.
|
|
819
|
+
*
|
|
820
|
+
* @public
|
|
821
|
+
* @async
|
|
822
|
+
* @param {bigint} claimFee
|
|
823
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'setClaimFee'>} [params]
|
|
824
|
+
* @returns {unknown}
|
|
825
|
+
*/
|
|
826
|
+
public async setClaimFee(
|
|
827
|
+
claimFee: bigint,
|
|
828
|
+
params?: WriteParams<typeof boostCoreAbi, 'setClaimFee'>,
|
|
829
|
+
) {
|
|
830
|
+
return this.awaitResult(this.setClaimFeeRaw(claimFee, params));
|
|
831
|
+
}
|
|
832
|
+
|
|
833
|
+
/**
|
|
834
|
+
* Sets the claim fee.
|
|
835
|
+
*
|
|
836
|
+
* @public
|
|
837
|
+
* @async
|
|
838
|
+
* @param {bigint} claimFee
|
|
839
|
+
* @param {?WriteParams<typeof boostCoreAbi, 'setClaimFee'>} [params]
|
|
840
|
+
* @returns {unknown}
|
|
841
|
+
*/
|
|
842
|
+
public async setClaimFeeRaw(
|
|
843
|
+
claimFee: bigint,
|
|
844
|
+
params?: WriteParams<typeof boostCoreAbi, 'setClaimFee'>,
|
|
845
|
+
) {
|
|
846
|
+
const { request, result } = await simulateBoostCoreSetClaimFee(
|
|
847
|
+
this._config,
|
|
848
|
+
{
|
|
849
|
+
address: this.assertValidAddress(),
|
|
850
|
+
args: [claimFee],
|
|
851
|
+
...this.optionallyAttachAccount(),
|
|
852
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
853
|
+
...(params as any),
|
|
854
|
+
},
|
|
855
|
+
);
|
|
856
|
+
const hash = await writeBoostCoreSetClaimFee(this._config, request);
|
|
857
|
+
return { hash, result };
|
|
858
|
+
}
|
|
859
|
+
|
|
860
|
+
/**
|
|
861
|
+
* Bound {@link PassthroughAuth} constructor that reuses the same configuration as the Boost Core instance.
|
|
862
|
+
*
|
|
863
|
+
* @example
|
|
864
|
+
* ```ts
|
|
865
|
+
* const auth = core.PassthroughAuth('0x') // is roughly equivalent to
|
|
866
|
+
* const auth = new PassthroughAuth({ config: core._config, account: core._account }, '0x')
|
|
867
|
+
* ```
|
|
868
|
+
* @param {DeployablePayloadOrAddress<{}>} options
|
|
869
|
+
* @param {?boolean} [isBase]
|
|
870
|
+
* @returns {PassthroughAuth}
|
|
871
|
+
*/
|
|
872
|
+
PassthroughAuth(address?: Address) {
|
|
873
|
+
return new PassthroughAuth(
|
|
874
|
+
{ config: this._config, account: this._account },
|
|
875
|
+
address,
|
|
876
|
+
);
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
// /**
|
|
880
|
+
// * Bound {@link ContractAction} constructor that reuses the same configuration as the Boost Core instance.
|
|
881
|
+
// *
|
|
882
|
+
// * @example
|
|
883
|
+
// * ```ts
|
|
884
|
+
// * const action = core.ContractAction('0x') // is roughly equivalent to
|
|
885
|
+
// * const action = new ContractAction({ config: core._config, account: core._account }, '0x')
|
|
886
|
+
// * ```
|
|
887
|
+
// * @param {DeployablePayloadOrAddress<ContractActionPayload>} options
|
|
888
|
+
// * @param {?boolean} [isBase]
|
|
889
|
+
// * @returns {ContractAction}
|
|
890
|
+
// */
|
|
891
|
+
// ContractAction(
|
|
892
|
+
// options: DeployablePayloadOrAddress<ContractActionPayload>,
|
|
893
|
+
// isBase?: boolean,
|
|
894
|
+
// ) {
|
|
895
|
+
// return new ContractAction(
|
|
896
|
+
// { config: this._config, account: this._account },
|
|
897
|
+
// options,
|
|
898
|
+
// isBase,
|
|
899
|
+
// );
|
|
900
|
+
// }
|
|
901
|
+
|
|
902
|
+
/**
|
|
903
|
+
* Bound {@link EventAction} constructor that reuses the same configuration as the Boost Core instance.
|
|
904
|
+
*
|
|
905
|
+
* @example
|
|
906
|
+
* ```ts
|
|
907
|
+
* const action = core.EventAction('0x') // is roughly equivalent to
|
|
908
|
+
* const action = new EventAction({ config: core._config, account: core._account }, '0x')
|
|
909
|
+
*/
|
|
910
|
+
EventAction(
|
|
911
|
+
options: DeployablePayloadOrAddress<EventActionPayload>,
|
|
912
|
+
isBase?: boolean,
|
|
913
|
+
) {
|
|
914
|
+
return new EventAction(
|
|
915
|
+
{ config: this._config, account: this._account },
|
|
916
|
+
options,
|
|
917
|
+
isBase,
|
|
918
|
+
);
|
|
919
|
+
}
|
|
920
|
+
// /**
|
|
921
|
+
// * Bound {@link ERC721MintAction} constructor that reuses the same configuration as the Boost Core instance.
|
|
922
|
+
// *
|
|
923
|
+
// * @example
|
|
924
|
+
// * ```ts
|
|
925
|
+
// * const action = core.ERC721MintAction('0x') // is roughly equivalent to
|
|
926
|
+
// * const action = new ERC721MintAction({ config: core._config, account: core._account }, '0x')
|
|
927
|
+
// * ```
|
|
928
|
+
// * @param {DeployablePayloadOrAddress<ERC721MintActionPayload>} options
|
|
929
|
+
// * @param {?boolean} [isBase]
|
|
930
|
+
// * @returns {ERC721MintAction}
|
|
931
|
+
// */
|
|
932
|
+
// ERC721MintAction(
|
|
933
|
+
// options: DeployablePayloadOrAddress<ERC721MintActionPayload>,
|
|
934
|
+
// isBase?: boolean,
|
|
935
|
+
// ) {
|
|
936
|
+
// return new ERC721MintAction(
|
|
937
|
+
// { config: this._config, account: this._account },
|
|
938
|
+
// options,
|
|
939
|
+
// isBase,
|
|
940
|
+
// );
|
|
941
|
+
// }
|
|
942
|
+
/**
|
|
943
|
+
* Bound {@link SimpleAllowList} constructor that reuses the same configuration as the Boost Core instance.
|
|
944
|
+
*
|
|
945
|
+
* @example
|
|
946
|
+
* ```ts
|
|
947
|
+
* const list = core.SimpleAllowList('0x') // is roughly equivalent to
|
|
948
|
+
* const list = new SimpleAllowList({ config: core._config, account: core._account }, '0x')
|
|
949
|
+
* ```
|
|
950
|
+
* @param {DeployablePayloadOrAddress<SimpleAllowListPayload>} options
|
|
951
|
+
* @param {?boolean} [isBase]
|
|
952
|
+
* @returns {SimpleAllowList}
|
|
953
|
+
*/
|
|
954
|
+
SimpleAllowList(
|
|
955
|
+
options: DeployablePayloadOrAddress<SimpleAllowListPayload>,
|
|
956
|
+
isBase?: boolean,
|
|
957
|
+
) {
|
|
958
|
+
return new SimpleAllowList(
|
|
959
|
+
{ config: this._config, account: this._account },
|
|
960
|
+
options,
|
|
961
|
+
isBase,
|
|
962
|
+
);
|
|
963
|
+
}
|
|
964
|
+
/**
|
|
965
|
+
* Bound {@link SimpleDenyList} constructor that reuses the same configuration as the Boost Core instance.
|
|
966
|
+
*
|
|
967
|
+
* @example
|
|
968
|
+
* ```ts
|
|
969
|
+
* const list = core.SimpleDenyList('0x') // is roughly equivalent to
|
|
970
|
+
* const list = new SimpleDenyList({ config: core._config, account: core._account }, '0x')
|
|
971
|
+
* ```
|
|
972
|
+
* @param {DeployablePayloadOrAddress<SimpleDenyListPayload>} options
|
|
973
|
+
* @param {?boolean} [isBase]
|
|
974
|
+
* @returns {SimpleDenyList}
|
|
975
|
+
*/
|
|
976
|
+
SimpleDenyList(
|
|
977
|
+
options: DeployablePayloadOrAddress<SimpleDenyListPayload>,
|
|
978
|
+
isBase?: boolean,
|
|
979
|
+
) {
|
|
980
|
+
return new SimpleDenyList(
|
|
981
|
+
{ config: this._config, account: this._account },
|
|
982
|
+
options,
|
|
983
|
+
isBase,
|
|
984
|
+
);
|
|
985
|
+
}
|
|
986
|
+
// /**
|
|
987
|
+
// * Bound {@link SimpleBudget} constructor that reuses the same configuration as the Boost Core instance.
|
|
988
|
+
// *
|
|
989
|
+
// * @example
|
|
990
|
+
// * ```ts
|
|
991
|
+
// * const budget = core.SimpleBudget('0x') // is roughly equivalent to
|
|
992
|
+
// * const budget = new SimpleBudget({ config: core._config, account: core._account }, '0x')
|
|
993
|
+
// * ```
|
|
994
|
+
// * @param {DeployablePayloadOrAddress<SimpleBudgetPayload>} options
|
|
995
|
+
// * @returns {SimpleBudget}
|
|
996
|
+
// */
|
|
997
|
+
// SimpleBudget(options: DeployablePayloadOrAddress<SimpleBudgetPayload>) {
|
|
998
|
+
// return new SimpleBudget(
|
|
999
|
+
// { config: this._config, account: this._account },
|
|
1000
|
+
// options,
|
|
1001
|
+
// );
|
|
1002
|
+
// }
|
|
1003
|
+
/**
|
|
1004
|
+
* Bound {@link ManagedBudget} constructor that reuses the same configuration as the Boost Core instance.
|
|
1005
|
+
*
|
|
1006
|
+
* @example
|
|
1007
|
+
* ```ts
|
|
1008
|
+
* const budget = core.ManagedBudget('0x') // is roughly equivalent to
|
|
1009
|
+
* const budget = new ManagedBudget({ config: core._config, account: core._account }, '0x')
|
|
1010
|
+
* ```
|
|
1011
|
+
* @param {DeployablePayloadOrAddress<ManagedBudgetPayload>} options
|
|
1012
|
+
* @returns {ManagedBudget}
|
|
1013
|
+
*/
|
|
1014
|
+
ManagedBudget(options: DeployablePayloadOrAddress<ManagedBudgetPayload>) {
|
|
1015
|
+
return new ManagedBudget(
|
|
1016
|
+
{ config: this._config, account: this._account },
|
|
1017
|
+
options,
|
|
1018
|
+
);
|
|
1019
|
+
}
|
|
1020
|
+
// /**
|
|
1021
|
+
// * Bound {@link VestingBudget} constructor that reuses the same configuration as the Boost Core instance.
|
|
1022
|
+
// *
|
|
1023
|
+
// * @example
|
|
1024
|
+
// * ```ts
|
|
1025
|
+
// * const budget = core.VestingBudget('0x') // is roughly equivalent to
|
|
1026
|
+
// * const budget = new VestingBudget({ config: core._config, account: core._account }, '0x')
|
|
1027
|
+
// * ```
|
|
1028
|
+
// * @param {DeployablePayloadOrAddress<VestingBudgetPayload>} options
|
|
1029
|
+
// * @returns {VestingBudget}
|
|
1030
|
+
// */
|
|
1031
|
+
// VestingBudget(options: DeployablePayloadOrAddress<VestingBudgetPayload>) {
|
|
1032
|
+
// return new VestingBudget(
|
|
1033
|
+
// { config: this._config, account: this._account },
|
|
1034
|
+
// options,
|
|
1035
|
+
// );
|
|
1036
|
+
// }
|
|
1037
|
+
/**
|
|
1038
|
+
* Bound {@link AllowListIncentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1039
|
+
*
|
|
1040
|
+
* @example
|
|
1041
|
+
* ```ts
|
|
1042
|
+
* const incentive = core.AllowListIncentive({ ... }) // is roughly equivalent to
|
|
1043
|
+
* const incentive = new AllowListIncentive({ config: core._config, account: core._account }, { ... })
|
|
1044
|
+
* ```
|
|
1045
|
+
* @param {DeployablePayloadOrAddress<VestingBudgetPayload>} options
|
|
1046
|
+
* @returns {VestingBudget}
|
|
1047
|
+
*/
|
|
1048
|
+
AllowListIncentive(options: AllowListIncentivePayload) {
|
|
1049
|
+
return new AllowListIncentive(
|
|
1050
|
+
{ config: this._config, account: this._account },
|
|
1051
|
+
options,
|
|
1052
|
+
);
|
|
1053
|
+
}
|
|
1054
|
+
/**
|
|
1055
|
+
* Bound {@link CGDAIncentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1056
|
+
*
|
|
1057
|
+
* @example
|
|
1058
|
+
* ```ts
|
|
1059
|
+
* const incentive = core.CGDAIncentive({ ... }) // is roughly equivalent to
|
|
1060
|
+
* const incentive = new CGDAIncentive({ config: core._config, account: core._account }, { ... })
|
|
1061
|
+
* ```
|
|
1062
|
+
* @param {CGDAIncentivePayload} options
|
|
1063
|
+
* @returns {CGDAIncentive}
|
|
1064
|
+
*/
|
|
1065
|
+
CGDAIncentive(options: CGDAIncentivePayload) {
|
|
1066
|
+
return new CGDAIncentive(
|
|
1067
|
+
{ config: this._config, account: this._account },
|
|
1068
|
+
options,
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
/**
|
|
1072
|
+
* Bound {@link ERC20Incentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1073
|
+
*
|
|
1074
|
+
* @example
|
|
1075
|
+
* ```ts
|
|
1076
|
+
* const incentive = core.ERC20Incentive({ ... }) // is roughly equivalent to
|
|
1077
|
+
* const incentive = new ERC20Incentive({ config: core._config, account: core._account }, { ... })
|
|
1078
|
+
* ```
|
|
1079
|
+
* @param {ERC20IncentivePayload} options
|
|
1080
|
+
* @returns {ERC20Incentive}
|
|
1081
|
+
*/
|
|
1082
|
+
ERC20Incentive(options: ERC20IncentivePayload) {
|
|
1083
|
+
return new ERC20Incentive(
|
|
1084
|
+
{ config: this._config, account: this._account },
|
|
1085
|
+
options,
|
|
1086
|
+
);
|
|
1087
|
+
}
|
|
1088
|
+
// /**
|
|
1089
|
+
// * Temporarily disabled until low level ABI encoding bugs are resolved
|
|
1090
|
+
// * Bound {@link ERC1155Incentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1091
|
+
// *
|
|
1092
|
+
// * @experimental
|
|
1093
|
+
// * @example
|
|
1094
|
+
// * ```ts
|
|
1095
|
+
// * const incentive = core.ERC1155Incentive({ ... }) // is roughly equivalent to
|
|
1096
|
+
// * const incentive = new ERC1155Incentive({ config: core._config, account: core._account }, { ... })
|
|
1097
|
+
// * ```
|
|
1098
|
+
// * @param {ERC1155IncentivePayload} options
|
|
1099
|
+
// * @returns {ERC1155Incentive}
|
|
1100
|
+
// */
|
|
1101
|
+
// ERC1155Incentive(options: ERC1155IncentivePayload) {
|
|
1102
|
+
// return new ERC1155Incentive(
|
|
1103
|
+
// { config: this._config, account: this._account },
|
|
1104
|
+
// options,
|
|
1105
|
+
// );
|
|
1106
|
+
// }
|
|
1107
|
+
/**
|
|
1108
|
+
* Bound {@link PointsIncentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1109
|
+
*
|
|
1110
|
+
* @example
|
|
1111
|
+
* ```ts
|
|
1112
|
+
* const incentive = core.PointsIncentive({ ... }) // is roughly equivalent to
|
|
1113
|
+
* const incentive = new PointsIncentive({ config: core._config, account: core._account }, { ... })
|
|
1114
|
+
* ```
|
|
1115
|
+
* @param {PointsIncentivePayload} options
|
|
1116
|
+
* @returns {PointsIncentive}
|
|
1117
|
+
*/
|
|
1118
|
+
PointsIncentive(options: PointsIncentivePayload) {
|
|
1119
|
+
return new PointsIncentive(
|
|
1120
|
+
{ config: this._config, account: this._account },
|
|
1121
|
+
options,
|
|
1122
|
+
);
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Bound {@link SignerValidator} constructor that reuses the same configuration as the Boost Core instance.
|
|
1126
|
+
*
|
|
1127
|
+
* @example
|
|
1128
|
+
* ```ts
|
|
1129
|
+
* const validator = core.SignerValidator({ ... }) // is roughly equivalent to
|
|
1130
|
+
* const validator = new SignerValidator({ config: core._config, account: core._account }, { ... })
|
|
1131
|
+
* ```
|
|
1132
|
+
* @param {DeployablePayloadOrAddress<SignerValidatorPayload>} options
|
|
1133
|
+
* @param {?boolean} [isBase]
|
|
1134
|
+
* @returns {SignerValidator}
|
|
1135
|
+
*/
|
|
1136
|
+
SignerValidator(
|
|
1137
|
+
options: DeployablePayloadOrAddress<SignerValidatorPayload>,
|
|
1138
|
+
isBase?: boolean,
|
|
1139
|
+
) {
|
|
1140
|
+
return new SignerValidator(
|
|
1141
|
+
{ config: this._config, account: this._account },
|
|
1142
|
+
options,
|
|
1143
|
+
isBase,
|
|
1144
|
+
);
|
|
1145
|
+
}
|
|
1146
|
+
/**
|
|
1147
|
+
* Bound {@link ERC20VariableIncentive} constructor that reuses the same configuration as the Boost Core instance.
|
|
1148
|
+
*
|
|
1149
|
+
* @example
|
|
1150
|
+
* ```ts
|
|
1151
|
+
* const validator = core.ERC20VariableIncentive({ ... }) // is roughly equivalent to
|
|
1152
|
+
* const validator = new ERC20VariableIncentive({ config: core._config, account: core._account }, { ... })
|
|
1153
|
+
* ```
|
|
1154
|
+
* @param {DeployablePayloadOrAddress<ERC20VariableIncentivePayload>} options
|
|
1155
|
+
* @param {?boolean} [isBase]
|
|
1156
|
+
* @returns {ERC20VariableIncentive}
|
|
1157
|
+
*/
|
|
1158
|
+
ERC20VariableIncentive(
|
|
1159
|
+
options: DeployablePayloadOrAddress<ERC20VariableIncentivePayload>,
|
|
1160
|
+
isBase?: boolean,
|
|
1161
|
+
) {
|
|
1162
|
+
return new ERC20VariableIncentive(
|
|
1163
|
+
{ config: this._config, account: this._account },
|
|
1164
|
+
options,
|
|
1165
|
+
isBase,
|
|
1166
|
+
);
|
|
1167
|
+
}
|
|
1168
|
+
|
|
1169
|
+
/**
|
|
1170
|
+
* @inheritdoc
|
|
1171
|
+
*
|
|
1172
|
+
* @public
|
|
1173
|
+
* @param {?[Address, Address]} [_payload]
|
|
1174
|
+
* @param {?DeployableOptions} [_options]
|
|
1175
|
+
* @returns {GenericDeployableParams}
|
|
1176
|
+
*/
|
|
1177
|
+
public override buildParameters(
|
|
1178
|
+
_payload?: [Address, Address],
|
|
1179
|
+
_options?: DeployableOptions,
|
|
1180
|
+
): GenericDeployableParams {
|
|
1181
|
+
const [payload, options] = this.validateDeploymentConfig(
|
|
1182
|
+
_payload,
|
|
1183
|
+
_options,
|
|
1184
|
+
);
|
|
1185
|
+
return {
|
|
1186
|
+
abi: boostCoreAbi,
|
|
1187
|
+
bytecode: bytecode as Hex,
|
|
1188
|
+
args: payload,
|
|
1189
|
+
...this.optionallyAttachAccount(options.account),
|
|
1190
|
+
};
|
|
1191
|
+
}
|
|
1192
|
+
}
|