@boostxyz/sdk 0.0.0-alpha.17 → 0.0.0-alpha.19

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 (205) hide show
  1. package/dist/Actions/Action.cjs +1 -1
  2. package/dist/Actions/Action.cjs.map +1 -1
  3. package/dist/Actions/Action.js +13 -13
  4. package/dist/Actions/ContractAction.d.ts +9 -9
  5. package/dist/Actions/ContractAction.d.ts.map +1 -1
  6. package/dist/Actions/ERC721MintAction.d.ts +12 -12
  7. package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
  8. package/dist/Actions/EventAction.cjs +1 -1
  9. package/dist/Actions/EventAction.cjs.map +1 -1
  10. package/dist/Actions/EventAction.d.ts +32 -49
  11. package/dist/Actions/EventAction.d.ts.map +1 -1
  12. package/dist/Actions/EventAction.js +13 -962
  13. package/dist/Actions/EventAction.js.map +1 -1
  14. package/dist/AllowLists/AllowList.cjs +1 -1
  15. package/dist/AllowLists/AllowList.js +3 -3
  16. package/dist/AllowLists/SimpleAllowList.cjs +1 -1
  17. package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
  18. package/dist/AllowLists/SimpleAllowList.d.ts +5 -5
  19. package/dist/AllowLists/SimpleAllowList.js +24 -24
  20. package/dist/AllowLists/SimpleAllowList.js.map +1 -1
  21. package/dist/AllowLists/SimpleDenyList.cjs +1 -1
  22. package/dist/AllowLists/SimpleDenyList.d.ts +6 -6
  23. package/dist/AllowLists/SimpleDenyList.js +3 -3
  24. package/dist/Auth/PassthroughAuth.cjs +1 -1
  25. package/dist/Auth/PassthroughAuth.js +1 -1
  26. package/dist/Boost.cjs.map +1 -1
  27. package/dist/Boost.d.ts +18 -0
  28. package/dist/Boost.d.ts.map +1 -1
  29. package/dist/Boost.js.map +1 -1
  30. package/dist/BoostCore-BiPwp6SR.cjs +3 -0
  31. package/dist/BoostCore-BiPwp6SR.cjs.map +1 -0
  32. package/dist/BoostCore-kwoUw7YE.js +1477 -0
  33. package/dist/BoostCore-kwoUw7YE.js.map +1 -0
  34. package/dist/BoostCore.cjs +1 -2
  35. package/dist/BoostCore.cjs.map +1 -1
  36. package/dist/BoostCore.d.ts +86 -36
  37. package/dist/BoostCore.d.ts.map +1 -1
  38. package/dist/BoostCore.js +29 -1273
  39. package/dist/BoostCore.js.map +1 -1
  40. package/dist/BoostRegistry.cjs +1 -1
  41. package/dist/BoostRegistry.cjs.map +1 -1
  42. package/dist/BoostRegistry.d.ts +25 -19
  43. package/dist/BoostRegistry.d.ts.map +1 -1
  44. package/dist/BoostRegistry.js +30 -29
  45. package/dist/BoostRegistry.js.map +1 -1
  46. package/dist/Budgets/Budget.cjs +1 -1
  47. package/dist/Budgets/Budget.js +2 -2
  48. package/dist/Budgets/ManagedBudget.cjs +1 -1
  49. package/dist/Budgets/ManagedBudget.cjs.map +1 -1
  50. package/dist/Budgets/ManagedBudget.d.ts +18 -18
  51. package/dist/Budgets/ManagedBudget.js +48 -48
  52. package/dist/Budgets/ManagedBudget.js.map +1 -1
  53. package/dist/Budgets/VestingBudget.d.ts +23 -23
  54. package/dist/Deployable/Contract.cjs +1 -1
  55. package/dist/Deployable/Contract.cjs.map +1 -1
  56. package/dist/Deployable/Contract.d.ts +4 -5
  57. package/dist/Deployable/Contract.d.ts.map +1 -1
  58. package/dist/Deployable/Contract.js +4 -5
  59. package/dist/Deployable/Contract.js.map +1 -1
  60. package/dist/Deployable/Deployable.cjs.map +1 -1
  61. package/dist/Deployable/Deployable.d.ts +1 -1
  62. package/dist/Deployable/Deployable.js +1 -1
  63. package/dist/Deployable/Deployable.js.map +1 -1
  64. package/dist/Deployable/DeployableTarget.cjs +1 -1
  65. package/dist/Deployable/DeployableTarget.cjs.map +1 -1
  66. package/dist/Deployable/DeployableTarget.d.ts +5 -5
  67. package/dist/Deployable/DeployableTarget.js +6 -6
  68. package/dist/Deployable/DeployableTarget.js.map +1 -1
  69. package/dist/Deployable/DeployableTargetWithRBAC.cjs +1 -1
  70. package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -1
  71. package/dist/Deployable/DeployableTargetWithRBAC.d.ts +15 -15
  72. package/dist/Deployable/DeployableTargetWithRBAC.js +33 -33
  73. package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -1
  74. package/dist/EventAction-D5tnm00s.js +1355 -0
  75. package/dist/EventAction-D5tnm00s.js.map +1 -0
  76. package/dist/EventAction-DBDRaG4A.cjs +2 -0
  77. package/dist/EventAction-DBDRaG4A.cjs.map +1 -0
  78. package/dist/{Incentive-DJf-vdyL.js → Incentive-Bp8Sez7M.js} +61 -62
  79. package/dist/Incentive-Bp8Sez7M.js.map +1 -0
  80. package/dist/{Incentive-DNwROd1r.cjs → Incentive-Djnzseoj.cjs} +2 -2
  81. package/dist/Incentive-Djnzseoj.cjs.map +1 -0
  82. package/dist/Incentives/AllowListIncentive.cjs +1 -1
  83. package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
  84. package/dist/Incentives/AllowListIncentive.d.ts +12 -12
  85. package/dist/Incentives/AllowListIncentive.js +19 -19
  86. package/dist/Incentives/AllowListIncentive.js.map +1 -1
  87. package/dist/Incentives/CGDAIncentive.cjs +1 -1
  88. package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
  89. package/dist/Incentives/CGDAIncentive.d.ts +15 -15
  90. package/dist/Incentives/CGDAIncentive.js +18 -18
  91. package/dist/Incentives/CGDAIncentive.js.map +1 -1
  92. package/dist/Incentives/ERC1155Incentive.d.ts +30 -30
  93. package/dist/Incentives/ERC20Incentive.cjs +1 -1
  94. package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
  95. package/dist/Incentives/ERC20Incentive.d.ts +23 -23
  96. package/dist/Incentives/ERC20Incentive.js +25 -25
  97. package/dist/Incentives/ERC20Incentive.js.map +1 -1
  98. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
  99. package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
  100. package/dist/Incentives/ERC20VariableIncentive.d.ts +19 -19
  101. package/dist/Incentives/Incentive.cjs +1 -1
  102. package/dist/Incentives/Incentive.d.ts +3 -3
  103. package/dist/Incentives/Incentive.d.ts.map +1 -1
  104. package/dist/Incentives/Incentive.js +3 -3
  105. package/dist/Incentives/PointsIncentive.cjs +1 -1
  106. package/dist/Incentives/PointsIncentive.cjs.map +1 -1
  107. package/dist/Incentives/PointsIncentive.d.ts +14 -14
  108. package/dist/Incentives/PointsIncentive.js +21 -21
  109. package/dist/Incentives/PointsIncentive.js.map +1 -1
  110. package/dist/{SimpleDenyList-DMlUkmAn.cjs → SimpleDenyList-BwfNjRsg.cjs} +2 -2
  111. package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
  112. package/dist/{SimpleDenyList-DvUvmOeE.js → SimpleDenyList-Cn5WpNn0.js} +9 -9
  113. package/dist/SimpleDenyList-Cn5WpNn0.js.map +1 -0
  114. package/dist/Validators/SignerValidator.cjs +1 -1
  115. package/dist/Validators/SignerValidator.cjs.map +1 -1
  116. package/dist/Validators/SignerValidator.d.ts +14 -14
  117. package/dist/Validators/SignerValidator.js +19 -19
  118. package/dist/Validators/SignerValidator.js.map +1 -1
  119. package/dist/Validators/Validator.cjs +1 -1
  120. package/dist/Validators/Validator.cjs.map +1 -1
  121. package/dist/Validators/Validator.d.ts +1 -1
  122. package/dist/Validators/Validator.js +6 -6
  123. package/dist/Validators/Validator.js.map +1 -1
  124. package/dist/claiming.cjs.map +1 -1
  125. package/dist/claiming.d.ts +1 -1
  126. package/dist/claiming.js.map +1 -1
  127. package/dist/componentInterfaces-D09mhzxO.cjs +2 -0
  128. package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
  129. package/dist/componentInterfaces-RXBMI5yH.js +14 -0
  130. package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
  131. package/dist/deployments-BM42vImE.js +43 -0
  132. package/dist/deployments-BM42vImE.js.map +1 -0
  133. package/dist/deployments-CMdF5uEC.cjs +2 -0
  134. package/dist/deployments-CMdF5uEC.cjs.map +1 -0
  135. package/dist/deployments.json +15 -12
  136. package/dist/errors.cjs +1 -1
  137. package/dist/errors.cjs.map +1 -1
  138. package/dist/errors.d.ts +132 -0
  139. package/dist/errors.d.ts.map +1 -1
  140. package/dist/errors.js +122 -36
  141. package/dist/errors.js.map +1 -1
  142. package/dist/generated-B0tk-c9b.cjs +3 -0
  143. package/dist/generated-B0tk-c9b.cjs.map +1 -0
  144. package/dist/{generated-C_7Jx3YG.js → generated-B7VaSah4.js} +631 -343
  145. package/dist/generated-B7VaSah4.js.map +1 -0
  146. package/dist/index.cjs +1 -1
  147. package/dist/index.d.ts +1 -0
  148. package/dist/index.d.ts.map +1 -1
  149. package/dist/index.js +135 -126
  150. package/dist/transfers.cjs.map +1 -1
  151. package/dist/transfers.d.ts +1 -1
  152. package/dist/transfers.js.map +1 -1
  153. package/dist/utils.cjs.map +1 -1
  154. package/dist/utils.d.ts +1 -1
  155. package/dist/utils.js.map +1 -1
  156. package/package.json +5 -5
  157. package/src/Actions/ContractAction.ts +9 -10
  158. package/src/Actions/ERC721MintAction.ts +12 -13
  159. package/src/Actions/EventAction.test.ts +45 -54
  160. package/src/Actions/EventAction.ts +100 -100
  161. package/src/AllowLists/SimpleAllowList.ts +5 -5
  162. package/src/AllowLists/SimpleDenyList.ts +6 -6
  163. package/src/Boost.ts +19 -0
  164. package/src/BoostCore.test.ts +117 -1
  165. package/src/BoostCore.ts +121 -57
  166. package/src/BoostRegistry.ts +29 -21
  167. package/src/Budgets/ManagedBudget.ts +18 -18
  168. package/src/Budgets/VestingBudget.ts +23 -23
  169. package/src/Deployable/Contract.ts +4 -5
  170. package/src/Deployable/Deployable.ts +1 -1
  171. package/src/Deployable/DeployableTarget.ts +5 -5
  172. package/src/Deployable/DeployableTargetWithRBAC.ts +15 -15
  173. package/src/Incentives/AllowListIncentive.ts +12 -12
  174. package/src/Incentives/CGDAIncentive.ts +15 -15
  175. package/src/Incentives/ERC1155Incentive.ts +26 -26
  176. package/src/Incentives/ERC20Incentive.ts +23 -23
  177. package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
  178. package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
  179. package/src/Incentives/ERC20VariableIncentive.ts +19 -19
  180. package/src/Incentives/Incentive.ts +6 -5
  181. package/src/Incentives/PointsIncentive.test.ts +21 -21
  182. package/src/Incentives/PointsIncentive.ts +14 -14
  183. package/src/Validators/SignerValidator.ts +14 -14
  184. package/src/Validators/Validator.ts +1 -1
  185. package/src/claiming.ts +1 -1
  186. package/src/errors.ts +165 -0
  187. package/src/index.test.ts +117 -33
  188. package/src/index.ts +1 -0
  189. package/src/transfers.ts +1 -1
  190. package/src/utils.ts +1 -1
  191. package/dist/Incentive-DJf-vdyL.js.map +0 -1
  192. package/dist/Incentive-DNwROd1r.cjs.map +0 -1
  193. package/dist/SimpleDenyList-DMlUkmAn.cjs.map +0 -1
  194. package/dist/SimpleDenyList-DvUvmOeE.js.map +0 -1
  195. package/dist/componentInterfaces-BPVR_Ykd.js +0 -13
  196. package/dist/componentInterfaces-BPVR_Ykd.js.map +0 -1
  197. package/dist/componentInterfaces-BfppSIl4.cjs +0 -2
  198. package/dist/componentInterfaces-BfppSIl4.cjs.map +0 -1
  199. package/dist/deployments-BvFcK_eR.js +0 -40
  200. package/dist/deployments-BvFcK_eR.js.map +0 -1
  201. package/dist/deployments-Ho4PnGCS.cjs +0 -2
  202. package/dist/deployments-Ho4PnGCS.cjs.map +0 -1
  203. package/dist/generated-CMQ6ZC2_.cjs +0 -3
  204. package/dist/generated-CMQ6ZC2_.cjs.map +0 -1
  205. package/dist/generated-C_7Jx3YG.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"ManagedBudget.js","sources":["../../src/Budgets/ManagedBudget.ts"],"sourcesContent":["import {\n managedBudgetAbi,\n readManagedBudgetAvailable,\n readManagedBudgetDistributed,\n readManagedBudgetHasAllRoles,\n readManagedBudgetHasAnyRole,\n readManagedBudgetIsAuthorized,\n readManagedBudgetOwner,\n readManagedBudgetRolesOf,\n readManagedBudgetTotal,\n simulateManagedBudgetAllocate,\n simulateManagedBudgetClawback,\n simulateManagedBudgetDisburse,\n simulateManagedBudgetDisburseBatch,\n simulateManagedBudgetGrantRoles,\n simulateManagedBudgetRevokeRoles,\n simulateManagedBudgetSetAuthorized,\n writeManagedBudgetAllocate,\n writeManagedBudgetClawback,\n writeManagedBudgetDisburse,\n writeManagedBudgetDisburseBatch,\n writeManagedBudgetGrantRoles,\n writeManagedBudgetRevokeRoles,\n writeManagedBudgetSetAuthorized,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/ManagedBudget.sol/ManagedBudget.json';\nimport { getAccount } from '@wagmi/core';\nimport {\n type Address,\n type ContractEventName,\n type Hex,\n encodeAbiParameters,\n parseAbiParameters,\n zeroAddress,\n} from 'viem';\nimport { ManagedBudget as ManagedBudgetBases } from '../../dist/deployments.json';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';\nimport {\n DeployableUnknownOwnerProvidedError,\n UnknownTransferPayloadSupplied,\n} from '../errors';\nimport {\n type ERC1155TransferPayload,\n type FungibleTransferPayload,\n prepareERC1155Transfer,\n prepareFungibleTransfer,\n} from '../transfers';\nimport {\n type GenericLog,\n type ReadParams,\n RegistryType,\n type WriteParams,\n} from '../utils';\nexport { managedBudgetAbi };\nexport type { ERC1155TransferPayload, FungibleTransferPayload };\n\n/**\n * The object representation of a `ManagedBudgetPayload.InitPayload`\n *\n * @export\n * @interface ManagedBudgetPayload\n * @typedef {ManagedBudgetPayload}\n */\nexport interface ManagedBudgetPayload {\n /**\n * The budget's owner\n *\n * @type {Address}\n */\n owner: Address;\n /**\n * List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.\n *\n * @type {Address[]}\n */\n authorized: Address[];\n /**\n * List of roles to assign to the corresponding account by index.\n *\n * @type {ManagedBudgetRoles[]}\n */\n roles: ManagedBudgetRoles[];\n}\n\n/**\n * Enum representing available roles for use in the `ManagedBudget`.\n * `MANAGER` can disburse funds.\n * `ADMIN` can additionally manage authorized users on the budget.\n *\n * @export\n * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}\n * @enum {bigint}\n */\nexport enum ManagedBudgetRoles {\n //@ts-expect-error ts doesn't like bigint enum values\n MANAGER = 1n,\n //@ts-expect-error ts doesn't like bigint enum values\n ADMIN = 2n,\n}\n\n/**\n * A generic `viem.Log` event with support for `ManagedBudget` event types.\n *\n * @export\n * @typedef {ManagedBudgetLog}\n * @template {ContractEventName<typeof managedBudgetAbi>} [event=ContractEventName<\n * typeof managedBudgetAbi\n * >]\n */\nexport type ManagedBudgetLog<\n event extends ContractEventName<typeof managedBudgetAbi> = ContractEventName<\n typeof managedBudgetAbi\n >,\n> = GenericLog<typeof managedBudgetAbi, event>;\n\n/**\n * Typeguard to determine if a transfer payload is a Fungible Transfer\n *\n * @export\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @returns {transfer is FungibleTransferPayload}\n */\nexport function isFungibleTransfer(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n): transfer is FungibleTransferPayload {\n return (transfer as ERC1155TransferPayload).tokenId === undefined;\n}\n\n/**\n * Typeguard to determine if a transfer payload is an ERC1155 Transfer\n *\n * @export\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @returns {transfer is ERC1155TransferPayload}\n */\nexport function isERC1155TransferPayload(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n): transfer is ERC1155TransferPayload {\n return (transfer as ERC1155TransferPayload).tokenId !== undefined;\n}\n\n/**\n * Given either a Fungible transfer, or ERC1155 transfer, will properly encode parameters for transfers, claims, disbursements, allocations, etc.\n *\n * @export\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @returns {*}\n * @throws {@link UnknownTransferPayloadSupplied}\n */\nexport function prepareTransfer(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n) {\n if (isFungibleTransfer(transfer)) {\n return prepareFungibleTransfer(transfer);\n }\n if (isERC1155TransferPayload(transfer)) {\n return prepareERC1155Transfer(transfer);\n }\n throw new UnknownTransferPayloadSupplied(transfer);\n}\n\n/**\n * A minimal budget implementation that simply holds and distributes tokens (ERC20-like and native)\n * This type of budget supports ETH, ERC20, and ERC1155 assets only\n *\n * @export\n * @class ManagedBudget\n * @typedef {ManagedBudget}\n * @extends {DeployableTargetWithRBAC<ManagedBudgetPayload>}\n */\nexport class ManagedBudget extends DeployableTargetWithRBAC<\n ManagedBudgetPayload,\n typeof managedBudgetAbi\n> {\n /**\n * @inheritdoc\n *\n * @public\n * @readonly\n * @type {*}\n */\n public override readonly abi = managedBudgetAbi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n ...(ManagedBudgetBases as Record<number, Address>),\n };\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {RegistryType}\n */\n public static override registryType: RegistryType = RegistryType.BUDGET;\n\n /**\n * Allocates assets to the budget.\n * The caller must have already approved the contract to transfer the asset\n * If the asset transfer fails, the allocation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams<typeof managedBudgetAbi, 'allocate'>} [params]\n * @returns {Promise<boolean>} - True if the allocation was successful\n */\n public async allocate(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'allocate'>,\n ) {\n return await this.awaitResult(this.allocateRaw(transfer, params));\n }\n\n /**\n * Allocates assets to the budget.\n * The caller must have already approved the contract to transfer the asset\n * If the asset transfer fails, the allocation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams<typeof managedBudgetAbi, 'allocate'>} [params]\n * @returns {Promise<boolean>} - True if the allocation was successful\n */\n public async allocateRaw(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'allocate'>,\n ) {\n const { request, result } = await simulateManagedBudgetAllocate(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareTransfer(transfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetAllocate(this._config, request);\n return { hash, result };\n }\n\n /**\n * Clawbacks assets from the budget.\n * Only the owner can directly clawback assets from the budget\n * If the amount is zero, the entire balance of the asset will be transferred to the receiver\n * If the asset transfer fails, the reclamation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams<typeof managedBudgetAbi, 'clawback'>} [params]\n * @returns {Promise<boolean>} - True if the request was successful\n */\n public async clawback(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'clawback'>,\n ) {\n return await this.awaitResult(this.clawbackRaw(transfer, params));\n }\n\n /**\n * Clawbacks assets from the budget.\n * Only the owner can directly clawback assets from the budget\n * If the amount is zero, the entire balance of the asset will be transferred to the receiver\n * If the asset transfer fails, the reclamation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams<typeof managedBudgetAbi, 'clawback'>} [params]\n * @returns {Promise<boolean>} - True if the request was successful\n */\n public async clawbackRaw(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'clawback'>,\n ) {\n const { request, result } = await simulateManagedBudgetClawback(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareTransfer(transfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetClawback(this._config, request);\n return { hash, result };\n }\n\n /**\n * Disburses assets from the budget to a single recipient\n * If the asset transfer fails, the disbursement will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams<typeof managedBudgetAbi, 'disburse'>} [params]\n * @returns {Promise<boolean>} - True if the disbursement was successful\n */\n public async disburse(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'disburse'>,\n ) {\n return await this.awaitResult(this.disburseRaw(transfer, params));\n }\n\n /**\n * Disburses assets from the budget to a single recipient\n * If the asset transfer fails, the disbursement will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams<typeof managedBudgetAbi, 'disburse'>} [params]\n * @returns {Promise<boolean>} - True if the disbursement was successful\n */\n public async disburseRaw(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'disburse'>,\n ) {\n const { request, result } = await simulateManagedBudgetDisburse(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareTransfer(transfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetDisburse(this._config, request);\n return { hash, result };\n }\n\n /**\n * Disburses assets from the budget to multiple recipients\n *\n * @public\n * @async\n * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers\n * @param {?WriteParams<typeof managedBudgetAbi, 'disburseBatch'>} [params]\n * @returns {Promise<boolean>} - True if all disbursements were successful\n */\n public async disburseBatch(\n transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,\n params?: WriteParams<typeof managedBudgetAbi, 'disburseBatch'>,\n ) {\n return await this.awaitResult(this.disburseBatchRaw(transfers, params));\n }\n\n /**\n * Disburses assets from the budget to multiple recipients\n *\n * @public\n * @async\n * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers\n * @param {?WriteParams<typeof managedBudgetAbi, 'disburseBatch'>} [params]\n * @returns {Promise<boolean>} - True if all disbursements were successful\n */\n public async disburseBatchRaw(\n transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,\n params?: WriteParams<typeof managedBudgetAbi, 'disburseBatch'>,\n ) {\n const { request, result } = await simulateManagedBudgetDisburseBatch(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [transfers.map(prepareTransfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetDisburseBatch(this._config, request);\n return { hash, result };\n }\n\n /**\n * Get the owner of the budget\n *\n * @public\n * @param {?ReadParams<typeof managedBudgetAbi, 'owner'>} [params]\n * @returns {Promise<Address>}\n */\n public owner(params?: ReadParams<typeof managedBudgetAbi, 'owner'>) {\n return readManagedBudgetOwner(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the total amount of assets allocated to the budget, including any that have been distributed\n * If a tokenId is provided, get the total amount of ERC1155 assets allocated to the budget, including any that have been distributed\n *\n * @public\n * @param {Address} [asset=\"0x0000000000000000000000000000000000000000\"] - The address of the asset\n * @param {?(bigint | undefined)} [tokenId] - The ID of the token\n * @param {?ReadParams<typeof managedBudgetAbi, 'total'>} [params]\n * @returns {Promise<bigint>} - The total amount of assets\n */\n public total(\n asset: Address = zeroAddress,\n tokenId?: bigint | undefined,\n params?: ReadParams<typeof managedBudgetAbi, 'total'>,\n ) {\n return readManagedBudgetTotal(this._config, {\n address: this.assertValidAddress(),\n args: tokenId ? [asset, tokenId] : [asset],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the amount of assets available for distribution from the budget.\n * If a tokenId is provided, get the amount of ERC1155 assets available for distribution from the budget\n *\n * @public\n * @param {Address} [asset=\"0x0000000000000000000000000000000000000000\"]\n * @param {?(bigint | undefined)} [tokenId]\n * @param {?ReadParams<typeof managedBudgetAbi, 'available'>} [params]\n * @returns {Promise<bigint>} - The amount of assets available\n */\n public available(\n asset: Address = zeroAddress,\n tokenId?: bigint | undefined,\n params?: ReadParams<typeof managedBudgetAbi, 'available'>,\n ) {\n return readManagedBudgetAvailable(this._config, {\n address: this.assertValidAddress(),\n args: tokenId ? [asset, tokenId] : [asset],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the amount of assets that have been distributed from the budget.\n * If a tokenId is provided, get the amount of ERC1155 assets that have been distributed from the budget\n *\n * @public\n * @param {Address} [asset=\"0x0000000000000000000000000000000000000000\"]\n * @param {?(bigint | undefined)} [tokenId]\n * @param {?ReadParams<typeof managedBudgetAbi, 'distributed'>} [params]\n * @returns {Promise<bigint>} - The amount of assets distributed\n */\n public distributed(\n asset: Address = zeroAddress,\n tokenId?: bigint | undefined,\n params?: ReadParams<typeof managedBudgetAbi, 'distributed'>,\n ) {\n return readManagedBudgetDistributed(this._config, {\n address: this.assertValidAddress(),\n args: tokenId ? [asset, tokenId] : [asset],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @param {?ManagedBudgetPayload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ManagedBudgetPayload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n if (!payload.owner || payload.owner === zeroAddress) {\n const owner = options.account\n ? options.account.address\n : options.config\n ? getAccount(options.config).address\n : this._account?.address;\n if (owner) {\n payload.owner = owner;\n } else {\n throw new DeployableUnknownOwnerProvidedError();\n }\n }\n return {\n abi: managedBudgetAbi,\n bytecode: bytecode as Hex,\n args: [prepareManagedBudgetPayload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n}\n\n/**\n * Given a {@link ManagedBudgetPayload}, properly encode a `ManagedBudget.InitPayload` for use with {@link ManagedBudget} initialization.\n *\n * @param {ManagedBudgetPayload} param0\n * @param {Address} param0.owner - The budget's owner\n * @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.\n * @param {{}} param0.roles - List of roles to assign to the corresponding account by index.\n * @returns {*}\n */\nexport const prepareManagedBudgetPayload = ({\n owner,\n authorized,\n roles,\n}: ManagedBudgetPayload) => {\n return encodeAbiParameters(\n parseAbiParameters([\n 'ManagedBudgetPayload payload',\n 'struct ManagedBudgetPayload { address owner; address[] authorized; uint256[] roles; }',\n ]),\n [{ owner, authorized, roles: roles as unknown as Array<bigint> }],\n );\n};\n"],"names":["ManagedBudgetRoles","isFungibleTransfer","transfer","isERC1155TransferPayload","prepareTransfer","prepareFungibleTransfer","prepareERC1155Transfer","UnknownTransferPayloadSupplied","_ManagedBudget","DeployableTargetWithRBAC","managedBudgetAbi","params","request","result","simulateManagedBudgetAllocate","writeManagedBudgetAllocate","simulateManagedBudgetClawback","writeManagedBudgetClawback","simulateManagedBudgetDisburse","writeManagedBudgetDisburse","transfers","simulateManagedBudgetDisburseBatch","writeManagedBudgetDisburseBatch","readManagedBudgetOwner","asset","zeroAddress","tokenId","readManagedBudgetTotal","readManagedBudgetAvailable","readManagedBudgetDistributed","_payload","_options","payload","options","owner","getAccount","_a","DeployableUnknownOwnerProvidedError","bytecode","prepareManagedBudgetPayload","ManagedBudgetBases","RegistryType","ManagedBudget","author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AAE,OAAAZ,GAAO,YAAAS,GAAY,OAAAC,GAA0C;AAAA;"}
