@boostxyz/sdk 0.0.0-alpha.2
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/LICENSE +674 -0
- package/README.md +7 -0
- package/dist/Actions/Action.cjs +1 -0
- package/dist/Actions/Action.d.ts +31 -0
- package/dist/Actions/Action.d.ts.map +1 -0
- package/dist/Actions/Action.js +27 -0
- package/dist/Actions/ContractAction.d.ts +327 -0
- package/dist/Actions/ContractAction.d.ts.map +1 -0
- package/dist/Actions/ERC721MintAction.d.ts +486 -0
- package/dist/Actions/ERC721MintAction.d.ts.map +1 -0
- package/dist/Actions/EventAction.cjs +1 -0
- package/dist/Actions/EventAction.d.ts +433 -0
- package/dist/Actions/EventAction.d.ts.map +1 -0
- package/dist/Actions/EventAction.js +211 -0
- package/dist/AllowLists/AllowList.cjs +1 -0
- package/dist/AllowLists/AllowList.d.ts +33 -0
- package/dist/AllowLists/AllowList.d.ts.map +1 -0
- package/dist/AllowLists/AllowList.js +28 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -0
- package/dist/AllowLists/SimpleAllowList.d.ts +452 -0
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.js +138 -0
- package/dist/AllowLists/SimpleDenyList.cjs +1 -0
- package/dist/AllowLists/SimpleDenyList.d.ts +306 -0
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleDenyList.js +202 -0
- package/dist/Auth/Auth.cjs +1 -0
- package/dist/Auth/Auth.d.ts +10 -0
- package/dist/Auth/Auth.d.ts.map +1 -0
- package/dist/Auth/Auth.js +4 -0
- package/dist/Auth/PassthroughAuth.cjs +1 -0
- package/dist/Auth/PassthroughAuth.d.ts +51 -0
- package/dist/Auth/PassthroughAuth.d.ts.map +1 -0
- package/dist/Auth/PassthroughAuth.js +38 -0
- package/dist/Boost.cjs +1 -0
- package/dist/Boost.d.ts +142 -0
- package/dist/Boost.d.ts.map +1 -0
- package/dist/Boost.js +15 -0
- package/dist/BoostCore.cjs +2 -0
- package/dist/BoostCore.d.ts +460 -0
- package/dist/BoostCore.d.ts.map +1 -0
- package/dist/BoostCore.js +1105 -0
- package/dist/BoostRegistry.cjs +1 -0
- package/dist/BoostRegistry.d.ts +229 -0
- package/dist/BoostRegistry.d.ts.map +1 -0
- package/dist/BoostRegistry.js +250 -0
- package/dist/Budgets/Budget.cjs +1 -0
- package/dist/Budgets/Budget.d.ts +31 -0
- package/dist/Budgets/Budget.d.ts.map +1 -0
- package/dist/Budgets/Budget.js +27 -0
- package/dist/Budgets/ManagedBudget.cjs +1 -0
- package/dist/Budgets/ManagedBudget.d.ts +1065 -0
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -0
- package/dist/Budgets/ManagedBudget.js +498 -0
- package/dist/Budgets/SimpleBudget.d.ts +793 -0
- package/dist/Budgets/SimpleBudget.d.ts.map +1 -0
- package/dist/Budgets/VestingBudget.d.ts +726 -0
- package/dist/Budgets/VestingBudget.d.ts.map +1 -0
- package/dist/Deployable/Contract.cjs +1 -0
- package/dist/Deployable/Contract.d.ts +125 -0
- package/dist/Deployable/Contract.d.ts.map +1 -0
- package/dist/Deployable/Contract.js +149 -0
- package/dist/Deployable/Deployable.cjs +1 -0
- package/dist/Deployable/Deployable.d.ts +155 -0
- package/dist/Deployable/Deployable.d.ts.map +1 -0
- package/dist/Deployable/Deployable.js +124 -0
- package/dist/Deployable/DeployableTarget.cjs +1 -0
- package/dist/Deployable/DeployableTarget.d.ts +115 -0
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -0
- package/dist/Deployable/DeployableTarget.js +128 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -0
- package/dist/Incentives/AllowListIncentive.d.ts +483 -0
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -0
- package/dist/Incentives/AllowListIncentive.js +188 -0
- package/dist/Incentives/CGDAIncentive.cjs +1 -0
- package/dist/Incentives/CGDAIncentive.d.ts +560 -0
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -0
- package/dist/Incentives/CGDAIncentive.js +249 -0
- package/dist/Incentives/ERC1155Incentive.d.ts +652 -0
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20Incentive.cjs +1 -0
- package/dist/Incentives/ERC20Incentive.d.ts +622 -0
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20Incentive.js +292 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +545 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -0
- package/dist/Incentives/Incentive.cjs +1 -0
- package/dist/Incentives/Incentive.d.ts +39 -0
- package/dist/Incentives/Incentive.d.ts.map +1 -0
- package/dist/Incentives/Incentive.js +280 -0
- package/dist/Incentives/PointsIncentive.cjs +1 -0
- package/dist/Incentives/PointsIncentive.d.ts +615 -0
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -0
- package/dist/Incentives/PointsIncentive.js +197 -0
- package/dist/Validators/SignerValidator.cjs +1 -0
- package/dist/Validators/SignerValidator.d.ts +452 -0
- package/dist/Validators/SignerValidator.d.ts.map +1 -0
- package/dist/Validators/SignerValidator.js +167 -0
- package/dist/Validators/Validator.cjs +1 -0
- package/dist/Validators/Validator.d.ts +31 -0
- package/dist/Validators/Validator.d.ts.map +1 -0
- package/dist/Validators/Validator.js +25 -0
- package/dist/errors.cjs +1 -0
- package/dist/errors.d.ts +257 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +161 -0
- package/dist/generated-BaaleHW-.cjs +2 -0
- package/dist/generated-x_abr3Yv.js +6228 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +29 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1355 -0
- package/dist/utils.cjs +1 -0
- package/dist/utils.d.ts +1454 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +643 -0
- package/package.json +197 -0
|
@@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AE,OAAO,CAAC;IAUvD;;;;;;;;OAQG;IACI,SAAS,CACd,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,EAAE,WAAW,CAAC;IAU3D;;;;;;;OAOG;IACI,WAAW,CAChB,KAAK,EAAE,OAAO,EACd,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,gBAAgB,EAAE,aAAa,CAAC;IAU7D;;;;;;;OAOG;IACa,eAAe,CAC7B,QAAQ,CAAC,EAAE,oBAAoB,EAC/B,QAAQ,CAAC,EAAE,iBAAiB,GAC3B,uBAAuB;CAwB3B"}
|
|
@@ -0,0 +1 @@
|
|
|
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 c.awaitResult(this._config,e,t)}}exports.Contract=h;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { type Config } from '@wagmi/core';
|
|
2
|
+
import type { ExtractAbiEvent } from 'abitype';
|
|
3
|
+
import { type Abi, type Address, type ContractEventName, type GetLogsReturnType, type WaitForTransactionReceiptParameters, type WatchContractEventOnLogsParameter } from 'viem';
|
|
4
|
+
import { type GetLogsParams, type HashAndSimulatedResult, type WatchParams } from '../utils';
|
|
5
|
+
/**
|
|
6
|
+
* A basic Contract class to encapsulate configuration and a potential address
|
|
7
|
+
*
|
|
8
|
+
* @export
|
|
9
|
+
* @class Contract
|
|
10
|
+
* @typedef {Contract}
|
|
11
|
+
* @template {Abi} [ContractAbi=[]]
|
|
12
|
+
* @template {ContractEventName<ContractAbi>} [ContractEvent=any]
|
|
13
|
+
*/
|
|
14
|
+
export declare class Contract<ContractAbi extends Abi> {
|
|
15
|
+
readonly abi: ContractAbi;
|
|
16
|
+
/**
|
|
17
|
+
* @see [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
|
|
18
|
+
* @protected
|
|
19
|
+
* @type {WagmiConfig}
|
|
20
|
+
*/
|
|
21
|
+
protected _config: Config;
|
|
22
|
+
/**
|
|
23
|
+
* The internally managed address for this contract
|
|
24
|
+
*
|
|
25
|
+
* @protected
|
|
26
|
+
* @type {(Address | undefined)}
|
|
27
|
+
*/
|
|
28
|
+
protected _address: Address | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Creates an instance of Contract.
|
|
31
|
+
*
|
|
32
|
+
* @constructor
|
|
33
|
+
* @param {Config} config
|
|
34
|
+
* @param {(Address | undefined)} address
|
|
35
|
+
*/
|
|
36
|
+
constructor(config: Config, address: Address | undefined);
|
|
37
|
+
/**
|
|
38
|
+
* A getter returning this contract's deployed address, if it exists.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
* @readonly
|
|
42
|
+
* @type {*}
|
|
43
|
+
*/
|
|
44
|
+
get address(): `0x${string}` | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* Will set this contract's address and return the instance for chaining. Does not verify that provided address is valid.
|
|
47
|
+
*
|
|
48
|
+
* @public
|
|
49
|
+
* @param {Address} address
|
|
50
|
+
* @returns {this}
|
|
51
|
+
*/
|
|
52
|
+
at(address: Address): this;
|
|
53
|
+
/**
|
|
54
|
+
* Will set this contract's internal [Wagmi Configuration](https://en.wikipedia.org/wiki/Factorial) and return the instance for chaining.
|
|
55
|
+
*
|
|
56
|
+
* @public
|
|
57
|
+
* @param {Config} config
|
|
58
|
+
* @returns {this}
|
|
59
|
+
*/
|
|
60
|
+
withConfig(config: Config): this;
|
|
61
|
+
/**
|
|
62
|
+
* Utility function to validate the existence of an address on this Contract.
|
|
63
|
+
*
|
|
64
|
+
* @public
|
|
65
|
+
* @returns {Address}
|
|
66
|
+
* @throws {@link ContractAddressRequiredError} if no address exists on this Contract instance
|
|
67
|
+
*/
|
|
68
|
+
assertValidAddress(): `0x${string}`;
|
|
69
|
+
/**
|
|
70
|
+
* A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs].
|
|
71
|
+
* Accepts `eventName` and `eventNames` as optional parameters to narrow the returned log types.
|
|
72
|
+
* @example
|
|
73
|
+
* ```ts
|
|
74
|
+
* const logs = contract.getLogs({ eventName: 'EventName' })
|
|
75
|
+
* const logs = contract.getLogs({ eventNames: ['EventName'] })
|
|
76
|
+
*
|
|
77
|
+
* @public
|
|
78
|
+
* @async
|
|
79
|
+
* @template {ContractEvent} event
|
|
80
|
+
* @template {ExtractAbiEvent<
|
|
81
|
+
* ContractAbi,
|
|
82
|
+
* event
|
|
83
|
+
* >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]
|
|
84
|
+
* @param {?Omit<
|
|
85
|
+
* GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,
|
|
86
|
+
* 'event' | 'events'
|
|
87
|
+
* > & {
|
|
88
|
+
* eventName?: event;
|
|
89
|
+
* eventNames?: event[];
|
|
90
|
+
* }} [params]
|
|
91
|
+
* @returns {Promise<GetLogsReturnType<abiEvent, abiEvent[]>>}
|
|
92
|
+
*/
|
|
93
|
+
getLogs<event extends ContractEventName<ContractAbi>, const abiEvent extends ExtractAbiEvent<ContractAbi, event> = ExtractAbiEvent<ContractAbi, event>>(params?: Omit<GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>, 'event' | 'events'> & {
|
|
94
|
+
eventName?: event;
|
|
95
|
+
eventNames?: event[];
|
|
96
|
+
}): Promise<GetLogsReturnType<abiEvent, abiEvent[]>>;
|
|
97
|
+
/**
|
|
98
|
+
* A typed wrapper for `wagmi.watchContractEvent`
|
|
99
|
+
*
|
|
100
|
+
* @public
|
|
101
|
+
* @async
|
|
102
|
+
* @template {ContractEvent} event
|
|
103
|
+
* @param {(
|
|
104
|
+
* log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],
|
|
105
|
+
* ) => unknown} cb
|
|
106
|
+
* @param {?WatchParams<ContractAbi, event> & {
|
|
107
|
+
* eventName?: event;
|
|
108
|
+
* }} [params]
|
|
109
|
+
* @returns {unknown, params?: any) => unknown}
|
|
110
|
+
*/
|
|
111
|
+
subscribe<event extends ContractEventName<ContractAbi>>(cb: (log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number]) => unknown, params?: WatchParams<ContractAbi, event> & {
|
|
112
|
+
eventName?: event;
|
|
113
|
+
}): Promise<() => void>;
|
|
114
|
+
/**
|
|
115
|
+
* @see {@link awaitResult}
|
|
116
|
+
* @protected
|
|
117
|
+
* @async
|
|
118
|
+
* @template [Result=unknown]
|
|
119
|
+
* @param {Promise<HashAndSimulatedResult<Result>>} hashPromise
|
|
120
|
+
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
|
|
121
|
+
* @returns {unknown}
|
|
122
|
+
*/
|
|
123
|
+
protected awaitResult<Result = unknown>(hashPromise: Promise<HashAndSimulatedResult<Result>>, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<Result>;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=Contract.d.ts.map
|
|
@@ -0,0 +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,E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AC,QAAQ,EAAE,QAAQ,EAAE,CAAC,CAAC;IA4BnD;;;;;;;;;;;;;OAaG;IACU,SAAS,CAAC,KAAK,SAAS,iBAAiB,CAAC,WAAW,CAAC,EACjE,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"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { watchContractEvent as o } from "@wagmi/core";
|
|
2
|
+
import { getAbiItem as i } from "viem";
|
|
3
|
+
import { getLogs as d } from "viem/actions";
|
|
4
|
+
import { ContractAddressRequiredError as r } from "../errors.js";
|
|
5
|
+
import { awaitResult as h } from "../utils.js";
|
|
6
|
+
class v {
|
|
7
|
+
/**
|
|
8
|
+
* Creates an instance of Contract.
|
|
9
|
+
*
|
|
10
|
+
* @constructor
|
|
11
|
+
* @param {Config} config
|
|
12
|
+
* @param {(Address | undefined)} address
|
|
13
|
+
*/
|
|
14
|
+
constructor(t, e) {
|
|
15
|
+
this._config = t, this._address = e;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A getter returning this contract's deployed address, if it exists.
|
|
19
|
+
*
|
|
20
|
+
* @public
|
|
21
|
+
* @readonly
|
|
22
|
+
* @type {*}
|
|
23
|
+
*/
|
|
24
|
+
get address() {
|
|
25
|
+
return this._address;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Will set this contract's address and return the instance for chaining. Does not verify that provided address is valid.
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param {Address} address
|
|
32
|
+
* @returns {this}
|
|
33
|
+
*/
|
|
34
|
+
at(t) {
|
|
35
|
+
return this._address = t, this;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Will set this contract's internal [Wagmi Configuration](https://en.wikipedia.org/wiki/Factorial) and return the instance for chaining.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
* @param {Config} config
|
|
42
|
+
* @returns {this}
|
|
43
|
+
*/
|
|
44
|
+
withConfig(t) {
|
|
45
|
+
return this._config = t, this;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Utility function to validate the existence of an address on this Contract.
|
|
49
|
+
*
|
|
50
|
+
* @public
|
|
51
|
+
* @returns {Address}
|
|
52
|
+
* @throws {@link ContractAddressRequiredError} if no address exists on this Contract instance
|
|
53
|
+
*/
|
|
54
|
+
assertValidAddress() {
|
|
55
|
+
const t = this.address;
|
|
56
|
+
if (!t)
|
|
57
|
+
throw new r();
|
|
58
|
+
return t;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* A typed wrapper for (viem.getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs].
|
|
62
|
+
* Accepts `eventName` and `eventNames` as optional parameters to narrow the returned log types.
|
|
63
|
+
* @example
|
|
64
|
+
* ```ts
|
|
65
|
+
* const logs = contract.getLogs({ eventName: 'EventName' })
|
|
66
|
+
* const logs = contract.getLogs({ eventNames: ['EventName'] })
|
|
67
|
+
*
|
|
68
|
+
* @public
|
|
69
|
+
* @async
|
|
70
|
+
* @template {ContractEvent} event
|
|
71
|
+
* @template {ExtractAbiEvent<
|
|
72
|
+
* ContractAbi,
|
|
73
|
+
* event
|
|
74
|
+
* >} [abiEvent=ExtractAbiEvent<ContractAbi, event>]
|
|
75
|
+
* @param {?Omit<
|
|
76
|
+
* GetLogsParams<ContractAbi, event, abiEvent, abiEvent[]>,
|
|
77
|
+
* 'event' | 'events'
|
|
78
|
+
* > & {
|
|
79
|
+
* eventName?: event;
|
|
80
|
+
* eventNames?: event[];
|
|
81
|
+
* }} [params]
|
|
82
|
+
* @returns {Promise<GetLogsReturnType<abiEvent, abiEvent[]>>}
|
|
83
|
+
*/
|
|
84
|
+
async getLogs(t) {
|
|
85
|
+
return d(this._config.getClient({ chainId: t == null ? void 0 : t.chainId }), {
|
|
86
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wag
|
|
87
|
+
...t,
|
|
88
|
+
...t != null && t.eventName ? {
|
|
89
|
+
event: i({
|
|
90
|
+
abi: this.abi,
|
|
91
|
+
name: t.eventName
|
|
92
|
+
// biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue
|
|
93
|
+
})
|
|
94
|
+
} : {},
|
|
95
|
+
...t != null && t.eventNames ? {
|
|
96
|
+
events: t.eventNames.map(
|
|
97
|
+
(e) => i({
|
|
98
|
+
abi: this.abi,
|
|
99
|
+
name: e
|
|
100
|
+
// biome-ignore lint/suspicious/noExplicitAny: awkward abi intersection issue
|
|
101
|
+
})
|
|
102
|
+
)
|
|
103
|
+
} : {},
|
|
104
|
+
address: this.assertValidAddress()
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* A typed wrapper for `wagmi.watchContractEvent`
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
* @async
|
|
112
|
+
* @template {ContractEvent} event
|
|
113
|
+
* @param {(
|
|
114
|
+
* log: WatchContractEventOnLogsParameter<ContractAbi, event, true>[number],
|
|
115
|
+
* ) => unknown} cb
|
|
116
|
+
* @param {?WatchParams<ContractAbi, event> & {
|
|
117
|
+
* eventName?: event;
|
|
118
|
+
* }} [params]
|
|
119
|
+
* @returns {unknown, params?: any) => unknown}
|
|
120
|
+
*/
|
|
121
|
+
async subscribe(t, e) {
|
|
122
|
+
return o(this._config, {
|
|
123
|
+
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
124
|
+
...e,
|
|
125
|
+
eventName: e == null ? void 0 : e.eventName,
|
|
126
|
+
abi: this.abi,
|
|
127
|
+
address: this.assertValidAddress(),
|
|
128
|
+
onLogs: (s) => {
|
|
129
|
+
for (let n of s)
|
|
130
|
+
t(n);
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* @see {@link awaitResult}
|
|
136
|
+
* @protected
|
|
137
|
+
* @async
|
|
138
|
+
* @template [Result=unknown]
|
|
139
|
+
* @param {Promise<HashAndSimulatedResult<Result>>} hashPromise
|
|
140
|
+
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]
|
|
141
|
+
* @returns {unknown}
|
|
142
|
+
*/
|
|
143
|
+
async awaitResult(t, e) {
|
|
144
|
+
return h(this._config, t, e);
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
export {
|
|
148
|
+
v as Contract
|
|
149
|
+
};
|
|
@@ -0,0 +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;
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { type Config, deployContract } from '@wagmi/core';
|
|
2
|
+
import type { Abi, Account, Address, Hash, Hex, WaitForTransactionReceiptParameters } from 'viem';
|
|
3
|
+
import { Contract } from './Contract';
|
|
4
|
+
/**
|
|
5
|
+
* A base class representing a deployable contract, contains base implementations for deployment and initialization payload construction.
|
|
6
|
+
*
|
|
7
|
+
* @export
|
|
8
|
+
* @typedef {GenericDeployableParams}
|
|
9
|
+
*/
|
|
10
|
+
export type GenericDeployableParams = Omit<Parameters<typeof deployContract>[1], 'args' | 'account'> & {
|
|
11
|
+
args: [Hex, ...Array<Hex>];
|
|
12
|
+
account?: Account;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* A generic type that encapsulates either an initialization payload for a contract, or a valid address for a previously deployed contract.
|
|
16
|
+
*
|
|
17
|
+
* @export
|
|
18
|
+
* @typedef {DeployablePayloadOrAddress}
|
|
19
|
+
* @template [Payload=unknown]
|
|
20
|
+
*/
|
|
21
|
+
export type DeployablePayloadOrAddress<Payload = unknown> = Payload | Address;
|
|
22
|
+
/**
|
|
23
|
+
* Instantion options for the base deployable.
|
|
24
|
+
*
|
|
25
|
+
* @export
|
|
26
|
+
* @interface DeployableOptions
|
|
27
|
+
* @typedef {DeployableOptions}
|
|
28
|
+
*/
|
|
29
|
+
export interface DeployableOptions {
|
|
30
|
+
/**
|
|
31
|
+
* [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)
|
|
32
|
+
*
|
|
33
|
+
* @see {@link Config}
|
|
34
|
+
* @type {Config}
|
|
35
|
+
*/
|
|
36
|
+
config: Config;
|
|
37
|
+
/**
|
|
38
|
+
* [Viem Local Account](https://viem.sh/docs/accounts/local), required if in a Node environment
|
|
39
|
+
*
|
|
40
|
+
* @see {@link Account}
|
|
41
|
+
* @type {?Account}
|
|
42
|
+
*/
|
|
43
|
+
account?: Account;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* A generic deployable contract that encapsulates common operations related to contract deployment
|
|
47
|
+
*
|
|
48
|
+
* @export
|
|
49
|
+
* @class Deployable
|
|
50
|
+
* @typedef {Deployable}
|
|
51
|
+
* @template [Payload=unknown]
|
|
52
|
+
* @template {Abi} [ContractAbi=[]]
|
|
53
|
+
* @template {ContractEventName<ContractAbi>} [ContractEvent=ContractEventName<ContractAbi>]
|
|
54
|
+
* @extends {Contract<ContractAbi, ContractEvent>}
|
|
55
|
+
*/
|
|
56
|
+
export declare class Deployable<Payload, ContractAbi extends Abi> extends Contract<ContractAbi> {
|
|
57
|
+
/**
|
|
58
|
+
* The deployable payload used either for contract construction or initialization
|
|
59
|
+
*
|
|
60
|
+
* @protected
|
|
61
|
+
* @type {(Payload | undefined)}
|
|
62
|
+
*/
|
|
63
|
+
protected _payload: Payload | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* If it exists, [Viem Local Account](https://viem.sh/docs/accounts/local), if in a Node environment
|
|
66
|
+
*
|
|
67
|
+
* @protected
|
|
68
|
+
* @type {?Account}
|
|
69
|
+
*/
|
|
70
|
+
protected _account?: Account;
|
|
71
|
+
/**
|
|
72
|
+
* Creates an instance of Deployable.
|
|
73
|
+
*
|
|
74
|
+
* @constructor
|
|
75
|
+
* @param {DeployableOptions} param0
|
|
76
|
+
* @param {?Account} [param0.account]
|
|
77
|
+
* @param {Config} param0.config
|
|
78
|
+
* @param {DeployablePayloadOrAddress<Payload>} payload
|
|
79
|
+
*/
|
|
80
|
+
constructor({ account, config }: DeployableOptions, payload?: DeployablePayloadOrAddress<Payload>);
|
|
81
|
+
/**
|
|
82
|
+
* Returns the attached deployable payload, if it exists
|
|
83
|
+
*
|
|
84
|
+
* @readonly
|
|
85
|
+
* @type {Payload}
|
|
86
|
+
*/
|
|
87
|
+
get payload(): Payload | undefined;
|
|
88
|
+
/**
|
|
89
|
+
* Attaches a new payload for use with this deployable's initialization
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
* @param {Payload} payload
|
|
93
|
+
* @returns {this}
|
|
94
|
+
*/
|
|
95
|
+
withPayload(payload: Payload): this;
|
|
96
|
+
/**
|
|
97
|
+
* High level deployment function to deploy and await the contract address.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
* @async
|
|
101
|
+
* @param {?Payload} [_payload]
|
|
102
|
+
* @param {?DeployableOptions} [_options]
|
|
103
|
+
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
|
|
104
|
+
* @returns {unknown}
|
|
105
|
+
*/
|
|
106
|
+
deploy(_payload?: Payload, _options?: DeployableOptions, waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>): Promise<this>;
|
|
107
|
+
/**
|
|
108
|
+
* The lower level contract deployment function that does not await for the transaction receipt.
|
|
109
|
+
*
|
|
110
|
+
* @public
|
|
111
|
+
* @async
|
|
112
|
+
* @param {?Payload} [_payload]
|
|
113
|
+
* @param {?DeployableOptions} [_options]
|
|
114
|
+
* @returns {Promise<Hash>}
|
|
115
|
+
* @throws {@link DeployableAlreadyDeployedError}
|
|
116
|
+
* @throws {@link DeployableWagmiConfigurationRequiredError}
|
|
117
|
+
* @throws {@link DeployableMissingPayloadError}
|
|
118
|
+
*/
|
|
119
|
+
deployRaw(_payload?: Payload, _options?: DeployableOptions): Promise<Hash>;
|
|
120
|
+
/**
|
|
121
|
+
* Internal function to attach the connected account to write methods to avoid manually passing in an account each call.
|
|
122
|
+
*
|
|
123
|
+
* @protected
|
|
124
|
+
* @param {?Account} [account]
|
|
125
|
+
* @returns {({ account: Account; } | { account?: undefined; })}
|
|
126
|
+
*/
|
|
127
|
+
protected optionallyAttachAccount(account?: Account): {
|
|
128
|
+
account: Account;
|
|
129
|
+
} | {
|
|
130
|
+
account?: undefined;
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Base parameter constructor, should return a partial `viem.deployContract` parameters shape including abi, bytecode, and arguments, if any.
|
|
134
|
+
* Expected to be overridden by protocol contracts.
|
|
135
|
+
*
|
|
136
|
+
* @public
|
|
137
|
+
* @param {?Payload} [_payload]
|
|
138
|
+
* @param {?DeployableOptions} [_options]
|
|
139
|
+
* @returns {GenericDeployableParams}
|
|
140
|
+
*/
|
|
141
|
+
buildParameters(_payload?: Payload, _options?: DeployableOptions): GenericDeployableParams;
|
|
142
|
+
/**
|
|
143
|
+
* Internal method used to ensure that a Wagmi configuration and payload are always present when deploying.
|
|
144
|
+
*
|
|
145
|
+
* @protected
|
|
146
|
+
* @template [P=Payload]
|
|
147
|
+
* @param {?P} [_payload]
|
|
148
|
+
* @param {?DeployableOptions} [_options]
|
|
149
|
+
* @returns {[P, DeployableOptions]}
|
|
150
|
+
* @throws {@link DeployableWagmiConfigurationRequiredError}
|
|
151
|
+
* @throws {@link DeployableMissingPayloadError}
|
|
152
|
+
*/
|
|
153
|
+
protected validateDeploymentConfig<P = Payload>(_payload?: P, _options?: DeployableOptions): [P, DeployableOptions];
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=Deployable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Deployable.d.ts","sourceRoot":"","sources":["../../src/Deployable/Deployable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,MAAM,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC1D,OAAO,KAAK,EACV,GAAG,EACH,OAAO,EACP,OAAO,EAEP,IAAI,EACJ,GAAG,EACH,mCAAmC,EACpC,MAAM,MAAM,CAAC;AAQd,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC;;;;;GAKG;AACH,MAAM,MAAM,uBAAuB,GAAG,IAAI,CACxC,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC,EACpC,MAAM,GA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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;CAU/B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { deployContract as i } from "@wagmi/core";
|
|
2
|
+
import { DeployableAlreadyDeployedError as s, DeployableBuildParametersUnspecifiedError as n, DeployableWagmiConfigurationRequiredError as l } from "../errors.js";
|
|
3
|
+
import { getDeployedContractAddress as c } from "../utils.js";
|
|
4
|
+
import { Contract as d } from "./Contract.js";
|
|
5
|
+
class m extends d {
|
|
6
|
+
/**
|
|
7
|
+
* Creates an instance of Deployable.
|
|
8
|
+
*
|
|
9
|
+
* @constructor
|
|
10
|
+
* @param {DeployableOptions} param0
|
|
11
|
+
* @param {?Account} [param0.account]
|
|
12
|
+
* @param {Config} param0.config
|
|
13
|
+
* @param {DeployablePayloadOrAddress<Payload>} payload
|
|
14
|
+
*/
|
|
15
|
+
constructor({ account: t, config: o }, a) {
|
|
16
|
+
typeof a == "string" ? super(o, a) : (super(o, void 0), this._payload = a), t && (this._account = t);
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Returns the attached deployable payload, if it exists
|
|
20
|
+
*
|
|
21
|
+
* @readonly
|
|
22
|
+
* @type {Payload}
|
|
23
|
+
*/
|
|
24
|
+
get payload() {
|
|
25
|
+
return this._payload;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Attaches a new payload for use with this deployable's initialization
|
|
29
|
+
*
|
|
30
|
+
* @public
|
|
31
|
+
* @param {Payload} payload
|
|
32
|
+
* @returns {this}
|
|
33
|
+
*/
|
|
34
|
+
withPayload(t) {
|
|
35
|
+
return this._payload = t, this;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* High level deployment function to deploy and await the contract address.
|
|
39
|
+
*
|
|
40
|
+
* @public
|
|
41
|
+
* @async
|
|
42
|
+
* @param {?Payload} [_payload]
|
|
43
|
+
* @param {?DeployableOptions} [_options]
|
|
44
|
+
* @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - See [viem.WaitForTransactionReceipt](https://v1.viem.sh/docs/actions/public/waitForTransactionReceipt.html#waitfortransactionreceipt)
|
|
45
|
+
* @returns {unknown}
|
|
46
|
+
*/
|
|
47
|
+
async deploy(t, o, a) {
|
|
48
|
+
const e = (o == null ? void 0 : o.config) || this._config, r = await c(
|
|
49
|
+
e,
|
|
50
|
+
this.deployRaw(t, o),
|
|
51
|
+
a
|
|
52
|
+
);
|
|
53
|
+
return this._address = r, this;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The lower level contract deployment function that does not await for the transaction receipt.
|
|
57
|
+
*
|
|
58
|
+
* @public
|
|
59
|
+
* @async
|
|
60
|
+
* @param {?Payload} [_payload]
|
|
61
|
+
* @param {?DeployableOptions} [_options]
|
|
62
|
+
* @returns {Promise<Hash>}
|
|
63
|
+
* @throws {@link DeployableAlreadyDeployedError}
|
|
64
|
+
* @throws {@link DeployableWagmiConfigurationRequiredError}
|
|
65
|
+
* @throws {@link DeployableMissingPayloadError}
|
|
66
|
+
*/
|
|
67
|
+
async deployRaw(t, o) {
|
|
68
|
+
if (this.address)
|
|
69
|
+
throw new s(this.address);
|
|
70
|
+
const [a, e] = this.validateDeploymentConfig(
|
|
71
|
+
t,
|
|
72
|
+
o
|
|
73
|
+
);
|
|
74
|
+
return await i(e.config, {
|
|
75
|
+
...this.buildParameters(a),
|
|
76
|
+
...this.optionallyAttachAccount(e.account)
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Internal function to attach the connected account to write methods to avoid manually passing in an account each call.
|
|
81
|
+
*
|
|
82
|
+
* @protected
|
|
83
|
+
* @param {?Account} [account]
|
|
84
|
+
* @returns {({ account: Account; } | { account?: undefined; })}
|
|
85
|
+
*/
|
|
86
|
+
optionallyAttachAccount(t) {
|
|
87
|
+
return t ? { account: t } : this._account ? { account: this._account } : {};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Base parameter constructor, should return a partial `viem.deployContract` parameters shape including abi, bytecode, and arguments, if any.
|
|
91
|
+
* Expected to be overridden by protocol contracts.
|
|
92
|
+
*
|
|
93
|
+
* @public
|
|
94
|
+
* @param {?Payload} [_payload]
|
|
95
|
+
* @param {?DeployableOptions} [_options]
|
|
96
|
+
* @returns {GenericDeployableParams}
|
|
97
|
+
*/
|
|
98
|
+
buildParameters(t, o) {
|
|
99
|
+
throw new n();
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Internal method used to ensure that a Wagmi configuration and payload are always present when deploying.
|
|
103
|
+
*
|
|
104
|
+
* @protected
|
|
105
|
+
* @template [P=Payload]
|
|
106
|
+
* @param {?P} [_payload]
|
|
107
|
+
* @param {?DeployableOptions} [_options]
|
|
108
|
+
* @returns {[P, DeployableOptions]}
|
|
109
|
+
* @throws {@link DeployableWagmiConfigurationRequiredError}
|
|
110
|
+
* @throws {@link DeployableMissingPayloadError}
|
|
111
|
+
*/
|
|
112
|
+
validateDeploymentConfig(t, o) {
|
|
113
|
+
const a = o || {
|
|
114
|
+
config: this._config,
|
|
115
|
+
account: this._account
|
|
116
|
+
};
|
|
117
|
+
if (!a)
|
|
118
|
+
throw new l();
|
|
119
|
+
return [t || this._payload, a];
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
export {
|
|
123
|
+
m as Deployable
|
|
124
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("../generated-BaaleHW-.cjs"),d=require("@wagmi/core"),l=require("viem"),n=require("../errors.cjs"),y=require("../utils.cjs"),u=require("./Deployable.cjs"),s=class s extends u.Deployable{constructor(t,e,r){super(t,e),this.isBase=!0,r!==void 0&&(this.isBase=r)}get base(){return this.constructor.base}get registryType(){return this.constructor.registryType}async deploy(t,e,r){return await super.deploy(t,e,r),this.assertValidAddress(),this}async deployRaw(t,e){if(this.address)throw new n.DeployableAlreadyDeployedError(this.address);const r=t||this._payload,o=(e==null?void 0:e.config)||this._config,{args:h,...c}=this.buildParameters(r);return await d.deployContract(o,{...c,...this.optionallyAttachAccount(e==null?void 0:e.account),args:[]})}async supportsInterface(t,e){return i.Xn(this._config,{address:this.assertValidAddress(),...this.optionallyAttachAccount(),...e,args:[t]})}async getComponentInterface(t){return i.Kn(this._config,{address:this.assertValidAddress(),...this.optionallyAttachAccount(),...t,args:[]})}validateDeploymentConfig(t,e){const r=t||this._payload;if(!r)throw new n.DeployableMissingPayloadError;return super.validateDeploymentConfig(r,e)}};s.base=l.zeroAddress,s.registryType=y.RegistryType.ACTION;let a=s;exports.DeployableTarget=a;
|