@boostxyz/sdk 0.0.0-alpha.5 → 0.0.0-alpha.7

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.
Files changed (165) hide show
  1. package/dist/Actions/Action.cjs +1 -0
  2. package/dist/Actions/Action.cjs.map +1 -0
  3. package/dist/Actions/Action.js +1 -0
  4. package/dist/Actions/Action.js.map +1 -0
  5. package/dist/Actions/EventAction.cjs +2 -1
  6. package/dist/Actions/EventAction.cjs.map +1 -0
  7. package/dist/Actions/EventAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.js +39 -40
  9. package/dist/Actions/EventAction.js.map +1 -0
  10. package/dist/AllowLists/AllowList.cjs +1 -0
  11. package/dist/AllowLists/AllowList.cjs.map +1 -0
  12. package/dist/AllowLists/AllowList.js +1 -0
  13. package/dist/AllowLists/AllowList.js.map +1 -0
  14. package/dist/AllowLists/SimpleAllowList.cjs +1 -0
  15. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  16. package/dist/AllowLists/SimpleAllowList.js +1 -0
  17. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  18. package/dist/AllowLists/SimpleDenyList.cjs +1 -0
  19. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  20. package/dist/AllowLists/SimpleDenyList.js +1 -0
  21. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  22. package/dist/Auth/Auth.cjs +1 -0
  23. package/dist/Auth/Auth.cjs.map +1 -0
  24. package/dist/Auth/Auth.js +1 -0
  25. package/dist/Auth/Auth.js.map +1 -0
  26. package/dist/Auth/PassthroughAuth.cjs +1 -0
  27. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  28. package/dist/Auth/PassthroughAuth.js +1 -0
  29. package/dist/Auth/PassthroughAuth.js.map +1 -0
  30. package/dist/Boost.cjs +1 -0
  31. package/dist/Boost.cjs.map +1 -0
  32. package/dist/Boost.js +1 -0
  33. package/dist/Boost.js.map +1 -0
  34. package/dist/BoostCore.cjs +1 -0
  35. package/dist/BoostCore.cjs.map +1 -0
  36. package/dist/BoostCore.js +1 -0
  37. package/dist/BoostCore.js.map +1 -0
  38. package/dist/BoostRegistry.cjs +1 -0
  39. package/dist/BoostRegistry.cjs.map +1 -0
  40. package/dist/BoostRegistry.js +1 -0
  41. package/dist/BoostRegistry.js.map +1 -0
  42. package/dist/Budgets/Budget.cjs +1 -0
  43. package/dist/Budgets/Budget.cjs.map +1 -0
  44. package/dist/Budgets/Budget.js +1 -0
  45. package/dist/Budgets/Budget.js.map +1 -0
  46. package/dist/Budgets/ManagedBudget.cjs +1 -0
  47. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  48. package/dist/Budgets/ManagedBudget.js +1 -0
  49. package/dist/Budgets/ManagedBudget.js.map +1 -0
  50. package/dist/Deployable/Contract.cjs +1 -0
  51. package/dist/Deployable/Contract.cjs.map +1 -0
  52. package/dist/Deployable/Contract.js +1 -0
  53. package/dist/Deployable/Contract.js.map +1 -0
  54. package/dist/Deployable/Deployable.cjs +1 -0
  55. package/dist/Deployable/Deployable.cjs.map +1 -0
  56. package/dist/Deployable/Deployable.js +1 -0
  57. package/dist/Deployable/Deployable.js.map +1 -0
  58. package/dist/Deployable/DeployableTarget.cjs +1 -0
  59. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  60. package/dist/Deployable/DeployableTarget.js +1 -0
  61. package/dist/Deployable/DeployableTarget.js.map +1 -0
  62. package/dist/Incentives/AllowListIncentive.cjs +1 -0
  63. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  64. package/dist/Incentives/AllowListIncentive.js +1 -0
  65. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  66. package/dist/Incentives/CGDAIncentive.cjs +1 -0
  67. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  68. package/dist/Incentives/CGDAIncentive.js +1 -0
  69. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  70. package/dist/Incentives/ERC20Incentive.cjs +1 -0
  71. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  72. package/dist/Incentives/ERC20Incentive.js +1 -0
  73. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  74. package/dist/Incentives/Incentive.cjs +1 -0
  75. package/dist/Incentives/Incentive.cjs.map +1 -0
  76. package/dist/Incentives/Incentive.js +1 -0
  77. package/dist/Incentives/Incentive.js.map +1 -0
  78. package/dist/Incentives/PointsIncentive.cjs +1 -0
  79. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  80. package/dist/Incentives/PointsIncentive.js +1 -0
  81. package/dist/Incentives/PointsIncentive.js.map +1 -0
  82. package/dist/Validators/SignerValidator.cjs +1 -0
  83. package/dist/Validators/SignerValidator.cjs.map +1 -0
  84. package/dist/Validators/SignerValidator.js +1 -0
  85. package/dist/Validators/SignerValidator.js.map +1 -0
  86. package/dist/Validators/Validator.cjs +1 -0
  87. package/dist/Validators/Validator.cjs.map +1 -0
  88. package/dist/Validators/Validator.js +1 -0
  89. package/dist/Validators/Validator.js.map +1 -0
  90. package/dist/componentInterfaces-CKCBwG16.cjs +1 -0
  91. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  92. package/dist/componentInterfaces-DYkaxBda.js +1 -0
  93. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  94. package/dist/errors.cjs +1 -0
  95. package/dist/errors.cjs.map +1 -0
  96. package/dist/errors.js +1 -0
  97. package/dist/errors.js.map +1 -0
  98. package/dist/generated-Cd-Fe7W7.cjs +1 -0
  99. package/dist/generated-Cd-Fe7W7.cjs.map +1 -0
  100. package/dist/generated-DGpIVcv5.js +1 -0
  101. package/dist/generated-DGpIVcv5.js.map +1 -0
  102. package/dist/index.cjs +1 -0
  103. package/dist/index.cjs.map +1 -0
  104. package/dist/index.js +1 -0
  105. package/dist/index.js.map +1 -0
  106. package/dist/utils.cjs +1 -0
  107. package/dist/utils.cjs.map +1 -0
  108. package/dist/utils.js +1 -0
  109. package/dist/utils.js.map +1 -0
  110. package/package.json +3 -2
  111. package/src/Actions/Action.test.ts +77 -0
  112. package/src/Actions/Action.ts +61 -0
  113. package/src/Actions/ContractAction.test.ts +199 -0
  114. package/src/Actions/ContractAction.ts +238 -0
  115. package/src/Actions/ERC721MintAction.test.ts +112 -0
  116. package/src/Actions/ERC721MintAction.ts +238 -0
  117. package/src/Actions/EventAction.test.ts +182 -0
  118. package/src/Actions/EventAction.ts +380 -0
  119. package/src/AllowLists/AllowList.test.ts +64 -0
  120. package/src/AllowLists/AllowList.ts +60 -0
  121. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  122. package/src/AllowLists/SimpleAllowList.ts +240 -0
  123. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  124. package/src/AllowLists/SimpleDenyList.ts +289 -0
  125. package/src/Auth/Auth.ts +11 -0
  126. package/src/Auth/PassthroughAuth.test.ts +12 -0
  127. package/src/Auth/PassthroughAuth.ts +80 -0
  128. package/src/Boost.ts +155 -0
  129. package/src/BoostCore.test.ts +846 -0
  130. package/src/BoostCore.ts +1192 -0
  131. package/src/BoostRegistry.ts +449 -0
  132. package/src/Budgets/Budget.test.ts +27 -0
  133. package/src/Budgets/Budget.ts +61 -0
  134. package/src/Budgets/ManagedBudget.test.ts +154 -0
  135. package/src/Budgets/ManagedBudget.ts +743 -0
  136. package/src/Budgets/SimpleBudget.test.ts +152 -0
  137. package/src/Budgets/SimpleBudget.ts +521 -0
  138. package/src/Budgets/VestingBudget.test.ts +123 -0
  139. package/src/Budgets/VestingBudget.ts +532 -0
  140. package/src/Deployable/Contract.ts +229 -0
  141. package/src/Deployable/Deployable.ts +244 -0
  142. package/src/Deployable/DeployableTarget.ts +210 -0
  143. package/src/Incentives/AllowListIncentive.test.ts +146 -0
  144. package/src/Incentives/AllowListIncentive.ts +290 -0
  145. package/src/Incentives/CGDAIncentive.test.ts +136 -0
  146. package/src/Incentives/CGDAIncentive.ts +364 -0
  147. package/src/Incentives/ERC1155Incentive.test.ts +98 -0
  148. package/src/Incentives/ERC1155Incentive.ts +384 -0
  149. package/src/Incentives/ERC20Incentive.test.ts +141 -0
  150. package/src/Incentives/ERC20Incentive.ts +417 -0
  151. package/src/Incentives/ERC20VariableIncentive.test.ts +156 -0
  152. package/src/Incentives/ERC20VariableIncentive.ts +368 -0
  153. package/src/Incentives/Incentive.test.ts +92 -0
  154. package/src/Incentives/Incentive.ts +85 -0
  155. package/src/Incentives/PointsIncentive.test.ts +142 -0
  156. package/src/Incentives/PointsIncentive.ts +303 -0
  157. package/src/Validators/SignerValidator.test.ts +163 -0
  158. package/src/Validators/SignerValidator.ts +272 -0
  159. package/src/Validators/Validator.test.ts +21 -0
  160. package/src/Validators/Validator.ts +55 -0
  161. package/src/errors.ts +524 -0
  162. package/src/index.test.ts +40 -0
  163. package/src/index.ts +50 -0
  164. package/src/utils.test.ts +44 -0
  165. package/src/utils.ts +2247 -0