1
+ {"version":3,"file":"ManagedBudget.js","sources":["../../src/Budgets/ManagedBudget.ts"],"sourcesContent":["import {\n managedBudgetAbi,\n readManagedBudgetAvailable,\n readManagedBudgetDistributed,\n readManagedBudgetHasAllRoles,\n readManagedBudgetHasAnyRole,\n readManagedBudgetIsAuthorized,\n readManagedBudgetOwner,\n readManagedBudgetRolesOf,\n readManagedBudgetTotal,\n simulateManagedBudgetAllocate,\n simulateManagedBudgetClawback,\n simulateManagedBudgetDisburse,\n simulateManagedBudgetDisburseBatch,\n simulateManagedBudgetGrantRoles,\n simulateManagedBudgetRevokeRoles,\n simulateManagedBudgetSetAuthorized,\n writeManagedBudgetAllocate,\n writeManagedBudgetClawback,\n writeManagedBudgetDisburse,\n writeManagedBudgetDisburseBatch,\n writeManagedBudgetGrantRoles,\n writeManagedBudgetRevokeRoles,\n writeManagedBudgetSetAuthorized,\n} from '@boostxyz/evm';\nimport { bytecode } from '@boostxyz/evm/artifacts/contracts/budgets/ManagedBudget.sol/ManagedBudget.json';\nimport { getAccount } from '@wagmi/core';\nimport {\n type Address,\n type ContractEventName,\n type Hex,\n encodeAbiParameters,\n parseAbiParameters,\n zeroAddress,\n} from 'viem';\nimport { ManagedBudget as ManagedBudgetBases } from '../../dist/deployments.json';\nimport type {\n DeployableOptions,\n GenericDeployableParams,\n} from '../Deployable/Deployable';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport { DeployableTargetWithRBAC } from '../Deployable/DeployableTargetWithRBAC';\nimport {\n DeployableUnknownOwnerProvidedError,\n UnknownTransferPayloadSupplied,\n} from '../errors';\nimport {\n type ERC1155TransferPayload,\n type FungibleTransferPayload,\n prepareERC1155Transfer,\n prepareFungibleTransfer,\n} from '../transfers';\nimport {\n type GenericLog,\n type ReadParams,\n RegistryType,\n type WriteParams,\n} from '../utils';\nexport { managedBudgetAbi };\nexport type { ERC1155TransferPayload, FungibleTransferPayload };\n\n/**\n * The object representation of a `ManagedBudgetPayload.InitPayload`\n *\n * @export\n * @interface ManagedBudgetPayload\n * @typedef {ManagedBudgetPayload}\n */\nexport interface ManagedBudgetPayload {\n /**\n * The budget's owner\n *\n * @type {Address}\n */\n owner: Address;\n /**\n * List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.\n *\n * @type {Address[]}\n */\n authorized: Address[];\n /**\n * List of roles to assign to the corresponding account by index.\n *\n * @type {ManagedBudgetRoles[]}\n */\n roles: ManagedBudgetRoles[];\n}\n\n/**\n * Enum representing available roles for use in the `ManagedBudget`.\n * `MANAGER` can disburse funds.\n * `ADMIN` can additionally manage authorized users on the budget.\n *\n * @export\n * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}\n * @enum {bigint}\n */\nexport enum ManagedBudgetRoles {\n //@ts-expect-error ts doesn't like bigint enum values\n MANAGER = 1n,\n //@ts-expect-error ts doesn't like bigint enum values\n ADMIN = 2n,\n}\n\n/**\n * A generic `viem.Log` event with support for `ManagedBudget` event types.\n *\n * @export\n * @typedef {ManagedBudgetLog}\n * @template {ContractEventName<typeof managedBudgetAbi>} [event=ContractEventName<\n * typeof managedBudgetAbi\n * >]\n */\nexport type ManagedBudgetLog<\n event extends ContractEventName<typeof managedBudgetAbi> = ContractEventName<\n typeof managedBudgetAbi\n >,\n> = GenericLog<typeof managedBudgetAbi, event>;\n\n/**\n * Typeguard to determine if a transfer payload is a Fungible Transfer\n *\n * @export\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @returns {transfer is FungibleTransferPayload}\n */\nexport function isFungibleTransfer(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n): transfer is FungibleTransferPayload {\n return (transfer as ERC1155TransferPayload).tokenId === undefined;\n}\n\n/**\n * Typeguard to determine if a transfer payload is an ERC1155 Transfer\n *\n * @export\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @returns {transfer is ERC1155TransferPayload}\n */\nexport function isERC1155TransferPayload(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n): transfer is ERC1155TransferPayload {\n return (transfer as ERC1155TransferPayload).tokenId !== undefined;\n}\n\n/**\n * Given either a Fungible transfer, or ERC1155 transfer, will properly encode parameters for transfers, claims, disbursements, allocations, etc.\n *\n * @export\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @returns {Hex}\n * @throws {@link UnknownTransferPayloadSupplied}\n */\nexport function prepareTransfer(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n) {\n if (isFungibleTransfer(transfer)) {\n return prepareFungibleTransfer(transfer);\n }\n if (isERC1155TransferPayload(transfer)) {\n return prepareERC1155Transfer(transfer);\n }\n throw new UnknownTransferPayloadSupplied(transfer);\n}\n\n/**\n * A minimal budget implementation that simply holds and distributes tokens (ERC20-like and native)\n * This type of budget supports ETH, ERC20, and ERC1155 assets only\n *\n * @export\n * @class ManagedBudget\n * @typedef {ManagedBudget}\n * @extends {DeployableTargetWithRBAC<ManagedBudgetPayload>}\n */\nexport class ManagedBudget extends DeployableTargetWithRBAC<\n ManagedBudgetPayload,\n typeof managedBudgetAbi\n> {\n /**\n * @inheritdoc\n *\n * @public\n * @readonly\n * @type {*}\n */\n public override readonly abi = managedBudgetAbi;\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {Record<number, Address>}\n */\n public static override bases: Record<number, Address> = {\n ...(ManagedBudgetBases as Record<number, Address>),\n };\n /**\n * @inheritdoc\n *\n * @public\n * @static\n * @type {RegistryType}\n */\n public static override registryType: RegistryType = RegistryType.BUDGET;\n\n /**\n * Allocates assets to the budget.\n * The caller must have already approved the contract to transfer the asset\n * If the asset transfer fails, the allocation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - True if the allocation was successful\n */\n public async allocate(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'allocate'>,\n ) {\n return await this.awaitResult(this.allocateRaw(transfer, params));\n }\n\n /**\n * Allocates assets to the budget.\n * The caller must have already approved the contract to transfer the asset\n * If the asset transfer fails, the allocation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the allocation was successful\n */\n public async allocateRaw(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'allocate'>,\n ) {\n const { request, result } = await simulateManagedBudgetAllocate(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareTransfer(transfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetAllocate(this._config, request);\n return { hash, result };\n }\n\n /**\n * Clawbacks assets from the budget.\n * Only the owner can directly clawback assets from the budget\n * If the amount is zero, the entire balance of the asset will be transferred to the receiver\n * If the asset transfer fails, the reclamation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - True if the request was successful\n */\n public async clawback(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'clawback'>,\n ) {\n return await this.awaitResult(this.clawbackRaw(transfer, params));\n }\n\n /**\n * Clawbacks assets from the budget.\n * Only the owner can directly clawback assets from the budget\n * If the amount is zero, the entire balance of the asset will be transferred to the receiver\n * If the asset transfer fails, the reclamation will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the request was successful\n */\n public async clawbackRaw(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'clawback'>,\n ) {\n const { request, result } = await simulateManagedBudgetClawback(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareTransfer(transfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetClawback(this._config, request);\n return { hash, result };\n }\n\n /**\n * Disburses assets from the budget to a single recipient\n * If the asset transfer fails, the disbursement will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - True if the disbursement was successful\n */\n public async disburse(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'disburse'>,\n ) {\n return await this.awaitResult(this.disburseRaw(transfer, params));\n }\n\n /**\n * Disburses assets from the budget to a single recipient\n * If the asset transfer fails, the disbursement will revert\n *\n * @public\n * @async\n * @param {(FungibleTransferPayload | ERC1155TransferPayload)} transfer\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the disbursement was successful\n */\n public async disburseRaw(\n transfer: FungibleTransferPayload | ERC1155TransferPayload,\n params?: WriteParams<typeof managedBudgetAbi, 'disburse'>,\n ) {\n const { request, result } = await simulateManagedBudgetDisburse(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [prepareTransfer(transfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetDisburse(this._config, request);\n return { hash, result };\n }\n\n /**\n * Disburses assets from the budget to multiple recipients\n *\n * @public\n * @async\n * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers\n * @param {?WriteParams} [params]\n * @returns {Promise<boolean>} - True if all disbursements were successful\n */\n public async disburseBatch(\n transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,\n params?: WriteParams<typeof managedBudgetAbi, 'disburseBatch'>,\n ) {\n return await this.awaitResult(this.disburseBatchRaw(transfers, params));\n }\n\n /**\n * Disburses assets from the budget to multiple recipients\n *\n * @public\n * @async\n * @param {Array<FungibleTransferPayload | ERC1155TransferPayload>} transfers\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if all disbursements were successful\n */\n public async disburseBatchRaw(\n transfers: Array<FungibleTransferPayload | ERC1155TransferPayload>,\n params?: WriteParams<typeof managedBudgetAbi, 'disburseBatch'>,\n ) {\n const { request, result } = await simulateManagedBudgetDisburseBatch(\n this._config,\n {\n address: this.assertValidAddress(),\n args: [transfers.map(prepareTransfer)],\n ...this.optionallyAttachAccount(),\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n },\n );\n const hash = await writeManagedBudgetDisburseBatch(this._config, request);\n return { hash, result };\n }\n\n /**\n * Get the owner of the budget\n *\n * @public\n * @param {?ReadParams} [params]\n * @returns {Promise<Address>}\n */\n public owner(params?: ReadParams<typeof managedBudgetAbi, 'owner'>) {\n return readManagedBudgetOwner(this._config, {\n address: this.assertValidAddress(),\n args: [],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the total amount of assets allocated to the budget, including any that have been distributed\n * If a tokenId is provided, get the total amount of ERC1155 assets allocated to the budget, including any that have been distributed\n *\n * @public\n * @param {Address} [asset=\"0x0000000000000000000000000000000000000000\"] - The address of the asset\n * @param {?(bigint | undefined)} [tokenId] - The ID of the token\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - The total amount of assets\n */\n public total(\n asset: Address = zeroAddress,\n tokenId?: bigint | undefined,\n params?: ReadParams<typeof managedBudgetAbi, 'total'>,\n ) {\n return readManagedBudgetTotal(this._config, {\n address: this.assertValidAddress(),\n args: tokenId ? [asset, tokenId] : [asset],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the amount of assets available for distribution from the budget.\n * If a tokenId is provided, get the amount of ERC1155 assets available for distribution from the budget\n *\n * @public\n * @param {Address} [asset=\"0x0000000000000000000000000000000000000000\"]\n * @param {?(bigint | undefined)} [tokenId]\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - The amount of assets available\n */\n public available(\n asset: Address = zeroAddress,\n tokenId?: bigint | undefined,\n params?: ReadParams<typeof managedBudgetAbi, 'available'>,\n ) {\n return readManagedBudgetAvailable(this._config, {\n address: this.assertValidAddress(),\n args: tokenId ? [asset, tokenId] : [asset],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * Get the amount of assets that have been distributed from the budget.\n * If a tokenId is provided, get the amount of ERC1155 assets that have been distributed from the budget\n *\n * @public\n * @param {Address} [asset=\"0x0000000000000000000000000000000000000000\"]\n * @param {?(bigint | undefined)} [tokenId]\n * @param {?ReadParams} [params]\n * @returns {Promise<bigint>} - The amount of assets distributed\n */\n public distributed(\n asset: Address = zeroAddress,\n tokenId?: bigint | undefined,\n params?: ReadParams<typeof managedBudgetAbi, 'distributed'>,\n ) {\n return readManagedBudgetDistributed(this._config, {\n address: this.assertValidAddress(),\n args: tokenId ? [asset, tokenId] : [asset],\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n });\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @param {?ManagedBudgetPayload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public override buildParameters(\n _payload?: ManagedBudgetPayload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n if (!payload.owner || payload.owner === zeroAddress) {\n const owner = options.account\n ? options.account.address\n : options.config\n ? getAccount(options.config).address\n : this._account?.address;\n if (owner) {\n payload.owner = owner;\n } else {\n throw new DeployableUnknownOwnerProvidedError();\n }\n }\n return {\n abi: managedBudgetAbi,\n bytecode: bytecode as Hex,\n args: [prepareManagedBudgetPayload(payload)],\n ...this.optionallyAttachAccount(options.account),\n };\n }\n}\n\n/**\n * Given a {@link ManagedBudgetPayload}, properly encode a `ManagedBudget.InitPayload` for use with {@link ManagedBudget} initialization.\n *\n * @param {ManagedBudgetPayload} param0\n * @param {Address} param0.owner - The budget's owner\n * @param {{}} param0.authorized - List of accounts authorized to use the budget. This list should include a Boost core address to interact with the protocol.\n * @param {{}} param0.roles - List of roles to assign to the corresponding account by index.\n * @returns {Hex}\n */\nexport const prepareManagedBudgetPayload = ({\n owner,\n authorized,\n roles,\n}: ManagedBudgetPayload) => {\n return encodeAbiParameters(\n parseAbiParameters([\n 'ManagedBudgetPayload payload',\n 'struct ManagedBudgetPayload { address owner; address[] authorized; uint256[] roles; }',\n ]),\n [{ owner, authorized, roles: roles as unknown as Array<bigint> }],\n );\n};\n"],"names":["ManagedBudgetRoles","isFungibleTransfer","transfer","isERC1155TransferPayload","prepareTransfer","prepareFungibleTransfer","prepareERC1155Transfer","UnknownTransferPayloadSupplied","_ManagedBudget","DeployableTargetWithRBAC","managedBudgetAbi","params","request","result","simulateManagedBudgetAllocate","writeManagedBudgetAllocate","simulateManagedBudgetClawback","writeManagedBudgetClawback","simulateManagedBudgetDisburse","writeManagedBudgetDisburse","transfers","simulateManagedBudgetDisburseBatch","writeManagedBudgetDisburseBatch","readManagedBudgetOwner","asset","zeroAddress","tokenId","readManagedBudgetTotal","readManagedBudgetAvailable","readManagedBudgetDistributed","_payload","_options","payload","options","owner","getAccount","_a","DeployableUnknownOwnerProvidedError","bytecode","prepareManagedBudgetPayload","ManagedBudgetBases","Reg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AAA,EACD,CAAC,EAAE,OAAAZ,GAAO,YAAAS,GAAY,OAAAC,GAA0C;AAAA;"}
@@ -688,7 +688,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
688
688
  * Get the owner of the budget
689
689
  *
690
690
  * @public
691
- * @param {?ReadParams<typeof vestingBudgetAbi, 'owner'>} [params]
691
+ * @param {?ReadParams} [params]
692
692
  * @returns {Promise<Address>}
693
693
  */
694
694
  owner(params?: ReadParams<typeof vestingBudgetAbi, 'owner'>): Promise<`0x${string}`>;
@@ -696,24 +696,24 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
696
696
  * The timestamp at which the vesting schedule begins
697
697
  *
698
698
  * @public
699
- * @param {?ReadParams<typeof vestingBudgetAbi, 'start'>} [params]
700
- * @returns {*}
699
+ * @param {?ReadParams} [params]
700
+ * @returns {Promise<bigint>}
701
701
  */
702
702
  start(params?: ReadParams<typeof vestingBudgetAbi, 'start'>): Promise<bigint>;
703
703
  /**
704
704
  * The duration of the vesting schedule (in seconds)
705
705
  *
706
706
  * @public
707
- * @param {?ReadParams<typeof vestingBudgetAbi, 'duration'>} [params]
708
- * @returns {*}
707
+ * @param {?ReadParams} [params]
708
+ * @returns {Promise<bigint>}
709
709
  */
710
710
  duration(params?: ReadParams<typeof vestingBudgetAbi, 'duration'>): Promise<bigint>;
711
711
  /**
712
712
  * The duration of the cliff period (in seconds)
713
713
  *
714
714
  * @public
715
- * @param {?ReadParams<typeof vestingBudgetAbi, 'cliff'>} [params]
716
- * @returns {*}
715
+ * @param {?ReadParams} [params]
716
+ * @returns {Promise<bigint>}
717
717
  */
718
718
  cliff(params?: ReadParams<typeof vestingBudgetAbi, 'cliff'>): Promise<bigint>;
719
719
  /**
@@ -724,7 +724,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
724
724
  * @public
725
725
  * @async
726
726
  * @param {(FungibleTransferPayload)} transfer
727
- * @param {?WriteParams<typeof vestingBudgetAbi, 'allocate'>} [params]
727
+ * @param {?WriteParams} [params]
728
728
  * @returns {Promise<boolean>} - True if the allocation was successful
729
729
  */
730
730
  allocate(transfer: FungibleTransferPayload, params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>): Promise<boolean>;
@@ -736,8 +736,8 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
736
736
  * @public
737
737
  * @async
738
738
  * @param {(FungibleTransferPayload)} transfer
739
- * @param {?WriteParams<typeof vestingBudgetAbi, 'allocate'>} [params]
740
- * @returns {Promise<boolean>} - True if the allocation was successful
739
+ * @param {?WriteParams} [params]
740
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the allocation was successful
741
741
  */
742
742
  allocateRaw(transfer: FungibleTransferPayload, params?: WriteParams<typeof vestingBudgetAbi, 'allocate'>): Promise<{
743
743
  hash: `0x${string}`;
@@ -752,7 +752,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
752
752
  * @public
753
753
  * @async
754
754
  * @param {(FungibleTransferPayload)} transfer
755
- * @param {?WriteParams<typeof vestingBudgetAbi, 'clawback'>} [params]
755
+ * @param {?WriteParams} [params]
756
756
  * @returns {Promise<boolean>} - True if the request was successful
757
757
  */
758
758
  clawback(transfer: FungibleTransferPayload, params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>): Promise<boolean>;
@@ -765,8 +765,8 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
765
765
  * @public
766
766
  * @async
767
767
  * @param {(FungibleTransferPayload)} transfer
768
- * @param {?WriteParams<typeof vestingBudgetAbi, 'clawback'>} [params]
769
- * @returns {Promise<boolean>} - True if the request was successful
768
+ * @param {?WriteParams} [params]
769
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the request was successful
770
770
  */
771
771
  clawbackRaw(transfer: FungibleTransferPayload, params?: WriteParams<typeof vestingBudgetAbi, 'clawback'>): Promise<{
772
772
  hash: `0x${string}`;
@@ -779,7 +779,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
779
779
  * @public
780
780
  * @async
781
781
  * @param {(FungibleTransferPayload)} transfer
782
- * @param {?WriteParams<typeof vestingBudgetAbi, 'disburse'>} [params]
782
+ * @param {?WriteParams} [params]
783
783
  * @returns {Promise<boolean>} - True if the disbursement was successful
784
784
  */
785
785
  disburse(transfer: FungibleTransferPayload, params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>): Promise<boolean>;
@@ -790,8 +790,8 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
790
790
  * @public
791
791
  * @async
792
792
  * @param {(FungibleTransferPayload)} transfer
793
- * @param {?WriteParams<typeof vestingBudgetAbi, 'disburse'>} [params]
794
- * @returns {Promise<boolean>} - True if the disbursement was successful
793
+ * @param {?WriteParams} [params]
794
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the disbursement was successful
795
795
  */
796
796
  disburseRaw(transfer: FungibleTransferPayload, params?: WriteParams<typeof vestingBudgetAbi, 'disburse'>): Promise<{
797
797
  hash: `0x${string}`;
@@ -803,7 +803,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
803
803
  * @public
804
804
  * @async
805
805
  * @param {Array<FungibleTransferPayload>} transfers
806
- * @param {?WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>} [params]
806
+ * @param {?WriteParams} [params]
807
807
  * @returns {Promise<boolean>} - True if all disbursements were successful
808
808
  */
809
809
  disburseBatch(transfers: FungibleTransferPayload[], params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>): Promise<boolean>;
@@ -813,8 +813,8 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
813
813
  * @public
814
814
  * @async
815
815
  * @param {Array<FungibleTransferPayload>} transfers
816
- * @param {?WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>} [params]
817
- * @returns {Promise<boolean>} - True if all disbursements were successful
816
+ * @param {?WriteParams} [params]
817
+ * @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if all disbursements were successful
818
818
  */
819
819
  disburseBatchRaw(transfers: FungibleTransferPayload[], params?: WriteParams<typeof vestingBudgetAbi, 'disburseBatch'>): Promise<{
820
820
  hash: `0x${string}`;
@@ -824,7 +824,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
824
824
  * Get the end time of the vesting schedule
825
825
  *
826
826
  * @public
827
- * @param {?ReadParams<typeof vestingBudgetAbi, 'end'>} [params]
827
+ * @param {?ReadParams} [params]
828
828
  * @returns {Promise<bigint>}
829
829
  */
830
830
  end(params?: ReadParams<typeof vestingBudgetAbi, 'end'>): Promise<bigint>;
@@ -834,7 +834,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
834
834
  *
835
835
  * @public
836
836
  * @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset (or the zero address for native assets)
837
- * @param {?ReadParams<typeof vestingBudgetAbi, 'total'>} [params]
837
+ * @param {?ReadParams} [params]
838
838
  * @returns {Promise<bigint>}
839
839
  */
840
840
  total(asset?: Address, params?: ReadParams<typeof vestingBudgetAbi, 'total'>): Promise<bigint>;
@@ -844,7 +844,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
844
844
  *
845
845
  * @public
846
846
  * @param {Address} [asset="0x0000000000000000000000000000000000000000"] - The address of the asset (or the zero address for native assets)
847
- * @param {?ReadParams<typeof vestingBudgetAbi, 'available'>} [params]
847
+ * @param {?ReadParams} [params]
848
848
  * @returns {Promise<bigint>} - The amount of assets currently available for distribution
849
849
  */
850
850
  available(asset?: Address, params?: ReadParams<typeof vestingBudgetAbi, 'available'>): Promise<bigint>;
@@ -853,7 +853,7 @@ export declare class VestingBudget extends DeployableTargetWithRBAC<VestingBudge
853
853
  *
854
854
  * @public
855
855
  * @param {Address} [asset="0x0000000000000000000000000000000000000000"]
856
- * @param {?ReadParams<typeof vestingBudgetAbi, 'distributed'>} [params]
856
+ * @param {?ReadParams} [params]
857
857
  * @returns {Promise<bigint>} - The amount of assets distributed
858
858
  */
859
859
  distributed(asset?: Address, params?: ReadParams<typeof vestingBudgetAbi, 'distributed'>): Promise<bigint>;
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@wagmi/core"),i=require("viem"),o=require("viem/actions"),d=require("../errors.cjs"),c=require("../utils.cjs");class h{constructor(e,t){this._config=e,this._address=t}get address(){return this._address}at(e){return this._address=e,this}withConfig(e){return this._config=e,this}assertValidAddress(){const e=this.address;if(!e)throw new d.ContractAddressRequiredError;return e}async getLogs(e){return o.getLogs(this._config.getClient({chainId:e==null?void 0:e.chainId}),{...e,...e!=null&&e.eventName?{event:i.getAbiItem({abi:this.abi,name:e.eventName})}:{},...e!=null&&e.eventNames?{events:e.eventNames.map(t=>i.getAbiItem({abi:this.abi,name:t}))}:{},address:this.assertValidAddress()})}async subscribe(e,t){return r.watchContractEvent(this._config,{...t,eventName:t==null?void 0:t.eventName,abi:this.abi,address:this.assertValidAddress(),onLogs:s=>{for(let n of s)e(n)}})}async awaitResult(e,t){return await c.awaitResult(this._config,e,t)}}exports.Contract=h;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("@wagmi/core"),i=require("viem"),o=require("viem/actions"),d=require("../errors.cjs"),c=require("../utils.cjs");class h{constructor(e,t){this._config=e,this._address=t}get address(){return this._address}at(e){return this._address=e,this}withConfig(e){return this._config=e,this}assertValidAddress(){const e=this.address;if(!e)throw new d.ContractAddressRequiredError;return e}async getLogs(e){return o.getLogs(this._config.getClient({chainId:e==null?void 0:e.chainId}),{...e,...e!=null&&e.eventName?{event:i.getAbiItem({abi:this.abi,name:e.eventName})}:{},...e!=null&&e.eventNames?{events:e.eventNames.map(t=>i.getAbiItem({abi:this.abi,name:t}))}:{},address:this.assertValidAddress()})}subscribe(e,t){return r.watchContractEvent(this._config,{...t,eventName:t==null?void 0:t.eventName,abi:this.abi,address:this.assertValidAddress(),onLogs:s=>{for(let n of s)e(n)}})}async awaitResult(e,t){return await c.awaitResult(this._config,e,t)}}exports.Contract=h;
2
2
  //# sourceMappingURL=Contract.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"Contract.cjs","sources":["../../src/Deployable/Contract.ts"],"sourcesContent":["import { type Config, watchContractEvent } from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport {\n type Abi,\n type Address,\n type ContractEventName,\n type GetLogsReturnType,\n type WaitForTransactionReceiptParameters,\n type WatchContractEventOnLogsParameter,\n getAbiItem,\n} from 'viem';\nimport { getLogs } from 'viem/actions';\nimport { ContractAddressRequiredError } from '../errors';\nimport {\n type GetLogsParams,\n type HashAndSimulatedResult,\n type WatchParams,\n awaitResult,\n} from '../utils';\n\n/**\n * A basic Contract class to encapsulate configuration and a potential address\n *\n * @export\n * @class Contract\n * @typedef {Contract}\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=any]\n */\nexport class Contract<ContractAbi extends Abi> {\n //@ts-expect-error this should always be set by implementing contract\n public readonly abi: ContractAbi;\n /**\n * @see [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @protected\n * @type {WagmiConfig}\n */\n protected _config: Config;\n /**\n * The internally managed address for this contract\n *\n * @protected\n * @type {(Address | undefined)}\n */\n protected _address: Address | undefined;\n\n /**\n * Creates an instance of Contract.\n *\n * @constructor\n * @param {Config} config\n * @param {(Address | undefined)} address\n */\n constructor(config: Config, address: Address | undefined) {\n this._config = config;\n this._address = address;\n }\n\n /**\n * A getter returning this contract's deployed address, if it exists.\n *\n * @public\n * @readonly\n * @type {*}\n */\n public get address() {\n return this._address;\n }\n\n /**\n * Will set this contract's address and return the instance for chaining. Does not verify that provided address is valid.\n *\n * @public\n * @param {Address} address\n * @returns {this}\n */\n public at(address: Address) {\n this._address = address;\n return this;\n }\n\n /**\n * Will set this contract's internal [Wagmi Configuration](https://en.wikipedia.org/wiki/Factorial) and return the instance for chaining.\n *\n * @public\n * @param {Config} config\n * @returns {this}\n */\n public withConfig(config: Config) {\n this._config = config;\n return this;\n }\n\n /**\n * Utility function to validate the existence of an address on this Contract.\n *\n * @public\n * @returns {Address}\n * @throws {@link ContractAddressRequiredError} if no address exists on this Contract instance\n */\n public assertValidAddress() {\n const address = this.address;\n if (!address) throw new ContractAddressRequiredError();\n return address;\n }\n\n /**\n * A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs].\n * Accepts `eventName` and `eventNames` as optional parameters to narrow the returned log types.\n * @example\n * ```ts\n * const logs = contract.getLogs({ eventName: 'EventName' })\n * const logs = contract.getLogs({ eventNames: ['EventName'] })\n *\n * @public\n * @async\n * @template {ContractEvent} event\n * @template {ExtractAbiEvent<\n * ContractAbi,\n * event\n * >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]\n * @param {?Omit<\n * GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n * 'event' | 'events'\n * > & {\n * eventName?: event;\n * eventNames?: event[];\n * }} [params]\n * @returns {Promise<GetLogsReturnType<abiEvent, abiEvent[]>>}\n */\n public async getLogs<\n event extends ContractEventName<ContractAbi>,\n const abiEvent extends ExtractAbiEvent<\n ContractAbi,\n event\n > = ExtractAbiEvent<ContractAbi, event>,\n >(\n params?: Omit<\n GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n 'event' | 'events'\n > & {\n eventName?: event;\n eventNames?: event[];\n },\n ): Promise<GetLogsReturnType<abiEvent, abiEvent[]>> {\n return getLogs(this._config.getClient({ chainId: params?.chainId }), {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wag\n ...(params as any),\n ...(params?.eventName\n ? {\n event: getAbiItem({\n abi: this.abi,\n name: params.eventName,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n }\n : {}),\n ...(params?.eventNames\n ? {\n events: params.eventNames.map((name) =>\n getAbiItem({\n abi: this.abi,\n name,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n ),\n }\n : {}),\n address: this.assertValidAddress(),\n });\n }\n\n /**\n * A typed wrapper for `wagmi.watchContractEvent`\n *\n * @public\n * @async\n * @template {ContractEvent} event\n * @param {(\n * log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n * ) => unknown} cb\n * @param {?WatchParams<ContractAbi, event> & {\n * eventName?: event;\n * }} [params]\n * @returns {unknown, params?: any) => unknown}\n */\n public async subscribe<event extends ContractEventName<ContractAbi>>(\n cb: (\n log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n ) => unknown,\n params?: WatchParams<ContractAbi, event> & {\n eventName?: event;\n },\n ) {\n return watchContractEvent<\n typeof this._config,\n (typeof this._config)['chains'][number]['id'],\n ContractAbi,\n event\n >(this._config, {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n eventName: params?.eventName,\n abi: this.abi,\n address: this.assertValidAddress(),\n onLogs: (logs) => {\n for (let l of logs) {\n cb(l);\n }\n },\n });\n }\n\n /**\n * @see {@link awaitResult}\n * @protected\n * @async\n * @template [Result=unknown]\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {unknown}\n */\n protected async awaitResult<Result = unknown>(\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n return await awaitResult(this._config, hashPromise, waitParams);\n }\n}\n"],"names":["Contract","config","address","ContractAddressRequiredError","params","getLogs","getAbiItem","name","cb","watchContractEvent","logs","l","hashPromise","waitParams","awaitResult"],"mappings":"gNA6BO,MAAMA,CAAkC,CAwB7C,YAAYC,EAAgBC,EAA8B,CACxD,KAAK,QAAUD,EACf,KAAK,SAAWC,CAClB,CASA,IAAW,SAAU,CACnB,OAAO,KAAK,QACd,CASO,GAAGA,EAAkB,CAC1B,YAAK,SAAWA,EACT,IACT,CASO,WAAWD,EAAgB,CAChC,YAAK,QAAUA,EACR,IACT,CASO,oBAAqB,CAC1B,MAAMC,EAAU,KAAK,QACrB,GAAI,CAACA,EAAe,MAAA,IAAIC,EAAAA,6BACjB,OAAAD,CACT,CA0BA,MAAa,QAOXE,EAOkD,CAC3C,OAAAC,EAAA,QAAQ,KAAK,QAAQ,UAAU,CAAE,QAASD,GAAA,YAAAA,EAAQ,OAAQ,CAAC,EAAG,CAEnE,GAAIA,EACJ,GAAIA,GAAA,MAAAA,EAAQ,UACR,CACE,MAAOE,EAAAA,WAAW,CAChB,IAAK,KAAK,IACV,KAAMF,EAAO,SAAA,CAEP,CAAA,EAEV,CAAC,EACL,GAAIA,GAAA,MAAAA,EAAQ,WACR,CACE,OAAQA,EAAO,WAAW,IAAKG,GAC7BD,EAAAA,WAAW,CACT,IAAK,KAAK,IACV,KAAAC,CAAA,CAEM,CACV,CAAA,EAEF,CAAC,EACL,QAAS,KAAK,mBAAmB,CAAA,CAClC,CACH,CAgBA,MAAa,UACXC,EAGAJ,EAGA,CACO,OAAAK,EAAA,mBAKL,KAAK,QAAS,CAEd,GAAIL,EACJ,UAAWA,GAAA,YAAAA,EAAQ,UACnB,IAAK,KAAK,IACV,QAAS,KAAK,mBAAmB,EACjC,OAASM,GAAS,CAChB,QAASC,KAAKD,EACZF,EAAGG,CAAC,CAER,CAAA,CACD,CACH,CAWA,MAAgB,YACdC,EACAC,EACA,CACA,OAAO,MAAMC,EAAA,YAAY,KAAK,QAASF,EAAaC,CAAU,CAChE,CACF"}
1
+ {"version":3,"file":"Contract.cjs","sources":["../../src/Deployable/Contract.ts"],"sourcesContent":["import { type Config, watchContractEvent } from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport {\n type Abi,\n type Address,\n type ContractEventName,\n type GetLogsReturnType,\n type WaitForTransactionReceiptParameters,\n type WatchContractEventOnLogsParameter,\n getAbiItem,\n} from 'viem';\nimport { getLogs } from 'viem/actions';\nimport { ContractAddressRequiredError } from '../errors';\nimport {\n type GetLogsParams,\n type HashAndSimulatedResult,\n type WatchParams,\n awaitResult,\n} from '../utils';\n\n/**\n * A basic Contract class to encapsulate configuration and a potential address\n *\n * @export\n * @class Contract\n * @typedef {Contract}\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=any]\n */\nexport class Contract<ContractAbi extends Abi> {\n //@ts-expect-error this should always be set by implementing contract\n public readonly abi: ContractAbi;\n /**\n * @see [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @protected\n * @type {WagmiConfig}\n */\n protected _config: Config;\n /**\n * The internally managed address for this contract\n *\n * @protected\n * @type {(Address | undefined)}\n */\n protected _address: Address | undefined;\n\n /**\n * Creates an instance of Contract.\n *\n * @constructor\n * @param {Config} config\n * @param {(Address | undefined)} address\n */\n constructor(config: Config, address: Address | undefined) {\n this._config = config;\n this._address = address;\n }\n\n /**\n * A getter returning this contract's deployed address, if it exists.\n *\n * @public\n * @readonly\n * @type {Address | undefined}\n */\n public get address() {\n return this._address;\n }\n\n /**\n * Will set this contract's address and return the instance for chaining. Does not verify that provided address is valid.\n *\n * @public\n * @param {Address} address\n * @returns {this}\n */\n public at(address: Address) {\n this._address = address;\n return this;\n }\n\n /**\n * Will set this contract's internal [Wagmi Configuration](https://en.wikipedia.org/wiki/Factorial) and return the instance for chaining.\n *\n * @public\n * @param {Config} config\n * @returns {this}\n */\n public withConfig(config: Config) {\n this._config = config;\n return this;\n }\n\n /**\n * Utility function to validate the existence of an address on this Contract.\n *\n * @public\n * @returns {Address}\n * @throws {@link ContractAddressRequiredError} if no address exists on this Contract instance\n */\n public assertValidAddress() {\n const address = this.address;\n if (!address) throw new ContractAddressRequiredError();\n return address;\n }\n\n /**\n * A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs].\n * Accepts `eventName` and `eventNames` as optional parameters to narrow the returned log types.\n * @example\n * ```ts\n * const logs = contract.getLogs({ eventName: 'EventName' })\n * const logs = contract.getLogs({ eventNames: ['EventName'] })\n *\n * @public\n * @async\n * @template {ContractEvent} event\n * @template {ExtractAbiEvent<\n * ContractAbi,\n * event\n * >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]\n * @param {?Omit<\n * GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n * 'event' | 'events'\n * > & {\n * eventName?: event;\n * eventNames?: event[];\n * }} [params]\n * @returns {Promise<GetLogsReturnType<abiEvent, abiEvent[]>>}\n */\n public async getLogs<\n event extends ContractEventName<ContractAbi>,\n const abiEvent extends ExtractAbiEvent<\n ContractAbi,\n event\n > = ExtractAbiEvent<ContractAbi, event>,\n >(\n params?: Omit<\n GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n 'event' | 'events'\n > & {\n eventName?: event;\n eventNames?: event[];\n },\n ): Promise<GetLogsReturnType<abiEvent, abiEvent[]>> {\n return getLogs(this._config.getClient({ chainId: params?.chainId }), {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wag\n ...(params as any),\n ...(params?.eventName\n ? {\n event: getAbiItem({\n abi: this.abi,\n name: params.eventName,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n }\n : {}),\n ...(params?.eventNames\n ? {\n events: params.eventNames.map((name) =>\n getAbiItem({\n abi: this.abi,\n name,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n ),\n }\n : {}),\n address: this.assertValidAddress(),\n });\n }\n\n /**\n * A typed wrapper for `wagmi.watchContractEvent`\n *\n * @public\n * @template {ContractEvent} event\n * @param {(\n * log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n * ) => unknown} cb\n * @param {?WatchParams<ContractAbi, event> & {\n * eventName?: event;\n * }} [params]\n * @returns {() => void}\n */\n public subscribe<event extends ContractEventName<ContractAbi>>(\n cb: (\n log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n ) => unknown,\n params?: WatchParams<ContractAbi, event> & {\n eventName?: event;\n },\n ) {\n return watchContractEvent<\n typeof this._config,\n (typeof this._config)['chains'][number]['id'],\n ContractAbi,\n event\n >(this._config, {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n eventName: params?.eventName,\n abi: this.abi,\n address: this.assertValidAddress(),\n onLogs: (logs) => {\n for (let l of logs) {\n cb(l);\n }\n },\n });\n }\n\n /**\n * @see {@link awaitResult}\n * @protected\n * @async\n * @template [Result=unknown]\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\n protected async awaitResult<Result = unknown>(\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n return await awaitResult(this._config, hashPromise, waitParams);\n }\n}\n"],"names":["Contract","config","address","ContractAddressRequiredError","params","getLogs","getAbiItem","name","cb","watchContractEvent","logs","l","hashPromise","waitParams","awaitResult"],"mappings":"gNA6BO,MAAMA,CAAkC,CAwB7C,YAAYC,EAAgBC,EAA8B,CACxD,KAAK,QAAUD,EACf,KAAK,SAAWC,CAClB,CASA,IAAW,SAAU,CACnB,OAAO,KAAK,QACd,CASO,GAAGA,EAAkB,CAC1B,YAAK,SAAWA,EACT,IACT,CASO,WAAWD,EAAgB,CAChC,YAAK,QAAUA,EACR,IACT,CASO,oBAAqB,CAC1B,MAAMC,EAAU,KAAK,QACrB,GAAI,CAACA,EAAe,MAAA,IAAIC,EAAAA,6BACjB,OAAAD,CACT,CA0BA,MAAa,QAOXE,EAOkD,CAC3C,OAAAC,EAAA,QAAQ,KAAK,QAAQ,UAAU,CAAE,QAASD,GAAA,YAAAA,EAAQ,OAAQ,CAAC,EAAG,CAEnE,GAAIA,EACJ,GAAIA,GAAA,MAAAA,EAAQ,UACR,CACE,MAAOE,EAAAA,WAAW,CAChB,IAAK,KAAK,IACV,KAAMF,EAAO,SAAA,CAEP,CAAA,EAEV,CAAC,EACL,GAAIA,GAAA,MAAAA,EAAQ,WACR,CACE,OAAQA,EAAO,WAAW,IAAKG,GAC7BD,EAAAA,WAAW,CACT,IAAK,KAAK,IACV,KAAAC,CAAA,CAEM,CACV,CAAA,EAEF,CAAC,EACL,QAAS,KAAK,mBAAmB,CAAA,CAClC,CACH,CAeO,UACLC,EAGAJ,EAGA,CACO,OAAAK,EAAA,mBAKL,KAAK,QAAS,CAEd,GAAIL,EACJ,UAAWA,GAAA,YAAAA,EAAQ,UACnB,IAAK,KAAK,IACV,QAAS,KAAK,mBAAmB,EACjC,OAASM,GAAS,CAChB,QAASC,KAAKD,EACZF,EAAGG,CAAC,CAER,CAAA,CACD,CACH,CAWA,MAAgB,YACdC,EACAC,EACA,CACA,OAAO,MAAMC,EAAA,YAAY,KAAK,QAASF,EAAaC,CAAU,CAChE,CACF"}
@@ -39,7 +39,7 @@ export declare class Contract<ContractAbi extends Abi> {
39
39
  *
40
40
  * @public
41
41
  * @readonly
42
- * @type {*}
42
+ * @type {Address | undefined}
43
43
  */
44
44
  get address(): `0x${string}` | undefined;
45
45
  /**
@@ -98,7 +98,6 @@ export declare class Contract<ContractAbi extends Abi> {
98
98
  * A typed wrapper for `wagmi.watchContractEvent`
99
99
  *
100
100
  * @public
101
- * @async
102
101
  * @template {ContractEvent} event
103
102
  * @param {(
104
103
  * log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],
@@ -106,11 +105,11 @@ export declare class Contract<ContractAbi extends Abi> {
106
105
  * @param {?WatchParams<ContractAbi, event> & {
107
106
  * eventName?: event;
108
107
  * }} [params]
109
- * @returns {unknown, params?: any) => unknown}
108
+ * @returns {() => void}
110
109
  */
111
110
  subscribe<event extends ContractEventName<ContractAbi>>(cb: (log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number]) => unknown, params?: WatchParams<ContractAbi, event> & {
112
111
  eventName?: event;
113
- }): Promise<() => void>;
112
+ }): () => void;
114
113
  /**
115
114
  * @see {@link awaitResult}
116
115
  * @protected
@@ -118,7 +117,7 @@ export declare class Contract<ContractAbi extends Abi> {
118
117
  * @template [Result=unknown]
119
118
  * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise
120
119
  * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
121
- * @returns {unknown}
120
+ * @returns {Promise<Result>}
122
121
  */
123
122
  protected awaitResult<Result = unknown>(hashPromise: Promise<HashAndSimulatedResult<Result>>, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<Result>;
124
123
  }
@@ -1 +1 @@
1
- {"version":3,"file":"Contract.d.ts","sourceRoot":"","sources":["../../src/Deployable/Contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAsB,MAAM,aAAa,CAAC;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,EACL,KAAK,GAAG,EACR,KAAK,OAAO,EACZ,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,mCAAmC,EACxC,KAAK,iCAAiC,EAEvC,MAAM,MAAM,CAAC;AAGd,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,WAAW,EAEjB,MAAM,UAAU,CAAC;AAElB;;;;;;;;GAQG;AACH,qBAAa,QAAQ,CAAC,WAAW,SAAS,GAAG;IAE3C,SAAgB,GAAG,EAAE,WAAW,CAAC;IACjC;;;;OAIG;IACH,SAAS,CAAC,OAAO,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,SAAS,CAAC,QAAQ,EAAE,OAAO,GAAG,SAAS,CAAC;IAExC;;;;;;OAMG;gBACS,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,SAAS;IAKxD;;;;;;OAMG;IACH,IAAW,OAAO,8BAEjB;IAED;;;;;;O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,EAAE,CAAC;KACtB,GACA,OAAO,CAAC,iBAAiB,CAAC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IA4BnD;;;;;;;;;;;;OAYG;IACI,SAAS,CAAC,KAAK,SAAS,iBAAiB,CAAC,WAAW,CAAC,EAC3D,EAAE,EAAE,CACF,GAAG,EAAE,iCAAiC,CAAC,WAAW,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,MAAM,CAAC,KACrE,OAAO,EACZ,MAAM,CAAC,EAAE,WAAW,CAAC,WAAW,EAAE,KAAK,CAAC,GAAG;QACzC,SAAS,CAAC,EAAE,KAAK,CAAC;KACnB;IAqBH;;;;;;;;OAQG;cACa,WAAW,CAAC,MAAM,GAAG,OAAO,EAC1C,WAAW,EAAE,OAAO,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC,EACpD,UAAU,CAAC,EAAE,IAAI,CAAC,mCAAmC,EAAE,MAAM,CAAC;CAIjE"}
@@ -19,7 +19,7 @@ class v {
19
19
  *
20
20
  * @public
21
21
  * @readonly
22
- * @type {*}
22
+ * @type {Address | undefined}
23
23
  */
24
24
  get address() {
25
25
  return this._address;
@@ -107,7 +107,6 @@ class v {
107
107
  * A typed wrapper for `wagmi.watchContractEvent`
108
108
  *
109
109
  * @public
110
- * @async
111
110
  * @template {ContractEvent} event
112
111
  * @param {(
113
112
  * log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],
@@ -115,9 +114,9 @@ class v {
115
114
  * @param {?WatchParams<ContractAbi, event> & {
116
115
  * eventName?: event;
117
116
  * }} [params]
118
- * @returns {unknown, params?: any) => unknown}
117
+ * @returns {() => void}
119
118
  */
120
- async subscribe(t, e) {
119
+ subscribe(t, e) {
121
120
  return o(this._config, {
122
121
  // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
123
122
  ...e,
@@ -137,7 +136,7 @@ class v {
137
136
  * @template [Result=unknown]
138
137
  * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise
139
138
  * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
140
- * @returns {unknown}
139
+ * @returns {Promise<Result>}
141
140
  */
142
141
  async awaitResult(t, e) {
143
142
  return await h(this._config, t, e);
@@ -1 +1 @@
1
- {"version":3,"file":"Contract.js","sources":["../../src/Deployable/Contract.ts"],"sourcesContent":["import { type Config, watchContractEvent } from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport {\n type Abi,\n type Address,\n type ContractEventName,\n type GetLogsReturnType,\n type WaitForTransactionReceiptParameters,\n type WatchContractEventOnLogsParameter,\n getAbiItem,\n} from 'viem';\nimport { getLogs } from 'viem/actions';\nimport { ContractAddressRequiredError } from '../errors';\nimport {\n type GetLogsParams,\n type HashAndSimulatedResult,\n type WatchParams,\n awaitResult,\n} from '../utils';\n\n/**\n * A basic Contract class to encapsulate configuration and a potential address\n *\n * @export\n * @class Contract\n * @typedef {Contract}\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=any]\n */\nexport class Contract<ContractAbi extends Abi> {\n //@ts-expect-error this should always be set by implementing contract\n public readonly abi: ContractAbi;\n /**\n * @see [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @protected\n * @type {WagmiConfig}\n */\n protected _config: Config;\n /**\n * The internally managed address for this contract\n *\n * @protected\n * @type {(Address | undefined)}\n */\n protected _address: Address | undefined;\n\n /**\n * Creates an instance of Contract.\n *\n * @constructor\n * @param {Config} config\n * @param {(Address | undefined)} address\n */\n constructor(config: Config, address: Address | undefined) {\n this._config = config;\n this._address = address;\n }\n\n /**\n * A getter returning this contract's deployed address, if it exists.\n *\n * @public\n * @readonly\n * @type {*}\n */\n public get address() {\n return this._address;\n }\n\n /**\n * Will set this contract's address and return the instance for chaining. Does not verify that provided address is valid.\n *\n * @public\n * @param {Address} address\n * @returns {this}\n */\n public at(address: Address) {\n this._address = address;\n return this;\n }\n\n /**\n * Will set this contract's internal [Wagmi Configuration](https://en.wikipedia.org/wiki/Factorial) and return the instance for chaining.\n *\n * @public\n * @param {Config} config\n * @returns {this}\n */\n public withConfig(config: Config) {\n this._config = config;\n return this;\n }\n\n /**\n * Utility function to validate the existence of an address on this Contract.\n *\n * @public\n * @returns {Address}\n * @throws {@link ContractAddressRequiredError} if no address exists on this Contract instance\n */\n public assertValidAddress() {\n const address = this.address;\n if (!address) throw new ContractAddressRequiredError();\n return address;\n }\n\n /**\n * A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs].\n * Accepts `eventName` and `eventNames` as optional parameters to narrow the returned log types.\n * @example\n * ```ts\n * const logs = contract.getLogs({ eventName: 'EventName' })\n * const logs = contract.getLogs({ eventNames: ['EventName'] })\n *\n * @public\n * @async\n * @template {ContractEvent} event\n * @template {ExtractAbiEvent<\n * ContractAbi,\n * event\n * >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]\n * @param {?Omit<\n * GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n * 'event' | 'events'\n * > & {\n * eventName?: event;\n * eventNames?: event[];\n * }} [params]\n * @returns {Promise<GetLogsReturnType<abiEvent, abiEvent[]>>}\n */\n public async getLogs<\n event extends ContractEventName<ContractAbi>,\n const abiEvent extends ExtractAbiEvent<\n ContractAbi,\n event\n > = ExtractAbiEvent<ContractAbi, event>,\n >(\n params?: Omit<\n GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n 'event' | 'events'\n > & {\n eventName?: event;\n eventNames?: event[];\n },\n ): Promise<GetLogsReturnType<abiEvent, abiEvent[]>> {\n return getLogs(this._config.getClient({ chainId: params?.chainId }), {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wag\n ...(params as any),\n ...(params?.eventName\n ? {\n event: getAbiItem({\n abi: this.abi,\n name: params.eventName,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n }\n : {}),\n ...(params?.eventNames\n ? {\n events: params.eventNames.map((name) =>\n getAbiItem({\n abi: this.abi,\n name,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n ),\n }\n : {}),\n address: this.assertValidAddress(),\n });\n }\n\n /**\n * A typed wrapper for `wagmi.watchContractEvent`\n *\n * @public\n * @async\n * @template {ContractEvent} event\n * @param {(\n * log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n * ) => unknown} cb\n * @param {?WatchParams<ContractAbi, event> & {\n * eventName?: event;\n * }} [params]\n * @returns {unknown, params?: any) => unknown}\n */\n public async subscribe<event extends ContractEventName<ContractAbi>>(\n cb: (\n log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n ) => unknown,\n params?: WatchParams<ContractAbi, event> & {\n eventName?: event;\n },\n ) {\n return watchContractEvent<\n typeof this._config,\n (typeof this._config)['chains'][number]['id'],\n ContractAbi,\n event\n >(this._config, {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n eventName: params?.eventName,\n abi: this.abi,\n address: this.assertValidAddress(),\n onLogs: (logs) => {\n for (let l of logs) {\n cb(l);\n }\n },\n });\n }\n\n /**\n * @see {@link awaitResult}\n * @protected\n * @async\n * @template [Result=unknown]\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {unknown}\n */\n protected async awaitResult<Result = unknown>(\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n return await awaitResult(this._config, hashPromise, waitParams);\n }\n}\n"],"names":["Contract","config","address","ContractAddressRequiredError","params","getLogs","getAbiItem","name","cb","watchContractEvent","logs","l","hashPromise","waitParams","awaitResult"],"mappings":";;;;;AA6BO,MAAMA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwB7C,YAAYC,GAAgBC,GAA8B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AAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAgBA,MAAa,UACXC,GAGAJ,GAGA;AACO,WAAAK,EAKL,KAAK,SAAS;AAAA;AAAA,MAEd,GAAIL;AAAA,MACJ,WAAWA,KAAA,gBAAAA,EAAQ;AAAA,MACnB,KAAK,KAAK;AAAA,MACV,SAAS,KAAK,mBAAmB;AAAA,MACjC,QAAQ,CAACM,MAAS;AAChB,iBAASC,KAAKD;AACZ,UAAAF,EAAGG,CAAC;AAAA,MAER;AAAA,IAAA,CACD;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAgB,YACdC,GACAC,GACA;AACA,WAAO,MAAMC,EAAY,KAAK,SAASF,GAAaC,CAAU;AAAA,EAChE;AACF;"}
1
+ {"version":3,"file":"Contract.js","sources":["../../src/Deployable/Contract.ts"],"sourcesContent":["import { type Config, watchContractEvent } from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport {\n type Abi,\n type Address,\n type ContractEventName,\n type GetLogsReturnType,\n type WaitForTransactionReceiptParameters,\n type WatchContractEventOnLogsParameter,\n getAbiItem,\n} from 'viem';\nimport { getLogs } from 'viem/actions';\nimport { ContractAddressRequiredError } from '../errors';\nimport {\n type GetLogsParams,\n type HashAndSimulatedResult,\n type WatchParams,\n awaitResult,\n} from '../utils';\n\n/**\n * A basic Contract class to encapsulate configuration and a potential address\n *\n * @export\n * @class Contract\n * @typedef {Contract}\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=any]\n */\nexport class Contract<ContractAbi extends Abi> {\n //@ts-expect-error this should always be set by implementing contract\n public readonly abi: ContractAbi;\n /**\n * @see [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @protected\n * @type {WagmiConfig}\n */\n protected _config: Config;\n /**\n * The internally managed address for this contract\n *\n * @protected\n * @type {(Address | undefined)}\n */\n protected _address: Address | undefined;\n\n /**\n * Creates an instance of Contract.\n *\n * @constructor\n * @param {Config} config\n * @param {(Address | undefined)} address\n */\n constructor(config: Config, address: Address | undefined) {\n this._config = config;\n this._address = address;\n }\n\n /**\n * A getter returning this contract's deployed address, if it exists.\n *\n * @public\n * @readonly\n * @type {Address | undefined}\n */\n public get address() {\n return this._address;\n }\n\n /**\n * Will set this contract's address and return the instance for chaining. Does not verify that provided address is valid.\n *\n * @public\n * @param {Address} address\n * @returns {this}\n */\n public at(address: Address) {\n this._address = address;\n return this;\n }\n\n /**\n * Will set this contract's internal [Wagmi Configuration](https://en.wikipedia.org/wiki/Factorial) and return the instance for chaining.\n *\n * @public\n * @param {Config} config\n * @returns {this}\n */\n public withConfig(config: Config) {\n this._config = config;\n return this;\n }\n\n /**\n * Utility function to validate the existence of an address on this Contract.\n *\n * @public\n * @returns {Address}\n * @throws {@link ContractAddressRequiredError} if no address exists on this Contract instance\n */\n public assertValidAddress() {\n const address = this.address;\n if (!address) throw new ContractAddressRequiredError();\n return address;\n }\n\n /**\n * A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs].\n * Accepts `eventName` and `eventNames` as optional parameters to narrow the returned log types.\n * @example\n * ```ts\n * const logs = contract.getLogs({ eventName: 'EventName' })\n * const logs = contract.getLogs({ eventNames: ['EventName'] })\n *\n * @public\n * @async\n * @template {ContractEvent} event\n * @template {ExtractAbiEvent<\n * ContractAbi,\n * event\n * >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]\n * @param {?Omit<\n * GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n * 'event' | 'events'\n * > & {\n * eventName?: event;\n * eventNames?: event[];\n * }} [params]\n * @returns {Promise<GetLogsReturnType<abiEvent, abiEvent[]>>}\n */\n public async getLogs<\n event extends ContractEventName<ContractAbi>,\n const abiEvent extends ExtractAbiEvent<\n ContractAbi,\n event\n > = ExtractAbiEvent<ContractAbi, event>,\n >(\n params?: Omit<\n GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,\n 'event' | 'events'\n > & {\n eventName?: event;\n eventNames?: event[];\n },\n ): Promise<GetLogsReturnType<abiEvent, abiEvent[]>> {\n return getLogs(this._config.getClient({ chainId: params?.chainId }), {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wag\n ...(params as any),\n ...(params?.eventName\n ? {\n event: getAbiItem({\n abi: this.abi,\n name: params.eventName,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n }\n : {}),\n ...(params?.eventNames\n ? {\n events: params.eventNames.map((name) =>\n getAbiItem({\n abi: this.abi,\n name,\n // biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue\n } as any),\n ),\n }\n : {}),\n address: this.assertValidAddress(),\n });\n }\n\n /**\n * A typed wrapper for `wagmi.watchContractEvent`\n *\n * @public\n * @template {ContractEvent} event\n * @param {(\n * log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n * ) => unknown} cb\n * @param {?WatchParams<ContractAbi, event> & {\n * eventName?: event;\n * }} [params]\n * @returns {() => void}\n */\n public subscribe<event extends ContractEventName<ContractAbi>>(\n cb: (\n log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],\n ) => unknown,\n params?: WatchParams<ContractAbi, event> & {\n eventName?: event;\n },\n ) {\n return watchContractEvent<\n typeof this._config,\n (typeof this._config)['chains'][number]['id'],\n ContractAbi,\n event\n >(this._config, {\n // biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally\n ...(params as any),\n eventName: params?.eventName,\n abi: this.abi,\n address: this.assertValidAddress(),\n onLogs: (logs) => {\n for (let l of logs) {\n cb(l);\n }\n },\n });\n }\n\n /**\n * @see {@link awaitResult}\n * @protected\n * @async\n * @template [Result=unknown]\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\n protected async awaitResult<Result = unknown>(\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n return await awaitResult(this._config, hashPromise, waitParams);\n }\n}\n"],"names":["Contract","config","address","ContractAddressRequiredError","params","getLogs","getAbiItem","name","cb","watchContractEvent","logs","l","hashPromise","waitParams","awaitResult"],"mappings":";;;;;AA6BO,MAAMA,EAAkC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAwB7C,YAAYC,GAAgBC,GAA8B;AACxD,SAAK,UAAUD,GACf,KAAK,WAAWC;AAAA,EAClB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,IAAW,UAAU;AACnB,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,GAAGA,GAAkB;AAC1B,gBAAK,WAAWA,GACT;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,WAAWD,GAAgB;AAChC,gBAAK,UAAUA,GACR;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,qBAAqB;AAC1B,UAAMC,IAAU,KAAK;AACrB,QAAI,CAACA,EAAe,OAAA,IAAIC;AACjB,WAAAD;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA0BA,MAAa,QAOXE,GAOkD;AAC3C,WAAAC,EAAQ,KAAK,QAAQ,UAAU,EAAE,SAASD,KAAA,gBAAAA,EAAQ,QAAQ,CAAC,GAAG;AAAA;AAAA,MAEnE,GAAIA;AAAA,MACJ,GAAIA,KAAA,QAAAA,EAAQ,YACR;AAAA,QACE,OAAOE,EAAW;AAAA,UAChB,KAAK,KAAK;AAAA,UACV,MAAMF,EAAO;AAAA;AAAA,QAAA,CAEP;AAAA,MAAA,IAEV,CAAC;AAAA,MACL,GAAIA,KAAA,QAAAA,EAAQ,aACR;AAAA,QACE,QAAQA,EAAO,WAAW;AAAA,UAAI,CAACG,MAC7BD,EAAW;AAAA,YACT,KAAK,KAAK;AAAA,YACV,MAAAC;AAAA;AAAA,UAAA,CAEM;AAAA,QACV;AAAA,MAAA,IAEF,CAAC;AAAA,MACL,SAAS,KAAK,mBAAmB;AAAA,IAAA,CAClC;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeO,UACLC,GAGAJ,GAGA;AACO,WAAAK,EAKL,KAAK,SAAS;AAAA;AAAA,MAEd,GAAIL;AAAA,MACJ,WAAWA,KAAA,gBAAAA,EAAQ;AAAA,MACnB,KAAK,KAAK;AAAA,MACV,SAAS,KAAK,mBAAmB;AAAA,MACjC,QAAQ,CAACM,MAAS;AAChB,iBAASC,KAAKD;AACZ,UAAAF,EAAGG,CAAC;AAAA,MAER;AAAA,IAAA,CACD;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAgB,YACdC,GACAC,GACA;AACA,WAAO,MAAMC,EAAY,KAAK,SAASF,GAAaC,CAAU;AAAA,EAChE;AACF;"}
@@ -1 +1 @@
1
- {"version":3,"file":"Deployable.cjs","sources":["../../src/Deployable/Deployable.ts"],"sourcesContent":["import { type Config, deployContract } from '@wagmi/core';\nimport type {\n Abi,\n Account,\n Address,\n ContractEventName,\n Hash,\n Hex,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport {\n DeployableAlreadyDeployedError,\n DeployableBuildParametersUnspecifiedError,\n DeployableMissingPayloadError,\n DeployableWagmiConfigurationRequiredError,\n} from '../errors';\nimport { getDeployedContractAddress } from '../utils';\nimport { Contract } from './Contract';\n\n/**\n * A base class representing a deployable contract, contains base implementations for deployment and initialization payload construction.\n *\n * @export\n * @typedef {GenericDeployableParams}\n */\nexport type GenericDeployableParams = Omit<\n Parameters<typeof deployContract>[1],\n 'args' | 'account'\n> & {\n args: [Hex, ...Array<Hex>];\n account?: Account;\n};\n\n/**\n * A generic type that encapsulates either an initialization payload for a contract, or a valid address for a previously deployed contract.\n *\n * @export\n * @typedef {DeployablePayloadOrAddress}\n * @template [Payload=unknown]\n */\nexport type DeployablePayloadOrAddress<Payload = unknown> = Payload | Address;\n\n/**\n * Instantion options for the base deployable.\n *\n * @export\n * @interface DeployableOptions\n * @typedef {DeployableOptions}\n */\nexport interface DeployableOptions {\n /**\n * [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n *\n * @see {@link Config}\n * @type {Config}\n */\n config: Config;\n /**\n * [Viem Local Account](https://viem.sh/docs/accounts/local), required if in a Node environment\n *\n * @see {@link Account}\n * @type {?Account}\n */\n account?: Account;\n}\n\n/**\n * A generic deployable contract that encapsulates common operations related to contract deployment\n *\n * @export\n * @class Deployable\n * @typedef {Deployable}\n * @template [Payload=unknown]\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=ContractEventName<ContractAbi>]\n * @extends {Contract<ContractAbi, ContractEvent>}\n */\nexport class Deployable<\n Payload,\n ContractAbi extends Abi,\n> extends Contract<ContractAbi> {\n /**\n * The deployable payload used either for contract construction or initialization\n *\n * @protected\n * @type {(Payload | undefined)}\n */\n protected _payload: Payload | undefined;\n /**\n * If it exists, [Viem Local Account](https://viem.sh/docs/accounts/local), if in a Node environment\n *\n * @protected\n * @type {?Account}\n */\n protected _account?: Account;\n\n /**\n * Creates an instance of Deployable.\n *\n * @constructor\n * @param {DeployableOptions} param0\n * @param {?Account} [param0.account]\n * @param {Config} param0.config\n * @param {DeployablePayloadOrAddress<Payload>} payload\n */\n constructor(\n { account, config }: DeployableOptions,\n payload?: DeployablePayloadOrAddress<Payload>,\n ) {\n if (typeof payload === 'string') {\n super(config, payload as Address);\n } else {\n super(config, undefined);\n this._payload = payload as Payload;\n }\n if (account) this._account = account;\n }\n\n /**\n * Returns the attached deployable payload, if it exists\n *\n * @readonly\n * @type {Payload}\n */\n get payload() {\n return this._payload;\n }\n\n /**\n * Attaches a new payload for use with this deployable's initialization\n *\n * @public\n * @param {Payload} payload\n * @returns {this}\n */\n public withPayload(payload: Payload) {\n this._payload = payload;\n return this;\n }\n\n /**\n * High level deployment function to deploy and await the contract address.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)\n * @returns {unknown}\n */\n protected async deploy(\n _payload?: Payload,\n _options?: DeployableOptions,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n const config = _options?.config || this._config;\n const address = await getDeployedContractAddress(\n config,\n this.deployRaw(_payload, _options),\n waitParams,\n );\n this._address = address;\n return this;\n }\n\n /**\n * The lower level contract deployment function that does not await for the transaction receipt.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {Promise<Hash>}\n * @throws {@link DeployableAlreadyDeployedError}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected async deployRaw(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): Promise<Hash> {\n if (this.address) throw new DeployableAlreadyDeployedError(this.address);\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return await deployContract(options.config, {\n ...this.buildParameters(payload),\n ...this.optionallyAttachAccount(options.account),\n });\n }\n\n /**\n * Internal function to attach the connected account to write methods to avoid manually passing in an account each call.\n *\n * @protected\n * @param {?Account} [account]\n * @returns {({ account: Account; } | { account?: undefined; })}\n */\n protected optionallyAttachAccount(account?: Account) {\n if (account) return { account };\n return this._account ? { account: this._account } : {};\n }\n\n /**\n * Base parameter constructor, should return a partial `viem.deployContract` parameters shape including abi, bytecode, and arguments, if any.\n * Expected to be overridden by protocol contracts.\n *\n * @public\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public buildParameters(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n throw new DeployableBuildParametersUnspecifiedError();\n }\n\n /**\n * Internal method used to ensure that a Wagmi configuration and payload are always present when deploying.\n *\n * @protected\n * @template [P=Payload]\n * @param {?P} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {[P, DeployableOptions]}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected validateDeploymentConfig<P = Payload>(\n _payload?: P,\n _options?: DeployableOptions,\n ) {\n const options = _options || {\n config: this._config,\n account: this._account,\n };\n if (!options) throw new DeployableWagmiConfigurationRequiredError();\n const payload = _payload || this._payload;\n return [payload, options] as [P, DeployableOptions];\n }\n}\n"],"names":["Deployable","Contract","account","config","payload","_payload","_options","waitParams","address","getDeployedContractAddress","DeployableAlreadyDeployedError","options","deployContract","DeployableBuildParametersUnspecifiedError","DeployableWagmiConfigurationRequiredError"],"mappings":"gMA6EO,MAAMA,UAGHC,EAAAA,QAAsB,CAyB9B,YACE,CAAE,QAAAC,EAAS,OAAAC,CAAA,EACXC,EACA,CACI,OAAOA,GAAY,SACrB,MAAMD,EAAQC,CAAkB,GAEhC,MAAMD,EAAQ,MAAS,EACvB,KAAK,SAAWC,GAEdF,SAAc,SAAWA,EAC/B,CAQA,IAAI,SAAU,CACZ,OAAO,KAAK,QACd,CASO,YAAYE,EAAkB,CACnC,YAAK,SAAWA,EACT,IACT,CAeA,MAAgB,OACdC,EACAC,EACAC,EACA,CACM,MAAAJ,GAASG,GAAA,YAAAA,EAAU,SAAU,KAAK,QAClCE,EAAU,MAAMC,EAAA,2BACpBN,EACA,KAAK,UAAUE,EAAUC,CAAQ,EACjCC,CAAA,EAEF,YAAK,SAAWC,EACT,IACT,CAiBA,MAAgB,UACdH,EACAC,EACe,CACf,GAAI,KAAK,QAAS,MAAM,IAAII,EAAAA,+BAA+B,KAAK,OAAO,EACvE,KAAM,CAACN,EAASO,CAAO,EAAI,KAAK,yBAC9BN,EACAC,CAAA,EAEK,OAAA,MAAMM,EAAAA,eAAeD,EAAQ,OAAQ,CAC1C,GAAG,KAAK,gBAAgBP,CAAO,EAC/B,GAAG,KAAK,wBAAwBO,EAAQ,OAAO,CAAA,CAChD,CACH,CASU,wBAAwBT,EAAmB,CAC/C,OAAAA,EAAgB,CAAE,QAAAA,GACf,KAAK,SAAW,CAAE,QAAS,KAAK,UAAa,EACtD,CAWO,gBACLG,EACAC,EACyB,CACzB,MAAM,IAAIO,EAA0C,yCACtD,CAaU,yBACRR,EACAC,EACA,CACA,MAAMK,EAAUL,GAAY,CAC1B,OAAQ,KAAK,QACb,QAAS,KAAK,QAAA,EAEhB,GAAI,CAACK,EAAe,MAAA,IAAIG,EAAAA,0CAEjB,MAAA,CADST,GAAY,KAAK,SAChBM,CAAO,CAC1B,CACF"}
1
+ {"version":3,"file":"Deployable.cjs","sources":["../../src/Deployable/Deployable.ts"],"sourcesContent":["import { type Config, deployContract } from '@wagmi/core';\nimport type {\n Abi,\n Account,\n Address,\n ContractEventName,\n Hash,\n Hex,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport {\n DeployableAlreadyDeployedError,\n DeployableBuildParametersUnspecifiedError,\n DeployableMissingPayloadError,\n DeployableWagmiConfigurationRequiredError,\n} from '../errors';\nimport { getDeployedContractAddress } from '../utils';\nimport { Contract } from './Contract';\n\n/**\n * A base class representing a deployable contract, contains base implementations for deployment and initialization payload construction.\n *\n * @export\n * @typedef {GenericDeployableParams}\n */\nexport type GenericDeployableParams = Omit<\n Parameters<typeof deployContract>[1],\n 'args' | 'account'\n> & {\n args: [Hex, ...Array<Hex>];\n account?: Account;\n};\n\n/**\n * A generic type that encapsulates either an initialization payload for a contract, or a valid address for a previously deployed contract.\n *\n * @export\n * @typedef {DeployablePayloadOrAddress}\n * @template [Payload=unknown]\n */\nexport type DeployablePayloadOrAddress<Payload = unknown> = Payload | Address;\n\n/**\n * Instantion options for the base deployable.\n *\n * @export\n * @interface DeployableOptions\n * @typedef {DeployableOptions}\n */\nexport interface DeployableOptions {\n /**\n * [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n *\n * @see {@link Config}\n * @type {Config}\n */\n config: Config;\n /**\n * [Viem Local Account](https://viem.sh/docs/accounts/local), required if in a Node environment\n *\n * @see {@link Account}\n * @type {?Account}\n */\n account?: Account;\n}\n\n/**\n * A generic deployable contract that encapsulates common operations related to contract deployment\n *\n * @export\n * @class Deployable\n * @typedef {Deployable}\n * @template [Payload=unknown]\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=ContractEventName<ContractAbi>]\n * @extends {Contract<ContractAbi, ContractEvent>}\n */\nexport class Deployable<\n Payload,\n ContractAbi extends Abi,\n> extends Contract<ContractAbi> {\n /**\n * The deployable payload used either for contract construction or initialization\n *\n * @protected\n * @type {(Payload | undefined)}\n */\n protected _payload: Payload | undefined;\n /**\n * If it exists, [Viem Local Account](https://viem.sh/docs/accounts/local), if in a Node environment\n *\n * @protected\n * @type {?Account}\n */\n protected _account?: Account;\n\n /**\n * Creates an instance of Deployable.\n *\n * @constructor\n * @param {DeployableOptions} param0\n * @param {?Account} [param0.account]\n * @param {Config} param0.config\n * @param {DeployablePayloadOrAddress<Payload>} payload\n */\n constructor(\n { account, config }: DeployableOptions,\n payload?: DeployablePayloadOrAddress<Payload>,\n ) {\n if (typeof payload === 'string') {\n super(config, payload as Address);\n } else {\n super(config, undefined);\n this._payload = payload as Payload;\n }\n if (account) this._account = account;\n }\n\n /**\n * Returns the attached deployable payload, if it exists\n *\n * @readonly\n * @type {Payload}\n */\n get payload() {\n return this._payload;\n }\n\n /**\n * Attaches a new payload for use with this deployable's initialization\n *\n * @public\n * @param {Payload} payload\n * @returns {this}\n */\n public withPayload(payload: Payload) {\n this._payload = payload;\n return this;\n }\n\n /**\n * High level deployment function to deploy and await the contract address.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)\n * @returns {Promise<this>}\n */\n protected async deploy(\n _payload?: Payload,\n _options?: DeployableOptions,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n const config = _options?.config || this._config;\n const address = await getDeployedContractAddress(\n config,\n this.deployRaw(_payload, _options),\n waitParams,\n );\n this._address = address;\n return this;\n }\n\n /**\n * The lower level contract deployment function that does not await for the transaction receipt.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {Promise<Hash>}\n * @throws {@link DeployableAlreadyDeployedError}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected async deployRaw(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): Promise<Hash> {\n if (this.address) throw new DeployableAlreadyDeployedError(this.address);\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return await deployContract(options.config, {\n ...this.buildParameters(payload),\n ...this.optionallyAttachAccount(options.account),\n });\n }\n\n /**\n * Internal function to attach the connected account to write methods to avoid manually passing in an account each call.\n *\n * @protected\n * @param {?Account} [account]\n * @returns {({ account: Account; } | { account?: undefined; })}\n */\n protected optionallyAttachAccount(account?: Account) {\n if (account) return { account };\n return this._account ? { account: this._account } : {};\n }\n\n /**\n * Base parameter constructor, should return a partial `viem.deployContract` parameters shape including abi, bytecode, and arguments, if any.\n * Expected to be overridden by protocol contracts.\n *\n * @public\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public buildParameters(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n throw new DeployableBuildParametersUnspecifiedError();\n }\n\n /**\n * Internal method used to ensure that a Wagmi configuration and payload are always present when deploying.\n *\n * @protected\n * @template [P=Payload]\n * @param {?P} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {[P, DeployableOptions]}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected validateDeploymentConfig<P = Payload>(\n _payload?: P,\n _options?: DeployableOptions,\n ) {\n const options = _options || {\n config: this._config,\n account: this._account,\n };\n if (!options) throw new DeployableWagmiConfigurationRequiredError();\n const payload = _payload || this._payload;\n return [payload, options] as [P, DeployableOptions];\n }\n}\n"],"names":["Deployable","Contract","account","config","payload","_payload","_options","waitParams","address","getDeployedContractAddress","DeployableAlreadyDeployedError","options","deployContract","DeployableBuildParametersUnspecifiedError","DeployableWagmiConfigurationRequiredError"],"mappings":"gMA6EO,MAAMA,UAGHC,EAAAA,QAAsB,CAyB9B,YACE,CAAE,QAAAC,EAAS,OAAAC,CAAA,EACXC,EACA,CACI,OAAOA,GAAY,SACrB,MAAMD,EAAQC,CAAkB,GAEhC,MAAMD,EAAQ,MAAS,EACvB,KAAK,SAAWC,GAEdF,SAAc,SAAWA,EAC/B,CAQA,IAAI,SAAU,CACZ,OAAO,KAAK,QACd,CASO,YAAYE,EAAkB,CACnC,YAAK,SAAWA,EACT,IACT,CAeA,MAAgB,OACdC,EACAC,EACAC,EACA,CACM,MAAAJ,GAASG,GAAA,YAAAA,EAAU,SAAU,KAAK,QAClCE,EAAU,MAAMC,EAAA,2BACpBN,EACA,KAAK,UAAUE,EAAUC,CAAQ,EACjCC,CAAA,EAEF,YAAK,SAAWC,EACT,IACT,CAiBA,MAAgB,UACdH,EACAC,EACe,CACf,GAAI,KAAK,QAAS,MAAM,IAAII,EAAAA,+BAA+B,KAAK,OAAO,EACvE,KAAM,CAACN,EAASO,CAAO,EAAI,KAAK,yBAC9BN,EACAC,CAAA,EAEK,OAAA,MAAMM,EAAAA,eAAeD,EAAQ,OAAQ,CAC1C,GAAG,KAAK,gBAAgBP,CAAO,EAC/B,GAAG,KAAK,wBAAwBO,EAAQ,OAAO,CAAA,CAChD,CACH,CASU,wBAAwBT,EAAmB,CAC/C,OAAAA,EAAgB,CAAE,QAAAA,GACf,KAAK,SAAW,CAAE,QAAS,KAAK,UAAa,EACtD,CAWO,gBACLG,EACAC,EACyB,CACzB,MAAM,IAAIO,EAA0C,yCACtD,CAaU,yBACRR,EACAC,EACA,CACA,MAAMK,EAAUL,GAAY,CAC1B,OAAQ,KAAK,QACb,QAAS,KAAK,QAAA,EAEhB,GAAI,CAACK,EAAe,MAAA,IAAIG,EAAAA,0CAEjB,MAAA,CADST,GAAY,KAAK,SAChBM,CAAO,CAC1B,CACF"}
@@ -104,7 +104,7 @@ export declare class Deployable<Payload, ContractAbi extends Abi> extends Contra
104
104
  * @param {?Payload} [_payload]
105
105
  * @param {?DeployableOptions} [_options]
106
106
  * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
107
- * @returns {unknown}
107
+ * @returns {Promise<this>}
108
108
  */
109
109
  protected deploy(_payload?: Payload, _options?: DeployableOptions, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<this>;
110
110
  /**
@@ -45,7 +45,7 @@ class m extends d {
45
45
  * @param {?Payload} [_payload]
46
46
  * @param {?DeployableOptions} [_options]
47
47
  * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
48
- * @returns {unknown}
48
+ * @returns {Promise<this>}
49
49
  */
50
50
  async deploy(t, o, a) {
51
51
  const e = (o == null ? void 0 : o.config) || this._config, r = await c(
@@ -1 +1 @@
1
- {"version":3,"file":"Deployable.js","sources":["../../src/Deployable/Deployable.ts"],"sourcesContent":["import { type Config, deployContract } from '@wagmi/core';\nimport type {\n Abi,\n Account,\n Address,\n ContractEventName,\n Hash,\n Hex,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport {\n DeployableAlreadyDeployedError,\n DeployableBuildParametersUnspecifiedError,\n DeployableMissingPayloadError,\n DeployableWagmiConfigurationRequiredError,\n} from '../errors';\nimport { getDeployedContractAddress } from '../utils';\nimport { Contract } from './Contract';\n\n/**\n * A base class representing a deployable contract, contains base implementations for deployment and initialization payload construction.\n *\n * @export\n * @typedef {GenericDeployableParams}\n */\nexport type GenericDeployableParams = Omit<\n Parameters<typeof deployContract>[1],\n 'args' | 'account'\n> & {\n args: [Hex, ...Array<Hex>];\n account?: Account;\n};\n\n/**\n * A generic type that encapsulates either an initialization payload for a contract, or a valid address for a previously deployed contract.\n *\n * @export\n * @typedef {DeployablePayloadOrAddress}\n * @template [Payload=unknown]\n */\nexport type DeployablePayloadOrAddress<Payload = unknown> = Payload | Address;\n\n/**\n * Instantion options for the base deployable.\n *\n * @export\n * @interface DeployableOptions\n * @typedef {DeployableOptions}\n */\nexport interface DeployableOptions {\n /**\n * [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n *\n * @see {@link Config}\n * @type {Config}\n */\n config: Config;\n /**\n * [Viem Local Account](https://viem.sh/docs/accounts/local), required if in a Node environment\n *\n * @see {@link Account}\n * @type {?Account}\n */\n account?: Account;\n}\n\n/**\n * A generic deployable contract that encapsulates common operations related to contract deployment\n *\n * @export\n * @class Deployable\n * @typedef {Deployable}\n * @template [Payload=unknown]\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=ContractEventName<ContractAbi>]\n * @extends {Contract<ContractAbi, ContractEvent>}\n */\nexport class Deployable<\n Payload,\n ContractAbi extends Abi,\n> extends Contract<ContractAbi> {\n /**\n * The deployable payload used either for contract construction or initialization\n *\n * @protected\n * @type {(Payload | undefined)}\n */\n protected _payload: Payload | undefined;\n /**\n * If it exists, [Viem Local Account](https://viem.sh/docs/accounts/local), if in a Node environment\n *\n * @protected\n * @type {?Account}\n */\n protected _account?: Account;\n\n /**\n * Creates an instance of Deployable.\n *\n * @constructor\n * @param {DeployableOptions} param0\n * @param {?Account} [param0.account]\n * @param {Config} param0.config\n * @param {DeployablePayloadOrAddress<Payload>} payload\n */\n constructor(\n { account, config }: DeployableOptions,\n payload?: DeployablePayloadOrAddress<Payload>,\n ) {\n if (typeof payload === 'string') {\n super(config, payload as Address);\n } else {\n super(config, undefined);\n this._payload = payload as Payload;\n }\n if (account) this._account = account;\n }\n\n /**\n * Returns the attached deployable payload, if it exists\n *\n * @readonly\n * @type {Payload}\n */\n get payload() {\n return this._payload;\n }\n\n /**\n * Attaches a new payload for use with this deployable's initialization\n *\n * @public\n * @param {Payload} payload\n * @returns {this}\n */\n public withPayload(payload: Payload) {\n this._payload = payload;\n return this;\n }\n\n /**\n * High level deployment function to deploy and await the contract address.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)\n * @returns {unknown}\n */\n protected async deploy(\n _payload?: Payload,\n _options?: DeployableOptions,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n const config = _options?.config || this._config;\n const address = await getDeployedContractAddress(\n config,\n this.deployRaw(_payload, _options),\n waitParams,\n );\n this._address = address;\n return this;\n }\n\n /**\n * The lower level contract deployment function that does not await for the transaction receipt.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {Promise<Hash>}\n * @throws {@link DeployableAlreadyDeployedError}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected async deployRaw(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): Promise<Hash> {\n if (this.address) throw new DeployableAlreadyDeployedError(this.address);\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return await deployContract(options.config, {\n ...this.buildParameters(payload),\n ...this.optionallyAttachAccount(options.account),\n });\n }\n\n /**\n * Internal function to attach the connected account to write methods to avoid manually passing in an account each call.\n *\n * @protected\n * @param {?Account} [account]\n * @returns {({ account: Account; } | { account?: undefined; })}\n */\n protected optionallyAttachAccount(account?: Account) {\n if (account) return { account };\n return this._account ? { account: this._account } : {};\n }\n\n /**\n * Base parameter constructor, should return a partial `viem.deployContract` parameters shape including abi, bytecode, and arguments, if any.\n * Expected to be overridden by protocol contracts.\n *\n * @public\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public buildParameters(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n throw new DeployableBuildParametersUnspecifiedError();\n }\n\n /**\n * Internal method used to ensure that a Wagmi configuration and payload are always present when deploying.\n *\n * @protected\n * @template [P=Payload]\n * @param {?P} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {[P, DeployableOptions]}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected validateDeploymentConfig<P = Payload>(\n _payload?: P,\n _options?: DeployableOptions,\n ) {\n const options = _options || {\n config: this._config,\n account: this._account,\n };\n if (!options) throw new DeployableWagmiConfigurationRequiredError();\n const payload = _payload || this._payload;\n return [payload, options] as [P, DeployableOptions];\n }\n}\n"],"names":["Deployable","Contract","account","config","payload","_payload","_options","waitParams","address","getDeployedContractAddress","DeployableAlreadyDeployedError","options","deployContract","DeployableBuildParametersUnspecifiedError","DeployableWagmiConfigurationRequiredError"],"mappings":";;;;AA6EO,MAAMA,UAGHC,EAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB9B,YACE,EAAE,SAAAC,GAAS,QAAAC,EAAA,GACXC,GACA;AACI,IAAA,OAAOA,KAAY,WACrB,MAAMD,GAAQC,CAAkB,KAEhC,MAAMD,GAAQ,MAAS,GACvB,KAAK,WAAWC,IAEdF,WAAc,WAAWA;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,UAAU;AACZ,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,YAAYE,GAAkB;AACnC,gBAAK,WAAWA,GACT;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAgB,OACdC,GACAC,GACAC,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ent":["import { type Config, deployContract } from '@wagmi/core';\nimport type {\n Abi,\n Account,\n Address,\n ContractEventName,\n Hash,\n Hex,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport {\n DeployableAlreadyDeployedError,\n DeployableBuildParametersUnspecifiedError,\n DeployableMissingPayloadError,\n DeployableWagmiConfigurationRequiredError,\n} from '../errors';\nimport { getDeployedContractAddress } from '../utils';\nimport { Contract } from './Contract';\n\n/**\n * A base class representing a deployable contract, contains base implementations for deployment and initialization payload construction.\n *\n * @export\n * @typedef {GenericDeployableParams}\n */\nexport type GenericDeployableParams = Omit<\n Parameters<typeof deployContract>[1],\n 'args' | 'account'\n> & {\n args: [Hex, ...Array<Hex>];\n account?: Account;\n};\n\n/**\n * A generic type that encapsulates either an initialization payload for a contract, or a valid address for a previously deployed contract.\n *\n * @export\n * @typedef {DeployablePayloadOrAddress}\n * @template [Payload=unknown]\n */\nexport type DeployablePayloadOrAddress<Payload = unknown> = Payload | Address;\n\n/**\n * Instantion options for the base deployable.\n *\n * @export\n * @interface DeployableOptions\n * @typedef {DeployableOptions}\n */\nexport interface DeployableOptions {\n /**\n * [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n *\n * @see {@link Config}\n * @type {Config}\n */\n config: Config;\n /**\n * [Viem Local Account](https://viem.sh/docs/accounts/local), required if in a Node environment\n *\n * @see {@link Account}\n * @type {?Account}\n */\n account?: Account;\n}\n\n/**\n * A generic deployable contract that encapsulates common operations related to contract deployment\n *\n * @export\n * @class Deployable\n * @typedef {Deployable}\n * @template [Payload=unknown]\n * @template {Abi} [ContractAbi=[]]\n * @template {ContractEventName<ContractAbi>} [ContractEvent=ContractEventName<ContractAbi>]\n * @extends {Contract<ContractAbi, ContractEvent>}\n */\nexport class Deployable<\n Payload,\n ContractAbi extends Abi,\n> extends Contract<ContractAbi> {\n /**\n * The deployable payload used either for contract construction or initialization\n *\n * @protected\n * @type {(Payload | undefined)}\n */\n protected _payload: Payload | undefined;\n /**\n * If it exists, [Viem Local Account](https://viem.sh/docs/accounts/local), if in a Node environment\n *\n * @protected\n * @type {?Account}\n */\n protected _account?: Account;\n\n /**\n * Creates an instance of Deployable.\n *\n * @constructor\n * @param {DeployableOptions} param0\n * @param {?Account} [param0.account]\n * @param {Config} param0.config\n * @param {DeployablePayloadOrAddress<Payload>} payload\n */\n constructor(\n { account, config }: DeployableOptions,\n payload?: DeployablePayloadOrAddress<Payload>,\n ) {\n if (typeof payload === 'string') {\n super(config, payload as Address);\n } else {\n super(config, undefined);\n this._payload = payload as Payload;\n }\n if (account) this._account = account;\n }\n\n /**\n * Returns the attached deployable payload, if it exists\n *\n * @readonly\n * @type {Payload}\n */\n get payload() {\n return this._payload;\n }\n\n /**\n * Attaches a new payload for use with this deployable's initialization\n *\n * @public\n * @param {Payload} payload\n * @returns {this}\n */\n public withPayload(payload: Payload) {\n this._payload = payload;\n return this;\n }\n\n /**\n * High level deployment function to deploy and await the contract address.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)\n * @returns {Promise<this>}\n */\n protected async deploy(\n _payload?: Payload,\n _options?: DeployableOptions,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n const config = _options?.config || this._config;\n const address = await getDeployedContractAddress(\n config,\n this.deployRaw(_payload, _options),\n waitParams,\n );\n this._address = address;\n return this;\n }\n\n /**\n * The lower level contract deployment function that does not await for the transaction receipt.\n * This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,\n * which makes it useless for Boost components.\n * Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {Promise<Hash>}\n * @throws {@link DeployableAlreadyDeployedError}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected async deployRaw(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): Promise<Hash> {\n if (this.address) throw new DeployableAlreadyDeployedError(this.address);\n const [payload, options] = this.validateDeploymentConfig(\n _payload,\n _options,\n );\n return await deployContract(options.config, {\n ...this.buildParameters(payload),\n ...this.optionallyAttachAccount(options.account),\n });\n }\n\n /**\n * Internal function to attach the connected account to write methods to avoid manually passing in an account each call.\n *\n * @protected\n * @param {?Account} [account]\n * @returns {({ account: Account; } | { account?: undefined; })}\n */\n protected optionallyAttachAccount(account?: Account) {\n if (account) return { account };\n return this._account ? { account: this._account } : {};\n }\n\n /**\n * Base parameter constructor, should return a partial `viem.deployContract` parameters shape including abi, bytecode, and arguments, if any.\n * Expected to be overridden by protocol contracts.\n *\n * @public\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {GenericDeployableParams}\n */\n public buildParameters(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): GenericDeployableParams {\n throw new DeployableBuildParametersUnspecifiedError();\n }\n\n /**\n * Internal method used to ensure that a Wagmi configuration and payload are always present when deploying.\n *\n * @protected\n * @template [P=Payload]\n * @param {?P} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {[P, DeployableOptions]}\n * @throws {@link DeployableWagmiConfigurationRequiredError}\n * @throws {@link DeployableMissingPayloadError}\n */\n protected validateDeploymentConfig<P = Payload>(\n _payload?: P,\n _options?: DeployableOptions,\n ) {\n const options = _options || {\n config: this._config,\n account: this._account,\n };\n if (!options) throw new DeployableWagmiConfigurationRequiredError();\n const payload = _payload || this._payload;\n return [payload, options] as [P, DeployableOptions];\n }\n}\n"],"names":["Deployable","Contract","account","config","payload","_payload","_options","waitParams","address","getDeployedContractAddress","DeployableAlreadyDeployedError","options","deployContract","DeployableBuildParametersUnspecifiedError","DeployableWagmiConfigurationRequiredError"],"mappings":";;;;AA6EO,MAAMA,UAGHC,EAAsB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAyB9B,YACE,EAAE,SAAAC,GAAS,QAAAC,EAAA,GACXC,GACA;AACI,IAAA,OAAOA,KAAY,WACrB,MAAMD,GAAQC,CAAkB,KAEhC,MAAMD,GAAQ,MAAS,GACvB,KAAK,WAAWC,IAEdF,WAAc,WAAWA;AAAA,EAC/B;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAI,UAAU;AACZ,WAAO,KAAK;AAAA,EACd;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASO,YAAYE,GAAkB;AACnC,gBAAK,WAAWA,GACT;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAeA,MAAgB,OACdC,GACAC,GACAC,GACA;AACM,UAAAJ,KAASG,KAAA,gBAAAA,EAAU,WAAU,KAAK,SAClCE,IAAU,MAAMC;AAAA,MACpBN;AAAA,MACA,KAAK,UAAUE,GAAUC,CAAQ;AAAA,MACjCC;AAAA,IAAA;AAEF,gBAAK,WAAWC,GACT;AAAA,EACT;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAiBA,MAAgB,UACdH,GACAC,GACe;AACf,QAAI,KAAK,QAAS,OAAM,IAAII,EAA+B,KAAK,OAAO;AACvE,UAAM,CAACN,GAASO,CAAO,IAAI,KAAK;AAAA,MAC9BN;AAAA,MACAC;AAAA,IAAA;AAEK,WAAA,MAAMM,EAAeD,EAAQ,QAAQ;AAAA,MAC1C,GAAG,KAAK,gBAAgBP,CAAO;AAAA,MAC/B,GAAG,KAAK,wBAAwBO,EAAQ,OAAO;AAAA,IAAA,CAChD;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASU,wBAAwBT,GAAmB;AAC/C,WAAAA,IAAgB,EAAE,SAAAA,MACf,KAAK,WAAW,EAAE,SAAS,KAAK,aAAa;EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWO,gBACLG,GACAC,GACyB;AACzB,UAAM,IAAIO,EAA0C;AAAA,EACtD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAaU,yBACRR,GACAC,GACA;AACA,UAAMK,IAAUL,KAAY;AAAA,MAC1B,QAAQ,KAAK;AAAA,MACb,SAAS,KAAK;AAAA,IAAA;AAEhB,QAAI,CAACK,EAAe,OAAA,IAAIG;AAEjB,WAAA,CADST,KAAY,KAAK,UAChBM,CAAO;AAAA,EAC1B;AACF;"}
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../generated-CMQ6ZC2_.cjs"),u=require("@wagmi/core"),i=require("viem"),d=require("../errors.cjs"),l=require("../utils.cjs"),h=require("./Deployable.cjs"),a=class a extends h.Deployable{constructor(s,e,t){super(s,e),this._isBase=!0,typeof e=="string"&&i.isAddress(e)&&e!==i.zeroAddress&&!Object.values(this.bases).some(r=>!e||!r?!1:i.isAddressEqual(e,r))&&(t=!1),t!==void 0&&(this._isBase=t)}get isBase(){return this.address&&Object.values(this.bases).some(s=>i.isAddressEqual(this.address,s))?!0:this._isBase}get bases(){return this.constructor.bases}get registryType(){return this.constructor.registryType}async deploy(s,e,t){return await super.deploy(s,e,t),this.assertValidAddress(),this}async deployRaw(s,e){if(this.address)throw new d.DeployableAlreadyDeployedError(this.address);const t=s||this._payload,r=(e==null?void 0:e.config)||this._config,{args:y,...o}=this.buildParameters(t);return await u.deployContract(r,{...o,...this.optionallyAttachAccount(e==null?void 0:e.account),args:[]})}async supportsInterface(s,e){return await c.ei(this._config,{address:this.assertValidAddress(),...this.optionallyAttachAccount(),...e,args:[s]})}async getComponentInterface(s){return await c.Ya(this._config,{address:this.assertValidAddress(),...this.optionallyAttachAccount(),...s,args:[]})}validateDeploymentConfig(s,e){const t=s||this._payload;if(!t)throw new d.DeployableMissingPayloadError;return super.validateDeploymentConfig(t,e)}};a.bases={},a.registryType=l.RegistryType.ACTION;let n=a;exports.DeployableTarget=n;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("../generated-B0tk-c9b.cjs"),u=require("@wagmi/core"),i=require("viem"),d=require("../errors.cjs"),l=require("../utils.cjs"),h=require("./Deployable.cjs"),a=class a extends h.Deployable{constructor(s,e,t){super(s,e),this._isBase=!0,typeof e=="string"&&i.isAddress(e)&&e!==i.zeroAddress&&!Object.values(this.bases).some(r=>!e||!r?!1:i.isAddressEqual(e,r))&&(t=!1),t!==void 0&&(this._isBase=t)}get isBase(){return this.address&&Object.values(this.bases).some(s=>i.isAddressEqual(this.address,s))?!0:this._isBase}get bases(){return this.constructor.bases}get registryType(){return this.constructor.registryType}async deploy(s,e,t){return await super.deploy(s,e,t),this.assertValidAddress(),this}async deployRaw(s,e){if(this.address)throw new d.DeployableAlreadyDeployedError(this.address);const t=s||this._payload,r=(e==null?void 0:e.config)||this._config,{args:y,...o}=this.buildParameters(t);return await u.deployContract(r,{...o,...this.optionallyAttachAccount(e==null?void 0:e.account),args:[]})}async supportsInterface(s,e){return await c.ti(this._config,{address:this.assertValidAddress(),...this.optionallyAttachAccount(),...e,args:[s]})}async getComponentInterface(s){return await c.ei(this._config,{address:this.assertValidAddress(),...this.optionallyAttachAccount(),...s,args:[]})}validateDeploymentConfig(s,e){const t=s||this._payload;if(!t)throw new d.DeployableMissingPayloadError;return super.validateDeploymentConfig(t,e)}};a.bases={},a.registryType=l.RegistryType.ACTION;let n=a;exports.DeployableTarget=n;
2
2
  //# sourceMappingURL=DeployableTarget.cjs.map