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

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 (191) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.js +1 -1
  3. package/dist/Actions/ContractAction.d.ts +46 -3
  4. package/dist/Actions/ContractAction.d.ts.map +1 -1
  5. package/dist/Actions/ERC721MintAction.d.ts +37 -10
  6. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  7. package/dist/Actions/EventAction.cjs +1 -1
  8. package/dist/Actions/EventAction.cjs.map +1 -1
  9. package/dist/Actions/EventAction.d.ts +257 -11
  10. package/dist/Actions/EventAction.d.ts.map +1 -1
  11. package/dist/Actions/EventAction.js +249 -82
  12. package/dist/Actions/EventAction.js.map +1 -1
  13. package/dist/AllowLists/AllowList.cjs +1 -1
  14. package/dist/AllowLists/AllowList.d.ts +2 -2
  15. package/dist/AllowLists/AllowList.js +1 -1
  16. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  17. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  18. package/dist/AllowLists/SimpleAllowList.d.ts +33 -4
  19. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
  20. package/dist/AllowLists/SimpleAllowList.js +52 -37
  21. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  22. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  23. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
  24. package/dist/AllowLists/SimpleDenyList.d.ts +31 -2
  25. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
  26. package/dist/AllowLists/SimpleDenyList.js +41 -129
  27. package/dist/AllowLists/SimpleDenyList.js.map +1 -1
  28. package/dist/Auth/PassthroughAuth.cjs +1 -1
  29. package/dist/Auth/PassthroughAuth.cjs.map +1 -1
  30. package/dist/Auth/PassthroughAuth.js +4 -4
  31. package/dist/Auth/PassthroughAuth.js.map +1 -1
  32. package/dist/Boost.cjs +1 -1
  33. package/dist/Boost.cjs.map +1 -1
  34. package/dist/Boost.d.ts +93 -1
  35. package/dist/Boost.d.ts.map +1 -1
  36. package/dist/Boost.js +151 -5
  37. package/dist/Boost.js.map +1 -1
  38. package/dist/BoostCore.cjs +2 -2
  39. package/dist/BoostCore.cjs.map +1 -1
  40. package/dist/BoostCore.d.ts +45 -7
  41. package/dist/BoostCore.d.ts.map +1 -1
  42. package/dist/BoostCore.js +352 -305
  43. package/dist/BoostCore.js.map +1 -1
  44. package/dist/BoostRegistry.cjs +1 -1
  45. package/dist/BoostRegistry.cjs.map +1 -1
  46. package/dist/BoostRegistry.d.ts +18 -4
  47. package/dist/BoostRegistry.d.ts.map +1 -1
  48. package/dist/BoostRegistry.js +36 -25
  49. package/dist/BoostRegistry.js.map +1 -1
  50. package/dist/Budgets/Budget.cjs +1 -1
  51. package/dist/Budgets/Budget.js +1 -1
  52. package/dist/Budgets/ManagedBudget.cjs +1 -1
  53. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  54. package/dist/Budgets/ManagedBudget.d.ts +40 -2
  55. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  56. package/dist/Budgets/ManagedBudget.js +53 -36
  57. package/dist/Budgets/ManagedBudget.js.map +1 -1
  58. package/dist/Budgets/SimpleBudget.d.ts +33 -2
  59. package/dist/Budgets/SimpleBudget.d.ts.map +1 -1
  60. package/dist/Budgets/VestingBudget.d.ts +54 -2
  61. package/dist/Budgets/VestingBudget.d.ts.map +1 -1
  62. package/dist/Deployable/Contract.cjs +1 -1
  63. package/dist/Deployable/Contract.cjs.map +1 -1
  64. package/dist/Deployable/Contract.js +1 -1
  65. package/dist/Deployable/Contract.js.map +1 -1
  66. package/dist/Deployable/Deployable.cjs.map +1 -1
  67. package/dist/Deployable/Deployable.d.ts +8 -2
  68. package/dist/Deployable/Deployable.d.ts.map +1 -1
  69. package/dist/Deployable/Deployable.js +6 -0
  70. package/dist/Deployable/Deployable.js.map +1 -1
  71. package/dist/Deployable/DeployableTarget.cjs +1 -1
  72. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  73. package/dist/Deployable/DeployableTarget.d.ts +4 -3
  74. package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
  75. package/dist/Deployable/DeployableTarget.js +31 -28
  76. package/dist/Deployable/DeployableTarget.js.map +1 -1
  77. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  78. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  79. package/dist/Incentives/AllowListIncentive.d.ts +35 -5
  80. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  81. package/dist/Incentives/AllowListIncentive.js +33 -21
  82. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  83. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  84. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  85. package/dist/Incentives/CGDAIncentive.d.ts +89 -5
  86. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  87. package/dist/Incentives/CGDAIncentive.js +44 -23
  88. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  89. package/dist/Incentives/ERC1155Incentive.d.ts +67 -6
  90. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
  91. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  92. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  93. package/dist/Incentives/ERC20Incentive.d.ts +49 -5
  94. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  95. package/dist/Incentives/ERC20Incentive.js +46 -27
  96. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  97. package/dist/Incentives/ERC20VariableIncentive.d.ts +42 -5
  98. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
  99. package/dist/Incentives/Incentive.cjs +1 -1
  100. package/dist/Incentives/Incentive.cjs.map +1 -1
  101. package/dist/Incentives/Incentive.js +48 -32
  102. package/dist/Incentives/Incentive.js.map +1 -1
  103. package/dist/Incentives/PointsIncentive.cjs +1 -1
  104. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  105. package/dist/Incentives/PointsIncentive.d.ts +49 -5
  106. package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
  107. package/dist/Incentives/PointsIncentive.js +38 -21
  108. package/dist/Incentives/PointsIncentive.js.map +1 -1
  109. package/dist/Validators/SignerValidator.cjs +1 -1
  110. package/dist/Validators/SignerValidator.cjs.map +1 -1
  111. package/dist/Validators/SignerValidator.d.ts +298 -5
  112. package/dist/Validators/SignerValidator.d.ts.map +1 -1
  113. package/dist/Validators/SignerValidator.js +151 -26
  114. package/dist/Validators/SignerValidator.js.map +1 -1
  115. package/dist/Validators/Validator.cjs +1 -1
  116. package/dist/Validators/Validator.js +1 -1
  117. package/dist/claiming.cjs +2 -0
  118. package/dist/claiming.cjs.map +1 -0
  119. package/dist/claiming.d.ts +43 -0
  120. package/dist/claiming.d.ts.map +1 -0
  121. package/dist/claiming.js +17 -0
  122. package/dist/claiming.js.map +1 -0
  123. package/dist/errors.cjs +1 -1
  124. package/dist/errors.cjs.map +1 -1
  125. package/dist/errors.d.ts +15 -1
  126. package/dist/errors.d.ts.map +1 -1
  127. package/dist/errors.js +30 -21
  128. package/dist/errors.js.map +1 -1
  129. package/dist/{generated-DGpIVcv5.js → generated-57_Kffpz.js} +293 -282
  130. package/dist/generated-57_Kffpz.js.map +1 -0
  131. package/dist/{generated-Cd-Fe7W7.cjs → generated-wKBNvm48.cjs} +3 -3
  132. package/dist/generated-wKBNvm48.cjs.map +1 -0
  133. package/dist/index.cjs +1 -1
  134. package/dist/index.d.ts +4 -4
  135. package/dist/index.d.ts.map +1 -1
  136. package/dist/index.js +108 -124
  137. package/dist/transfers.cjs +2 -0
  138. package/dist/transfers.cjs.map +1 -0
  139. package/dist/transfers.d.ts +198 -0
  140. package/dist/transfers.d.ts.map +1 -0
  141. package/dist/transfers.js +84 -0
  142. package/dist/transfers.js.map +1 -0
  143. package/dist/utils.cjs +1 -1
  144. package/dist/utils.cjs.map +1 -1
  145. package/dist/utils.d.ts +2 -1371
  146. package/dist/utils.d.ts.map +1 -1
  147. package/dist/utils.js +26 -653
  148. package/dist/utils.js.map +1 -1
  149. package/package.json +17 -3
  150. package/src/Actions/Action.test.ts +5 -4
  151. package/src/Actions/ContractAction.test.ts +4 -6
  152. package/src/Actions/ContractAction.ts +73 -10
  153. package/src/Actions/ERC721MintAction.test.ts +2 -2
  154. package/src/Actions/ERC721MintAction.ts +70 -16
  155. package/src/Actions/EventAction.test.ts +43 -17
  156. package/src/Actions/EventAction.ts +451 -26
  157. package/src/AllowLists/SimpleAllowList.ts +51 -7
  158. package/src/AllowLists/SimpleDenyList.ts +47 -109
  159. package/src/Auth/PassthroughAuth.ts +1 -1
  160. package/src/Boost.ts +136 -1
  161. package/src/BoostCore.test.ts +4 -11
  162. package/src/BoostCore.ts +114 -45
  163. package/src/BoostRegistry.ts +39 -21
  164. package/src/Budgets/ManagedBudget.ts +69 -16
  165. package/src/Budgets/SimpleBudget.ts +57 -14
  166. package/src/Budgets/VestingBudget.ts +79 -9
  167. package/src/Deployable/Contract.ts +1 -1
  168. package/src/Deployable/Deployable.ts +8 -2
  169. package/src/Deployable/DeployableTarget.ts +19 -6
  170. package/src/Incentives/AllowListIncentive.test.ts +2 -5
  171. package/src/Incentives/AllowListIncentive.ts +59 -15
  172. package/src/Incentives/CGDAIncentive.test.ts +3 -7
  173. package/src/Incentives/CGDAIncentive.ts +123 -19
  174. package/src/Incentives/ERC1155Incentive.test.ts +2 -13
  175. package/src/Incentives/ERC1155Incentive.ts +104 -22
  176. package/src/Incentives/ERC20Incentive.test.ts +6 -17
  177. package/src/Incentives/ERC20Incentive.ts +86 -21
  178. package/src/Incentives/ERC20VariableIncentive.test.ts +4 -24
  179. package/src/Incentives/ERC20VariableIncentive.ts +71 -19
  180. package/src/Incentives/Incentive.test.ts +1 -1
  181. package/src/Incentives/PointsIncentive.test.ts +3 -6
  182. package/src/Incentives/PointsIncentive.ts +79 -17
  183. package/src/Validators/SignerValidator.test.ts +3 -7
  184. package/src/Validators/SignerValidator.ts +422 -13
  185. package/src/claiming.ts +56 -0
  186. package/src/errors.ts +19 -1
  187. package/src/index.ts +10 -7
  188. package/src/transfers.ts +284 -0
  189. package/src/utils.ts +3 -2052
  190. package/dist/generated-Cd-Fe7W7.cjs.map +0 -1
  191. package/dist/generated-DGpIVcv5.js.map +0 -1
