@morpho-org/morpho-sdk 6.6.0 → 7.1.0-next.1
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/MIGRATION-v6-to-v7.md +297 -0
- package/README.md +26 -12
- package/lib/cjs/abis.d.ts +2 -2
- package/lib/cjs/abis.js +7 -2
- package/lib/cjs/actions/bundles/common.d.ts +9 -5
- package/lib/cjs/actions/bundles/common.js +22 -13
- package/lib/cjs/actions/midnight/authorization.d.ts +3 -2
- package/lib/cjs/actions/midnight/authorization.js +3 -2
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/cjs/actions/midnight/cancelAndMake.js +292 -0
- package/lib/cjs/actions/midnight/index.d.ts +3 -3
- package/lib/cjs/actions/midnight/index.js +3 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +105 -69
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -71
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/cjs/actions/midnight/takeBorrow.js +95 -54
- package/lib/cjs/actions/midnight/takeLend.d.ts +51 -27
- package/lib/cjs/actions/midnight/takeLend.js +111 -54
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +201 -0
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/cjs/actions/midnight/takeWithdraw.js +153 -0
- package/lib/cjs/actions/midnight/types.d.ts +7 -26
- package/lib/cjs/actions/midnight/types.js +0 -13
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +24 -13
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/cjs/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/midnight/index.js +0 -1
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +5 -1
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +3 -1
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +5 -1
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +3 -1
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +2 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -1
- package/lib/cjs/entities/index.d.ts +6 -6
- package/lib/cjs/entities/index.js +3 -1
- package/lib/cjs/entities/midnight/midnight.d.ts +585 -108
- package/lib/cjs/entities/midnight/midnight.js +984 -509
- package/lib/cjs/entities/midnight/types.d.ts +142 -60
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +3 -2
- package/lib/cjs/entities/vaultV1/vaultV1.js +32 -34
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +37 -12
- package/lib/cjs/entities/vaultV2/vaultV2.js +68 -41
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +9 -3
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +10 -5
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +3 -1
- package/lib/cjs/helpers/callback.d.ts +54 -0
- package/lib/cjs/helpers/callback.js +73 -0
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/index.d.ts +3 -2
- package/lib/cjs/helpers/index.js +6 -1
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/cjs/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/cjs/helpers/validate.d.ts +43 -2
- package/lib/cjs/helpers/validate.js +60 -3
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/cjs/helpers/validateRequirementSpender.js +4 -5
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -2
- package/lib/cjs/midnight/errors.d.ts +2 -1
- package/lib/cjs/midnight/errors.js +5 -4
- package/lib/cjs/midnight/types.d.ts +1 -1
- package/lib/cjs/types/action.d.ts +219 -90
- package/lib/cjs/types/action.js +103 -20
- package/lib/cjs/types/error.d.ts +126 -40
- package/lib/cjs/types/error.js +154 -49
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +4 -2
- package/lib/esm/abis.d.ts +2 -2
- package/lib/esm/abis.js +2 -2
- package/lib/esm/actions/bundles/common.d.ts +9 -5
- package/lib/esm/actions/bundles/common.js +22 -13
- package/lib/esm/actions/midnight/authorization.d.ts +3 -2
- package/lib/esm/actions/midnight/authorization.js +3 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/esm/actions/midnight/cancelAndMake.js +288 -0
- package/lib/esm/actions/midnight/index.d.ts +3 -3
- package/lib/esm/actions/midnight/index.js +3 -3
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +108 -72
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +131 -74
- package/lib/esm/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/esm/actions/midnight/takeBorrow.js +98 -57
- package/lib/esm/actions/midnight/takeLend.d.ts +51 -27
- package/lib/esm/actions/midnight/takeLend.js +114 -57
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +197 -0
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/esm/actions/midnight/takeWithdraw.js +149 -0
- package/lib/esm/actions/midnight/types.d.ts +7 -26
- package/lib/esm/actions/midnight/types.js +1 -12
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +25 -14
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/esm/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/esm/actions/requirements/midnight/index.js +0 -1
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/index.d.ts +6 -6
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +585 -108
- package/lib/esm/entities/midnight/midnight.js +990 -515
- package/lib/esm/entities/midnight/types.d.ts +142 -60
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +3 -2
- package/lib/esm/entities/vaultV1/vaultV1.js +33 -35
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +37 -12
- package/lib/esm/entities/vaultV2/vaultV2.js +69 -42
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +5 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +9 -3
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/callback.d.ts +54 -0
- package/lib/esm/helpers/callback.js +68 -0
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/index.d.ts +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/esm/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/esm/helpers/validate.d.ts +43 -2
- package/lib/esm/helpers/validate.js +58 -2
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/esm/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/esm/helpers/validateRequirementSpender.js +4 -5
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/errors.d.ts +2 -1
- package/lib/esm/midnight/errors.js +2 -1
- package/lib/esm/midnight/types.d.ts +1 -1
- package/lib/esm/types/action.d.ts +219 -90
- package/lib/esm/types/action.js +103 -19
- package/lib/esm/types/error.d.ts +126 -40
- package/lib/esm/types/error.js +135 -38
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +10 -10
- package/lib/cjs/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/cjs/actions/midnight/cancelOffer.js +0 -73
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +0 -72
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +0 -59
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -70
- package/lib/esm/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/esm/actions/midnight/cancelOffer.js +0 -69
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +0 -68
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +0 -55
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -66
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setterRatifierRatifyRoot = void 0;
|
|
4
|
-
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
-
/**
|
|
9
|
-
* Encodes a SetterRatifier root-ratification transaction.
|
|
10
|
-
*
|
|
11
|
-
* Use this after building a Setter-ratified offer tree and before submitting
|
|
12
|
-
* its mempool payload. Entity make-offer flows expose the same transaction
|
|
13
|
-
* through `getRequirements()` when the root is not already approved.
|
|
14
|
-
*
|
|
15
|
-
* @param params.chainId - Chain id used to resolve `SetterRatifier`.
|
|
16
|
-
* @param params.maker - Maker whose root approval is updated.
|
|
17
|
-
* @param params.root - Offer-tree root to approve or revoke.
|
|
18
|
-
* @param params.isRootRatified - Optional target state; defaults to `true`.
|
|
19
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
20
|
-
* @returns A deep-frozen `Transaction<SetterRatifierRatifyRootAction>` targeting `SetterRatifier`.
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { setterRatifierRatifyRoot } from "@morpho-org/morpho-sdk";
|
|
24
|
-
*
|
|
25
|
-
* const tx = setterRatifierRatifyRoot({
|
|
26
|
-
* chainId: 8453,
|
|
27
|
-
* maker,
|
|
28
|
-
* root,
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
const setterRatifierRatifyRoot = (params) => {
|
|
33
|
-
const isRootRatified = params.isRootRatified ?? true;
|
|
34
|
-
const setterRatifier = (0, morpho_ts_1.getChainAddress)(params.chainId, "setterRatifier");
|
|
35
|
-
let tx = {
|
|
36
|
-
to: setterRatifier,
|
|
37
|
-
value: 0n,
|
|
38
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
39
|
-
abi: midnight_sdk_1.setterRatifierAbi,
|
|
40
|
-
functionName: "setIsRootRatified",
|
|
41
|
-
args: [params.maker, params.root, isRootRatified],
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
44
|
-
if (params.metadata) {
|
|
45
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
46
|
-
}
|
|
47
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
48
|
-
...tx,
|
|
49
|
-
action: {
|
|
50
|
-
type: "setterRatifierRatifyRoot",
|
|
51
|
-
args: {
|
|
52
|
-
maker: params.maker,
|
|
53
|
-
root: params.root,
|
|
54
|
-
isRootRatified,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
exports.setterRatifierRatifyRoot = setterRatifierRatifyRoot;
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
-
import type { SetterRatifierRatifyRootAction, Transaction } from "../../../types/index.js";
|
|
3
|
-
/** Parameters for {@link getSetterRatifierRatifyRootRequirement}. */
|
|
4
|
-
export interface GetSetterRatifierRatifyRootRequirementParams {
|
|
5
|
-
readonly viemClient: Client;
|
|
6
|
-
readonly chainId: number;
|
|
7
|
-
readonly maker: Address;
|
|
8
|
-
readonly root: Hex;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Resolves the SetterRatifier root approval transaction for a maker offer tree.
|
|
12
|
-
*
|
|
13
|
-
* Call after building a Setter-ratified tree and before encoding/submitting its
|
|
14
|
-
* payload. Entity make-offer flows call this from `getRequirements()` and omit
|
|
15
|
-
* the transaction when the maker has already approved the root.
|
|
16
|
-
*
|
|
17
|
-
* @param params.viemClient - Viem client used to read root approval state.
|
|
18
|
-
* @param params.chainId - Chain id expected by the viem client.
|
|
19
|
-
* @param params.maker - Maker whose root approval is checked.
|
|
20
|
-
* @param params.root - Offer-tree root that must be approved.
|
|
21
|
-
* @returns Ratify-root transaction, or `null` when the root is already ratified.
|
|
22
|
-
* @throws {ChainIdMismatchError} when the viem client is connected to another chain.
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { getSetterRatifierRatifyRootRequirement } from "@morpho-org/morpho-sdk";
|
|
26
|
-
*
|
|
27
|
-
* const tx = await getSetterRatifierRatifyRootRequirement({
|
|
28
|
-
* viemClient: client,
|
|
29
|
-
* chainId: 8453,
|
|
30
|
-
* maker: user,
|
|
31
|
-
* root,
|
|
32
|
-
* });
|
|
33
|
-
* if (tx) {
|
|
34
|
-
* await walletClient.sendTransaction({
|
|
35
|
-
* to: tx.to,
|
|
36
|
-
* data: tx.data,
|
|
37
|
-
* value: tx.value,
|
|
38
|
-
* });
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare const getSetterRatifierRatifyRootRequirement: (params: GetSetterRatifierRatifyRootRequirementParams) => Promise<Readonly<Transaction<SetterRatifierRatifyRootAction>> | null>;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getSetterRatifierRatifyRootRequirement = void 0;
|
|
4
|
-
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
const actions_1 = require("viem/actions");
|
|
8
|
-
const index_js_1 = require("../../../helpers/index.js");
|
|
9
|
-
/**
|
|
10
|
-
* Resolves the SetterRatifier root approval transaction for a maker offer tree.
|
|
11
|
-
*
|
|
12
|
-
* Call after building a Setter-ratified tree and before encoding/submitting its
|
|
13
|
-
* payload. Entity make-offer flows call this from `getRequirements()` and omit
|
|
14
|
-
* the transaction when the maker has already approved the root.
|
|
15
|
-
*
|
|
16
|
-
* @param params.viemClient - Viem client used to read root approval state.
|
|
17
|
-
* @param params.chainId - Chain id expected by the viem client.
|
|
18
|
-
* @param params.maker - Maker whose root approval is checked.
|
|
19
|
-
* @param params.root - Offer-tree root that must be approved.
|
|
20
|
-
* @returns Ratify-root transaction, or `null` when the root is already ratified.
|
|
21
|
-
* @throws {ChainIdMismatchError} when the viem client is connected to another chain.
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { getSetterRatifierRatifyRootRequirement } from "@morpho-org/morpho-sdk";
|
|
25
|
-
*
|
|
26
|
-
* const tx = await getSetterRatifierRatifyRootRequirement({
|
|
27
|
-
* viemClient: client,
|
|
28
|
-
* chainId: 8453,
|
|
29
|
-
* maker: user,
|
|
30
|
-
* root,
|
|
31
|
-
* });
|
|
32
|
-
* if (tx) {
|
|
33
|
-
* await walletClient.sendTransaction({
|
|
34
|
-
* to: tx.to,
|
|
35
|
-
* data: tx.data,
|
|
36
|
-
* value: tx.value,
|
|
37
|
-
* });
|
|
38
|
-
* }
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
const getSetterRatifierRatifyRootRequirement = async (params) => {
|
|
42
|
-
(0, index_js_1.validateChainId)(params.viemClient.chain?.id, params.chainId);
|
|
43
|
-
const setterRatifier = (0, morpho_ts_1.getChainAddress)(params.chainId, "setterRatifier");
|
|
44
|
-
const isRootRatified = await (0, actions_1.readContract)(params.viemClient, {
|
|
45
|
-
address: setterRatifier,
|
|
46
|
-
abi: midnight_sdk_1.setterRatifierAbi,
|
|
47
|
-
functionName: "isRootRatified",
|
|
48
|
-
args: [params.maker, params.root],
|
|
49
|
-
});
|
|
50
|
-
if (isRootRatified)
|
|
51
|
-
return null;
|
|
52
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
53
|
-
to: setterRatifier,
|
|
54
|
-
value: 0n,
|
|
55
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
56
|
-
abi: midnight_sdk_1.setterRatifierAbi,
|
|
57
|
-
functionName: "setIsRootRatified",
|
|
58
|
-
args: [params.maker, params.root, true],
|
|
59
|
-
}),
|
|
60
|
-
action: {
|
|
61
|
-
type: "setterRatifierRatifyRoot",
|
|
62
|
-
args: {
|
|
63
|
-
maker: params.maker,
|
|
64
|
-
root: params.root,
|
|
65
|
-
isRootRatified: true,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
exports.getSetterRatifierRatifyRootRequirement = getSetterRatifierRatifyRootRequirement;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from "viem";
|
|
2
|
-
import type { Metadata, MidnightCancelOfferAction, Transaction } from "../../types/index.js";
|
|
3
|
-
/** Parameters for encoding a Midnight group consumption update. */
|
|
4
|
-
export interface MidnightCancelOfferParams {
|
|
5
|
-
readonly chainId: number;
|
|
6
|
-
readonly group: Hex;
|
|
7
|
-
readonly onBehalf: Address;
|
|
8
|
-
readonly amount?: bigint;
|
|
9
|
-
readonly metadata?: Metadata;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Encodes `Midnight.setConsumed` to cancel or partially consume an offer group.
|
|
13
|
-
*
|
|
14
|
-
* App flows should usually call `client.morpho.midnight(chainId).cancelOffer(...)`.
|
|
15
|
-
* Use this builder directly when the group id is already known and no
|
|
16
|
-
* additional requirements are needed. Omitting `amount` fully cancels the group
|
|
17
|
-
* by setting consumption to {@link MAX_OFFER_CAP}.
|
|
18
|
-
*
|
|
19
|
-
* @param params.chainId - Chain id used to resolve `Midnight`.
|
|
20
|
-
* @param params.group - Offer group id to mark consumed.
|
|
21
|
-
* @param params.onBehalf - Maker whose group consumption is updated.
|
|
22
|
-
* @param params.amount - Optional consumed amount; defaults to {@link MAX_OFFER_CAP} for full cancellation.
|
|
23
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
24
|
-
* @returns A deep-frozen `Transaction<MidnightCancelOfferAction>` targeting `Midnight`.
|
|
25
|
-
* @throws {NegativeInputError} when `amount` is negative.
|
|
26
|
-
* @throws {MidnightAmountExceedsMaxOfferCapError} when `amount` exceeds {@link MAX_OFFER_CAP}.
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* import { midnightCancelOffer } from "@morpho-org/morpho-sdk";
|
|
30
|
-
*
|
|
31
|
-
* const tx = midnightCancelOffer({
|
|
32
|
-
* chainId: 8453,
|
|
33
|
-
* group,
|
|
34
|
-
* onBehalf: maker,
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare const midnightCancelOffer: (params: MidnightCancelOfferParams) => Readonly<Transaction<MidnightCancelOfferAction>>;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { MAX_OFFER_CAP, midnightAbi } from "@morpho-org/midnight-sdk";
|
|
2
|
-
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
|
-
import { encodeFunctionData } from "viem";
|
|
4
|
-
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
5
|
-
import { MidnightAmountExceedsMaxOfferCapError, NegativeInputError, } from "../../types/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Encodes `Midnight.setConsumed` to cancel or partially consume an offer group.
|
|
8
|
-
*
|
|
9
|
-
* App flows should usually call `client.morpho.midnight(chainId).cancelOffer(...)`.
|
|
10
|
-
* Use this builder directly when the group id is already known and no
|
|
11
|
-
* additional requirements are needed. Omitting `amount` fully cancels the group
|
|
12
|
-
* by setting consumption to {@link MAX_OFFER_CAP}.
|
|
13
|
-
*
|
|
14
|
-
* @param params.chainId - Chain id used to resolve `Midnight`.
|
|
15
|
-
* @param params.group - Offer group id to mark consumed.
|
|
16
|
-
* @param params.onBehalf - Maker whose group consumption is updated.
|
|
17
|
-
* @param params.amount - Optional consumed amount; defaults to {@link MAX_OFFER_CAP} for full cancellation.
|
|
18
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
19
|
-
* @returns A deep-frozen `Transaction<MidnightCancelOfferAction>` targeting `Midnight`.
|
|
20
|
-
* @throws {NegativeInputError} when `amount` is negative.
|
|
21
|
-
* @throws {MidnightAmountExceedsMaxOfferCapError} when `amount` exceeds {@link MAX_OFFER_CAP}.
|
|
22
|
-
* @example
|
|
23
|
-
* ```ts
|
|
24
|
-
* import { midnightCancelOffer } from "@morpho-org/morpho-sdk";
|
|
25
|
-
*
|
|
26
|
-
* const tx = midnightCancelOffer({
|
|
27
|
-
* chainId: 8453,
|
|
28
|
-
* group,
|
|
29
|
-
* onBehalf: maker,
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export const midnightCancelOffer = (params) => {
|
|
34
|
-
const midnight = getChainAddress(params.chainId, "midnight");
|
|
35
|
-
const amount = params.amount ?? MAX_OFFER_CAP;
|
|
36
|
-
if (amount < 0n) {
|
|
37
|
-
throw new NegativeInputError("amount", amount);
|
|
38
|
-
}
|
|
39
|
-
if (amount > MAX_OFFER_CAP) {
|
|
40
|
-
throw new MidnightAmountExceedsMaxOfferCapError({
|
|
41
|
-
label: "cancel amount",
|
|
42
|
-
amount,
|
|
43
|
-
maxOfferCap: MAX_OFFER_CAP,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
let tx = {
|
|
47
|
-
to: midnight,
|
|
48
|
-
value: 0n,
|
|
49
|
-
data: encodeFunctionData({
|
|
50
|
-
abi: midnightAbi,
|
|
51
|
-
functionName: "setConsumed",
|
|
52
|
-
args: [params.group, amount, params.onBehalf],
|
|
53
|
-
}),
|
|
54
|
-
};
|
|
55
|
-
if (params.metadata) {
|
|
56
|
-
tx = addTransactionMetadata(tx, params.metadata);
|
|
57
|
-
}
|
|
58
|
-
return deepFreeze({
|
|
59
|
-
...tx,
|
|
60
|
-
action: {
|
|
61
|
-
type: "midnightCancelOffer",
|
|
62
|
-
args: {
|
|
63
|
-
group: params.group,
|
|
64
|
-
amount,
|
|
65
|
-
onBehalf: params.onBehalf,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
});
|
|
69
|
-
};
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
|
-
import type { MempoolSubmitOffersAction, Metadata, Transaction } from "../../types/index.js";
|
|
3
|
-
/** Parameters for publishing an already ratified Midnight offer payload. */
|
|
4
|
-
export interface MempoolSubmitOffersParams {
|
|
5
|
-
readonly chainId: number;
|
|
6
|
-
readonly groups: readonly Hex[];
|
|
7
|
-
readonly root: Hex;
|
|
8
|
-
readonly maker: Address;
|
|
9
|
-
readonly ratifier: Address;
|
|
10
|
-
readonly ratifierType: "ecrecover" | "setter";
|
|
11
|
-
readonly offers: number;
|
|
12
|
-
readonly payload: Hex;
|
|
13
|
-
readonly metadata?: Metadata;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Encodes a Midnight mempool payload submission transaction.
|
|
17
|
-
*
|
|
18
|
-
* App make-offer flows should call `getOffersData`, gather the returned
|
|
19
|
-
* requirements, then call the output `buildTx(signatures)`. Use this builder
|
|
20
|
-
* directly only when the payload has already been encoded with ratifier data
|
|
21
|
-
* and the caller wants to submit those bytes to the mempool contract.
|
|
22
|
-
*
|
|
23
|
-
* @param params.chainId - Chain id used to resolve `MidnightMempool`.
|
|
24
|
-
* @param params.groups - Group ids included in the payload.
|
|
25
|
-
* @param params.root - Offer tree root committed by the maker.
|
|
26
|
-
* @param params.maker - Maker whose offers are submitted.
|
|
27
|
-
* @param params.ratifier - Ratifier address shared by the offer tree.
|
|
28
|
-
* @param params.ratifierType - Ratifier route used to build the payload.
|
|
29
|
-
* @param params.offers - Number of non-padding offers in the payload.
|
|
30
|
-
* @param params.payload - Encoded mempool payload bytes.
|
|
31
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
32
|
-
* @returns A deep-frozen `Transaction<MempoolSubmitOffersAction>` targeting `MidnightMempool`.
|
|
33
|
-
* @throws {InvalidTreeError} when `offers <= 0`.
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { MidnightPayload } from "@morpho-org/morpho-sdk/utils";
|
|
37
|
-
* import { mempoolSubmitOffers } from "@morpho-org/morpho-sdk";
|
|
38
|
-
*
|
|
39
|
-
* const payload = await MidnightPayload.encode(items);
|
|
40
|
-
* const tx = mempoolSubmitOffers({
|
|
41
|
-
* chainId: 8453,
|
|
42
|
-
* groups,
|
|
43
|
-
* root: tree.root,
|
|
44
|
-
* maker,
|
|
45
|
-
* ratifier,
|
|
46
|
-
* ratifierType: "ecrecover",
|
|
47
|
-
* offers: tree.offers.length,
|
|
48
|
-
* payload,
|
|
49
|
-
* });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare const mempoolSubmitOffers: (params: MempoolSubmitOffersParams) => Readonly<Transaction<MempoolSubmitOffersAction>>;
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import { InvalidTreeError } from "@morpho-org/midnight-sdk";
|
|
2
|
-
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
|
-
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Encodes a Midnight mempool payload submission transaction.
|
|
6
|
-
*
|
|
7
|
-
* App make-offer flows should call `getOffersData`, gather the returned
|
|
8
|
-
* requirements, then call the output `buildTx(signatures)`. Use this builder
|
|
9
|
-
* directly only when the payload has already been encoded with ratifier data
|
|
10
|
-
* and the caller wants to submit those bytes to the mempool contract.
|
|
11
|
-
*
|
|
12
|
-
* @param params.chainId - Chain id used to resolve `MidnightMempool`.
|
|
13
|
-
* @param params.groups - Group ids included in the payload.
|
|
14
|
-
* @param params.root - Offer tree root committed by the maker.
|
|
15
|
-
* @param params.maker - Maker whose offers are submitted.
|
|
16
|
-
* @param params.ratifier - Ratifier address shared by the offer tree.
|
|
17
|
-
* @param params.ratifierType - Ratifier route used to build the payload.
|
|
18
|
-
* @param params.offers - Number of non-padding offers in the payload.
|
|
19
|
-
* @param params.payload - Encoded mempool payload bytes.
|
|
20
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
21
|
-
* @returns A deep-frozen `Transaction<MempoolSubmitOffersAction>` targeting `MidnightMempool`.
|
|
22
|
-
* @throws {InvalidTreeError} when `offers <= 0`.
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { MidnightPayload } from "@morpho-org/morpho-sdk/utils";
|
|
26
|
-
* import { mempoolSubmitOffers } from "@morpho-org/morpho-sdk";
|
|
27
|
-
*
|
|
28
|
-
* const payload = await MidnightPayload.encode(items);
|
|
29
|
-
* const tx = mempoolSubmitOffers({
|
|
30
|
-
* chainId: 8453,
|
|
31
|
-
* groups,
|
|
32
|
-
* root: tree.root,
|
|
33
|
-
* maker,
|
|
34
|
-
* ratifier,
|
|
35
|
-
* ratifierType: "ecrecover",
|
|
36
|
-
* offers: tree.offers.length,
|
|
37
|
-
* payload,
|
|
38
|
-
* });
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
export const mempoolSubmitOffers = (params) => {
|
|
42
|
-
if (params.offers <= 0) {
|
|
43
|
-
throw new InvalidTreeError("Tree must contain at least one offer.");
|
|
44
|
-
}
|
|
45
|
-
const midnightMempool = getChainAddress(params.chainId, "midnightMempool");
|
|
46
|
-
let tx = {
|
|
47
|
-
to: midnightMempool,
|
|
48
|
-
value: 0n,
|
|
49
|
-
data: params.payload,
|
|
50
|
-
};
|
|
51
|
-
if (params.metadata) {
|
|
52
|
-
tx = addTransactionMetadata(tx, params.metadata);
|
|
53
|
-
}
|
|
54
|
-
return deepFreeze({
|
|
55
|
-
...tx,
|
|
56
|
-
action: {
|
|
57
|
-
type: "mempoolSubmitOffers",
|
|
58
|
-
args: {
|
|
59
|
-
groups: [...params.groups],
|
|
60
|
-
root: params.root,
|
|
61
|
-
maker: params.maker,
|
|
62
|
-
ratifier: params.ratifier,
|
|
63
|
-
ratifierType: params.ratifierType,
|
|
64
|
-
offers: params.offers,
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
};
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from "viem";
|
|
2
|
-
import type { Metadata, SetterRatifierRatifyRootAction, Transaction } from "../../types/index.js";
|
|
3
|
-
/** Parameters for {@link setterRatifierRatifyRoot}. */
|
|
4
|
-
export interface SetterRatifierRatifyRootParams {
|
|
5
|
-
/** Chain id used to resolve the SetterRatifier deployment. */
|
|
6
|
-
readonly chainId: number;
|
|
7
|
-
/** Maker whose offer-tree root is being ratified. */
|
|
8
|
-
readonly maker: Address;
|
|
9
|
-
/** Offer-tree root to ratify or unratify. */
|
|
10
|
-
readonly root: Hex;
|
|
11
|
-
/** Whether the root should be ratified. Defaults to `true`. */
|
|
12
|
-
readonly isRootRatified?: boolean;
|
|
13
|
-
/** Optional metadata appended to the transaction calldata. */
|
|
14
|
-
readonly metadata?: Metadata;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Encodes a SetterRatifier root-ratification transaction.
|
|
18
|
-
*
|
|
19
|
-
* Use this after building a Setter-ratified offer tree and before submitting
|
|
20
|
-
* its mempool payload. Entity make-offer flows expose the same transaction
|
|
21
|
-
* through `getRequirements()` when the root is not already approved.
|
|
22
|
-
*
|
|
23
|
-
* @param params.chainId - Chain id used to resolve `SetterRatifier`.
|
|
24
|
-
* @param params.maker - Maker whose root approval is updated.
|
|
25
|
-
* @param params.root - Offer-tree root to approve or revoke.
|
|
26
|
-
* @param params.isRootRatified - Optional target state; defaults to `true`.
|
|
27
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
28
|
-
* @returns A deep-frozen `Transaction<SetterRatifierRatifyRootAction>` targeting `SetterRatifier`.
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* import { setterRatifierRatifyRoot } from "@morpho-org/morpho-sdk";
|
|
32
|
-
*
|
|
33
|
-
* const tx = setterRatifierRatifyRoot({
|
|
34
|
-
* chainId: 8453,
|
|
35
|
-
* maker,
|
|
36
|
-
* root,
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare const setterRatifierRatifyRoot: (params: SetterRatifierRatifyRootParams) => Readonly<Transaction<SetterRatifierRatifyRootAction>>;
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { setterRatifierAbi } from "@morpho-org/midnight-sdk";
|
|
2
|
-
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
|
-
import { encodeFunctionData } from "viem";
|
|
4
|
-
import { addTransactionMetadata } from "../../helpers/index.js";
|
|
5
|
-
/**
|
|
6
|
-
* Encodes a SetterRatifier root-ratification transaction.
|
|
7
|
-
*
|
|
8
|
-
* Use this after building a Setter-ratified offer tree and before submitting
|
|
9
|
-
* its mempool payload. Entity make-offer flows expose the same transaction
|
|
10
|
-
* through `getRequirements()` when the root is not already approved.
|
|
11
|
-
*
|
|
12
|
-
* @param params.chainId - Chain id used to resolve `SetterRatifier`.
|
|
13
|
-
* @param params.maker - Maker whose root approval is updated.
|
|
14
|
-
* @param params.root - Offer-tree root to approve or revoke.
|
|
15
|
-
* @param params.isRootRatified - Optional target state; defaults to `true`.
|
|
16
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
17
|
-
* @returns A deep-frozen `Transaction<SetterRatifierRatifyRootAction>` targeting `SetterRatifier`.
|
|
18
|
-
* @example
|
|
19
|
-
* ```ts
|
|
20
|
-
* import { setterRatifierRatifyRoot } from "@morpho-org/morpho-sdk";
|
|
21
|
-
*
|
|
22
|
-
* const tx = setterRatifierRatifyRoot({
|
|
23
|
-
* chainId: 8453,
|
|
24
|
-
* maker,
|
|
25
|
-
* root,
|
|
26
|
-
* });
|
|
27
|
-
* ```
|
|
28
|
-
*/
|
|
29
|
-
export const setterRatifierRatifyRoot = (params) => {
|
|
30
|
-
const isRootRatified = params.isRootRatified ?? true;
|
|
31
|
-
const setterRatifier = getChainAddress(params.chainId, "setterRatifier");
|
|
32
|
-
let tx = {
|
|
33
|
-
to: setterRatifier,
|
|
34
|
-
value: 0n,
|
|
35
|
-
data: encodeFunctionData({
|
|
36
|
-
abi: setterRatifierAbi,
|
|
37
|
-
functionName: "setIsRootRatified",
|
|
38
|
-
args: [params.maker, params.root, isRootRatified],
|
|
39
|
-
}),
|
|
40
|
-
};
|
|
41
|
-
if (params.metadata) {
|
|
42
|
-
tx = addTransactionMetadata(tx, params.metadata);
|
|
43
|
-
}
|
|
44
|
-
return deepFreeze({
|
|
45
|
-
...tx,
|
|
46
|
-
action: {
|
|
47
|
-
type: "setterRatifierRatifyRoot",
|
|
48
|
-
args: {
|
|
49
|
-
maker: params.maker,
|
|
50
|
-
root: params.root,
|
|
51
|
-
isRootRatified,
|
|
52
|
-
},
|
|
53
|
-
},
|
|
54
|
-
});
|
|
55
|
-
};
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { type Address, type Client, type Hex } from "viem";
|
|
2
|
-
import type { SetterRatifierRatifyRootAction, Transaction } from "../../../types/index.js";
|
|
3
|
-
/** Parameters for {@link getSetterRatifierRatifyRootRequirement}. */
|
|
4
|
-
export interface GetSetterRatifierRatifyRootRequirementParams {
|
|
5
|
-
readonly viemClient: Client;
|
|
6
|
-
readonly chainId: number;
|
|
7
|
-
readonly maker: Address;
|
|
8
|
-
readonly root: Hex;
|
|
9
|
-
}
|
|
10
|
-
/**
|
|
11
|
-
* Resolves the SetterRatifier root approval transaction for a maker offer tree.
|
|
12
|
-
*
|
|
13
|
-
* Call after building a Setter-ratified tree and before encoding/submitting its
|
|
14
|
-
* payload. Entity make-offer flows call this from `getRequirements()` and omit
|
|
15
|
-
* the transaction when the maker has already approved the root.
|
|
16
|
-
*
|
|
17
|
-
* @param params.viemClient - Viem client used to read root approval state.
|
|
18
|
-
* @param params.chainId - Chain id expected by the viem client.
|
|
19
|
-
* @param params.maker - Maker whose root approval is checked.
|
|
20
|
-
* @param params.root - Offer-tree root that must be approved.
|
|
21
|
-
* @returns Ratify-root transaction, or `null` when the root is already ratified.
|
|
22
|
-
* @throws {ChainIdMismatchError} when the viem client is connected to another chain.
|
|
23
|
-
* @example
|
|
24
|
-
* ```ts
|
|
25
|
-
* import { getSetterRatifierRatifyRootRequirement } from "@morpho-org/morpho-sdk";
|
|
26
|
-
*
|
|
27
|
-
* const tx = await getSetterRatifierRatifyRootRequirement({
|
|
28
|
-
* viemClient: client,
|
|
29
|
-
* chainId: 8453,
|
|
30
|
-
* maker: user,
|
|
31
|
-
* root,
|
|
32
|
-
* });
|
|
33
|
-
* if (tx) {
|
|
34
|
-
* await walletClient.sendTransaction({
|
|
35
|
-
* to: tx.to,
|
|
36
|
-
* data: tx.data,
|
|
37
|
-
* value: tx.value,
|
|
38
|
-
* });
|
|
39
|
-
* }
|
|
40
|
-
* ```
|
|
41
|
-
*/
|
|
42
|
-
export declare const getSetterRatifierRatifyRootRequirement: (params: GetSetterRatifierRatifyRootRequirementParams) => Promise<Readonly<Transaction<SetterRatifierRatifyRootAction>> | null>;
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { setterRatifierAbi } from "@morpho-org/midnight-sdk";
|
|
2
|
-
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
|
-
import { encodeFunctionData } from "viem";
|
|
4
|
-
import { readContract } from "viem/actions";
|
|
5
|
-
import { validateChainId } from "../../../helpers/index.js";
|
|
6
|
-
/**
|
|
7
|
-
* Resolves the SetterRatifier root approval transaction for a maker offer tree.
|
|
8
|
-
*
|
|
9
|
-
* Call after building a Setter-ratified tree and before encoding/submitting its
|
|
10
|
-
* payload. Entity make-offer flows call this from `getRequirements()` and omit
|
|
11
|
-
* the transaction when the maker has already approved the root.
|
|
12
|
-
*
|
|
13
|
-
* @param params.viemClient - Viem client used to read root approval state.
|
|
14
|
-
* @param params.chainId - Chain id expected by the viem client.
|
|
15
|
-
* @param params.maker - Maker whose root approval is checked.
|
|
16
|
-
* @param params.root - Offer-tree root that must be approved.
|
|
17
|
-
* @returns Ratify-root transaction, or `null` when the root is already ratified.
|
|
18
|
-
* @throws {ChainIdMismatchError} when the viem client is connected to another chain.
|
|
19
|
-
* @example
|
|
20
|
-
* ```ts
|
|
21
|
-
* import { getSetterRatifierRatifyRootRequirement } from "@morpho-org/morpho-sdk";
|
|
22
|
-
*
|
|
23
|
-
* const tx = await getSetterRatifierRatifyRootRequirement({
|
|
24
|
-
* viemClient: client,
|
|
25
|
-
* chainId: 8453,
|
|
26
|
-
* maker: user,
|
|
27
|
-
* root,
|
|
28
|
-
* });
|
|
29
|
-
* if (tx) {
|
|
30
|
-
* await walletClient.sendTransaction({
|
|
31
|
-
* to: tx.to,
|
|
32
|
-
* data: tx.data,
|
|
33
|
-
* value: tx.value,
|
|
34
|
-
* });
|
|
35
|
-
* }
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export const getSetterRatifierRatifyRootRequirement = async (params) => {
|
|
39
|
-
validateChainId(params.viemClient.chain?.id, params.chainId);
|
|
40
|
-
const setterRatifier = getChainAddress(params.chainId, "setterRatifier");
|
|
41
|
-
const isRootRatified = await readContract(params.viemClient, {
|
|
42
|
-
address: setterRatifier,
|
|
43
|
-
abi: setterRatifierAbi,
|
|
44
|
-
functionName: "isRootRatified",
|
|
45
|
-
args: [params.maker, params.root],
|
|
46
|
-
});
|
|
47
|
-
if (isRootRatified)
|
|
48
|
-
return null;
|
|
49
|
-
return deepFreeze({
|
|
50
|
-
to: setterRatifier,
|
|
51
|
-
value: 0n,
|
|
52
|
-
data: encodeFunctionData({
|
|
53
|
-
abi: setterRatifierAbi,
|
|
54
|
-
functionName: "setIsRootRatified",
|
|
55
|
-
args: [params.maker, params.root, true],
|
|
56
|
-
}),
|
|
57
|
-
action: {
|
|
58
|
-
type: "setterRatifierRatifyRoot",
|
|
59
|
-
args: {
|
|
60
|
-
maker: params.maker,
|
|
61
|
-
root: params.root,
|
|
62
|
-
isRootRatified: true,
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
});
|
|
66
|
-
};
|