@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
|
@@ -2,22 +2,21 @@ import { selectors as eventSelectors } from "@boostxyz/signatures/events";
|
|
|
2
2
|
import { selectors as funcSelectors } from "@boostxyz/signatures/functions";
|
|
3
3
|
import { loadFixture } from "@nomicfoundation/hardhat-network-helpers";
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
AbiEvent,
|
|
6
|
+
AbiFunction,
|
|
6
7
|
type Address,
|
|
7
|
-
type GetLogsReturnType,
|
|
8
8
|
type Hex,
|
|
9
|
-
type Log,
|
|
10
9
|
isAddress,
|
|
11
|
-
|
|
10
|
+
isAddressEqual,
|
|
12
11
|
parseEther,
|
|
13
12
|
toHex,
|
|
14
13
|
zeroAddress,
|
|
15
14
|
zeroHash,
|
|
16
|
-
} from
|
|
17
|
-
import { beforeAll, beforeEach, describe, expect, test } from
|
|
18
|
-
import type { MockERC20 } from
|
|
19
|
-
import type { MockERC721 } from
|
|
20
|
-
import { accounts } from
|
|
15
|
+
} from "viem";
|
|
16
|
+
import { beforeAll, beforeEach, describe, expect, test } from "vitest";
|
|
17
|
+
import type { MockERC20 } from "@boostxyz/test/MockERC20";
|
|
18
|
+
import type { MockERC721 } from "@boostxyz/test/MockERC721";
|
|
19
|
+
import { accounts } from "@boostxyz/test/accounts";
|
|
21
20
|
import {
|
|
22
21
|
type Fixtures,
|
|
23
22
|
type StringEmitterFixtures,
|
|
@@ -26,7 +25,7 @@ import {
|
|
|
26
25
|
fundErc20,
|
|
27
26
|
deployStringEmitterMock,
|
|
28
27
|
fundErc721,
|
|
29
|
-
} from
|
|
28
|
+
} from "@boostxyz/test/helpers";
|
|
30
29
|
import {
|
|
31
30
|
EventAction,
|
|
32
31
|
type EventLogs,
|
|
@@ -36,7 +35,9 @@ import {
|
|
|
36
35
|
SignatureType,
|
|
37
36
|
Criteria,
|
|
38
37
|
anyActionParameter,
|
|
38
|
+
transactionSenderClaimant,
|
|
39
39
|
} from "./EventAction";
|
|
40
|
+
import { allKnownSignatures } from "@boostxyz/test/allKnownSignatures";
|
|
40
41
|
|
|
41
42
|
let fixtures: Fixtures,
|
|
42
43
|
erc721: MockERC721,
|
|
@@ -83,14 +84,18 @@ function basicErc721TransferAction(
|
|
|
83
84
|
}
|
|
84
85
|
|
|
85
86
|
function basicErc721TransferActionWithEmptyActionParameter(erc721: MockERC721) {
|
|
86
|
-
const eventActionPayload = basicErc721TransferAction(erc721)
|
|
87
|
+
const eventActionPayload = basicErc721TransferAction(erc721);
|
|
87
88
|
if (eventActionPayload.actionSteps[0]?.actionParameter) {
|
|
88
|
-
eventActionPayload.actionSteps[0].actionParameter = anyActionParameter()
|
|
89
|
+
eventActionPayload.actionSteps[0].actionParameter = anyActionParameter();
|
|
89
90
|
}
|
|
90
|
-
return eventActionPayload
|
|
91
|
+
return eventActionPayload;
|
|
91
92
|
}
|
|
92
93
|
|
|
93
|
-
function cloneEventAction(
|
|
94
|
+
function cloneEventAction(
|
|
95
|
+
fixtures: Fixtures,
|
|
96
|
+
erc721: MockERC721,
|
|
97
|
+
eventActionPayload = basicErc721TransferAction(erc721),
|
|
98
|
+
) {
|
|
94
99
|
return function cloneEventAction() {
|
|
95
100
|
return fixtures.registry.initialize(
|
|
96
101
|
crypto.randomUUID(),
|
|
@@ -129,11 +134,11 @@ function basicErc721MintFuncAction(
|
|
|
129
134
|
}
|
|
130
135
|
|
|
131
136
|
function basicErc721MintFuncActionWithEmptyActionParameter(erc721: MockERC721) {
|
|
132
|
-
const eventActionPayload = basicErc721MintFuncAction(erc721)
|
|
137
|
+
const eventActionPayload = basicErc721MintFuncAction(erc721);
|
|
133
138
|
if (eventActionPayload.actionSteps[0]?.actionParameter) {
|
|
134
|
-
eventActionPayload.actionSteps[0].actionParameter = anyActionParameter()
|
|
139
|
+
eventActionPayload.actionSteps[0].actionParameter = anyActionParameter();
|
|
135
140
|
}
|
|
136
|
-
return eventActionPayload
|
|
141
|
+
return eventActionPayload;
|
|
137
142
|
}
|
|
138
143
|
|
|
139
144
|
function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
|
|
@@ -245,14 +250,15 @@ function cloneFunctionAction20(fixtures: Fixtures, erc20: MockERC20) {
|
|
|
245
250
|
};
|
|
246
251
|
}
|
|
247
252
|
|
|
248
|
-
function cloneFunctionAction(
|
|
253
|
+
function cloneFunctionAction(
|
|
254
|
+
fixtures: Fixtures,
|
|
255
|
+
erc721: MockERC721,
|
|
256
|
+
eventActionPayload = basicErc721MintFuncAction(erc721),
|
|
257
|
+
) {
|
|
249
258
|
return function cloneFunctionAction() {
|
|
250
259
|
return fixtures.registry.clone(
|
|
251
260
|
crypto.randomUUID(),
|
|
252
|
-
new fixtures.bases.EventAction(
|
|
253
|
-
defaultOptions,
|
|
254
|
-
eventActionPayload
|
|
255
|
-
),
|
|
261
|
+
new fixtures.bases.EventAction(defaultOptions, eventActionPayload),
|
|
256
262
|
);
|
|
257
263
|
};
|
|
258
264
|
}
|
|
@@ -273,7 +279,7 @@ function createMockCriteria(
|
|
|
273
279
|
filterType: FilterType,
|
|
274
280
|
fieldType: PrimitiveType,
|
|
275
281
|
filterData: Hex,
|
|
276
|
-
fieldIndex: number = 0
|
|
282
|
+
fieldIndex: number = 0,
|
|
277
283
|
): Criteria {
|
|
278
284
|
return {
|
|
279
285
|
filterType,
|
|
@@ -413,12 +419,23 @@ describe("EventAction Event Selector", () => {
|
|
|
413
419
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
414
420
|
const recipient = accounts[1].account;
|
|
415
421
|
await erc721.approve(recipient, 1n);
|
|
416
|
-
const { hash } = await erc721.transferFromRaw(
|
|
417
|
-
|
|
422
|
+
const { hash } = await erc721.transferFromRaw(
|
|
423
|
+
defaultOptions.account.address,
|
|
424
|
+
recipient,
|
|
425
|
+
1n,
|
|
426
|
+
);
|
|
427
|
+
expect(
|
|
428
|
+
await action.validateActionSteps({
|
|
429
|
+
hash,
|
|
430
|
+
chainId,
|
|
431
|
+
knownSignatures: allKnownSignatures,
|
|
432
|
+
}),
|
|
433
|
+
).toBe(true);
|
|
418
434
|
});
|
|
419
435
|
|
|
420
436
|
test("can supply your own logs to validate against", async () => {
|
|
421
|
-
const hash =
|
|
437
|
+
const hash =
|
|
438
|
+
"0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5";
|
|
422
439
|
const logs: EventLogs = [
|
|
423
440
|
{
|
|
424
441
|
eventName: "Transfer",
|
|
@@ -446,7 +463,14 @@ describe("EventAction Event Selector", () => {
|
|
|
446
463
|
},
|
|
447
464
|
];
|
|
448
465
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
449
|
-
expect(
|
|
466
|
+
expect(
|
|
467
|
+
await action.validateActionSteps({
|
|
468
|
+
hash,
|
|
469
|
+
chainId,
|
|
470
|
+
logs,
|
|
471
|
+
knownSignatures: allKnownSignatures,
|
|
472
|
+
}),
|
|
473
|
+
).toBe(true);
|
|
450
474
|
});
|
|
451
475
|
|
|
452
476
|
describe("string event actions", () => {
|
|
@@ -463,10 +487,15 @@ describe("EventAction Event Selector", () => {
|
|
|
463
487
|
),
|
|
464
488
|
);
|
|
465
489
|
|
|
466
|
-
const hash =
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
490
|
+
const hash =
|
|
491
|
+
await stringEmitterFixtures.emitIndexedString("Hello world");
|
|
492
|
+
await expect(() =>
|
|
493
|
+
action.validateActionSteps({
|
|
494
|
+
hash,
|
|
495
|
+
chainId,
|
|
496
|
+
knownSignatures: allKnownSignatures,
|
|
497
|
+
}),
|
|
498
|
+
).rejects.toThrowError(/Parameter is not transparently stored onchain/);
|
|
470
499
|
});
|
|
471
500
|
test("can parse and validate contains for an emitted string event", async () => {
|
|
472
501
|
const action = await loadFixture(
|
|
@@ -481,7 +510,13 @@ describe("EventAction Event Selector", () => {
|
|
|
481
510
|
),
|
|
482
511
|
);
|
|
483
512
|
const hash = await stringEmitterFixtures.emitString("Hello world");
|
|
484
|
-
expect(
|
|
513
|
+
expect(
|
|
514
|
+
await action.validateActionSteps({
|
|
515
|
+
hash,
|
|
516
|
+
chainId,
|
|
517
|
+
knownSignatures: allKnownSignatures,
|
|
518
|
+
}),
|
|
519
|
+
).toBe(true);
|
|
485
520
|
});
|
|
486
521
|
test("can parse and validate regex for an emitted string event", async () => {
|
|
487
522
|
const action = await loadFixture(
|
|
@@ -497,20 +532,63 @@ describe("EventAction Event Selector", () => {
|
|
|
497
532
|
);
|
|
498
533
|
|
|
499
534
|
const hash = await stringEmitterFixtures.emitString("Hello world");
|
|
500
|
-
expect(
|
|
535
|
+
expect(
|
|
536
|
+
await action.validateActionSteps({
|
|
537
|
+
hash,
|
|
538
|
+
chainId,
|
|
539
|
+
knownSignatures: allKnownSignatures,
|
|
540
|
+
}),
|
|
541
|
+
).toBe(true);
|
|
501
542
|
});
|
|
502
543
|
});
|
|
503
544
|
|
|
545
|
+
test("can derive a transaction sender claimant from an event action", async () => {
|
|
546
|
+
const action = await loadFixture(
|
|
547
|
+
cloneEventAction(fixtures, erc721, {
|
|
548
|
+
...basicErc721TransferAction(erc721),
|
|
549
|
+
actionClaimant: transactionSenderClaimant(),
|
|
550
|
+
}),
|
|
551
|
+
);
|
|
552
|
+
const recipient = accounts[1].account;
|
|
553
|
+
await erc721.approve(recipient, 1n);
|
|
554
|
+
const { hash } = await erc721.transferFromRaw(
|
|
555
|
+
defaultOptions.account.address,
|
|
556
|
+
recipient,
|
|
557
|
+
1n,
|
|
558
|
+
);
|
|
559
|
+
expect(
|
|
560
|
+
isAddressEqual(
|
|
561
|
+
(await action.deriveActionClaimantFromTransaction(
|
|
562
|
+
await action.getActionClaimant(),
|
|
563
|
+
{
|
|
564
|
+
hash,
|
|
565
|
+
chainId,
|
|
566
|
+
knownSignatures: allKnownSignatures,
|
|
567
|
+
},
|
|
568
|
+
))!,
|
|
569
|
+
defaultOptions.account.address,
|
|
570
|
+
),
|
|
571
|
+
).toBe(true);
|
|
572
|
+
});
|
|
573
|
+
|
|
504
574
|
test("can derive the claimant from an event action", async () => {
|
|
505
575
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
506
576
|
const recipient = accounts[1].account;
|
|
507
577
|
await erc721.approve(recipient, 1n);
|
|
508
|
-
const { hash } = await erc721.transferFromRaw(
|
|
578
|
+
const { hash } = await erc721.transferFromRaw(
|
|
579
|
+
defaultOptions.account.address,
|
|
580
|
+
recipient,
|
|
581
|
+
1n,
|
|
582
|
+
);
|
|
509
583
|
expect(
|
|
510
|
-
await action.deriveActionClaimantFromTransaction(
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
584
|
+
await action.deriveActionClaimantFromTransaction(
|
|
585
|
+
await action.getActionClaimant(),
|
|
586
|
+
{
|
|
587
|
+
hash,
|
|
588
|
+
chainId,
|
|
589
|
+
knownSignatures: allKnownSignatures,
|
|
590
|
+
},
|
|
591
|
+
),
|
|
514
592
|
).toBe(recipient);
|
|
515
593
|
});
|
|
516
594
|
|
|
@@ -522,148 +600,310 @@ describe("EventAction Event Selector", () => {
|
|
|
522
600
|
});
|
|
523
601
|
|
|
524
602
|
expect(
|
|
525
|
-
await action.deriveActionClaimantFromTransaction(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
603
|
+
await action.deriveActionClaimantFromTransaction(
|
|
604
|
+
await action.getActionClaimant(),
|
|
605
|
+
{
|
|
606
|
+
hash,
|
|
607
|
+
chainId,
|
|
608
|
+
knownSignatures: allKnownSignatures,
|
|
609
|
+
},
|
|
610
|
+
),
|
|
529
611
|
).toBe(recipient);
|
|
530
612
|
});
|
|
531
613
|
|
|
532
|
-
test(
|
|
533
|
-
const action = await loadFixture(
|
|
614
|
+
test("validates empty actionParameter", async () => {
|
|
615
|
+
const action = await loadFixture(
|
|
616
|
+
cloneEventAction(
|
|
617
|
+
fixtures,
|
|
618
|
+
erc721,
|
|
619
|
+
basicErc721TransferActionWithEmptyActionParameter(erc721),
|
|
620
|
+
),
|
|
621
|
+
);
|
|
534
622
|
const recipient = accounts[1].account;
|
|
535
623
|
await erc721.approve(recipient, 1n);
|
|
536
|
-
const { hash } = await erc721.transferFromRaw(
|
|
537
|
-
|
|
538
|
-
|
|
624
|
+
const { hash } = await erc721.transferFromRaw(
|
|
625
|
+
defaultOptions.account.address,
|
|
626
|
+
recipient,
|
|
627
|
+
1n,
|
|
628
|
+
);
|
|
629
|
+
expect(
|
|
630
|
+
await action.validateActionSteps({
|
|
631
|
+
hash,
|
|
632
|
+
chainId,
|
|
633
|
+
knownSignatures: allKnownSignatures,
|
|
634
|
+
}),
|
|
635
|
+
).toBe(true);
|
|
636
|
+
});
|
|
539
637
|
});
|
|
540
638
|
});
|
|
541
639
|
|
|
542
640
|
describe("validateFieldAgainstCriteria unit tests", () => {
|
|
543
|
-
let action: EventAction
|
|
641
|
+
let action: EventAction;
|
|
544
642
|
beforeAll(async () => {
|
|
545
643
|
action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
546
644
|
});
|
|
547
|
-
const mockAddress =
|
|
548
|
-
const mockInput = { decodedArgs: [
|
|
549
|
-
|
|
550
|
-
test(
|
|
551
|
-
const mockCriteria = createMockCriteria(
|
|
552
|
-
|
|
645
|
+
const mockAddress = "0x1234567890abcdef1234567890abcdef12345678";
|
|
646
|
+
const mockInput = { decodedArgs: ["not used"] };
|
|
647
|
+
|
|
648
|
+
test("should return true for EQUAL filter type with ADDRESS field type", () => {
|
|
649
|
+
const mockCriteria = createMockCriteria(
|
|
650
|
+
FilterType.EQUAL,
|
|
651
|
+
PrimitiveType.ADDRESS,
|
|
652
|
+
mockAddress,
|
|
653
|
+
);
|
|
654
|
+
const result = action.validateFieldAgainstCriteria(
|
|
655
|
+
mockCriteria,
|
|
656
|
+
mockAddress,
|
|
657
|
+
mockInput,
|
|
658
|
+
);
|
|
553
659
|
expect(result).toBe(true);
|
|
554
660
|
});
|
|
555
661
|
|
|
556
|
-
test(
|
|
557
|
-
const mockCriteria = createMockCriteria(
|
|
558
|
-
|
|
662
|
+
test("should return true for EQUAL filter type with UINT field type", () => {
|
|
663
|
+
const mockCriteria = createMockCriteria(
|
|
664
|
+
FilterType.EQUAL,
|
|
665
|
+
PrimitiveType.UINT,
|
|
666
|
+
"0xc8",
|
|
667
|
+
);
|
|
668
|
+
const result = action.validateFieldAgainstCriteria(
|
|
669
|
+
mockCriteria,
|
|
670
|
+
200n,
|
|
671
|
+
mockInput,
|
|
672
|
+
);
|
|
559
673
|
expect(result).toBe(true);
|
|
560
674
|
});
|
|
561
|
-
test(
|
|
675
|
+
test("should return true for EQUAL filter type with STRING field type when values match", () => {
|
|
562
676
|
// Decoded value: 'hello'
|
|
563
|
-
const mockCriteria = createMockCriteria(
|
|
564
|
-
|
|
677
|
+
const mockCriteria = createMockCriteria(
|
|
678
|
+
FilterType.EQUAL,
|
|
679
|
+
PrimitiveType.STRING,
|
|
680
|
+
"0x68656c6c6f",
|
|
681
|
+
);
|
|
682
|
+
const result = action.validateFieldAgainstCriteria(
|
|
683
|
+
mockCriteria,
|
|
684
|
+
"hello",
|
|
685
|
+
mockInput,
|
|
686
|
+
);
|
|
565
687
|
expect(result).toBe(true);
|
|
566
688
|
});
|
|
567
689
|
|
|
568
|
-
test(
|
|
690
|
+
test("should return false for EQUAL filter type with STRING field type when values do not match", () => {
|
|
569
691
|
// Decoded value: 'hello'
|
|
570
|
-
const mockCriteria = createMockCriteria(
|
|
571
|
-
|
|
692
|
+
const mockCriteria = createMockCriteria(
|
|
693
|
+
FilterType.EQUAL,
|
|
694
|
+
PrimitiveType.STRING,
|
|
695
|
+
"0x68656c6c6f",
|
|
696
|
+
);
|
|
697
|
+
const result = action.validateFieldAgainstCriteria(
|
|
698
|
+
mockCriteria,
|
|
699
|
+
"world",
|
|
700
|
+
mockInput,
|
|
701
|
+
);
|
|
572
702
|
expect(result).toBe(false);
|
|
573
703
|
});
|
|
574
704
|
|
|
575
|
-
test(
|
|
705
|
+
test("should return true for EQUAL filter type with BYTES field type when values match", () => {
|
|
576
706
|
// Decoded value: '0x68656c6c6f' (hex for 'hello')
|
|
577
|
-
const mockCriteria = createMockCriteria(
|
|
578
|
-
|
|
707
|
+
const mockCriteria = createMockCriteria(
|
|
708
|
+
FilterType.EQUAL,
|
|
709
|
+
PrimitiveType.BYTES,
|
|
710
|
+
"0x68656c6c6f",
|
|
711
|
+
);
|
|
712
|
+
const result = action.validateFieldAgainstCriteria(
|
|
713
|
+
mockCriteria,
|
|
714
|
+
"0x68656c6c6f",
|
|
715
|
+
mockInput,
|
|
716
|
+
);
|
|
579
717
|
expect(result).toBe(true);
|
|
580
718
|
});
|
|
581
719
|
|
|
582
|
-
test(
|
|
720
|
+
test("should return false for EQUAL filter type with BYTES field type when values do not match", () => {
|
|
583
721
|
// Decoded value: '0x68656c6c6f' (hex for 'hello')
|
|
584
|
-
const mockCriteria = createMockCriteria(
|
|
585
|
-
|
|
722
|
+
const mockCriteria = createMockCriteria(
|
|
723
|
+
FilterType.EQUAL,
|
|
724
|
+
PrimitiveType.BYTES,
|
|
725
|
+
"0x68656c6c6f",
|
|
726
|
+
);
|
|
727
|
+
const result = action.validateFieldAgainstCriteria(
|
|
728
|
+
mockCriteria,
|
|
729
|
+
"0x776f726c64",
|
|
730
|
+
mockInput,
|
|
731
|
+
); // hex for 'world'
|
|
586
732
|
expect(result).toBe(false);
|
|
587
733
|
});
|
|
588
734
|
|
|
589
|
-
test(
|
|
590
|
-
const mockCriteria = createMockCriteria(
|
|
591
|
-
|
|
735
|
+
test("should return false for NOT_EQUAL filter type with ADDRESS field type", () => {
|
|
736
|
+
const mockCriteria = createMockCriteria(
|
|
737
|
+
FilterType.NOT_EQUAL,
|
|
738
|
+
PrimitiveType.ADDRESS,
|
|
739
|
+
mockAddress,
|
|
740
|
+
);
|
|
741
|
+
const result = action.validateFieldAgainstCriteria(
|
|
742
|
+
mockCriteria,
|
|
743
|
+
zeroAddress,
|
|
744
|
+
mockInput,
|
|
745
|
+
);
|
|
592
746
|
expect(result).toBe(true);
|
|
593
747
|
});
|
|
594
748
|
|
|
595
|
-
test(
|
|
596
|
-
const mockCriteria = createMockCriteria(
|
|
597
|
-
|
|
749
|
+
test("should return true for NOT_EQUAL filter type with UINT field type", () => {
|
|
750
|
+
const mockCriteria = createMockCriteria(
|
|
751
|
+
FilterType.NOT_EQUAL,
|
|
752
|
+
PrimitiveType.UINT,
|
|
753
|
+
"0xc9",
|
|
754
|
+
);
|
|
755
|
+
const result = action.validateFieldAgainstCriteria(
|
|
756
|
+
mockCriteria,
|
|
757
|
+
200n,
|
|
758
|
+
mockInput,
|
|
759
|
+
);
|
|
598
760
|
expect(result).toBe(true);
|
|
599
761
|
});
|
|
600
762
|
|
|
601
|
-
test(
|
|
602
|
-
const mockCriteria = createMockCriteria(
|
|
603
|
-
|
|
763
|
+
test("should throw InvalidNumericalCriteriaError for GREATER_THAN filter type with non-uint field type", () => {
|
|
764
|
+
const mockCriteria = createMockCriteria(
|
|
765
|
+
FilterType.GREATER_THAN,
|
|
766
|
+
PrimitiveType.STRING,
|
|
767
|
+
"0x100",
|
|
768
|
+
);
|
|
769
|
+
expect(() =>
|
|
770
|
+
action.validateFieldAgainstCriteria(mockCriteria, "200", mockInput),
|
|
771
|
+
).toThrow("non-numerical criteria");
|
|
604
772
|
});
|
|
605
773
|
|
|
606
|
-
test(
|
|
607
|
-
const mockCriteria = createMockCriteria(
|
|
608
|
-
|
|
774
|
+
test("should return true for GREATER_THAN filter type with UINT field type", () => {
|
|
775
|
+
const mockCriteria = createMockCriteria(
|
|
776
|
+
FilterType.GREATER_THAN,
|
|
777
|
+
PrimitiveType.UINT,
|
|
778
|
+
"0x64",
|
|
779
|
+
);
|
|
780
|
+
const result = action.validateFieldAgainstCriteria(
|
|
781
|
+
mockCriteria,
|
|
782
|
+
200n,
|
|
783
|
+
mockInput,
|
|
784
|
+
);
|
|
609
785
|
expect(result).toBe(true);
|
|
610
786
|
});
|
|
611
787
|
|
|
612
|
-
test(
|
|
788
|
+
test("should return true for CONTAINS filter type with STRING field type", () => {
|
|
613
789
|
// Decoded value: 'hello'
|
|
614
|
-
const mockCriteria = createMockCriteria(
|
|
615
|
-
|
|
790
|
+
const mockCriteria = createMockCriteria(
|
|
791
|
+
FilterType.CONTAINS,
|
|
792
|
+
PrimitiveType.STRING,
|
|
793
|
+
"0x68656c6c6f",
|
|
794
|
+
);
|
|
795
|
+
const result = action.validateFieldAgainstCriteria(
|
|
796
|
+
mockCriteria,
|
|
797
|
+
"hello world",
|
|
798
|
+
mockInput,
|
|
799
|
+
);
|
|
616
800
|
expect(result).toBe(true);
|
|
617
801
|
});
|
|
618
802
|
|
|
619
|
-
test(
|
|
620
|
-
const mockCriteria = createMockCriteria(
|
|
621
|
-
|
|
803
|
+
test("should return true for CONTAINS filter type with BYTES field type", () => {
|
|
804
|
+
const mockCriteria = createMockCriteria(
|
|
805
|
+
FilterType.CONTAINS,
|
|
806
|
+
PrimitiveType.BYTES,
|
|
807
|
+
"0xbeef",
|
|
808
|
+
);
|
|
809
|
+
const result = action.validateFieldAgainstCriteria(
|
|
810
|
+
mockCriteria,
|
|
811
|
+
"0xdeadbeef",
|
|
812
|
+
mockInput,
|
|
813
|
+
);
|
|
622
814
|
expect(result).toBe(true);
|
|
623
815
|
});
|
|
624
816
|
|
|
625
|
-
test(
|
|
817
|
+
test("should throw FieldValueNotComparableError for CONTAINS filter type with non-string/bytes field type", () => {
|
|
626
818
|
// Decoded value: 123
|
|
627
|
-
const mockCriteria = createMockCriteria(
|
|
628
|
-
|
|
819
|
+
const mockCriteria = createMockCriteria(
|
|
820
|
+
FilterType.CONTAINS,
|
|
821
|
+
PrimitiveType.UINT,
|
|
822
|
+
"0x7b",
|
|
823
|
+
);
|
|
824
|
+
expect(() =>
|
|
825
|
+
action.validateFieldAgainstCriteria(mockCriteria, 123n, mockInput),
|
|
826
|
+
).toThrow(/only .* bytes or string/);
|
|
629
827
|
});
|
|
630
828
|
|
|
631
|
-
test(
|
|
632
|
-
const mockCriteria = createMockCriteria(
|
|
633
|
-
|
|
829
|
+
test("should throw UnrecognizedFilterTypeError for unrecognized filter type", () => {
|
|
830
|
+
const mockCriteria = createMockCriteria(
|
|
831
|
+
6 as FilterType,
|
|
832
|
+
PrimitiveType.STRING,
|
|
833
|
+
"0x74657374",
|
|
834
|
+
); // Decoded value: 'test'
|
|
835
|
+
expect(() =>
|
|
836
|
+
action.validateFieldAgainstCriteria(mockCriteria, "test", mockInput),
|
|
837
|
+
).toThrow("Invalid FilterType");
|
|
634
838
|
});
|
|
635
839
|
|
|
636
|
-
test(
|
|
840
|
+
test("should return true for LESS_THAN filter type with UINT field type", () => {
|
|
637
841
|
// Decoded value: 200
|
|
638
|
-
const mockCriteria = createMockCriteria(
|
|
639
|
-
|
|
842
|
+
const mockCriteria = createMockCriteria(
|
|
843
|
+
FilterType.LESS_THAN,
|
|
844
|
+
PrimitiveType.UINT,
|
|
845
|
+
"0xc8",
|
|
846
|
+
);
|
|
847
|
+
const result = action.validateFieldAgainstCriteria(
|
|
848
|
+
mockCriteria,
|
|
849
|
+
100n,
|
|
850
|
+
mockInput,
|
|
851
|
+
);
|
|
640
852
|
expect(result).toBe(true);
|
|
641
853
|
});
|
|
642
854
|
|
|
643
|
-
test(
|
|
855
|
+
test("should return false for LESS_THAN filter type with UINT field type when value is greater", () => {
|
|
644
856
|
// Decoded value: 100
|
|
645
|
-
const mockCriteria = createMockCriteria(
|
|
646
|
-
|
|
857
|
+
const mockCriteria = createMockCriteria(
|
|
858
|
+
FilterType.LESS_THAN,
|
|
859
|
+
PrimitiveType.UINT,
|
|
860
|
+
"0x64",
|
|
861
|
+
);
|
|
862
|
+
const result = action.validateFieldAgainstCriteria(
|
|
863
|
+
mockCriteria,
|
|
864
|
+
200n,
|
|
865
|
+
mockInput,
|
|
866
|
+
);
|
|
647
867
|
expect(result).toBe(false);
|
|
648
868
|
});
|
|
649
869
|
|
|
650
|
-
test(
|
|
870
|
+
test("should throw InvalidNumericalCriteriaError for LESS_THAN filter type with non-uint field type", () => {
|
|
651
871
|
// Decoded value: 100
|
|
652
|
-
const mockCriteria = createMockCriteria(
|
|
653
|
-
|
|
872
|
+
const mockCriteria = createMockCriteria(
|
|
873
|
+
FilterType.LESS_THAN,
|
|
874
|
+
PrimitiveType.STRING,
|
|
875
|
+
"0x64",
|
|
876
|
+
);
|
|
877
|
+
expect(() =>
|
|
878
|
+
action.validateFieldAgainstCriteria(mockCriteria, "50", mockInput),
|
|
879
|
+
).toThrow("non-numerical");
|
|
654
880
|
});
|
|
655
881
|
|
|
656
|
-
test(
|
|
657
|
-
const mockCriteria = createMockCriteria(
|
|
658
|
-
|
|
882
|
+
test("should throw InvalidNumericalCriteriaError for LESS_THAN filter type with ADDRESS field type", () => {
|
|
883
|
+
const mockCriteria = createMockCriteria(
|
|
884
|
+
FilterType.LESS_THAN,
|
|
885
|
+
PrimitiveType.ADDRESS,
|
|
886
|
+
"0x1234567890abcdef1234567890abcdef12345678",
|
|
887
|
+
);
|
|
888
|
+
expect(() =>
|
|
889
|
+
action.validateFieldAgainstCriteria(
|
|
890
|
+
mockCriteria,
|
|
891
|
+
"0x1234567890abcdef1234567890abcdef12345678",
|
|
892
|
+
mockInput,
|
|
893
|
+
),
|
|
894
|
+
).toThrow("non-numerical");
|
|
659
895
|
});
|
|
660
896
|
|
|
661
|
-
test(
|
|
662
|
-
const mockCriteria = anyActionParameter()
|
|
663
|
-
const result = action.validateFieldAgainstCriteria(
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
897
|
+
test("should return true for anyActionParameter", async () => {
|
|
898
|
+
const mockCriteria = anyActionParameter();
|
|
899
|
+
const result = action.validateFieldAgainstCriteria(
|
|
900
|
+
mockCriteria,
|
|
901
|
+
zeroHash,
|
|
902
|
+
mockInput,
|
|
903
|
+
);
|
|
904
|
+
expect(result).toBe(true);
|
|
905
|
+
});
|
|
906
|
+
});
|
|
667
907
|
|
|
668
908
|
describe("EventAction Func Selector", () => {
|
|
669
909
|
beforeEach(async () => {
|
|
@@ -683,21 +923,25 @@ describe("EventAction Func Selector", () => {
|
|
|
683
923
|
test("validates function action step with correct hash", async () => {
|
|
684
924
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
685
925
|
const actionSteps = await action.getActionSteps();
|
|
686
|
-
const actionStep = actionSteps[0]
|
|
926
|
+
const actionStep = actionSteps[0]!;
|
|
687
927
|
const recipient = accounts[1].account;
|
|
688
928
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
689
929
|
value: parseEther(".1"),
|
|
690
930
|
});
|
|
691
931
|
|
|
692
932
|
expect(
|
|
693
|
-
await action.isActionStepValid(actionStep, {
|
|
933
|
+
await action.isActionStepValid(actionStep, {
|
|
934
|
+
hash,
|
|
935
|
+
chainId,
|
|
936
|
+
knownSignatures: allKnownSignatures,
|
|
937
|
+
}),
|
|
694
938
|
).toBe(true);
|
|
695
939
|
});
|
|
696
940
|
|
|
697
941
|
test("validates function step with EQUAL filter", async () => {
|
|
698
942
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
699
943
|
const actionSteps = await action.getActionSteps();
|
|
700
|
-
const actionStep = actionSteps[0]
|
|
944
|
+
const actionStep = actionSteps[0]!;
|
|
701
945
|
const recipient = accounts[1].account;
|
|
702
946
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
703
947
|
value: parseEther(".1"),
|
|
@@ -706,6 +950,7 @@ describe("EventAction Func Selector", () => {
|
|
|
706
950
|
const criteriaMatch = await action.isActionStepValid(actionStep, {
|
|
707
951
|
hash,
|
|
708
952
|
chainId,
|
|
953
|
+
knownSignatures: allKnownSignatures,
|
|
709
954
|
});
|
|
710
955
|
|
|
711
956
|
expect(criteriaMatch).toBe(true);
|
|
@@ -727,7 +972,11 @@ describe("EventAction Func Selector", () => {
|
|
|
727
972
|
});
|
|
728
973
|
|
|
729
974
|
try {
|
|
730
|
-
await action.isActionStepValid(invalidStep, {
|
|
975
|
+
await action.isActionStepValid(invalidStep, {
|
|
976
|
+
hash,
|
|
977
|
+
chainId,
|
|
978
|
+
knownSignatures: allKnownSignatures,
|
|
979
|
+
});
|
|
731
980
|
} catch (e) {
|
|
732
981
|
expect(e).toBeInstanceOf(Error);
|
|
733
982
|
expect((e as Error).message).toContain(
|
|
@@ -736,15 +985,27 @@ describe("EventAction Func Selector", () => {
|
|
|
736
985
|
}
|
|
737
986
|
});
|
|
738
987
|
|
|
739
|
-
test(
|
|
740
|
-
const action = await loadFixture(
|
|
988
|
+
test("validates empty actionParameter", async () => {
|
|
989
|
+
const action = await loadFixture(
|
|
990
|
+
cloneFunctionAction(
|
|
991
|
+
fixtures,
|
|
992
|
+
erc721,
|
|
993
|
+
basicErc721MintFuncActionWithEmptyActionParameter(erc721),
|
|
994
|
+
),
|
|
995
|
+
);
|
|
741
996
|
const recipient = accounts[1].account;
|
|
742
997
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
743
998
|
value: parseEther(".1"),
|
|
744
999
|
});
|
|
745
1000
|
|
|
746
|
-
expect(
|
|
747
|
-
|
|
1001
|
+
expect(
|
|
1002
|
+
await action.validateActionSteps({
|
|
1003
|
+
hash,
|
|
1004
|
+
chainId,
|
|
1005
|
+
knownSignatures: allKnownSignatures,
|
|
1006
|
+
}),
|
|
1007
|
+
).toBe(true);
|
|
1008
|
+
});
|
|
748
1009
|
|
|
749
1010
|
test("validates against NOT_EQUAL filter criteria", async () => {
|
|
750
1011
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
@@ -760,6 +1021,7 @@ describe("EventAction Func Selector", () => {
|
|
|
760
1021
|
await action.isActionStepValid(actionStep, {
|
|
761
1022
|
hash,
|
|
762
1023
|
chainId,
|
|
1024
|
+
knownSignatures: allKnownSignatures,
|
|
763
1025
|
}),
|
|
764
1026
|
).toBe(true);
|
|
765
1027
|
});
|
|
@@ -784,6 +1046,7 @@ describe("EventAction Func Selector", () => {
|
|
|
784
1046
|
await action.isActionStepValid(actionStep, {
|
|
785
1047
|
hash,
|
|
786
1048
|
chainId,
|
|
1049
|
+
knownSignatures: allKnownSignatures,
|
|
787
1050
|
}),
|
|
788
1051
|
).toBe(true);
|
|
789
1052
|
});
|
|
@@ -807,6 +1070,7 @@ describe("EventAction Func Selector", () => {
|
|
|
807
1070
|
await action.isActionStepValid(actionStep, {
|
|
808
1071
|
hash,
|
|
809
1072
|
chainId,
|
|
1073
|
+
knownSignatures: allKnownSignatures,
|
|
810
1074
|
}),
|
|
811
1075
|
).toBe(true);
|
|
812
1076
|
});
|
|
@@ -822,6 +1086,7 @@ describe("EventAction Func Selector", () => {
|
|
|
822
1086
|
await action.validateActionSteps({
|
|
823
1087
|
hash,
|
|
824
1088
|
chainId,
|
|
1089
|
+
knownSignatures: allKnownSignatures,
|
|
825
1090
|
}),
|
|
826
1091
|
).toBe(true);
|
|
827
1092
|
});
|