@boostxyz/sdk 0.0.0-alpha.16 → 0.0.0-alpha.18
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 +9 -9
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +12 -12
- 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 +32 -49
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +13 -779
- 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.js +3 -3
- package/dist/AllowLists/OpenAllowList.d.ts +183 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +82 -36
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +44 -80
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +192 -9
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +5 -5
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +18 -0
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BiPwp6SR.cjs +3 -0
- package/dist/BoostCore-BiPwp6SR.cjs.map +1 -0
- package/dist/BoostCore-C00iqvks.js +1477 -0
- package/dist/BoostCore-C00iqvks.js.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +80 -35
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1273
- 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 +18 -18
- package/dist/BoostRegistry.js +36 -36
- 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 +24 -174
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +76 -298
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +181 -77
- 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 +4 -5
- 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.js +1 -1
- 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 +5 -5
- package/dist/Deployable/DeployableTarget.js +10 -10
- 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-BO5WI_5s.js +1355 -0
- package/dist/EventAction-BO5WI_5s.js.map +1 -0
- package/dist/EventAction-DBDRaG4A.cjs +2 -0
- package/dist/EventAction-DBDRaG4A.cjs.map +1 -0
- package/dist/{Incentive-CtuAJAjG.js → Incentive-CF7kaz_9.js} +67 -68
- package/dist/Incentive-CF7kaz_9.js.map +1 -0
- package/dist/{Incentive-CqX3fYEd.cjs → Incentive-Djnzseoj.cjs} +2 -2
- package/dist/Incentive-Djnzseoj.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +12 -12
- package/dist/Incentives/AllowListIncentive.js +26 -26
- 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 +15 -15
- package/dist/Incentives/CGDAIncentive.js +25 -25
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +30 -30
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +23 -23
- package/dist/Incentives/ERC20Incentive.js +45 -45
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +19 -19
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.d.ts +3 -3
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +3 -3
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +14 -14
- package/dist/Incentives/PointsIncentive.js +20 -20
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BwfNjRsg.cjs +2 -0
- package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
- package/dist/SimpleDenyList-D9i4rw_F.js +132 -0
- package/dist/SimpleDenyList-D9i4rw_F.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 +14 -14
- package/dist/Validators/SignerValidator.js +25 -25
- 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 +6 -6
- 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-D09mhzxO.cjs +2 -0
- package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
- package/dist/componentInterfaces-RXBMI5yH.js +14 -0
- package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
- package/dist/deployments-BM42vImE.js +43 -0
- package/dist/deployments-BM42vImE.js.map +1 -0
- package/dist/deployments-CMdF5uEC.cjs +2 -0
- package/dist/deployments-CMdF5uEC.cjs.map +1 -0
- package/dist/deployments.json +15 -12
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +132 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +122 -36
- package/dist/errors.js.map +1 -1
- package/dist/generated-B0tk-c9b.cjs +3 -0
- package/dist/generated-B0tk-c9b.cjs.map +1 -0
- package/dist/{generated-DLMdMwD1.js → generated-B8VWObPa.js} +2350 -1290
- package/dist/generated-B8VWObPa.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +134 -122
- 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.map +1 -1
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +12 -5
- package/src/Actions/ContractAction.ts +9 -10
- package/src/Actions/ERC721MintAction.ts +12 -13
- package/src/Actions/EventAction.test.ts +182 -53
- package/src/Actions/EventAction.ts +128 -107
- package/src/AllowLists/SimpleAllowList.ts +14 -59
- package/src/AllowLists/SimpleDenyList.ts +12 -9
- package/src/Boost.ts +19 -0
- package/src/BoostCore.test.ts +117 -1
- package/src/BoostCore.ts +113 -54
- package/src/BoostRegistry.ts +18 -18
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.ts +21 -295
- package/src/Budgets/VestingBudget.ts +26 -97
- package/src/Deployable/Contract.ts +4 -5
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +5 -5
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.ts +12 -12
- package/src/Incentives/CGDAIncentive.ts +15 -15
- package/src/Incentives/ERC1155Incentive.ts +26 -26
- package/src/Incentives/ERC20Incentive.ts +23 -23
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
- package/src/Incentives/ERC20VariableIncentive.ts +19 -19
- package/src/Incentives/Incentive.ts +6 -5
- package/src/Incentives/PointsIncentive.test.ts +21 -21
- package/src/Incentives/PointsIncentive.ts +14 -14
- package/src/Validators/SignerValidator.ts +14 -14
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +1 -1
- package/src/errors.ts +165 -0
- package/src/index.test.ts +3 -4
- package/src/index.ts +2 -0
- package/src/transfers.ts +1 -1
- package/src/utils.ts +1 -1
- package/dist/Budgets/SimpleBudget.d.ts +0 -824
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/Incentive-CqX3fYEd.cjs.map +0 -1
- package/dist/Incentive-CtuAJAjG.js.map +0 -1
- package/dist/SimpleDenyList-9UIxZZKP.cjs +0 -2
- package/dist/SimpleDenyList-9UIxZZKP.cjs.map +0 -1
- package/dist/SimpleDenyList-DGPNc7ov.js +0 -132
- package/dist/SimpleDenyList-DGPNc7ov.js.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-Cmg8tUxq.js +0 -13
- package/dist/componentInterfaces-Cmg8tUxq.js.map +0 -1
- package/dist/deployments-BvFcK_eR.js +0 -40
- package/dist/deployments-BvFcK_eR.js.map +0 -1
- package/dist/deployments-Ho4PnGCS.cjs +0 -2
- package/dist/deployments-Ho4PnGCS.cjs.map +0 -1
- package/dist/generated-BLg7yPgI.cjs +0 -3
- package/dist/generated-BLg7yPgI.cjs.map +0 -1
- package/dist/generated-DLMdMwD1.js.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -563
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/EventAction.sol/EventAction.json';
|
|
9
9
|
import events from '@boostxyz/signatures/events';
|
|
10
10
|
import functions from '@boostxyz/signatures/functions';
|
|
11
|
+
import { match } from 'ts-pattern';
|
|
11
12
|
import {
|
|
12
13
|
type Abi,
|
|
13
14
|
type AbiEvent,
|
|
@@ -20,14 +21,13 @@ import {
|
|
|
20
21
|
type Hex,
|
|
21
22
|
type Log,
|
|
22
23
|
type PublicClient,
|
|
24
|
+
type Transaction,
|
|
25
|
+
decodeEventLog,
|
|
23
26
|
decodeFunctionData,
|
|
24
27
|
encodeAbiParameters,
|
|
25
28
|
fromHex,
|
|
26
29
|
isAddressEqual,
|
|
27
|
-
pad,
|
|
28
|
-
trim,
|
|
29
30
|
} from 'viem';
|
|
30
|
-
import { getLogs } from 'viem/actions';
|
|
31
31
|
import { EventAction as EventActionBases } from '../../dist/deployments.json';
|
|
32
32
|
import type {
|
|
33
33
|
DeployableOptions,
|
|
@@ -44,6 +44,8 @@ import {
|
|
|
44
44
|
TooManyEventActionStepsProvidedError,
|
|
45
45
|
UnparseableAbiParamError,
|
|
46
46
|
UnrecognizedFilterTypeError,
|
|
47
|
+
ValidationAbiMissingError,
|
|
48
|
+
ValidationLogsMissingError,
|
|
47
49
|
} from '../errors';
|
|
48
50
|
import {
|
|
49
51
|
type GetLogsParams,
|
|
@@ -215,38 +217,19 @@ export interface ActionStep {
|
|
|
215
217
|
}
|
|
216
218
|
|
|
217
219
|
/**
|
|
218
|
-
* Parameters for validating an
|
|
220
|
+
* Parameters for validating an action step.
|
|
219
221
|
*
|
|
220
|
-
*
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* @
|
|
224
|
-
* @property {
|
|
225
|
-
* @property {
|
|
226
|
-
* @property {number} [fromBlock]
|
|
227
|
-
* @property {number} [toBlock]
|
|
228
|
-
* @property {Hex} [blockHash]
|
|
229
|
-
* @property {Abi} abi
|
|
230
|
-
* @property {ContractEventName<Abi>} eventName
|
|
231
|
-
*/
|
|
232
|
-
export type ValidateEventStepParams = Omit<
|
|
233
|
-
GetLogsParams<Abi, ContractEventName<Abi>> & {
|
|
234
|
-
logs?: Log[];
|
|
235
|
-
knownEvents?: Record<Hex, AbiEvent>;
|
|
236
|
-
},
|
|
237
|
-
'address'
|
|
238
|
-
>;
|
|
239
|
-
|
|
240
|
-
/**
|
|
241
|
-
* Parameters for validating a function step.
|
|
242
|
-
*
|
|
243
|
-
* This type includes all parameters required to get a transaction.
|
|
244
|
-
*
|
|
245
|
-
* @typedef {Object} ValidateFunctionStepParams
|
|
246
|
-
* @property {Hex} hash
|
|
247
|
-
* @property {number} [chainId]
|
|
222
|
+
* @typedef {Object} ValidateActionStepParams
|
|
223
|
+
* @property {Record<Hex, AbiEvent>} [knownEvents] - Optional record of known events, keyed by their hex signature.
|
|
224
|
+
* @property {AbiEvent} [event] - Optional ABI event definition.
|
|
225
|
+
* @property {EventLogs} [logs] - Event logs to validate against. Required if 'hash' is not provided.
|
|
226
|
+
* @property {Hex} [hash] - Transaction hash to validate against. Required if 'logs' is not provided.
|
|
227
|
+
* @property {number} [chainId] - Chain ID for the transaction. Required if 'hash' is provided.
|
|
248
228
|
*/
|
|
249
|
-
export type
|
|
229
|
+
export type ValidateActionStepParams = {
|
|
230
|
+
knownEvents?: Record<Hex, AbiEvent>;
|
|
231
|
+
event?: AbiEvent;
|
|
232
|
+
} & ({ logs: EventLogs } | { hash: Hex; chainId: number });
|
|
250
233
|
|
|
251
234
|
/**
|
|
252
235
|
* You can either supply a simplified version of the payload, or one that explicitly declares action steps.
|
|
@@ -348,8 +331,6 @@ export type ReadEventActionParams<
|
|
|
348
331
|
fnName extends ContractFunctionName<typeof eventActionAbi, 'pure' | 'view'>,
|
|
349
332
|
> = ReadParams<typeof eventActionAbi, fnName>;
|
|
350
333
|
|
|
351
|
-
type TxParams = ValidateEventStepParams | ValidateFunctionStepParams;
|
|
352
|
-
|
|
353
334
|
/**
|
|
354
335
|
* A generic event action
|
|
355
336
|
*
|
|
@@ -466,7 +447,7 @@ export class EventAction extends DeployableTarget<
|
|
|
466
447
|
* @public
|
|
467
448
|
* @async
|
|
468
449
|
* @param {Hex} data
|
|
469
|
-
* @param {?WriteParams
|
|
450
|
+
* @param {?WriteParams} [params]
|
|
470
451
|
* @returns {Promise<readonly [boolean, `0x${string}`]>}
|
|
471
452
|
*/
|
|
472
453
|
public async execute(
|
|
@@ -482,8 +463,8 @@ export class EventAction extends DeployableTarget<
|
|
|
482
463
|
* @public
|
|
483
464
|
* @async
|
|
484
465
|
* @param {Hex} data
|
|
485
|
-
* @param {?WriteParams
|
|
486
|
-
* @returns {
|
|
466
|
+
* @param {?WriteParams} [params]
|
|
467
|
+
* @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
|
|
487
468
|
*/
|
|
488
469
|
public async executeRaw(
|
|
489
470
|
data: Hex,
|
|
@@ -506,10 +487,10 @@ export class EventAction extends DeployableTarget<
|
|
|
506
487
|
*
|
|
507
488
|
* @public
|
|
508
489
|
* @async
|
|
509
|
-
* @param
|
|
490
|
+
* @param ValidateActionStepParams params
|
|
510
491
|
* @returns {Promise<boolean>}
|
|
511
492
|
*/
|
|
512
|
-
public async validateActionSteps(params
|
|
493
|
+
public async validateActionSteps(params: ValidateActionStepParams) {
|
|
513
494
|
const actionSteps = await this.getActionSteps();
|
|
514
495
|
for (const actionStep of actionSteps) {
|
|
515
496
|
if (!(await this.isActionStepValid(actionStep, params))) {
|
|
@@ -527,21 +508,75 @@ export class EventAction extends DeployableTarget<
|
|
|
527
508
|
* @public
|
|
528
509
|
* @async
|
|
529
510
|
* @param {ActionStep} actionStep - The action step to validate. Can be a function of event step.
|
|
530
|
-
* @param {
|
|
511
|
+
* @param {ValidateActionStepParams} params - Additional parameters for validation, including hash, known events, logs, and chain ID.
|
|
531
512
|
* @returns {Promise<boolean>}
|
|
532
513
|
*/
|
|
533
514
|
public async isActionStepValid(
|
|
534
515
|
actionStep: ActionStep,
|
|
535
|
-
params
|
|
516
|
+
params: ValidateActionStepParams,
|
|
536
517
|
) {
|
|
537
518
|
if (actionStep.signatureType === SignatureType.EVENT) {
|
|
538
|
-
|
|
519
|
+
const signature = actionStep.signature;
|
|
520
|
+
let event: AbiEvent;
|
|
521
|
+
// Lookup ABI based on event signature
|
|
522
|
+
if (params.knownEvents) {
|
|
523
|
+
event = params.knownEvents?.[signature] as AbiEvent;
|
|
524
|
+
} else {
|
|
525
|
+
event = (events.abi as Record<Hex, AbiEvent>)[signature] as AbiEvent;
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
if (!event) {
|
|
529
|
+
throw new ValidationAbiMissingError(signature);
|
|
530
|
+
}
|
|
531
|
+
|
|
532
|
+
if (this.isArraylikeIndexed(actionStep, event)) {
|
|
533
|
+
// If the field is indexed, we can't filter on it
|
|
534
|
+
throw new UnparseableAbiParamError(
|
|
535
|
+
actionStep.actionParameter.fieldIndex,
|
|
536
|
+
event,
|
|
537
|
+
);
|
|
538
|
+
}
|
|
539
|
+
|
|
540
|
+
params.event = event;
|
|
541
|
+
|
|
542
|
+
// Use the provided logs, no need to fetch receipt
|
|
543
|
+
if ('logs' in params) {
|
|
544
|
+
return this.isActionEventValid(actionStep, {
|
|
545
|
+
...params,
|
|
546
|
+
});
|
|
547
|
+
}
|
|
548
|
+
|
|
549
|
+
const client = this._config.getClient({
|
|
550
|
+
chainId: params.chainId,
|
|
551
|
+
}) as PublicClient;
|
|
552
|
+
const receipt = await client.getTransactionReceipt({
|
|
553
|
+
hash: params.hash,
|
|
554
|
+
});
|
|
555
|
+
const decodedLogs = receipt.logs.map((log) => {
|
|
556
|
+
const { eventName, args } = decodeEventLog({
|
|
557
|
+
abi: [event],
|
|
558
|
+
data: log.data,
|
|
559
|
+
topics: log.topics,
|
|
560
|
+
});
|
|
561
|
+
|
|
562
|
+
return { ...log, eventName, args };
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
return this.isActionEventValid(actionStep, {
|
|
566
|
+
logs: decodedLogs,
|
|
567
|
+
...params,
|
|
568
|
+
});
|
|
539
569
|
}
|
|
540
570
|
if (actionStep.signatureType === SignatureType.FUNC) {
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
571
|
+
if ('hash' in params && 'chainId' in params) {
|
|
572
|
+
const client = this._config.getClient({
|
|
573
|
+
chainId: params.chainId,
|
|
574
|
+
}) as PublicClient;
|
|
575
|
+
const transaction = await client.getTransaction({
|
|
576
|
+
hash: params.hash,
|
|
577
|
+
});
|
|
578
|
+
return this.isActionFunctionValid(actionStep, transaction);
|
|
579
|
+
}
|
|
545
580
|
}
|
|
546
581
|
return false;
|
|
547
582
|
}
|
|
@@ -553,88 +588,49 @@ export class EventAction extends DeployableTarget<
|
|
|
553
588
|
* @public
|
|
554
589
|
* @async
|
|
555
590
|
* @param {ActionStep} actionStep - The action step containing the event to validate.
|
|
556
|
-
* @param {
|
|
591
|
+
* @param {ValidateActionStepParams} params - Additional parameters for validation, including known events and logs
|
|
557
592
|
* @returns {Promise<boolean>} Resolves to true if the action event is valid, throws if input is invalid, otherwise false.
|
|
558
593
|
*/
|
|
559
|
-
public
|
|
594
|
+
public isActionEventValid(
|
|
560
595
|
actionStep: ActionStep,
|
|
561
|
-
params
|
|
596
|
+
params: ValidateActionStepParams,
|
|
562
597
|
) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
let event: AbiEvent;
|
|
566
|
-
// Lookup ABI based on event signature
|
|
567
|
-
if (params?.knownEvents) {
|
|
568
|
-
event = params.knownEvents[signature] as AbiEvent;
|
|
569
|
-
} else {
|
|
570
|
-
event = (events.abi as Record<Hex, AbiEvent>)[signature] as AbiEvent;
|
|
598
|
+
if (!('logs' in params)) {
|
|
599
|
+
throw new ValidationLogsMissingError();
|
|
571
600
|
}
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
throw new Error(`No known ABI for given event signature: ${signature}`);
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
if (this.isArraylikeIndexed(actionStep, event)) {
|
|
578
|
-
// If the field is indexed, we can't filter on it
|
|
579
|
-
throw new UnparseableAbiParamError(
|
|
580
|
-
actionStep.actionParameter.fieldIndex,
|
|
581
|
-
event,
|
|
582
|
-
);
|
|
583
|
-
}
|
|
584
|
-
const targetContract = actionStep.targetContract;
|
|
585
|
-
// Get all logs matching the event signature from the target contract
|
|
586
|
-
const logs =
|
|
587
|
-
params?.logs ||
|
|
588
|
-
(await getLogs(this._config.getClient({ chainId: params?.chainId }), {
|
|
589
|
-
// biome-ignore lint/suspicious/noExplicitAny: <explanation>
|
|
590
|
-
...(params as any),
|
|
591
|
-
address: targetContract,
|
|
592
|
-
event,
|
|
593
|
-
}));
|
|
601
|
+
const criteria = actionStep.actionParameter;
|
|
602
|
+
const logs = params.logs;
|
|
594
603
|
if (!logs.length) return false;
|
|
595
604
|
for (let log of logs) {
|
|
596
|
-
if (
|
|
597
|
-
return
|
|
605
|
+
if (this.validateLogAgainstCriteria(criteria, log)) {
|
|
606
|
+
return true;
|
|
598
607
|
}
|
|
599
608
|
}
|
|
600
|
-
return
|
|
609
|
+
return false;
|
|
601
610
|
}
|
|
602
611
|
/**
|
|
603
612
|
* Validates a single action function with a given criteria against the transaction input.
|
|
604
|
-
* If a transaction hash is provided in the optional `params` argument, then the transaction
|
|
605
|
-
* will be fetched and decoded using the configured client.
|
|
606
613
|
*
|
|
607
614
|
* @public
|
|
608
615
|
* @async
|
|
609
616
|
* @param {ActionStep} actionStep - The action step containing the function to validate.
|
|
610
|
-
* @param {
|
|
617
|
+
* @param {Transaction} transaction - The transaction that will be validated against.
|
|
611
618
|
* @returns {Promise<boolean>} Resolves to true if the action function is valid, throws if the inputs are invalid, otherwise false.
|
|
612
619
|
*/
|
|
613
|
-
public
|
|
620
|
+
public isActionFunctionValid(
|
|
614
621
|
actionStep: ActionStep,
|
|
615
|
-
|
|
622
|
+
transaction: Transaction,
|
|
616
623
|
) {
|
|
617
624
|
const criteria = actionStep.actionParameter;
|
|
618
625
|
let signature = actionStep.signature;
|
|
619
626
|
|
|
620
|
-
if (!params || !params?.hash) {
|
|
621
|
-
// Should we return false in this case?
|
|
622
|
-
throw new Error('Hash is required for function validation');
|
|
623
|
-
}
|
|
624
|
-
const client = this._config.getClient({
|
|
625
|
-
chainId: params?.chainId,
|
|
626
|
-
}) as PublicClient;
|
|
627
|
-
// Fetch the transaction receipt and decode the function input using `viem` utilities
|
|
628
|
-
const transaction = await client.getTransaction({ hash: params.hash });
|
|
629
627
|
const func = (functions.abi as Record<Hex, AbiFunction>)[
|
|
630
628
|
signature
|
|
631
629
|
] as AbiFunction;
|
|
632
|
-
|
|
633
630
|
if (!func) {
|
|
634
|
-
throw new
|
|
635
|
-
`No known ABI for given function signature: ${signature}`,
|
|
636
|
-
);
|
|
631
|
+
throw new ValidationAbiMissingError(signature);
|
|
637
632
|
}
|
|
633
|
+
|
|
638
634
|
let decodedData;
|
|
639
635
|
try {
|
|
640
636
|
decodedData = decodeFunctionData({
|
|
@@ -665,7 +661,10 @@ export class EventAction extends DeployableTarget<
|
|
|
665
661
|
* Validates a field against a given criteria.
|
|
666
662
|
*
|
|
667
663
|
* @param {Criteria} criteria - The criteria to validate against.
|
|
668
|
-
* @param {string | bigint} fieldValue - The field value to validate.
|
|
664
|
+
* @param {string | bigint | Hex} fieldValue - The field value to validate.
|
|
665
|
+
* @param {Object} input - Additional context for validation.
|
|
666
|
+
* @param {EventLogs[0]} [input.log] - The event log, if validating an event.
|
|
667
|
+
* @param {readonly (string | bigint)[]} [input.decodedArgs] - The decoded function arguments, if validating a function call.
|
|
669
668
|
* @returns {Promise<boolean>} - Returns true if the field passes the criteria, false otherwise.
|
|
670
669
|
*/
|
|
671
670
|
public validateFieldAgainstCriteria(
|
|
@@ -678,13 +677,35 @@ export class EventAction extends DeployableTarget<
|
|
|
678
677
|
// Type narrow based on criteria.filterType
|
|
679
678
|
switch (criteria.filterType) {
|
|
680
679
|
case FilterType.EQUAL:
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
680
|
+
return match(criteria.fieldType)
|
|
681
|
+
.with(PrimitiveType.ADDRESS, () =>
|
|
682
|
+
isAddressEqual(criteria.filterData, fieldValue as Address),
|
|
683
|
+
)
|
|
684
|
+
.with(
|
|
685
|
+
PrimitiveType.UINT,
|
|
686
|
+
() => BigInt(fieldValue) === BigInt(criteria.filterData),
|
|
687
|
+
)
|
|
688
|
+
.with(
|
|
689
|
+
PrimitiveType.STRING,
|
|
690
|
+
() => fieldValue === fromHex(criteria.filterData, 'string'),
|
|
691
|
+
)
|
|
692
|
+
.otherwise(() => fieldValue === criteria.filterData);
|
|
685
693
|
|
|
686
694
|
case FilterType.NOT_EQUAL:
|
|
687
|
-
return
|
|
695
|
+
return match(criteria.fieldType)
|
|
696
|
+
.with(
|
|
697
|
+
PrimitiveType.ADDRESS,
|
|
698
|
+
() => !isAddressEqual(criteria.filterData, fieldValue as Address),
|
|
699
|
+
)
|
|
700
|
+
.with(
|
|
701
|
+
PrimitiveType.UINT,
|
|
702
|
+
() => BigInt(fieldValue) !== BigInt(criteria.filterData),
|
|
703
|
+
)
|
|
704
|
+
.with(
|
|
705
|
+
PrimitiveType.STRING,
|
|
706
|
+
() => fieldValue !== fromHex(criteria.filterData, 'string'),
|
|
707
|
+
)
|
|
708
|
+
.otherwise(() => fieldValue !== criteria.filterData);
|
|
688
709
|
|
|
689
710
|
case FilterType.GREATER_THAN:
|
|
690
711
|
if (criteria.fieldType === PrimitiveType.UINT) {
|
|
@@ -2,9 +2,7 @@ import {
|
|
|
2
2
|
readSimpleAllowListIsAllowed,
|
|
3
3
|
readSimpleAllowListOwner,
|
|
4
4
|
simpleAllowListAbi,
|
|
5
|
-
simulateSimpleAllowListGrantRoles,
|
|
6
5
|
simulateSimpleAllowListSetAllowed,
|
|
7
|
-
writeSimpleAllowListGrantRoles,
|
|
8
6
|
writeSimpleAllowListSetAllowed,
|
|
9
7
|
} from '@boostxyz/evm';
|
|
10
8
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/allowlists/SimpleAllowList.sol/SimpleAllowList.json';
|
|
@@ -22,7 +20,10 @@ import type {
|
|
|
22
20
|
DeployableOptions,
|
|
23
21
|
GenericDeployableParams,
|
|
24
22
|
} from '../Deployable/Deployable';
|
|
25
|
-
import {
|
|
23
|
+
import {
|
|
24
|
+
DeployableTargetWithRBAC,
|
|
25
|
+
Roles,
|
|
26
|
+
} from '../Deployable/DeployableTargetWithRBAC';
|
|
26
27
|
import { DeployableUnknownOwnerProvidedError } from '../errors';
|
|
27
28
|
import {
|
|
28
29
|
type GenericLog,
|
|
@@ -73,18 +74,19 @@ export type SimpleAllowListLog<
|
|
|
73
74
|
/**
|
|
74
75
|
* A constant representing the list manager's role
|
|
75
76
|
*
|
|
76
|
-
* @
|
|
77
|
+
* @deprecated use {@link Roles} instead
|
|
78
|
+
* @type {1n}
|
|
77
79
|
*/
|
|
78
|
-
export const LIST_MANAGER_ROLE =
|
|
80
|
+
export const LIST_MANAGER_ROLE = Roles.MANAGER;
|
|
79
81
|
/**
|
|
80
82
|
* A simple implementation of an AllowList that checks if a user is authorized based on a list of allowed addresses
|
|
81
83
|
*
|
|
82
84
|
* @export
|
|
83
85
|
* @class SimpleAllowList
|
|
84
86
|
* @typedef {SimpleAllowList}
|
|
85
|
-
* @extends {
|
|
87
|
+
* @extends {DeployableTargetWithRBAC<SimpleAllowListPayload>}
|
|
86
88
|
*/
|
|
87
|
-
export class SimpleAllowList extends
|
|
89
|
+
export class SimpleAllowList extends DeployableTargetWithRBAC<
|
|
88
90
|
SimpleAllowListPayload,
|
|
89
91
|
typeof simpleAllowListAbi
|
|
90
92
|
> {
|
|
@@ -113,7 +115,7 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
113
115
|
*
|
|
114
116
|
* @public
|
|
115
117
|
* @async
|
|
116
|
-
* @param {?ReadParams
|
|
118
|
+
* @param {?ReadParams} [params]
|
|
117
119
|
* @returns {Promise<Address>} - The address of the owner
|
|
118
120
|
*/
|
|
119
121
|
public async owner(
|
|
@@ -134,7 +136,7 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
134
136
|
* @public
|
|
135
137
|
* @async
|
|
136
138
|
* @param {Address} address - The address of the user
|
|
137
|
-
* @param {?ReadParams
|
|
139
|
+
* @param {?ReadParams} [params]
|
|
138
140
|
* @returns {Promise<boolean>} - True if the user is authorized
|
|
139
141
|
*/
|
|
140
142
|
public async isAllowed(
|
|
@@ -158,7 +160,7 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
158
160
|
* @async
|
|
159
161
|
* @param {Address[]} addresses - The list of users to update
|
|
160
162
|
* @param {boolean[]} allowed - The allowed status of each user
|
|
161
|
-
* @param {?ReadParams
|
|
163
|
+
* @param {?ReadParams} [params]
|
|
162
164
|
* @returns {Promise<void>}
|
|
163
165
|
*/
|
|
164
166
|
public async setAllowed(
|
|
@@ -179,8 +181,8 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
179
181
|
* @async
|
|
180
182
|
* @param {Address[]} addresses - The list of users to update
|
|
181
183
|
* @param {boolean[]} allowed - The allowed status of each user
|
|
182
|
-
* @param {?ReadParams
|
|
183
|
-
* @returns {Promise<void>}
|
|
184
|
+
* @param {?ReadParams} [params]
|
|
185
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
184
186
|
*/
|
|
185
187
|
public async setAllowedRaw(
|
|
186
188
|
addresses: Address[],
|
|
@@ -201,53 +203,6 @@ export class SimpleAllowList extends DeployableTarget<
|
|
|
201
203
|
return { hash, result };
|
|
202
204
|
}
|
|
203
205
|
|
|
204
|
-
/**
|
|
205
|
-
* Allows the owner to grant `user` `roles`.
|
|
206
|
-
*
|
|
207
|
-
* @public
|
|
208
|
-
* @async
|
|
209
|
-
* @param {Address} address
|
|
210
|
-
* @param {bigint} role
|
|
211
|
-
* @param {?ReadParams<typeof simpleAllowListAbi, 'grantRoles'>} [params]
|
|
212
|
-
* @returns {Promise<void>}
|
|
213
|
-
*/
|
|
214
|
-
public async grantRoles(
|
|
215
|
-
address: Address,
|
|
216
|
-
role: bigint,
|
|
217
|
-
params?: WriteParams<typeof simpleAllowListAbi, 'grantRoles'>,
|
|
218
|
-
) {
|
|
219
|
-
return await this.awaitResult(this.grantRolesRaw(address, role, params));
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
/**
|
|
223
|
-
* Allows the owner to grant `user` `roles`.
|
|
224
|
-
*
|
|
225
|
-
* @public
|
|
226
|
-
* @async
|
|
227
|
-
* @param {Address} address
|
|
228
|
-
* @param {bigint} role
|
|
229
|
-
* @param {?ReadParams<typeof simpleAllowListAbi, 'grantRoles'>} [params]
|
|
230
|
-
* @returns {Promise<void>}
|
|
231
|
-
*/
|
|
232
|
-
public async grantRolesRaw(
|
|
233
|
-
address: Address,
|
|
234
|
-
role: bigint,
|
|
235
|
-
params?: ReadParams<typeof simpleAllowListAbi, 'grantRoles'>,
|
|
236
|
-
) {
|
|
237
|
-
const { request, result } = await simulateSimpleAllowListGrantRoles(
|
|
238
|
-
this._config,
|
|
239
|
-
{
|
|
240
|
-
address: this.assertValidAddress(),
|
|
241
|
-
args: [address, role],
|
|
242
|
-
...this.optionallyAttachAccount(),
|
|
243
|
-
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
244
|
-
...(params as any),
|
|
245
|
-
},
|
|
246
|
-
);
|
|
247
|
-
const hash = await writeSimpleAllowListGrantRoles(this._config, request);
|
|
248
|
-
return { hash, result };
|
|
249
|
-
}
|
|
250
|
-
|
|
251
206
|
/**
|
|
252
207
|
* @inheritdoc
|
|
253
208
|
*
|
|
@@ -20,7 +20,7 @@ import type {
|
|
|
20
20
|
DeployableOptions,
|
|
21
21
|
GenericDeployableParams,
|
|
22
22
|
} from '../Deployable/Deployable';
|
|
23
|
-
import {
|
|
23
|
+
import { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';
|
|
24
24
|
import { DeployableUnknownOwnerProvidedError } from '../errors';
|
|
25
25
|
import {
|
|
26
26
|
type GenericLog,
|
|
@@ -74,11 +74,14 @@ export type SimpleDenyListLog<
|
|
|
74
74
|
* @export
|
|
75
75
|
* @class SimpleDenyList
|
|
76
76
|
* @typedef {SimpleDenyList}
|
|
77
|
-
* @extends {
|
|
77
|
+
* @extends {DeployableTargetWithRBAC<SimpleDenyListPayload>}
|
|
78
78
|
*/
|
|
79
79
|
export class SimpleDenyList<
|
|
80
80
|
Payload = SimpleDenyListPayload,
|
|
81
|
-
> extends
|
|
81
|
+
> extends DeployableTargetWithRBAC<
|
|
82
|
+
Payload | undefined,
|
|
83
|
+
typeof simpleDenyListAbi
|
|
84
|
+
> {
|
|
82
85
|
public override readonly abi = simpleDenyListAbi;
|
|
83
86
|
/**
|
|
84
87
|
* @inheritdoc
|
|
@@ -104,7 +107,7 @@ export class SimpleDenyList<
|
|
|
104
107
|
*
|
|
105
108
|
* @public
|
|
106
109
|
* @async
|
|
107
|
-
* @param {?ReadParams
|
|
110
|
+
* @param {?ReadParams} [params]
|
|
108
111
|
* @returns {Promise<Address>} - The address of the owner
|
|
109
112
|
*/
|
|
110
113
|
public async owner(
|
|
@@ -125,7 +128,7 @@ export class SimpleDenyList<
|
|
|
125
128
|
* @public
|
|
126
129
|
* @async
|
|
127
130
|
* @param {Address} address - The address of the user
|
|
128
|
-
* @param {?ReadParams
|
|
131
|
+
* @param {?ReadParams} [params]
|
|
129
132
|
* @returns {Promise<boolean>} - True if the user is authorized
|
|
130
133
|
*/
|
|
131
134
|
public async isAllowed(
|
|
@@ -148,8 +151,8 @@ export class SimpleDenyList<
|
|
|
148
151
|
* @async
|
|
149
152
|
* @param {Address[]} addresses - The list of users to update
|
|
150
153
|
* @param {boolean[]} allowed - The denied status of each user
|
|
151
|
-
* @param {?WriteParams
|
|
152
|
-
* @returns {
|
|
154
|
+
* @param {?WriteParams} [params]
|
|
155
|
+
* @returns {Promise<void>}
|
|
153
156
|
*/
|
|
154
157
|
public async setDenied(
|
|
155
158
|
addresses: Address[],
|
|
@@ -168,8 +171,8 @@ export class SimpleDenyList<
|
|
|
168
171
|
* @async
|
|
169
172
|
* @param {Address[]} addresses - The list of users to update
|
|
170
173
|
* @param {boolean[]} allowed - The denied status of each user
|
|
171
|
-
* @param {?WriteParams
|
|
172
|
-
* @returns {
|
|
174
|
+
* @param {?WriteParams} [params]
|
|
175
|
+
* @returns {Promise<{ hash: `0x${string}`; result: void; }>}
|
|
173
176
|
*/
|
|
174
177
|
public async setDeniedRaw(
|
|
175
178
|
addresses: Address[],
|
package/src/Boost.ts
CHANGED
|
@@ -12,6 +12,25 @@ import type { Budget } from './Budgets/Budget';
|
|
|
12
12
|
import type { Incentive } from './Incentives/Incentive';
|
|
13
13
|
import type { Validator } from './Validators/Validator';
|
|
14
14
|
|
|
15
|
+
/**
|
|
16
|
+
* Interface representing a `BoostLib.Boost` on-chain struct
|
|
17
|
+
*
|
|
18
|
+
* @export
|
|
19
|
+
* @interface BoostPayload
|
|
20
|
+
* @typedef {BoostPayload}
|
|
21
|
+
*/
|
|
22
|
+
export interface RawBoost {
|
|
23
|
+
action: Address;
|
|
24
|
+
validator: Address;
|
|
25
|
+
allowList: Address;
|
|
26
|
+
budget: Address;
|
|
27
|
+
incentives: readonly Address[];
|
|
28
|
+
protocolFee: bigint;
|
|
29
|
+
referralFee: bigint;
|
|
30
|
+
maxParticipants: bigint;
|
|
31
|
+
owner: Address;
|
|
32
|
+
}
|
|
33
|
+
|
|
15
34
|
/**
|
|
16
35
|
* Configuration used to instantiate a `Boost` instance.
|
|
17
36
|
*
|