@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,465 @@
1
+ import {
2
+ erc1155IncentiveAbi,
3
+ readErc1155IncentiveAsset,
4
+ readErc1155IncentiveClaimed,
5
+ readErc1155IncentiveClaims,
6
+ readErc1155IncentiveExtraData,
7
+ readErc1155IncentiveIsClaimable,
8
+ readErc1155IncentiveLimit,
9
+ readErc1155IncentivePreflight,
10
+ readErc1155IncentiveReward,
11
+ readErc1155IncentiveStrategy,
12
+ readErc1155IncentiveTokenId,
13
+ simulateErc1155IncentiveClaim,
14
+ simulateErc1155IncentiveClawback,
15
+ writeErc1155IncentiveClaim,
16
+ writeErc1155IncentiveClawback,
17
+ } from '@boostxyz/evm';
18
+ import { bytecode } from '@boostxyz/evm/artifacts/contracts/incentives/ERC1155Incentive.sol/ERC1155Incentive.json';
19
+ import {
20
+ type Address,
21
+ type ContractEventName,
22
+ type Hex,
23
+ encodeAbiParameters,
24
+ parseAbiParameters,
25
+ } from 'viem';
26
+ import type {
27
+ DeployableOptions,
28
+ GenericDeployableParams,
29
+ } from '../Deployable/Deployable';
30
+ import { DeployableTarget } from '../Deployable/DeployableTarget';
31
+ import {
32
+ type ClaimPayload,
33
+ type StrategyType,
34
+ prepareClaimPayload,
35
+ } from '../claiming';
36
+ import {
37
+ type GenericLog,
38
+ type ReadParams,
39
+ RegistryType,
40
+ type WriteParams,
41
+ } from '../utils';
42
+
43
+ export { erc1155IncentiveAbi };
44
+
45
+ /**
46
+ * Enum representing inventive disbursement strategies for {@link ERC1155Incentive}
47
+ *
48
+ * @export
49
+ * @enum {number}
50
+ */
51
+ export enum ERC1155StrategyType {
52
+ POOL = 0,
53
+ MINT = 1,
54
+ }
55
+
56
+ /**
57
+ * The object representation of a `ERC1155Incentive.InitPayload`
58
+ *
59
+ * @export
60
+ * @interface ERC1155IncentivePayload
61
+ * @typedef {ERC1155IncentivePayload}
62
+ */
63
+ export interface ERC1155IncentivePayload {
64
+ /**
65
+ * The address of the `ERC1155` asset
66
+ *
67
+ * @type {Address}
68
+ */
69
+ asset: Address;
70
+ /**
71
+ * Should be `Strategy.POOL`
72
+ *
73
+ * @type {ERC1155StrategyType}
74
+ */
75
+ strategy: ERC1155StrategyType;
76
+ /**
77
+ * The token ID to target
78
+ *
79
+ * @type {bigint}
80
+ */
81
+ tokenId: bigint;
82
+ /**
83
+ * The maximum number of claims that can be made (one per address)
84
+ *
85
+ * @type {bigint}
86
+ */
87
+ limit: bigint;
88
+ /**
89
+ * Any extra data to accompany the claim, if applicable.
90
+ *
91
+ * @type {Hex}
92
+ */
93
+ extraData: Hex;
94
+ }
95
+
96
+ /**
97
+ * A generic `viem.Log` event with support for `ERC1155Incentive` event types.
98
+ *
99
+ * @export
100
+ * @typedef {ERC1155IncentiveLog}
101
+ * @template {ContractEventName<
102
+ * typeof erc1155IncentiveAbi
103
+ * >} [event=ContractEventName<typeof erc1155IncentiveAbi>]
104
+ */
105
+ export type ERC1155IncentiveLog<
106
+ event extends ContractEventName<
107
+ typeof erc1155IncentiveAbi
108
+ > = ContractEventName<typeof erc1155IncentiveAbi>,
109
+ > = GenericLog<typeof erc1155IncentiveAbi, event>;
110
+
111
+ /**
112
+ * This is currently not exported due to a mysterious abi encoding issue
113
+ *
114
+ * @experimental
115
+ * @export
116
+ * @class ERC1155Incentive
117
+ * @typedef {ERC1155Incentive}
118
+ * @extends {DeployableTarget<ERC1155IncentivePayload>}
119
+ */
120
+ export class ERC1155Incentive extends DeployableTarget<
121
+ ERC1155IncentivePayload,
122
+ typeof erc1155IncentiveAbi
123
+ > {
124
+ public override readonly abi = erc1155IncentiveAbi;
125
+ /**
126
+ * @inheritdoc
127
+ *
128
+ * @public
129
+ * @static
130
+ * @type {Record<number, Address>}
131
+ */
132
+ public static override bases: Record<number, Address> = {};
133
+ /**
134
+ * @inheritdoc
135
+ *
136
+ * @public
137
+ * @static
138
+ * @type {RegistryType}
139
+ */
140
+ public static override registryType: RegistryType = RegistryType.INCENTIVE;
141
+
142
+ /**
143
+ * Description placeholder
144
+ *
145
+ * @public
146
+ * @async
147
+ * @param {?ReadParams} [params]
148
+ * @returns {Promise<bigint>}
149
+ */
150
+ public async claims(
151
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'claims'>,
152
+ ) {
153
+ return await readErc1155IncentiveClaims(this._config, {
154
+ address: this.assertValidAddress(),
155
+ args: [],
156
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
157
+ ...(params as any),
158
+ });
159
+ }
160
+
161
+ /**
162
+ * Description placeholder
163
+ *
164
+ * @public
165
+ * @async
166
+ * @param {?ReadParams} [params]
167
+ * @returns {Promise<bigint>}
168
+ */
169
+ public async reward(
170
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'reward'>,
171
+ ) {
172
+ return await readErc1155IncentiveReward(this._config, {
173
+ address: this.assertValidAddress(),
174
+ args: [],
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
+ * Description placeholder
182
+ *
183
+ * @public
184
+ * @async
185
+ * @param {Address} address
186
+ * @param {?ReadParams} [params]
187
+ * @returns {Promise<boolean>}
188
+ */
189
+ public async claimed(
190
+ address: Address,
191
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'claimed'>,
192
+ ) {
193
+ return await readErc1155IncentiveClaimed(this._config, {
194
+ address: this.assertValidAddress(),
195
+ args: [address],
196
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
197
+ ...(params as any),
198
+ });
199
+ }
200
+
201
+ /**
202
+ * Description placeholder
203
+ *
204
+ * @public
205
+ * @async
206
+ * @param {?ReadParams} [params]
207
+ * @returns {Promise<Address>}
208
+ */
209
+ public async asset(params?: ReadParams<typeof erc1155IncentiveAbi, 'asset'>) {
210
+ return await readErc1155IncentiveAsset(this._config, {
211
+ address: this.assertValidAddress(),
212
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
213
+ ...(params as any),
214
+ });
215
+ }
216
+
217
+ /**
218
+ * Description placeholder
219
+ *
220
+ * @public
221
+ * @async
222
+ * @param {?ReadParams} [params]
223
+ * @returns {Promise<StrategyType>}
224
+ */
225
+ public strategy(
226
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'strategy'>,
227
+ ): Promise<StrategyType> {
228
+ return readErc1155IncentiveStrategy(this._config, {
229
+ address: this.assertValidAddress(),
230
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
231
+ ...(params as any),
232
+ }) as Promise<StrategyType>;
233
+ }
234
+
235
+ /**
236
+ * Description placeholder
237
+ *
238
+ * @public
239
+ * @async
240
+ * @param {?ReadParams} [params]
241
+ * @returns {unknown}
242
+ */
243
+ public async limit(params?: ReadParams<typeof erc1155IncentiveAbi, 'limit'>) {
244
+ return await readErc1155IncentiveLimit(this._config, {
245
+ address: this.assertValidAddress(),
246
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
247
+ ...(params as any),
248
+ });
249
+ }
250
+
251
+ /**
252
+ * Description placeholder
253
+ *
254
+ * @public
255
+ * @async
256
+ * @param {?ReadParams} [params]
257
+ * @returns {Promise<bigint>}
258
+ */
259
+ public async tokenId(
260
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'tokenId'>,
261
+ ) {
262
+ return await readErc1155IncentiveTokenId(this._config, {
263
+ address: this.assertValidAddress(),
264
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
265
+ ...(params as any),
266
+ });
267
+ }
268
+
269
+ /**
270
+ * Description placeholder
271
+ *
272
+ * @public
273
+ * @async
274
+ * @param {?ReadParams} [params]
275
+ * @returns {Promise<Hex>}
276
+ */
277
+ public async extraData(
278
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'extraData'>,
279
+ ) {
280
+ return await readErc1155IncentiveExtraData(this._config, {
281
+ address: this.assertValidAddress(),
282
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
283
+ ...(params as any),
284
+ });
285
+ }
286
+
287
+ /**
288
+ * Description placeholder
289
+ *
290
+ * @public
291
+ * @async
292
+ * @param {ClaimPayload} payload
293
+ * @param {?WriteParams} [params]
294
+ * @returns {Promise<boolean>}
295
+ */
296
+ protected async claim(
297
+ payload: ClaimPayload,
298
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
299
+ ) {
300
+ return await this.awaitResult(this.claimRaw(payload, params));
301
+ }
302
+
303
+ /**
304
+ * Description placeholder
305
+ *
306
+ * @public
307
+ * @async
308
+ * @param {ClaimPayload} payload
309
+ * @param {?WriteParams} [params]
310
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>}
311
+ */
312
+ protected async claimRaw(
313
+ payload: ClaimPayload,
314
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'claim'>,
315
+ ) {
316
+ const { request, result } = await simulateErc1155IncentiveClaim(
317
+ this._config,
318
+ {
319
+ address: this.assertValidAddress(),
320
+ args: [prepareClaimPayload(payload)],
321
+ ...this.optionallyAttachAccount(),
322
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
323
+ ...(params as any),
324
+ },
325
+ );
326
+ const hash = await writeErc1155IncentiveClaim(this._config, request);
327
+ return { hash, result };
328
+ }
329
+
330
+ /**
331
+ * Description placeholder
332
+ *
333
+ * @public
334
+ * @async
335
+ * @param {ClaimPayload} payload
336
+ * @param {?WriteParams} [params]
337
+ * @returns {Promise<boolean>}
338
+ */
339
+ public async clawback(
340
+ payload: ClaimPayload,
341
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
342
+ ) {
343
+ return await this.awaitResult(this.clawbackRaw(payload, params));
344
+ }
345
+
346
+ /**
347
+ * Description placeholder
348
+ *
349
+ * @public
350
+ * @async
351
+ * @param {ClaimPayload} payload
352
+ * @param {?WriteParams} [params]
353
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>}
354
+ */
355
+ public async clawbackRaw(
356
+ payload: ClaimPayload,
357
+ params?: WriteParams<typeof erc1155IncentiveAbi, 'clawback'>,
358
+ ) {
359
+ const { request, result } = await simulateErc1155IncentiveClawback(
360
+ this._config,
361
+ {
362
+ address: this.assertValidAddress(),
363
+ args: [prepareClaimPayload(payload)],
364
+ ...this.optionallyAttachAccount(),
365
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
366
+ ...(params as any),
367
+ },
368
+ );
369
+ const hash = await writeErc1155IncentiveClawback(this._config, request);
370
+ return { hash, result };
371
+ }
372
+
373
+ /**
374
+ * Description placeholder
375
+ *
376
+ * @public
377
+ * @async
378
+ * @param {ClaimPayload} payload
379
+ * @param {?ReadParams} [params]
380
+ * @returns {Promise<boolean>}
381
+ */
382
+ public async isClaimable(
383
+ payload: ClaimPayload,
384
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'isClaimable'>,
385
+ ) {
386
+ return await readErc1155IncentiveIsClaimable(this._config, {
387
+ address: this.assertValidAddress(),
388
+ args: [prepareClaimPayload(payload)],
389
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
390
+ ...(params as any),
391
+ });
392
+ }
393
+
394
+ /**
395
+ * Description placeholder
396
+ *
397
+ * @public
398
+ * @async
399
+ * @param {ERC1155IncentivePayload} data
400
+ * @param {?ReadParams} [params]
401
+ * @returns {Promise<Hex>}
402
+ */
403
+ public async preflight(
404
+ data: ERC1155IncentivePayload,
405
+ params?: ReadParams<typeof erc1155IncentiveAbi, 'preflight'>,
406
+ ) {
407
+ return await readErc1155IncentivePreflight(this._config, {
408
+ address: this.assertValidAddress(),
409
+ args: [prepareERC1155IncentivePayload(data)],
410
+ // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
411
+ ...(params as any),
412
+ });
413
+ }
414
+
415
+ /**
416
+ * @inheritdoc
417
+ *
418
+ * @public
419
+ * @param {?ERC1155IncentivePayload} [_payload]
420
+ * @param {?DeployableOptions} [_options]
421
+ * @returns {GenericDeployableParams}
422
+ */
423
+ public override buildParameters(
424
+ _payload?: ERC1155IncentivePayload,
425
+ _options?: DeployableOptions,
426
+ ): GenericDeployableParams {
427
+ const [payload, options] = this.validateDeploymentConfig(
428
+ _payload,
429
+ _options,
430
+ );
431
+ return {
432
+ abi: erc1155IncentiveAbi,
433
+ bytecode: bytecode as Hex,
434
+ args: [prepareERC1155IncentivePayload(payload)],
435
+ ...this.optionallyAttachAccount(options.account),
436
+ };
437
+ }
438
+ }
439
+
440
+ /**
441
+ * Given a {@link ERC1155IncentivePayload}, properly encode a `ERC1155Incentive.InitPayload` for use with {@link ERC1155Incentive} initialization.
442
+ *
443
+ * @param {ERC1155IncentivePayload} param0
444
+ * @param {Address} param0.asset - The address of the `ERC1155` asset
445
+ * @param {ERC1155StrategyType} param0.strategy - Should be `Strategy.POOL`
446
+ * @param {bigint} param0.tokenId - The token ID to target
447
+ * @param {bigint} param0.limit - The maximum number of claims that can be made (one per address)
448
+ * @param {Hex} param0.extraData - Any extra data to accompany the claim, if applicable.
449
+ * @returns {Hex}
450
+ */
451
+ export const prepareERC1155IncentivePayload = ({
452
+ asset,
453
+ strategy,
454
+ tokenId,
455
+ limit,
456
+ extraData,
457
+ }: ERC1155IncentivePayload) => {
458
+ return encodeAbiParameters(
459
+ parseAbiParameters([
460
+ 'InitPayload payload',
461
+ 'struct InitPayload { address asset; uint8 strategy; uint256 tokenId; uint256 limit; bytes extraData; }',
462
+ ]),
463
+ [{ asset, strategy, tokenId, limit, extraData }],
464
+ );
465
+ };
@@ -0,0 +1,133 @@
1
+ import { readMockErc20BalanceOf } from '@boostxyz/evm';
2
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
+ import { isAddress, pad, parseEther, zeroAddress } from 'viem';
4
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
5
+ import { accounts } from '@boostxyz/test/accounts';
6
+ import {
7
+ type BudgetFixtures,
8
+ type Fixtures,
9
+ defaultOptions,
10
+ deployFixtures,
11
+ freshBoost,
12
+ fundBudget,
13
+ } from '@boostxyz/test/helpers';
14
+ import { BOOST_CORE_CLAIM_FEE } from '../BoostCore';
15
+ import { StrategyType } from '../claiming';
16
+ import { ERC20Incentive } from './ERC20Incentive';
17
+
18
+ let fixtures: Fixtures, budgets: BudgetFixtures;
19
+
20
+ describe('ERC20Incentive', () => {
21
+ beforeAll(async () => {
22
+ fixtures = await loadFixture(deployFixtures(defaultOptions));
23
+ });
24
+
25
+ beforeEach(async () => {
26
+ budgets = await loadFixture(fundBudget(defaultOptions, fixtures));
27
+ });
28
+
29
+ test('can successfully be deployed', async () => {
30
+ const action = new ERC20Incentive(defaultOptions, {
31
+ asset: zeroAddress,
32
+ strategy: StrategyType.POOL,
33
+ reward: 1n,
34
+ limit: 1n,
35
+ manager: zeroAddress,
36
+ });
37
+ await action.deploy();
38
+ expect(isAddress(action.assertValidAddress())).toBe(true);
39
+ });
40
+
41
+ test('can claim', async () => {
42
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
43
+ const referrer = accounts.at(1)!.account!,
44
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
45
+ trustedSigner = accounts.at(0)!;
46
+ const erc20Incentive = fixtures.core.ERC20Incentive({
47
+ asset: budgets.erc20.assertValidAddress(),
48
+ strategy: StrategyType.POOL,
49
+ reward: 1n,
50
+ limit: 1n,
51
+ manager: budgets.budget.assertValidAddress(),
52
+ });
53
+ const boost = await freshBoost(fixtures, {
54
+ budget: budgets.budget,
55
+ incentives: [erc20Incentive],
56
+ });
57
+
58
+ const claimant = trustedSigner.account;
59
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
60
+ const incentiveQuantity = 1;
61
+ const claimDataPayload = await boost.validator.encodeClaimData({
62
+ signer: trustedSigner,
63
+ incentiveData,
64
+ chainId: defaultOptions.config.chains[0].id,
65
+ incentiveQuantity,
66
+ claimant,
67
+ boostId: boost.id,
68
+ });
69
+
70
+ await fixtures.core.claimIncentive(
71
+ boost.id,
72
+ 0n,
73
+ referrer,
74
+ claimDataPayload,
75
+ { value: BOOST_CORE_CLAIM_FEE },
76
+ );
77
+ expect(
78
+ await readMockErc20BalanceOf(defaultOptions.config, {
79
+ address: budgets.erc20.assertValidAddress(),
80
+ args: [defaultOptions.account.address],
81
+ }),
82
+ ).toBe(1n);
83
+ });
84
+
85
+ test('cannot claim twice', async () => {
86
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
87
+ const referrer = accounts.at(1)!.account!;
88
+ // biome-ignore lint/style/noNonNullAssertion: we know this is defined
89
+ const trustedSigner = accounts.at(0)!;
90
+ const erc20Incentive = fixtures.core.ERC20Incentive({
91
+ asset: budgets.erc20.assertValidAddress(),
92
+ strategy: StrategyType.POOL,
93
+ reward: 1n,
94
+ limit: 1n,
95
+ manager: budgets.budget.assertValidAddress(),
96
+ });
97
+ const boost = await freshBoost(fixtures, {
98
+ budget: budgets.budget,
99
+ incentives: [erc20Incentive],
100
+ });
101
+
102
+ const claimant = trustedSigner.account;
103
+ const incentiveData = pad('0xdef456232173821931823712381232131391321934');
104
+ const incentiveQuantity = 1;
105
+ const claimDataPayload = await boost.validator.encodeClaimData({
106
+ signer: trustedSigner,
107
+ incentiveData,
108
+ chainId: defaultOptions.config.chains[0].id,
109
+ incentiveQuantity,
110
+ claimant,
111
+ boostId: boost.id,
112
+ });
113
+
114
+ await fixtures.core.claimIncentive(
115
+ boost.id,
116
+ 0n,
117
+ referrer,
118
+ claimDataPayload,
119
+ { value: BOOST_CORE_CLAIM_FEE },
120
+ );
121
+ try {
122
+ await fixtures.core.claimIncentive(
123
+ boost.id,
124
+ 0n,
125
+ referrer,
126
+ claimDataPayload,
127
+ { value: parseEther('0.000075') },
128
+ );
129
+ } catch (e) {
130
+ expect(e).toBeInstanceOf(Error);
131
+ }
132
+ });
133
+ });