@boostxyz/sdk 0.0.0-alpha.17 → 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 +13 -13
- 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 -962
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.js +3 -3
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +5 -5
- package/dist/AllowLists/SimpleAllowList.js +24 -24
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +6 -6
- package/dist/AllowLists/SimpleDenyList.js +3 -3
- 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 +28 -28
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +18 -18
- package/dist/Budgets/ManagedBudget.js +48 -48
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +23 -23
- 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 +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -1
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +15 -15
- package/dist/Deployable/DeployableTargetWithRBAC.js +32 -32
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -1
- 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-DJf-vdyL.js → Incentive-CF7kaz_9.js} +61 -62
- package/dist/Incentive-CF7kaz_9.js.map +1 -0
- package/dist/{Incentive-DNwROd1r.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 +19 -19
- 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 +18 -18
- 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 +25 -25
- 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 +21 -21
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/{SimpleDenyList-DMlUkmAn.cjs → SimpleDenyList-BwfNjRsg.cjs} +2 -2
- package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
- package/dist/{SimpleDenyList-DvUvmOeE.js → SimpleDenyList-D9i4rw_F.js} +9 -9
- 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 +19 -19
- 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-C_7Jx3YG.js → generated-B8VWObPa.js} +631 -343
- package/dist/generated-B8VWObPa.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +133 -125
- 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 +5 -5
- package/src/Actions/ContractAction.ts +9 -10
- package/src/Actions/ERC721MintAction.ts +12 -13
- package/src/Actions/EventAction.test.ts +45 -54
- package/src/Actions/EventAction.ts +100 -100
- package/src/AllowLists/SimpleAllowList.ts +5 -5
- package/src/AllowLists/SimpleDenyList.ts +6 -6
- 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/ManagedBudget.ts +18 -18
- package/src/Budgets/VestingBudget.ts +23 -23
- 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 +15 -15
- 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.ts +1 -0
- package/src/transfers.ts +1 -1
- package/src/utils.ts +1 -1
- package/dist/Incentive-DJf-vdyL.js.map +0 -1
- package/dist/Incentive-DNwROd1r.cjs.map +0 -1
- package/dist/SimpleDenyList-DMlUkmAn.cjs.map +0 -1
- package/dist/SimpleDenyList-DvUvmOeE.js.map +0 -1
- package/dist/componentInterfaces-BPVR_Ykd.js +0 -13
- package/dist/componentInterfaces-BPVR_Ykd.js.map +0 -1
- package/dist/componentInterfaces-BfppSIl4.cjs +0 -2
- package/dist/componentInterfaces-BfppSIl4.cjs.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-CMQ6ZC2_.cjs +0 -3
- package/dist/generated-CMQ6ZC2_.cjs.map +0 -1
- package/dist/generated-C_7Jx3YG.js.map +0 -1
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
encodeAbiParameters,
|
|
18
18
|
parseAbiParameters,
|
|
19
19
|
} from 'viem';
|
|
20
|
-
import {} from '../../dist/deployments.json';
|
|
21
20
|
import type {
|
|
22
21
|
DeployableOptions,
|
|
23
22
|
GenericDeployableParams,
|
|
@@ -117,7 +116,7 @@ export class ContractAction<
|
|
|
117
116
|
*
|
|
118
117
|
* @public
|
|
119
118
|
* @async
|
|
120
|
-
* @param {?ReadParams
|
|
119
|
+
* @param {?ReadParams} [params]
|
|
121
120
|
* @returns {Promise<bigint>}
|
|
122
121
|
*/
|
|
123
122
|
public async chainId(
|
|
@@ -136,7 +135,7 @@ export class ContractAction<
|
|
|
136
135
|
*
|
|
137
136
|
* @public
|
|
138
137
|
* @async
|
|
139
|
-
* @param {?ReadParams
|
|
138
|
+
* @param {?ReadParams} [params]
|
|
140
139
|
* @returns {Promise<`0x${string}`>}
|
|
141
140
|
*/
|
|
142
141
|
public async target(params?: ReadParams<typeof contractActionAbi, 'target'>) {
|
|
@@ -154,7 +153,7 @@ export class ContractAction<
|
|
|
154
153
|
* @example `function mint(address to, uint256 amount)`
|
|
155
154
|
* @public
|
|
156
155
|
* @async
|
|
157
|
-
* @param {?ReadParams
|
|
156
|
+
* @param {?ReadParams} [params]
|
|
158
157
|
* @returns {Promise<`0x${string}`>}
|
|
159
158
|
*/
|
|
160
159
|
public async selector(
|
|
@@ -173,7 +172,7 @@ export class ContractAction<
|
|
|
173
172
|
*
|
|
174
173
|
* @public
|
|
175
174
|
* @async
|
|
176
|
-
* @param {?ReadParams
|
|
175
|
+
* @param {?ReadParams} [params]
|
|
177
176
|
* @returns {Promise<bigint>}
|
|
178
177
|
*/
|
|
179
178
|
public async value(params?: ReadParams<typeof contractActionAbi, 'value'>) {
|
|
@@ -191,7 +190,7 @@ export class ContractAction<
|
|
|
191
190
|
* @public
|
|
192
191
|
* @async
|
|
193
192
|
* @param {Hex} data
|
|
194
|
-
* @param {?WriteParams
|
|
193
|
+
* @param {?WriteParams} [params]
|
|
195
194
|
* @returns {Promise<readonly [boolean, `0x${string}`]>}
|
|
196
195
|
*/
|
|
197
196
|
public async execute(
|
|
@@ -207,8 +206,8 @@ export class ContractAction<
|
|
|
207
206
|
* @public
|
|
208
207
|
* @async
|
|
209
208
|
* @param {Hex} data
|
|
210
|
-
* @param {?WriteParams
|
|
211
|
-
* @returns {
|
|
209
|
+
* @param {?WriteParams} [params]
|
|
210
|
+
* @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
|
|
212
211
|
*/
|
|
213
212
|
public async executeRaw(
|
|
214
213
|
data: Hex,
|
|
@@ -234,8 +233,8 @@ export class ContractAction<
|
|
|
234
233
|
* @public
|
|
235
234
|
* @async
|
|
236
235
|
* @param {Hex} calldata
|
|
237
|
-
* @param {?ReadParams
|
|
238
|
-
* @returns {
|
|
236
|
+
* @param {?ReadParams} [params]
|
|
237
|
+
* @returns {Promise<`0x${string}`>}
|
|
239
238
|
*/
|
|
240
239
|
public async prepare(
|
|
241
240
|
calldata: Hex,
|
|
@@ -15,7 +15,6 @@ import {
|
|
|
15
15
|
encodeAbiParameters,
|
|
16
16
|
toHex,
|
|
17
17
|
} from 'viem';
|
|
18
|
-
import {} from '../../dist/deployments.json';
|
|
19
18
|
import type {
|
|
20
19
|
DeployableOptions,
|
|
21
20
|
GenericDeployableParams,
|
|
@@ -97,8 +96,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
97
96
|
* @public
|
|
98
97
|
* @async
|
|
99
98
|
* @param {bigint} token
|
|
100
|
-
* @param {?ReadParams
|
|
101
|
-
* @returns {
|
|
99
|
+
* @param {?ReadParams} [params]
|
|
100
|
+
* @returns {Promise<boolean>}
|
|
102
101
|
*/
|
|
103
102
|
public async validated(
|
|
104
103
|
token: bigint,
|
|
@@ -119,8 +118,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
119
118
|
* @public
|
|
120
119
|
* @async
|
|
121
120
|
* @param {Hex} data
|
|
122
|
-
* @param {?WriteParams
|
|
123
|
-
* @returns {
|
|
121
|
+
* @param {?WriteParams} [params]
|
|
122
|
+
* @returns {Promise<readonly [boolean, `0x${string}`]>}
|
|
124
123
|
*/
|
|
125
124
|
public override async execute(
|
|
126
125
|
data: Hex,
|
|
@@ -135,8 +134,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
135
134
|
* @public
|
|
136
135
|
* @async
|
|
137
136
|
* @param {Hex} data
|
|
138
|
-
* @param {?WriteParams
|
|
139
|
-
* @returns {
|
|
137
|
+
* @param {?WriteParams} [params]
|
|
138
|
+
* @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
|
|
140
139
|
*/
|
|
141
140
|
public override async executeRaw(
|
|
142
141
|
data: Hex,
|
|
@@ -162,8 +161,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
162
161
|
* @public
|
|
163
162
|
* @async
|
|
164
163
|
* @param {Hex} data
|
|
165
|
-
* @param {?ReadParams
|
|
166
|
-
* @returns {
|
|
164
|
+
* @param {?ReadParams} [params]
|
|
165
|
+
* @returns {Promise<`0x${string}`>}
|
|
167
166
|
*/
|
|
168
167
|
public override async prepare(
|
|
169
168
|
data: Hex,
|
|
@@ -185,8 +184,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
185
184
|
* @async
|
|
186
185
|
* @param {Address} holder - The holder
|
|
187
186
|
* @param {BigInt} tokenId - The token ID
|
|
188
|
-
* @param {?WriteParams
|
|
189
|
-
* @returns {Promise<
|
|
187
|
+
* @param {?WriteParams} [params]
|
|
188
|
+
* @returns {Promise<boolean>} - True if the action has been validated for the user
|
|
190
189
|
*/
|
|
191
190
|
protected async validate(
|
|
192
191
|
holder: Address,
|
|
@@ -203,7 +202,7 @@ export class ERC721MintAction extends ContractAction<
|
|
|
203
202
|
* @async
|
|
204
203
|
* @param {Address} holder - The holder
|
|
205
204
|
* @param {BigInt} tokenId - The token ID
|
|
206
|
-
* @param {?WriteParams
|
|
205
|
+
* @param {?WriteParams} [params]
|
|
207
206
|
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the action has been validated for the user
|
|
208
207
|
*/
|
|
209
208
|
protected async validateRaw(
|
|
@@ -280,7 +279,7 @@ export function prepareERC721MintActionValidate(
|
|
|
280
279
|
* @param {Address} param0.target - The target contract address
|
|
281
280
|
* @param {Hex} param0.selector - The selector for the function to be called
|
|
282
281
|
* @param {bigint} param0.value - The native token value to send with the function call
|
|
283
|
-
* @returns {
|
|
282
|
+
* @returns {Hex}
|
|
284
283
|
*/
|
|
285
284
|
export function prepareERC721MintActionPayload({
|
|
286
285
|
chainId,
|
|
@@ -17,7 +17,6 @@ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
|
17
17
|
import type { MockERC20 } from '@boostxyz/test/MockERC20';
|
|
18
18
|
import type { MockERC721 } from '@boostxyz/test/MockERC721';
|
|
19
19
|
import { accounts } from '@boostxyz/test/accounts';
|
|
20
|
-
import { InvalidNumericalCriteriaError, FieldValueNotComparableError, UnrecognizedFilterTypeError } from '../errors';
|
|
21
20
|
import {
|
|
22
21
|
type Fixtures,
|
|
23
22
|
type StringEmitterFixtures,
|
|
@@ -41,10 +40,12 @@ let fixtures: Fixtures,
|
|
|
41
40
|
erc721: MockERC721,
|
|
42
41
|
erc20: MockERC20,
|
|
43
42
|
stringEmitterFixtures: StringEmitterFixtures;
|
|
43
|
+
let chainId: number;
|
|
44
44
|
|
|
45
45
|
beforeAll(async () => {
|
|
46
46
|
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
47
47
|
stringEmitterFixtures = await loadFixture(deployStringEmitterMock);
|
|
48
|
+
chainId = defaultOptions.config.chains[0].id;
|
|
48
49
|
});
|
|
49
50
|
|
|
50
51
|
function basicErc721TransferAction(
|
|
@@ -58,7 +59,7 @@ function basicErc721TransferAction(
|
|
|
58
59
|
] as Hex,
|
|
59
60
|
fieldIndex: 1,
|
|
60
61
|
targetContract: erc721.assertValidAddress(),
|
|
61
|
-
chainid:
|
|
62
|
+
chainid: chainId,
|
|
62
63
|
},
|
|
63
64
|
actionSteps: [
|
|
64
65
|
{
|
|
@@ -67,7 +68,7 @@ function basicErc721TransferAction(
|
|
|
67
68
|
] as Hex,
|
|
68
69
|
signatureType: SignatureType.EVENT,
|
|
69
70
|
targetContract: erc721.assertValidAddress(),
|
|
70
|
-
chainid:
|
|
71
|
+
chainid: chainId,
|
|
71
72
|
actionParameter: {
|
|
72
73
|
filterType: FilterType.EQUAL,
|
|
73
74
|
fieldType: PrimitiveType.ADDRESS,
|
|
@@ -91,14 +92,13 @@ function cloneEventAction(fixtures: Fixtures, erc721: MockERC721) {
|
|
|
91
92
|
function basicErc721MintFuncAction(
|
|
92
93
|
erc721: MockERC721,
|
|
93
94
|
): EventActionPayloadSimple {
|
|
94
|
-
console.log(funcSelectors["mint(address)"] as Hex);
|
|
95
95
|
return {
|
|
96
96
|
actionClaimant: {
|
|
97
97
|
signatureType: SignatureType.FUNC,
|
|
98
98
|
signature: funcSelectors["mint(address)"] as Hex,
|
|
99
99
|
fieldIndex: 0,
|
|
100
100
|
targetContract: erc721.assertValidAddress(),
|
|
101
|
-
chainid:
|
|
101
|
+
chainid: chainId,
|
|
102
102
|
},
|
|
103
103
|
actionSteps: [
|
|
104
104
|
{
|
|
@@ -106,7 +106,7 @@ function basicErc721MintFuncAction(
|
|
|
106
106
|
signatureType: SignatureType.FUNC,
|
|
107
107
|
actionType: 0,
|
|
108
108
|
targetContract: erc721.assertValidAddress(),
|
|
109
|
-
chainid:
|
|
109
|
+
chainid: chainId,
|
|
110
110
|
actionParameter: {
|
|
111
111
|
filterType: FilterType.EQUAL,
|
|
112
112
|
fieldType: PrimitiveType.ADDRESS,
|
|
@@ -125,7 +125,7 @@ function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
|
|
|
125
125
|
signature: funcSelectors["mint(address to, uint256 amount)"] as Hex,
|
|
126
126
|
fieldIndex: 0,
|
|
127
127
|
targetContract: erc20.assertValidAddress(),
|
|
128
|
-
chainid:
|
|
128
|
+
chainid: chainId,
|
|
129
129
|
},
|
|
130
130
|
actionSteps: [
|
|
131
131
|
{
|
|
@@ -133,7 +133,7 @@ function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
|
|
|
133
133
|
signatureType: SignatureType.FUNC,
|
|
134
134
|
actionType: 0,
|
|
135
135
|
targetContract: erc20.assertValidAddress(),
|
|
136
|
-
chainid:
|
|
136
|
+
chainid: chainId,
|
|
137
137
|
actionParameter: {
|
|
138
138
|
filterType: FilterType.EQUAL,
|
|
139
139
|
fieldType: PrimitiveType.ADDRESS,
|
|
@@ -159,7 +159,7 @@ function indexedStringErc721TransferAction(
|
|
|
159
159
|
] as Hex,
|
|
160
160
|
fieldIndex: 1,
|
|
161
161
|
targetContract: erc721.assertValidAddress(),
|
|
162
|
-
chainid:
|
|
162
|
+
chainid: chainId,
|
|
163
163
|
},
|
|
164
164
|
actionSteps: [
|
|
165
165
|
{
|
|
@@ -169,7 +169,7 @@ function indexedStringErc721TransferAction(
|
|
|
169
169
|
signatureType: SignatureType.EVENT,
|
|
170
170
|
actionType: 0,
|
|
171
171
|
targetContract: stringEmitterAddress,
|
|
172
|
-
chainid:
|
|
172
|
+
chainid: chainId,
|
|
173
173
|
actionParameter: {
|
|
174
174
|
filterType,
|
|
175
175
|
fieldType: PrimitiveType.STRING,
|
|
@@ -195,7 +195,7 @@ function stringErc721TransferAction(
|
|
|
195
195
|
] as Hex,
|
|
196
196
|
fieldIndex: 1,
|
|
197
197
|
targetContract: erc721.assertValidAddress(),
|
|
198
|
-
chainid:
|
|
198
|
+
chainid: chainId,
|
|
199
199
|
},
|
|
200
200
|
actionSteps: [
|
|
201
201
|
{
|
|
@@ -203,7 +203,7 @@ function stringErc721TransferAction(
|
|
|
203
203
|
signatureType: SignatureType.EVENT,
|
|
204
204
|
actionType: 0,
|
|
205
205
|
targetContract: stringEmitterAddress,
|
|
206
|
-
chainid:
|
|
206
|
+
chainid: chainId,
|
|
207
207
|
actionParameter: {
|
|
208
208
|
filterType,
|
|
209
209
|
fieldType: PrimitiveType.STRING,
|
|
@@ -308,7 +308,7 @@ describe("EventAction Event Selector", () => {
|
|
|
308
308
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
309
309
|
const steps = await action.getActionSteps();
|
|
310
310
|
expect(steps.length).toBe(1);
|
|
311
|
-
const step = steps[0]
|
|
311
|
+
const step = steps[0]!;
|
|
312
312
|
step.targetContract = step.targetContract.toUpperCase() as Hex;
|
|
313
313
|
step.actionParameter.filterData =
|
|
314
314
|
step.actionParameter.filterData.toUpperCase() as Hex;
|
|
@@ -351,7 +351,7 @@ describe("EventAction Event Selector", () => {
|
|
|
351
351
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
352
352
|
const steps = await action.getActionSteps();
|
|
353
353
|
expect(steps.length).toBe(1);
|
|
354
|
-
const step = steps[0]
|
|
354
|
+
const step = steps[0]!;
|
|
355
355
|
step.targetContract = step.targetContract.toUpperCase() as Hex;
|
|
356
356
|
step.actionParameter.filterData =
|
|
357
357
|
step.actionParameter.filterData.toUpperCase() as Hex;
|
|
@@ -391,20 +391,16 @@ describe("EventAction Event Selector", () => {
|
|
|
391
391
|
});
|
|
392
392
|
});
|
|
393
393
|
|
|
394
|
-
test("with no logs, does not validate", async () => {
|
|
395
|
-
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
396
|
-
expect(await action.validateActionSteps()).toBe(false);
|
|
397
|
-
});
|
|
398
|
-
|
|
399
394
|
test("with a correct log, validates", async () => {
|
|
400
395
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
401
396
|
const recipient = accounts[1].account;
|
|
402
397
|
await erc721.approve(recipient, 1n);
|
|
403
|
-
await erc721.
|
|
404
|
-
expect(await action.validateActionSteps()).toBe(true);
|
|
398
|
+
const { hash } = await erc721.transferFromRaw(defaultOptions.account.address, recipient, 1n);
|
|
399
|
+
expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
|
|
405
400
|
});
|
|
406
401
|
|
|
407
402
|
test("can supply your own logs to validate against", async () => {
|
|
403
|
+
const hash = "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5"
|
|
408
404
|
const logs: EventLogs = [
|
|
409
405
|
{
|
|
410
406
|
eventName: "Transfer",
|
|
@@ -432,7 +428,7 @@ describe("EventAction Event Selector", () => {
|
|
|
432
428
|
},
|
|
433
429
|
];
|
|
434
430
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
435
|
-
expect(await action.validateActionSteps({ logs })).toBe(true);
|
|
431
|
+
expect(await action.validateActionSteps({ hash, chainId, logs })).toBe(true);
|
|
436
432
|
});
|
|
437
433
|
|
|
438
434
|
describe("string event actions", () => {
|
|
@@ -449,8 +445,8 @@ describe("EventAction Event Selector", () => {
|
|
|
449
445
|
),
|
|
450
446
|
);
|
|
451
447
|
|
|
452
|
-
await stringEmitterFixtures.emitIndexedString("Hello world");
|
|
453
|
-
await expect(() => action.validateActionSteps()).rejects.toThrowError(
|
|
448
|
+
const hash = await stringEmitterFixtures.emitIndexedString("Hello world");
|
|
449
|
+
await expect(() => action.validateActionSteps({ hash, chainId })).rejects.toThrowError(
|
|
454
450
|
/Parameter is not transparently stored onchain/,
|
|
455
451
|
);
|
|
456
452
|
});
|
|
@@ -466,8 +462,8 @@ describe("EventAction Event Selector", () => {
|
|
|
466
462
|
),
|
|
467
463
|
),
|
|
468
464
|
);
|
|
469
|
-
await stringEmitterFixtures.emitString("Hello world");
|
|
470
|
-
expect(await action.validateActionSteps()).toBe(true);
|
|
465
|
+
const hash = await stringEmitterFixtures.emitString("Hello world");
|
|
466
|
+
expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
|
|
471
467
|
});
|
|
472
468
|
test("can parse and validate regex for an emitted string event", async () => {
|
|
473
469
|
const action = await loadFixture(
|
|
@@ -482,8 +478,8 @@ describe("EventAction Event Selector", () => {
|
|
|
482
478
|
),
|
|
483
479
|
);
|
|
484
480
|
|
|
485
|
-
await stringEmitterFixtures.emitString("Hello world");
|
|
486
|
-
expect(await action.validateActionSteps()).toBe(true);
|
|
481
|
+
const hash = await stringEmitterFixtures.emitString("Hello world");
|
|
482
|
+
expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
|
|
487
483
|
});
|
|
488
484
|
});
|
|
489
485
|
});
|
|
@@ -628,42 +624,29 @@ describe("EventAction Func Selector", () => {
|
|
|
628
624
|
test("validates function action step with correct hash", async () => {
|
|
629
625
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
630
626
|
const actionSteps = await action.getActionSteps();
|
|
627
|
+
const actionStep = actionSteps[0]!
|
|
631
628
|
const recipient = accounts[1].account;
|
|
632
629
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
633
630
|
value: parseEther(".1"),
|
|
634
631
|
});
|
|
635
632
|
|
|
636
633
|
expect(
|
|
637
|
-
await action.
|
|
638
|
-
hash,
|
|
639
|
-
}),
|
|
634
|
+
await action.isActionStepValid(actionStep, { hash, chainId })
|
|
640
635
|
).toBe(true);
|
|
641
636
|
});
|
|
642
637
|
|
|
643
|
-
test("throws an error when hash is missing", async () => {
|
|
644
|
-
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
645
|
-
const actionSteps = await action.getActionSteps();
|
|
646
|
-
try {
|
|
647
|
-
await action.isActionFunctionValid(actionSteps[0], {});
|
|
648
|
-
} catch (e) {
|
|
649
|
-
expect(e).toBeInstanceOf(Error);
|
|
650
|
-
expect((e as Error).message).toBe(
|
|
651
|
-
"Hash is required for function validation",
|
|
652
|
-
);
|
|
653
|
-
}
|
|
654
|
-
});
|
|
655
|
-
|
|
656
638
|
test("validates function step with EQUAL filter", async () => {
|
|
657
639
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
658
640
|
const actionSteps = await action.getActionSteps();
|
|
659
|
-
|
|
641
|
+
const actionStep = actionSteps[0]!
|
|
660
642
|
const recipient = accounts[1].account;
|
|
661
643
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
662
644
|
value: parseEther(".1"),
|
|
663
645
|
});
|
|
664
646
|
|
|
665
|
-
const criteriaMatch = await action.
|
|
647
|
+
const criteriaMatch = await action.isActionStepValid(actionStep, {
|
|
666
648
|
hash,
|
|
649
|
+
chainId,
|
|
667
650
|
});
|
|
668
651
|
|
|
669
652
|
expect(criteriaMatch).toBe(true);
|
|
@@ -672,10 +655,11 @@ describe("EventAction Func Selector", () => {
|
|
|
672
655
|
test("fails validation with incorrect function signature", async () => {
|
|
673
656
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
674
657
|
const actionSteps = await action.getActionSteps();
|
|
658
|
+
const actionStep = actionSteps[0]!;
|
|
675
659
|
const recipient = accounts[1].account;
|
|
676
660
|
|
|
677
661
|
const invalidStep = {
|
|
678
|
-
...
|
|
662
|
+
...actionStep,
|
|
679
663
|
signature: funcSelectors["mint(address to, uint256 amount)"] as Hex, // Intentional mismatch
|
|
680
664
|
};
|
|
681
665
|
|
|
@@ -684,7 +668,7 @@ describe("EventAction Func Selector", () => {
|
|
|
684
668
|
});
|
|
685
669
|
|
|
686
670
|
try {
|
|
687
|
-
await action.
|
|
671
|
+
await action.isActionStepValid(invalidStep, { hash, chainId });
|
|
688
672
|
} catch (e) {
|
|
689
673
|
expect(e).toBeInstanceOf(Error);
|
|
690
674
|
expect((e as Error).message).toContain(
|
|
@@ -696,15 +680,17 @@ describe("EventAction Func Selector", () => {
|
|
|
696
680
|
test("validates against NOT_EQUAL filter criteria", async () => {
|
|
697
681
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
698
682
|
const actionSteps = await action.getActionSteps();
|
|
699
|
-
actionSteps[0]
|
|
683
|
+
const actionStep = actionSteps[0]!;
|
|
684
|
+
actionStep.actionParameter.filterType = FilterType.NOT_EQUAL;
|
|
700
685
|
const recipient = accounts[2].account;
|
|
701
686
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
702
687
|
value: parseEther(".1"),
|
|
703
688
|
});
|
|
704
689
|
|
|
705
690
|
expect(
|
|
706
|
-
await action.
|
|
691
|
+
await action.isActionStepValid(actionStep, {
|
|
707
692
|
hash,
|
|
693
|
+
chainId,
|
|
708
694
|
}),
|
|
709
695
|
).toBe(true);
|
|
710
696
|
});
|
|
@@ -712,8 +698,9 @@ describe("EventAction Func Selector", () => {
|
|
|
712
698
|
test("validates GREATER_THAN criteria for numeric values", async () => {
|
|
713
699
|
const action = await loadFixture(cloneFunctionAction20(fixtures, erc20));
|
|
714
700
|
const actionSteps = await action.getActionSteps();
|
|
701
|
+
const actionStep = actionSteps[0]!;
|
|
715
702
|
|
|
716
|
-
|
|
703
|
+
actionStep.actionParameter = {
|
|
717
704
|
filterType: FilterType.GREATER_THAN,
|
|
718
705
|
fieldType: PrimitiveType.UINT,
|
|
719
706
|
fieldIndex: 1,
|
|
@@ -725,8 +712,9 @@ describe("EventAction Func Selector", () => {
|
|
|
725
712
|
const { hash } = await erc20.mintRaw(address, value);
|
|
726
713
|
|
|
727
714
|
expect(
|
|
728
|
-
await action.
|
|
715
|
+
await action.isActionStepValid(actionStep, {
|
|
729
716
|
hash,
|
|
717
|
+
chainId,
|
|
730
718
|
}),
|
|
731
719
|
).toBe(true);
|
|
732
720
|
});
|
|
@@ -734,7 +722,8 @@ describe("EventAction Func Selector", () => {
|
|
|
734
722
|
test("validates LESS_THAN criteria for numeric values", async () => {
|
|
735
723
|
const action = await loadFixture(cloneFunctionAction20(fixtures, erc20));
|
|
736
724
|
const actionSteps = await action.getActionSteps();
|
|
737
|
-
actionSteps[0]
|
|
725
|
+
const actionStep = actionSteps[0]!;
|
|
726
|
+
actionStep.actionParameter = {
|
|
738
727
|
filterType: FilterType.LESS_THAN,
|
|
739
728
|
fieldType: PrimitiveType.UINT,
|
|
740
729
|
fieldIndex: 1,
|
|
@@ -746,8 +735,9 @@ describe("EventAction Func Selector", () => {
|
|
|
746
735
|
const { hash } = await erc20.mintRaw(address, value);
|
|
747
736
|
|
|
748
737
|
expect(
|
|
749
|
-
await action.
|
|
738
|
+
await action.isActionStepValid(actionStep, {
|
|
750
739
|
hash,
|
|
740
|
+
chainId,
|
|
751
741
|
}),
|
|
752
742
|
).toBe(true);
|
|
753
743
|
});
|
|
@@ -762,6 +752,7 @@ describe("EventAction Func Selector", () => {
|
|
|
762
752
|
expect(
|
|
763
753
|
await action.validateActionSteps({
|
|
764
754
|
hash,
|
|
755
|
+
chainId,
|
|
765
756
|
}),
|
|
766
757
|
).toBe(true);
|
|
767
758
|
});
|