@boostxyz/sdk 1.1.0-alpha.22 → 1.1.0-alpha.24
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 +6 -6
- package/dist/Actions/EventAction.cjs +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +36 -6
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +846 -15
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +2 -2
- package/dist/AllowLists/OpenAllowList.d.ts +28 -28
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +28 -28
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +11 -10
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +28 -28
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/BoostCore-Btl5BdAs.cjs +3 -0
- package/dist/BoostCore-Btl5BdAs.cjs.map +1 -0
- package/dist/{BoostCore-BVZExPPu.js → BoostCore-CD56zbYX.js} +1678 -499
- package/dist/BoostCore-CD56zbYX.js.map +1 -0
- package/dist/BoostCore.cjs +1 -1
- package/dist/BoostCore.d.ts +7 -7
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +6 -6
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +6 -6
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +50 -50
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +28 -28
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +30 -29
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +28 -28
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.js +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +92 -23
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.js +145 -47
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -1
- package/dist/{Incentive-BhHaK3PZ.cjs → Incentive-CcnOIc8L.cjs} +2 -2
- package/dist/{Incentive-BhHaK3PZ.cjs.map → Incentive-CcnOIc8L.cjs.map} +1 -1
- package/dist/{Incentive-Cqg1w6wD.js → Incentive-rM5nKznp.js} +30 -29
- package/dist/{Incentive-Cqg1w6wD.js.map → Incentive-rM5nKznp.js.map} +1 -1
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +11 -10
- 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 +28 -28
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +12 -11
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +28 -28
- 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 +34 -31
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +30 -27
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +28 -28
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20VariableIncentive.d.ts +28 -28
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.js +2 -2
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +12 -11
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/{SimpleDenyList-CGaWjuld.js → SimpleDenyList-BDXpY74P.js} +18 -17
- package/dist/SimpleDenyList-BDXpY74P.js.map +1 -0
- package/dist/{SimpleDenyList-BUR17Tt1.cjs → SimpleDenyList-DNj5qDWM.cjs} +2 -2
- package/dist/SimpleDenyList-DNj5qDWM.cjs.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +13 -12
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.js +1 -1
- package/dist/deployments-DF_6-7hH.cjs +2 -0
- package/dist/deployments-DF_6-7hH.cjs.map +1 -0
- package/dist/deployments-fJsWblwS.js +56 -0
- package/dist/deployments-fJsWblwS.js.map +1 -0
- package/dist/deployments.json +26 -12
- package/dist/{generated-CKt2yCQd.js → generated-CsNyWPKA.js} +458 -443
- package/dist/generated-CsNyWPKA.js.map +1 -0
- package/dist/generated-DHerxf1y.cjs +3 -0
- package/dist/generated-DHerxf1y.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.js +116 -115
- package/package.json +4 -4
- package/src/Actions/EventAction.test.ts +384 -119
- package/src/Actions/EventAction.ts +76 -35
- package/src/AllowLists/SimpleAllowList.ts +1 -0
- package/src/AllowLists/SimpleDenyList.ts +1 -0
- package/src/BoostCore.test.ts +78 -78
- package/src/BoostCore.ts +19 -13
- package/src/BoostRegistry.ts +10 -10
- package/src/Budgets/ManagedBudget.test.ts +41 -17
- package/src/Budgets/ManagedBudget.ts +1 -11
- package/src/Budgets/VestingBudget.ts +3 -1
- package/src/Deployable/DeployableTargetWithRBAC.test.ts +103 -0
- package/src/Deployable/DeployableTargetWithRBAC.ts +160 -36
- package/src/Incentives/AllowListIncentive.test.ts +7 -7
- package/src/Incentives/AllowListIncentive.ts +1 -0
- package/src/Incentives/CGDAIncentive.ts +1 -0
- package/src/Incentives/ERC1155Incentive.ts +3 -1
- package/src/Incentives/ERC20Incentive.ts +10 -3
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +1 -0
- package/src/Incentives/ERC20VariableIncentive.ts +1 -0
- package/src/Incentives/PointsIncentive.ts +1 -0
- package/src/Validators/SignerValidator.ts +1 -0
- package/dist/BoostCore-BVZExPPu.js.map +0 -1
- package/dist/BoostCore-D-E-cnGI.cjs +0 -3
- package/dist/BoostCore-D-E-cnGI.cjs.map +0 -1
- package/dist/EventAction-BZt5cjbe.cjs +0 -2
- package/dist/EventAction-BZt5cjbe.cjs.map +0 -1
- package/dist/EventAction-C_-hJXWm.js +0 -1541
- package/dist/EventAction-C_-hJXWm.js.map +0 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +0 -1
- package/dist/SimpleDenyList-CGaWjuld.js.map +0 -1
- package/dist/deployments-DVXioW2i.cjs +0 -2
- package/dist/deployments-DVXioW2i.cjs.map +0 -1
- package/dist/deployments-oykLv3_Z.js +0 -43
- package/dist/deployments-oykLv3_Z.js.map +0 -1
- package/dist/generated-CKt2yCQd.js.map +0 -1
- package/dist/generated-CyTNlOwM.cjs +0 -3
- package/dist/generated-CyTNlOwM.cjs.map +0 -1
|
@@ -6,24 +6,15 @@ import {
|
|
|
6
6
|
writeEventActionExecute,
|
|
7
7
|
} from '@boostxyz/evm';
|
|
8
8
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/EventAction.sol/EventAction.json';
|
|
9
|
-
import
|
|
10
|
-
import functions from '@boostxyz/signatures/functions';
|
|
11
|
-
import {
|
|
12
|
-
GetTransactionReceiptParameters,
|
|
13
|
-
getTransaction,
|
|
14
|
-
getTransactionReceipt,
|
|
15
|
-
} from '@wagmi/core';
|
|
9
|
+
import { getTransaction, getTransactionReceipt } from '@wagmi/core';
|
|
16
10
|
import { match } from 'ts-pattern';
|
|
17
11
|
import {
|
|
18
|
-
type Abi,
|
|
19
12
|
type AbiEvent,
|
|
20
13
|
type AbiFunction,
|
|
21
14
|
AbiItem,
|
|
22
15
|
type Address,
|
|
23
|
-
type ContractEventName,
|
|
24
16
|
type ContractFunctionName,
|
|
25
17
|
type GetLogsReturnType,
|
|
26
|
-
type GetTransactionParameters,
|
|
27
18
|
type Hex,
|
|
28
19
|
type Log,
|
|
29
20
|
type PublicClient,
|
|
@@ -34,6 +25,7 @@ import {
|
|
|
34
25
|
fromHex,
|
|
35
26
|
isAddress,
|
|
36
27
|
isAddressEqual,
|
|
28
|
+
zeroAddress,
|
|
37
29
|
zeroHash,
|
|
38
30
|
} from 'viem';
|
|
39
31
|
import { EventAction as EventActionBases } from '../../dist/deployments.json';
|
|
@@ -55,7 +47,6 @@ import {
|
|
|
55
47
|
ValidationAbiMissingError,
|
|
56
48
|
} from '../errors';
|
|
57
49
|
import {
|
|
58
|
-
type GetLogsParams,
|
|
59
50
|
type Overwrite,
|
|
60
51
|
type ReadParams,
|
|
61
52
|
RegistryType,
|
|
@@ -227,14 +218,14 @@ export interface ActionStep {
|
|
|
227
218
|
* Parameters for validating an action step.
|
|
228
219
|
*
|
|
229
220
|
* @typedef {Object} ValidateActionStepParams
|
|
230
|
-
* @property {Record<Hex, AbiEvent | AbiFunction>} [knownSignatures] -
|
|
221
|
+
* @property {Record<Hex, AbiEvent | AbiFunction>} [knownSignatures] - Record of known events, keyed by 32 byte selectors. You can use [@boostxyz/signatures](https://www.npmjs.com/package/@boostxyz/signatures) to assemble this parameter.
|
|
231
222
|
* @property {AbiEvent | AbiFunction} [abiItem] - Optional ABI item definition.
|
|
232
223
|
* @property {EventLogs} [logs] - Event logs to validate against. Required if 'hash' is not provided.
|
|
233
224
|
* @property {Hex} [hash] - Transaction hash to validate against. Required if 'logs' is not provided.
|
|
234
225
|
* @property {number} [chainId] - Chain ID for the transaction. Required if 'hash' is provided.
|
|
235
226
|
*/
|
|
236
227
|
export type ValidateActionStepParams = {
|
|
237
|
-
knownSignatures
|
|
228
|
+
knownSignatures: Record<Hex, AbiEvent | AbiFunction>;
|
|
238
229
|
abiItem?: AbiEvent | AbiFunction;
|
|
239
230
|
} & ({ logs: EventLogs } | { hash: Hex; chainId: number });
|
|
240
231
|
|
|
@@ -366,6 +357,7 @@ export class EventAction extends DeployableTarget<
|
|
|
366
357
|
* @type {Record<number, Address>}
|
|
367
358
|
*/
|
|
368
359
|
public static override bases: Record<number, Address> = {
|
|
360
|
+
31337: import.meta.env.VITE_EVENT_ACTION_BASE,
|
|
369
361
|
...(EventActionBases as Record<number, Address>),
|
|
370
362
|
};
|
|
371
363
|
/**
|
|
@@ -491,6 +483,8 @@ export class EventAction extends DeployableTarget<
|
|
|
491
483
|
/**
|
|
492
484
|
* Derives the action claimant address from a transaction based on the provided ActionClaimant configuration.
|
|
493
485
|
* This method supports both event-based and function-based claimant derivation.
|
|
486
|
+
* **Important**: The claimant is considered to be `transaction.from` when `claimant.fieldIndex` is 255.
|
|
487
|
+
* This may have unintended side effects for bridged transactions and SCW transactions, so these are considered unsupported use cases for the time being.
|
|
494
488
|
*
|
|
495
489
|
** @example
|
|
496
490
|
* // Example usage
|
|
@@ -505,8 +499,11 @@ export class EventAction extends DeployableTarget<
|
|
|
505
499
|
* const params: ValidateActionStepParams = {
|
|
506
500
|
* hash: '0x5678...',
|
|
507
501
|
* chainId: 1,
|
|
508
|
-
* knownSignatures
|
|
509
|
-
* '0x1234...': {
|
|
502
|
+
* knownSignatures: {
|
|
503
|
+
* '0x1234...': {
|
|
504
|
+
* type: 'event',
|
|
505
|
+
* name: 'Transfer(...)'
|
|
506
|
+
* }
|
|
510
507
|
* }
|
|
511
508
|
* };
|
|
512
509
|
* const claimantAddress = await eventAction.deriveActionClaimantFromTransaction(claimant, params);
|
|
@@ -521,18 +518,37 @@ export class EventAction extends DeployableTarget<
|
|
|
521
518
|
claimant: ActionClaimant,
|
|
522
519
|
params: ValidateActionStepParams,
|
|
523
520
|
): Promise<Address | undefined> {
|
|
521
|
+
// find message sender and return it
|
|
522
|
+
// WARNING: this is error prone in bridged transactions and SCW transactions, as this will return exit node
|
|
523
|
+
if (claimant.fieldIndex === 255) {
|
|
524
|
+
if ('hash' in params) {
|
|
525
|
+
const transaction = await getTransaction(this._config, {
|
|
526
|
+
hash: params.hash,
|
|
527
|
+
});
|
|
528
|
+
return transaction.from;
|
|
529
|
+
}
|
|
530
|
+
if ('logs' in params) {
|
|
531
|
+
for (let log of params.logs) {
|
|
532
|
+
if (log.transactionHash) {
|
|
533
|
+
const transaction = await getTransaction(this._config, {
|
|
534
|
+
hash: log.transactionHash,
|
|
535
|
+
});
|
|
536
|
+
return transaction.from;
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
return undefined;
|
|
541
|
+
}
|
|
542
|
+
|
|
524
543
|
const signature = claimant.signature;
|
|
544
|
+
|
|
525
545
|
if (claimant.signatureType === SignatureType.EVENT) {
|
|
526
546
|
let event: AbiEvent;
|
|
527
547
|
if (params.abiItem) event = params.abiItem as AbiEvent;
|
|
528
548
|
else {
|
|
529
|
-
const sigPool
|
|
530
|
-
...(events.abi as Record<Hex, AbiEvent>),
|
|
531
|
-
...((params.knownSignatures as Record<Hex, AbiEvent>) || {}),
|
|
532
|
-
};
|
|
549
|
+
const sigPool = params.knownSignatures as Record<Hex, AbiEvent>;
|
|
533
550
|
event = sigPool[signature] as AbiEvent;
|
|
534
551
|
}
|
|
535
|
-
|
|
536
552
|
if (!event) {
|
|
537
553
|
throw new ValidationAbiMissingError(signature);
|
|
538
554
|
}
|
|
@@ -578,10 +594,7 @@ export class EventAction extends DeployableTarget<
|
|
|
578
594
|
let func: AbiFunction;
|
|
579
595
|
if (params.abiItem) func = params.abiItem as AbiFunction;
|
|
580
596
|
else {
|
|
581
|
-
const sigPool
|
|
582
|
-
...(functions.abi as Record<Hex, AbiFunction>),
|
|
583
|
-
...((params.knownSignatures as Record<Hex, AbiFunction>) || {}),
|
|
584
|
-
};
|
|
597
|
+
const sigPool = params.knownSignatures as Record<Hex, AbiFunction>;
|
|
585
598
|
func = sigPool[signature] as AbiFunction;
|
|
586
599
|
}
|
|
587
600
|
if (!func) {
|
|
@@ -664,10 +677,7 @@ export class EventAction extends DeployableTarget<
|
|
|
664
677
|
let event: AbiEvent;
|
|
665
678
|
if (params.abiItem) event = params.abiItem as AbiEvent;
|
|
666
679
|
else {
|
|
667
|
-
const sigPool
|
|
668
|
-
...(events.abi as Record<Hex, AbiEvent>),
|
|
669
|
-
...((params.knownSignatures as Record<Hex, AbiEvent>) || {}),
|
|
670
|
-
};
|
|
680
|
+
const sigPool = params.knownSignatures as Record<Hex, AbiEvent>;
|
|
671
681
|
event = sigPool[signature] as AbiEvent;
|
|
672
682
|
}
|
|
673
683
|
|
|
@@ -747,7 +757,7 @@ export class EventAction extends DeployableTarget<
|
|
|
747
757
|
* @public
|
|
748
758
|
* @param {ActionStep} actionStep - The action step containing the function to validate.
|
|
749
759
|
* @param {Transaction} transaction - The transaction that will be validated against.
|
|
750
|
-
* @param {Object} [params] -
|
|
760
|
+
* @param {Object} [params] - Parameters for validation.
|
|
751
761
|
* @param {AbiItem} [params.abiItem] - The ABI item for the function, if known.
|
|
752
762
|
* @param {Record<Hex, AbiEvent | AbiFunction>} [params.knownSignatures] - A record of known signatures.
|
|
753
763
|
* @returns {boolean} Returns true if the action function is valid, false otherwise.
|
|
@@ -757,18 +767,15 @@ export class EventAction extends DeployableTarget<
|
|
|
757
767
|
public isActionFunctionValid(
|
|
758
768
|
actionStep: ActionStep,
|
|
759
769
|
transaction: Transaction,
|
|
760
|
-
params
|
|
770
|
+
params: Pick<ValidateActionStepParams, 'abiItem' | 'knownSignatures'>,
|
|
761
771
|
) {
|
|
762
772
|
const criteria = actionStep.actionParameter;
|
|
763
773
|
let signature = actionStep.signature;
|
|
764
774
|
|
|
765
775
|
let func: AbiFunction;
|
|
766
|
-
if (params
|
|
776
|
+
if (params.abiItem) func = params?.abiItem as AbiFunction;
|
|
767
777
|
else {
|
|
768
|
-
const sigPool
|
|
769
|
-
...(functions.abi as Record<Hex, AbiFunction>),
|
|
770
|
-
...((params?.knownSignatures as Record<Hex, AbiFunction>) || {}),
|
|
771
|
-
};
|
|
778
|
+
const sigPool = params.knownSignatures as Record<Hex, AbiFunction>;
|
|
772
779
|
func = sigPool[signature] as AbiFunction;
|
|
773
780
|
}
|
|
774
781
|
if (!func) {
|
|
@@ -1261,3 +1268,37 @@ export function anyActionParameter(): Criteria {
|
|
|
1261
1268
|
filterData: zeroHash,
|
|
1262
1269
|
};
|
|
1263
1270
|
}
|
|
1271
|
+
|
|
1272
|
+
/**
|
|
1273
|
+
* Creates an ActionClaimant object that represents the transaction sender as the claimant.
|
|
1274
|
+
* This function is useful when you want to set up an action where the transaction sender is always considered the valid claimant,
|
|
1275
|
+
* regardless of the event or function parameters.
|
|
1276
|
+
*
|
|
1277
|
+
* The returned ActionClaimant has the following properties:
|
|
1278
|
+
* - signatureType: Set to SignatureType.EVENT (though it doesn't matter for this case)
|
|
1279
|
+
* - signature: Set to zeroHash (0x0000...0000)
|
|
1280
|
+
* - fieldIndex: Set to 255, indicating "any" field
|
|
1281
|
+
* - targetContract: Set to zeroAddress (0x0000...0000)
|
|
1282
|
+
* - chainid: Set to 0, indicating it's valid for any chain
|
|
1283
|
+
*
|
|
1284
|
+
* @returns {ActionClaimant} An ActionClaimant object representing the msg.sender
|
|
1285
|
+
*
|
|
1286
|
+
* @example
|
|
1287
|
+
* const eventAction = new EventAction();
|
|
1288
|
+
* const payload: EventActionPayload = {
|
|
1289
|
+
* actionClaimant: transactionSenderClaimant(),
|
|
1290
|
+
* actionSteps: [
|
|
1291
|
+
* // ... define your action steps here
|
|
1292
|
+
* ]
|
|
1293
|
+
* };
|
|
1294
|
+
* await eventAction.deploy(payload);
|
|
1295
|
+
*/
|
|
1296
|
+
export function transactionSenderClaimant(): ActionClaimant {
|
|
1297
|
+
return {
|
|
1298
|
+
signatureType: SignatureType.EVENT,
|
|
1299
|
+
signature: zeroHash,
|
|
1300
|
+
fieldIndex: 255,
|
|
1301
|
+
targetContract: zeroAddress,
|
|
1302
|
+
chainid: 0,
|
|
1303
|
+
};
|
|
1304
|
+
}
|
|
@@ -99,6 +99,7 @@ export class SimpleAllowList extends DeployableTargetWithRBAC<
|
|
|
99
99
|
* @type {Record<number, Address>}
|
|
100
100
|
*/
|
|
101
101
|
public static override bases: Record<number, Address> = {
|
|
102
|
+
31337: import.meta.env.VITE_SIMPLE_ALLOWLIST_BASE,
|
|
102
103
|
...(SimpleAllowListBases as Record<number, Address>),
|
|
103
104
|
};
|
|
104
105
|
/**
|