@@ -0,0 +1,284 @@
1
+ import {
2
+ type Address,
3
+ type Hex,
4
+ encodeAbiParameters,
5
+ parseAbiParameters,
6
+ zeroAddress,
7
+ } from 'viem';
8
+
9
+ /**
10
+ * The various types of assets supported in Budgets and Incentives.
11
+ *
12
+ * @export
13
+ * @enum {number}
14
+ */
15
+ export enum AssetType {
16
+ ETH,
17
+ ERC20,
18
+ ERC1155,
19
+ }
20
+
21
+ /**
22
+ * Object representation of a generic `Transfer` struct.
23
+ *
24
+ * @export
25
+ * @interface TransferPayload
26
+ * @typedef {TransferPayload}
27
+ */
28
+ export interface TransferPayload {
29
+ /**
30
+ * The type of the asset being transferred.
31
+ *
32
+ * @type {AssetType}
33
+ */
34
+ assetType: AssetType;
35
+ /**
36
+ * The address of the asset to transfer, zero address for ETH.
37
+ *
38
+ * @type {Address}
39
+ */
40
+ address: Address;
41
+ /**
42
+ * The account from which to transfer the assets.
43
+ *
44
+ * @type {Address}
45
+ */
46
+ target: Address;
47
+ /**
48
+ * An encoded {@link FungiblePayload}, use {@link prepareFungiblePayload} to construct.
49
+ *
50
+ * @type {Hex}
51
+ */
52
+ data: Hex;
53
+ }
54
+
55
+ /**
56
+ * Encodes parameters for transferring the transfer of Fungible and ERC1155 assets, used for {@link Budget} operations.
57
+ * Typically you'd use {@link prepareFungibleTransfer} or {@link prepareERC1155Transfer}
58
+ *
59
+ * @param {TransferPayload} param0
60
+ * @param {AssetType} param0.assetType - The asset type being transferred.
61
+ * @param {Address} param0.address - The address of the asset, use zero address for ETH transfers.
62
+ * @param {Address} param0.target - The address of the account being transferred from
63
+ * @param {Hex} param0.data - Use {@link prepareFungiblePayload} to properly encode an amount to transfer
64
+ * @returns {Hex}
65
+ */
66
+ export const prepareTransferPayload = ({
67
+ assetType,
68
+ address,
69
+ target,
70
+ data,
71
+ }: TransferPayload) => {
72
+ return encodeAbiParameters(
73
+ [
74
+ { type: 'uint8', name: 'assetType' },
75
+ { type: 'address', name: 'asset' },
76
+ { type: 'address', name: 'target' },
77
+ { type: 'bytes', name: 'data' },
78
+ ],
79
+ [assetType, address, target, data],
80
+ );
81
+ };
82
+
83
+ /**
84
+ * Object representation of
85
+ *
86
+ * @export
87
+ * @interface ERC1155Payload
88
+ * @typedef {ERC1155Payload}
89
+ */
90
+ export interface ERC1155Payload {
91
+ /**
92
+ * The ERC1155 token ID for the incentive
93
+ *
94
+ * @type {bigint}
95
+ */
96
+ tokenId: bigint;
97
+ /**
98
+ * The amount to transfer
99
+ *
100
+ * @type {bigint}
101
+ */
102
+ amount: bigint;
103
+ }
104
+
105
+ /**
106
+ * Given a token ID and amount, properly encode a `ERC1155Incentive.ERC1155Payload` for use with {@link ERC1155Incentive} initialization.
107
+ *
108
+ * @export
109
+ * @param {ERC1155Payload} param0
110
+ * @param {bigint} param0.tokenId - The ERC1155 token ID for the incentive
111
+ * @param {bigint} param0.amount - The amount to transfer
112
+ * @returns {Hex}
113
+ */
114
+ export function prepareERC1155Payload({ tokenId, amount }: ERC1155Payload) {
115
+ return encodeAbiParameters(
116
+ parseAbiParameters([
117
+ 'ERC1155Payload payload',
118
+ 'struct ERC1155Payload { uint256 tokenId; uint256 amount; bytes data; }',
119
+ ]),
120
+ [{ tokenId, amount, data: '0x' }],
121
+ );
122
+ }
123
+
124
+ /**
125
+ * An object representation of the `Budget.Transfer` contract struct for transfers of ERC1155 assets.
126
+ *
127
+ * @export
128
+ * @interface ERC1155TransferPayload
129
+ * @typedef {ERC1155TransferPayload}
130
+ */
131
+ export interface ERC1155TransferPayload {
132
+ /**
133
+ * The token ID to transfer
134
+ *
135
+ * @type {bigint}
136
+ */
137
+ tokenId: bigint;
138
+ /**
139
+ * The amount to transfer
140
+ *
141
+ * @type {bigint}
142
+ */
143
+ amount: bigint;
144
+ /**
145
+ * The address of the asset to target
146
+ *
147
+ * @type {Address}
148
+ */
149
+ asset: Address;
150
+ /**
151
+ * The account to transfer from
152
+ *
153
+ * @type {Address}
154
+ */
155
+ target: Address;
156
+ }
157
+
158
+ /**
159
+ * Encodes parameters for transferring the transfer of ERC1155 assets, used for {@link Budget} operations.
160
+ * The caller must have already approved the contract to transfer the asset.
161
+ *
162
+ * @export
163
+ * @param {ERC1155TransferPayload} param0
164
+ * @param {bigint} param0.tokenId - The token ID to transfer
165
+ * @param {bigint} param0.amount - The amount to transfer
166
+ * @param {Address} param0.asset - The address of the asset to target
167
+ * @param {Address} param0.target - The account to transfer from
168
+ * @returns {Hex}
169
+ */
170
+ export function prepareERC1155Transfer({
171
+ tokenId,
172
+ amount,
173
+ asset,
174
+ target,
175
+ }: ERC1155TransferPayload) {
176
+ return encodeAbiParameters(
177
+ parseAbiParameters([
178
+ 'Transfer request',
179
+ 'struct Transfer { uint8 assetType; address asset; address target; bytes data; }',
180
+ ]),
181
+ [
182
+ {
183
+ assetType: AssetType.ERC1155,
184
+ asset,
185
+ data: prepareERC1155Payload({ tokenId, amount }),
186
+ target,
187
+ },
188
+ ],
189
+ );
190
+ }
191
+
192
+ /**
193
+ * An object representation of the `FungiblePayload` struct
194
+ *
195
+ * @export
196
+ * @interface FungiblePayload
197
+ * @typedef {FungiblePayload}
198
+ */
199
+ export interface FungiblePayload {
200
+ /**
201
+ * The amount being transferred
202
+ *
203
+ * @type {bigint}
204
+ */
205
+ amount: bigint;
206
+ }
207
+
208
+ /**
209
+ * Encodes an amount for the `FungiblePayload` struct
210
+ *
211
+ * @export
212
+ * @param {FungiblePayload} param0
213
+ * @param {bigint} param0.amount - The amount being transferred
214
+ * @returns {*}
215
+ */
216
+ export function prepareFungiblePayload({ amount }: FungiblePayload) {
217
+ return encodeAbiParameters(
218
+ parseAbiParameters([
219
+ 'FungiblePayload payload',
220
+ 'struct FungiblePayload { uint256 amount; }',
221
+ ]),
222
+ [{ amount }],
223
+ );
224
+ }
225
+
226
+ /**
227
+ * An object representation of the `Budget.Transfer` contract struct for transfers of fungible assets.
228
+ *
229
+ * @export
230
+ * @interface FungibleTransferPayload
231
+ * @typedef {FungibleTransferPayload}
232
+ */
233
+ export interface FungibleTransferPayload {
234
+ /**
235
+ * The amount to transfer
236
+ *
237
+ * @type {bigint}
238
+ */
239
+ amount: bigint;
240
+ /**
241
+ * The address of the asset. Use zero address for ETH transfers.
242
+ *
243
+ * @type {Address}
244
+ */
245
+ asset: Address;
246
+ /**
247
+ * The account to transfer from
248
+ *
249
+ * @type {Address}
250
+ */
251
+ target: Address;
252
+ }
253
+
254
+ /**
255
+ * Encodes parameters for a Fungible transfer, used for Budget allocations.
256
+ * The caller must have already approved the contract to transfer the asset.
257
+ *
258
+ * @export
259
+ * @param {FungibleTransferPayload} param0
260
+ * @param {bigint} param0.amount - The amount to transfer
261
+ * @param {Address} param0.asset - The address of the asset. Use zero address for ETH transfers.
262
+ * @param {Address} param0.target - The account to transfer from
263
+ * @returns {Hex}
264
+ */
265
+ export function prepareFungibleTransfer({
266
+ amount,
267
+ asset,
268
+ target,
269
+ }: FungibleTransferPayload) {
270
+ return encodeAbiParameters(
271
+ parseAbiParameters([
272
+ 'Transfer request',
273
+ 'struct Transfer { uint8 assetType; address asset; address target; bytes data; }',
274
+ ]),
275
+ [
276
+ {
277
+ assetType: asset == zeroAddress ? AssetType.ETH : AssetType.ERC20,
278
+ asset,
279
+ data: prepareFungiblePayload({ amount }),
280
+ target,
281
+ },
282
+ ],
283
+ );
284
+ }