@boostxyz/sdk 0.0.0-alpha.8 → 1.1.0-alpha.22
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 +1 -1
- package/dist/Actions/Action.cjs.map +1 -1
- package/dist/Actions/Action.js +7 -7
- 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 +1 -1
- package/dist/Actions/EventAction.cjs.map +1 -1
- package/dist/Actions/EventAction.d.ts +420 -45
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -225
- package/dist/Actions/EventAction.js.map +1 -1
- package/dist/AllowLists/AllowList.cjs +1 -1
- package/dist/AllowLists/AllowList.cjs.map +1 -1
- package/dist/AllowLists/AllowList.d.ts +6 -4
- package/dist/AllowLists/AllowList.d.ts.map +1 -1
- package/dist/AllowLists/AllowList.js +45 -23
- package/dist/AllowLists/AllowList.js.map +1 -1
- package/dist/AllowLists/OpenAllowList.d.ts +423 -0
- package/dist/AllowLists/OpenAllowList.d.ts.map +1 -0
- package/dist/AllowLists/SimpleAllowList.cjs +1 -1
- package/dist/AllowLists/SimpleAllowList.cjs.map +1 -1
- package/dist/AllowLists/SimpleAllowList.d.ts +123 -39
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +75 -76
- package/dist/AllowLists/SimpleAllowList.js.map +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs +1 -1
- package/dist/AllowLists/SimpleDenyList.cjs.map +1 -1
- package/dist/AllowLists/SimpleDenyList.d.ts +234 -13
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -200
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.cjs.map +1 -1
- package/dist/Auth/PassthroughAuth.js +4 -4
- package/dist/Auth/PassthroughAuth.js.map +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +105 -14
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +137 -5
- package/dist/Boost.js.map +1 -1
- package/dist/BoostCore-BVZExPPu.js +1462 -0
- package/dist/BoostCore-BVZExPPu.js.map +1 -0
- package/dist/BoostCore-D-E-cnGI.cjs +3 -0
- package/dist/BoostCore-D-E-cnGI.cjs.map +1 -0
- package/dist/BoostCore.cjs +1 -2
- package/dist/BoostCore.cjs.map +1 -1
- package/dist/BoostCore.d.ts +759 -82
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1148
- package/dist/BoostCore.js.map +1 -1
- package/dist/BoostRegistry.cjs +1 -1
- package/dist/BoostRegistry.cjs.map +1 -1
- package/dist/BoostRegistry.d.ts +83 -28
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +170 -93
- package/dist/BoostRegistry.js.map +1 -1
- package/dist/Budgets/Budget.cjs +1 -1
- package/dist/Budgets/Budget.cjs.map +1 -1
- package/dist/Budgets/Budget.d.ts.map +1 -1
- package/dist/Budgets/Budget.js +2 -2
- package/dist/Budgets/Budget.js.map +1 -1
- package/dist/Budgets/ManagedBudget.cjs +1 -1
- package/dist/Budgets/ManagedBudget.cjs.map +1 -1
- package/dist/Budgets/ManagedBudget.d.ts +112 -192
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +89 -290
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +277 -91
- package/dist/Budgets/VestingBudget.d.ts.map +1 -1
- package/dist/Deployable/Contract.cjs +1 -1
- package/dist/Deployable/Contract.cjs.map +1 -1
- package/dist/Deployable/Contract.d.ts +4 -5
- package/dist/Deployable/Contract.d.ts.map +1 -1
- package/dist/Deployable/Contract.js +6 -8
- package/dist/Deployable/Contract.js.map +1 -1
- package/dist/Deployable/Deployable.cjs.map +1 -1
- package/dist/Deployable/Deployable.d.ts +1 -1
- package/dist/Deployable/Deployable.d.ts.map +1 -1
- package/dist/Deployable/Deployable.js +3 -5
- package/dist/Deployable/Deployable.js.map +1 -1
- package/dist/Deployable/DeployableTarget.cjs +1 -1
- package/dist/Deployable/DeployableTarget.cjs.map +1 -1
- package/dist/Deployable/DeployableTarget.d.ts +13 -13
- package/dist/Deployable/DeployableTarget.d.ts.map +1 -1
- package/dist/Deployable/DeployableTarget.js +30 -27
- package/dist/Deployable/DeployableTarget.js.map +1 -1
- 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-BZt5cjbe.cjs +2 -0
- package/dist/EventAction-BZt5cjbe.cjs.map +1 -0
- package/dist/EventAction-C_-hJXWm.js +1541 -0
- package/dist/EventAction-C_-hJXWm.js.map +1 -0
- package/dist/Incentive-BhHaK3PZ.cjs +2 -0
- package/dist/Incentive-BhHaK3PZ.cjs.map +1 -0
- package/dist/Incentive-Cqg1w6wD.js +312 -0
- package/dist/Incentive-Cqg1w6wD.js.map +1 -0
- package/dist/Incentives/AllowListIncentive.cjs +1 -1
- package/dist/Incentives/AllowListIncentive.cjs.map +1 -1
- package/dist/Incentives/AllowListIncentive.d.ts +73 -21
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +61 -36
- package/dist/Incentives/AllowListIncentive.js.map +1 -1
- package/dist/Incentives/CGDAIncentive.cjs +1 -1
- package/dist/Incentives/CGDAIncentive.cjs.map +1 -1
- package/dist/Incentives/CGDAIncentive.d.ts +323 -26
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +73 -39
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +291 -43
- package/dist/Incentives/ERC1155Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.cjs +1 -1
- package/dist/Incentives/ERC20Incentive.cjs.map +1 -1
- package/dist/Incentives/ERC20Incentive.d.ts +278 -33
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +79 -47
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +346 -420
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +271 -32
- package/dist/Incentives/ERC20VariableIncentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.cjs +1 -1
- package/dist/Incentives/Incentive.cjs.map +1 -1
- package/dist/Incentives/Incentive.d.ts +4 -4
- package/dist/Incentives/Incentive.d.ts.map +1 -1
- package/dist/Incentives/Incentive.js +16 -280
- package/dist/Incentives/Incentive.js.map +1 -1
- package/dist/Incentives/PointsIncentive.cjs +1 -1
- package/dist/Incentives/PointsIncentive.cjs.map +1 -1
- package/dist/Incentives/PointsIncentive.d.ts +89 -23
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +66 -36
- package/dist/Incentives/PointsIncentive.js.map +1 -1
- package/dist/SimpleDenyList-BUR17Tt1.cjs +2 -0
- package/dist/SimpleDenyList-BUR17Tt1.cjs.map +1 -0
- package/dist/SimpleDenyList-CGaWjuld.js +132 -0
- package/dist/SimpleDenyList-CGaWjuld.js.map +1 -0
- package/dist/Validators/SignerValidator.cjs +1 -1
- package/dist/Validators/SignerValidator.cjs.map +1 -1
- package/dist/Validators/SignerValidator.d.ts +310 -17
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +164 -36
- package/dist/Validators/SignerValidator.js.map +1 -1
- package/dist/Validators/Validator.cjs +1 -1
- package/dist/Validators/Validator.cjs.map +1 -1
- package/dist/Validators/Validator.d.ts +1 -1
- package/dist/Validators/Validator.js +2 -2
- package/dist/Validators/Validator.js.map +1 -1
- 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-BBCFkrZv.js +14 -0
- package/dist/componentInterfaces-BBCFkrZv.js.map +1 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs +2 -0
- package/dist/componentInterfaces-DRI_dQ-P.cjs.map +1 -0
- package/dist/deployments-DVXioW2i.cjs +2 -0
- package/dist/deployments-DVXioW2i.cjs.map +1 -0
- package/dist/deployments-oykLv3_Z.js +43 -0
- package/dist/deployments-oykLv3_Z.js.map +1 -0
- package/dist/deployments.json +44 -0
- package/dist/errors.cjs +1 -1
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.d.ts +257 -21
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-Cbv8zFkf.js → generated-CKt2yCQd.js} +3615 -1868
- package/dist/generated-CKt2yCQd.js.map +1 -0
- package/dist/generated-CyTNlOwM.cjs +3 -0
- package/dist/generated-CyTNlOwM.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +9 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +143 -126
- package/dist/index.js.map +1 -1
- 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 +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +25 -1380
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +36 -648
- package/dist/utils.js.map +1 -1
- package/package.json +34 -10
- package/src/Actions/Action.test.ts +19 -17
- package/src/Actions/ContractAction.test.ts +14 -16
- package/src/Actions/ContractAction.ts +84 -22
- package/src/Actions/ERC721MintAction.test.ts +8 -8
- package/src/Actions/ERC721MintAction.ts +83 -30
- package/src/Actions/EventAction.test.ts +759 -113
- package/src/Actions/EventAction.ts +991 -116
- package/src/AllowLists/AllowList.test.ts +7 -7
- package/src/AllowLists/AllowList.ts +5 -3
- package/src/AllowLists/OpenAllowList.test.ts +40 -0
- package/src/AllowLists/OpenAllowList.ts +45 -0
- package/src/AllowLists/SimpleAllowList.test.ts +4 -4
- package/src/AllowLists/SimpleAllowList.ts +86 -65
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +87 -126
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Auth/PassthroughAuth.ts +1 -1
- package/src/Boost.ts +147 -15
- package/src/BoostCore.test.ts +326 -278
- package/src/BoostCore.ts +425 -242
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +168 -50
- package/src/Budgets/Budget.test.ts +2 -2
- package/src/Budgets/Budget.ts +1 -2
- package/src/Budgets/ManagedBudget.test.ts +82 -19
- package/src/Budgets/ManagedBudget.ts +106 -315
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +110 -112
- package/src/Deployable/Contract.ts +5 -6
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +32 -21
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +7 -10
- package/src/Incentives/AllowListIncentive.ts +88 -30
- package/src/Incentives/CGDAIncentive.test.ts +11 -12
- package/src/Incentives/CGDAIncentive.ts +161 -37
- package/src/Incentives/ERC1155Incentive.test.ts +5 -16
- package/src/Incentives/ERC1155Incentive.ts +132 -51
- package/src/Incentives/ERC20Incentive.test.ts +15 -23
- package/src/Incentives/ERC20Incentive.ts +131 -46
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +12 -35
- package/src/Incentives/ERC20VariableIncentive.ts +118 -43
- package/src/Incentives/Incentive.test.ts +5 -2
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +26 -30
- package/src/Incentives/PointsIncentive.ts +110 -34
- package/src/Validators/SignerValidator.test.ts +9 -13
- package/src/Validators/SignerValidator.ts +437 -26
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +56 -0
- package/src/errors.ts +346 -22
- package/src/index.test.ts +118 -36
- package/src/index.ts +15 -7
- package/src/transfers.ts +284 -0
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -2061
- package/dist/Budgets/SimpleBudget.d.ts.map +0 -1
- package/dist/componentInterfaces-CKCBwG16.cjs +0 -2
- package/dist/componentInterfaces-CKCBwG16.cjs.map +0 -1
- package/dist/componentInterfaces-DYkaxBda.js +0 -13
- package/dist/componentInterfaces-DYkaxBda.js.map +0 -1
- package/dist/generated-BzszviNp.cjs +0 -3
- package/dist/generated-BzszviNp.cjs.map +0 -1
- package/dist/generated-Cbv8zFkf.js.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -521
|
@@ -9,23 +9,61 @@ import {
|
|
|
9
9
|
writeContractActionExecute,
|
|
10
10
|
} from '@boostxyz/evm';
|
|
11
11
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/ContractAction.sol/ContractAction.json';
|
|
12
|
-
import
|
|
12
|
+
import {
|
|
13
|
+
type Abi,
|
|
14
|
+
type Address,
|
|
15
|
+
type ContractEventName,
|
|
16
|
+
type Hex,
|
|
17
|
+
encodeAbiParameters,
|
|
18
|
+
parseAbiParameters,
|
|
19
|
+
} from 'viem';
|
|
13
20
|
import type {
|
|
14
21
|
DeployableOptions,
|
|
15
22
|
GenericDeployableParams,
|
|
16
23
|
} from '../Deployable/Deployable';
|
|
17
24
|
import { DeployableTarget } from '../Deployable/DeployableTarget';
|
|
18
25
|
import {
|
|
19
|
-
type ContractActionPayload,
|
|
20
26
|
type GenericLog,
|
|
21
27
|
type ReadParams,
|
|
22
28
|
RegistryType,
|
|
23
29
|
type WriteParams,
|
|
24
|
-
prepareContractActionPayload,
|
|
25
30
|
} from '../utils';
|
|
26
31
|
|
|
27
32
|
export { contractActionAbi };
|
|
28
|
-
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* The object representation of a `ContractAction.InitPayload`
|
|
36
|
+
*
|
|
37
|
+
* @export
|
|
38
|
+
* @interface ContractActionPayload
|
|
39
|
+
* @typedef {ContractActionPayload}
|
|
40
|
+
*/
|
|
41
|
+
export interface ContractActionPayload {
|
|
42
|
+
/**
|
|
43
|
+
* The chain ID on which the target exists
|
|
44
|
+
*
|
|
45
|
+
* @type {bigint}
|
|
46
|
+
*/
|
|
47
|
+
chainId: bigint;
|
|
48
|
+
/**
|
|
49
|
+
* The target contract address
|
|
50
|
+
*
|
|
51
|
+
* @type {Address}
|
|
52
|
+
*/
|
|
53
|
+
target: Address;
|
|
54
|
+
/**
|
|
55
|
+
* The selector for the function to be called
|
|
56
|
+
*
|
|
57
|
+
* @type {Hex}
|
|
58
|
+
*/
|
|
59
|
+
selector: Hex;
|
|
60
|
+
/**
|
|
61
|
+
* The native token value to send with the function call
|
|
62
|
+
*
|
|
63
|
+
* @type {bigint}
|
|
64
|
+
*/
|
|
65
|
+
value: bigint;
|
|
66
|
+
}
|
|
29
67
|
|
|
30
68
|
/**
|
|
31
69
|
* A generic `viem.Log` event with support for `ContractAction` event types.
|
|
@@ -61,10 +99,9 @@ export class ContractAction<
|
|
|
61
99
|
*
|
|
62
100
|
* @public
|
|
63
101
|
* @static
|
|
64
|
-
* @type {Address}
|
|
102
|
+
* @type {Record<number, Address>}
|
|
65
103
|
*/
|
|
66
|
-
public static override
|
|
67
|
-
.VITE_CONTRACT_ACTION_BASE;
|
|
104
|
+
public static override bases: Record<number, Address> = {};
|
|
68
105
|
/**
|
|
69
106
|
* @inheritdoc
|
|
70
107
|
*
|
|
@@ -79,13 +116,13 @@ export class ContractAction<
|
|
|
79
116
|
*
|
|
80
117
|
* @public
|
|
81
118
|
* @async
|
|
82
|
-
* @param {?ReadParams
|
|
119
|
+
* @param {?ReadParams} [params]
|
|
83
120
|
* @returns {Promise<bigint>}
|
|
84
121
|
*/
|
|
85
122
|
public async chainId(
|
|
86
123
|
params?: ReadParams<typeof contractActionAbi, 'chainId'>,
|
|
87
124
|
) {
|
|
88
|
-
return readContractActionChainId(this._config, {
|
|
125
|
+
return await readContractActionChainId(this._config, {
|
|
89
126
|
address: this.assertValidAddress(),
|
|
90
127
|
...this.optionallyAttachAccount(),
|
|
91
128
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -98,11 +135,11 @@ export class ContractAction<
|
|
|
98
135
|
*
|
|
99
136
|
* @public
|
|
100
137
|
* @async
|
|
101
|
-
* @param {?ReadParams
|
|
138
|
+
* @param {?ReadParams} [params]
|
|
102
139
|
* @returns {Promise<`0x${string}`>}
|
|
103
140
|
*/
|
|
104
141
|
public async target(params?: ReadParams<typeof contractActionAbi, 'target'>) {
|
|
105
|
-
return readContractActionTarget(this._config, {
|
|
142
|
+
return await readContractActionTarget(this._config, {
|
|
106
143
|
address: this.assertValidAddress(),
|
|
107
144
|
...this.optionallyAttachAccount(),
|
|
108
145
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -116,13 +153,13 @@ export class ContractAction<
|
|
|
116
153
|
* @example `function mint(address to, uint256 amount)`
|
|
117
154
|
* @public
|
|
118
155
|
* @async
|
|
119
|
-
* @param {?ReadParams
|
|
156
|
+
* @param {?ReadParams} [params]
|
|
120
157
|
* @returns {Promise<`0x${string}`>}
|
|
121
158
|
*/
|
|
122
159
|
public async selector(
|
|
123
160
|
params?: ReadParams<typeof contractActionAbi, 'selector'>,
|
|
124
161
|
) {
|
|
125
|
-
return readContractActionSelector(this._config, {
|
|
162
|
+
return await readContractActionSelector(this._config, {
|
|
126
163
|
address: this.assertValidAddress(),
|
|
127
164
|
...this.optionallyAttachAccount(),
|
|
128
165
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -135,11 +172,11 @@ export class ContractAction<
|
|
|
135
172
|
*
|
|
136
173
|
* @public
|
|
137
174
|
* @async
|
|
138
|
-
* @param {?ReadParams
|
|
175
|
+
* @param {?ReadParams} [params]
|
|
139
176
|
* @returns {Promise<bigint>}
|
|
140
177
|
*/
|
|
141
178
|
public async value(params?: ReadParams<typeof contractActionAbi, 'value'>) {
|
|
142
|
-
return readContractActionValue(this._config, {
|
|
179
|
+
return await readContractActionValue(this._config, {
|
|
143
180
|
address: this.assertValidAddress(),
|
|
144
181
|
...this.optionallyAttachAccount(),
|
|
145
182
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -153,14 +190,14 @@ export class ContractAction<
|
|
|
153
190
|
* @public
|
|
154
191
|
* @async
|
|
155
192
|
* @param {Hex} data
|
|
156
|
-
* @param {?WriteParams
|
|
193
|
+
* @param {?WriteParams} [params]
|
|
157
194
|
* @returns {Promise<readonly [boolean, `0x${string}`]>}
|
|
158
195
|
*/
|
|
159
196
|
public async execute(
|
|
160
197
|
data: Hex,
|
|
161
198
|
params?: WriteParams<typeof contractActionAbi, 'execute'>,
|
|
162
199
|
) {
|
|
163
|
-
return this.awaitResult(this.executeRaw(data, params));
|
|
200
|
+
return await this.awaitResult(this.executeRaw(data, params));
|
|
164
201
|
}
|
|
165
202
|
|
|
166
203
|
/**
|
|
@@ -169,8 +206,8 @@ export class ContractAction<
|
|
|
169
206
|
* @public
|
|
170
207
|
* @async
|
|
171
208
|
* @param {Hex} data
|
|
172
|
-
* @param {?WriteParams
|
|
173
|
-
* @returns {
|
|
209
|
+
* @param {?WriteParams} [params]
|
|
210
|
+
* @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
|
|
174
211
|
*/
|
|
175
212
|
public async executeRaw(
|
|
176
213
|
data: Hex,
|
|
@@ -196,14 +233,14 @@ export class ContractAction<
|
|
|
196
233
|
* @public
|
|
197
234
|
* @async
|
|
198
235
|
* @param {Hex} calldata
|
|
199
|
-
* @param {?ReadParams
|
|
200
|
-
* @returns {
|
|
236
|
+
* @param {?ReadParams} [params]
|
|
237
|
+
* @returns {Promise<`0x${string}`>}
|
|
201
238
|
*/
|
|
202
239
|
public async prepare(
|
|
203
240
|
calldata: Hex,
|
|
204
241
|
params?: ReadParams<typeof contractActionAbi, 'prepare'>,
|
|
205
242
|
) {
|
|
206
|
-
return readContractActionPrepare(this._config, {
|
|
243
|
+
return await readContractActionPrepare(this._config, {
|
|
207
244
|
address: this.assertValidAddress(),
|
|
208
245
|
args: [calldata],
|
|
209
246
|
...this.optionallyAttachAccount(),
|
|
@@ -236,3 +273,28 @@ export class ContractAction<
|
|
|
236
273
|
};
|
|
237
274
|
}
|
|
238
275
|
}
|
|
276
|
+
|
|
277
|
+
/**
|
|
278
|
+
* Given a {@link ContractActionPayload}, properly encode a `ContractAction.InitPayload` for use with {@link ContractAction} initialization.
|
|
279
|
+
*
|
|
280
|
+
* @param {ContractActionPayload} param0
|
|
281
|
+
* @param {bigint} param0.chainId - The chain ID on which the target exists
|
|
282
|
+
* @param {Address} param0.target - The target contract address
|
|
283
|
+
* @param {Hex} param0.selector - The selector for the function to be called
|
|
284
|
+
* @param {bigint} param0.value - The native token value to send with the function call
|
|
285
|
+
* @returns {Hex}
|
|
286
|
+
*/
|
|
287
|
+
export function prepareContractActionPayload({
|
|
288
|
+
chainId,
|
|
289
|
+
target,
|
|
290
|
+
selector,
|
|
291
|
+
value,
|
|
292
|
+
}: ContractActionPayload) {
|
|
293
|
+
return encodeAbiParameters(
|
|
294
|
+
parseAbiParameters([
|
|
295
|
+
'ContractActionPayload payload',
|
|
296
|
+
'struct ContractActionPayload { uint256 chainId; address target; bytes4 selector; uint256 value; }',
|
|
297
|
+
]),
|
|
298
|
+
[{ chainId, target, selector, value }],
|
|
299
|
+
);
|
|
300
|
+
}
|
|
@@ -9,29 +9,29 @@ import {
|
|
|
9
9
|
zeroAddress,
|
|
10
10
|
} from 'viem';
|
|
11
11
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
12
|
-
import type { MockERC721 } from '
|
|
13
|
-
import { accounts } from '
|
|
12
|
+
import type { MockERC721 } from '@boostxyz/test/MockERC721';
|
|
13
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
14
14
|
import {
|
|
15
15
|
type Fixtures,
|
|
16
16
|
defaultOptions,
|
|
17
17
|
deployFixtures,
|
|
18
18
|
fundErc721,
|
|
19
|
-
} from '
|
|
19
|
+
} from '@boostxyz/test/helpers';
|
|
20
20
|
import { ERC721MintAction } from './ERC721MintAction';
|
|
21
21
|
|
|
22
22
|
let fixtures: Fixtures, erc721: MockERC721;
|
|
23
23
|
|
|
24
24
|
beforeAll(async () => {
|
|
25
|
-
fixtures = await loadFixture(deployFixtures);
|
|
25
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
26
26
|
});
|
|
27
27
|
|
|
28
28
|
const mintSelector = toFunctionSelector('function mint(address to)');
|
|
29
29
|
|
|
30
30
|
function nonPayableAction(fixtures: Fixtures, erc721: MockERC721) {
|
|
31
31
|
return function nonPayableAction() {
|
|
32
|
-
return fixtures.registry.
|
|
32
|
+
return fixtures.registry.initialize(
|
|
33
33
|
crypto.randomUUID(),
|
|
34
|
-
|
|
34
|
+
fixtures.core.ERC721MintAction({
|
|
35
35
|
chainId: BigInt(31_337),
|
|
36
36
|
target: erc721.assertValidAddress(),
|
|
37
37
|
selector: mintSelector,
|
|
@@ -81,7 +81,7 @@ describe.skip('ERC721MintAction', () => {
|
|
|
81
81
|
|
|
82
82
|
test('prepare will properly encode execution payload', async () => {
|
|
83
83
|
const action = await loadFixture(nonPayableAction(fixtures, erc721));
|
|
84
|
-
const { account } = accounts
|
|
84
|
+
const { account } = accounts[1];
|
|
85
85
|
const payload = await action.prepare(
|
|
86
86
|
encodeAbiParameters([{ type: 'address', name: 'address' }], [account]),
|
|
87
87
|
);
|
|
@@ -97,7 +97,7 @@ describe.skip('ERC721MintAction', () => {
|
|
|
97
97
|
// TODO implement execute
|
|
98
98
|
test.skip('nonpayable execute', async () => {
|
|
99
99
|
const action = await loadFixture(nonPayableAction(fixtures, erc721));
|
|
100
|
-
const { account } = accounts
|
|
100
|
+
const { account } = accounts[1];
|
|
101
101
|
const [success] = await action.execute(
|
|
102
102
|
encodeAbiParameters(
|
|
103
103
|
[
|
|
@@ -8,24 +8,37 @@ import {
|
|
|
8
8
|
writeErc721MintActionValidate,
|
|
9
9
|
} from '@boostxyz/evm';
|
|
10
10
|
import { bytecode } from '@boostxyz/evm/artifacts/contracts/actions/ERC721MintAction.sol/ERC721MintAction.json';
|
|
11
|
-
import
|
|
11
|
+
import {
|
|
12
|
+
type Address,
|
|
13
|
+
type ContractEventName,
|
|
14
|
+
type Hex,
|
|
15
|
+
encodeAbiParameters,
|
|
16
|
+
toHex,
|
|
17
|
+
} from 'viem';
|
|
12
18
|
import type {
|
|
13
19
|
DeployableOptions,
|
|
14
20
|
GenericDeployableParams,
|
|
15
21
|
} from '../Deployable/Deployable';
|
|
16
22
|
import {
|
|
17
|
-
type ERC721MintActionPayload,
|
|
18
23
|
type GenericLog,
|
|
19
24
|
type ReadParams,
|
|
20
25
|
RegistryType,
|
|
21
26
|
type WriteParams,
|
|
22
|
-
prepareERC721MintActionPayload,
|
|
23
|
-
prepareERC721MintActionValidate,
|
|
24
27
|
} from '../utils';
|
|
25
|
-
import {
|
|
28
|
+
import {
|
|
29
|
+
ContractAction,
|
|
30
|
+
type ContractActionPayload,
|
|
31
|
+
prepareContractActionPayload,
|
|
32
|
+
} from './ContractAction';
|
|
26
33
|
|
|
27
|
-
export { erc721MintActionAbi
|
|
28
|
-
|
|
34
|
+
export { erc721MintActionAbi };
|
|
35
|
+
/**
|
|
36
|
+
* `ERC721MintActionPayload` is a re-exported `ContractActionPayload`
|
|
37
|
+
*
|
|
38
|
+
* @export
|
|
39
|
+
* @typedef {ERC721MintActionPayload}
|
|
40
|
+
*/
|
|
41
|
+
export type ERC721MintActionPayload = ContractActionPayload;
|
|
29
42
|
|
|
30
43
|
/**
|
|
31
44
|
* A generic `viem.Log` event with support for `ERC721MintAction` event types.
|
|
@@ -64,10 +77,9 @@ export class ERC721MintAction extends ContractAction<
|
|
|
64
77
|
*
|
|
65
78
|
* @public
|
|
66
79
|
* @static
|
|
67
|
-
* @type {Address}
|
|
80
|
+
* @type {Record<number, Address>}
|
|
68
81
|
*/
|
|
69
|
-
public static override
|
|
70
|
-
.VITE_ERC721_MINT_ACTION_BASE;
|
|
82
|
+
public static override bases: Record<number, Address> = {};
|
|
71
83
|
/**
|
|
72
84
|
* @inheritdoc
|
|
73
85
|
*
|
|
@@ -84,14 +96,14 @@ export class ERC721MintAction extends ContractAction<
|
|
|
84
96
|
* @public
|
|
85
97
|
* @async
|
|
86
98
|
* @param {bigint} token
|
|
87
|
-
* @param {?ReadParams
|
|
88
|
-
* @returns {
|
|
99
|
+
* @param {?ReadParams} [params]
|
|
100
|
+
* @returns {Promise<boolean>}
|
|
89
101
|
*/
|
|
90
102
|
public async validated(
|
|
91
103
|
token: bigint,
|
|
92
104
|
params?: ReadParams<typeof erc721MintActionAbi, 'validated'>,
|
|
93
105
|
) {
|
|
94
|
-
return readErc721MintActionValidated(this._config, {
|
|
106
|
+
return await readErc721MintActionValidated(this._config, {
|
|
95
107
|
address: this.assertValidAddress(),
|
|
96
108
|
...this.optionallyAttachAccount(),
|
|
97
109
|
// biome-ignore lint/suspicious/noExplicitAny: Accept any shape of valid wagmi/viem parameters, wagmi does the same thing internally
|
|
@@ -106,14 +118,14 @@ export class ERC721MintAction extends ContractAction<
|
|
|
106
118
|
* @public
|
|
107
119
|
* @async
|
|
108
120
|
* @param {Hex} data
|
|
109
|
-
* @param {?WriteParams
|
|
110
|
-
* @returns {
|
|
121
|
+
* @param {?WriteParams} [params]
|
|
122
|
+
* @returns {Promise<readonly [boolean, `0x${string}`]>}
|
|
111
123
|
*/
|
|
112
124
|
public override async execute(
|
|
113
125
|
data: Hex,
|
|
114
126
|
params?: WriteParams<typeof erc721MintActionAbi, 'execute'>,
|
|
115
127
|
) {
|
|
116
|
-
return this.awaitResult(this.executeRaw(data, params));
|
|
128
|
+
return await this.awaitResult(this.executeRaw(data, params));
|
|
117
129
|
}
|
|
118
130
|
|
|
119
131
|
/**
|
|
@@ -122,8 +134,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
122
134
|
* @public
|
|
123
135
|
* @async
|
|
124
136
|
* @param {Hex} data
|
|
125
|
-
* @param {?WriteParams
|
|
126
|
-
* @returns {
|
|
137
|
+
* @param {?WriteParams} [params]
|
|
138
|
+
* @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
|
|
127
139
|
*/
|
|
128
140
|
public override async executeRaw(
|
|
129
141
|
data: Hex,
|
|
@@ -149,14 +161,14 @@ export class ERC721MintAction extends ContractAction<
|
|
|
149
161
|
* @public
|
|
150
162
|
* @async
|
|
151
163
|
* @param {Hex} data
|
|
152
|
-
* @param {?ReadParams
|
|
153
|
-
* @returns {
|
|
164
|
+
* @param {?ReadParams} [params]
|
|
165
|
+
* @returns {Promise<`0x${string}`>}
|
|
154
166
|
*/
|
|
155
167
|
public override async prepare(
|
|
156
168
|
data: Hex,
|
|
157
169
|
params?: ReadParams<typeof erc721MintActionAbi, 'prepare'>,
|
|
158
170
|
) {
|
|
159
|
-
return readErc721MintActionPrepare(this._config, {
|
|
171
|
+
return await readErc721MintActionPrepare(this._config, {
|
|
160
172
|
address: this.assertValidAddress(),
|
|
161
173
|
args: [data],
|
|
162
174
|
...this.optionallyAttachAccount(),
|
|
@@ -166,34 +178,34 @@ export class ERC721MintAction extends ContractAction<
|
|
|
166
178
|
}
|
|
167
179
|
|
|
168
180
|
/**
|
|
169
|
-
* Validate that the action has been completed successfully
|
|
181
|
+
* Validate that the action has been completed successfully. This API is protected to prevent accidental signature burning.
|
|
170
182
|
*
|
|
171
|
-
* @
|
|
183
|
+
* @protected
|
|
172
184
|
* @async
|
|
173
185
|
* @param {Address} holder - The holder
|
|
174
186
|
* @param {BigInt} tokenId - The token ID
|
|
175
|
-
* @param {?WriteParams
|
|
176
|
-
* @returns {Promise<
|
|
187
|
+
* @param {?WriteParams} [params]
|
|
188
|
+
* @returns {Promise<boolean>} - True if the action has been validated for the user
|
|
177
189
|
*/
|
|
178
|
-
|
|
190
|
+
protected async validate(
|
|
179
191
|
holder: Address,
|
|
180
192
|
tokenId: bigint,
|
|
181
193
|
params?: WriteParams<typeof erc721MintActionAbi, 'validate'>,
|
|
182
194
|
) {
|
|
183
|
-
return this.awaitResult(this.validateRaw(holder, tokenId, params));
|
|
195
|
+
return await this.awaitResult(this.validateRaw(holder, tokenId, params));
|
|
184
196
|
}
|
|
185
197
|
|
|
186
198
|
/**
|
|
187
199
|
* Validate that the action has been completed successfully
|
|
188
200
|
*
|
|
189
|
-
* @
|
|
201
|
+
* @protected
|
|
190
202
|
* @async
|
|
191
203
|
* @param {Address} holder - The holder
|
|
192
204
|
* @param {BigInt} tokenId - The token ID
|
|
193
|
-
* @param {?WriteParams
|
|
205
|
+
* @param {?WriteParams} [params]
|
|
194
206
|
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the action has been validated for the user
|
|
195
207
|
*/
|
|
196
|
-
|
|
208
|
+
protected async validateRaw(
|
|
197
209
|
holder: Address,
|
|
198
210
|
tokenId: bigint,
|
|
199
211
|
params?: WriteParams<typeof erc721MintActionAbi, 'validate'>,
|
|
@@ -236,3 +248,44 @@ export class ERC721MintAction extends ContractAction<
|
|
|
236
248
|
};
|
|
237
249
|
}
|
|
238
250
|
}
|
|
251
|
+
|
|
252
|
+
/**
|
|
253
|
+
* Encodes a payload to validate that an action has been completed successfully.
|
|
254
|
+
*
|
|
255
|
+
*
|
|
256
|
+
* @export
|
|
257
|
+
* @param {Address} holder - The holder address
|
|
258
|
+
* @param {bigint} payload - The token ID
|
|
259
|
+
* @returns {Hex} - The first 20 bytes of the payload will be the holder address and the remaining bytes must be an encoded token ID (uint256)
|
|
260
|
+
*/
|
|
261
|
+
export function prepareERC721MintActionValidate(
|
|
262
|
+
holder: Address,
|
|
263
|
+
payload: bigint,
|
|
264
|
+
) {
|
|
265
|
+
return encodeAbiParameters(
|
|
266
|
+
[
|
|
267
|
+
{ type: 'address', name: 'holder' },
|
|
268
|
+
{ type: 'bytes', name: 'payload' },
|
|
269
|
+
],
|
|
270
|
+
[holder, toHex(payload)],
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Given a {@link ContractActionPayload}, properly encode a `ContractAction.InitPayload` for use with {@link ERC721MintAction} initialization.
|
|
276
|
+
*
|
|
277
|
+
* @param {ContractActionPayload} param0
|
|
278
|
+
* @param {bigint} param0.chainId - The chain ID on which the target exists
|
|
279
|
+
* @param {Address} param0.target - The target contract address
|
|
280
|
+
* @param {Hex} param0.selector - The selector for the function to be called
|
|
281
|
+
* @param {bigint} param0.value - The native token value to send with the function call
|
|
282
|
+
* @returns {Hex}
|
|
283
|
+
*/
|
|
284
|
+
export function prepareERC721MintActionPayload({
|
|
285
|
+
chainId,
|
|
286
|
+
target,
|
|
287
|
+
selector,
|
|
288
|
+
value,
|
|
289
|
+
}: ContractActionPayload) {
|
|
290
|
+
return prepareContractActionPayload({ chainId, target, selector, value });
|
|
291
|
+
}
|