@hyperlane-xyz/sdk
Version:
The official SDK for the Hyperlane Network
94 lines • 4.09 kB
TypeScript
import { type Address, type Hex } from 'viem';
import type { Permit2Data, SubmitQuoteCommand } from './types.js';
import { QuotedCallsCommand } from './types.js';
/**
* Sentinel value: resolves to the contract's token balance (ERC20) or
* native balance (ETH) at execution time. Matches QuotedCalls.CONTRACT_BALANCE.
*/
export declare const CONTRACT_BALANCE: bigint;
/** Matches QuotedCalls._scopeSalt: keccak256(abi.encodePacked(caller, salt)) */
export declare function computeScopedSalt(caller: Address, clientSalt: Hex): Hex;
/** Encode SUBMIT_QUOTE input: abi.encode(address quoter, SignedQuote quote, bytes signature, bytes32 clientSalt) */
export declare function encodeSubmitQuoteInput(cmd: SubmitQuoteCommand, clientSalt: Hex): Hex;
/** Encode PERMIT2_PERMIT input: abi.encode(IAllowanceTransfer.PermitSingle, bytes signature) */
export declare function encodePermit2PermitInput(permit2Data: Permit2Data): Hex;
/** Encode PERMIT2_TRANSFER_FROM input: abi.encode(address token, uint160 amount) */
export declare function encodePermit2TransferFromInput(token: Address, amount: bigint): Hex;
/** Encode TRANSFER_FROM input: abi.encode(address token, uint256 amount) */
export declare function encodeTransferFromInput(token: Address, amount: bigint): Hex;
/** Encode TRANSFER_REMOTE input: abi.encode(address warpRoute, uint32 destination, bytes32 recipient, uint256 amount, uint256 value, address token, uint256 approval) */
export declare function encodeTransferRemoteInput(params: {
warpRoute: Address;
destination: number;
recipient: Hex;
amount: bigint;
value: bigint;
token: Address;
approval: bigint;
}): Hex;
/** Encode TRANSFER_REMOTE_TO input: abi.encode(address router, uint32 destination, bytes32 recipient, uint256 amount, bytes32 targetRouter, uint256 value, address token, uint256 approval) */
export declare function encodeTransferRemoteToInput(params: {
router: Address;
destination: number;
recipient: Hex;
amount: bigint;
targetRouter: Hex;
value: bigint;
token: Address;
approval: bigint;
}): Hex;
/** Encode SWEEP input: abi.encode(address token) */
export declare function encodeSweepInput(token: Address): Hex;
export declare const quotedCallsAbi: readonly [{
readonly name: "execute";
readonly type: "function";
readonly inputs: readonly [{
readonly name: "commands";
readonly type: "bytes";
}, {
readonly name: "inputs";
readonly type: "bytes[]";
}];
readonly outputs: readonly [];
readonly stateMutability: "payable";
}, {
readonly name: "quoteExecute";
readonly type: "function";
readonly inputs: readonly [{
readonly name: "commands";
readonly type: "bytes";
}, {
readonly name: "inputs";
readonly type: "bytes[]";
}];
readonly outputs: readonly [{
readonly name: "results";
readonly type: "tuple[][]";
readonly components: ({
name: string;
type: "address";
} | {
name: string;
type: "uint256";
})[];
}];
readonly stateMutability: "nonpayable";
}];
/** Encode QuotedCalls.execute(commands, inputs) calldata */
export declare function encodeExecuteCalldata(commands: QuotedCallsCommand[], inputs: Hex[]): Hex;
/** Encode QuotedCalls.quoteExecute(commands, inputs) calldata */
export declare function encodeQuoteExecuteCalldata(commands: QuotedCallsCommand[], inputs: Hex[]): Hex;
export interface Quote {
token: Address;
amount: bigint;
}
/** Decode the return value of quoteExecute into Quote[][] */
export declare function decodeQuoteExecuteResult(data: Hex): Quote[][];
/** Sum Quote[][] into totals per token address (normalized to lowercase) */
export declare function sumQuotesByToken(results: Quote[][]): Map<Address, bigint>;
/** Extract native (address(0)) and ERC20 totals from quote results */
export declare function extractQuoteTotals(results: Quote[][]): {
nativeValue: bigint;
tokenTotals: Map<Address, bigint>;
};
//# sourceMappingURL=codec.d.ts.map