@boostxyz/sdk 0.0.0-alpha.10

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 (242) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +7 -0
  3. package/dist/Actions/Action.cjs +2 -0
  4. package/dist/Actions/Action.cjs.map +1 -0
  5. package/dist/Actions/Action.d.ts +31 -0
  6. package/dist/Actions/Action.d.ts.map +1 -0
  7. package/dist/Actions/Action.js +29 -0
  8. package/dist/Actions/Action.js.map +1 -0
  9. package/dist/Actions/ContractAction.d.ts +370 -0
  10. package/dist/Actions/ContractAction.d.ts.map +1 -0
  11. package/dist/Actions/ERC721MintAction.d.ts +513 -0
  12. package/dist/Actions/ERC721MintAction.d.ts.map +1 -0
  13. package/dist/Actions/EventAction.cjs +2 -0
  14. package/dist/Actions/EventAction.cjs.map +1 -0
  15. package/dist/Actions/EventAction.d.ts +694 -0
  16. package/dist/Actions/EventAction.d.ts.map +1 -0
  17. package/dist/Actions/EventAction.js +491 -0
  18. package/dist/Actions/EventAction.js.map +1 -0
  19. package/dist/AllowLists/AllowList.cjs +2 -0
  20. package/dist/AllowLists/AllowList.cjs.map +1 -0
  21. package/dist/AllowLists/AllowList.d.ts +32 -0
  22. package/dist/AllowLists/AllowList.d.ts.map +1 -0
  23. package/dist/AllowLists/AllowList.js +30 -0
  24. package/dist/AllowLists/AllowList.js.map +1 -0
  25. package/dist/AllowLists/SimpleAllowList.cjs +2 -0
  26. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
  27. package/dist/AllowLists/SimpleAllowList.d.ts +481 -0
  28. package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -0
  29. package/dist/AllowLists/SimpleAllowList.js +154 -0
  30. package/dist/AllowLists/SimpleAllowList.js.map +1 -0
  31. package/dist/AllowLists/SimpleDenyList.cjs +2 -0
  32. package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
  33. package/dist/AllowLists/SimpleDenyList.d.ts +335 -0
  34. package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -0
  35. package/dist/AllowLists/SimpleDenyList.js +115 -0
  36. package/dist/AllowLists/SimpleDenyList.js.map +1 -0
  37. package/dist/Auth/Auth.cjs +2 -0
  38. package/dist/Auth/Auth.cjs.map +1 -0
  39. package/dist/Auth/Auth.d.ts +10 -0
  40. package/dist/Auth/Auth.d.ts.map +1 -0
  41. package/dist/Auth/Auth.js +5 -0
  42. package/dist/Auth/Auth.js.map +1 -0
  43. package/dist/Auth/PassthroughAuth.cjs +2 -0
  44. package/dist/Auth/PassthroughAuth.cjs.map +1 -0
  45. package/dist/Auth/PassthroughAuth.d.ts +51 -0
  46. package/dist/Auth/PassthroughAuth.d.ts.map +1 -0
  47. package/dist/Auth/PassthroughAuth.js +39 -0
  48. package/dist/Auth/PassthroughAuth.js.map +1 -0
  49. package/dist/Boost.cjs +2 -0
  50. package/dist/Boost.cjs.map +1 -0
  51. package/dist/Boost.d.ts +234 -0
  52. package/dist/Boost.d.ts.map +1 -0
  53. package/dist/Boost.js +162 -0
  54. package/dist/Boost.js.map +1 -0
  55. package/dist/BoostCore.cjs +3 -0
  56. package/dist/BoostCore.cjs.map +1 -0
  57. package/dist/BoostCore.d.ts +498 -0
  58. package/dist/BoostCore.d.ts.map +1 -0
  59. package/dist/BoostCore.js +1153 -0
  60. package/dist/BoostCore.js.map +1 -0
  61. package/dist/BoostRegistry.cjs +2 -0
  62. package/dist/BoostRegistry.cjs.map +1 -0
  63. package/dist/BoostRegistry.d.ts +243 -0
  64. package/dist/BoostRegistry.d.ts.map +1 -0
  65. package/dist/BoostRegistry.js +262 -0
  66. package/dist/BoostRegistry.js.map +1 -0
  67. package/dist/Budgets/Budget.cjs +2 -0
  68. package/dist/Budgets/Budget.cjs.map +1 -0
  69. package/dist/Budgets/Budget.d.ts +31 -0
  70. package/dist/Budgets/Budget.d.ts.map +1 -0
  71. package/dist/Budgets/Budget.js +29 -0
  72. package/dist/Budgets/Budget.js.map +1 -0
  73. package/dist/Budgets/ManagedBudget.cjs +2 -0
  74. package/dist/Budgets/ManagedBudget.cjs.map +1 -0
  75. package/dist/Budgets/ManagedBudget.d.ts +1103 -0
  76. package/dist/Budgets/ManagedBudget.d.ts.map +1 -0
  77. package/dist/Budgets/ManagedBudget.js +516 -0
  78. package/dist/Budgets/ManagedBudget.js.map +1 -0
  79. package/dist/Budgets/SimpleBudget.d.ts +824 -0
  80. package/dist/Budgets/SimpleBudget.d.ts.map +1 -0
  81. package/dist/Budgets/VestingBudget.d.ts +778 -0
  82. package/dist/Budgets/VestingBudget.d.ts.map +1 -0
  83. package/dist/Deployable/Contract.cjs +2 -0
  84. package/dist/Deployable/Contract.cjs.map +1 -0
  85. package/dist/Deployable/Contract.d.ts +125 -0
  86. package/dist/Deployable/Contract.d.ts.map +1 -0
  87. package/dist/Deployable/Contract.js +150 -0
  88. package/dist/Deployable/Contract.js.map +1 -0
  89. package/dist/Deployable/Deployable.cjs +2 -0
  90. package/dist/Deployable/Deployable.cjs.map +1 -0
  91. package/dist/Deployable/Deployable.d.ts +161 -0
  92. package/dist/Deployable/Deployable.d.ts.map +1 -0
  93. package/dist/Deployable/Deployable.js +131 -0
  94. package/dist/Deployable/Deployable.js.map +1 -0
  95. package/dist/Deployable/DeployableTarget.cjs +2 -0
  96. package/dist/Deployable/DeployableTarget.cjs.map +1 -0
  97. package/dist/Deployable/DeployableTarget.d.ts +116 -0
  98. package/dist/Deployable/DeployableTarget.d.ts.map +1 -0
  99. package/dist/Deployable/DeployableTarget.js +132 -0
  100. package/dist/Deployable/DeployableTarget.js.map +1 -0
  101. package/dist/Incentives/AllowListIncentive.cjs +2 -0
  102. package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
  103. package/dist/Incentives/AllowListIncentive.d.ts +513 -0
  104. package/dist/Incentives/AllowListIncentive.d.ts.map +1 -0
  105. package/dist/Incentives/AllowListIncentive.js +201 -0
  106. package/dist/Incentives/AllowListIncentive.js.map +1 -0
  107. package/dist/Incentives/CGDAIncentive.cjs +2 -0
  108. package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
  109. package/dist/Incentives/CGDAIncentive.d.ts +644 -0
  110. package/dist/Incentives/CGDAIncentive.d.ts.map +1 -0
  111. package/dist/Incentives/CGDAIncentive.js +271 -0
  112. package/dist/Incentives/CGDAIncentive.js.map +1 -0
  113. package/dist/Incentives/ERC1155Incentive.d.ts +713 -0
  114. package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -0
  115. package/dist/Incentives/ERC20Incentive.cjs +2 -0
  116. package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
  117. package/dist/Incentives/ERC20Incentive.d.ts +666 -0
  118. package/dist/Incentives/ERC20Incentive.d.ts.map +1 -0
  119. package/dist/Incentives/ERC20Incentive.js +312 -0
  120. package/dist/Incentives/ERC20Incentive.js.map +1 -0
  121. package/dist/Incentives/ERC20VariableIncentive.d.ts +582 -0
  122. package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -0
  123. package/dist/Incentives/Incentive.cjs +2 -0
  124. package/dist/Incentives/Incentive.cjs.map +1 -0
  125. package/dist/Incentives/Incentive.d.ts +36 -0
  126. package/dist/Incentives/Incentive.d.ts.map +1 -0
  127. package/dist/Incentives/Incentive.js +299 -0
  128. package/dist/Incentives/Incentive.js.map +1 -0
  129. package/dist/Incentives/PointsIncentive.cjs +2 -0
  130. package/dist/Incentives/PointsIncentive.cjs.map +1 -0
  131. package/dist/Incentives/PointsIncentive.d.ts +659 -0
  132. package/dist/Incentives/PointsIncentive.d.ts.map +1 -0
  133. package/dist/Incentives/PointsIncentive.js +215 -0
  134. package/dist/Incentives/PointsIncentive.js.map +1 -0
  135. package/dist/Validators/SignerValidator.cjs +2 -0
  136. package/dist/Validators/SignerValidator.cjs.map +1 -0
  137. package/dist/Validators/SignerValidator.d.ts +745 -0
  138. package/dist/Validators/SignerValidator.d.ts.map +1 -0
  139. package/dist/Validators/SignerValidator.js +293 -0
  140. package/dist/Validators/SignerValidator.js.map +1 -0
  141. package/dist/Validators/Validator.cjs +2 -0
  142. package/dist/Validators/Validator.cjs.map +1 -0
  143. package/dist/Validators/Validator.d.ts +31 -0
  144. package/dist/Validators/Validator.d.ts.map +1 -0
  145. package/dist/Validators/Validator.js +27 -0
  146. package/dist/Validators/Validator.js.map +1 -0
  147. package/dist/claiming.cjs +2 -0
  148. package/dist/claiming.cjs.map +1 -0
  149. package/dist/claiming.d.ts +43 -0
  150. package/dist/claiming.d.ts.map +1 -0
  151. package/dist/claiming.js +17 -0
  152. package/dist/claiming.js.map +1 -0
  153. package/dist/componentInterfaces-CKCBwG16.cjs +2 -0
  154. package/dist/componentInterfaces-CKCBwG16.cjs.map +1 -0
  155. package/dist/componentInterfaces-DYkaxBda.js +13 -0
  156. package/dist/componentInterfaces-DYkaxBda.js.map +1 -0
  157. package/dist/errors.cjs +2 -0
  158. package/dist/errors.cjs.map +1 -0
  159. package/dist/errors.d.ts +441 -0
  160. package/dist/errors.d.ts.map +1 -0
  161. package/dist/errors.js +262 -0
  162. package/dist/errors.js.map +1 -0
  163. package/dist/generated-BDeDiaCK.js +4625 -0
  164. package/dist/generated-BDeDiaCK.js.map +1 -0
  165. package/dist/generated-wKBNvm48.cjs +3 -0
  166. package/dist/generated-wKBNvm48.cjs.map +1 -0
  167. package/dist/index.cjs +2 -0
  168. package/dist/index.cjs.map +1 -0
  169. package/dist/index.d.ts +25 -0
  170. package/dist/index.d.ts.map +1 -0
  171. package/dist/index.js +113 -0
  172. package/dist/index.js.map +1 -0
  173. package/dist/transfers.cjs +2 -0
  174. package/dist/transfers.cjs.map +1 -0
  175. package/dist/transfers.d.ts +198 -0
  176. package/dist/transfers.d.ts.map +1 -0
  177. package/dist/transfers.js +84 -0
  178. package/dist/transfers.js.map +1 -0
  179. package/dist/utils.cjs +2 -0
  180. package/dist/utils.cjs.map +1 -0
  181. package/dist/utils.d.ts +116 -0
  182. package/dist/utils.d.ts.map +1 -0
  183. package/dist/utils.js +30 -0
  184. package/dist/utils.js.map +1 -0
  185. package/package.json +211 -0
  186. package/src/Actions/Action.test.ts +75 -0
  187. package/src/Actions/Action.ts +61 -0
  188. package/src/Actions/ContractAction.test.ts +197 -0
  189. package/src/Actions/ContractAction.ts +301 -0
  190. package/src/Actions/ERC721MintAction.test.ts +112 -0
  191. package/src/Actions/ERC721MintAction.ts +292 -0
  192. package/src/Actions/EventAction.test.ts +205 -0
  193. package/src/Actions/EventAction.ts +811 -0
  194. package/src/AllowLists/AllowList.test.ts +64 -0
  195. package/src/AllowLists/AllowList.ts +60 -0
  196. package/src/AllowLists/SimpleAllowList.test.ts +52 -0
  197. package/src/AllowLists/SimpleAllowList.ts +284 -0
  198. package/src/AllowLists/SimpleDenyList.test.ts +52 -0
  199. package/src/AllowLists/SimpleDenyList.ts +227 -0
  200. package/src/Auth/Auth.ts +11 -0
  201. package/src/Auth/PassthroughAuth.test.ts +12 -0
  202. package/src/Auth/PassthroughAuth.ts +80 -0
  203. package/src/Boost.ts +290 -0
  204. package/src/BoostCore.test.ts +773 -0
  205. package/src/BoostCore.ts +1261 -0
  206. package/src/BoostRegistry.ts +467 -0
  207. package/src/Budgets/Budget.test.ts +27 -0
  208. package/src/Budgets/Budget.ts +61 -0
  209. package/src/Budgets/ManagedBudget.test.ts +154 -0
  210. package/src/Budgets/ManagedBudget.ts +796 -0
  211. package/src/Budgets/SimpleBudget.test.ts +152 -0
  212. package/src/Budgets/SimpleBudget.ts +564 -0
  213. package/src/Budgets/VestingBudget.test.ts +123 -0
  214. package/src/Budgets/VestingBudget.ts +602 -0
  215. package/src/Deployable/Contract.ts +229 -0
  216. package/src/Deployable/Deployable.ts +250 -0
  217. package/src/Deployable/DeployableTarget.ts +223 -0
  218. package/src/Incentives/AllowListIncentive.test.ts +143 -0
  219. package/src/Incentives/AllowListIncentive.ts +334 -0
  220. package/src/Incentives/CGDAIncentive.test.ts +132 -0
  221. package/src/Incentives/CGDAIncentive.ts +468 -0
  222. package/src/Incentives/ERC1155Incentive.test.ts +87 -0
  223. package/src/Incentives/ERC1155Incentive.ts +466 -0
  224. package/src/Incentives/ERC20Incentive.test.ts +130 -0
  225. package/src/Incentives/ERC20Incentive.ts +482 -0
  226. package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
  227. package/src/Incentives/ERC20VariableIncentive.ts +420 -0
  228. package/src/Incentives/Incentive.test.ts +92 -0
  229. package/src/Incentives/Incentive.ts +85 -0
  230. package/src/Incentives/PointsIncentive.test.ts +139 -0
  231. package/src/Incentives/PointsIncentive.ts +365 -0
  232. package/src/Validators/SignerValidator.test.ts +159 -0
  233. package/src/Validators/SignerValidator.ts +681 -0
  234. package/src/Validators/Validator.test.ts +21 -0
  235. package/src/Validators/Validator.ts +55 -0
  236. package/src/claiming.ts +56 -0
  237. package/src/errors.ts +542 -0
  238. package/src/index.test.ts +40 -0
  239. package/src/index.ts +53 -0
  240. package/src/transfers.ts +284 -0
  241. package/src/utils.test.ts +44 -0
  242. package/src/utils.ts +198 -0
