@axelar-network/interchain-token-service
Version:
Interchain token service for EVM chains to faciliate interchain token transfers and contract calls
153 lines (137 loc) • 3.71 kB
text/typescript
/* eslint-disable @typescript-eslint/no-explicit-any */
/**
* This file was generated by scripts/codegen.ts
*
* Original abi file:
* - artifacts/contracts/TokenHandler.sol/TokenHandler.json
*
* DO NOT EDIT MANUALLY
*/
import { encodeFunctionData } from "viem";
import ABI_FILE from "./TokenHandler.abi";
export type TokenHandlerGiveTokenArgs = {
tokenId: `0x${string}`;
to: `0x${string}`;
amount: bigint;
};
/**
* Factory function for TokenHandler.giveToken function args
*/
export const encodeTokenHandlerGiveTokenArgs = ({
tokenId,
to,
amount,
}: TokenHandlerGiveTokenArgs) => [tokenId, to, amount] as const;
/**
* Encoder function for TokenHandler.giveToken function data
*/
export const encodeTokenHandlerGiveTokenData = ({
tokenId,
to,
amount,
}: TokenHandlerGiveTokenArgs): `0x${string}` =>
encodeFunctionData({
functionName: "giveToken",
abi: ABI_FILE.abi,
args: [tokenId, to, amount],
});
export type TokenHandlerPostTokenManagerDeployArgs = {
tokenManagerType: bigint;
tokenManager: `0x${string}`;
};
/**
* Factory function for TokenHandler.postTokenManagerDeploy function args
*/
export const encodeTokenHandlerPostTokenManagerDeployArgs = ({
tokenManagerType,
tokenManager,
}: TokenHandlerPostTokenManagerDeployArgs) =>
[tokenManagerType, tokenManager] as const;
/**
* Encoder function for TokenHandler.postTokenManagerDeploy function data
*/
export const encodeTokenHandlerPostTokenManagerDeployData = ({
tokenManagerType,
tokenManager,
}: TokenHandlerPostTokenManagerDeployArgs): `0x${string}` =>
encodeFunctionData({
functionName: "postTokenManagerDeploy",
abi: ABI_FILE.abi,
args: [tokenManagerType, tokenManager],
});
export type TokenHandlerTakeTokenArgs = {
tokenId: `0x${string}`;
tokenOnly: boolean;
from: `0x${string}`;
amount: bigint;
};
/**
* Factory function for TokenHandler.takeToken function args
*/
export const encodeTokenHandlerTakeTokenArgs = ({
tokenId,
tokenOnly,
from,
amount,
}: TokenHandlerTakeTokenArgs) => [tokenId, tokenOnly, from, amount] as const;
/**
* Encoder function for TokenHandler.takeToken function data
*/
export const encodeTokenHandlerTakeTokenData = ({
tokenId,
tokenOnly,
from,
amount,
}: TokenHandlerTakeTokenArgs): `0x${string}` =>
encodeFunctionData({
functionName: "takeToken",
abi: ABI_FILE.abi,
args: [tokenId, tokenOnly, from, amount],
});
export type TokenHandlerTransferTokenFromArgs = {
tokenId: `0x${string}`;
from: `0x${string}`;
to: `0x${string}`;
amount: bigint;
};
/**
* Factory function for TokenHandler.transferTokenFrom function args
*/
export const encodeTokenHandlerTransferTokenFromArgs = ({
tokenId,
from,
to,
amount,
}: TokenHandlerTransferTokenFromArgs) => [tokenId, from, to, amount] as const;
/**
* Encoder function for TokenHandler.transferTokenFrom function data
*/
export const encodeTokenHandlerTransferTokenFromData = ({
tokenId,
from,
to,
amount,
}: TokenHandlerTransferTokenFromArgs): `0x${string}` =>
encodeFunctionData({
functionName: "transferTokenFrom",
abi: ABI_FILE.abi,
args: [tokenId, from, to, amount],
});
export const TOKEN_HANDLER_ENCODERS = {
giveToken: {
args: encodeTokenHandlerGiveTokenArgs,
data: encodeTokenHandlerGiveTokenData,
},
postTokenManagerDeploy: {
args: encodeTokenHandlerPostTokenManagerDeployArgs,
data: encodeTokenHandlerPostTokenManagerDeployData,
},
takeToken: {
args: encodeTokenHandlerTakeTokenArgs,
data: encodeTokenHandlerTakeTokenData,
},
transferTokenFrom: {
args: encodeTokenHandlerTransferTokenFromArgs,
data: encodeTokenHandlerTransferTokenFromData,
},
};