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

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 +77 -77
  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 +111 -1
  48. package/dist/Boost.d.ts.map +1 -1
  49. package/dist/Boost.js +140 -5
  50. package/dist/Boost.js.map +1 -0
  51. package/dist/BoostCore-3-U1xTQN.cjs +3 -0
  52. package/dist/BoostCore-3-U1xTQN.cjs.map +1 -0
  53. package/dist/BoostCore-DVGBUr2y.js +1477 -0
  54. package/dist/BoostCore-DVGBUr2y.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 +166 -43
  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 +64 -23
  64. package/dist/BoostRegistry.d.ts.map +1 -1
  65. package/dist/BoostRegistry.js +162 -88
  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 +78 -188
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
  77. package/dist/Budgets/ManagedBudget.js +86 -286
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/VestingBudget.d.ts +243 -87
  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-CIPqmAoP.js +1450 -0
  106. package/dist/EventAction-CIPqmAoP.js.map +1 -0
  107. package/dist/EventAction-d-oeqZQs.cjs +2 -0
  108. package/dist/EventAction-d-oeqZQs.cjs.map +1 -0
  109. package/dist/Incentive-Bp8Sez7M.js +298 -0
  110. package/dist/Incentive-Bp8Sez7M.js.map +1 -0
  111. package/dist/Incentive-Djnzseoj.cjs +2 -0
  112. package/dist/Incentive-Djnzseoj.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 +49 -19
  116. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
  117. package/dist/Incentives/AllowListIncentive.js +50 -34
  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 +118 -22
  122. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
  123. package/dist/Incentives/CGDAIncentive.js +67 -42
  124. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  125. package/dist/Incentives/ERC1155Incentive.d.ts +99 -38
  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 +73 -29
  130. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
  131. package/dist/Incentives/ERC20Incentive.js +71 -48
  132. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  133. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
  134. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  135. package/dist/Incentives/ERC20VariableIncentive.d.ts +65 -28
  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 +4 -7
  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 +65 -21
  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-BwfNjRsg.cjs +2 -0
  150. package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
  151. package/dist/SimpleDenyList-Cn5WpNn0.js +132 -0
  152. package/dist/SimpleDenyList-Cn5WpNn0.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 +12 -10
  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-D09mhzxO.cjs +2 -0
  172. package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
  173. package/dist/componentInterfaces-RXBMI5yH.js +14 -0
  174. package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
  175. package/dist/deployments-BM42vImE.js +43 -0
  176. package/dist/deployments-BM42vImE.js.map +1 -0
  177. package/dist/deployments-CMdF5uEC.cjs +2 -0
  178. package/dist/deployments-CMdF5uEC.cjs.map +1 -0
  179. package/dist/deployments.json +41 -0
  180. package/dist/errors.cjs +2 -1
  181. package/dist/errors.cjs.map +1 -0
  182. package/dist/errors.d.ts +403 -1
  183. package/dist/errors.d.ts.map +1 -1
  184. package/dist/errors.js +285 -39
  185. package/dist/errors.js.map +1 -0
  186. package/dist/generated-B0tk-c9b.cjs +3 -0
  187. package/dist/generated-B0tk-c9b.cjs.map +1 -0
  188. package/dist/{generated-x_abr3Yv.js → generated-B7VaSah4.js} +2058 -2541
  189. package/dist/generated-B7VaSah4.js.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 +143 -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 +1214 -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 +309 -0
  229. package/src/BoostCore.test.ts +827 -0
  230. package/src/BoostCore.ts +1447 -0
  231. package/src/BoostRegistry.ts +543 -0
  232. package/src/Budgets/Budget.test.ts +27 -0
  233. package/src/Budgets/Budget.ts +60 -0
  234. package/src/Budgets/ManagedBudget.test.ts +217 -0
  235. package/src/Budgets/ManagedBudget.ts +534 -0
  236. package/src/Budgets/VestingBudget.test.ts +123 -0
  237. package/src/Budgets/VestingBudget.ts +530 -0
  238. package/src/Deployable/Contract.ts +228 -0
  239. package/src/Deployable/Deployable.ts +250 -0
  240. package/src/Deployable/DeployableTarget.ts +234 -0
  241. package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
  242. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  243. package/src/Incentives/AllowListIncentive.ts +336 -0
  244. package/src/Incentives/CGDAIncentive.test.ts +132 -0
  245. package/src/Incentives/CGDAIncentive.ts +470 -0
  246. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  247. package/src/Incentives/ERC1155Incentive.ts +465 -0
  248. package/src/Incentives/ERC20Incentive.test.ts +130 -0
  249. package/src/Incentives/ERC20Incentive.ts +484 -0
  250. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  251. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  252. package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
  253. package/src/Incentives/ERC20VariableIncentive.ts +422 -0
  254. package/src/Incentives/Incentive.test.ts +92 -0
  255. package/src/Incentives/Incentive.ts +86 -0
  256. package/src/Incentives/PointsIncentive.test.ts +139 -0
  257. package/src/Incentives/PointsIncentive.ts +367 -0
  258. package/src/Validators/SignerValidator.test.ts +159 -0
  259. package/src/Validators/SignerValidator.ts +683 -0
  260. package/src/Validators/Validator.test.ts +21 -0
  261. package/src/Validators/Validator.ts +55 -0
  262. package/src/claiming.ts +56 -0
  263. package/src/errors.ts +844 -0
  264. package/src/index.test.ts +122 -0
  265. package/src/index.ts +58 -0
  266. package/src/transfers.ts +284 -0
  267. package/src/utils.test.ts +44 -0
  268. package/src/utils.ts +247 -0
  269. package/dist/Budgets/SimpleBudget.d.ts +0 -793
  270. package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
  271. package/dist/generated-BaaleHW-.cjs +0 -2