package/dist/utils.js ADDED
@@ -0,0 +1,30 @@
1
+ import { waitForTransactionReceipt as n } from "@wagmi/core";
2
+ import { slice as s, isHex as I, keccak256 as c, toHex as d } from "viem";
3
+ import { NoContractAddressUponReceiptError as e } from "./errors.js";
4
+ function u(t) {
5
+ return s(I(t) ? c(t) : c(d(t)), 0, 4);
6
+ }
7
+ async function E(t, a, r) {
8
+ const o = await n(t, {
9
+ ...r,
10
+ hash: await a
11
+ });
12
+ if (!o.contractAddress)
13
+ throw new e(o);
14
+ return o.contractAddress;
15
+ }
16
+ async function N(t, a, r) {
17
+ const { hash: o, result: A } = await a;
18
+ return await n(t, {
19
+ ...r,
20
+ hash: o
21
+ }), A;
22
+ }
23
+ var i = /* @__PURE__ */ ((t) => (t[t.ACTION = 0] = "ACTION", t[t.ALLOW_LIST = 1] = "ALLOW_LIST", t[t.BUDGET = 2] = "BUDGET", t[t.INCENTIVE = 3] = "INCENTIVE", t[t.VALIDATOR = 4] = "VALIDATOR", t))(i || {});
24
+ export {
25
+ i as RegistryType,
26
+ N as awaitResult,
27
+ u as bytes4,
28
+ E as getDeployedContractAddress
29
+ };
30
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import {\n type Config,\n type ReadContractParameters,\n type WatchContractEventParameters,\n type WriteContractParameters,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport { NoContractAddressUponReceiptError } from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n WriteContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n ReadContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {unknown}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n"],"names":["bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","RegistryType"],"mappings":";;;AA2HO,SAASA,EAAOC,GAAe;AACpC,SAAOC,EAAMC,EAAMF,CAAK,IAAIG,EAAUH,CAAK,IAAIG,EAAUC,EAAMJ,CAAK,CAAC,GAAG,GAAG,CAAC;AAC9E;AAasB,eAAAK,EACpBC,GACAC,GACAC,GACA;AACM,QAAAC,IAAU,MAAMC,EAA0BJ,GAAQ;AAAA,IACtD,GAAGE;AAAA,IACH,MAAM,MAAMD;AAAA,EAAA,CACb;AACD,MAAI,CAACE,EAAQ;AACL,UAAA,IAAIE,EAAkCF,CAAO;AACrD,SAAOA,EAAQ;AACjB;AAsBsB,eAAAG,EACpBN,GACAO,GACAL,GACiB;AACjB,QAAM,EAAE,MAAAD,GAAM,QAAAO,EAAO,IAAI,MAAMD;AAC/B,eAAMH,EAA0BJ,GAAQ;AAAA,IACtC,GAAGE;AAAA,IACH,MAAAD;AAAA,EAAA,CACD,GACMO;AACT;AAQY,IAAAC,sBAAAA,OACVA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,aAAa,CAAb,IAAA,cACAA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aALUA,IAAAA,KAAA,CAAA,CAAA;"}
package/package.json ADDED
@@ -0,0 +1,211 @@
1
+ {
2
+ "name": "@boostxyz/sdk",
3
+ "version": "0.0.0-alpha.10",
4
+ "license": "GPL-3.0-or-later",
5
+ "type": "module",
6
+ "files": [
7
+ "dist",
8
+ "src"
9
+ ],
10
+ "repository": "https://github.com/rabbitholegg/boost-protocol",
11
+ "author": "Boost Team<boost-team@boost.xyz>",
12
+ "access": "public",
13
+ "private": false,
14
+ "browserslist": [
15
+ "node >=14",
16
+ "edge >=88",
17
+ "firefox >=78",
18
+ "chrome >=87",
19
+ "safari >=14"
20
+ ],
21
+ "main": "./dist/index.cjs",
22
+ "module": "./dist/index.js",
23
+ "types": "./dist/index.d.ts",
24
+ "typings": "./dist/index.d.ts",
25
+ "sideEffects": false,
26
+ "exports": {
27
+ ".": {
28
+ "require": "./dist/index.cjs",
29
+ "import": "./dist/index.js",
30
+ "node": "./dist/index.js",
31
+ "types": "./dist/index.d.ts"
32
+ },
33
+ "./errors": {
34
+ "require": "./dist/errors.cjs",
35
+ "import": "./dist/errors.js",
36
+ "node": "./dist/errors.js",
37
+ "types": "./dist/errors.d.ts"
38
+ },
39
+ "./utils": {
40
+ "require": "./dist/utils.cjs",
41
+ "import": "./dist/utils.js",
42
+ "node": "./dist/utils.js",
43
+ "types": "./dist/utils.d.ts"
44
+ },
45
+ "./claiming": {
46
+ "require": "./dist/claiming.cjs",
47
+ "import": "./dist/claiming.js",
48
+ "node": "./dist/claiming.js",
49
+ "types": "./dist/claiming.d.ts"
50
+ },
51
+ "./transfers": {
52
+ "require": "./dist/transfers.cjs",
53
+ "import": "./dist/transfers.js",
54
+ "node": "./dist/transfers.js",
55
+ "types": "./dist/transfers.d.ts"
56
+ },
57
+ "./Boost": {
58
+ "require": "./dist/Boost.cjs",
59
+ "import": "./dist/Boost.js",
60
+ "node": "./dist/Boost.js",
61
+ "types": "./dist/Boost.d.ts"
62
+ },
63
+ "./BoostRegistry": {
64
+ "require": "./dist/BoostRegistry.cjs",
65
+ "import": "./dist/BoostRegistry.js",
66
+ "node": "./dist/BoostRegistry.js",
67
+ "types": "./dist/BoostRegistry.d.ts"
68
+ },
69
+ "./BoostCore": {
70
+ "require": "./dist/BoostCore.cjs",
71
+ "import": "./dist/BoostCore.js",
72
+ "node": "./dist/BoostCore.js",
73
+ "types": "./dist/BoostCore.d.ts"
74
+ },
75
+ "./Auth/Auth": {
76
+ "require": "./dist/Auth/Auth.cjs",
77
+ "import": "./dist/Auth/Auth.js",
78
+ "node": "./dist/Auth/Auth.js",
79
+ "types": "./dist/Auth/Auth.d.ts"
80
+ },
81
+ "./Auth/PassthroughAuth": {
82
+ "require": "./dist/Auth/PassthroughAuth.cjs",
83
+ "import": "./dist/Auth/PassthroughAuth.js",
84
+ "node": "./dist/Auth/PassthroughAuth.js",
85
+ "types": "./dist/Auth/PassthroughAuth.d.ts"
86
+ },
87
+ "./Deployable/Deployable": {
88
+ "require": "./dist/Deployable/Deployable.cjs",
89
+ "import": "./dist/Deployable/Deployable.js",
90
+ "node": "./dist/Deployable/Deployable.js",
91
+ "types": "./dist/Deployable/Deployable.d.ts"
92
+ },
93
+ "./Deployable/DeployableTarget": {
94
+ "require": "./dist/Deployable/DeployableTarget.cjs",
95
+ "import": "./dist/Deployable/DeployableTarget.js",
96
+ "node": "./dist/Deployable/DeployableTarget.js",
97
+ "types": "./dist/Deployable/DeployableTarget.d.ts"
98
+ },
99
+ "./Deployable/Contract": {
100
+ "require": "./dist/Deployable/Contract.cjs",
101
+ "import": "./dist/Deployable/Contract.js",
102
+ "node": "./dist/Deployable/Contract.js",
103
+ "types": "./dist/Deployable/Contract.d.ts"
104
+ },
105
+ "./Actions/Action": {
106
+ "require": "./dist/Actions/Action.cjs",
107
+ "import": "./dist/Actions/Action.js",
108
+ "node": "./dist/Actions/Action.js",
109
+ "types": "./dist/Actions/Action.d.ts"
110
+ },
111
+ "./Actions/EventAction": {
112
+ "require": "./dist/Actions/EventAction.cjs",
113
+ "import": "./dist/Actions/EventAction.js",
114
+ "node": "./dist/Actions/EventAction.js",
115
+ "types": "./dist/Actions/EventAction.d.ts"
116
+ },
117
+ "./AllowLists/AllowList": {
118
+ "require": "./dist/AllowLists/AllowList.cjs",
119
+ "import": "./dist/AllowLists/AllowList.js",
120
+ "node": "./dist/AllowLists/AllowList.js",
121
+ "types": "./dist/AllowLists/AllowList.d.ts"
122
+ },
123
+ "./AllowLists/SimpleAllowList": {
124
+ "require": "./dist/AllowLists/SimpleAllowList.cjs",
125
+ "import": "./dist/AllowLists/SimpleAllowList.js",
126
+ "node": "./dist/AllowLists/SimpleAllowList.js",
127
+ "types": "./dist/AllowLists/SimpleAllowList.d.ts"
128
+ },
129
+ "./AllowLists/SimpleDenyList": {
130
+ "require": "./dist/AllowLists/SimpleDenyList.cjs",
131
+ "import": "./dist/AllowLists/SimpleDenyList.js",
132
+ "node": "./dist/AllowLists/SimpleDenyList.js",
133
+ "types": "./dist/AllowLists/SimpleDenyList.d.ts"
134
+ },
135
+ "./Budgets/Budget": {
136
+ "require": "./dist/Budgets/Budget.cjs",
137
+ "import": "./dist/Budgets/Budget.js",
138
+ "node": "./dist/Budgets/Budget.js",
139
+ "types": "./dist/Budgets/Budget.d.ts"
140
+ },
141
+ "./Budgets/ManagedBudget": {
142
+ "require": "./dist/Budgets/ManagedBudget.cjs",
143
+ "import": "./dist/Budgets/ManagedBudget.js",
144
+ "node": "./dist/Budgets/ManagedBudget.js",
145
+ "types": "./dist/Budgets/ManagedBudget.d.ts"
146
+ },
147
+ "./Incentives/AllowListIncentive": {
148
+ "require": "./dist/Incentives/AllowListIncentive.cjs",
149
+ "import": "./dist/Incentives/AllowListIncentive.js",
150
+ "node": "./dist/Incentives/AllowListIncentive.js",
151
+ "types": "./dist/Incentives/AllowListIncentive.d.ts"
152
+ },
153
+ "./Incentives/CGDAIncentive": {
154
+ "require": "./dist/Incentives/CGDAIncentive.cjs",
155
+ "import": "./dist/Incentives/CGDAIncentive.js",
156
+ "node": "./dist/Incentives/CGDAIncentive.js",
157
+ "types": "./dist/Incentives/CGDAIncentive.d.ts"
158
+ },
159
+ "./Incentives/ERC20Incentive": {
160
+ "require": "./dist/Incentives/ERC20Incentive.cjs",
161
+ "import": "./dist/Incentives/ERC20Incentive.js",
162
+ "node": "./dist/Incentives/ERC20Incentive.js",
163
+ "types": "./dist/Incentives/ERC20Incentive.d.ts"
164
+ },
165
+ "./Incentives/Incentive": {
166
+ "require": "./dist/Incentives/Incentive.cjs",
167
+ "import": "./dist/Incentives/Incentive.js",
168
+ "node": "./dist/Incentives/Incentive.js",
169
+ "types": "./dist/Incentives/Incentive.d.ts"
170
+ },
171
+ "./Incentives/PointsIncentive": {
172
+ "require": "./dist/Incentives/PointsIncentive.cjs",
173
+ "import": "./dist/Incentives/PointsIncentive.js",
174
+ "node": "./dist/Incentives/PointsIncentive.js",
175
+ "types": "./dist/Incentives/PointsIncentive.d.ts"
176
+ },
177
+ "./Validators/Validator": {
178
+ "require": "./dist/Validators/Validator.cjs",
179
+ "import": "./dist/Validators/Validator.js",
180
+ "node": "./dist/Validators/Validator.js",
181
+ "types": "./dist/Validators/Validator.d.ts"
182
+ },
183
+ "./Validators/SignerValidator": {
184
+ "require": "./dist/Validators/SignerValidator.cjs",
185
+ "import": "./dist/Validators/SignerValidator.js",
186
+ "node": "./dist/Validators/SignerValidator.js",
187
+ "types": "./dist/Validators/SignerValidator.d.ts"
188
+ }
189
+ },
190
+ "optionalDependencies": {
191
+ "@boostxyz/evm": "0.0.0-alpha.1",
192
+ "@boostxyz/signatures": "0.0.0-alpha.2"
193
+ },
194
+ "peerDependencies": {
195
+ "@wagmi/core": "2",
196
+ "viem": "2",
197
+ "abitype": "1"
198
+ },
199
+ "scripts": {
200
+ "build": "vite build && tsc --build --emitDeclarationOnly --declaration --declarationMap --force",
201
+ "lint:ci": "npx biome ci",
202
+ "lint": "npx biome check",
203
+ "bench": "vitest bench",
204
+ "bench:ci": "CI=true vitest bench",
205
+ "clean": "rm -rf dist",
206
+ "dev": "vite build --watch",
207
+ "test": "vitest dev",
208
+ "test:ci": "CI=true vitest --coverage",
209
+ "typedoc": "npx typedoc --sort required-first --sort visibility --sort kind"
210
+ }
211
+ }
@@ -0,0 +1,75 @@
1
+ import { selectors } from '@boostxyz/signatures/events';
2
+ import { loadFixture } from '@nomicfoundation/hardhat-toolbox-viem/network-helpers';
3
+ import type { Hex } from 'viem';
4
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
5
+ import type { MockERC721 } from '../../test/MockERC721';
6
+ import { accounts } from '../../test/accounts';
7
+ import {
8
+ type Fixtures,
9
+ defaultOptions,
10
+ deployFixtures,
11
+ fundErc721,
12
+ } from '../../test/helpers';
13
+ import { EventAction, actionFromAddress } from './Action';
14
+ import {
15
+ type EventActionPayloadSimple,
16
+ FilterType,
17
+ PrimitiveType,
18
+ SignatureType,
19
+ } from './EventAction';
20
+
21
+ let fixtures: Fixtures, erc721: MockERC721;
22
+
23
+ export function basicErc721TransferAction(
24
+ erc721: MockERC721,
25
+ ): EventActionPayloadSimple {
26
+ return {
27
+ actionClaimant: {
28
+ chainid: 31337,
29
+ signatureType: SignatureType.EVENT,
30
+ signature: selectors['Transfer(address,address,uint256)'] as Hex,
31
+ fieldIndex: 2,
32
+ targetContract: erc721.assertValidAddress(),
33
+ },
34
+ actionSteps: [
35
+ {
36
+ chainid: 31337,
37
+ signature: selectors['Transfer(address,address,uint256)'] as Hex,
38
+ signatureType: SignatureType.EVENT,
39
+ targetContract: erc721.assertValidAddress(),
40
+ actionParameter: {
41
+ filterType: FilterType.EQUAL,
42
+ fieldType: PrimitiveType.ADDRESS,
43
+ fieldIndex: 2,
44
+ filterData: accounts[1].account,
45
+ },
46
+ },
47
+ ],
48
+ };
49
+ }
50
+
51
+ export function cloneEventAction(fixtures: Fixtures, erc721: MockERC721) {
52
+ return function cloneEventAction() {
53
+ return fixtures.registry.clone(
54
+ crypto.randomUUID(),
55
+ fixtures.core.EventAction(basicErc721TransferAction(erc721)),
56
+ );
57
+ };
58
+ }
59
+
60
+ beforeAll(async () => {
61
+ fixtures = await loadFixture(deployFixtures);
62
+ });
63
+
64
+ describe('Action', () => {
65
+ beforeEach(async () => {
66
+ erc721 = await loadFixture(fundErc721(defaultOptions));
67
+ });
68
+
69
+ test('can automatically instantiate EventAction given an address', async () => {
70
+ const _action = await loadFixture(cloneEventAction(fixtures, erc721));
71
+ expect(
72
+ await actionFromAddress(defaultOptions, _action.assertValidAddress()),
73
+ ).toBeInstanceOf(EventAction);
74
+ });
75
+ });
@@ -0,0 +1,61 @@
1
+ import { aActionAbi } from '@boostxyz/evm';
2
+ import { AEventAction } from '@boostxyz/evm/deploys/componentInterfaces.json';
3
+ import { readContract } from '@wagmi/core';
4
+ import type { Address, Hex } from 'viem';
5
+ import type { DeployableOptions } from '../Deployable/Deployable';
6
+ import { InvalidComponentInterfaceError } from '../errors';
7
+ import { EventAction } from './EventAction';
8
+
9
+ export {
10
+ // ContractAction,
11
+ // ERC721MintAction,
12
+ EventAction,
13
+ };
14
+
15
+ /**
16
+ * A union type representing all valid protocol Action implementations
17
+ *
18
+ * @export
19
+ * @typedef {Action}
20
+ */
21
+ export type Action = EventAction; // | ContractAction | ERC721MintAction
22
+
23
+ /**
24
+ * A map of Action component interfaces to their constructors.
25
+ *
26
+ * @type {{ "0x7687b0ed": EventAction; }}
27
+ */
28
+ export const ActionByComponentInterface = {
29
+ // ['0x6c3129aa']: ContractAction,
30
+ // ['0x97e083eb']: ERC721MintAction,
31
+ [AEventAction as Hex]: EventAction,
32
+ };
33
+
34
+ /**
35
+ * A function that will read a contract's component interface using `getComponentInterface` and return the correct instantiated instance.
36
+ *
37
+ * @export
38
+ * @async
39
+ * @param {DeployableOptions} options
40
+ * @param {Address} address
41
+ * @returns {Promise<EventAction>}
42
+ * @throws {@link InvalidComponentInterfaceError}
43
+ */
44
+ export async function actionFromAddress(
45
+ options: DeployableOptions,
46
+ address: Address,
47
+ ) {
48
+ const interfaceId = (await readContract(options.config, {
49
+ abi: aActionAbi,
50
+ functionName: 'getComponentInterface',
51
+ address,
52
+ })) as keyof typeof ActionByComponentInterface;
53
+ const Ctor = ActionByComponentInterface[interfaceId];
54
+ if (!Ctor) {
55
+ throw new InvalidComponentInterfaceError(
56
+ Object.keys(ActionByComponentInterface) as Hex[],
57
+ interfaceId as Hex,
58
+ );
59
+ }
60
+ return new Ctor(options, address);
61
+ }
@@ -0,0 +1,197 @@
1
+ import { mockErc20Abi, readMockErc20BalanceOf } from '@boostxyz/evm';
2
+ import { loadFixture } from '@nomicfoundation/hardhat-network-helpers';
3
+ import {
4
+ ContractFunctionExecutionError,
5
+ encodeAbiParameters,
6
+ encodeFunctionData,
7
+ isAddress,
8
+ parseEther,
9
+ toFunctionSelector,
10
+ zeroAddress,
11
+ } from 'viem';
12
+ import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
13
+ import type { MockERC20 } from '../../test/MockERC20';
14
+ import { accounts } from '../../test/accounts';
15
+ import {
16
+ type Fixtures,
17
+ defaultOptions,
18
+ deployFixtures,
19
+ fundErc20,
20
+ } from '../../test/helpers';
21
+ import { ContractAction } from './ContractAction';
22
+
23
+ let fixtures: Fixtures, erc20: MockERC20;
24
+
25
+ beforeAll(async () => {
26
+ fixtures = await loadFixture(deployFixtures);
27
+ });
28
+
29
+ const mintPayableSelector = toFunctionSelector(
30
+ 'function mintPayable(address to, uint256 amount)',
31
+ );
32
+
33
+ const mintSelector = toFunctionSelector(
34
+ 'function mint(address to, uint256 amount)',
35
+ );
36
+
37
+ function payableContractAction(fixtures: Fixtures, erc20: MockERC20) {
38
+ return function payableContractAction() {
39
+ return fixtures.registry.clone(
40
+ crypto.randomUUID(),
41
+ fixtures.core.ContractAction({
42
+ chainId: BigInt(31_337),
43
+ target: erc20.assertValidAddress(),
44
+ selector: mintPayableSelector,
45
+ value: parseEther('0.1'),
46
+ }),
47
+ );
48
+ };
49
+ }
50
+
51
+ function nonPayableAction(fixtures: Fixtures, erc20: MockERC20) {
52
+ return function nonPayableAction() {
53
+ return fixtures.registry.clone(
54
+ crypto.randomUUID(),
55
+ fixtures.core.ContractAction({
56
+ chainId: BigInt(31_337),
57
+ target: erc20.assertValidAddress(),
58
+ selector: mintSelector,
59
+ value: 0n,
60
+ }),
61
+ );
62
+ };
63
+ }
64
+
65
+ function otherAction(fixtures: Fixtures, erc20: MockERC20) {
66
+ return function nonPayableAction() {
67
+ return fixtures.registry.clone(
68
+ crypto.randomUUID(),
69
+ fixtures.core.ContractAction({
70
+ chainId: BigInt(31_337) + 1n,
71
+ target: erc20.assertValidAddress(),
72
+ selector: mintSelector,
73
+ value: parseEther('0.1'),
74
+ }),
75
+ );
76
+ };
77
+ }
78
+
79
+ describe.skip('ContractAction', () => {
80
+ beforeEach(async () => {
81
+ erc20 = await loadFixture(fundErc20(defaultOptions));
82
+ });
83
+
84
+ test('can successfully be deployed', async () => {
85
+ const action = new ContractAction(defaultOptions, {
86
+ chainId: BigInt(31_337),
87
+ target: zeroAddress,
88
+ selector: '0xdeadbeef',
89
+ value: 2n,
90
+ });
91
+ await action.deploy();
92
+ expect(isAddress(action.assertValidAddress())).toBe(true);
93
+ });
94
+
95
+ test('can read chain id', async () => {
96
+ const action = await loadFixture(payableContractAction(fixtures, erc20));
97
+ expect(await action.chainId()).toBe(BigInt(31_337));
98
+ });
99
+
100
+ test('can read target', async () => {
101
+ const action = await loadFixture(payableContractAction(fixtures, erc20));
102
+ expect((await action.target()).toLowerCase()).toBe(
103
+ erc20.assertValidAddress().toLowerCase(),
104
+ );
105
+ });
106
+
107
+ test('can read selector', async () => {
108
+ const action = await loadFixture(payableContractAction(fixtures, erc20));
109
+ expect(await action.selector()).toBe(mintPayableSelector);
110
+ });
111
+
112
+ test('can read value', async () => {
113
+ const action = await loadFixture(payableContractAction(fixtures, erc20));
114
+ expect(await action.value()).toBe(parseEther('0.1'));
115
+ });
116
+
117
+ test('prepare will properly encode execution payload', async () => {
118
+ const action = await loadFixture(payableContractAction(fixtures, erc20));
119
+ const { account } = accounts[1];
120
+ const payload = await action.prepare(
121
+ encodeAbiParameters(
122
+ [
123
+ { type: 'address', name: 'address' },
124
+ { type: 'uint256', name: 'value' },
125
+ ],
126
+ [account, parseEther('100')],
127
+ ),
128
+ );
129
+ expect(payload).toBe(
130
+ encodeFunctionData({
131
+ abi: mockErc20Abi,
132
+ functionName: 'mintPayable',
133
+ args: [account, parseEther('100')],
134
+ }),
135
+ );
136
+ });
137
+
138
+ test('payable execute', async () => {
139
+ const action = await loadFixture(payableContractAction(fixtures, erc20));
140
+ const { account } = accounts[1];
141
+ await action.execute(
142
+ encodeAbiParameters(
143
+ [
144
+ { type: 'address', name: 'to' },
145
+ { type: 'uint256', name: 'amount' },
146
+ ],
147
+ [account, parseEther('0.1')],
148
+ ),
149
+ { value: parseEther('0.1') },
150
+ );
151
+ expect(
152
+ await readMockErc20BalanceOf(defaultOptions.config, {
153
+ address: erc20.assertValidAddress(),
154
+ args: [account],
155
+ }),
156
+ ).toBe(parseEther('0.1'));
157
+ });
158
+
159
+ test('nonpayable execute', async () => {
160
+ const action = await loadFixture(nonPayableAction(fixtures, erc20));
161
+ const { account } = accounts[1];
162
+ const [success] = await action.execute(
163
+ encodeAbiParameters(
164
+ [
165
+ { type: 'address', name: 'to' },
166
+ { type: 'uint256', name: 'amount' },
167
+ ],
168
+ [account, parseEther('100')],
169
+ ),
170
+ );
171
+ expect(success).toBe(true);
172
+ expect(
173
+ await readMockErc20BalanceOf(defaultOptions.config, {
174
+ address: erc20.assertValidAddress(),
175
+ args: [account],
176
+ }),
177
+ ).toBe(parseEther('100'));
178
+ });
179
+
180
+ test('different chain id should throw', async () => {
181
+ const action = await loadFixture(otherAction(fixtures, erc20));
182
+ const { account } = accounts[1];
183
+ try {
184
+ await action.execute(
185
+ encodeAbiParameters(
186
+ [
187
+ { type: 'address', name: 'to' },
188
+ { type: 'uint256', name: 'amount' },
189
+ ],
190
+ [account, parseEther('100')],
191
+ ),
192
+ );
193
+ } catch (e) {
194
+ expect(e).toBeInstanceOf(ContractFunctionExecutionError);
195
+ }
196
+ });
197
+ });