@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
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boostxyz/sdk",
|
|
3
|
-
"version": "0.0.0-alpha.
|
|
3
|
+
"version": "0.0.0-alpha.18",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
|
-
"repository": "https://github.com/
|
|
10
|
+
"repository": "https://github.com/boostxyz/boost-protocol",
|
|
11
11
|
"author": "Boost Team<boost-team@boost.xyz>",
|
|
12
12
|
"access": "public",
|
|
13
13
|
"private": false,
|
|
@@ -97,6 +97,12 @@
|
|
|
97
97
|
"node": "./dist/Deployable/DeployableTarget.js",
|
|
98
98
|
"types": "./dist/Deployable/DeployableTarget.d.ts"
|
|
99
99
|
},
|
|
100
|
+
"./Deployable/DeployableTargetWithRBAC": {
|
|
101
|
+
"require": "./dist/Deployable/DeployableTargetWithRBAC.cjs",
|
|
102
|
+
"import": "./dist/Deployable/DeployableTargetWithRBAC.js",
|
|
103
|
+
"node": "./dist/Deployable/DeployableTargetWithRBAC.js",
|
|
104
|
+
"types": "./dist/Deployable/DeployableTargetWithRBAC.d.ts"
|
|
105
|
+
},
|
|
100
106
|
"./Deployable/Contract": {
|
|
101
107
|
"require": "./dist/Deployable/Contract.cjs",
|
|
102
108
|
"import": "./dist/Deployable/Contract.js",
|
|
@@ -189,11 +195,12 @@
|
|
|
189
195
|
}
|
|
190
196
|
},
|
|
191
197
|
"dependencies": {
|
|
192
|
-
"
|
|
198
|
+
"ts-pattern": "5.4.0",
|
|
199
|
+
"@boostxyz/signatures": "0.0.0-alpha.6"
|
|
193
200
|
},
|
|
194
201
|
"optionalDependencies": {
|
|
195
|
-
"@boostxyz/evm": "0.0.0-alpha.
|
|
196
|
-
"@boostxyz/signatures": "0.0.0-alpha.
|
|
202
|
+
"@boostxyz/evm": "0.0.0-alpha.6",
|
|
203
|
+
"@boostxyz/signatures": "0.0.0-alpha.6"
|
|
197
204
|
},
|
|
198
205
|
"peerDependencies": {
|
|
199
206
|
"@wagmi/core": "2.x",
|
|
@@ -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,
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
pad,
|
|
12
12
|
parseEther,
|
|
13
13
|
toHex,
|
|
14
|
+
zeroAddress,
|
|
14
15
|
} from 'viem';
|
|
15
16
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
16
17
|
import type { MockERC20 } from '@boostxyz/test/MockERC20';
|
|
@@ -32,16 +33,19 @@ import {
|
|
|
32
33
|
FilterType,
|
|
33
34
|
PrimitiveType,
|
|
34
35
|
SignatureType,
|
|
36
|
+
Criteria,
|
|
35
37
|
} from "./EventAction";
|
|
36
38
|
|
|
37
39
|
let fixtures: Fixtures,
|
|
38
40
|
erc721: MockERC721,
|
|
39
41
|
erc20: MockERC20,
|
|
40
42
|
stringEmitterFixtures: StringEmitterFixtures;
|
|
43
|
+
let chainId: number;
|
|
41
44
|
|
|
42
45
|
beforeAll(async () => {
|
|
43
46
|
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
44
47
|
stringEmitterFixtures = await loadFixture(deployStringEmitterMock);
|
|
48
|
+
chainId = defaultOptions.config.chains[0].id;
|
|
45
49
|
});
|
|
46
50
|
|
|
47
51
|
function basicErc721TransferAction(
|
|
@@ -55,7 +59,7 @@ function basicErc721TransferAction(
|
|
|
55
59
|
] as Hex,
|
|
56
60
|
fieldIndex: 1,
|
|
57
61
|
targetContract: erc721.assertValidAddress(),
|
|
58
|
-
chainid:
|
|
62
|
+
chainid: chainId,
|
|
59
63
|
},
|
|
60
64
|
actionSteps: [
|
|
61
65
|
{
|
|
@@ -64,7 +68,7 @@ function basicErc721TransferAction(
|
|
|
64
68
|
] as Hex,
|
|
65
69
|
signatureType: SignatureType.EVENT,
|
|
66
70
|
targetContract: erc721.assertValidAddress(),
|
|
67
|
-
chainid:
|
|
71
|
+
chainid: chainId,
|
|
68
72
|
actionParameter: {
|
|
69
73
|
filterType: FilterType.EQUAL,
|
|
70
74
|
fieldType: PrimitiveType.ADDRESS,
|
|
@@ -88,14 +92,13 @@ function cloneEventAction(fixtures: Fixtures, erc721: MockERC721) {
|
|
|
88
92
|
function basicErc721MintFuncAction(
|
|
89
93
|
erc721: MockERC721,
|
|
90
94
|
): EventActionPayloadSimple {
|
|
91
|
-
console.log(funcSelectors["mint(address)"] as Hex);
|
|
92
95
|
return {
|
|
93
96
|
actionClaimant: {
|
|
94
97
|
signatureType: SignatureType.FUNC,
|
|
95
98
|
signature: funcSelectors["mint(address)"] as Hex,
|
|
96
99
|
fieldIndex: 0,
|
|
97
100
|
targetContract: erc721.assertValidAddress(),
|
|
98
|
-
chainid:
|
|
101
|
+
chainid: chainId,
|
|
99
102
|
},
|
|
100
103
|
actionSteps: [
|
|
101
104
|
{
|
|
@@ -103,7 +106,7 @@ function basicErc721MintFuncAction(
|
|
|
103
106
|
signatureType: SignatureType.FUNC,
|
|
104
107
|
actionType: 0,
|
|
105
108
|
targetContract: erc721.assertValidAddress(),
|
|
106
|
-
chainid:
|
|
109
|
+
chainid: chainId,
|
|
107
110
|
actionParameter: {
|
|
108
111
|
filterType: FilterType.EQUAL,
|
|
109
112
|
fieldType: PrimitiveType.ADDRESS,
|
|
@@ -122,7 +125,7 @@ function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
|
|
|
122
125
|
signature: funcSelectors["mint(address to, uint256 amount)"] as Hex,
|
|
123
126
|
fieldIndex: 0,
|
|
124
127
|
targetContract: erc20.assertValidAddress(),
|
|
125
|
-
chainid:
|
|
128
|
+
chainid: chainId,
|
|
126
129
|
},
|
|
127
130
|
actionSteps: [
|
|
128
131
|
{
|
|
@@ -130,7 +133,7 @@ function basicErc20MintFuncAction(erc20: MockERC20): EventActionPayloadSimple {
|
|
|
130
133
|
signatureType: SignatureType.FUNC,
|
|
131
134
|
actionType: 0,
|
|
132
135
|
targetContract: erc20.assertValidAddress(),
|
|
133
|
-
chainid:
|
|
136
|
+
chainid: chainId,
|
|
134
137
|
actionParameter: {
|
|
135
138
|
filterType: FilterType.EQUAL,
|
|
136
139
|
fieldType: PrimitiveType.ADDRESS,
|
|
@@ -156,7 +159,7 @@ function indexedStringErc721TransferAction(
|
|
|
156
159
|
] as Hex,
|
|
157
160
|
fieldIndex: 1,
|
|
158
161
|
targetContract: erc721.assertValidAddress(),
|
|
159
|
-
chainid:
|
|
162
|
+
chainid: chainId,
|
|
160
163
|
},
|
|
161
164
|
actionSteps: [
|
|
162
165
|
{
|
|
@@ -166,7 +169,7 @@ function indexedStringErc721TransferAction(
|
|
|
166
169
|
signatureType: SignatureType.EVENT,
|
|
167
170
|
actionType: 0,
|
|
168
171
|
targetContract: stringEmitterAddress,
|
|
169
|
-
chainid:
|
|
172
|
+
chainid: chainId,
|
|
170
173
|
actionParameter: {
|
|
171
174
|
filterType,
|
|
172
175
|
fieldType: PrimitiveType.STRING,
|
|
@@ -192,7 +195,7 @@ function stringErc721TransferAction(
|
|
|
192
195
|
] as Hex,
|
|
193
196
|
fieldIndex: 1,
|
|
194
197
|
targetContract: erc721.assertValidAddress(),
|
|
195
|
-
chainid:
|
|
198
|
+
chainid: chainId,
|
|
196
199
|
},
|
|
197
200
|
actionSteps: [
|
|
198
201
|
{
|
|
@@ -200,7 +203,7 @@ function stringErc721TransferAction(
|
|
|
200
203
|
signatureType: SignatureType.EVENT,
|
|
201
204
|
actionType: 0,
|
|
202
205
|
targetContract: stringEmitterAddress,
|
|
203
|
-
chainid:
|
|
206
|
+
chainid: chainId,
|
|
204
207
|
actionParameter: {
|
|
205
208
|
filterType,
|
|
206
209
|
fieldType: PrimitiveType.STRING,
|
|
@@ -248,6 +251,20 @@ function cloneStringEventAction(
|
|
|
248
251
|
};
|
|
249
252
|
}
|
|
250
253
|
|
|
254
|
+
function createMockCriteria(
|
|
255
|
+
filterType: FilterType,
|
|
256
|
+
fieldType: PrimitiveType,
|
|
257
|
+
filterData: Hex,
|
|
258
|
+
fieldIndex: number = 0
|
|
259
|
+
): Criteria {
|
|
260
|
+
return {
|
|
261
|
+
filterType,
|
|
262
|
+
fieldType,
|
|
263
|
+
filterData,
|
|
264
|
+
fieldIndex,
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
251
268
|
describe("EventAction Event Selector", () => {
|
|
252
269
|
beforeEach(async () => {
|
|
253
270
|
erc721 = await loadFixture(fundErc721(defaultOptions));
|
|
@@ -291,7 +308,7 @@ describe("EventAction Event Selector", () => {
|
|
|
291
308
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
292
309
|
const steps = await action.getActionSteps();
|
|
293
310
|
expect(steps.length).toBe(1);
|
|
294
|
-
const step = steps[0]
|
|
311
|
+
const step = steps[0]!;
|
|
295
312
|
step.targetContract = step.targetContract.toUpperCase() as Hex;
|
|
296
313
|
step.actionParameter.filterData =
|
|
297
314
|
step.actionParameter.filterData.toUpperCase() as Hex;
|
|
@@ -334,7 +351,7 @@ describe("EventAction Event Selector", () => {
|
|
|
334
351
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
335
352
|
const steps = await action.getActionSteps();
|
|
336
353
|
expect(steps.length).toBe(1);
|
|
337
|
-
const step = steps[0]
|
|
354
|
+
const step = steps[0]!;
|
|
338
355
|
step.targetContract = step.targetContract.toUpperCase() as Hex;
|
|
339
356
|
step.actionParameter.filterData =
|
|
340
357
|
step.actionParameter.filterData.toUpperCase() as Hex;
|
|
@@ -374,20 +391,16 @@ describe("EventAction Event Selector", () => {
|
|
|
374
391
|
});
|
|
375
392
|
});
|
|
376
393
|
|
|
377
|
-
test("with no logs, does not validate", async () => {
|
|
378
|
-
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
379
|
-
expect(await action.validateActionSteps()).toBe(false);
|
|
380
|
-
});
|
|
381
|
-
|
|
382
394
|
test("with a correct log, validates", async () => {
|
|
383
395
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
384
396
|
const recipient = accounts[1].account;
|
|
385
397
|
await erc721.approve(recipient, 1n);
|
|
386
|
-
await erc721.
|
|
387
|
-
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);
|
|
388
400
|
});
|
|
389
401
|
|
|
390
402
|
test("can supply your own logs to validate against", async () => {
|
|
403
|
+
const hash = "0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5"
|
|
391
404
|
const logs: EventLogs = [
|
|
392
405
|
{
|
|
393
406
|
eventName: "Transfer",
|
|
@@ -415,7 +428,7 @@ describe("EventAction Event Selector", () => {
|
|
|
415
428
|
},
|
|
416
429
|
];
|
|
417
430
|
const action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
418
|
-
expect(await action.validateActionSteps({ logs })).toBe(true);
|
|
431
|
+
expect(await action.validateActionSteps({ hash, chainId, logs })).toBe(true);
|
|
419
432
|
});
|
|
420
433
|
|
|
421
434
|
describe("string event actions", () => {
|
|
@@ -432,8 +445,8 @@ describe("EventAction Event Selector", () => {
|
|
|
432
445
|
),
|
|
433
446
|
);
|
|
434
447
|
|
|
435
|
-
await stringEmitterFixtures.emitIndexedString("Hello world");
|
|
436
|
-
await expect(() => action.validateActionSteps()).rejects.toThrowError(
|
|
448
|
+
const hash = await stringEmitterFixtures.emitIndexedString("Hello world");
|
|
449
|
+
await expect(() => action.validateActionSteps({ hash, chainId })).rejects.toThrowError(
|
|
437
450
|
/Parameter is not transparently stored onchain/,
|
|
438
451
|
);
|
|
439
452
|
});
|
|
@@ -449,8 +462,8 @@ describe("EventAction Event Selector", () => {
|
|
|
449
462
|
),
|
|
450
463
|
),
|
|
451
464
|
);
|
|
452
|
-
await stringEmitterFixtures.emitString("Hello world");
|
|
453
|
-
expect(await action.validateActionSteps()).toBe(true);
|
|
465
|
+
const hash = await stringEmitterFixtures.emitString("Hello world");
|
|
466
|
+
expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
|
|
454
467
|
});
|
|
455
468
|
test("can parse and validate regex for an emitted string event", async () => {
|
|
456
469
|
const action = await loadFixture(
|
|
@@ -465,13 +478,134 @@ describe("EventAction Event Selector", () => {
|
|
|
465
478
|
),
|
|
466
479
|
);
|
|
467
480
|
|
|
468
|
-
await stringEmitterFixtures.emitString("Hello world");
|
|
469
|
-
expect(await action.validateActionSteps()).toBe(true);
|
|
481
|
+
const hash = await stringEmitterFixtures.emitString("Hello world");
|
|
482
|
+
expect(await action.validateActionSteps({ hash, chainId })).toBe(true);
|
|
470
483
|
});
|
|
471
484
|
});
|
|
472
485
|
});
|
|
473
486
|
});
|
|
474
487
|
|
|
488
|
+
describe("validateFieldAgainstCriteria unit tests", () => {
|
|
489
|
+
let action: EventAction
|
|
490
|
+
beforeAll(async () => {
|
|
491
|
+
action = await loadFixture(cloneEventAction(fixtures, erc721));
|
|
492
|
+
});
|
|
493
|
+
const mockAddress = '0x1234567890abcdef1234567890abcdef12345678';
|
|
494
|
+
const mockInput = { decodedArgs: ['not used'] };
|
|
495
|
+
|
|
496
|
+
test('should return true for EQUAL filter type with ADDRESS field type', () => {
|
|
497
|
+
const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.ADDRESS, mockAddress);
|
|
498
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, mockAddress, mockInput);
|
|
499
|
+
expect(result).toBe(true);
|
|
500
|
+
});
|
|
501
|
+
|
|
502
|
+
test('should return true for EQUAL filter type with UINT field type', () => {
|
|
503
|
+
const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.UINT, '0xc8');
|
|
504
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
|
|
505
|
+
expect(result).toBe(true);
|
|
506
|
+
});
|
|
507
|
+
test('should return true for EQUAL filter type with STRING field type when values match', () => {
|
|
508
|
+
// Decoded value: 'hello'
|
|
509
|
+
const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
|
|
510
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 'hello', mockInput);
|
|
511
|
+
expect(result).toBe(true);
|
|
512
|
+
});
|
|
513
|
+
|
|
514
|
+
test('should return false for EQUAL filter type with STRING field type when values do not match', () => {
|
|
515
|
+
// Decoded value: 'hello'
|
|
516
|
+
const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.STRING, '0x68656c6c6f');
|
|
517
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 'world', mockInput);
|
|
518
|
+
expect(result).toBe(false);
|
|
519
|
+
});
|
|
520
|
+
|
|
521
|
+
test('should return true for EQUAL filter type with BYTES field type when values match', () => {
|
|
522
|
+
// Decoded value: '0x68656c6c6f' (hex for 'hello')
|
|
523
|
+
const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
|
|
524
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, '0x68656c6c6f', mockInput);
|
|
525
|
+
expect(result).toBe(true);
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
test('should return false for EQUAL filter type with BYTES field type when values do not match', () => {
|
|
529
|
+
// Decoded value: '0x68656c6c6f' (hex for 'hello')
|
|
530
|
+
const mockCriteria = createMockCriteria(FilterType.EQUAL, PrimitiveType.BYTES, '0x68656c6c6f');
|
|
531
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, '0x776f726c64', mockInput); // hex for 'world'
|
|
532
|
+
expect(result).toBe(false);
|
|
533
|
+
});
|
|
534
|
+
|
|
535
|
+
test('should return false for NOT_EQUAL filter type with ADDRESS field type', () => {
|
|
536
|
+
const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.ADDRESS, mockAddress);
|
|
537
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, zeroAddress, mockInput);
|
|
538
|
+
expect(result).toBe(true);
|
|
539
|
+
});
|
|
540
|
+
|
|
541
|
+
test('should return true for NOT_EQUAL filter type with UINT field type', () => {
|
|
542
|
+
const mockCriteria = createMockCriteria(FilterType.NOT_EQUAL, PrimitiveType.UINT, '0xc9');
|
|
543
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
|
|
544
|
+
expect(result).toBe(true);
|
|
545
|
+
});
|
|
546
|
+
|
|
547
|
+
test('should throw InvalidNumericalCriteriaError for GREATER_THAN filter type with non-uint field type', () => {
|
|
548
|
+
const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.STRING, '0x100');
|
|
549
|
+
expect(() => action.validateFieldAgainstCriteria(mockCriteria, '200', mockInput)).toThrow('non-numerical criteria');
|
|
550
|
+
});
|
|
551
|
+
|
|
552
|
+
test('should return true for GREATER_THAN filter type with UINT field type', () => {
|
|
553
|
+
const mockCriteria = createMockCriteria(FilterType.GREATER_THAN, PrimitiveType.UINT, '0x64');
|
|
554
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
|
|
555
|
+
expect(result).toBe(true);
|
|
556
|
+
});
|
|
557
|
+
|
|
558
|
+
test('should return true for CONTAINS filter type with STRING field type', () => {
|
|
559
|
+
// Decoded value: 'hello'
|
|
560
|
+
const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.STRING, '0x68656c6c6f');
|
|
561
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 'hello world', mockInput);
|
|
562
|
+
expect(result).toBe(true);
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
test('should return true for CONTAINS filter type with BYTES field type', () => {
|
|
566
|
+
const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.BYTES, '0xbeef');
|
|
567
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, '0xdeadbeef', mockInput);
|
|
568
|
+
expect(result).toBe(true);
|
|
569
|
+
});
|
|
570
|
+
|
|
571
|
+
test('should throw FieldValueNotComparableError for CONTAINS filter type with non-string/bytes field type', () => {
|
|
572
|
+
// Decoded value: 123
|
|
573
|
+
const mockCriteria = createMockCriteria(FilterType.CONTAINS, PrimitiveType.UINT, '0x7b');
|
|
574
|
+
expect(() => action.validateFieldAgainstCriteria(mockCriteria, 123n, mockInput)).toThrow(/only .* bytes or string/);
|
|
575
|
+
});
|
|
576
|
+
|
|
577
|
+
test('should throw UnrecognizedFilterTypeError for unrecognized filter type', () => {
|
|
578
|
+
const mockCriteria = createMockCriteria(6 as FilterType, PrimitiveType.STRING, '0x74657374'); // Decoded value: 'test'
|
|
579
|
+
expect(() => action.validateFieldAgainstCriteria(mockCriteria, 'test', mockInput)).toThrow('Invalid FilterType');
|
|
580
|
+
});
|
|
581
|
+
|
|
582
|
+
test('should return true for LESS_THAN filter type with UINT field type', () => {
|
|
583
|
+
// Decoded value: 200
|
|
584
|
+
const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0xc8');
|
|
585
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 100n, mockInput);
|
|
586
|
+
expect(result).toBe(true);
|
|
587
|
+
});
|
|
588
|
+
|
|
589
|
+
test('should return false for LESS_THAN filter type with UINT field type when value is greater', () => {
|
|
590
|
+
// Decoded value: 100
|
|
591
|
+
const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.UINT, '0x64');
|
|
592
|
+
const result = action.validateFieldAgainstCriteria(mockCriteria, 200n, mockInput);
|
|
593
|
+
expect(result).toBe(false);
|
|
594
|
+
});
|
|
595
|
+
|
|
596
|
+
test('should throw InvalidNumericalCriteriaError for LESS_THAN filter type with non-uint field type', () => {
|
|
597
|
+
// Decoded value: 100
|
|
598
|
+
const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.STRING, '0x64');
|
|
599
|
+
expect(() => action.validateFieldAgainstCriteria(mockCriteria, '50', mockInput)).toThrow('non-numerical');
|
|
600
|
+
});
|
|
601
|
+
|
|
602
|
+
test('should throw InvalidNumericalCriteriaError for LESS_THAN filter type with ADDRESS field type', () => {
|
|
603
|
+
const mockCriteria = createMockCriteria(FilterType.LESS_THAN, PrimitiveType.ADDRESS, '0x1234567890abcdef1234567890abcdef12345678');
|
|
604
|
+
expect(() => action.validateFieldAgainstCriteria(mockCriteria, '0x1234567890abcdef1234567890abcdef12345678', mockInput)).toThrow('non-numerical');
|
|
605
|
+
});
|
|
606
|
+
|
|
607
|
+
})
|
|
608
|
+
|
|
475
609
|
describe("EventAction Func Selector", () => {
|
|
476
610
|
beforeEach(async () => {
|
|
477
611
|
erc721 = await loadFixture(fundErc721(defaultOptions));
|
|
@@ -490,42 +624,29 @@ describe("EventAction Func Selector", () => {
|
|
|
490
624
|
test("validates function action step with correct hash", async () => {
|
|
491
625
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
492
626
|
const actionSteps = await action.getActionSteps();
|
|
627
|
+
const actionStep = actionSteps[0]!
|
|
493
628
|
const recipient = accounts[1].account;
|
|
494
629
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
495
630
|
value: parseEther(".1"),
|
|
496
631
|
});
|
|
497
632
|
|
|
498
633
|
expect(
|
|
499
|
-
await action.
|
|
500
|
-
hash,
|
|
501
|
-
}),
|
|
634
|
+
await action.isActionStepValid(actionStep, { hash, chainId })
|
|
502
635
|
).toBe(true);
|
|
503
636
|
});
|
|
504
637
|
|
|
505
|
-
test("throws an error when hash is missing", async () => {
|
|
506
|
-
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
507
|
-
const actionSteps = await action.getActionSteps();
|
|
508
|
-
try {
|
|
509
|
-
await action.isActionFunctionValid(actionSteps[0], {});
|
|
510
|
-
} catch (e) {
|
|
511
|
-
expect(e).toBeInstanceOf(Error);
|
|
512
|
-
expect((e as Error).message).toBe(
|
|
513
|
-
"Hash is required for function validation",
|
|
514
|
-
);
|
|
515
|
-
}
|
|
516
|
-
});
|
|
517
|
-
|
|
518
638
|
test("validates function step with EQUAL filter", async () => {
|
|
519
639
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
520
640
|
const actionSteps = await action.getActionSteps();
|
|
521
|
-
|
|
641
|
+
const actionStep = actionSteps[0]!
|
|
522
642
|
const recipient = accounts[1].account;
|
|
523
643
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
524
644
|
value: parseEther(".1"),
|
|
525
645
|
});
|
|
526
646
|
|
|
527
|
-
const criteriaMatch = await action.
|
|
647
|
+
const criteriaMatch = await action.isActionStepValid(actionStep, {
|
|
528
648
|
hash,
|
|
649
|
+
chainId,
|
|
529
650
|
});
|
|
530
651
|
|
|
531
652
|
expect(criteriaMatch).toBe(true);
|
|
@@ -534,10 +655,11 @@ describe("EventAction Func Selector", () => {
|
|
|
534
655
|
test("fails validation with incorrect function signature", async () => {
|
|
535
656
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
536
657
|
const actionSteps = await action.getActionSteps();
|
|
658
|
+
const actionStep = actionSteps[0]!;
|
|
537
659
|
const recipient = accounts[1].account;
|
|
538
660
|
|
|
539
661
|
const invalidStep = {
|
|
540
|
-
...
|
|
662
|
+
...actionStep,
|
|
541
663
|
signature: funcSelectors["mint(address to, uint256 amount)"] as Hex, // Intentional mismatch
|
|
542
664
|
};
|
|
543
665
|
|
|
@@ -546,7 +668,7 @@ describe("EventAction Func Selector", () => {
|
|
|
546
668
|
});
|
|
547
669
|
|
|
548
670
|
try {
|
|
549
|
-
await action.
|
|
671
|
+
await action.isActionStepValid(invalidStep, { hash, chainId });
|
|
550
672
|
} catch (e) {
|
|
551
673
|
expect(e).toBeInstanceOf(Error);
|
|
552
674
|
expect((e as Error).message).toContain(
|
|
@@ -558,15 +680,17 @@ describe("EventAction Func Selector", () => {
|
|
|
558
680
|
test("validates against NOT_EQUAL filter criteria", async () => {
|
|
559
681
|
const action = await loadFixture(cloneFunctionAction(fixtures, erc721));
|
|
560
682
|
const actionSteps = await action.getActionSteps();
|
|
561
|
-
actionSteps[0]
|
|
683
|
+
const actionStep = actionSteps[0]!;
|
|
684
|
+
actionStep.actionParameter.filterType = FilterType.NOT_EQUAL;
|
|
562
685
|
const recipient = accounts[2].account;
|
|
563
686
|
const { hash } = await erc721.mintRaw(recipient, {
|
|
564
687
|
value: parseEther(".1"),
|
|
565
688
|
});
|
|
566
689
|
|
|
567
690
|
expect(
|
|
568
|
-
await action.
|
|
691
|
+
await action.isActionStepValid(actionStep, {
|
|
569
692
|
hash,
|
|
693
|
+
chainId,
|
|
570
694
|
}),
|
|
571
695
|
).toBe(true);
|
|
572
696
|
});
|
|
@@ -574,8 +698,9 @@ describe("EventAction Func Selector", () => {
|
|
|
574
698
|
test("validates GREATER_THAN criteria for numeric values", async () => {
|
|
575
699
|
const action = await loadFixture(cloneFunctionAction20(fixtures, erc20));
|
|
576
700
|
const actionSteps = await action.getActionSteps();
|
|
701
|
+
const actionStep = actionSteps[0]!;
|
|
577
702
|
|
|
578
|
-
|
|
703
|
+
actionStep.actionParameter = {
|
|
579
704
|
filterType: FilterType.GREATER_THAN,
|
|
580
705
|
fieldType: PrimitiveType.UINT,
|
|
581
706
|
fieldIndex: 1,
|
|
@@ -587,8 +712,9 @@ describe("EventAction Func Selector", () => {
|
|
|
587
712
|
const { hash } = await erc20.mintRaw(address, value);
|
|
588
713
|
|
|
589
714
|
expect(
|
|
590
|
-
await action.
|
|
715
|
+
await action.isActionStepValid(actionStep, {
|
|
591
716
|
hash,
|
|
717
|
+
chainId,
|
|
592
718
|
}),
|
|
593
719
|
).toBe(true);
|
|
594
720
|
});
|
|
@@ -596,7 +722,8 @@ describe("EventAction Func Selector", () => {
|
|
|
596
722
|
test("validates LESS_THAN criteria for numeric values", async () => {
|
|
597
723
|
const action = await loadFixture(cloneFunctionAction20(fixtures, erc20));
|
|
598
724
|
const actionSteps = await action.getActionSteps();
|
|
599
|
-
actionSteps[0]
|
|
725
|
+
const actionStep = actionSteps[0]!;
|
|
726
|
+
actionStep.actionParameter = {
|
|
600
727
|
filterType: FilterType.LESS_THAN,
|
|
601
728
|
fieldType: PrimitiveType.UINT,
|
|
602
729
|
fieldIndex: 1,
|
|
@@ -608,8 +735,9 @@ describe("EventAction Func Selector", () => {
|
|
|
608
735
|
const { hash } = await erc20.mintRaw(address, value);
|
|
609
736
|
|
|
610
737
|
expect(
|
|
611
|
-
await action.
|
|
738
|
+
await action.isActionStepValid(actionStep, {
|
|
612
739
|
hash,
|
|
740
|
+
chainId,
|
|
613
741
|
}),
|
|
614
742
|
).toBe(true);
|
|
615
743
|
});
|
|
@@ -624,6 +752,7 @@ describe("EventAction Func Selector", () => {
|
|
|
624
752
|
expect(
|
|
625
753
|
await action.validateActionSteps({
|
|
626
754
|
hash,
|
|
755
|
+
chainId,
|
|
627
756
|
}),
|
|
628
757
|
).toBe(true);
|
|
629
758
|
});
|