@boostxyz/sdk 0.0.0-alpha.2 → 0.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Actions/Action.cjs +2 -1
- package/dist/Actions/Action.cjs.map +1 -0
- package/dist/Actions/Action.d.ts +1 -1
- package/dist/Actions/Action.d.ts.map +1 -1
- package/dist/Actions/Action.js +14 -12
- package/dist/Actions/Action.js.map +1 -0
- package/dist/Actions/ContractAction.d.ts +57 -14
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +50 -23
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.cjs +2 -1
- package/dist/Actions/EventAction.cjs.map +1 -0
- package/dist/Actions/EventAction.d.ts +405 -36
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -209
- package/dist/Actions/EventAction.js.map +1 -0
- package/dist/AllowLists/AllowList.cjs +2 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -0
- package/dist/AllowLists/AllowList.d.ts +6 -5
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +46 -22
- package/dist/AllowLists/AllowList.js.map +1 -0
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +2 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -0
- package/dist/AllowLists/SimpleAllowList.d.ts +124 -40
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +77 -77
- package/dist/AllowLists/SimpleAllowList.js.map +1 -0
- package/dist/AllowLists/SimpleDenyList.cjs +2 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -0
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +12 -200
- package/dist/AllowLists/SimpleDenyList.js.map +1 -0
- package/dist/Auth/Auth.cjs +1 -0
- package/dist/Auth/Auth.cjs.map +1 -0
- package/dist/Auth/Auth.js +1 -0
- package/dist/Auth/Auth.js.map +1 -0
- package/dist/Auth/PassthroughAuth.cjs +2 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -0
- package/dist/Auth/PassthroughAuth.js +5 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -0
- package/dist/Boost.cjs +2 -1
- package/dist/Boost.cjs.map +1 -0
- package/dist/Boost.d.ts +111 -1
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +140 -5
- package/dist/Boost.js.map +1 -0
- package/dist/BoostCore-3-U1xTQN.cjs +3 -0
- package/dist/BoostCore-3-U1xTQN.cjs.map +1 -0
- package/dist/BoostCore-DVGBUr2y.js +1477 -0
- package/dist/BoostCore-DVGBUr2y.js.map +1 -0
- package/dist/BoostCore.cjs +2 -2
- package/dist/BoostCore.cjs.map +1 -0
- package/dist/BoostCore.d.ts +166 -43
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +30 -1103
- package/dist/BoostCore.js.map +1 -0
- package/dist/BoostRegistry.cjs +2 -1
- package/dist/BoostRegistry.cjs.map +1 -0
- package/dist/BoostRegistry.d.ts +64 -23
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +162 -88
- package/dist/BoostRegistry.js.map +1 -0
- package/dist/Budgets/Budget.cjs +2 -1
- package/dist/Budgets/Budget.cjs.map +1 -0
- package/dist/Budgets/Budget.d.ts +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +15 -13
- package/dist/Budgets/Budget.js.map +1 -0
- package/dist/Budgets/ManagedBudget.cjs +2 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -0
- package/dist/Budgets/ManagedBudget.d.ts +78 -188
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +86 -286
- package/dist/Budgets/ManagedBudget.js.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +243 -87
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +2 -1
- package/dist/Deployable/Contract.cjs.map +1 -0
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +7 -8
- package/dist/Deployable/Contract.js.map +1 -0
- package/dist/Deployable/Deployable.cjs +1 -0
- package/dist/Deployable/Deployable.cjs.map +1 -0
- package/dist/Deployable/Deployable.d.ts +9 -3
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +10 -5
- package/dist/Deployable/Deployable.js.map +1 -0
- package/dist/Deployable/DeployableTarget.cjs +2 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -0
- package/dist/Deployable/DeployableTarget.d.ts +16 -15
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +49 -42
- package/dist/Deployable/DeployableTarget.js.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs +2 -0
- package/dist/Deployable/DeployableTargetWithRBAC.cjs.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts +179 -0
- package/dist/Deployable/DeployableTargetWithRBAC.d.ts.map +1 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js +222 -0
- package/dist/Deployable/DeployableTargetWithRBAC.js.map +1 -0
- package/dist/EventAction-CIPqmAoP.js +1450 -0
- package/dist/EventAction-CIPqmAoP.js.map +1 -0
- package/dist/EventAction-d-oeqZQs.cjs +2 -0
- package/dist/EventAction-d-oeqZQs.cjs.map +1 -0
- package/dist/Incentive-Bp8Sez7M.js +298 -0
- package/dist/Incentive-Bp8Sez7M.js.map +1 -0
- package/dist/Incentive-Djnzseoj.cjs +2 -0
- package/dist/Incentive-Djnzseoj.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +2 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -0
- package/dist/Incentives/AllowListIncentive.d.ts +49 -19
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +50 -34
- package/dist/Incentives/AllowListIncentive.js.map +1 -0
- package/dist/Incentives/CGDAIncentive.cjs +2 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -0
- package/dist/Incentives/CGDAIncentive.d.ts +118 -22
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +67 -42
- package/dist/Incentives/CGDAIncentive.js.map +1 -0
- package/dist/Incentives/ERC1155Incentive.d.ts +99 -38
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +2 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -0
- package/dist/Incentives/ERC20Incentive.d.ts +73 -29
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +71 -48
- package/dist/Incentives/ERC20Incentive.js.map +1 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts +523 -0
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +65 -28
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +2 -1
- package/dist/Incentives/Incentive.cjs.map +1 -0
- package/dist/Incentives/Incentive.d.ts +4 -7
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +17 -278
- package/dist/Incentives/Incentive.js.map +1 -0
- package/dist/Incentives/PointsIncentive.cjs +2 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -0
- package/dist/Incentives/PointsIncentive.d.ts +65 -21
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +57 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -0
- package/dist/SimpleDenyList-BwfNjRsg.cjs +2 -0
- package/dist/SimpleDenyList-BwfNjRsg.cjs.map +1 -0
- package/dist/SimpleDenyList-Cn5WpNn0.js +132 -0
- package/dist/SimpleDenyList-Cn5WpNn0.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +2 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -0
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +165 -36
- package/dist/Validators/SignerValidator.js.map +1 -0
- package/dist/Validators/Validator.cjs +2 -1
- package/dist/Validators/Validator.cjs.map +1 -0
- package/dist/Validators/Validator.d.ts +2 -2
- package/dist/Validators/Validator.d.ts.map +1 -1
- package/dist/Validators/Validator.js +12 -10
- package/dist/Validators/Validator.js.map +1 -0
- package/dist/claiming.cjs +2 -0
- package/dist/claiming.cjs.map +1 -0
- package/dist/claiming.d.ts +43 -0
- package/dist/claiming.d.ts.map +1 -0
- package/dist/claiming.js +17 -0
- package/dist/claiming.js.map +1 -0
- package/dist/componentInterfaces-D09mhzxO.cjs +2 -0
- package/dist/componentInterfaces-D09mhzxO.cjs.map +1 -0
- package/dist/componentInterfaces-RXBMI5yH.js +14 -0
- package/dist/componentInterfaces-RXBMI5yH.js.map +1 -0
- package/dist/deployments-BM42vImE.js +43 -0
- package/dist/deployments-BM42vImE.js.map +1 -0
- package/dist/deployments-CMdF5uEC.cjs +2 -0
- package/dist/deployments-CMdF5uEC.cjs.map +1 -0
- package/dist/deployments.json +41 -0
- package/dist/errors.cjs +2 -1
- package/dist/errors.cjs.map +1 -0
- package/dist/errors.d.ts +403 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +285 -39
- package/dist/errors.js.map +1 -0
- package/dist/generated-B0tk-c9b.cjs +3 -0
- package/dist/generated-B0tk-c9b.cjs.map +1 -0
- package/dist/{generated-x_abr3Yv.js → generated-B7VaSah4.js} +2058 -2541
- package/dist/generated-B7VaSah4.js.map +1 -0
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.ts +10 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -1353
- package/dist/index.js.map +1 -0
- package/dist/transfers.cjs +2 -0
- package/dist/transfers.cjs.map +1 -0
- package/dist/transfers.d.ts +198 -0
- package/dist/transfers.d.ts.map +1 -0
- package/dist/transfers.js +84 -0
- package/dist/transfers.js.map +1 -0
- package/dist/utils.cjs +2 -1
- package/dist/utils.cjs.map +1 -0
- package/dist/utils.d.ts +26 -1350
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -636
- package/dist/utils.js.map +1 -0
- package/package.json +37 -11
- package/src/Actions/Action.test.ts +79 -0
- package/src/Actions/Action.ts +61 -0
- package/src/Actions/ContractAction.test.ts +197 -0
- package/src/Actions/ContractAction.ts +300 -0
- package/src/Actions/ERC721MintAction.test.ts +112 -0
- package/src/Actions/ERC721MintAction.ts +291 -0
- package/src/Actions/EventAction.test.ts +787 -0
- package/src/Actions/EventAction.ts +1214 -0
- package/src/AllowLists/AllowList.test.ts +64 -0
- package/src/AllowLists/AllowList.ts +62 -0
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +52 -0
- package/src/AllowLists/SimpleAllowList.ts +262 -0
- package/src/AllowLists/SimpleDenyList.test.ts +52 -0
- package/src/AllowLists/SimpleDenyList.ts +250 -0
- package/src/Auth/Auth.ts +11 -0
- package/src/Auth/PassthroughAuth.test.ts +12 -0
- package/src/Auth/PassthroughAuth.ts +80 -0
- package/src/Boost.ts +309 -0
- package/src/BoostCore.test.ts +827 -0
- package/src/BoostCore.ts +1447 -0
- package/src/BoostRegistry.ts +543 -0
- package/src/Budgets/Budget.test.ts +27 -0
- package/src/Budgets/Budget.ts +60 -0
- package/src/Budgets/ManagedBudget.test.ts +217 -0
- package/src/Budgets/ManagedBudget.ts +534 -0
- package/src/Budgets/VestingBudget.test.ts +123 -0
- package/src/Budgets/VestingBudget.ts +530 -0
- package/src/Deployable/Contract.ts +228 -0
- package/src/Deployable/Deployable.ts +250 -0
- package/src/Deployable/DeployableTarget.ts +234 -0
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +143 -0
- package/src/Incentives/AllowListIncentive.ts +336 -0
- package/src/Incentives/CGDAIncentive.test.ts +132 -0
- package/src/Incentives/CGDAIncentive.ts +470 -0
- package/src/Incentives/ERC1155Incentive.test.ts +87 -0
- package/src/Incentives/ERC1155Incentive.ts +465 -0
- package/src/Incentives/ERC20Incentive.test.ts +130 -0
- package/src/Incentives/ERC20Incentive.ts +484 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +309 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +136 -0
- package/src/Incentives/ERC20VariableIncentive.ts +422 -0
- package/src/Incentives/Incentive.test.ts +92 -0
- package/src/Incentives/Incentive.ts +86 -0
- package/src/Incentives/PointsIncentive.test.ts +139 -0
- package/src/Incentives/PointsIncentive.ts +367 -0
- package/src/Validators/SignerValidator.test.ts +159 -0
- package/src/Validators/SignerValidator.ts +683 -0
- package/src/Validators/Validator.test.ts +21 -0
- package/src/Validators/Validator.ts +55 -0
- package/src/claiming.ts +56 -0
- package/src/errors.ts +844 -0
- package/src/index.test.ts +122 -0
- package/src/index.ts +58 -0
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +44 -0
- package/src/utils.ts +247 -0
- package/dist/Budgets/SimpleBudget.d.ts +0 -793
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/generated-BaaleHW-.cjs +0 -2
|
@@ -1 +1 @@
|
|
|
1
|
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EAC5C,KAAK,CAAC,QAAQ,SAAS,eAAe,CACpC,WAAW,EACX,KAAK,CACN,GAAG,eAAe,CAAC,WAAW,EAAE,KAAK,CAAC,EAEvC,MAAM,CAAC,EAAE,IAAI,CACX,aAAa,CAAC,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,QAAQ,EAAE,CAAC,EACvD,OAAO,GAAG,QAAQ,CACnB,GAAG;QACF,SAAS,CAAC,EAAE,KAAK,CAAC;QAClB,UAAU,CAAC,EAAE,KAAK,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;
|
|
@@ -53,8 +53,7 @@ class v {
|
|
|
53
53
|
*/
|
|
54
54
|
assertValidAddress() {
|
|
55
55
|
const t = this.address;
|
|
56
|
-
if (!t)
|
|
57
|
-
throw new r();
|
|
56
|
+
if (!t) throw new r();
|
|
58
57
|
return t;
|
|
59
58
|
}
|
|
60
59
|
/**
|
|
@@ -108,7 +107,6 @@ class v {
|
|
|
108
107
|
* A typed wrapper for `wagmi.watchContractEvent`
|
|
109
108
|
*
|
|
110
109
|
* @public
|
|
111
|
-
* @async
|
|
112
110
|
* @template {ContractEvent} event
|
|
113
111
|
* @param {(
|
|
114
112
|
* log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],
|
|
@@ -116,9 +114,9 @@ class v {
|
|
|
116
114
|
* @param {?WatchParams<ContractAbi, event> & {
|
|
117
115
|
* eventName?: event;
|
|
118
116
|
* }} [params]
|
|
119
|
-
* @returns {
|
|
117
|
+
* @returns {() => void}
|
|
120
118
|
*/
|
|
121
|
-
|
|
119
|
+
subscribe(t, e) {
|
|
122
120
|
return o(this._config, {
|
|
123
121
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
124
122
|
...e,
|
|
@@ -138,12 +136,13 @@ class v {
|
|
|
138
136
|
* @template [Result=unknown]
|
|
139
137
|
* @param {Promise<HashAndSimulatedResult<Result>>} hashPromise
|
|
140
138
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
|
|
141
|
-
* @returns {
|
|
139
|
+
* @returns {Promise<Result>}
|
|
142
140
|
*/
|
|
143
141
|
async awaitResult(t, e) {
|
|
144
|
-
return h(this._config, t, e);
|
|
142
|
+
return await h(this._config, t, e);
|
|
145
143
|
}
|
|
146
144
|
}
|
|
147
145
|
export {
|
|
148
146
|
v as Contract
|
|
149
147
|
};
|
|
148
|
+
//# sourceMappingURL=Contract.js.map
|
|
@@ -0,0 +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 {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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AAA,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,2 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("@wagmi/core"),a=require("../errors.cjs"),n=require("../utils.cjs"),c=require("./Contract.cjs");class l extends c.Contract{constructor({account:t,config:e},o){typeof o=="string"?super(e,o):(super(e,void 0),this._payload=o),t&&(this._account=t)}get payload(){return this._payload}withPayload(t){return this._payload=t,this}async deploy(t,e,o){const r=(e==null?void 0:e.config)||this._config,i=await n.getDeployedContractAddress(r,this.deployRaw(t,e),o);return this._address=i,this}async deployRaw(t,e){if(this.address)throw new a.DeployableAlreadyDeployedError(this.address);const[o,r]=this.validateDeploymentConfig(t,e);return await s.deployContract(r.config,{...this.buildParameters(o),...this.optionallyAttachAccount(r.account)})}optionallyAttachAccount(t){return t?{account:t}:this._account?{account:this._account}:{}}buildParameters(t,e){throw new a.DeployableBuildParametersUnspecifiedError}validateDeploymentConfig(t,e){const o=e||{config:this._config,account:this._account};if(!o)throw new a.DeployableWagmiConfigurationRequiredError;return[t||this._payload,o]}}exports.Deployable=l;
|
|
2
|
+
//# sourceMappingURL=Deployable.cjs.map
|
|
@@ -0,0 +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 {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"}
|
|
@@ -95,17 +95,23 @@ export declare class Deployable<Payload, ContractAbi extends Abi> extends Contra
|
|
|
95
95
|
withPayload(payload: Payload): this;
|
|
96
96
|
/**
|
|
97
97
|
* High level deployment function to deploy and await the contract address.
|
|
98
|
+
* This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,
|
|
99
|
+
* which makes it useless for Boost components.
|
|
100
|
+
* Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.
|
|
98
101
|
*
|
|
99
102
|
* @public
|
|
100
103
|
* @async
|
|
101
104
|
* @param {?Payload} [_payload]
|
|
102
105
|
* @param {?DeployableOptions} [_options]
|
|
103
106
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
|
|
104
|
-
* @returns {
|
|
107
|
+
* @returns {Promise<this>}
|
|
105
108
|
*/
|
|
106
|
-
deploy(_payload?: Payload, _options?: DeployableOptions, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<this>;
|
|
109
|
+
protected deploy(_payload?: Payload, _options?: DeployableOptions, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<this>;
|
|
107
110
|
/**
|
|
108
111
|
* The lower level contract deployment function that does not await for the transaction receipt.
|
|
112
|
+
* This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,
|
|
113
|
+
* which makes it useless for Boost components.
|
|
114
|
+
* Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.
|
|
109
115
|
*
|
|
110
116
|
* @public
|
|
111
117
|
* @async
|
|
@@ -116,7 +122,7 @@ export declare class Deployable<Payload, ContractAbi extends Abi> extends Contra
|
|
|
116
122
|
* @throws {@link DeployableWagmiConfigurationRequiredError}
|
|
117
123
|
* @throws {@link DeployableMissingPayloadError}
|
|
118
124
|
*/
|
|
119
|
-
deployRaw(_payload?: Payload, _options?: DeployableOptions): Promise<Hash>;
|
|
125
|
+
protected deployRaw(_payload?: Payload, _options?: DeployableOptions): Promise<Hash>;
|
|
120
126
|
/**
|
|
121
127
|
* Internal function to attach the connected account to write methods to avoid manually passing in an account each call.
|
|
122
128
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Deployable.d.ts","sourceRoot":"","sources":["../../src/Deployable/Deployable.ts"],"names":[],"mapp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AEV;IAED;;;;;;OAMG;IACI,WAAW,CAAC,OAAO,EAAE,OAAO;IAKnC;;;;;;;;;;;;OAYG;cACa,MAAM,CACpB,QAAQ,CAAC,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,iBAAiB,EAC5B,UAAU,CAAC,EAAE,IAAI,CAAC,mCAAmC,EAAE,MAAM,CAAC;IAYhE;;;;;;;;;;;;;;OAcG;cACa,SAAS,CACvB,QAAQ,CAAC,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,IAAI,CAAC;IAYhB;;;;;;OAMG;IACH,SAAS,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,OAAO;;;;;IAKnD;;;;;;;;OAQG;IACI,eAAe,CACpB,QAAQ,CAAC,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,uBAAuB;IAI1B;;;;;;;;;;OAUG;IACH,SAAS,CAAC,wBAAwB,CAAC,CAAC,GAAG,OAAO,EAC5C,QAAQ,CAAC,EAAE,CAAC,EACZ,QAAQ,CAAC,EAAE,iBAAiB,GAQC,CAAC,CAAC,EAAE,iBAAiB,CAAC;CAEtD"}
|
|
@@ -36,13 +36,16 @@ class m extends d {
|
|
|
36
36
|
}
|
|
37
37
|
/**
|
|
38
38
|
* High level deployment function to deploy and await the contract address.
|
|
39
|
+
* This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,
|
|
40
|
+
* which makes it useless for Boost components.
|
|
41
|
+
* Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.
|
|
39
42
|
*
|
|
40
43
|
* @public
|
|
41
44
|
* @async
|
|
42
45
|
* @param {?Payload} [_payload]
|
|
43
46
|
* @param {?DeployableOptions} [_options]
|
|
44
47
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
|
|
45
|
-
* @returns {
|
|
48
|
+
* @returns {Promise<this>}
|
|
46
49
|
*/
|
|
47
50
|
async deploy(t, o, a) {
|
|
48
51
|
const e = (o == null ? void 0 : o.config) || this._config, r = await c(
|
|
@@ -54,6 +57,9 @@ class m extends d {
|
|
|
54
57
|
}
|
|
55
58
|
/**
|
|
56
59
|
* The lower level contract deployment function that does not await for the transaction receipt.
|
|
60
|
+
* This is mainly a convenience method to easily deploy a contract, but will not initialize a `Cloneable`,
|
|
61
|
+
* which makes it useless for Boost components.
|
|
62
|
+
* Obviously you can ignore the TS warnings and use this, but you shouldn't in most all cases.
|
|
57
63
|
*
|
|
58
64
|
* @public
|
|
59
65
|
* @async
|
|
@@ -65,8 +71,7 @@ class m extends d {
|
|
|
65
71
|
* @throws {@link DeployableMissingPayloadError}
|
|
66
72
|
*/
|
|
67
73
|
async deployRaw(t, o) {
|
|
68
|
-
if (this.address)
|
|
69
|
-
throw new s(this.address);
|
|
74
|
+
if (this.address) throw new s(this.address);
|
|
70
75
|
const [a, e] = this.validateDeploymentConfig(
|
|
71
76
|
t,
|
|
72
77
|
o
|
|
@@ -114,11 +119,11 @@ class m extends d {
|
|
|
114
119
|
config: this._config,
|
|
115
120
|
account: this._account
|
|
116
121
|
};
|
|
117
|
-
if (!a)
|
|
118
|
-
throw new l();
|
|
122
|
+
if (!a) throw new l();
|
|
119
123
|
return [t || this._payload, a];
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
126
|
export {
|
|
123
127
|
m as Deployable
|
|
124
128
|
};
|
|
129
|
+
//# sourceMappingURL=Deployable.js.map
|
|
@@ -0,0 +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 {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,E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E,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 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
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
|
+
//# sourceMappingURL=DeployableTarget.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeployableTarget.cjs","sources":["../../src/Deployable/DeployableTarget.ts"],"sourcesContent":["import {\n type aCloneableAbi,\n readACloneableGetComponentInterface,\n readACloneableSupportsInterface,\n} from '@boostxyz/evm';\nimport { deployContract } from '@wagmi/core';\nimport {\n type Abi,\n type Address,\n type Hash,\n type Hex,\n type WaitForTransactionReceiptParameters,\n isAddress,\n isAddressEqual,\n zeroAddress,\n} from 'viem';\nimport {\n DeployableAlreadyDeployedError,\n DeployableMissingPayloadError,\n} from '../errors';\nimport { type ReadParams, RegistryType } from '../utils';\nimport {\n Deployable,\n type DeployableOptions,\n type DeployablePayloadOrAddress,\n} from './Deployable';\n\n/**\n * A base class representing a generic base Boost Protocol target contract, extended by Actions, AllowLists, Budgets, Incentives, and Validators.\n *\n * @export\n * @class DeployableTarget\n * @typedef {DeployableTarget}\n * @template [Payload=unknown]\n * @extends {Deployable<Payload>}\n */\nexport class DeployableTarget<\n Payload,\n ContractAbi extends Abi,\n> extends Deployable<Payload, ContractAbi> {\n /**\n * A static property representing a map of stringified chain ID's to the address of the base implementation on chain, used when cloning base contracts.\n *\n * @static\n * @readonly\n * @type {Record<string, Address>}\n */\n static readonly bases: Record<number, Address> = {};\n /**\n * The target's registry type.\n *\n * @static\n * @readonly\n * @type {RegistryType}\n */\n static readonly registryType: RegistryType = RegistryType.ACTION;\n /**\n * A property asserting that the protocol should eiher clone and initialize a new target from the base implementation, or re-use an existing contract without initializing.\n *\n * @readonly\n * @type {boolean}\n */\n readonly _isBase: boolean = true;\n public get isBase() {\n if (\n !!this.address &&\n Object.values(this.bases).some((base) =>\n // biome-ignore lint/style/noNonNullAssertion: won't evaluate this if address checked and defined above\n isAddressEqual(this.address!, base),\n )\n )\n return true;\n return this._isBase;\n }\n\n /**\n * Creates an instance of DeployableTarget.\n *\n * @constructor\n * @param {DeployableOptions} options\n * @param {DeployablePayloadOrAddress<Payload>} payload - Either a given implementation's initialization payload, or an address to an existing on chain target.\n * @param {?boolean} [isBase] - A property asserting that the protocol should eiher clone and initialize a new target from the base implementation, or re-use an existing contract without initializing.\n */\n constructor(\n options: DeployableOptions,\n payload?: DeployablePayloadOrAddress<Payload>,\n isBase?: boolean,\n ) {\n super(options, payload);\n // if supplying a custom address, safe enough to assume it is not a base address which makes reusing contracts like budgets easier\n if (\n typeof payload === 'string' &&\n isAddress(payload) &&\n payload !== zeroAddress &&\n !Object.values(this.bases).some((base) => {\n if (!payload || !base) return false;\n return isAddressEqual(payload, base);\n })\n )\n isBase = false;\n if (isBase !== undefined) this._isBase = isBase;\n }\n\n /**\n * A getter that will return the base implementation's static addresses by numerical chain ID\n *\n * @public\n * @readonly\n * @type {Record<number, Address>}\n */\n public get bases(): Record<number, Address> {\n return (this.constructor as typeof DeployableTarget).bases;\n }\n\n /**\n * A getter that returns the registry type of the base implementation\n *\n * @public\n * @readonly\n * @type {RegistryType}\n */\n public get registryType(): RegistryType {\n return (this.constructor as typeof DeployableTarget).registryType;\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @async\n * @param {?Payload} [payload]\n * @param {?DeployableOptions} [options]\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<this>}\n */\n protected override async deploy(\n payload?: Payload,\n options?: DeployableOptions,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n await super.deploy(payload, options, waitParams);\n this.assertValidAddress();\n return this;\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {Promise<Hash>}\n */\n protected override async deployRaw(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): Promise<Hash> {\n if (this.address) throw new DeployableAlreadyDeployedError(this.address);\n const payload = _payload || this._payload;\n const config = _options?.config || this._config;\n const { args, ...deployment } = this.buildParameters(payload);\n return await deployContract(config, {\n ...deployment,\n ...this.optionallyAttachAccount(_options?.account),\n // Deployable targets don't construct with arguments, they initialize with encoded payloads\n args: [],\n });\n }\n\n /**\n * Check if the contract supports the given interface\n *\n * @public\n * @async\n * @param {Hex} interfaceId - The interface identifier\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} - True if the contract supports the interface\n */\n public async supportsInterface(\n interfaceId: Hex,\n params?: ReadParams<typeof aCloneableAbi, 'supportsInterface'>,\n ) {\n return await readACloneableSupportsInterface(this._config, {\n address: this.assertValidAddress(),\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 args: [interfaceId],\n });\n }\n\n /**\n * Return a cloneable's unique identifier for downstream consumers to differentiate various targets\n * All implementations must override this function\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Hex>}\n */\n public async getComponentInterface(\n params?: ReadParams<typeof aCloneableAbi, 'getComponentInterface'>,\n ) {\n return await readACloneableGetComponentInterface(this._config, {\n address: this.assertValidAddress(),\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 args: [],\n });\n }\n\n /**\n * @inheritdoc\n *\n * @protected\n * @template [P=Payload]\n * @param {?P} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {[P, DeployableOptions]}\n */\n protected override validateDeploymentConfig<P = Payload>(\n _payload?: P,\n _options?: DeployableOptions,\n ) {\n const payload = _payload || this._payload;\n if (!payload) throw new DeployableMissingPayloadError();\n return super.validateDeploymentConfig(payload, _options) as [\n P,\n DeployableOptions,\n ];\n }\n}\n"],"names":["_DeployableTarget","Deployable","options","payload","isBase","isAddress","zeroAddress","base","isAddressEqual","waitParams","_payload","_options","DeployableAlreadyDeployedError","config","args","deployment","deployContract","interfaceId","params","readACloneableSupportsInterface","readACloneableGetComponentInterface","DeployableMissingPayloadError","RegistryType","DeployableTarget"],"mappings":"2PAoCaA,EAAN,MAAMA,UAGHC,EAAAA,UAAiC,CA4CzC,YACEC,EACAC,EACAC,EACA,CACA,MAAMF,EAASC,CAAO,EA1BxB,KAAS,QAAmB,GA6BxB,OAAOA,GAAY,UACnBE,EAAU,UAAAF,CAAO,GACjBA,IAAYG,EAAAA,aACZ,CAAC,OAAO,OAAO,KAAK,KAAK,EAAE,KAAMC,GAC3B,CAACJ,GAAW,CAACI,EAAa,GACvBC,EAAA,eAAeL,EAASI,CAAI,CACpC,IAEQH,EAAA,IACPA,IAAW,SAAW,KAAK,QAAUA,EAC3C,CAtCA,IAAW,QAAS,CAEhB,OAAE,KAAK,SACP,OAAO,OAAO,KAAK,KAAK,EAAE,KAAMG,GAE9BC,iBAAe,KAAK,QAAUD,CAAI,CACpC,EAEO,GACF,KAAK,OACd,CAqCA,IAAW,OAAiC,CAC1C,OAAQ,KAAK,YAAwC,KACvD,CASA,IAAW,cAA6B,CACtC,OAAQ,KAAK,YAAwC,YACvD,CAYA,MAAyB,OACvBJ,EACAD,EACAO,EACA,CACA,aAAM,MAAM,OAAON,EAASD,EAASO,CAAU,EAC/C,KAAK,mBAAmB,EACjB,IACT,CAWA,MAAyB,UACvBC,EACAC,EACe,CACf,GAAI,KAAK,QAAS,MAAM,IAAIC,EAAAA,+BAA+B,KAAK,OAAO,EACjE,MAAAT,EAAUO,GAAY,KAAK,SAC3BG,GAASF,GAAA,YAAAA,EAAU,SAAU,KAAK,QAClC,CAAE,KAAAG,EAAM,GAAGC,GAAe,KAAK,gBAAgBZ,CAAO,EACrD,OAAA,MAAMa,iBAAeH,EAAQ,CAClC,GAAGE,EACH,GAAG,KAAK,wBAAwBJ,GAAA,YAAAA,EAAU,OAAO,EAEjD,KAAM,CAAC,CAAA,CACR,CACH,CAWA,MAAa,kBACXM,EACAC,EACA,CACO,OAAA,MAAMC,EAAAA,GAAgC,KAAK,QAAS,CACzD,QAAS,KAAK,mBAAmB,EACjC,GAAG,KAAK,wBAAwB,EAEhC,GAAID,EACJ,KAAM,CAACD,CAAW,CAAA,CACnB,CACH,CAWA,MAAa,sBACXC,EACA,CACO,OAAA,MAAME,EAAAA,GAAoC,KAAK,QAAS,CAC7D,QAAS,KAAK,mBAAmB,EACjC,GAAG,KAAK,wBAAwB,EAEhC,GAAIF,EACJ,KAAM,CAAC,CAAA,CACR,CACH,CAWmB,yBACjBR,EACAC,EACA,CACM,MAAAR,EAAUO,GAAY,KAAK,SACjC,GAAI,CAACP,EAAe,MAAA,IAAIkB,EAAAA,8BACjB,OAAA,MAAM,yBAAyBlB,EAASQ,CAAQ,CAIzD,CACF,EA1LEX,EAAgB,MAAiC,GAQjDA,EAAgB,aAA6BsB,EAAa,aAAA,OAnBrD,IAAMC,EAANvB"}
|
|
@@ -13,13 +13,13 @@ import { Deployable, type DeployableOptions, type DeployablePayloadOrAddress } f
|
|
|
13
13
|
*/
|
|
14
14
|
export declare class DeployableTarget<Payload, ContractAbi extends Abi> extends Deployable<Payload, ContractAbi> {
|
|
15
15
|
/**
|
|
16
|
-
* A static property representing the address of the base implementation on chain, used when cloning base contracts.
|
|
16
|
+
* A static property representing a map of stringified chain ID's to the address of the base implementation on chain, used when cloning base contracts.
|
|
17
17
|
*
|
|
18
18
|
* @static
|
|
19
19
|
* @readonly
|
|
20
|
-
* @type {Address}
|
|
20
|
+
* @type {Record<string, Address>}
|
|
21
21
|
*/
|
|
22
|
-
static readonly
|
|
22
|
+
static readonly bases: Record<number, Address>;
|
|
23
23
|
/**
|
|
24
24
|
* The target's registry type.
|
|
25
25
|
*
|
|
@@ -34,7 +34,8 @@ export declare class DeployableTarget<Payload, ContractAbi extends Abi> extends
|
|
|
34
34
|
* @readonly
|
|
35
35
|
* @type {boolean}
|
|
36
36
|
*/
|
|
37
|
-
readonly
|
|
37
|
+
readonly _isBase: boolean;
|
|
38
|
+
get isBase(): boolean;
|
|
38
39
|
/**
|
|
39
40
|
* Creates an instance of DeployableTarget.
|
|
40
41
|
*
|
|
@@ -43,15 +44,15 @@ export declare class DeployableTarget<Payload, ContractAbi extends Abi> extends
|
|
|
43
44
|
* @param {DeployablePayloadOrAddress<Payload>} payload - Either a given implementation's initialization payload, or an address to an existing on chain target.
|
|
44
45
|
* @param {?boolean} [isBase] - A property asserting that the protocol should eiher clone and initialize a new target from the base implementation, or re-use an existing contract without initializing.
|
|
45
46
|
*/
|
|
46
|
-
constructor(options: DeployableOptions, payload
|
|
47
|
+
constructor(options: DeployableOptions, payload?: DeployablePayloadOrAddress<Payload>, isBase?: boolean);
|
|
47
48
|
/**
|
|
48
|
-
* A getter that will return the base implementation's static
|
|
49
|
+
* A getter that will return the base implementation's static addresses by numerical chain ID
|
|
49
50
|
*
|
|
50
51
|
* @public
|
|
51
52
|
* @readonly
|
|
52
|
-
* @type {Address}
|
|
53
|
+
* @type {Record<number, Address>}
|
|
53
54
|
*/
|
|
54
|
-
get
|
|
55
|
+
get bases(): Record<number, Address>;
|
|
55
56
|
/**
|
|
56
57
|
* A getter that returns the registry type of the base implementation
|
|
57
58
|
*
|
|
@@ -68,9 +69,9 @@ export declare class DeployableTarget<Payload, ContractAbi extends Abi> extends
|
|
|
68
69
|
* @param {?Payload} [payload]
|
|
69
70
|
* @param {?DeployableOptions} [options]
|
|
70
71
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
|
|
71
|
-
* @returns {
|
|
72
|
+
* @returns {Promise<this>}
|
|
72
73
|
*/
|
|
73
|
-
deploy(payload?: Payload, options?: DeployableOptions, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<this>;
|
|
74
|
+
protected deploy(payload?: Payload, options?: DeployableOptions, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<this>;
|
|
74
75
|
/**
|
|
75
76
|
* @inheritdoc
|
|
76
77
|
*
|
|
@@ -80,15 +81,15 @@ export declare class DeployableTarget<Payload, ContractAbi extends Abi> extends
|
|
|
80
81
|
* @param {?DeployableOptions} [_options]
|
|
81
82
|
* @returns {Promise<Hash>}
|
|
82
83
|
*/
|
|
83
|
-
deployRaw(_payload?: Payload, _options?: DeployableOptions): Promise<Hash>;
|
|
84
|
+
protected deployRaw(_payload?: Payload, _options?: DeployableOptions): Promise<Hash>;
|
|
84
85
|
/**
|
|
85
86
|
* Check if the contract supports the given interface
|
|
86
87
|
*
|
|
87
88
|
* @public
|
|
88
89
|
* @async
|
|
89
90
|
* @param {Hex} interfaceId - The interface identifier
|
|
90
|
-
* @param {?ReadParams
|
|
91
|
-
* @returns {
|
|
91
|
+
* @param {?ReadParams} [params]
|
|
92
|
+
* @returns {Promise<boolean>} - True if the contract supports the interface
|
|
92
93
|
*/
|
|
93
94
|
supportsInterface(interfaceId: Hex, params?: ReadParams<typeof aCloneableAbi, 'supportsInterface'>): Promise<boolean>;
|
|
94
95
|
/**
|
|
@@ -97,8 +98,8 @@ export declare class DeployableTarget<Payload, ContractAbi extends Abi> extends
|
|
|
97
98
|
*
|
|
98
99
|
* @public
|
|
99
100
|
* @async
|
|
100
|
-
* @param {?ReadParams
|
|
101
|
-
* @returns {
|
|
101
|
+
* @param {?ReadParams} [params]
|
|
102
|
+
* @returns {Promise<Hex>}
|
|
102
103
|
*/
|
|
103
104
|
getComponentInterface(params?: ReadParams<typeof aCloneableAbi, 'getComponentInterface'>): Promise<`0x${string}`>;
|
|
104
105
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeployableTarget.d.ts","sourceRoot":"","sources":["../../src/Deployable/DeployableTarget.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,aAAa,EAGnB,MAAM,eAAe,CAAC;AAEvB,OAAO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AO,EACjB,OAAO,CAAC,EAAE,iBAAiB,EAC3B,UAAU,CAAC,EAAE,IAAI,CAAC,mCAAmC,EAAE,MAAM,CAAC;IAOhE;;;;;;;;OAQG;cACsB,SAAS,CAChC,QAAQ,CAAC,EAAE,OAAO,EAClB,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,OAAO,CAAC,IAAI,CAAC;IAahB;;;;;;;;OAQG;IACU,iBAAiB,CAC5B,WAAW,EAAE,GAAG,EAChB,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,aAAa,EAAE,mBAAmB,CAAC;IAWhE;;;;;;;;OAQG;IACU,qBAAqB,CAChC,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,aAAa,EAAE,uBAAuB,CAAC;IAWpE;;;;;;;;OAQG;cACgB,wBAAwB,CAAC,CAAC,GAAG,OAAO,EACrD,QAAQ,CAAC,EAAE,CAAC,EACZ,QAAQ,CAAC,EAAE,iBAAiB,GAIgC,CAC1D,CAAC,EACD,iBAAiB,CAClB;CAEJ"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { deployContract as
|
|
3
|
-
import { zeroAddress as
|
|
4
|
-
import { DeployableAlreadyDeployedError as
|
|
5
|
-
import { RegistryType as
|
|
6
|
-
import { Deployable as
|
|
7
|
-
const
|
|
1
|
+
import { q as d, r as c } from "../generated-B7VaSah4.js";
|
|
2
|
+
import { deployContract as h } from "@wagmi/core";
|
|
3
|
+
import { isAddress as u, zeroAddress as l, isAddressEqual as a } from "viem";
|
|
4
|
+
import { DeployableAlreadyDeployedError as y, DeployableMissingPayloadError as f } from "../errors.js";
|
|
5
|
+
import { RegistryType as m } from "../utils.js";
|
|
6
|
+
import { Deployable as p } from "./Deployable.js";
|
|
7
|
+
const i = class i extends p {
|
|
8
8
|
/**
|
|
9
9
|
* Creates an instance of DeployableTarget.
|
|
10
10
|
*
|
|
@@ -13,18 +13,26 @@ const e = class e extends u {
|
|
|
13
13
|
* @param {DeployablePayloadOrAddress<Payload>} payload - Either a given implementation's initialization payload, or an address to an existing on chain target.
|
|
14
14
|
* @param {?boolean} [isBase] - A property asserting that the protocol should eiher clone and initialize a new target from the base implementation, or re-use an existing contract without initializing.
|
|
15
15
|
*/
|
|
16
|
-
constructor(
|
|
17
|
-
super(
|
|
16
|
+
constructor(t, s, r) {
|
|
17
|
+
super(t, s), this._isBase = !0, typeof s == "string" && u(s) && s !== l && !Object.values(this.bases).some((e) => !s || !e ? !1 : a(s, e)) && (r = !1), r !== void 0 && (this._isBase = r);
|
|
18
|
+
}
|
|
19
|
+
get isBase() {
|
|
20
|
+
return this.address && Object.values(this.bases).some(
|
|
21
|
+
(t) => (
|
|
22
|
+
// biome-ignore lint/style/noNonNullAssertion: won't evaluate this if address checked and defined above
|
|
23
|
+
a(this.address, t)
|
|
24
|
+
)
|
|
25
|
+
) ? !0 : this._isBase;
|
|
18
26
|
}
|
|
19
27
|
/**
|
|
20
|
-
* A getter that will return the base implementation's static
|
|
28
|
+
* A getter that will return the base implementation's static addresses by numerical chain ID
|
|
21
29
|
*
|
|
22
30
|
* @public
|
|
23
31
|
* @readonly
|
|
24
|
-
* @type {Address}
|
|
32
|
+
* @type {Record<number, Address>}
|
|
25
33
|
*/
|
|
26
|
-
get
|
|
27
|
-
return this.constructor.
|
|
34
|
+
get bases() {
|
|
35
|
+
return this.constructor.bases;
|
|
28
36
|
}
|
|
29
37
|
/**
|
|
30
38
|
* A getter that returns the registry type of the base implementation
|
|
@@ -44,10 +52,10 @@ const e = class e extends u {
|
|
|
44
52
|
* @param {?Payload} [payload]
|
|
45
53
|
* @param {?DeployableOptions} [options]
|
|
46
54
|
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
|
|
47
|
-
* @returns {
|
|
55
|
+
* @returns {Promise<this>}
|
|
48
56
|
*/
|
|
49
|
-
async deploy(
|
|
50
|
-
return await super.deploy(
|
|
57
|
+
async deploy(t, s, r) {
|
|
58
|
+
return await super.deploy(t, s, r), this.assertValidAddress(), this;
|
|
51
59
|
}
|
|
52
60
|
/**
|
|
53
61
|
* @inheritdoc
|
|
@@ -58,13 +66,12 @@ const e = class e extends u {
|
|
|
58
66
|
* @param {?DeployableOptions} [_options]
|
|
59
67
|
* @returns {Promise<Hash>}
|
|
60
68
|
*/
|
|
61
|
-
async deployRaw(
|
|
62
|
-
if (this.address)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
...
|
|
67
|
-
...this.optionallyAttachAccount(t == null ? void 0 : t.account),
|
|
69
|
+
async deployRaw(t, s) {
|
|
70
|
+
if (this.address) throw new y(this.address);
|
|
71
|
+
const r = t || this._payload, e = (s == null ? void 0 : s.config) || this._config, { args: g, ...n } = this.buildParameters(r);
|
|
72
|
+
return await h(e, {
|
|
73
|
+
...n,
|
|
74
|
+
...this.optionallyAttachAccount(s == null ? void 0 : s.account),
|
|
68
75
|
// Deployable targets don't construct with arguments, they initialize with encoded payloads
|
|
69
76
|
args: []
|
|
70
77
|
});
|
|
@@ -75,16 +82,16 @@ const e = class e extends u {
|
|
|
75
82
|
* @public
|
|
76
83
|
* @async
|
|
77
84
|
* @param {Hex} interfaceId - The interface identifier
|
|
78
|
-
* @param {?ReadParams
|
|
79
|
-
* @returns {
|
|
85
|
+
* @param {?ReadParams} [params]
|
|
86
|
+
* @returns {Promise<boolean>} - True if the contract supports the interface
|
|
80
87
|
*/
|
|
81
|
-
async supportsInterface(
|
|
82
|
-
return
|
|
88
|
+
async supportsInterface(t, s) {
|
|
89
|
+
return await d(this._config, {
|
|
83
90
|
address: this.assertValidAddress(),
|
|
84
91
|
...this.optionallyAttachAccount(),
|
|
85
92
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
86
|
-
...
|
|
87
|
-
args: [
|
|
93
|
+
...s,
|
|
94
|
+
args: [t]
|
|
88
95
|
});
|
|
89
96
|
}
|
|
90
97
|
/**
|
|
@@ -93,15 +100,15 @@ const e = class e extends u {
|
|
|
93
100
|
*
|
|
94
101
|
* @public
|
|
95
102
|
* @async
|
|
96
|
-
* @param {?ReadParams
|
|
97
|
-
* @returns {
|
|
103
|
+
* @param {?ReadParams} [params]
|
|
104
|
+
* @returns {Promise<Hex>}
|
|
98
105
|
*/
|
|
99
|
-
async getComponentInterface(
|
|
100
|
-
return c(this._config, {
|
|
106
|
+
async getComponentInterface(t) {
|
|
107
|
+
return await c(this._config, {
|
|
101
108
|
address: this.assertValidAddress(),
|
|
102
109
|
...this.optionallyAttachAccount(),
|
|
103
110
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
104
|
-
...
|
|
111
|
+
...t,
|
|
105
112
|
args: []
|
|
106
113
|
});
|
|
107
114
|
}
|
|
@@ -114,15 +121,15 @@ const e = class e extends u {
|
|
|
114
121
|
* @param {?DeployableOptions} [_options]
|
|
115
122
|
* @returns {[P, DeployableOptions]}
|
|
116
123
|
*/
|
|
117
|
-
validateDeploymentConfig(
|
|
118
|
-
const r =
|
|
119
|
-
if (!r)
|
|
120
|
-
|
|
121
|
-
return super.validateDeploymentConfig(r, t);
|
|
124
|
+
validateDeploymentConfig(t, s) {
|
|
125
|
+
const r = t || this._payload;
|
|
126
|
+
if (!r) throw new f();
|
|
127
|
+
return super.validateDeploymentConfig(r, s);
|
|
122
128
|
}
|
|
123
129
|
};
|
|
124
|
-
|
|
125
|
-
let
|
|
130
|
+
i.bases = {}, i.registryType = m.ACTION;
|
|
131
|
+
let o = i;
|
|
126
132
|
export {
|
|
127
|
-
|
|
133
|
+
o as DeployableTarget
|
|
128
134
|
};
|
|
135
|
+
//# sourceMappingURL=DeployableTarget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeployableTarget.js","sources":["../../src/Deployable/DeployableTarget.ts"],"sourcesContent":["import {\n type aCloneableAbi,\n readACloneableGetComponentInterface,\n readACloneableSupportsInterface,\n} from '@boostxyz/evm';\nimport { deployContract } from '@wagmi/core';\nimport {\n type Abi,\n type Address,\n type Hash,\n type Hex,\n type WaitForTransactionReceiptParameters,\n isAddress,\n isAddressEqual,\n zeroAddress,\n} from 'viem';\nimport {\n DeployableAlreadyDeployedError,\n DeployableMissingPayloadError,\n} from '../errors';\nimport { type ReadParams, RegistryType } from '../utils';\nimport {\n Deployable,\n type DeployableOptions,\n type DeployablePayloadOrAddress,\n} from './Deployable';\n\n/**\n * A base class representing a generic base Boost Protocol target contract, extended by Actions, AllowLists, Budgets, Incentives, and Validators.\n *\n * @export\n * @class DeployableTarget\n * @typedef {DeployableTarget}\n * @template [Payload=unknown]\n * @extends {Deployable<Payload>}\n */\nexport class DeployableTarget<\n Payload,\n ContractAbi extends Abi,\n> extends Deployable<Payload, ContractAbi> {\n /**\n * A static property representing a map of stringified chain ID's to the address of the base implementation on chain, used when cloning base contracts.\n *\n * @static\n * @readonly\n * @type {Record<string, Address>}\n */\n static readonly bases: Record<number, Address> = {};\n /**\n * The target's registry type.\n *\n * @static\n * @readonly\n * @type {RegistryType}\n */\n static readonly registryType: RegistryType = RegistryType.ACTION;\n /**\n * A property asserting that the protocol should eiher clone and initialize a new target from the base implementation, or re-use an existing contract without initializing.\n *\n * @readonly\n * @type {boolean}\n */\n readonly _isBase: boolean = true;\n public get isBase() {\n if (\n !!this.address &&\n Object.values(this.bases).some((base) =>\n // biome-ignore lint/style/noNonNullAssertion: won't evaluate this if address checked and defined above\n isAddressEqual(this.address!, base),\n )\n )\n return true;\n return this._isBase;\n }\n\n /**\n * Creates an instance of DeployableTarget.\n *\n * @constructor\n * @param {DeployableOptions} options\n * @param {DeployablePayloadOrAddress<Payload>} payload - Either a given implementation's initialization payload, or an address to an existing on chain target.\n * @param {?boolean} [isBase] - A property asserting that the protocol should eiher clone and initialize a new target from the base implementation, or re-use an existing contract without initializing.\n */\n constructor(\n options: DeployableOptions,\n payload?: DeployablePayloadOrAddress<Payload>,\n isBase?: boolean,\n ) {\n super(options, payload);\n // if supplying a custom address, safe enough to assume it is not a base address which makes reusing contracts like budgets easier\n if (\n typeof payload === 'string' &&\n isAddress(payload) &&\n payload !== zeroAddress &&\n !Object.values(this.bases).some((base) => {\n if (!payload || !base) return false;\n return isAddressEqual(payload, base);\n })\n )\n isBase = false;\n if (isBase !== undefined) this._isBase = isBase;\n }\n\n /**\n * A getter that will return the base implementation's static addresses by numerical chain ID\n *\n * @public\n * @readonly\n * @type {Record<number, Address>}\n */\n public get bases(): Record<number, Address> {\n return (this.constructor as typeof DeployableTarget).bases;\n }\n\n /**\n * A getter that returns the registry type of the base implementation\n *\n * @public\n * @readonly\n * @type {RegistryType}\n */\n public get registryType(): RegistryType {\n return (this.constructor as typeof DeployableTarget).registryType;\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @async\n * @param {?Payload} [payload]\n * @param {?DeployableOptions} [options]\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<this>}\n */\n protected override async deploy(\n payload?: Payload,\n options?: DeployableOptions,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n ) {\n await super.deploy(payload, options, waitParams);\n this.assertValidAddress();\n return this;\n }\n\n /**\n * @inheritdoc\n *\n * @public\n * @async\n * @param {?Payload} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {Promise<Hash>}\n */\n protected override async deployRaw(\n _payload?: Payload,\n _options?: DeployableOptions,\n ): Promise<Hash> {\n if (this.address) throw new DeployableAlreadyDeployedError(this.address);\n const payload = _payload || this._payload;\n const config = _options?.config || this._config;\n const { args, ...deployment } = this.buildParameters(payload);\n return await deployContract(config, {\n ...deployment,\n ...this.optionallyAttachAccount(_options?.account),\n // Deployable targets don't construct with arguments, they initialize with encoded payloads\n args: [],\n });\n }\n\n /**\n * Check if the contract supports the given interface\n *\n * @public\n * @async\n * @param {Hex} interfaceId - The interface identifier\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} - True if the contract supports the interface\n */\n public async supportsInterface(\n interfaceId: Hex,\n params?: ReadParams<typeof aCloneableAbi, 'supportsInterface'>,\n ) {\n return await readACloneableSupportsInterface(this._config, {\n address: this.assertValidAddress(),\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 args: [interfaceId],\n });\n }\n\n /**\n * Return a cloneable's unique identifier for downstream consumers to differentiate various targets\n * All implementations must override this function\n *\n * @public\n * @async\n * @param {?ReadParams} [params]\n * @returns {Promise<Hex>}\n */\n public async getComponentInterface(\n params?: ReadParams<typeof aCloneableAbi, 'getComponentInterface'>,\n ) {\n return await readACloneableGetComponentInterface(this._config, {\n address: this.assertValidAddress(),\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 args: [],\n });\n }\n\n /**\n * @inheritdoc\n *\n * @protected\n * @template [P=Payload]\n * @param {?P} [_payload]\n * @param {?DeployableOptions} [_options]\n * @returns {[P, DeployableOptions]}\n */\n protected override validateDeploymentConfig<P = Payload>(\n _payload?: P,\n _options?: DeployableOptions,\n ) {\n const payload = _payload || this._payload;\n if (!payload) throw new DeployableMissingPayloadError();\n return super.validateDeploymentConfig(payload, _options) as [\n P,\n DeployableOptions,\n ];\n }\n}\n"],"names":["_DeployableTarget","Deployable","options","payload","isBase","isAddress","zeroAddress","base","isAddressEqual","waitParams","_payload","_options","DeployableAlreadyDeployedError","config","args","deployment","deployContract","interfaceId","params","readACloneableSupportsInterface","readACloneableGetComponentInterface","DeployableMissingPayloadError","RegistryType","DeployableTarget"],"mappings":";;;;;;AAoCO,MAAMA,IAAN,MAAMA,UAGHC,EAAiC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4CzC,YACEC,GACAC,GACAC,GACA;AACA,UAAMF,GAASC,CAAO,GA1BxB,KAAS,UAAmB,IA6BxB,O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AAM,CAAC;AAAA,IAAA,CACR;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAa,kBACXM,GACAC,GACA;AACO,WAAA,MAAMC,EAAgC,KAAK,SAAS;AAAA,MACzD,SAAS,KAAK,mBAAmB;AAAA,MACjC,GAAG,KAAK,wBAAwB;AAAA;AAAA,MAEhC,GAAID;AAAA,MACJ,MAAM,CAACD,CAAW;AAAA,IAAA,CACnB;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAa,sBACXC,GACA;AACO,WAAA,MAAME,EAAoC,KAAK,SAAS;AAAA,MAC7D,SAAS,KAAK,mBAAmB;AAAA,MACjC,GAAG,KAAK,wBAAwB;AAAA;AAAA,MAEhC,GAAIF;AAAA,MACJ,MAAM,CAAC;AAAA,IAAA,CACR;AAAA,EACH;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWmB,yBACjBR,GACAC,GACA;AACM,UAAAR,IAAUO,KAAY,KAAK;AACjC,QAAI,CAACP,EAAe,OAAA,IAAIkB;AACjB,WAAA,MAAM,yBAAyBlB,GAASQ,CAAQ;AAAA,EAIzD;AACF;AA1LEX,EAAgB,QAAiC,IAQjDA,EAAgB,eAA6BsB,EAAa;AAnBrD,IAAMC,IAANvB;"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("../generated-B0tk-c9b.cjs"),c=require("./DeployableTarget.cjs");var n=(i=>(i[i.MANAGER=1n]="MANAGER",i[i.ADMIN=2n]="ADMIN",i))(n||{});class l extends c.DeployableTarget{async setAuthorized(t,s,a){return await this.awaitResult(this.setAuthorizedRaw(t,s,a))}async setAuthorizedRaw(t,s,a){const{request:r,result:o}=await e.Mg(this._config,{address:this.assertValidAddress(),args:[t,s],...this.optionallyAttachAccount(),...a});return{hash:await e.fg(this._config,r),result:o}}async grantRoles(t,s,a){return await this.awaitResult(this.grantRolesRaw(t,s,a))}async grantRolesRaw(t,s,a){const{request:r,result:o}=await e.Ig(this._config,{address:this.assertValidAddress(),args:[t,s],...this.optionallyAttachAccount(),...a});return{hash:await e.yg(this._config,r),result:o}}async revokeRoles(t,s,a){return await this.awaitResult(this.revokeRolesRaw(t,s,a))}async revokeRolesRaw(t,s,a){const{request:r,result:o}=await e.Og(this._config,{address:this.assertValidAddress(),args:[t,s],...this.optionallyAttachAccount(),...a});return{hash:await e.bg(this._config,r),result:o}}async rolesOf(t,s){const a=await e.og(this._config,{address:this.assertValidAddress(),args:[t],...this.optionallyAttachAccount(),...s});return[n.MANAGER,n.ADMIN].filter(r=>(a&r)===r)}hasAnyRole(t,s,a){return e.ag(this._config,{address:this.assertValidAddress(),args:[t,s],...this.optionallyAttachAccount(),...a})}hasAllRoles(t,s,a){return e.ng(this._config,{address:this.assertValidAddress(),args:[t,s],...this.optionallyAttachAccount(),...a})}isAuthorized(t,s){return e.ig(this._config,{address:this.assertValidAddress(),args:[t],...this.optionallyAttachAccount(),...s})}}exports.rbacAbi=e.z;exports.DeployableTargetWithRBAC=l;exports.Roles=n;
|
|
2
|
+
//# sourceMappingURL=DeployableTargetWithRBAC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"DeployableTargetWithRBAC.cjs","sources":["../../src/Deployable/DeployableTargetWithRBAC.ts"],"sourcesContent":["import {\n rbacAbi,\n readRbacHasAllRoles,\n readRbacHasAnyRole,\n readRbacIsAuthorized,\n readRbacRolesOf,\n simulateRbacGrantRoles,\n simulateRbacRevokeRoles,\n simulateRbacSetAuthorized,\n writeRbacGrantRoles,\n writeRbacRevokeRoles,\n writeRbacSetAuthorized,\n} from '@boostxyz/evm';\nimport type { Abi, Address, ContractEventName } from 'viem';\nimport { DeployableTarget } from '../Deployable/DeployableTarget';\nimport type { GenericLog, ReadParams, WriteParams } from '../utils';\nexport { rbacAbi };\n\n/**\n * Enum representing available roles for use with the `RBAC` authorization scheme.\n * `MANAGER` has lowest level of write permissions, for specific implementations, see Budgets and ALlowLists\n * `ADMIN` can additionally manage authorized users on the contract.\n *\n * @export\n * @type {{ readonly MANAGER: 1n; readonly ADMIN_ROLE: 2n; }}\n * @enum {bigint}\n */\nexport enum Roles {\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 `Rbac` event types.\n *\n * @export\n * @typedef {RBACLog}\n * @template {ContractEventName<typeof rbacAbi>} [event=ContractEventName<\n * typeof rbacAbi\n * >]\n */\nexport type RBACLog<\n event extends ContractEventName<typeof rbacAbi> = ContractEventName<\n typeof rbacAbi\n >,\n> = GenericLog<typeof rbacAbi, event>;\n\n/**\n * A minimal RBAC implementation that offers MANAGER and ADMIN roles, and\n * Budgets and allowlists support this auth scheme\n *\n * @export\n * @class DeployableTargetWithRBAC\n * @typedef {DeployableTargetWithRBAC}\n * @extends {DeployableTarget<RbacPayload>}\n */\nexport class DeployableTargetWithRBAC<\n Payload,\n ABI extends Abi,\n> extends DeployableTarget<Payload, ABI> {\n /**\n * Set the authorized status of the given accounts\n * The mechanism for managing authorization is left to the implementing contract\n *\n * @public\n * @async\n * @param {Address[]} addresses - The accounts to authorize or deauthorize\n * @param {boolean[]} allowed - The authorization status for the given accounts\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async setAuthorized(\n addresses: Address[],\n allowed: boolean[],\n params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,\n ) {\n return await this.awaitResult(\n this.setAuthorizedRaw(addresses, allowed, params),\n );\n }\n\n /**\n * Set the authorized status of the given accounts\n * The mechanism for managing authorization is left to the implementing contract\n *\n * @public\n * @async\n * @param {Address[]} addresses - The accounts to authorize or deauthorize\n * @param {boolean[]} allowed - The authorization status for the given accounts\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async setAuthorizedRaw(\n addresses: Address[],\n allowed: boolean[],\n params?: WriteParams<typeof rbacAbi, 'setAuthorized'>,\n ) {\n const { request, result } = await simulateRbacSetAuthorized(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, allowed],\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 const hash = await writeRbacSetAuthorized(this._config, request);\n return { hash, result };\n }\n\n /**\n * Grant many accounts permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])\n * ```\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async grantRoles(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'grantRoles'>,\n ) {\n return await this.awaitResult(this.grantRolesRaw(addresses, roles, params));\n }\n\n /**\n * Grant many accounts permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.grantRoles(['0xfoo', '0xbar], [Roles.MANAGER, Roles.ADMIN])\n *\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async grantRolesRaw(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'grantRoles'>,\n ) {\n const { request, result } = await simulateRbacGrantRoles(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, roles],\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 const hash = await writeRbacGrantRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Revoke many accounts' permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])\n *\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<void>}\n */\n public async revokeRoles(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,\n ) {\n return await this.awaitResult(\n this.revokeRolesRaw(addresses, roles, params),\n );\n }\n\n /**\n * Revoke many accounts' permissions on the rbac.\n *\n * @example\n * ```ts\n * await rbac.revokeRoles(['0xfoo', '0xbar], [RbacRoles.MANAGER, RbacRoles.ADMIN])\n * @public\n * @async\n * @param {Address[]} addresses\n * @param {RbacRoles[]} roles\n * @param {?WriteParams} [params]\n * @returns {Promise<{ hash: `0x${string}`; result: void; }>}\n */\n public async revokeRolesRaw(\n addresses: Address[],\n roles: Roles[],\n params?: WriteParams<typeof rbacAbi, 'revokeRoles'>,\n ) {\n const { request, result } = await simulateRbacRevokeRoles(this._config, {\n address: this.assertValidAddress(),\n args: [addresses, roles],\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 const hash = await writeRbacRevokeRoles(\n this._config,\n // biome-ignore lint/suspicious/noExplicitAny: negligible low level lack of type intersection\n request as any,\n );\n return { hash, result };\n }\n\n /**\n * Return an array of the roles assigned to the given account.\n * @example\n * ```ts\n * (await rbac.rolesOf(0xfoo)).includes(RbacRoles.ADMIN)\n * @public\n * @param {Address} account\n * @param {?ReadParams} [params]\n * @returns {Promise<Array<RbacRoles>>}\n */\n public async rolesOf(\n account: Address,\n params?: ReadParams<typeof rbacAbi, 'rolesOf'>,\n ) {\n const roles = await readRbacRolesOf(this._config, {\n address: this.assertValidAddress(),\n args: [account],\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 return ([Roles.MANAGER, Roles.ADMIN] as unknown as Array<bigint>).filter(\n (role) => (roles & role) === role,\n ) as unknown as Roles[];\n }\n\n /**\n * Returns whether given account has any of the provided roles bitmap.\n *\n * @example\n * ```ts\n * await rbac.hasAnyRole(0xfoo, RbacRoles.ADMIN | RbacRoles.MANAGER)\n * @public\n * @param {Address} account\n * @param {RbacRoles} roles\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public hasAnyRole(\n account: Address,\n roles: Roles,\n params?: ReadParams<typeof rbacAbi, 'hasAnyRole'>,\n ) {\n return readRbacHasAnyRole(this._config, {\n address: this.assertValidAddress(),\n args: [account, roles],\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\n /**\n * Returns whether given account has all of the provided roles bitmap.\n *\n * @example\n * ```ts\n * await rbac.hasAllRoles(0xfoo, RbacRoles.ADMIN & RbacRoles.MANAGER)\n *\n * @public\n * @param {Address} account\n * @param {RbacRoles} roles\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>}\n */\n public hasAllRoles(\n account: Address,\n roles: Roles,\n params?: ReadParams<typeof rbacAbi, 'hasAllRoles'>,\n ) {\n return readRbacHasAllRoles(this._config, {\n address: this.assertValidAddress(),\n args: [account, roles],\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\n /**\n * Check if the given account is authorized to use the rbac\n *\n * @public\n * @param {Address} account\n * @param {?ReadParams} [params]\n * @returns {Promise<boolean>} - True if the account is authorized\n */\n public isAuthorized(\n account: Address,\n params?: ReadParams<typeof rbacAbi, 'isAuthorized'>,\n ) {\n return readRbacIsAuthorized(this._config, {\n address: this.assertValidAddress(),\n args: [account],\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}\n"],"names":["Roles","DeployableTargetWithRBAC","DeployableTarget","addresses","allowed","params","request","result","simulateRbacSetAuthorized","writeRbacSetAuthorized","roles","simulateRbacGrantRoles","writeRbacGrantRoles","simulateRbacRevokeRoles","writeRbacRevokeRoles","account","readRbacRolesOf","role","readRbacHasAnyRole","readRbacHasAllRoles","readRbacIsAuthorized"],"mappings":"iKA2BY,IAAAA,GAAAA,IAEVA,EAAAA,EAAA,QAAU,EAAV,EAAA,UAEAA,EAAAA,EAAA,MAAQ,EAAR,EAAA,QAJUA,IAAAA,GAAA,CAAA,CAAA,EA+BL,MAAMC,UAGHC,EAAAA,gBAA+B,CAYvC,MAAa,cACXC,EACAC,EACAC,EACA,CACA,OAAO,MAAM,KAAK,YAChB,KAAK,iBAAiBF,EAAWC,EAASC,CAAM,CAAA,CAEpD,CAaA,MAAa,iBACXF,EACAC,EACAC,EACA,CACA,KAAM,CAAE,QAAAC,EAAS,OAAAC,CAAA,EAAW,MAAMC,EAAA,GAA0B,KAAK,QAAS,CACxE,QAAS,KAAK,mBAAmB,EACjC,KAAM,CAACL,EAAWC,CAAO,EACzB,GAAG,KAAK,wBAAwB,EAEhC,GAAIC,CAAA,CACL,EAEM,MAAA,CAAE,KADI,MAAMI,EAAuB,GAAA,KAAK,QAASH,CAAO,EAChD,OAAAC,EACjB,CAgBA,MAAa,WACXJ,EACAO,EACAL,EACA,CACO,OAAA,MAAM,KAAK,YAAY,KAAK,cAAcF,EAAWO,EAAOL,CAAM,CAAC,CAC5E,CAgBA,MAAa,cACXF,EACAO,EACAL,EACA,CACA,KAAM,CAAE,QAAAC,EAAS,OAAAC,CAAA,EAAW,MAAMI,EAAA,GAAuB,KAAK,QAAS,CACrE,QAAS,KAAK,mBAAmB,EACjC,KAAM,CAACR,EAAWO,CAAK,EACvB,GAA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