@@ -0,0 +1,122 @@
1
+ import { describe, expect, test } from "vitest";
2
+ import * as SDK from "./index";
3
+
4
+ // Please add any public interface you'd like to verify exists on the root export here
5
+ // Types don't exist in .js so only list objects, constants, classes, etc, no interfaces
6
+ const allExports = [
7
+ "BoostRegistry",
8
+ "BoostCore",
9
+ "Boost",
10
+ "EventAction",
11
+ "OpenAllowList",
12
+ "SimpleAllowList",
13
+ "SimpleDenyList",
14
+ "ManagedBudget",
15
+ "Deployable",
16
+ "Contract",
17
+ "DeployableTarget",
18
+ "DeployableTargetWithRBAC",
19
+ "AllowListIncentive",
20
+ "CGDAIncentive",
21
+ "ERC20Incentive",
22
+ "ERC20VariableIncentive",
23
+ "ERC20VariableCriteriaIncentive",
24
+ "PointsIncentive",
25
+ "SignerValidator",
26
+ "BoostCoreNoIdentifierEmitted",
27
+ "ContractAddressRequiredError",
28
+ "DeployableAlreadyDeployedError",
29
+ "DeployableBuildParametersUnspecifiedError",
30
+ "DeployableUnknownOwnerProvidedError",
31
+ "DeployableWagmiConfigurationRequiredError",
32
+ "DeployableMissingPayloadError",
33
+ "NoContractAddressUponReceiptError",
34
+ "InvalidComponentInterfaceError",
35
+ "UnparseableAbiParamError",
36
+ "UnknownTransferPayloadSupplied",
37
+ "BudgetMustAuthorizeBoostCore",
38
+ "MustInitializeBudgetError",
39
+ "IncentiveNotCloneableError",
40
+ "NoEventActionStepsProvidedError",
41
+ "TooManyEventActionStepsProvidedError",
42
+ "ValidationAbiMissingError",
43
+ "FieldActionValidationError",
44
+ "DecodedArgsMalformedError",
45
+ "FieldValueUndefinedError",
46
+ "InvalidNumericalCriteriaError",
47
+ "FunctionDataDecodeError",
48
+ "FieldValueNotComparableError",
49
+ "UnrecognizedFilterTypeError",
50
+ "NoConnectedChainIdError",
51
+ "InvalidProtocolChainIdError",
52
+ "IncentiveCriteriaNotFoundError",
53
+ "NoMatchingLogsError",
54
+ "InvalidCriteriaTypeError",
55
+ "DecodedArgsError",
56
+ "PassthroughAuth",
57
+ "prepareBoostPayload",
58
+ "actionFromAddress",
59
+ "isEventActionPayloadSimple",
60
+ "prepareEventActionPayload",
61
+ "allowListFromAddress",
62
+ "prepareSimpleAllowListPayload",
63
+ "prepareSimpleDenyListPayload",
64
+ "budgetFromAddress",
65
+ "isFungibleTransfer",
66
+ "isERC1155TransferPayload",
67
+ "prepareTransfer",
68
+ "prepareManagedBudgetPayload",
69
+ "prepareAllowListIncentivePayload",
70
+ "prepareCGDAIncentivePayload",
71
+ "prepareERC20IncentivePayload",
72
+ "prepareERC20VariableIncentivePayload",
73
+ "prepareERC20VariableCriteriaIncentivePayload",
74
+ "incentiveFromAddress",
75
+ "preparePointsIncentivePayload",
76
+ "prepareSignerValidatorClaimDataPayload",
77
+ "prepareSignerValidatorInputParams",
78
+ "prepareSignerValidatorPayload",
79
+ "validatorFromAddress",
80
+ "bytes4",
81
+ "getDeployedContractAddress",
82
+ "awaitResult",
83
+ "assertValidAddressByChainId",
84
+ "prepareClaimPayload",
85
+ "prepareERC1155Payload",
86
+ "prepareERC1155Transfer",
87
+ "prepareFungiblePayload",
88
+ "prepareFungibleTransfer",
89
+ "prepareTransferPayload",
90
+ "BOOST_REGISTRY_ADDRESS",
91
+ "BOOST_REGISTRY_ADDRESSES",
92
+ "boostCoreAbi",
93
+ "boostRegistryAbi",
94
+ "BOOST_CORE_CLAIM_FEE",
95
+ "BOOST_CORE_ADDRESS",
96
+ "BOOST_CORE_ADDRESSES",
97
+ "ActionByComponentInterface",
98
+ "AllowListByComponentInterface",
99
+ "simpleAllowListAbi",
100
+ "LIST_MANAGER_ROLE",
101
+ "simpleDenyListAbi",
102
+ "BudgetByComponentInterface",
103
+ "managedBudgetAbi",
104
+ "rbacAbi",
105
+ "allowListIncentiveAbi",
106
+ "cgdaIncentiveAbi",
107
+ "erc20IncentiveAbi",
108
+ "erc20VariableIncentiveAbi",
109
+ "IncentiveByComponentInterface",
110
+ "pointsIncentiveAbi",
111
+ "signerValidatorAbi",
112
+ "ValidatorByComponentInterface",
113
+ "passthroughAuthAbi"
114
+ ]
115
+
116
+ describe("SDK exports", () => {
117
+ test(`should export all public API`, () => {
118
+ for(let exp of allExports) {
119
+ expect((SDK as any)[exp]).toBeDefined()
120
+ }
121
+ });
122
+ });
package/src/index.ts ADDED
@@ -0,0 +1,58 @@
1
+ export * from './BoostRegistry';
2
+ export * from './BoostCore';
3
+ export * from './Boost';
4
+
5
+ // Actions
6
+
7
+ export * from './Actions/Action';
8
+ // export * from './Actions/ContractAction';
9
+ // export * from './Actions/ERC721MintAction';
10
+ export * from './Actions/EventAction';
11
+
12
+ // AllowLists
13
+
14
+ export * from './AllowLists/AllowList';
15
+ export * from './AllowLists/SimpleAllowList';
16
+ export * from './AllowLists/SimpleDenyList';
17
+
18
+ // Budgets
19
+
20
+ export * from './Budgets/Budget';
21
+ // export * from './Budgets/SimpleBudget';
22
+ // export * from './Budgets/VestingBudget';
23
+ export * from './Budgets/ManagedBudget';
24
+
25
+ // Deployable
26
+
27
+ export * from './Deployable/Deployable';
28
+ export * from './Deployable/Contract';
29
+ export * from './Deployable/DeployableTarget';
30
+ export * from './Deployable/DeployableTargetWithRBAC';
31
+
32
+ // Incentives
33
+
34
+ export * from './Incentives/AllowListIncentive';
35
+ export * from './Incentives/CGDAIncentive';
36
+ export * from './Incentives/ERC20Incentive';
37
+ export * from './Incentives/ERC20VariableIncentive';
38
+ export * from './Incentives/ERC20VariableCriteriaIncentive';
39
+ // export * from './Incentives/ERC1155Incentive';
40
+ export * from './Incentives/Incentive';
41
+ export * from './Incentives/PointsIncentive';
42
+
43
+ // Validators
44
+
45
+ export * from './Validators/SignerValidator';
46
+ export * from './Validators/Validator';
47
+
48
+ // Extra
49
+
50
+ export * from './errors';
51
+ export * from './utils';
52
+ export * from './claiming';
53
+ export * from './transfers';
54
+
55
+ // Auth
56
+
57
+ export * from './Auth/Auth';
58
+ export * from './Auth/PassthroughAuth';
@@ -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 {Hex}
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
+ }
@@ -0,0 +1,44 @@
1
+ import { simulateMockErc20Mint, writeMockErc20Mint } from '@boostxyz/evm';
2
+ import { isAddress } from 'viem';
3
+ import { describe, expect, test } from 'vitest';
4
+ import { MockERC20 } from '@boostxyz/test/MockERC20';
5
+ import { defaultOptions } from '@boostxyz/test/helpers';
6
+ import { awaitResult, bytes4, getDeployedContractAddress } from './utils';
7
+
8
+ describe('bytes4', () => {
9
+ test('should return the bytes4 representation of a string', () => {
10
+ expect(bytes4('0xdeadbeef')).toBe('0xd4fd4e18');
11
+ expect(bytes4('deadbeef')).toBe('0x9f24c52e');
12
+ });
13
+ });
14
+
15
+ describe('getDeployedContractAddress', () => {
16
+ test('should return the address of a contract given a tx hash promise', async () => {
17
+ const hash = new MockERC20(defaultOptions, {}).deployRaw();
18
+ expect(
19
+ isAddress(await getDeployedContractAddress(defaultOptions.config, hash)),
20
+ ).toBe(true);
21
+ });
22
+ });
23
+
24
+ describe('awaitResult', () => {
25
+ test('should wait for a transaction receipt and return the simulated result', async () => {
26
+ const erc20 = new MockERC20(defaultOptions, {});
27
+ await erc20.deploy();
28
+ const { request, result } = await simulateMockErc20Mint(
29
+ defaultOptions.config,
30
+ {
31
+ address: erc20.assertValidAddress(),
32
+ args: [defaultOptions.account.address, 100n],
33
+ account: defaultOptions.account,
34
+ },
35
+ );
36
+ const hash = await writeMockErc20Mint(defaultOptions.config, request);
37
+ expect(
38
+ await awaitResult(
39
+ defaultOptions.config,
40
+ Promise.resolve({ hash, result }),
41
+ ),
42
+ ).toBe(undefined);
43
+ });
44
+ });