@otim/sdk
Version:
Otim's TypeScript SDK for blockchain automation and smart contract interactions
1,016 lines (991 loc) • 37.1 kB
TypeScript
import { AxiosInstance, AxiosRequestConfig } from 'axios';
import z$1, { ZodTypeAny, z } from 'zod';
import { Address as Address$1, WalletClient, PublicClient, Account, Chain, Transport, Authorization } from 'viem';
interface ServiceResponse<T> {
data: T;
}
interface RequestOptions<T extends ZodTypeAny> {
params?: Record<string, unknown>;
data?: unknown;
responseSchema: T;
headers?: Record<string, string>;
timeout?: number;
}
interface RequestOptionsWithoutSchema {
params?: Record<string, unknown>;
data?: unknown;
headers?: Record<string, string>;
timeout?: number;
}
declare abstract class BaseService {
protected readonly instance: AxiosInstance;
constructor(instance: AxiosInstance);
protected get<T extends ZodTypeAny>(url: string, options: RequestOptions<T>): Promise<ServiceResponse<z.infer<T>>>;
protected get<T = unknown>(url: string, options?: RequestOptionsWithoutSchema): Promise<ServiceResponse<T>>;
protected post<T extends ZodTypeAny>(url: string, options: RequestOptions<T>): Promise<ServiceResponse<z.infer<T>>>;
protected post<T = unknown>(url: string, options?: RequestOptionsWithoutSchema): Promise<ServiceResponse<T>>;
protected put<T extends ZodTypeAny>(url: string, options: RequestOptions<T>): Promise<ServiceResponse<z.infer<T>>>;
protected put<T = unknown>(url: string, options?: RequestOptionsWithoutSchema): Promise<ServiceResponse<T>>;
protected delete<T extends ZodTypeAny>(url: string, options: RequestOptions<T>): Promise<ServiceResponse<z.infer<T>>>;
protected delete<T = unknown>(url: string, options?: RequestOptionsWithoutSchema): Promise<ServiceResponse<T>>;
private requestWithSchema;
private requestWithoutSchema;
private handleError;
private isAxiosError;
}
/**
* schemas
*/
declare const DelegationStatus: {
readonly Undelegated: "Undelegated";
readonly Pending: "Pending";
readonly Delegated: "Delegated";
readonly Expired: "Expired";
readonly Errored: "Errored";
};
type DelegationStatus = (typeof DelegationStatus)[keyof typeof DelegationStatus];
declare const delegationStatusRequestSchema: z.ZodObject<{
address: z.ZodString;
chainId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
address: string;
chainId: number;
}, {
address: string;
chainId: number;
}>;
type DelegationStatusRequest = z.infer<typeof delegationStatusRequestSchema>;
declare const delegationStatusResponseSchema: z.ZodObject<{
delegationStatus: z.ZodEnum<[DelegationStatus, ...DelegationStatus[]]>;
}, "strip", z.ZodTypeAny, {
delegationStatus: DelegationStatus;
}, {
delegationStatus: DelegationStatus;
}>;
type DelegationStatusResponse = z.infer<typeof delegationStatusResponseSchema>;
declare const delegationCreateRequestSchema: z.ZodObject<{
signedAuthorization: z.ZodString;
signerAddress: z.ZodString;
}, "strip", z.ZodTypeAny, {
signedAuthorization: string;
signerAddress: string;
}, {
signedAuthorization: string;
signerAddress: string;
}>;
type DelegationCreateRequest = z.infer<typeof delegationCreateRequestSchema>;
declare const delegationCreateResponseSchema: z.ZodEffects<z.ZodObject<{
success: z.ZodBoolean;
transactionHash: z.ZodOptional<z.ZodString>;
message: z.ZodOptional<z.ZodString>;
}, "strip", z.ZodTypeAny, {
success: boolean;
message?: string | undefined;
transactionHash?: string | undefined;
}, {
success: boolean;
message?: string | undefined;
transactionHash?: string | undefined;
}>, {
success: boolean;
message?: string | undefined;
transactionHash?: string | undefined;
}, unknown>;
type DelegationCreateResponse = z.infer<typeof delegationCreateResponseSchema>;
declare class DelegationService extends BaseService {
getStatus(data: DelegationStatusRequest): Promise<ServiceResponse<DelegationStatusResponse>>;
create(requestBody: DelegationCreateRequest): Promise<ServiceResponse<DelegationCreateResponse>>;
}
/**
* schemas
*/
declare const authLoginRequestSchema: z.ZodObject<{
siwe: z.ZodString;
signature: z.ZodObject<{
v: z.ZodNumber;
r: z.ZodString;
s: z.ZodString;
}, "strip", z.ZodTypeAny, {
v: number;
r: string;
s: string;
}, {
v: number;
r: string;
s: string;
}>;
}, "strip", z.ZodTypeAny, {
siwe: string;
signature: {
v: number;
r: string;
s: string;
};
}, {
siwe: string;
signature: {
v: number;
r: string;
s: string;
};
}>;
type AuthLoginRequest = z.infer<typeof authLoginRequestSchema>;
declare const authLoginResponseSchema: z.ZodObject<{
authorization: z.ZodString;
}, "strip", z.ZodTypeAny, {
authorization: string;
}, {
authorization: string;
}>;
type AuthLoginResponse = z.infer<typeof authLoginResponseSchema>;
declare const authLogoutResponseSchema: z.ZodAny;
type AuthLogoutResponse = z.infer<typeof authLogoutResponseSchema>;
declare class AuthService extends BaseService {
login(body: AuthLoginRequest): Promise<ServiceResponse<AuthLoginResponse>>;
logout(): Promise<ServiceResponse<AuthLogoutResponse>>;
}
/**
* schemas
*/
declare const GetDelegateAddressRequestSchema: z.ZodObject<{
chainId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
chainId: number;
}, {
chainId: number;
}>;
type GetDelegateAddressRequest = z.infer<typeof GetDelegateAddressRequestSchema>;
declare const getDelegateAddressResponseSchema: z.ZodObject<{
otimDelegateAddress: z.ZodString;
}, "strip", z.ZodTypeAny, {
otimDelegateAddress: string;
}, {
otimDelegateAddress: string;
}>;
type GetDelegateAddressResponse = z.infer<typeof getDelegateAddressResponseSchema>;
declare const getConfigTokensRequestParametersSchema: z.ZodObject<{
chainId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
chainId: number;
}, {
chainId: number;
}>;
type GetConfigTokensRequestParameters = z.infer<typeof getConfigTokensRequestParametersSchema>;
declare const getConfigTokensResponseSchema: z.ZodObject<{
tokens: z.ZodArray<z.ZodObject<{
symbol: z.ZodString;
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
}, "strip", z.ZodTypeAny, {
symbol: string;
address: `0x${string}`;
}, {
symbol: string;
address: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
tokens: {
symbol: string;
address: `0x${string}`;
}[];
}, {
tokens: {
symbol: string;
address: string;
}[];
}>;
type GetConfigTokensResponse = z.infer<typeof getConfigTokensResponseSchema>;
declare const getConfigChainsResponseSchema: z.ZodObject<{
chains: z.ZodArray<z.ZodObject<{
chainId: z.ZodNumber;
chainName: z.ZodString;
}, "strip", z.ZodTypeAny, {
chainId: number;
chainName: string;
}, {
chainId: number;
chainName: string;
}>, "many">;
}, "strip", z.ZodTypeAny, {
chains: {
chainId: number;
chainName: string;
}[];
}, {
chains: {
chainId: number;
chainName: string;
}[];
}>;
type GetConfigChainsResponse = z.infer<typeof getConfigChainsResponseSchema>;
declare const getInstructionStorageAddressRequestSchema: z.ZodObject<{
chainId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
chainId: number;
}, {
chainId: number;
}>;
type GetInstructionStorageAddressRequest = z.infer<typeof getInstructionStorageAddressRequestSchema>;
declare const getInstructionStorageAddressResponseSchema: z.ZodObject<{
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
}, "strip", z.ZodTypeAny, {
address: `0x${string}`;
}, {
address: string;
}>;
type GetInstructionStorageAddressResponse = z.infer<typeof getInstructionStorageAddressResponseSchema>;
declare const getHealthResponseSchema: z.ZodObject<{
"otim.db.liveness": z.ZodBoolean;
}, "strip", z.ZodTypeAny, {
"otim.db.liveness": boolean;
}, {
"otim.db.liveness": boolean;
}>;
type GetHealthResponse = z.infer<typeof getHealthResponseSchema>;
declare class ConfigService extends BaseService {
getDelegateAddress(params: GetDelegateAddressRequest): Promise<ServiceResponse<GetDelegateAddressResponse>>;
getTokens(params: GetConfigTokensRequestParameters): Promise<ServiceResponse<GetConfigTokensResponse>>;
getChains(): Promise<ServiceResponse<GetConfigChainsResponse>>;
getInstructionStorageAddress(params: GetInstructionStorageAddressRequest): Promise<ServiceResponse<GetInstructionStorageAddressResponse>>;
getHealth(): Promise<ServiceResponse<GetHealthResponse>>;
}
declare const addressSchema: z.ZodEffects<z.ZodString, `0x${string}`, string>;
type Address = z.infer<typeof addressSchema>;
declare const instructionIdSchema: z.ZodEffects<z.ZodString, `0x${string}`, string>;
type InstructionId = z.infer<typeof instructionIdSchema>;
declare const Sort: {
readonly Asc: "asc";
readonly Desc: "desc";
};
type Sort = (typeof Sort)[keyof typeof Sort];
declare const InstructionAction: {
readonly DeactivateInstruction: "deactivateInstruction";
readonly RefuelERC20: "refuelERC20";
readonly Refuel: "refuel";
readonly SweepDepositAccountERC20: "sweepDepositAccountERC20";
readonly SweepDepositAccount: "sweepDepositAccount";
readonly SweepSkipCCTPDepositAccount: "sweepSkipCCTPDepositAccount";
readonly TransferERC20: "transferERC20";
readonly Transfer: "transfer";
readonly UniswapV3ExactInput: "uniswapV3ExactInput";
};
type InstructionAction = (typeof InstructionAction)[keyof typeof InstructionAction];
/**
* schemas
*/
declare const InstructionState: {
readonly PendingActivation: "PendingActivation";
readonly Active: "Active";
readonly PendingDeactivation: "PendingDeactivation";
readonly Deactivated: "Deactivated";
readonly Errored: "Errored";
readonly Completed: "Completed";
readonly UserNotDelegated: "UserNotDelegated";
};
type InstructionState = (typeof InstructionState)[keyof typeof InstructionState];
declare const InstructionViewTimescale: {
readonly Days: "days";
readonly Hours: "hours";
readonly Minutes: "minutes";
readonly Seconds: "seconds";
};
type InstructionViewTimescale = (typeof InstructionViewTimescale)[keyof typeof InstructionViewTimescale];
declare const instructionSummariesByDateSchema: z$1.ZodRecord<z$1.ZodString, z$1.ZodArray<z$1.ZodObject<{
instructionId: z$1.ZodEffects<z$1.ZodString, `0x${string}`, string>;
chainId: z$1.ZodNumber;
executionCount: z$1.ZodNumber;
onTimeCount: z$1.ZodNumber;
lateCount: z$1.ZodNumber;
wasActivatedDuring: z$1.ZodBoolean;
amount: z$1.ZodDefault<z$1.ZodNumber>;
instructedValue: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>>;
instructedTokenAddress: z$1.ZodDefault<z$1.ZodOptional<z$1.ZodNullable<z$1.ZodString>>>;
}, "strip", z$1.ZodTypeAny, {
chainId: number;
instructionId: `0x${string}`;
instructedTokenAddress: string | null;
executionCount: number;
onTimeCount: number;
lateCount: number;
wasActivatedDuring: boolean;
amount: number;
instructedValue: string | null;
}, {
chainId: number;
instructionId: string;
executionCount: number;
onTimeCount: number;
lateCount: number;
wasActivatedDuring: boolean;
instructedTokenAddress?: string | null | undefined;
amount?: number | undefined;
instructedValue?: string | null | undefined;
}>, "many">>;
type InstructionSummariesByDate = z$1.infer<typeof instructionSummariesByDateSchema>;
declare const instructionGetAllRequestSchema: z.ZodObject<{
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
chainId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
address: `0x${string}`;
chainId: number;
}, {
address: string;
chainId: number;
}>;
type InstructionGetAllRequest = z.infer<typeof instructionGetAllRequestSchema>;
declare const instructionGetAllResponseSchema: z.ZodArray<z.ZodObject<{
instructionId: z.ZodEffects<z.ZodString, `0x${string}`, string>;
startAt: z.ZodOptional<z.ZodNullable<z.ZodString>>;
interval: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
timeout: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
maxExecutions: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
executionState: z.ZodObject<{
executionStatus: z.ZodEnum<[InstructionState, ...InstructionState[]]>;
executionCounter: z.ZodNumber;
lastExecuted: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
executionStatus: InstructionState;
executionCounter: number;
lastExecuted: number;
}, {
executionStatus: InstructionState;
executionCounter: number;
lastExecuted: number;
}>;
actionName: z.ZodOptional<z.ZodString>;
arguments: z.ZodAny;
nickname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
lastInstructedValue: z.ZodString;
totalInstructedValue: z.ZodString;
instructedTokenAddress: z.ZodOptional<z.ZodNullable<z.ZodEffects<z.ZodString, `0x${string}`, string>>>;
}, "strip", z.ZodTypeAny, {
instructionId: `0x${string}`;
executionState: {
executionStatus: InstructionState;
executionCounter: number;
lastExecuted: number;
};
lastInstructedValue: string;
totalInstructedValue: string;
timeout?: number | null | undefined;
maxExecutions?: number | null | undefined;
startAt?: string | null | undefined;
interval?: number | null | undefined;
actionName?: string | undefined;
arguments?: any;
nickname?: string | null | undefined;
instructedTokenAddress?: `0x${string}` | null | undefined;
}, {
instructionId: string;
executionState: {
executionStatus: InstructionState;
executionCounter: number;
lastExecuted: number;
};
lastInstructedValue: string;
totalInstructedValue: string;
timeout?: number | null | undefined;
maxExecutions?: number | null | undefined;
startAt?: string | null | undefined;
interval?: number | null | undefined;
actionName?: string | undefined;
arguments?: any;
nickname?: string | null | undefined;
instructedTokenAddress?: string | null | undefined;
}>, "many">;
type InstructionGetAllResponse = z.infer<typeof instructionGetAllResponseSchema>;
declare const instructionGetSummaryRequestSchema: z.ZodObject<{
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
chainId: z.ZodNumber;
instructionIds: z.ZodArray<z.ZodEffects<z.ZodString, `0x${string}`, string>, "many">;
from: z.ZodString;
to: z.ZodString;
skip: z.ZodOptional<z.ZodNumber>;
take: z.ZodOptional<z.ZodNumber>;
sort: z.ZodEnum<[Sort, ...Sort[]]>;
timeScale: z.ZodOptional<z.ZodEnum<[InstructionViewTimescale, ...InstructionViewTimescale[]]>>;
}, "strip", z.ZodTypeAny, {
sort: Sort;
address: `0x${string}`;
chainId: number;
instructionIds: `0x${string}`[];
from: string;
to: string;
skip?: number | undefined;
take?: number | undefined;
timeScale?: InstructionViewTimescale | undefined;
}, {
sort: Sort;
address: string;
chainId: number;
instructionIds: string[];
from: string;
to: string;
skip?: number | undefined;
take?: number | undefined;
timeScale?: InstructionViewTimescale | undefined;
}>;
type InstructionGetSummaryRequest = z.infer<typeof instructionGetSummaryRequestSchema>;
declare const instructionBuildRequestSchema: z.ZodObject<{
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
chainId: z.ZodNumber;
salt: z.ZodNumber;
maxExecutions: z.ZodNumber;
actionArguments: z.ZodRecord<z.ZodEnum<[InstructionAction, ...InstructionAction[]]>, z.ZodUnknown>;
}, "strip", z.ZodTypeAny, {
address: `0x${string}`;
chainId: number;
maxExecutions: number;
salt: number;
actionArguments: Partial<Record<InstructionAction, unknown>>;
}, {
address: string;
chainId: number;
maxExecutions: number;
salt: number;
actionArguments: Partial<Record<InstructionAction, unknown>>;
}>;
type InstructionBuildRequest = z.infer<typeof instructionBuildRequestSchema>;
declare const instructionBuildResponseSchema: z.ZodObject<{
action: z.ZodEffects<z.ZodString, `0x${string}`, string>;
arguments: z.ZodEffects<z.ZodString, `0x${string}`, string>;
maxExecutions: z.ZodEffects<z.ZodString, `0x${string}`, string>;
salt: z.ZodEffects<z.ZodString, `0x${string}`, string>;
nickname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
maxExecutions: `0x${string}`;
arguments: `0x${string}`;
action: `0x${string}`;
salt: `0x${string}`;
nickname?: string | null | undefined;
}, {
maxExecutions: string;
arguments: string;
action: string;
salt: string;
nickname?: string | null | undefined;
}>;
type InstructionBuildResponse = z.infer<typeof instructionBuildResponseSchema>;
declare const instructionActivateRequestSchema: z.ZodObject<{
nickname: z.ZodOptional<z.ZodString>;
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
chainId: z.ZodNumber;
salt: z.ZodEffects<z.ZodString, `0x${string}`, string>;
maxExecutions: z.ZodEffects<z.ZodString, `0x${string}`, string>;
action: z.ZodEffects<z.ZodString, `0x${string}`, string>;
arguments: z.ZodEffects<z.ZodString, `0x${string}`, string>;
activationSignature: z.ZodObject<{
yParity: z.ZodNumber;
r: z.ZodString;
s: z.ZodString;
}, "strip", z.ZodTypeAny, {
r: string;
s: string;
yParity: number;
}, {
r: string;
s: string;
yParity: number;
}>;
}, "strip", z.ZodTypeAny, {
address: `0x${string}`;
chainId: number;
maxExecutions: `0x${string}`;
arguments: `0x${string}`;
action: `0x${string}`;
salt: `0x${string}`;
activationSignature: {
r: string;
s: string;
yParity: number;
};
nickname?: string | undefined;
}, {
address: string;
chainId: number;
maxExecutions: string;
arguments: string;
action: string;
salt: string;
activationSignature: {
r: string;
s: string;
yParity: number;
};
nickname?: string | undefined;
}>;
type InstructionActivateRequest = z.infer<typeof instructionActivateRequestSchema>;
declare const instructionActivateResponseSchema: z.ZodObject<{
instructionId: z.ZodEffects<z.ZodString, `0x${string}`, string>;
}, "strip", z.ZodTypeAny, {
instructionId: `0x${string}`;
}, {
instructionId: string;
}>;
type InstructionActivateResponse = z.infer<typeof instructionActivateResponseSchema>;
declare const instructionDeactivateRequestSchema: z.ZodObject<{
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
chainId: z.ZodNumber;
deactivation: z.ZodObject<{
instructionId: z.ZodEffects<z.ZodString, `0x${string}`, string>;
}, "strip", z.ZodTypeAny, {
instructionId: `0x${string}`;
}, {
instructionId: string;
}>;
deactivationSignature: z.ZodObject<{
yParity: z.ZodNumber;
r: z.ZodString;
s: z.ZodString;
}, "strip", z.ZodTypeAny, {
r: string;
s: string;
yParity: number;
}, {
r: string;
s: string;
yParity: number;
}>;
}, "strip", z.ZodTypeAny, {
address: `0x${string}`;
chainId: number;
deactivation: {
instructionId: `0x${string}`;
};
deactivationSignature: {
r: string;
s: string;
yParity: number;
};
}, {
address: string;
chainId: number;
deactivation: {
instructionId: string;
};
deactivationSignature: {
r: string;
s: string;
yParity: number;
};
}>;
type InstructionDeactivateRequest = z.infer<typeof instructionDeactivateRequestSchema>;
declare const instructionDeactivateResponseSchema: z.ZodUnknown;
type InstructionDeactivateResponse = z.infer<typeof instructionDeactivateResponseSchema>;
declare const instructionDetailsRequestSchema: z.ZodObject<{
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
instructionId: z.ZodEffects<z.ZodString, `0x${string}`, string>;
chainId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
address: `0x${string}`;
chainId: number;
instructionId: `0x${string}`;
}, {
address: string;
chainId: number;
instructionId: string;
}>;
type InstructionDetailsRequest = z.infer<typeof instructionDetailsRequestSchema>;
declare const instructionDetailsResponseSchema: z.ZodObject<{
action: z.ZodEffects<z.ZodString, `0x${string}`, string>;
actionArguments: z.ZodUnknown;
actionName: z.ZodOptional<z.ZodNullable<z.ZodString>>;
salt: z.ZodEffects<z.ZodString, `0x${string}`, string>;
maxExecutions: z.ZodEffects<z.ZodString, `0x${string}`, string>;
nickname: z.ZodOptional<z.ZodNullable<z.ZodString>>;
}, "strip", z.ZodTypeAny, {
maxExecutions: `0x${string}`;
action: `0x${string}`;
salt: `0x${string}`;
actionName?: string | null | undefined;
nickname?: string | null | undefined;
actionArguments?: unknown;
}, {
maxExecutions: string;
action: string;
salt: string;
actionName?: string | null | undefined;
nickname?: string | null | undefined;
actionArguments?: unknown;
}>;
type InstructionDetailsResponse = z.infer<typeof instructionDetailsResponseSchema>;
declare const getMaxPriorityFeePerGasEstimateSchema: z.ZodObject<{
chainId: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
chainId: number;
}, {
chainId: number;
}>;
type GetMaxPriorityFeePerGasEstimateRequest = z.infer<typeof getMaxPriorityFeePerGasEstimateSchema>;
declare const getMaxPriorityFeePerGasEstimateResponseSchema: z.ZodObject<{
slowMaxPriorityFeeEstimate: z.ZodNumber;
normalMaxPriorityFeeEstimate: z.ZodNumber;
fastMaxPriorityFeeEstimate: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
slowMaxPriorityFeeEstimate: number;
normalMaxPriorityFeeEstimate: number;
fastMaxPriorityFeeEstimate: number;
}, {
slowMaxPriorityFeeEstimate: number;
normalMaxPriorityFeeEstimate: number;
fastMaxPriorityFeeEstimate: number;
}>;
type GetMaxPriorityFeePerGasEstimateResponse = z.infer<typeof getMaxPriorityFeePerGasEstimateResponseSchema>;
declare class InstructionService extends BaseService {
getAll(data: InstructionGetAllRequest): Promise<ServiceResponse<InstructionGetAllResponse>>;
getSummary(data: InstructionGetSummaryRequest): Promise<ServiceResponse<InstructionSummariesByDate>>;
build(body: InstructionBuildRequest): Promise<ServiceResponse<InstructionBuildResponse>>;
activate(body: InstructionActivateRequest): Promise<ServiceResponse<InstructionActivateResponse>>;
deactivate(body: InstructionDeactivateRequest): Promise<ServiceResponse<InstructionDeactivateResponse>>;
getDetails(data: InstructionDetailsRequest): Promise<ServiceResponse<InstructionDetailsResponse>>;
getMaxPriorityFeePerGasEstimate(params: GetMaxPriorityFeePerGasEstimateRequest): Promise<ServiceResponse<GetMaxPriorityFeePerGasEstimateResponse>>;
}
declare const transactionGetListRequestSchema: z.ZodObject<{
address: z.ZodEffects<z.ZodString, `0x${string}`, string>;
chainId: z.ZodNumber;
instructionIds: z.ZodArray<z.ZodString, "many">;
from: z.ZodString;
to: z.ZodString;
skip: z.ZodNumber;
take: z.ZodNumber;
sort: z.ZodEnum<[Sort, ...Sort[]]>;
}, "strip", z.ZodTypeAny, {
sort: Sort;
address: `0x${string}`;
chainId: number;
instructionIds: string[];
from: string;
to: string;
skip: number;
take: number;
}, {
sort: Sort;
address: string;
chainId: number;
instructionIds: string[];
from: string;
to: string;
skip: number;
take: number;
}>;
type TransactionGetListRequest = z.infer<typeof transactionGetListRequestSchema>;
declare const transactionGetListResponseSchema: z.ZodArray<z.ZodObject<{
instructionId: z.ZodEffects<z.ZodString, `0x${string}`, string>;
transactionHash: z.ZodOptional<z.ZodEffects<z.ZodString, `0x${string}`, string>>;
blockHash: z.ZodNullable<z.ZodString>;
transactionStatus: z.ZodString;
error: z.ZodOptional<z.ZodNullable<z.ZodString>>;
startedAt: z.ZodString;
startedAtBlock: z.ZodNumber;
finishedAt: z.ZodNullable<z.ZodString>;
finishedAtBlock: z.ZodNullable<z.ZodNumber>;
amount: z.ZodOptional<z.ZodNullable<z.ZodObject<{
value: z.ZodNumber;
token: z.ZodString;
}, "strip", z.ZodTypeAny, {
value: number;
token: string;
}, {
value: number;
token: string;
}>>>;
instructedValue: z.ZodString;
instructedTokenAddress: z.ZodNullable<z.ZodString>;
executionNum: z.ZodNumber;
}, "strip", z.ZodTypeAny, {
instructionId: `0x${string}`;
instructedTokenAddress: string | null;
instructedValue: string;
blockHash: string | null;
transactionStatus: string;
startedAt: string;
startedAtBlock: number;
finishedAt: string | null;
finishedAtBlock: number | null;
executionNum: number;
transactionHash?: `0x${string}` | undefined;
amount?: {
value: number;
token: string;
} | null | undefined;
error?: string | null | undefined;
}, {
instructionId: string;
instructedTokenAddress: string | null;
instructedValue: string;
blockHash: string | null;
transactionStatus: string;
startedAt: string;
startedAtBlock: number;
finishedAt: string | null;
finishedAtBlock: number | null;
executionNum: number;
transactionHash?: string | undefined;
amount?: {
value: number;
token: string;
} | null | undefined;
error?: string | null | undefined;
}>, "many">;
type TransactionGetListResponse = z.infer<typeof transactionGetListResponseSchema>;
declare class TransactionService extends BaseService {
getAll(data: TransactionGetListRequest): Promise<ServiceResponse<TransactionGetListResponse>>;
}
interface OtimAPIClientConfig {
authorizationToken?: string;
baseURL?: string;
withCredentials?: boolean;
headers?: Record<string, string>;
axiosConfig?: AxiosRequestConfig;
}
declare class OtimAPIClient {
private readonly clientConfig;
private readonly instance;
private authService?;
private configService?;
private delegationService?;
private instructionService?;
private transactionService?;
constructor(config?: OtimAPIClientConfig);
get auth(): AuthService;
get config(): ConfigService;
get delegation(): DelegationService;
get instruction(): InstructionService;
get transaction(): TransactionService;
setAuthToken(token: string): void;
clearAuth(): void;
}
interface LoginOptions {
domain: string;
uri: string;
address: Address$1;
chainId: number;
}
declare function login(client: OtimAPIClient, walletClient: WalletClient, { domain, uri, address, chainId }: LoginOptions): Promise<AuthLoginResponse>;
declare function logout(client: OtimAPIClient): Promise<AuthLogoutResponse>;
declare function setAuthorizationHeader(client: OtimAPIClient, authorizationToken: string): Promise<void>;
interface AuthClient {
readonly login: (options: LoginOptions) => ReturnType<typeof login>;
readonly logout: () => ReturnType<typeof logout>;
readonly setAuthorizationHeader: (authorizationToken: string) => ReturnType<typeof setAuthorizationHeader>;
}
interface GetTokensOptions {
chainId: number;
}
interface GetMaxPriorityFeeEstimateOptions {
chainId: number;
}
interface GetInstructionStorageAddressOptions {
chainId: number;
}
declare function getTokens(client: OtimAPIClient, { chainId }: GetTokensOptions): Promise<GetConfigTokensResponse>;
declare function getChains(client: OtimAPIClient): Promise<GetConfigChainsResponse>;
declare function getMaxPriorityFeeEstimate(client: OtimAPIClient, { chainId }: GetMaxPriorityFeeEstimateOptions): Promise<GetMaxPriorityFeePerGasEstimateResponse>;
declare function getHealth(client: OtimAPIClient): Promise<GetHealthResponse>;
declare function getInstructionStorageAddress(client: OtimAPIClient, { chainId }: GetInstructionStorageAddressOptions): Promise<GetInstructionStorageAddressResponse>;
declare function getDelegateAddress(client: OtimAPIClient, { chainId }: {
chainId: number;
}): Promise<GetDelegateAddressResponse>;
interface ConfigClient {
readonly chains: () => ReturnType<typeof getChains>;
readonly health: () => ReturnType<typeof getHealth>;
readonly getMaxPriorityFeeEstimate: (options: GetMaxPriorityFeeEstimateOptions) => ReturnType<typeof getMaxPriorityFeeEstimate>;
readonly getDelegateAddress: (options: {
chainId: number;
}) => ReturnType<typeof getDelegateAddress>;
readonly getInstructionStorageAddress: (options: GetInstructionStorageAddressOptions) => ReturnType<typeof getInstructionStorageAddress>;
readonly getTokens: (options: GetTokensOptions) => ReturnType<typeof getTokens>;
}
interface DelegationStatusOptions {
address?: Address$1;
chainId?: number;
}
interface DelegateOptions {
address?: Address$1;
signedAuthorization: string;
}
declare function getDelegationStatus(client: OtimAPIClient, walletClient: WalletClient, { address, chainId }?: DelegationStatusOptions): Promise<DelegationStatusResponse>;
declare function delegate(client: OtimAPIClient, walletClient: WalletClient, { address, signedAuthorization }: DelegateOptions): Promise<ServiceResponse<{
success: boolean;
message?: string | undefined;
transactionHash?: string | undefined;
}>>;
interface DelegationClient {
readonly getDelegationStatus: (options: DelegationStatusOptions) => ReturnType<typeof getDelegationStatus>;
readonly delegate: (options: DelegateOptions) => ReturnType<typeof delegate>;
}
interface BaseInstructionOptions {
address?: Address;
chainId?: number;
salt?: number;
maxExecutions?: number;
}
interface BaseFeeOptions {
token?: Address;
maxBaseFeePerGas?: bigint | string;
maxPriorityFeePerGas?: bigint | string;
executionFee?: number;
}
interface BaseScheduleOptions {
startAt?: number;
startBy?: number;
interval?: number;
timeout?: number;
}
interface InstructionBuildResult<T = unknown> {
instruction: T;
actionType: InstructionAction;
activate: (options?: {
nickname?: string;
}) => Promise<InstructionActivateResponse>;
}
interface TransferOptions extends BaseInstructionOptions {
target: Address;
value: bigint;
token?: Address;
gasLimit?: bigint;
schedule?: BaseScheduleOptions;
fee?: BaseFeeOptions;
}
interface SweepOptions extends BaseInstructionOptions {
depositor: Address;
recipient: Address;
threshold?: bigint;
token?: Address;
fee?: BaseFeeOptions;
}
interface SweepSkipCCTPDepositAccountOptions extends BaseInstructionOptions {
depositor: Address;
destinationDomain: number;
destinationMintRecipient: Address;
threshold?: bigint;
fee?: BaseFeeOptions;
}
interface SwapOptions extends BaseInstructionOptions {
tokenIn: Address;
tokenOut: Address;
amountIn: bigint;
floorAmountOut: bigint;
recipient?: Address;
feeTier?: number;
meanPriceLookBack?: number;
maxPriceDeviationBps?: number;
schedule?: BaseScheduleOptions;
fee?: BaseFeeOptions;
}
interface RefuelOptions extends BaseInstructionOptions {
target?: Address;
threshold: bigint;
endBalance: bigint;
token?: Address;
gasLimit?: bigint;
fee?: BaseFeeOptions;
}
interface BuildDeactivateInstructionOptions extends BaseInstructionOptions {
instructionId: InstructionId;
fee?: BaseFeeOptions;
}
interface GetAllInstructionsOptions {
address?: Address;
chainId?: number;
}
interface GetInstructionDetailsOptions {
instructionId: Address;
}
declare function buildTransferInstruction(client: OtimAPIClient, walletClient: WalletClient, options: TransferOptions): Promise<InstructionBuildResult>;
declare function buildSweepInstruction(client: OtimAPIClient, walletClient: WalletClient, options: SweepOptions): Promise<InstructionBuildResult>;
declare function buildSweepSkipCCTPDepositAccountInstruction(client: OtimAPIClient, walletClient: WalletClient, options: SweepSkipCCTPDepositAccountOptions): Promise<InstructionBuildResult>;
declare function buildSwapInstruction(client: OtimAPIClient, walletClient: WalletClient, options: SwapOptions): Promise<InstructionBuildResult>;
declare function buildRefuelInstruction(client: OtimAPIClient, walletClient: WalletClient, options: RefuelOptions): Promise<InstructionBuildResult>;
declare function buildDeactivateInstruction(client: OtimAPIClient, walletClient: WalletClient, options: BuildDeactivateInstructionOptions): Promise<InstructionBuildResult>;
declare function getAll(client: OtimAPIClient, walletClient: WalletClient, { address, chainId }?: GetAllInstructionsOptions): Promise<InstructionGetAllResponse>;
declare function details(client: OtimAPIClient, walletClient: WalletClient, { instructionId }: GetInstructionDetailsOptions): Promise<InstructionDetailsResponse>;
interface InstructionClient {
readonly getAll: (options: GetAllInstructionsOptions) => ReturnType<typeof getAll>;
readonly details: (options: GetInstructionDetailsOptions) => ReturnType<typeof details>;
readonly build: {
readonly transfer: (options: TransferOptions) => ReturnType<typeof buildTransferInstruction>;
readonly sweep: (options: SweepOptions) => ReturnType<typeof buildSweepInstruction>;
readonly sweepSkipCCTPDepositAccount: (options: SweepSkipCCTPDepositAccountOptions) => ReturnType<typeof buildSweepSkipCCTPDepositAccountInstruction>;
readonly swap: (options: SwapOptions) => ReturnType<typeof buildSwapInstruction>;
readonly refuel: (options: RefuelOptions) => ReturnType<typeof buildRefuelInstruction>;
readonly deactivate: (options: BuildDeactivateInstructionOptions) => ReturnType<typeof buildDeactivateInstruction>;
};
}
interface GetTransactionListOptions {
address?: Address$1;
chainId?: number;
instructionIds: string[];
from: string;
to: string;
skip?: number;
take?: number;
sort?: Sort;
}
declare function getList(client: OtimAPIClient, walletClient: WalletClient, { address, chainId, instructionIds, from, to, skip, take, sort, }: GetTransactionListOptions): Promise<TransactionGetListResponse>;
interface TransactionClient {
readonly getList: (options: GetTransactionListOptions) => ReturnType<typeof getList>;
}
interface BaseConfig {
authorizationToken?: string;
axiosConfig?: AxiosRequestConfig;
baseURL?: string;
headers?: Record<string, string>;
withCredentials?: boolean;
}
interface CreateClientConfigWithWalletClient extends BaseConfig {
walletClient: WalletClient;
}
interface CreateClientConfigWithTransport extends BaseConfig {
account: Account | Address$1;
chain: Chain;
transport: Transport;
}
interface OtimClientWithWalletClient {
auth: AuthClient;
delegation: DelegationClient;
config: ConfigClient;
instruction: InstructionClient;
transaction: TransactionClient;
}
interface OtimClientWithTransport {
auth: AuthClient;
delegation: DelegationClient;
config: ConfigClient;
instruction: InstructionClient;
transaction: TransactionClient;
publicClient: PublicClient;
}
type OtimClient = OtimClientWithWalletClient | OtimClientWithTransport;
declare function createOtimClient(config: CreateClientConfigWithWalletClient): OtimClientWithWalletClient;
declare function createOtimClient(config: CreateClientConfigWithTransport): OtimClientWithTransport;
declare function createRlpEncodedAuthorization(authorization: Authorization): `0x${string}`;
declare function createRlpEncodedAuthorization(chainId: number, delegateAddress: string, nonce: number, yParity: number | bigint, r: `0x${string}`, s: `0x${string}`): `0x${string}`;
declare const corsConfigs: {
development: {
baseURL: string;
withCredentials: false;
};
production: {
withCredentials: false;
headers: {
"Content-Type": string;
Accept: string;
};
};
withCredentials: {
withCredentials: true;
headers: {
"Content-Type": string;
Accept: string;
};
};
};
declare const isBrowser: boolean;
declare const isNode: boolean;
declare function getCorsConfig(environment?: "development" | "production" | "withCredentials"): Partial<OtimAPIClientConfig>;
/**
* Create a proxy url for development.
* Useful when running a local dev server with proxy.
*/
declare function createProxyUrl(path: string, proxyBase?: string): string;
export { type OtimAPIClientConfig, type OtimClient, corsConfigs, createOtimClient, createProxyUrl, createRlpEncodedAuthorization, getCorsConfig, isBrowser, isNode };