@boostxyz/sdk 0.0.0-alpha.9 → 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 +11 -11
- package/dist/Actions/ContractAction.d.ts.map +1 -1
- package/dist/Actions/ERC721MintAction.d.ts +14 -14
- 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 +171 -41
- package/dist/Actions/EventAction.d.ts.map +1 -1
- package/dist/Actions/EventAction.js +15 -392
- 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 +92 -37
- package/dist/AllowLists/SimpleAllowList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleAllowList.js +55 -71
- 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 +203 -11
- package/dist/AllowLists/SimpleDenyList.d.ts.map +1 -1
- package/dist/AllowLists/SimpleDenyList.js +11 -112
- package/dist/AllowLists/SimpleDenyList.js.map +1 -1
- package/dist/Auth/PassthroughAuth.cjs +1 -1
- package/dist/Auth/PassthroughAuth.js +1 -1
- package/dist/Boost.cjs +1 -1
- package/dist/Boost.cjs.map +1 -1
- package/dist/Boost.d.ts +20 -21
- package/dist/Boost.d.ts.map +1 -1
- package/dist/Boost.js +43 -57
- 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 +748 -77
- package/dist/BoostCore.d.ts.map +1 -1
- package/dist/BoostCore.js +29 -1150
- 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 +80 -25
- package/dist/BoostRegistry.d.ts.map +1 -1
- package/dist/BoostRegistry.js +165 -83
- 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 +75 -193
- package/dist/Budgets/ManagedBudget.d.ts.map +1 -1
- package/dist/Budgets/ManagedBudget.js +80 -298
- package/dist/Budgets/ManagedBudget.js.map +1 -1
- package/dist/Budgets/VestingBudget.d.ts +223 -89
- 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 +5 -7
- 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 +28 -25
- 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 +38 -16
- package/dist/Incentives/AllowListIncentive.d.ts.map +1 -1
- package/dist/Incentives/AllowListIncentive.js +42 -29
- 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 +234 -21
- package/dist/Incentives/CGDAIncentive.d.ts.map +1 -1
- package/dist/Incentives/CGDAIncentive.js +45 -32
- package/dist/Incentives/CGDAIncentive.js.map +1 -1
- package/dist/Incentives/ERC1155Incentive.d.ts +224 -37
- 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 +230 -29
- package/dist/Incentives/ERC20Incentive.d.ts.map +1 -1
- package/dist/Incentives/ERC20Incentive.js +56 -43
- package/dist/Incentives/ERC20Incentive.js.map +1 -1
- package/dist/{Budgets/SimpleBudget.d.ts → Incentives/ERC20VariableCriteriaIncentive.d.ts} +335 -440
- package/dist/Incentives/ERC20VariableCriteriaIncentive.d.ts.map +1 -0
- package/dist/Incentives/ERC20VariableIncentive.d.ts +231 -29
- 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 -296
- 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 +40 -18
- package/dist/Incentives/PointsIncentive.d.ts.map +1 -1
- package/dist/Incentives/PointsIncentive.js +37 -24
- 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 +16 -16
- package/dist/Validators/SignerValidator.d.ts.map +1 -1
- package/dist/Validators/SignerValidator.js +30 -27
- 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.map +1 -1
- package/dist/claiming.d.ts +1 -1
- package/dist/claiming.js.map +1 -1
- 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 +256 -20
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +183 -26
- package/dist/errors.js.map +1 -1
- package/dist/{generated-57_Kffpz.js → generated-CKt2yCQd.js} +3613 -1869
- 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 +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +142 -108
- package/dist/index.js.map +1 -1
- package/dist/transfers.cjs.map +1 -1
- package/dist/transfers.d.ts +1 -1
- package/dist/transfers.js.map +1 -1
- package/dist/utils.cjs +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.ts +26 -12
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js +38 -23
- package/dist/utils.js.map +1 -1
- package/package.json +20 -10
- package/src/Actions/Action.test.ts +14 -13
- package/src/Actions/ContractAction.test.ts +10 -10
- package/src/Actions/ContractAction.ts +11 -12
- package/src/Actions/ERC721MintAction.test.ts +6 -6
- package/src/Actions/ERC721MintAction.ts +14 -15
- package/src/Actions/EventAction.test.ts +729 -109
- package/src/Actions/EventAction.ts +542 -84
- 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 +39 -61
- package/src/AllowLists/SimpleDenyList.test.ts +4 -4
- package/src/AllowLists/SimpleDenyList.ts +40 -17
- package/src/Auth/PassthroughAuth.test.ts +1 -1
- package/src/Boost.ts +21 -24
- package/src/BoostCore.test.ts +323 -268
- package/src/BoostCore.ts +396 -219
- package/src/BoostRegistry.test.ts +53 -0
- package/src/BoostRegistry.ts +161 -40
- 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 +48 -310
- package/src/Budgets/VestingBudget.test.ts +7 -7
- package/src/Budgets/VestingBudget.ts +34 -106
- package/src/Deployable/Contract.ts +4 -5
- package/src/Deployable/Deployable.ts +1 -1
- package/src/Deployable/DeployableTarget.ts +30 -19
- package/src/Deployable/DeployableTargetWithRBAC.ts +323 -0
- package/src/Incentives/AllowListIncentive.test.ts +5 -5
- package/src/Incentives/AllowListIncentive.ts +29 -15
- package/src/Incentives/CGDAIncentive.test.ts +9 -6
- package/src/Incentives/CGDAIncentive.ts +38 -18
- package/src/Incentives/ERC1155Incentive.test.ts +3 -3
- package/src/Incentives/ERC1155Incentive.ts +28 -29
- package/src/Incentives/ERC20Incentive.test.ts +9 -6
- package/src/Incentives/ERC20Incentive.ts +46 -26
- package/src/Incentives/ERC20VariableCriteriaIncentive.test.ts +184 -0
- package/src/Incentives/ERC20VariableCriteriaIncentive.ts +324 -0
- package/src/Incentives/ERC20VariableIncentive.test.ts +8 -11
- package/src/Incentives/ERC20VariableIncentive.ts +49 -26
- package/src/Incentives/Incentive.test.ts +4 -1
- package/src/Incentives/Incentive.ts +7 -6
- package/src/Incentives/PointsIncentive.test.ts +24 -25
- package/src/Incentives/PointsIncentive.ts +31 -17
- package/src/Validators/SignerValidator.test.ts +6 -6
- package/src/Validators/SignerValidator.ts +19 -17
- package/src/Validators/Validator.test.ts +2 -2
- package/src/Validators/Validator.ts +1 -1
- package/src/claiming.ts +1 -1
- package/src/errors.ts +345 -21
- package/src/index.test.ts +118 -36
- package/src/index.ts +5 -0
- package/src/transfers.ts +1 -1
- package/src/utils.test.ts +2 -2
- package/src/utils.ts +61 -12
- 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-57_Kffpz.js.map +0 -1
- package/dist/generated-wKBNvm48.cjs +0 -3
- package/dist/generated-wKBNvm48.cjs.map +0 -1
- package/src/Budgets/SimpleBudget.test.ts +0 -152
- package/src/Budgets/SimpleBudget.ts +0 -564
package/dist/utils.js
CHANGED
|
@@ -1,30 +1,45 @@
|
|
|
1
|
-
import { waitForTransactionReceipt as
|
|
2
|
-
import { slice as
|
|
3
|
-
import { NoContractAddressUponReceiptError as
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { waitForTransactionReceipt as f, getAccount as A, getClient as u } from "@wagmi/core";
|
|
2
|
+
import { slice as e, isHex as w, keccak256 as i, toHex as m } from "viem";
|
|
3
|
+
import { NoContractAddressUponReceiptError as I, InvalidProtocolChainIdError as s } from "./errors.js";
|
|
4
|
+
var N = /* @__PURE__ */ ((o) => (o[o.ACTION = 0] = "ACTION", o[o.ALLOW_LIST = 1] = "ALLOW_LIST", o[o.BUDGET = 2] = "BUDGET", o[o.INCENTIVE = 3] = "INCENTIVE", o[o.VALIDATOR = 4] = "VALIDATOR", o))(N || {});
|
|
5
|
+
function L(o) {
|
|
6
|
+
return e(w(o) ? i(o) : i(m(o)), 0, 4);
|
|
6
7
|
}
|
|
7
|
-
async function
|
|
8
|
-
const
|
|
9
|
-
...
|
|
10
|
-
hash: await
|
|
8
|
+
async function l(o, c, n) {
|
|
9
|
+
const t = await f(o, {
|
|
10
|
+
...n,
|
|
11
|
+
hash: await c
|
|
11
12
|
});
|
|
12
|
-
if (!
|
|
13
|
-
throw new
|
|
14
|
-
return
|
|
13
|
+
if (!t.contractAddress)
|
|
14
|
+
throw new I(t);
|
|
15
|
+
return t.contractAddress;
|
|
15
16
|
}
|
|
16
|
-
async function
|
|
17
|
-
const { hash:
|
|
18
|
-
return await
|
|
19
|
-
...
|
|
20
|
-
hash:
|
|
21
|
-
}),
|
|
17
|
+
async function v(o, c, n) {
|
|
18
|
+
const { hash: t, result: a } = await c;
|
|
19
|
+
return await f(o, {
|
|
20
|
+
...n,
|
|
21
|
+
hash: t
|
|
22
|
+
}), a;
|
|
23
|
+
}
|
|
24
|
+
function O(o, c, n) {
|
|
25
|
+
let t;
|
|
26
|
+
const a = A(o);
|
|
27
|
+
if (n !== void 0 ? c[n] && (t = n) : a.chainId !== void 0 && c[a.chainId] && (t = a.chainId), t === void 0) {
|
|
28
|
+
const r = u(o);
|
|
29
|
+
r != null && r.chain.id && c[r == null ? void 0 : r.chain.id] && (t = r.chain.id);
|
|
30
|
+
}
|
|
31
|
+
if (t === void 0 && (t = 11155111), !c[t])
|
|
32
|
+
throw new s(
|
|
33
|
+
t,
|
|
34
|
+
Object.keys(c).map(Number)
|
|
35
|
+
);
|
|
36
|
+
return { chainId: t, address: c[t] };
|
|
22
37
|
}
|
|
23
|
-
var i = /* @__PURE__ */ ((t) => (t[t.ACTION = 0] = "ACTION", t[t.ALLOW_LIST = 1] = "ALLOW_LIST", t[t.BUDGET = 2] = "BUDGET", t[t.INCENTIVE = 3] = "INCENTIVE", t[t.VALIDATOR = 4] = "VALIDATOR", t))(i || {});
|
|
24
38
|
export {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
39
|
+
N as RegistryType,
|
|
40
|
+
O as assertValidAddressByChainId,
|
|
41
|
+
v as awaitResult,
|
|
42
|
+
L as bytes4,
|
|
43
|
+
l as getDeployedContractAddress
|
|
29
44
|
};
|
|
30
45
|
//# sourceMappingURL=utils.js.map
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import {\n type Config,\n type ReadContractParameters,\n type WatchContractEventParameters,\n type WriteContractParameters,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport { NoContractAddressUponReceiptError } from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n WriteContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n ReadContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {unknown}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n"],"names":["bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","RegistryType"],"mappings":";;;AA2HO,SAASA,EAAOC,GAAe;AACpC,SAAOC,EAAMC,EAAMF,CAAK,IAAIG,EAAUH,CAAK,IAAIG,EAAUC,EAAMJ,CAAK,CAAC,GAAG,GAAG,CAAC;AAC9E;AAasB,eAAAK,EACpBC,GACAC,GACAC,GACA;AACM,QAAAC,IAAU,MAAMC,EAA0BJ,GAAQ;AAAA,IACtD,GAAGE;AAAA,IACH,MAAM,MAAMD;AAAA,EAAA,CACb;AACD,MAAI,CAACE,EAAQ;AACL,UAAA,IAAIE,EAAkCF,CAAO;AACrD,SAAOA,EAAQ;AACjB;AAsBsB,eAAAG,EACpBN,GACAO,GACAL,GACiB;AACjB,QAAM,EAAE,MAAAD,GAAM,QAAAO,EAAO,IAAI,MAAMD;AAC/B,eAAMH,EAA0BJ,GAAQ;AAAA,IACtC,GAAGE;AAAA,IACH,MAAAD;AAAA,EAAA,CACD,GACMO;AACT;AAQY,IAAAC,sBAAAA,OACVA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,aAAa,CAAb,IAAA,cACAA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aALUA,IAAAA,KAAA,CAAA,CAAA;"}
|
|
1
|
+
{"version":3,"file":"utils.js","sources":["../src/utils.ts"],"sourcesContent":["import {\n type Config,\n type ReadContractParameters,\n type WatchContractEventParameters,\n type WriteContractParameters,\n getAccount,\n getClient,\n waitForTransactionReceipt,\n} from '@wagmi/core';\nimport type { ExtractAbiEvent } from 'abitype';\nimport type {\n Abi,\n AbiEvent,\n Address,\n ContractEventName,\n ContractFunctionName,\n GetLogsParameters,\n Hash,\n Hex,\n Log,\n WaitForTransactionReceiptParameters,\n} from 'viem';\nimport { isHex, keccak256, slice, toHex } from 'viem';\nimport {\n InvalidProtocolChainIdError,\n NoConnectedChainIdError,\n NoContractAddressUponReceiptError,\n} from './errors';\n\nexport type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;\n\n/**\n * Enum encapsulating all the different types of targets used in the Boost V2 Protocol.\n *\n * @export\n * @enum {number}\n */\nexport enum RegistryType {\n ACTION = 0,\n ALLOW_LIST = 1,\n BUDGET = 2,\n INCENTIVE = 3,\n VALIDATOR = 4,\n}\n\n/**\n * Helper type that encapsulates common writeContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (writeContract)[https://viem.sh/docs/contract/writeContract]\n *\n * @export\n * @typedef {WriteParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type WriteParams<\n abi extends Abi = Abi,\n functionName extends ContractFunctionName<abi> = ContractFunctionName<abi>,\n> = Partial<\n Omit<\n WriteContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common readContract parameters without fields like `abi`, `args`, `functionName`, `address` that are expected to be provided the SDK.\n * See (readContract)[https://viem.sh/docs/contract/readContract]\n *\n * @export\n * @typedef {ReadParams}\n * @template {Abi} abi\n * @template {ContractFunctionName<abi>} functionName\n */\nexport type ReadParams<\n abi extends Abi,\n functionName extends ContractFunctionName<abi>,\n> = Partial<\n Omit<\n ReadContractParameters<abi, functionName>,\n 'address' | 'args' | 'functionName' | 'abi'\n >\n>;\n\n/**\n * Helper type that encapsulates common `watchContractEvent` parameters without fields like `address`, and `abi` that are expected to be provided the SDK.\n * See (watchContractEvent)[https://wagmi.sh/core/api/actions/watchContractEvent]\n *\n * @export\n * @typedef {WatchParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi> | undefined} [eventName=undefined]\n */\nexport type WatchParams<\n abi extends Abi,\n eventName extends ContractEventName<abi> | undefined = undefined,\n> = Partial<\n Omit<WatchContractEventParameters<abi, eventName>, 'address' | 'abi'>\n>;\n\n/**\n * Helper type that encapsulates common `getLogs` parameters without fields like `address` that are expected to be provided the SDK.\n * See (getLogs)[https://viem.sh/docs/actions/public/getLogs#getlogs]\n *\n * @export\n * @typedef {GetLogsParams}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} event\n * @template {ExtractAbiEvent<abi, event>} [abiEvent=ExtractAbiEvent<abi, event>]\n * @template {| readonly AbiEvent[]\n * | readonly unknown[]\n * | undefined} [abiEvents=abiEvent extends AbiEvent ? [abiEvent] : undefined]\n */\nexport type GetLogsParams<\n abi extends Abi,\n event extends ContractEventName<abi>,\n abiEvent extends ExtractAbiEvent<abi, event> = ExtractAbiEvent<abi, event>,\n abiEvents extends\n | readonly AbiEvent[]\n | readonly unknown[]\n | undefined = abiEvent extends AbiEvent ? [abiEvent] : undefined,\n> = Partial<Omit<GetLogsParameters<abiEvent, abiEvents>, 'address'>> & {\n chainId?: number | undefined;\n};\n\n/**\n * A generic `viem.Log` event with typed `args` support via a given `Abi` and `ContractEventName`\n *\n * @export\n * @typedef {GenericLog}\n * @template {Abi} abi\n * @template {ContractEventName<abi>} [event=ContractEventName<abi>]\n */\nexport type GenericLog<\n abi extends Abi,\n event extends ContractEventName<abi> = ContractEventName<abi>,\n> = Log<bigint, number, false, ExtractAbiEvent<abi, event>, false>;\n\n/**\n * Helper utility to convert a string to a `bytes4` type\n *\n * @export\n * @param {string} input\n * @returns {Hex}\n */\nexport function bytes4(input: string) {\n return slice(isHex(input) ? keccak256(input) : keccak256(toHex(input)), 0, 4);\n}\n\n/**\n * Utility function to wait for a transaction receipt, and extract the contractAddress\n *\n * @export\n * @async\n * @param {WagmiConfig} config - [Wagmi Configuration](https://wagmi.sh/core/api/createConfig)\n * @param {Promise<Hash>} hash - A transaction hash promise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams] - @see {@link WaitForTransactionReceiptParameters}\n * @returns {Promise<Address>}\n * @throws {@link NoContractAddressUponReceiptError} if no `contractAddress` exists after the transaction has been received\n */\nexport async function getDeployedContractAddress(\n config: Config,\n hash: Promise<Hash>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n) {\n const receipt = await waitForTransactionReceipt(config, {\n ...waitParams,\n hash: await hash,\n });\n if (!receipt.contractAddress)\n throw new NoContractAddressUponReceiptError(receipt);\n return receipt.contractAddress;\n}\n\n/**\n * Utility type to encapsulate a transaction hash, and the simulated result prior to submitting the transaction.\n *\n * @export\n * @typedef {HashAndSimulatedResult}\n * @template [T=unknown]\n */\nexport type HashAndSimulatedResult<T = unknown> = { hash: Hash; result: T };\n\n/**\n * Helper function to wait for a transaction receipt given a hash promise.\n *\n * @export\n * @async\n * @template [Result=unknown]\n * @param {WagmiConfig} config\n * @param {Promise<HashAndSimulatedResult<Result>>} hashPromise\n * @param {?Omit<WaitForTransactionReceiptParameters, 'hash'>} [waitParams]\n * @returns {Promise<Result>}\n */\nexport async function awaitResult<Result = unknown>(\n config: Config,\n hashPromise: Promise<HashAndSimulatedResult<Result>>,\n waitParams?: Omit<WaitForTransactionReceiptParameters, 'hash'>,\n): Promise<Result> {\n const { hash, result } = await hashPromise;\n await waitForTransactionReceipt(config, {\n ...waitParams,\n hash,\n });\n return result;\n}\n\n/**\n * Given a wagmi config and a map of chain id's to addresses, determine an address/chainId combo that maps to the currently connected chain id, or throw a typed error.\n *\n * @export\n * @param {Config} config\n * @param {Record<string, Address>} addressByChainId\n * @param {number} desiredChainId\n * @returns {{ chainId: number, address: Address }}\n * @throws {@link InvalidProtocolChainIdError}\n */\nexport function assertValidAddressByChainId(\n config: Config,\n addressByChainId: Record<number, Address>,\n desiredChainId?: number,\n): { chainId: number; address: Address } {\n let chainId: number | undefined = undefined;\n const wagmiAccount = getAccount(config);\n // if manually providing a chain id for some contract operation, try to use it\n if (desiredChainId !== undefined) {\n if (addressByChainId[desiredChainId]) chainId = desiredChainId;\n } else if (wagmiAccount.chainId !== undefined) {\n // otherwise if we can get the current chain id off the connected account and it matches one of ours, use it\n if (addressByChainId[wagmiAccount.chainId]) chainId = wagmiAccount.chainId;\n }\n // chainId is still undefined, try to get chain id off viem client\n if (chainId === undefined) {\n const client = getClient(config);\n if (client?.chain.id && addressByChainId[client?.chain.id])\n chainId = client.chain.id;\n }\n // if chainId is STILL undefined, use our default addresses\n // TODO: update this when on prod network\n if (chainId === undefined) chainId = Number(__DEFAULT_CHAIN_ID__);\n if (!addressByChainId[chainId])\n throw new InvalidProtocolChainIdError(\n chainId,\n Object.keys(addressByChainId).map(Number),\n );\n // biome-ignore lint/style/noNonNullAssertion: this type should be narrowed by the above statement but isn't?\n return { chainId, address: addressByChainId[chainId]! };\n}\n"],"names":["RegistryType","bytes4","input","slice","isHex","keccak256","toHex","getDeployedContractAddress","config","hash","waitParams","receipt","waitForTransactionReceipt","NoContractAddressUponReceiptError","awaitResult","hashPromise","result","assertValidAddressByChainId","addressByChainId","desiredChainId","chainId","wagmiAccount","getAccount","client","getClient","InvalidProtocolChainIdError"],"mappings":";;;AAqCY,IAAAA,sBAAAA,OACVA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,aAAa,CAAb,IAAA,cACAA,EAAAA,EAAA,SAAS,CAAT,IAAA,UACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aACAA,EAAAA,EAAA,YAAY,CAAZ,IAAA,aALUA,IAAAA,KAAA,CAAA,CAAA;AA2GL,SAASC,EAAOC,GAAe;AACpC,SAAOC,EAAMC,EAAMF,CAAK,IAAIG,EAAUH,CAAK,IAAIG,EAAUC,EAAMJ,CAAK,CAAC,GAAG,GAAG,CAAC;AAC9E;AAasB,eAAAK,EACpBC,GACAC,GACAC,GACA;AACM,QAAAC,IAAU,MAAMC,EAA0BJ,GAAQ;AAAA,IACtD,GAAGE;AAAA,IACH,MAAM,MAAMD;AAAA,EAAA,CACb;AACD,MAAI,CAACE,EAAQ;AACL,UAAA,IAAIE,EAAkCF,CAAO;AACrD,SAAOA,EAAQ;AACjB;AAsBsB,eAAAG,EACpBN,GACAO,GACAL,GACiB;AACjB,QAAM,EAAE,MAAAD,GAAM,QAAAO,EAAO,IAAI,MAAMD;AAC/B,eAAMH,EAA0BJ,GAAQ;AAAA,IACtC,GAAGE;AAAA,IACH,MAAAD;AAAA,EAAA,CACD,GACMO;AACT;AAYgB,SAAAC,EACdT,GACAU,GACAC,GACuC;AACvC,MAAIC;AACE,QAAAC,IAAeC,EAAWd,CAAM;AAStC,MAPIW,MAAmB,SACjBD,EAAiBC,CAAc,MAAaC,IAAAD,KACvCE,EAAa,YAAY,UAE9BH,EAAiBG,EAAa,OAAO,UAAaA,EAAa,UAGjED,MAAY,QAAW;AACnB,UAAAG,IAASC,EAAUhB,CAAM;AAC/B,IAAIe,KAAA,QAAAA,EAAQ,MAAM,MAAML,EAAiBK,KAAA,gBAAAA,EAAQ,MAAM,EAAE,MACvDH,IAAUG,EAAO,MAAM;AAAA,EAC3B;AAII,MADAH,MAAY,WAAqBA,IAAO,WACxC,CAACF,EAAiBE,CAAO;AAC3B,UAAM,IAAIK;AAAA,MACRL;AAAA,MACA,OAAO,KAAKF,CAAgB,EAAE,IAAI,MAAM;AAAA,IAAA;AAG5C,SAAO,EAAE,SAAAE,GAAS,SAASF,EAAiBE,CAAO,EAAG;AACxD;"}
|
package/package.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@boostxyz/sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "1.1.0-alpha.22",
|
|
4
4
|
"license": "GPL-3.0-or-later",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
7
7
|
"dist",
|
|
8
8
|
"src"
|
|
9
9
|
],
|
|
10
|
-
"repository": "https://github.com/
|
|
10
|
+
"repository": "https://github.com/boostxyz/boost-protocol",
|
|
11
11
|
"author": "Boost Team<boost-team@boost.xyz>",
|
|
12
12
|
"access": "public",
|
|
13
13
|
"private": false,
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"node": "./dist/transfers.js",
|
|
55
55
|
"types": "./dist/transfers.d.ts"
|
|
56
56
|
},
|
|
57
|
+
"./deployments.json": "./dist/deployments.json",
|
|
57
58
|
"./Boost": {
|
|
58
59
|
"require": "./dist/Boost.cjs",
|
|
59
60
|
"import": "./dist/Boost.js",
|
|
@@ -96,6 +97,12 @@
|
|
|
96
97
|
"node": "./dist/Deployable/DeployableTarget.js",
|
|
97
98
|
"types": "./dist/Deployable/DeployableTarget.d.ts"
|
|
98
99
|
},
|
|
100
|
+
"./Deployable/DeployableTargetWithRBAC": {
|
|
101
|
+
"require": "./dist/Deployable/DeployableTargetWithRBAC.cjs",
|
|
102
|
+
"import": "./dist/Deployable/DeployableTargetWithRBAC.js",
|
|
103
|
+
"node": "./dist/Deployable/DeployableTargetWithRBAC.js",
|
|
104
|
+
"types": "./dist/Deployable/DeployableTargetWithRBAC.d.ts"
|
|
105
|
+
},
|
|
99
106
|
"./Deployable/Contract": {
|
|
100
107
|
"require": "./dist/Deployable/Contract.cjs",
|
|
101
108
|
"import": "./dist/Deployable/Contract.js",
|
|
@@ -188,26 +195,29 @@
|
|
|
188
195
|
}
|
|
189
196
|
},
|
|
190
197
|
"dependencies": {
|
|
191
|
-
"
|
|
198
|
+
"ts-pattern": "5.4.0",
|
|
199
|
+
"@boostxyz/signatures": "1.1.0-alpha.22"
|
|
192
200
|
},
|
|
193
201
|
"optionalDependencies": {
|
|
194
|
-
"@boostxyz/evm": "
|
|
202
|
+
"@boostxyz/evm": "1.1.0-alpha.22",
|
|
203
|
+
"@boostxyz/signatures": "1.1.0-alpha.22"
|
|
195
204
|
},
|
|
196
205
|
"peerDependencies": {
|
|
197
|
-
"@wagmi/core": "2",
|
|
198
|
-
"
|
|
199
|
-
"
|
|
206
|
+
"@wagmi/core": "2.x",
|
|
207
|
+
"abitype": "1",
|
|
208
|
+
"viem": "2.x"
|
|
200
209
|
},
|
|
201
210
|
"scripts": {
|
|
202
|
-
"build": "vite build && tsc
|
|
211
|
+
"build": "mkdir -p dist && vite build && tsc -p ./tsconfig.build.json --emitDeclarationOnly --declaration --declarationMap",
|
|
212
|
+
"typecheck": "tsc -p ./tsconfig.build.json --noEmit",
|
|
203
213
|
"lint:ci": "npx biome ci",
|
|
204
214
|
"lint": "npx biome check",
|
|
205
215
|
"bench": "vitest bench",
|
|
206
216
|
"bench:ci": "CI=true vitest bench",
|
|
207
217
|
"clean": "rm -rf dist",
|
|
208
|
-
"dev": "vite build --watch",
|
|
218
|
+
"dev": "mkdir -p dist && vite build --watch",
|
|
209
219
|
"test": "vitest dev",
|
|
210
220
|
"test:ci": "CI=true vitest --coverage",
|
|
211
|
-
"typedoc": "npx typedoc --sort required-first --sort visibility --sort kind"
|
|
221
|
+
"typedoc": "npx typedoc --tsconfig ./tsconfig.build.json --sort required-first --sort visibility --sort kind"
|
|
212
222
|
}
|
|
213
223
|
}
|
|
@@ -2,14 +2,14 @@ import { selectors } from '@boostxyz/signatures/events';
|
|
|
2
2
|
import { loadFixture } from '@nomicfoundation/hardhat-toolbox-viem/network-helpers';
|
|
3
3
|
import type { Hex } from 'viem';
|
|
4
4
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
5
|
-
import type { MockERC721 } from '
|
|
6
|
-
import { accounts } from '
|
|
5
|
+
import type { MockERC721 } from '@boostxyz/test/MockERC721';
|
|
6
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
7
7
|
import {
|
|
8
8
|
type Fixtures,
|
|
9
9
|
defaultOptions,
|
|
10
10
|
deployFixtures,
|
|
11
11
|
fundErc721,
|
|
12
|
-
} from '
|
|
12
|
+
} from '@boostxyz/test/helpers';
|
|
13
13
|
import { EventAction, actionFromAddress } from './Action';
|
|
14
14
|
import {
|
|
15
15
|
type EventActionPayloadSimple,
|
|
@@ -27,20 +27,24 @@ export function basicErc721TransferAction(
|
|
|
27
27
|
actionClaimant: {
|
|
28
28
|
chainid: 31337,
|
|
29
29
|
signatureType: SignatureType.EVENT,
|
|
30
|
-
signature: selectors[
|
|
31
|
-
|
|
30
|
+
signature: selectors[
|
|
31
|
+
'Transfer(address indexed,address indexed,uint256 indexed)'
|
|
32
|
+
] as Hex,
|
|
33
|
+
fieldIndex: 1,
|
|
32
34
|
targetContract: erc721.assertValidAddress(),
|
|
33
35
|
},
|
|
34
36
|
actionSteps: [
|
|
35
37
|
{
|
|
36
38
|
chainid: 31337,
|
|
37
|
-
signature: selectors[
|
|
39
|
+
signature: selectors[
|
|
40
|
+
'Transfer(address indexed,address indexed,uint256 indexed)'
|
|
41
|
+
] as Hex,
|
|
38
42
|
signatureType: SignatureType.EVENT,
|
|
39
43
|
targetContract: erc721.assertValidAddress(),
|
|
40
44
|
actionParameter: {
|
|
41
45
|
filterType: FilterType.EQUAL,
|
|
42
46
|
fieldType: PrimitiveType.ADDRESS,
|
|
43
|
-
fieldIndex:
|
|
47
|
+
fieldIndex: 1,
|
|
44
48
|
filterData: accounts[1].account,
|
|
45
49
|
},
|
|
46
50
|
},
|
|
@@ -50,18 +54,15 @@ export function basicErc721TransferAction(
|
|
|
50
54
|
|
|
51
55
|
export function cloneEventAction(fixtures: Fixtures, erc721: MockERC721) {
|
|
52
56
|
return function cloneEventAction() {
|
|
53
|
-
return fixtures.registry.
|
|
57
|
+
return fixtures.registry.initialize(
|
|
54
58
|
crypto.randomUUID(),
|
|
55
|
-
|
|
56
|
-
defaultOptions,
|
|
57
|
-
basicErc721TransferAction(erc721),
|
|
58
|
-
),
|
|
59
|
+
fixtures.core.EventAction(basicErc721TransferAction(erc721)),
|
|
59
60
|
);
|
|
60
61
|
};
|
|
61
62
|
}
|
|
62
63
|
|
|
63
64
|
beforeAll(async () => {
|
|
64
|
-
fixtures = await loadFixture(deployFixtures);
|
|
65
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
65
66
|
});
|
|
66
67
|
|
|
67
68
|
describe('Action', () => {
|
|
@@ -10,20 +10,20 @@ import {
|
|
|
10
10
|
zeroAddress,
|
|
11
11
|
} from 'viem';
|
|
12
12
|
import { beforeAll, beforeEach, describe, expect, test } from 'vitest';
|
|
13
|
-
import type { MockERC20 } from '
|
|
14
|
-
import { accounts } from '
|
|
13
|
+
import type { MockERC20 } from '@boostxyz/test/MockERC20';
|
|
14
|
+
import { accounts } from '@boostxyz/test/accounts';
|
|
15
15
|
import {
|
|
16
16
|
type Fixtures,
|
|
17
17
|
defaultOptions,
|
|
18
18
|
deployFixtures,
|
|
19
19
|
fundErc20,
|
|
20
|
-
} from '
|
|
20
|
+
} from '@boostxyz/test/helpers';
|
|
21
21
|
import { ContractAction } from './ContractAction';
|
|
22
22
|
|
|
23
23
|
let fixtures: Fixtures, erc20: MockERC20;
|
|
24
24
|
|
|
25
25
|
beforeAll(async () => {
|
|
26
|
-
fixtures = await loadFixture(deployFixtures);
|
|
26
|
+
fixtures = await loadFixture(deployFixtures(defaultOptions));
|
|
27
27
|
});
|
|
28
28
|
|
|
29
29
|
const mintPayableSelector = toFunctionSelector(
|
|
@@ -36,9 +36,9 @@ const mintSelector = toFunctionSelector(
|
|
|
36
36
|
|
|
37
37
|
function payableContractAction(fixtures: Fixtures, erc20: MockERC20) {
|
|
38
38
|
return function payableContractAction() {
|
|
39
|
-
return fixtures.registry.
|
|
39
|
+
return fixtures.registry.initialize(
|
|
40
40
|
crypto.randomUUID(),
|
|
41
|
-
|
|
41
|
+
fixtures.core.ContractAction({
|
|
42
42
|
chainId: BigInt(31_337),
|
|
43
43
|
target: erc20.assertValidAddress(),
|
|
44
44
|
selector: mintPayableSelector,
|
|
@@ -50,9 +50,9 @@ function payableContractAction(fixtures: Fixtures, erc20: MockERC20) {
|
|
|
50
50
|
|
|
51
51
|
function nonPayableAction(fixtures: Fixtures, erc20: MockERC20) {
|
|
52
52
|
return function nonPayableAction() {
|
|
53
|
-
return fixtures.registry.
|
|
53
|
+
return fixtures.registry.initialize(
|
|
54
54
|
crypto.randomUUID(),
|
|
55
|
-
|
|
55
|
+
fixtures.core.ContractAction({
|
|
56
56
|
chainId: BigInt(31_337),
|
|
57
57
|
target: erc20.assertValidAddress(),
|
|
58
58
|
selector: mintSelector,
|
|
@@ -64,9 +64,9 @@ function nonPayableAction(fixtures: Fixtures, erc20: MockERC20) {
|
|
|
64
64
|
|
|
65
65
|
function otherAction(fixtures: Fixtures, erc20: MockERC20) {
|
|
66
66
|
return function nonPayableAction() {
|
|
67
|
-
return fixtures.registry.
|
|
67
|
+
return fixtures.registry.initialize(
|
|
68
68
|
crypto.randomUUID(),
|
|
69
|
-
|
|
69
|
+
fixtures.core.ContractAction({
|
|
70
70
|
chainId: BigInt(31_337) + 1n,
|
|
71
71
|
target: erc20.assertValidAddress(),
|
|
72
72
|
selector: mintSelector,
|
|
@@ -99,10 +99,9 @@ export class ContractAction<
|
|
|
99
99
|
*
|
|
100
100
|
* @public
|
|
101
101
|
* @static
|
|
102
|
-
* @type {Address}
|
|
102
|
+
* @type {Record<number, Address>}
|
|
103
103
|
*/
|
|
104
|
-
public static override
|
|
105
|
-
.VITE_CONTRACT_ACTION_BASE;
|
|
104
|
+
public static override bases: Record<number, Address> = {};
|
|
106
105
|
/**
|
|
107
106
|
* @inheritdoc
|
|
108
107
|
*
|
|
@@ -117,7 +116,7 @@ export class ContractAction<
|
|
|
117
116
|
*
|
|
118
117
|
* @public
|
|
119
118
|
* @async
|
|
120
|
-
* @param {?ReadParams
|
|
119
|
+
* @param {?ReadParams} [params]
|
|
121
120
|
* @returns {Promise<bigint>}
|
|
122
121
|
*/
|
|
123
122
|
public async chainId(
|
|
@@ -136,7 +135,7 @@ export class ContractAction<
|
|
|
136
135
|
*
|
|
137
136
|
* @public
|
|
138
137
|
* @async
|
|
139
|
-
* @param {?ReadParams
|
|
138
|
+
* @param {?ReadParams} [params]
|
|
140
139
|
* @returns {Promise<`0x${string}`>}
|
|
141
140
|
*/
|
|
142
141
|
public async target(params?: ReadParams<typeof contractActionAbi, 'target'>) {
|
|
@@ -154,7 +153,7 @@ export class ContractAction<
|
|
|
154
153
|
* @example `function mint(address to, uint256 amount)`
|
|
155
154
|
* @public
|
|
156
155
|
* @async
|
|
157
|
-
* @param {?ReadParams
|
|
156
|
+
* @param {?ReadParams} [params]
|
|
158
157
|
* @returns {Promise<`0x${string}`>}
|
|
159
158
|
*/
|
|
160
159
|
public async selector(
|
|
@@ -173,7 +172,7 @@ export class ContractAction<
|
|
|
173
172
|
*
|
|
174
173
|
* @public
|
|
175
174
|
* @async
|
|
176
|
-
* @param {?ReadParams
|
|
175
|
+
* @param {?ReadParams} [params]
|
|
177
176
|
* @returns {Promise<bigint>}
|
|
178
177
|
*/
|
|
179
178
|
public async value(params?: ReadParams<typeof contractActionAbi, 'value'>) {
|
|
@@ -191,7 +190,7 @@ export class ContractAction<
|
|
|
191
190
|
* @public
|
|
192
191
|
* @async
|
|
193
192
|
* @param {Hex} data
|
|
194
|
-
* @param {?WriteParams
|
|
193
|
+
* @param {?WriteParams} [params]
|
|
195
194
|
* @returns {Promise<readonly [boolean, `0x${string}`]>}
|
|
196
195
|
*/
|
|
197
196
|
public async execute(
|
|
@@ -207,8 +206,8 @@ export class ContractAction<
|
|
|
207
206
|
* @public
|
|
208
207
|
* @async
|
|
209
208
|
* @param {Hex} data
|
|
210
|
-
* @param {?WriteParams
|
|
211
|
-
* @returns {
|
|
209
|
+
* @param {?WriteParams} [params]
|
|
210
|
+
* @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
|
|
212
211
|
*/
|
|
213
212
|
public async executeRaw(
|
|
214
213
|
data: Hex,
|
|
@@ -234,8 +233,8 @@ export class ContractAction<
|
|
|
234
233
|
* @public
|
|
235
234
|
* @async
|
|
236
235
|
* @param {Hex} calldata
|
|
237
|
-
* @param {?ReadParams
|
|
238
|
-
* @returns {
|
|
236
|
+
* @param {?ReadParams} [params]
|
|
237
|
+
* @returns {Promise<`0x${string}`>}
|
|
239
238
|
*/
|
|
240
239
|
public async prepare(
|
|
241
240
|
calldata: Hex,
|
|
@@ -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,
|
|
@@ -77,10 +77,9 @@ export class ERC721MintAction extends ContractAction<
|
|
|
77
77
|
*
|
|
78
78
|
* @public
|
|
79
79
|
* @static
|
|
80
|
-
* @type {Address}
|
|
80
|
+
* @type {Record<number, Address>}
|
|
81
81
|
*/
|
|
82
|
-
public static override
|
|
83
|
-
.VITE_ERC721_MINT_ACTION_BASE;
|
|
82
|
+
public static override bases: Record<number, Address> = {};
|
|
84
83
|
/**
|
|
85
84
|
* @inheritdoc
|
|
86
85
|
*
|
|
@@ -97,8 +96,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
97
96
|
* @public
|
|
98
97
|
* @async
|
|
99
98
|
* @param {bigint} token
|
|
100
|
-
* @param {?ReadParams
|
|
101
|
-
* @returns {
|
|
99
|
+
* @param {?ReadParams} [params]
|
|
100
|
+
* @returns {Promise<boolean>}
|
|
102
101
|
*/
|
|
103
102
|
public async validated(
|
|
104
103
|
token: bigint,
|
|
@@ -119,8 +118,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
119
118
|
* @public
|
|
120
119
|
* @async
|
|
121
120
|
* @param {Hex} data
|
|
122
|
-
* @param {?WriteParams
|
|
123
|
-
* @returns {
|
|
121
|
+
* @param {?WriteParams} [params]
|
|
122
|
+
* @returns {Promise<readonly [boolean, `0x${string}`]>}
|
|
124
123
|
*/
|
|
125
124
|
public override async execute(
|
|
126
125
|
data: Hex,
|
|
@@ -135,8 +134,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
135
134
|
* @public
|
|
136
135
|
* @async
|
|
137
136
|
* @param {Hex} data
|
|
138
|
-
* @param {?WriteParams
|
|
139
|
-
* @returns {
|
|
137
|
+
* @param {?WriteParams} [params]
|
|
138
|
+
* @returns {Promise<{ hash: `0x${string}`; result: readonly [boolean, `0x${string}`]; }>}
|
|
140
139
|
*/
|
|
141
140
|
public override async executeRaw(
|
|
142
141
|
data: Hex,
|
|
@@ -162,8 +161,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
162
161
|
* @public
|
|
163
162
|
* @async
|
|
164
163
|
* @param {Hex} data
|
|
165
|
-
* @param {?ReadParams
|
|
166
|
-
* @returns {
|
|
164
|
+
* @param {?ReadParams} [params]
|
|
165
|
+
* @returns {Promise<`0x${string}`>}
|
|
167
166
|
*/
|
|
168
167
|
public override async prepare(
|
|
169
168
|
data: Hex,
|
|
@@ -185,8 +184,8 @@ export class ERC721MintAction extends ContractAction<
|
|
|
185
184
|
* @async
|
|
186
185
|
* @param {Address} holder - The holder
|
|
187
186
|
* @param {BigInt} tokenId - The token ID
|
|
188
|
-
* @param {?WriteParams
|
|
189
|
-
* @returns {Promise<
|
|
187
|
+
* @param {?WriteParams} [params]
|
|
188
|
+
* @returns {Promise<boolean>} - True if the action has been validated for the user
|
|
190
189
|
*/
|
|
191
190
|
protected async validate(
|
|
192
191
|
holder: Address,
|
|
@@ -203,7 +202,7 @@ export class ERC721MintAction extends ContractAction<
|
|
|
203
202
|
* @async
|
|
204
203
|
* @param {Address} holder - The holder
|
|
205
204
|
* @param {BigInt} tokenId - The token ID
|
|
206
|
-
* @param {?WriteParams
|
|
205
|
+
* @param {?WriteParams} [params]
|
|
207
206
|
* @returns {Promise<{ hash: `0x${string}`; result: boolean; }>} - True if the action has been validated for the user
|
|
208
207
|
*/
|
|
209
208
|
protected async validateRaw(
|
|
@@ -280,7 +279,7 @@ export function prepareERC721MintActionValidate(
|
|
|
280
279
|
* @param {Address} param0.target - The target contract address
|
|
281
280
|
* @param {Hex} param0.selector - The selector for the function to be called
|
|
282
281
|
* @param {bigint} param0.value - The native token value to send with the function call
|
|
283
|
-
* @returns {
|
|
282
|
+
* @returns {Hex}
|
|
284
283
|
*/
|
|
285
284
|
export function prepareERC721MintActionPayload({
|
|
286
285
|
chainId,
|