@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.21

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 (271) hide show
  1. package/dist/Actions/Action.cjs +2 -1
  2. package/dist/Actions/Action.cjs.map +1 -0
  3. package/dist/Actions/Action.d.ts +1 -1
  4. package/dist/Actions/Action.d.ts.map +1 -1
  5. package/dist/Actions/Action.js +14 -12
  6. package/dist/Actions/Action.js.map +1 -0
  7. package/dist/Actions/ContractAction.d.ts +57 -14
  8. package/dist/Actions/ContractAction.d.ts.map +1 -1
  9. package/dist/Actions/ERC721MintAction.d.ts +50 -23
  10. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  11. package/dist/Actions/EventAction.cjs +2 -1
  12. package/dist/Actions/EventAction.cjs.map +1 -0
  13. package/dist/Actions/EventAction.d.ts +405 -36
  14. package/dist/Actions/EventAction.d.ts.map +1 -1
  15. package/dist/Actions/EventAction.js +15 -209
  16. package/dist/Actions/EventAction.js.map +1 -0
  17. package/dist/AllowLists/AllowList.cjs +2 -1
  18. package/dist/AllowLists/AllowList.cjs.map +1 -0
  19. package/dist/AllowLists/AllowList.d.ts +6 -5
  20. package/dist/AllowLists/AllowList.d.ts.map +1 -1
  21. package/dist/AllowLists/AllowList.js +46 -22
  22. package/dist/AllowLists/AllowList.js.map +1 -0
  23. package/dist/AllowLists/OpenAllowList.d.ts +423 -0
  24. package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -1
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  29. package/dist/AllowLists/SimpleAllowList.js +76 -76
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -1
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  35. package/dist/AllowLists/SimpleDenyList.js +12 -200
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +1 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.js +1 -0
  40. package/dist/Auth/Auth.js.map +1 -0
  41. package/dist/Auth/PassthroughAuth.cjs +2 -1
  42. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  43. package/dist/Auth/PassthroughAuth.js +5 -4
  44. package/dist/Auth/PassthroughAuth.js.map +1 -0
  45. package/dist/Boost.cjs +2 -1
  46. package/dist/Boost.cjs.map +1 -0
  47. package/dist/Boost.d.ts +105 -14
  48. package/dist/Boost.d.ts.map +1 -1
  49. package/dist/Boost.js +138 -5
  50. package/dist/Boost.js.map +1 -0
  51. package/dist/BoostCore-DolmDuXW.cjs +3 -0
  52. package/dist/BoostCore-DolmDuXW.cjs.map +1 -0
  53. package/dist/BoostCore-Z97KVu4V.js +1448 -0
  54. package/dist/BoostCore-Z97KVu4V.js.map +1 -0
  55. package/dist/BoostCore.cjs +2 -2
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +788 -79
  58. package/dist/BoostCore.d.ts.map +1 -1
  59. package/dist/BoostCore.js +30 -1103
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -1
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +95 -26
  64. package/dist/BoostRegistry.d.ts.map +1 -1
  65. package/dist/BoostRegistry.js +183 -89
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -1
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +1 -1
  70. package/dist/Budgets/Budget.d.ts.map +1 -1
  71. package/dist/Budgets/Budget.js +15 -13
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -1
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +112 -192
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  77. package/dist/Budgets/ManagedBudget.js +91 -291
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/VestingBudget.d.ts +277 -91
  80. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  81. package/dist/Deployable/Contract.cjs +2 -1
  82. package/dist/Deployable/Contract.cjs.map +1 -0
  83. package/dist/Deployable/Contract.d.ts +4 -5
  84. package/dist/Deployable/Contract.d.ts.map +1 -1
  85. package/dist/Deployable/Contract.js +7 -8
  86. package/dist/Deployable/Contract.js.map +1 -0
  87. package/dist/Deployable/Deployable.cjs +1 -0
  88. package/dist/Deployable/Deployable.cjs.map +1 -0
  89. package/dist/Deployable/Deployable.d.ts +9 -3
  90. package/dist/Deployable/Deployable.d.ts.map +1 -1
  91. package/dist/Deployable/Deployable.js +10 -5
  92. package/dist/Deployable/Deployable.js.map +1 -0
  93. package/dist/Deployable/DeployableTarget.cjs +2 -1
  94. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  95. package/dist/Deployable/DeployableTarget.d.ts +16 -15
  96. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  97. package/dist/Deployable/DeployableTarget.js +49 -42
  98. package/dist/Deployable/DeployableTarget.js.map +1 -0
  99. package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
  100. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
  101. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
  102. package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
  103. package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
  104. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
  105. package/dist/EventAction-CBKzuNoN.cjs +2 -0
  106. package/dist/EventAction-CBKzuNoN.cjs.map +1 -0
  107. package/dist/EventAction-DWuuc_Qy.js +1528 -0
  108. package/dist/EventAction-DWuuc_Qy.js.map +1 -0
  109. package/dist/Incentive-BxzEtN26.js +298 -0
  110. package/dist/Incentive-BxzEtN26.js.map +1 -0
  111. package/dist/Incentive-CrF3-ayL.cjs +2 -0
  112. package/dist/Incentive-CrF3-ayL.cjs.map +1 -0
  113. package/dist/Incentives/AllowListIncentive.cjs +2 -1
  114. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  115. package/dist/Incentives/AllowListIncentive.d.ts +65 -21
  116. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  117. package/dist/Incentives/AllowListIncentive.js +52 -36
  118. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  119. package/dist/Incentives/CGDAIncentive.cjs +2 -1
  120. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  121. package/dist/Incentives/CGDAIncentive.d.ts +315 -26
  122. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  123. package/dist/Incentives/CGDAIncentive.js +64 -39
  124. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  125. package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
  126. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  127. package/dist/Incentives/ERC20Incentive.cjs +2 -1
  128. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  129. package/dist/Incentives/ERC20Incentive.d.ts +270 -33
  130. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  131. package/dist/Incentives/ERC20Incentive.js +69 -46
  132. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  133. package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +338 -421
  134. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  135. package/dist/Incentives/ERC20VariableIncentive.d.ts +262 -32
  136. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  137. package/dist/Incentives/Incentive.cjs +2 -1
  138. package/dist/Incentives/Incentive.cjs.map +1 -0
  139. package/dist/Incentives/Incentive.d.ts +5 -8
  140. package/dist/Incentives/Incentive.d.ts.map +1 -1
  141. package/dist/Incentives/Incentive.js +17 -278
  142. package/dist/Incentives/Incentive.js.map +1 -0
  143. package/dist/Incentives/PointsIncentive.cjs +2 -1
  144. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  145. package/dist/Incentives/PointsIncentive.d.ts +81 -23
  146. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  147. package/dist/Incentives/PointsIncentive.js +57 -36
  148. package/dist/Incentives/PointsIncentive.js.map +1 -0
  149. package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
  150. package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
  151. package/dist/SimpleDenyList-CGaWjuld.js +132 -0
  152. package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
  153. package/dist/Validators/SignerValidator.cjs +2 -1
  154. package/dist/Validators/SignerValidator.cjs.map +1 -0
  155. package/dist/Validators/SignerValidator.d.ts +310 -17
  156. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  157. package/dist/Validators/SignerValidator.js +165 -36
  158. package/dist/Validators/SignerValidator.js.map +1 -0
  159. package/dist/Validators/Validator.cjs +2 -1
  160. package/dist/Validators/Validator.cjs.map +1 -0
  161. package/dist/Validators/Validator.d.ts +2 -2
  162. package/dist/Validators/Validator.d.ts.map +1 -1
  163. package/dist/Validators/Validator.js +10 -8
  164. package/dist/Validators/Validator.js.map +1 -0
  165. package/dist/claiming.cjs +2 -0
  166. package/dist/claiming.cjs.map +1 -0
  167. package/dist/claiming.d.ts +43 -0
  168. package/dist/claiming.d.ts.map +1 -0
  169. package/dist/claiming.js +17 -0
  170. package/dist/claiming.js.map +1 -0
  171. package/dist/componentInterfaces-BBCFkrZv.js +14 -0
  172. package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
  173. package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
  174. package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
  175. package/dist/deployments-DVXioW2i.cjs +2 -0
  176. package/dist/deployments-DVXioW2i.cjs.map +1 -0
  177. package/dist/deployments-oykLv3_Z.js +43 -0
  178. package/dist/deployments-oykLv3_Z.js.map +1 -0
  179. package/dist/deployments.json +44 -0
  180. package/dist/errors.cjs +2 -1
  181. package/dist/errors.cjs.map +1 -0
  182. package/dist/errors.d.ts +421 -1
  183. package/dist/errors.d.ts.map +1 -1
  184. package/dist/errors.js +297 -39
  185. package/dist/errors.js.map +1 -0
  186. package/dist/{generated-x_abr3Yv.js → generated-CKt2yCQd.js} +3143 -3002
  187. package/dist/generated-CKt2yCQd.js.map +1 -0
  188. package/dist/generated-CyTNlOwM.cjs +3 -0
  189. package/dist/generated-CyTNlOwM.cjs.map +1 -0
  190. package/dist/index.cjs +2 -1
  191. package/dist/index.cjs.map +1 -0
  192. package/dist/index.d.ts +10 -9
  193. package/dist/index.d.ts.map +1 -1
  194. package/dist/index.js +144 -1353
  195. package/dist/index.js.map +1 -0
  196. package/dist/transfers.cjs +2 -0
  197. package/dist/transfers.cjs.map +1 -0
  198. package/dist/transfers.d.ts +198 -0
  199. package/dist/transfers.d.ts.map +1 -0
  200. package/dist/transfers.js +84 -0
  201. package/dist/transfers.js.map +1 -0
  202. package/dist/utils.cjs +2 -1
  203. package/dist/utils.cjs.map +1 -0
  204. package/dist/utils.d.ts +26 -1350
  205. package/dist/utils.d.ts.map +1 -1
  206. package/dist/utils.js +38 -636
  207. package/dist/utils.js.map +1 -0
  208. package/package.json +37 -11
  209. package/src/Actions/Action.test.ts +79 -0
  210. package/src/Actions/Action.ts +61 -0
  211. package/src/Actions/ContractAction.test.ts +197 -0
  212. package/src/Actions/ContractAction.ts +300 -0
  213. package/src/Actions/ERC721MintAction.test.ts +112 -0
  214. package/src/Actions/ERC721MintAction.ts +291 -0
  215. package/src/Actions/EventAction.test.ts +787 -0
  216. package/src/Actions/EventAction.ts +1218 -0
  217. package/src/AllowLists/AllowList.test.ts +64 -0
  218. package/src/AllowLists/AllowList.ts +62 -0
  219. package/src/AllowLists/OpenAllowList.test.ts +40 -0
  220. package/src/AllowLists/OpenAllowList.ts +45 -0
  221. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  222. package/src/AllowLists/SimpleAllowList.ts +262 -0
  223. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  224. package/src/AllowLists/SimpleDenyList.ts +250 -0
  225. package/src/Auth/Auth.ts +11 -0
  226. package/src/Auth/PassthroughAuth.test.ts +12 -0
  227. package/src/Auth/PassthroughAuth.ts +80 -0
  228. package/src/Boost.ts +287 -0
  229. package/src/BoostCore.test.ts +894 -0
  230. package/src/BoostCore.ts +1438 -0
  231. package/src/BoostRegistry.test.ts +53 -0
  232. package/src/BoostRegistry.ts +588 -0
  233. package/src/Budgets/Budget.test.ts +27 -0
  234. package/src/Budgets/Budget.ts +60 -0
  235. package/src/Budgets/ManagedBudget.test.ts +217 -0
  236. package/src/Budgets/ManagedBudget.ts +534 -0
  237. package/src/Budgets/VestingBudget.test.ts +123 -0
  238. package/src/Budgets/VestingBudget.ts +530 -0
  239. package/src/Deployable/Contract.ts +228 -0
  240. package/src/Deployable/Deployable.ts +250 -0
  241. package/src/Deployable/DeployableTarget.ts +234 -0
  242. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  243. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  244. package/src/Incentives/AllowListIncentive.ts +336 -0
  245. package/src/Incentives/CGDAIncentive.test.ts +135 -0
  246. package/src/Incentives/CGDAIncentive.ts +476 -0
  247. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  248. package/src/Incentives/ERC1155Incentive.ts +465 -0
  249. package/src/Incentives/ERC20Incentive.test.ts +133 -0
  250. package/src/Incentives/ERC20Incentive.ts +490 -0
  251. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  252. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  253. package/src/Incentives/ERC20VariableIncentive.test.ts +139 -0
  254. package/src/Incentives/ERC20VariableIncentive.ts +428 -0
  255. package/src/Incentives/Incentive.test.ts +95 -0
  256. package/src/Incentives/Incentive.ts +86 -0
  257. package/src/Incentives/PointsIncentive.test.ts +138 -0
  258. package/src/Incentives/PointsIncentive.ts +367 -0
  259. package/src/Validators/SignerValidator.test.ts +159 -0
  260. package/src/Validators/SignerValidator.ts +683 -0
  261. package/src/Validators/Validator.test.ts +21 -0
  262. package/src/Validators/Validator.ts +55 -0
  263. package/src/claiming.ts +56 -0
  264. package/src/errors.ts +866 -0
  265. package/src/index.test.ts +122 -0
  266. package/src/index.ts +58 -0
  267. package/src/transfers.ts +284 -0
  268. package/src/utils.test.ts +44 -0
  269. package/src/utils.ts +247 -0
  270. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  271. package/dist/generated-BaaleHW-.cjs +0 -2