@@ -0,0 +1,238 @@
1
+ import {
2
+ erc721MintActionAbi,
3
+ readErc721MintActionPrepare,
4
+ readErc721MintActionValidated,
5
+ simulateErc721MintActionExecute,
6
+ simulateErc721MintActionValidate,
7
+ writeErc721MintActionExecute,
8
+ writeErc721MintActionValidate,
9
+ } from '@boostxyz/evm';
10
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/ERC721MintAction.sol/ERC721MintAction.json';
11
+ import type { Address, ContractEventName, Hex } from 'viem';
12
+ import type {
13
+ DeployableOptions,
14
+ GenericDeployableParams,
15
+ } from '../Deployable/Deployable';
16
+ import {
17
+ type ERC721MintActionPayload,
18
+ type GenericLog,
19
+ type ReadParams,
20
+ RegistryType,
21
+ type WriteParams,
22
+ prepareERC721MintActionPayload,
23
+ prepareERC721MintActionValidate,
24
+ } from '../utils';
25
+ import { ContractAction } from './ContractAction';
26
+
27
+ export { erc721MintActionAbi, prepareERC721MintActionPayload };
28
+ export type { ERC721MintActionPayload };
29
+
30
+ /**
31
+ * A generic `viem.Log` event with support for `ERC721MintAction` event types.
32
+ *
33
+ * @export
34
+ * @typedef {ERC721MintActionLog}
35
+ * @template {ContractEventName<
36
+ * typeof erc721MintActionAbi
37
+ * >} [event=ContractEventName<typeof erc721MintActionAbi>]
38
+ */
39
+ export type ERC721MintActionLog<
40
+ event extends ContractEventName<
41
+ typeof erc721MintActionAbi
42
+ > = ContractEventName<typeof erc721MintActionAbi>,
43
+ > = GenericLog<typeof erc721MintActionAbi, event>;
44
+
45
+ /**
46
+ * A primitive action to mint and/or validate that an ERC721 token has been minted
47
+ * The action is expected to be prepared with the data payload for the minting of the token
48
+ * This a minimal generic implementation that should be extended if additional functionality or customizations are required
49
+ * It is expected that the target contract has an externally accessible mint function whose selector
50
+ *
51
+ * @export
52
+ * @class ERC721MintAction
53
+ * @typedef {ERC721MintAction}
54
+ * @extends {ContractAction}
55
+ */
56
+ export class ERC721MintAction extends ContractAction<
57
+ typeof erc721MintActionAbi
58
+ > {
59
+ //@ts-expect-error should never be constructed with variant typ
60
+ public override readonly abi = erc721MintActionAbi;
61
+
62
+ /**
63
+ * @inheritdoc
64
+ *
65
+ * @public
66
+ * @static
67
+ * @type {Address}
68
+ */
69
+ public static override base: Address = import.meta.env
70
+ .VITE_ERC721_MINT_ACTION_BASE;
71
+ /**
72
+ * @inheritdoc
73
+ *
74
+ * @public
75
+ * @static
76
+ * @type {RegistryType}
77
+ */
78
+ public static override registryType: RegistryType = RegistryType.ACTION;
79
+
80
+ /**
81
+ * The set of validated tokens
82
+ * This is intended to prevent multiple validations against the same token ID
83
+ *
84
+ * @public
85
+ * @async
86
+ * @param {bigint} token
87
+ * @param {?ReadParams<typeof erc721MintActionAbi, 'validated'>} [params]
88
+ * @returns {unknown}
89
+ */
90
+ public async validated(
91
+ token: bigint,
92
+ params?: ReadParams<typeof erc721MintActionAbi, 'validated'>,
93
+ ) {
94
+ return readErc721MintActionValidated(this._config, {
95
+ address: this.assertValidAddress(),
96
+ ...this.optionallyAttachAccount(),
97
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
98
+ ...(params as any),
99
+ args: [token],
100
+ });
101
+ }
102
+
103
+ /**
104
+ * @inheritdoc
105
+ *
106
+ * @public
107
+ * @async
108
+ * @param {Hex} data
109
+ * @param {?WriteParams<typeof erc721MintActionAbi, 'execute'>} [params]
110
+ * @returns {unknown}
111
+ */
112
+ public override async execute(
113
+ data: Hex,
114
+ params?: WriteParams<typeof erc721MintActionAbi, 'execute'>,
115
+ ) {
116
+ return this.awaitResult(this.executeRaw(data, params));
117
+ }
118
+
119
+ /**
120
+ * @inheritdoc
121
+ *
122
+ * @public
123
+ * @async
124
+ * @param {Hex} data
125
+ * @param {?WriteParams<typeof erc721MintActionAbi, 'execute'>} [params]
126
+ * @returns {unknown}
127
+ */
128
+ public override async executeRaw(
129
+ data: Hex,
130
+ params?: WriteParams<typeof erc721MintActionAbi, 'execute'>,
131
+ ) {
132
+ const { request, result } = await simulateErc721MintActionExecute(
133
+ this._config,
134
+ {
135
+ address: this.assertValidAddress(),
136
+ args: [data],
137
+ ...this.optionallyAttachAccount(),
138
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
139
+ ...(params as any),
140
+ },
141
+ );
142
+ const hash = await writeErc721MintActionExecute(this._config, request);
143
+ return { hash, result };
144
+ }
145
+
146
+ /**
147
+ * @inheritdoc
148
+ *
149
+ * @public
150
+ * @async
151
+ * @param {Hex} data
152
+ * @param {?ReadParams<typeof erc721MintActionAbi, 'prepare'>} [params]
153
+ * @returns {unknown}
154
+ */
155
+ public override async prepare(
156
+ data: Hex,
157
+ params?: ReadParams<typeof erc721MintActionAbi, 'prepare'>,
158
+ ) {
159
+ return readErc721MintActionPrepare(this._config, {
160
+ address: this.assertValidAddress(),
161
+ args: [data],
162
+ ...this.optionallyAttachAccount(),
163
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
164
+ ...(params as any),
165
+ });
166
+ }
167
+
168
+ /**
169
+ * Validate that the action has been completed successfully
170
+ *
171
+ * @public
172
+ * @async
173
+ * @param {Address} holder - The holder
174
+ * @param {BigInt} tokenId - The token ID
175
+ * @param {?WriteParams<typeof erc721MintActionAbi, 'validate'>} [params]
176
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the action has been validated for the user
177
+ */
178
+ public async validate(
179
+ holder: Address,
180
+ tokenId: bigint,
181
+ params?: WriteParams<typeof erc721MintActionAbi, 'validate'>,
182
+ ) {
183
+ return this.awaitResult(this.validateRaw(holder, tokenId, params));
184
+ }
185
+
186
+ /**
187
+ * Validate that the action has been completed successfully
188
+ *
189
+ * @public
190
+ * @async
191
+ * @param {Address} holder - The holder
192
+ * @param {BigInt} tokenId - The token ID
193
+ * @param {?WriteParams<typeof erc721MintActionAbi, 'validate'>} [params]
194
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the action has been validated for the user
195
+ */
196
+ public async validateRaw(
197
+ holder: Address,
198
+ tokenId: bigint,
199
+ params?: WriteParams<typeof erc721MintActionAbi, 'validate'>,
200
+ ) {
201
+ const { request, result } = await simulateErc721MintActionValidate(
202
+ this._config,
203
+ {
204
+ address: this.assertValidAddress(),
205
+ args: [prepareERC721MintActionValidate(holder, tokenId)],
206
+ ...this.optionallyAttachAccount(),
207
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
208
+ ...(params as any),
209
+ },
210
+ );
211
+ const hash = await writeErc721MintActionValidate(this._config, request);
212
+ return { hash, result };
213
+ }
214
+
215
+ /**
216
+ * @inheritdoc
217
+ *
218
+ * @public
219
+ * @param {?ERC721MintActionPayload} [_payload]
220
+ * @param {?DeployableOptions} [_options]
221
+ * @returns {GenericDeployableParams}
222
+ */
223
+ public override buildParameters(
224
+ _payload?: ERC721MintActionPayload,
225
+ _options?: DeployableOptions,
226
+ ): GenericDeployableParams {
227
+ const [payload, options] = this.validateDeploymentConfig(
228
+ _payload,
229
+ _options,
230
+ );
231
+ return {
232
+ abi: erc721MintActionAbi,
233
+ bytecode: bytecode as Hex,
234
+ args: [prepareERC721MintActionPayload(payload)],
235
+ ...this.optionallyAttachAccount(options.account),
236
+ };
237
+ }
238
+ }
@@ -0,0 +1,182 @@
1
+ import {
2
+ readAActionGetComponentInterface,
3
+ readEventActionGetComponentInterface,
4
+ } from '@boostxyz/evm';
5
+ import { selectors } from '@boostxyz/signatures/events';
6
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
7
+ import { type Hex, type Log, isAddress } from 'viem';
8
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
9
+ import type { MockERC721 } from '../../test/MockERC721';
10
+ import { accounts } from '../../test/accounts';
11
+ import {
12
+ type Fixtures,
13
+ defaultOptions,
14
+ deployFixtures,
15
+ fundErc721,
16
+ } from '../../test/helpers';
17
+ import {
18
+ type EventActionPayloadSimple,
19
+ FilterType,
20
+ PrimitiveType,
21
+ SignatureType,
22
+ } from '../utils';
23
+ import { EventAction } from './EventAction';
24
+
25
+ let fixtures: Fixtures, erc721: MockERC721;
26
+
27
+ beforeAll(async () => {
28
+ fixtures = await loadFixture(deployFixtures);
29
+ });
30
+
31
+ function basicErc721TransferAction(
32
+ erc721: MockERC721,
33
+ ): EventActionPayloadSimple {
34
+ return {
35
+ actionClaimant: {
36
+ signatureType: SignatureType.EVENT,
37
+ signature: selectors['Transfer(address,address,uint256)'] as Hex,
38
+ fieldIndex: 2,
39
+ targetContract: erc721.assertValidAddress(),
40
+ },
41
+ actionSteps: [
42
+ {
43
+ signature: selectors['Transfer(address,address,uint256)'] as Hex,
44
+ signatureType: SignatureType.EVENT,
45
+ actionType: 0,
46
+ targetContract: erc721.assertValidAddress(),
47
+ actionParameter: {
48
+ filterType: FilterType.EQUAL,
49
+ fieldType: PrimitiveType.ADDRESS,
50
+ fieldIndex: 2,
51
+ filterData: accounts.at(1)!.account,
52
+ },
53
+ },
54
+ ],
55
+ };
56
+ }
57
+
58
+ function cloneEventAction(fixtures: Fixtures, erc721: MockERC721) {
59
+ return function cloneEventAction() {
60
+ return fixtures.registry.clone(
61
+ crypto.randomUUID(),
62
+ new fixtures.bases.EventAction(
63
+ defaultOptions,
64
+ basicErc721TransferAction(erc721),
65
+ ),
66
+ );
67
+ };
68
+ }
69
+
70
+ describe('EventAction', () => {
71
+ beforeEach(async () => {
72
+ erc721 = await loadFixture(fundErc721(defaultOptions));
73
+ });
74
+
75
+ test('can successfully be deployed', async () => {
76
+ const action = new EventAction(
77
+ defaultOptions,
78
+ basicErc721TransferAction(erc721),
79
+ );
80
+ await action.deploy();
81
+ expect(isAddress(action.assertValidAddress())).toBe(true);
82
+ });
83
+
84
+ test('can get an action step', async () => {
85
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
86
+ const step = await action.getActionStep(0);
87
+ if (!step) throw new Error('there should be an action step at this index');
88
+ step.targetContract = step.targetContract.toUpperCase() as Hex;
89
+ step.actionParameter.filterData =
90
+ step.actionParameter.filterData.toUpperCase() as Hex;
91
+ expect(step).toMatchObject({
92
+ signature: selectors['Transfer(address,address,uint256)'] as Hex,
93
+ signatureType: SignatureType.EVENT,
94
+ actionType: 0,
95
+ targetContract: erc721.assertValidAddress().toUpperCase(),
96
+ actionParameter: {
97
+ filterType: FilterType.EQUAL,
98
+ fieldType: PrimitiveType.ADDRESS,
99
+ fieldIndex: 2,
100
+ filterData: accounts.at(1)!.account.toUpperCase(),
101
+ },
102
+ });
103
+ });
104
+
105
+ test('can get all action steps', async () => {
106
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
107
+ const steps = await action.getActionSteps();
108
+ expect(steps.length).toBe(1);
109
+ const step = steps.at(0)!;
110
+ step.targetContract = step.targetContract.toUpperCase() as Hex;
111
+ step.actionParameter.filterData =
112
+ step.actionParameter.filterData.toUpperCase() as Hex;
113
+ expect(step).toMatchObject({
114
+ signature: selectors['Transfer(address,address,uint256)'] as Hex,
115
+ signatureType: SignatureType.EVENT,
116
+ actionType: 0,
117
+ targetContract: erc721.assertValidAddress().toUpperCase(),
118
+ actionParameter: {
119
+ filterType: FilterType.EQUAL,
120
+ fieldType: PrimitiveType.ADDRESS,
121
+ fieldIndex: 2,
122
+ filterData: accounts.at(1)!.account.toUpperCase(),
123
+ },
124
+ });
125
+ });
126
+
127
+ test('can get the total number of action steps', async () => {
128
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
129
+ const count = await action.getActionStepsCount();
130
+ expect(count).toBe(1);
131
+ });
132
+
133
+ test('can get the action claimant', async () => {
134
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
135
+ const claimant = await action.getActionClaimant();
136
+ claimant.targetContract = claimant.targetContract.toUpperCase() as Hex;
137
+ expect(claimant).toMatchObject({
138
+ signatureType: SignatureType.EVENT,
139
+ signature: selectors['Transfer(address,address,uint256)'] as Hex,
140
+ fieldIndex: 2,
141
+ targetContract: erc721.assertValidAddress().toUpperCase(),
142
+ });
143
+ });
144
+
145
+ test('with no logs, does not validate', async () => {
146
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
147
+ expect(await action.validateActionSteps()).toBe(false);
148
+ });
149
+
150
+ test('with a correct log, validates', async () => {
151
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
152
+ const recipient = accounts.at(1)!.account;
153
+ await erc721.approve(recipient, 1n);
154
+ await erc721.transferFrom(defaultOptions.account.address, recipient, 1n);
155
+ expect(await action.validateActionSteps()).toBe(true);
156
+ });
157
+
158
+ test('can supply your own logs to validate against', async () => {
159
+ const log = {
160
+ eventName: 'Transfer',
161
+ args: undefined,
162
+ address: erc721.assertValidAddress(),
163
+ blockHash:
164
+ '0xbf602f988260519805d032be46d6ff97fbefbee6924b21097074d6d0bc34eced',
165
+ blockNumber: 1203n,
166
+ data: '0x',
167
+ logIndex: 0,
168
+ removed: false,
169
+ topics: [
170
+ '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
171
+ '0x000000000000000000000000f39fd6e51aad88f6f4ce6ab8827279cfffb92266',
172
+ '0x00000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c8',
173
+ '0x0000000000000000000000000000000000000000000000000000000000000001',
174
+ ],
175
+ transactionHash:
176
+ '0xff0e6ab0c4961ec14b7b40afec83ed7d7a77582683512a262e641d21f82efea5',
177
+ transactionIndex: 0,
178
+ } as Log;
179
+ const action = await loadFixture(cloneEventAction(fixtures, erc721));
180
+ expect(await action.validateActionSteps({ logs: [log] })).toBe(true);
181
+ });
182
+ });