@@ -0,0 +1,300 @@
1
+ import {
2
+ contractActionAbi,
3
+ readContractActionChainId,
4
+ readContractActionPrepare,
5
+ readContractActionSelector,
6
+ readContractActionTarget,
7
+ readContractActionValue,
8
+ simulateContractActionExecute,
9
+ writeContractActionExecute,
10
+ } from '@boostxyz/evm';
11
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/ContractAction.sol/ContractAction.json';
12
+ import {
13
+ type Abi,
14
+ type Address,
15
+ type ContractEventName,
16
+ type Hex,
17
+ encodeAbiParameters,
18
+ parseAbiParameters,
19
+ } from 'viem';
20
+ import type {
21
+ DeployableOptions,
22
+ GenericDeployableParams,
23
+ } from '../Deployable/Deployable';
24
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
25
+ import {
26
+ type GenericLog,
27
+ type ReadParams,
28
+ RegistryType,
29
+ type WriteParams,
30
+ } from '../utils';
31
+
32
+ export { contractActionAbi };
33
+
34
+ /**
35
+ * The object representation of a `ContractAction.InitPayload`
36
+ *
37
+ * @export
38
+ * @interface ContractActionPayload
39
+ * @typedef {ContractActionPayload}
40
+ */
41
+ export interface ContractActionPayload {
42
+ /**
43
+ * The chain ID on which the target exists
44
+ *
45
+ * @type {bigint}
46
+ */
47
+ chainId: bigint;
48
+ /**
49
+ * The target contract address
50
+ *
51
+ * @type {Address}
52
+ */
53
+ target: Address;
54
+ /**
55
+ * The selector for the function to be called
56
+ *
57
+ * @type {Hex}
58
+ */
59
+ selector: Hex;
60
+ /**
61
+ * The native token value to send with the function call
62
+ *
63
+ * @type {bigint}
64
+ */
65
+ value: bigint;
66
+ }
67
+
68
+ /**
69
+ * A generic `viem.Log` event with support for `ContractAction` event types.
70
+ *
71
+ * @export
72
+ * @typedef {ContractActionLog}
73
+ * @template {ContractEventName<typeof contractActionAbi>} [event=ContractEventName<
74
+ * typeof contractActionAbi
75
+ * >]
76
+ */
77
+ export type ContractActionLog<
78
+ event extends ContractEventName<typeof contractActionAbi> = ContractEventName<
79
+ typeof contractActionAbi
80
+ >,
81
+ > = GenericLog<typeof contractActionAbi, event>;
82
+
83
+ /**
84
+ * A generic contract action
85
+ *
86
+ * @export
87
+ * @class ContractAction
88
+ * @typedef {ContractAction}
89
+ * @extends {DeployableTarget<ContractActionPayload>}
90
+ */
91
+ export class ContractAction<
92
+ ContractActionAbi extends Abi = typeof contractActionAbi,
93
+ > extends DeployableTarget<ContractActionPayload, ContractActionAbi> {
94
+ //@ts-expect-error should never be constructed with variant typ
95
+ public override readonly abi = contractActionAbi;
96
+
97
+ /**
98
+ * @inheritdoc
99
+ *
100
+ * @public
101
+ * @static
102
+ * @type {Record<number, Address>}
103
+ */
104
+ public static override bases: Record<number, Address> = {};
105
+ /**
106
+ * @inheritdoc
107
+ *
108
+ * @public
109
+ * @static
110
+ * @type {RegistryType}
111
+ */
112
+ public static override registryType: RegistryType = RegistryType.ACTION;
113
+
114
+ /**
115
+ * The target chain ID
116
+ *
117
+ * @public
118
+ * @async
119
+ * @param {?ReadParams} [params]
120
+ * @returns {Promise<bigint>}
121
+ */
122
+ public async chainId(
123
+ params?: ReadParams<typeof contractActionAbi, 'chainId'>,
124
+ ) {
125
+ return await readContractActionChainId(this._config, {
126
+ address: this.assertValidAddress(),
127
+ ...this.optionallyAttachAccount(),
128
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
129
+ ...(params as any),
130
+ });
131
+ }
132
+
133
+ /**
134
+ * The target contract
135
+ *
136
+ * @public
137
+ * @async
138
+ * @param {?ReadParams} [params]
139
+ * @returns {Promise<`0x${string}`>}
140
+ */
141
+ public async target(params?: ReadParams<typeof contractActionAbi, 'target'>) {
142
+ return await readContractActionTarget(this._config, {
143
+ address: this.assertValidAddress(),
144
+ ...this.optionallyAttachAccount(),
145
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
146
+ ...(params as any),
147
+ });
148
+ }
149
+
150
+ /**
151
+ * The selector for the function to be called
152
+ *
153
+ * @example `function mint(address to, uint256 amount)`
154
+ * @public
155
+ * @async
156
+ * @param {?ReadParams} [params]
157
+ * @returns {Promise<`0x${string}`>}
158
+ */
159
+ public async selector(
160
+ params?: ReadParams<typeof contractActionAbi, 'selector'>,
161
+ ) {
162
+ return await readContractActionSelector(this._config, {
163
+ address: this.assertValidAddress(),
164
+ ...this.optionallyAttachAccount(),
165
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
166
+ ...(params as any),
167
+ });
168
+ }
169
+
170
+ /**
171
+ * The native token value to send with the function call
172
+ *
173
+ * @public
174
+ * @async
175
+ * @param {?ReadParams} [params]
176
+ * @returns {Promise<bigint>}
177
+ */
178
+ public async value(params?: ReadParams<typeof contractActionAbi, 'value'>) {
179
+ return await readContractActionValue(this._config, {
180
+ address: this.assertValidAddress(),
181
+ ...this.optionallyAttachAccount(),
182
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
183
+ ...(params as any),
184
+ });
185
+ }
186
+
187
+ /**
188
+ * Executes a prepared contract action
189
+ *
190
+ * @public
191
+ * @async
192
+ * @param {Hex} data
193
+ * @param {?WriteParams} [params]
194
+ * @returns {Promise<readonly [boolean, `0x${string}`]>}
195
+ */
196
+ public async execute(
197
+ data: Hex,
198
+ params?: WriteParams<typeof contractActionAbi, 'execute'>,
199
+ ) {
200
+ return await this.awaitResult(this.executeRaw(data, params));
201
+ }
202
+
203
+ /**
204
+ * Executes a prepared contract action
205
+ *
206
+ * @public
207
+ * @async
208
+ * @param {Hex} data
209
+ * @param {?WriteParams} [params]
210
+ * @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
211
+ */
212
+ public async executeRaw(
213
+ data: Hex,
214
+ params?: WriteParams<typeof contractActionAbi, 'execute'>,
215
+ ) {
216
+ const { request, result } = await simulateContractActionExecute(
217
+ this._config,
218
+ {
219
+ address: this.assertValidAddress(),
220
+ ...this.optionallyAttachAccount(),
221
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
222
+ ...(params as any),
223
+ args: [data],
224
+ },
225
+ );
226
+ const hash = await writeContractActionExecute(this._config, request);
227
+ return { hash, result };
228
+ }
229
+
230
+ /**
231
+ * The encoded execution payload
232
+ *
233
+ * @public
234
+ * @async
235
+ * @param {Hex} calldata
236
+ * @param {?ReadParams} [params]
237
+ * @returns {Promise<`0x${string}`>}
238
+ */
239
+ public async prepare(
240
+ calldata: Hex,
241
+ params?: ReadParams<typeof contractActionAbi, 'prepare'>,
242
+ ) {
243
+ return await readContractActionPrepare(this._config, {
244
+ address: this.assertValidAddress(),
245
+ args: [calldata],
246
+ ...this.optionallyAttachAccount(),
247
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
248
+ ...(params as any),
249
+ });
250
+ }
251
+
252
+ /**
253
+ * @inheritdoc
254
+ *
255
+ * @public
256
+ * @param {?ContractActionPayload} [_payload]
257
+ * @param {?DeployableOptions} [_options]
258
+ * @returns {GenericDeployableParams}
259
+ */
260
+ public override buildParameters(
261
+ _payload?: ContractActionPayload,
262
+ _options?: DeployableOptions,
263
+ ): GenericDeployableParams {
264
+ const [payload, options] = this.validateDeploymentConfig(
265
+ _payload,
266
+ _options,
267
+ );
268
+ return {
269
+ abi: contractActionAbi,
270
+ bytecode: bytecode as Hex,
271
+ args: [prepareContractActionPayload(payload)],
272
+ ...this.optionallyAttachAccount(options.account),
273
+ };
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Given a {@link ContractActionPayload}, properly encode a `ContractAction.InitPayload` for use with {@link ContractAction} initialization.
279
+ *
280
+ * @param {ContractActionPayload} param0
281
+ * @param {bigint} param0.chainId - The chain ID on which the target exists
282
+ * @param {Address} param0.target - The target contract address
283
+ * @param {Hex} param0.selector - The selector for the function to be called
284
+ * @param {bigint} param0.value - The native token value to send with the function call
285
+ * @returns {Hex}
286
+ */
287
+ export function prepareContractActionPayload({
288
+ chainId,
289
+ target,
290
+ selector,
291
+ value,
292
+ }: ContractActionPayload) {
293
+ return encodeAbiParameters(
294
+ parseAbiParameters([
295
+ 'ContractActionPayload payload',
296
+ 'struct ContractActionPayload { uint256 chainId; address target; bytes4 selector; uint256 value; }',
297
+ ]),
298
+ [{ chainId, target, selector, value }],
299
+ );
300
+ }
@@ -0,0 +1,112 @@
1
+ import { mockErc721Abi } from '@boostxyz/evm';
2
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
+ import {
4
+ encodeAbiParameters,
5
+ encodeFunctionData,
6
+ isAddress,
7
+ parseEther,
8
+ toFunctionSelector,
9
+ zeroAddress,
10
+ } from 'viem';
11
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
12
+ import type { MockERC721 } from '@boostxyz/test/MockERC721';
13
+ import { accounts } from '@boostxyz/test/accounts';
14
+ import {
15
+ type Fixtures,
16
+ defaultOptions,
17
+ deployFixtures,
18
+ fundErc721,
19
+ } from '@boostxyz/test/helpers';
20
+ import { ERC721MintAction } from './ERC721MintAction';
21
+
22
+ let fixtures: Fixtures, erc721: MockERC721;
23
+
24
+ beforeAll(async () => {
25
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
26
+ });
27
+
28
+ const mintSelector = toFunctionSelector('function mint(address to)');
29
+
30
+ function nonPayableAction(fixtures: Fixtures, erc721: MockERC721) {
31
+ return function nonPayableAction() {
32
+ return fixtures.registry.initialize(
33
+ crypto.randomUUID(),
34
+ fixtures.core.ERC721MintAction({
35
+ chainId: BigInt(31_337),
36
+ target: erc721.assertValidAddress(),
37
+ selector: mintSelector,
38
+ value: 0n,
39
+ }),
40
+ );
41
+ };
42
+ }
43
+
44
+ describe.skip('ERC721MintAction', () => {
45
+ beforeEach(async () => {
46
+ erc721 = await loadFixture(fundErc721(defaultOptions));
47
+ });
48
+
49
+ test('can successfully be deployed', async () => {
50
+ const action = new ERC721MintAction(defaultOptions, {
51
+ chainId: BigInt(31_337),
52
+ target: zeroAddress,
53
+ selector: '0xdeadbeef',
54
+ value: 2n,
55
+ });
56
+ await action.deploy();
57
+ expect(isAddress(action.assertValidAddress())).toBe(true);
58
+ });
59
+
60
+ test('can read chain id', async () => {
61
+ const action = await loadFixture(nonPayableAction(fixtures, erc721));
62
+ expect(await action.chainId()).toBe(BigInt(31_337));
63
+ });
64
+
65
+ test('can read target', async () => {
66
+ const action = await loadFixture(nonPayableAction(fixtures, erc721));
67
+ expect((await action.target()).toLowerCase()).toBe(
68
+ erc721.assertValidAddress().toLowerCase(),
69
+ );
70
+ });
71
+
72
+ test('can read selector', async () => {
73
+ const action = await loadFixture(nonPayableAction(fixtures, erc721));
74
+ expect(await action.selector()).toBe(mintSelector);
75
+ });
76
+
77
+ test('can read value', async () => {
78
+ const action = await loadFixture(nonPayableAction(fixtures, erc721));
79
+ expect(await action.value()).toBe(0n);
80
+ });
81
+
82
+ test('prepare will properly encode execution payload', async () => {
83
+ const action = await loadFixture(nonPayableAction(fixtures, erc721));
84
+ const { account } = accounts[1];
85
+ const payload = await action.prepare(
86
+ encodeAbiParameters([{ type: 'address', name: 'address' }], [account]),
87
+ );
88
+ expect(payload).toBe(
89
+ encodeFunctionData({
90
+ abi: mockErc721Abi,
91
+ functionName: 'mint',
92
+ args: [account],
93
+ }),
94
+ );
95
+ });
96
+
97
+ // TODO implement execute
98
+ test.skip('nonpayable execute', async () => {
99
+ const action = await loadFixture(nonPayableAction(fixtures, erc721));
100
+ const { account } = accounts[1];
101
+ const [success] = await action.execute(
102
+ encodeAbiParameters(
103
+ [
104
+ { type: 'address', name: 'to' },
105
+ { type: 'uint256', name: 'amount' },
106
+ ],
107
+ [account, parseEther('100')],
108
+ ),
109
+ );
110
+ expect(success).toBe(true);
111
+ });
112
+ });
@@ -0,0 +1,291 @@
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 {
12
+ type Address,
13
+ type ContractEventName,
14
+ type Hex,
15
+ encodeAbiParameters,
16
+ toHex,
17
+ } from 'viem';
18
+ import type {
19
+ DeployableOptions,
20
+ GenericDeployableParams,
21
+ } from '../Deployable/Deployable';
22
+ import {
23
+ type GenericLog,
24
+ type ReadParams,
25
+ RegistryType,
26
+ type WriteParams,
27
+ } from '../utils';
28
+ import {
29
+ ContractAction,
30
+ type ContractActionPayload,
31
+ prepareContractActionPayload,
32
+ } from './ContractAction';
33
+
34
+ export { erc721MintActionAbi };
35
+ /**
36
+ * `ERC721MintActionPayload` is a re-exported `ContractActionPayload`
37
+ *
38
+ * @export
39
+ * @typedef {ERC721MintActionPayload}
40
+ */
41
+ export type ERC721MintActionPayload = ContractActionPayload;
42
+
43
+ /**
44
+ * A generic `viem.Log` event with support for `ERC721MintAction` event types.
45
+ *
46
+ * @export
47
+ * @typedef {ERC721MintActionLog}
48
+ * @template {ContractEventName<
49
+ * typeof erc721MintActionAbi
50
+ * >} [event=ContractEventName<typeof erc721MintActionAbi>]
51
+ */
52
+ export type ERC721MintActionLog<
53
+ event extends ContractEventName<
54
+ typeof erc721MintActionAbi
55
+ > = ContractEventName<typeof erc721MintActionAbi>,
56
+ > = GenericLog<typeof erc721MintActionAbi, event>;
57
+
58
+ /**
59
+ * A primitive action to mint and/or validate that an ERC721 token has been minted
60
+ * The action is expected to be prepared with the data payload for the minting of the token
61
+ * This a minimal generic implementation that should be extended if additional functionality or customizations are required
62
+ * It is expected that the target contract has an externally accessible mint function whose selector
63
+ *
64
+ * @export
65
+ * @class ERC721MintAction
66
+ * @typedef {ERC721MintAction}
67
+ * @extends {ContractAction}
68
+ */
69
+ export class ERC721MintAction extends ContractAction<
70
+ typeof erc721MintActionAbi
71
+ > {
72
+ //@ts-expect-error should never be constructed with variant typ
73
+ public override readonly abi = erc721MintActionAbi;
74
+
75
+ /**
76
+ * @inheritdoc
77
+ *
78
+ * @public
79
+ * @static
80
+ * @type {Record<number, Address>}
81
+ */
82
+ public static override bases: Record<number, Address> = {};
83
+ /**
84
+ * @inheritdoc
85
+ *
86
+ * @public
87
+ * @static
88
+ * @type {RegistryType}
89
+ */
90
+ public static override registryType: RegistryType = RegistryType.ACTION;
91
+
92
+ /**
93
+ * The set of validated tokens
94
+ * This is intended to prevent multiple validations against the same token ID
95
+ *
96
+ * @public
97
+ * @async
98
+ * @param {bigint} token
99
+ * @param {?ReadParams} [params]
100
+ * @returns {Promise<boolean>}
101
+ */
102
+ public async validated(
103
+ token: bigint,
104
+ params?: ReadParams<typeof erc721MintActionAbi, 'validated'>,
105
+ ) {
106
+ return await readErc721MintActionValidated(this._config, {
107
+ address: this.assertValidAddress(),
108
+ ...this.optionallyAttachAccount(),
109
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
110
+ ...(params as any),
111
+ args: [token],
112
+ });
113
+ }
114
+
115
+ /**
116
+ * @inheritdoc
117
+ *
118
+ * @public
119
+ * @async
120
+ * @param {Hex} data
121
+ * @param {?WriteParams} [params]
122
+ * @returns {Promise<readonly [boolean, `0x${string}`]>}
123
+ */
124
+ public override async execute(
125
+ data: Hex,
126
+ params?: WriteParams<typeof erc721MintActionAbi, 'execute'>,
127
+ ) {
128
+ return await this.awaitResult(this.executeRaw(data, params));
129
+ }
130
+
131
+ /**
132
+ * @inheritdoc
133
+ *
134
+ * @public
135
+ * @async
136
+ * @param {Hex} data
137
+ * @param {?WriteParams} [params]
138
+ * @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
139
+ */
140
+ public override async executeRaw(
141
+ data: Hex,
142
+ params?: WriteParams<typeof erc721MintActionAbi, 'execute'>,
143
+ ) {
144
+ const { request, result } = await simulateErc721MintActionExecute(
145
+ this._config,
146
+ {
147
+ address: this.assertValidAddress(),
148
+ args: [data],
149
+ ...this.optionallyAttachAccount(),
150
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
151
+ ...(params as any),
152
+ },
153
+ );
154
+ const hash = await writeErc721MintActionExecute(this._config, request);
155
+ return { hash, result };
156
+ }
157
+
158
+ /**
159
+ * @inheritdoc
160
+ *
161
+ * @public
162
+ * @async
163
+ * @param {Hex} data
164
+ * @param {?ReadParams} [params]
165
+ * @returns {Promise<`0x${string}`>}
166
+ */
167
+ public override async prepare(
168
+ data: Hex,
169
+ params?: ReadParams<typeof erc721MintActionAbi, 'prepare'>,
170
+ ) {
171
+ return await readErc721MintActionPrepare(this._config, {
172
+ address: this.assertValidAddress(),
173
+ args: [data],
174
+ ...this.optionallyAttachAccount(),
175
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
176
+ ...(params as any),
177
+ });
178
+ }
179
+
180
+ /**
181
+ * Validate that the action has been completed successfully. This API is protected to prevent accidental signature burning.
182
+ *
183
+ * @protected
184
+ * @async
185
+ * @param {Address} holder - The holder
186
+ * @param {BigInt} tokenId - The token ID
187
+ * @param {?WriteParams} [params]
188
+ * @returns {Promise<boolean>} - True if the action has been validated for the user
189
+ */
190
+ protected async validate(
191
+ holder: Address,
192
+ tokenId: bigint,
193
+ params?: WriteParams<typeof erc721MintActionAbi, 'validate'>,
194
+ ) {
195
+ return await this.awaitResult(this.validateRaw(holder, tokenId, params));
196
+ }
197
+
198
+ /**
199
+ * Validate that the action has been completed successfully
200
+ *
201
+ * @protected
202
+ * @async
203
+ * @param {Address} holder - The holder
204
+ * @param {BigInt} tokenId - The token ID
205
+ * @param {?WriteParams} [params]
206
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the action has been validated for the user
207
+ */
208
+ protected async validateRaw(
209
+ holder: Address,
210
+ tokenId: bigint,
211
+ params?: WriteParams<typeof erc721MintActionAbi, 'validate'>,
212
+ ) {
213
+ const { request, result } = await simulateErc721MintActionValidate(
214
+ this._config,
215
+ {
216
+ address: this.assertValidAddress(),
217
+ args: [prepareERC721MintActionValidate(holder, tokenId)],
218
+ ...this.optionallyAttachAccount(),
219
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
220
+ ...(params as any),
221
+ },
222
+ );
223
+ const hash = await writeErc721MintActionValidate(this._config, request);
224
+ return { hash, result };
225
+ }
226
+
227
+ /**
228
+ * @inheritdoc
229
+ *
230
+ * @public
231
+ * @param {?ERC721MintActionPayload} [_payload]
232
+ * @param {?DeployableOptions} [_options]
233
+ * @returns {GenericDeployableParams}
234
+ */
235
+ public override buildParameters(
236
+ _payload?: ERC721MintActionPayload,
237
+ _options?: DeployableOptions,
238
+ ): GenericDeployableParams {
239
+ const [payload, options] = this.validateDeploymentConfig(
240
+ _payload,
241
+ _options,
242
+ );
243
+ return {
244
+ abi: erc721MintActionAbi,
245
+ bytecode: bytecode as Hex,
246
+ args: [prepareERC721MintActionPayload(payload)],
247
+ ...this.optionallyAttachAccount(options.account),
248
+ };
249
+ }
250
+ }
251
+
252
+ /**
253
+ * Encodes a payload to validate that an action has been completed successfully.
254
+ *
255
+ *
256
+ * @export
257
+ * @param {Address} holder - The holder address
258
+ * @param {bigint} payload - The token ID
259
+ * @returns {Hex} - The first 20 bytes of the payload will be the holder address and the remaining bytes must be an encoded token ID (uint256)
260
+ */
261
+ export function prepareERC721MintActionValidate(
262
+ holder: Address,
263
+ payload: bigint,
264
+ ) {
265
+ return encodeAbiParameters(
266
+ [
267
+ { type: 'address', name: 'holder' },
268
+ { type: 'bytes', name: 'payload' },
269
+ ],
270
+ [holder, toHex(payload)],
271
+ );
272
+ }
273
+
274
+ /**
275
+ * Given a {@link ContractActionPayload}, properly encode a `ContractAction.InitPayload` for use with {@link ERC721MintAction} initialization.
276
+ *
277
+ * @param {ContractActionPayload} param0
278
+ * @param {bigint} param0.chainId - The chain ID on which the target exists
279
+ * @param {Address} param0.target - The target contract address
280
+ * @param {Hex} param0.selector - The selector for the function to be called
281
+ * @param {bigint} param0.value - The native token value to send with the function call
282
+ * @returns {Hex}
283
+ */
284
+ export function prepareERC721MintActionPayload({
285
+ chainId,
286
+ target,
287
+ selector,
288
+ value,
289
+ }: ContractActionPayload) {
290
+ return prepareContractActionPayload({ chainId, target, selector, value });
291
+ }