@defuse-protocol/one-click-sdk-typescript
Version:
TypeScript SDK for 1Click API
1,426 lines (1,388 loc) • 619 kB
TypeScript
type ApiRequestOptions = {
readonly method: 'GET' | 'PUT' | 'POST' | 'DELETE' | 'OPTIONS' | 'HEAD' | 'PATCH';
readonly url: string;
readonly path?: Record<string, any>;
readonly cookies?: Record<string, any>;
readonly headers?: Record<string, any>;
readonly query?: Record<string, any>;
readonly formData?: Record<string, any>;
readonly body?: any;
readonly mediaType?: string;
readonly responseHeader?: string;
readonly errors?: Record<number, string>;
};
type ApiResult = {
readonly url: string;
readonly ok: boolean;
readonly status: number;
readonly statusText: string;
readonly body: any;
};
declare class ApiError extends Error {
readonly url: string;
readonly status: number;
readonly statusText: string;
readonly body: any;
readonly request: ApiRequestOptions;
constructor(request: ApiRequestOptions, response: ApiResult, message: string);
}
declare class CancelError extends Error {
constructor(message: string);
get isCancelled(): boolean;
}
interface OnCancel {
readonly isResolved: boolean;
readonly isRejected: boolean;
readonly isCancelled: boolean;
(cancelHandler: () => void): void;
}
declare class CancelablePromise<T> implements Promise<T> {
#private;
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
get [Symbol.toStringTag](): string;
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
finally(onFinally?: (() => void) | null): Promise<T>;
cancel(): void;
get isCancelled(): boolean;
}
type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
type Headers = Record<string, string>;
type OpenAPIConfig = {
BASE: string;
VERSION: string;
WITH_CREDENTIALS: boolean;
CREDENTIALS: 'include' | 'omit' | 'same-origin';
TOKEN?: string | Resolver<string> | undefined;
USERNAME?: string | Resolver<string> | undefined;
PASSWORD?: string | Resolver<string> | undefined;
HEADERS?: Headers | Resolver<Headers> | undefined;
ENCODE_PATH?: ((path: string) => string) | undefined;
};
declare const OpenAPI: OpenAPIConfig;
type AnyInputQuoteWithdrawal = {
/**
* Withdrawal status
*/
status: AnyInputQuoteWithdrawal.status;
/**
* Amount out in readable format
*/
amountOutFormatted: string;
/**
* Amount out in USD
*/
amountOutUsd: string;
/**
* Amount out in smallest unit
*/
amountOut: string;
/**
* Withdrawal fee in readable format
*/
withdrawFeeFormatted: string;
/**
* Withdrawal fee in smallest unit
*/
withdrawFee: string;
/**
* Withdrawal fee in USD
*/
withdrawFeeUsd: string;
/**
* Timestamp of withdrawal
*/
timestamp: string;
/**
* Transaction hash
*/
hash: string;
};
declare namespace AnyInputQuoteWithdrawal {
/**
* Withdrawal status
*/
enum status {
SUCCESS = "SUCCESS",
FAILED = "FAILED"
}
}
type AppFee = {
/**
* Account ID within Intents to which this fee will be transferred
*/
recipient: string;
/**
* Fee for this recipient as part of amountIn in basis points (1/100th of a percent), e.g. 100 for 1% fee
*/
fee: number;
};
/**
* Call [`.on_auth`](::defuse_auth_call::AuthCallee::on_auth) with `signer_id` of intent.
*/
type AuthCall = {
/**
* Optionally, attach deposit to [`.on_auth`](::defuse_auth_call::AuthCallee::on_auth) call. The amount will be subtracted from user's NEP-141 `wNEAR` balance.
*
* NOTE: the `wNEAR` will not be refunded in case of fail.
*/
attached_deposit?: string;
/**
* Callee for [`.on_auth`](::defuse_auth_call::AuthCallee::on_auth)
*/
contract_id: string;
/**
* Optional minimum gas required for created promise to succeed. By default, only [`MIN_GAS_DEFAULT`](AuthCall::MIN_GAS_DEFAULT) is required.
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* `msg` to pass in [`.on_auth`](::defuse_auth_call::AuthCallee::on_auth)
*/
msg: string;
/**
* Optionally initialize the receiver's contract (Deterministic AccountId) via [`state_init`](https://github.com/near/NEPs/blob/master/neps/nep-0616.md#stateinit-action) right before calling [`.on_auth()`](::defuse_auth_call::AuthCallee::on_auth) (in the same receipt).
*/
state_init?: {
code: ({
hash: string;
} | {
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
account_id: string;
});
data: Record<string, string>;
version: AuthCall.version;
} | null;
};
declare namespace AuthCall {
enum version {
V1 = "v1"
}
}
/**
* Assuming wallets want to interact with Intents protocol, besides preparing the data in a certain form, they have to have the capability to sign raw messages (off-chain signatures) using an algorithm we understand. This enum solves that problem.
*
* For example, because we support ERC-191 and know how to verify messages with that standard, we can allow wallets, like Metamask, sign messages to perform intents without having to support new cryptographic primitives and signing standards.
*/
type MultiPayload = ({
/**
* See [NEP-413](https://github.com/near/NEPs/blob/master/neps/nep-0413.md)
*/
payload: {
callbackUrl?: string | null;
message: string;
/**
* Encoding: base64
*/
nonce: string;
recipient: string;
};
/**
* Encoding: base58
*/
public_key: string;
/**
* Encoding: base58
*/
signature: string;
standard: MultiPayload.standard;
} | {
/**
* See [ERC-191](https://github.com/ethereum/ercs/blob/master/ERCS/erc-191.md)
*/
payload: string;
/**
* There is no public key member because the public key can be recovered via `ecrecover()` knowing the data and the signature. Encoding: base58
*/
signature: string;
standard: MultiPayload.standard;
} | {
/**
* See [TIP-191](https://github.com/tronprotocol/tips/blob/master/tip-191.md)
*/
payload: string;
/**
* There is no public key member because the public key can be recovered via `ecrecover()` knowing the data and the signature. Encoding: base58
*/
signature: string;
standard: MultiPayload.standard;
} | {
payload: string;
/**
* Encoding: base58
*/
public_key: string;
/**
* Encoding: base58
*/
signature: string;
standard: MultiPayload.standard;
} | {
/**
* Base64Url-encoded [authenticatorData](https://w3c.github.io/webauthn/#authenticator-data). Encoding: base64
*/
authenticator_data: string;
/**
* Serialized [clientDataJSON](https://w3c.github.io/webauthn/#dom-authenticatorresponse-clientdatajson)
*/
client_data_json: string;
payload: string;
standard: MultiPayload.standard;
/**
* Encoding: base58
*/
public_key: string;
/**
* Encoding: base58
*/
signature: string;
} | {
/**
* Wallet address in either [Raw](https://docs.ton.org/v3/documentation/smart-contracts/addresses/address-formats#raw-address) representation or [user-friendly](https://docs.ton.org/v3/documentation/smart-contracts/addresses/address-formats#user-friendly-address) format
*/
address: string;
/**
* dApp domain
*/
domain: string;
/**
* See <https://docs.tonconsole.com/academy/sign-data#choosing-the-right-format>
*/
payload: {
text: string;
type: MultiPayload.type;
};
/**
* Encoding: base58
*/
public_key: string;
/**
* Encoding: base58
*/
signature: string;
standard: MultiPayload.standard;
/**
* UNIX timestamp (in seconds or RFC3339) at the time of singing
*/
timestamp: (string | number);
});
declare namespace MultiPayload {
enum standard {
NEP413 = "nep413"
}
enum type {
TEXT = "text"
}
}
type AuthenticateRequestDto = {
signedData: MultiPayload;
};
type AuthenticateResponseDto = {
/**
* JWT access token for API calls
*/
accessToken: string;
/**
* JWT refresh token for getting new access tokens
*/
refreshToken: string;
/**
* Access token expiration time in seconds
*/
expiresIn: number;
/**
* Refresh token expiration time in seconds
*/
refreshExpiresIn: number;
};
type BadRequestResponse = {
message: string;
};
type BalanceEntry = {
/**
* Token identifier
*/
tokenId: string;
/**
* Available balance (as string to preserve precision)
*/
available: string;
/**
* Balance source
*/
source: BalanceEntry.source;
};
declare namespace BalanceEntry {
/**
* Balance source
*/
enum source {
PRIVATE = "private"
}
}
type ChainDepositAddress = {
/**
* Blockchain on which this deposit address accepts funds for the quote.
*/
blockchain: ChainDepositAddress.blockchain;
/**
* Deposit address on `blockchain`. Funds sent here are credited to the same Intents account.
*/
address: string;
/**
* Memo required together with `address` on chains that need it (e.g. Stellar, XRP, TON).
*/
memo?: string;
};
declare namespace ChainDepositAddress {
/**
* Blockchain on which this deposit address accepts funds for the quote.
*/
enum blockchain {
NEAR = "near",
ETH = "eth",
BASE = "base",
ARB = "arb",
BTC = "btc",
SOL = "sol",
TON = "ton",
DASH = "dash",
DOGE = "doge",
XRP = "xrp",
ZEC = "zec",
GNOSIS = "gnosis",
BERA = "bera",
BSC = "bsc",
POL = "pol",
TRON = "tron",
SUI = "sui",
MOVEMENT = "movement",
OP = "op",
AVAX = "avax",
STELLAR = "stellar",
APTOS = "aptos",
CARDANO = "cardano",
LTC = "ltc",
XLAYER = "xlayer",
MONAD = "monad",
BCH = "bch",
ADI = "adi",
PLASMA = "plasma",
SCROLL = "scroll",
STARKNET = "starknet",
ALEO = "aleo",
HYPERCORE = "hypercore"
}
}
type Deadline = string;
type DefuseConfig = {
fees: {
/**
* 1 pip == 1/100th of bip == 0.0001%
*/
fee: number;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
fee_collector: string;
};
roles?: {
admins?: Record<string, Array<string>>;
grantees?: Record<string, Array<string>>;
super_admins?: Array<string>;
};
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
wnear_id: string;
};
type DefusePayload_for_DefuseIntents = {
deadline: string;
/**
* Sequence of intents to execute in given order. Empty list is also a valid sequence, i.e. it doesn't do anything, but still invalidates the `nonce` for the signer WARNING: Promises created by different intents are executed concurrently and does not rely on the order of the intents in this structure
*/
intents?: Array<({
intent: 'add_public_key';
/**
* Encoding: base58
*/
public_key: string;
} | {
intent: 'remove_public_key';
/**
* Encoding: base58
*/
public_key: string;
} | {
intent: 'transfer';
memo?: string | null;
/**
* Minimum gas for `mt_on_transfer()`
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* Message to pass to `mt_on_transfer`
*/
msg?: string;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
receiver_id: string;
/**
* Optionally initialize the receiver's contract (Deterministic AccountId) via [`state_init`](https://github.com/near/NEPs/blob/master/neps/nep-0616.md#stateinit-action) right before calling `mt_on_transfer()` (in the same receipt).
*/
state_init?: {
code: ({
hash: string;
} | {
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
account_id: string;
});
data: Record<string, string>;
version: 'v1';
} | null;
tokens: Record<string, string>;
} | {
amount: string;
intent: 'ft_withdraw';
memo?: string | null;
/**
* Optional minimum required Near gas for created Promise to succeed: * `ft_transfer`: minimum: 15TGas, default: 15TGas * `ft_transfer_call`: minimum: 30TGas, default: 50TGas
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* Message to pass to `ft_transfer_call`. Otherwise, `ft_transfer` will be used. NOTE: No refund will be made in case of insufficient `storage_deposit` on `token` for `receiver_id`
*/
msg?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
receiver_id: string;
/**
* Optionally make `storage_deposit` for `receiver_id` on `token`. The amount will be subtracted from user's NEP-141 `wNEAR` balance. NOTE: the `wNEAR` will not be refunded in case of fail
*/
storage_deposit?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
token: string;
} | {
intent: 'nft_withdraw';
memo?: string | null;
/**
* Optional minimum required Near gas for created Promise to succeed: * `nft_transfer`: minimum: 15TGas, default: 15TGas * `nft_transfer_call`: minimum: 30TGas, default: 50TGas
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* Message to pass to `nft_transfer_call`. Otherwise, `nft_transfer` will be used. NOTE: No refund will be made in case of insufficient `storage_deposit` on `token` for `receiver_id`
*/
msg?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
receiver_id: string;
/**
* Optionally make `storage_deposit` for `receiver_id` on `token`. The amount will be subtracted from user's NEP-141 `wNEAR` balance. NOTE: the `wNEAR` will not be refunded in case of fail
*/
storage_deposit?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
token: string;
token_id: string;
} | {
amounts: Array<string>;
intent: 'mt_withdraw';
memo?: string | null;
/**
* Optional minimum required Near gas for created Promise to succeed per token: * `mt_batch_transfer`: minimum: 20TGas, default: 20TGas * `mt_batch_transfer_call`: minimum: 35TGas, default: 50TGas
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* Message to pass to `mt_batch_transfer_call`. Otherwise, `mt_batch_transfer` will be used. NOTE: No refund will be made in case of insufficient `storage_deposit` on `token` for `receiver_id`
*/
msg?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
receiver_id: string;
/**
* Optionally make `storage_deposit` for `receiver_id` on `token`. The amount will be subtracted from user's NEP-141 `wNEAR` balance. NOTE: the `wNEAR` will not be refunded in case of fail
*/
storage_deposit?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
token: string;
token_ids: Array<string>;
} | {
amount: string;
intent: 'native_withdraw';
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
receiver_id: string;
} | {
amount: string;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
contract_id: string;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
deposit_for_account_id: string;
intent: 'storage_deposit';
} | {
diff: Record<string, string>;
intent: 'token_diff';
memo?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
referral?: string | null;
} | {
enabled: boolean;
intent: 'set_auth_by_predecessor_id';
} | {
/**
* Optionally, attach deposit to [`.on_auth`](::defuse_auth_call::AuthCallee::on_auth) call. The amount will be subtracted from user's NEP-141 `wNEAR` balance.
*
* NOTE: the `wNEAR` will not be refunded in case of fail.
*/
attached_deposit?: string;
/**
* Callee for [`.on_auth`](::defuse_auth_call::AuthCallee::on_auth)
*/
contract_id: string;
intent: 'auth_call';
/**
* Optional minimum gas required for created promise to succeed. By default, only [`MIN_GAS_DEFAULT`](AuthCall::MIN_GAS_DEFAULT) is required.
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* `msg` to pass in [`.on_auth`](::defuse_auth_call::AuthCallee::on_auth)
*/
msg: string;
/**
* Optionally initialize the receiver's contract (Deterministic AccountId) via [`state_init`](https://github.com/near/NEPs/blob/master/neps/nep-0616.md#stateinit-action) right before calling [`.on_auth()`](::defuse_auth_call::AuthCallee::on_auth) (in the same receipt).
*/
state_init?: {
code: ({
hash: string;
} | {
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
account_id: string;
});
data: Record<string, string>;
version: 'v1';
} | null;
} | {
intent: 'imt_mint';
memo?: string | null;
/**
* Minimum gas for `mt_on_transfer()`
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* Message to pass to `mt_on_transfer`
*/
msg?: string;
/**
* Receiver of the minted tokens
*/
receiver_id: string;
/**
* Optionally initialize the receiver's contract (Deterministic AccountId) via [`state_init`](https://github.com/near/NEPs/blob/master/neps/nep-0616.md#stateinit-action) right before calling `mt_on_transfer()` (in the same receipt).
*/
state_init?: {
code: ({
hash: string;
} | {
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
account_id: string;
});
data: Record<string, string>;
version: 'v1';
} | null;
/**
* The token_ids will be wrapped to bind the token ID to the minter authority (i.e. signer of this intent). The final string representation of the token will be as follows: `imt:<minter_id>:<token_id>`
*/
tokens: Record<string, string>;
} | {
intent: 'imt_burn';
memo?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
minter_id: string;
/**
* The token_ids will be wrapped to bind the token ID to the minter authority. The final string representation of the token will be as follows: `imt:<minter_id>:<token_id>`
*/
tokens: Record<string, string>;
})>;
/**
* Encoding: base64
*/
nonce: string;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
signer_id: string;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
verifying_contract: string;
};
/**
* See [ERC-191](https://github.com/ethereum/ercs/blob/master/ERCS/erc-191.md)
*/
type Erc191Payload = string;
type FeesConfig = {
/**
* 1 pip == 1/100th of bip == 0.0001%
*/
fee: number;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
fee_collector: string;
};
/**
* Withdraw given FT tokens from the intents contract to a given external account id (external being outside of intents).
*/
type FtWithdraw = {
amount: string;
memo?: string | null;
/**
* Optional minimum required Near gas for created Promise to succeed: * `ft_transfer`: minimum: 15TGas, default: 15TGas * `ft_transfer_call`: minimum: 30TGas, default: 50TGas
*
* Remaining gas will be distributed evenly across all Function Call Promises created during execution of current receipt.
*/
min_gas?: string | null;
/**
* Message to pass to `ft_transfer_call`. Otherwise, `ft_transfer` will be used. NOTE: No refund will be made in case of insufficient `storage_deposit` on `token` for `receiver_id`
*/
msg?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
receiver_id: string;
/**
* Optionally make `storage_deposit` for `receiver_id` on `token`. The amount will be subtracted from user's NEP-141 `wNEAR` balance. NOTE: the `wNEAR` will not be refunded in case of fail
*/
storage_deposit?: string | null;
/**
* NEAR Account Identifier.
*
* This is a unique, syntactically valid, human-readable account identifier on the NEAR network.
*
* [See the crate-level docs for information about validation.](index.html#account-id-rules)
*
* Also see [Error kind precedence](AccountId#error-kind-precedence).
*
* ## Examples
*
* ``` use near_account_id::AccountId;
*
* let alice: AccountId = "alice.near".parse().unwrap();
*
* assert!("ƒelicia.near".parse::<AccountId>().is_err()); // (ƒ is not f) ```
*/
token: string;
};
type MultiPayloadErc191Narrowed = {
standard: 'erc191';
payload: Erc191Payload;
};
/**
* See [NEP-413](https://github.com/near/NEPs/blob/master/neps/nep-0413.md)
*/
type Nep413Payload = {
callbackUrl?: string | null;
message: string;
/**
* Encoding: base64
*/
nonce: string;
recipient: string;
};
type MultiPayloadNep413Narrowed = {
standard: 'nep413';
payload: Nep413Payload;
};
/**
* Raw Ed25519 payload is an inline string
*/
type MultiPayloadRawEd25519Narrowed = {
standard: 'raw_ed25519';
payload: string;
};
/**
* Sep53 payload is an inline string
*/
type MultiPayloadSep53Narrowed = {
standard: 'sep53';
payload: string;
};
/**
* See [TIP-191](https://github.com/tronprotocol/tips/blob/master/tip-191.md)
*/
type Tip191Payload = string;
type MultiPayloadTip191Narrowed = {
standard: 'tip191';
payload: Tip191Payload;
};
/**
* See <https://docs.tonconsole.com/academy/sign-data#choosing-the-right-format>
*/
type TonConnectPayloadSchema = {
text: string;
type: TonConnectPayloadSchema.type;
};
declare namespace TonConnectPayloadSchema {
enum type {
TEXT = "text"
}
}
type MultiPayloadTonConnectNarrowed = {
standard: 'ton_connect';
payload: TonConnectPayloadSchema;
};
/**
* Webauthn payload is an inline string
*/
type MultiPayloadWebauthnNarrowed = {
standard: 'webauthn';
payload: string;
};
/**
* Narrowed MultiPayload union with only 'standard' and 'payload' properties exposed
*/
type MultiPayloadNarrowed = (MultiPayloadNep413Narrowed | MultiPayloadErc191Narrowed | MultiPayloadTip191Narrowed | MultiPayloadRawEd25519Narrowed | MultiPayloadWebauthnNarrowed | MultiPayloadTonConnectNarrowed | MultiPayloadSep53Narrowed);
type GenerateIntentResponse = {
intent: MultiPayloadNarrowed;
/**
* Unique identifier for tracing this request
*/
correlationId: string;
};
declare enum IntentStandardEnum {
NEP413 = "nep413",
ERC191 = "erc191",
RAW_ED25519 = "raw_ed25519",
WEBAUTHN = "webauthn",
TON_CONNECT = "ton_connect",
SEP53 = "sep53",
TIP191 = "tip191"
}
type GenerateSwapTransferIntentRequest = {
/**
* The type of intent action
*/
type: GenerateSwapTransferIntentRequest.type;
/**
* The standard used for signing the intent
*/
standard: IntentStandardEnum;
/**
* The account ID of the signer
*/
signerId: string;
/**
* The deposit address from the quote response
*/
depositAddress: string;
};
declare namespace GenerateSwapTransferIntentRequest {
/**
* The type of intent action
*/
enum type {
SWAP_TRANSFER = "swap_transfer"
}
}
type GetAnyInputQuoteWithdrawals = {
/**
* ID of the destination asset.
*/
asset: string;
/**
* Recipient address
*/
recipient: string;
/**
* Affiliate recipient address
*/
affiliateRecipient: string;
/**
* Details of withdrawals
*/
withdrawals?: AnyInputQuoteWithdrawal;
};
type GetBalancesResponse = {
/**
* List of token balances
*/
balances: Array<BalanceEntry>;
};
type Quote = {
/**
* The deposit address on the chain of `originAsset` when `depositType` is `ORIGIN_CHAIN`.
*
* The deposit address inside NEAR Intents (the verifier smart contract) when `depositType` is `INTENTS`.
*
* The account ID within Confidential Intents to which assets are to be transferred when `depositType` is `CONFIDENTIAL_INTENTS`. Fund the swap by submitting a signed transfer intent to this value. Direct token transfers are not supported.
*/
depositAddress?: string;
/**
* Some deposit addresses **REQUIRE** a `memo` together with `depositAddress` for the deposit to be processed. This field is deposit-side metadata.
*/
depositMemo?: string;
/**
* Deposit addresses across all bridge-supported blockchains for funding the same Intents account. Present only for public `ANY_INPUT` quotes (`depositType` `INTENTS`); the confidential rail does not support multi-chain funding addresses yet. Each entry forwards to the Intents account in `depositAddress`, so the user may deposit from any listed chain.
*/
chainDepositAddresses?: Array<ChainDepositAddress>;
/**
* Amount of the origin asset
*/
amountIn: string;
/**
* Amount of the origin asset in readable format
*/
amountInFormatted: string;
/**
* Amount of the origin assets equivalent in USD
*/
amountInUsd: string;
/**
* Minimum amount of the origin asset that will be used for the swap
*/
minAmountIn: string;
/**
* Amount of the destination asset
*/
amountOut: string;
/**
* Amount of the destination asset in readable format
*/
amountOutFormatted: string;
/**
* Amount of the destination asset equivalent in USD
*/
amountOutUsd: string;
/**
* Minimum output amount after slippage is applied
*/
minAmountOut: string;
/**
* Time when the deposit address becomes inactive and funds may be lost
*/
deadline?: string;
/**
* Time when the deposit address becomes cold, causing swap processing to take longer
*/
timeWhenInactive?: string;
/**
* Estimated time in seconds for the swap to be executed after the deposit transaction is confirmed
*/
timeEstimate: number;
/**
* EVM address of a transfer recipient in a virtual chain
*/
virtualChainRecipient?: string;
/**
* EVM address of a refund recipient in a virtual chain
*/
virtualChainRefundRecipient?: string;
/**
* **HIGHLY EXPERIMENTAL** Message passed to `ft_transfer_call` when withdrawing assets to NEAR.
*
* Otherwise, `ft_transfer` will be used.
*
* **WARNING**: Funds will be lost if used with non NEP-141 tokens, in case of insufficient `storage_deposit` or if the recipient does not implement `ft_on_transfer` method.
*/
customRecipientMsg?: string;
/**
* Fee charged for refunding assets to the refund address in the smallest unit of the origin asset
*/
refundFee?: string;
/**
* Fee charged for withdrawing assets to the recipient in the smallest unit of the destination asset. This fee is already accounted for in the final amountOut result
*/
withdrawFee?: string;
};
type Rebate = {
/**
* Confidential Intents account identifier that receives this rebate share. Rebate delivery uses signed transfer intent on Confidential Intents; direct token transfers are not supported.
*/
recipient: string;
/**
* Rebate share for this recipient in percent.
*/
share: number;
};
type QuoteRequest = {
/**
* Flag indicating whether this is a dry run request.
* If `true`, the response will **NOT** contain the following fields:
* - `depositAddress`
* - `timeWhenInactive`
* - `deadline`
*/
dry: boolean;
/**
* What deposit address mode you will get in the response, most chain supports only `SIMPLE` and some(for example `stellar`) only `MEMO`:
* - `SIMPLE` - usual deposit with only deposit address.
* - `MEMO` - some chains will **REQUIRE** the `memo` together with `depositAddress` for swap to work.
*
* `depositMode` applies only to deposit transaction metadata.
*/
depositMode?: QuoteRequest.depositMode;
/**
* How to interpret `amount` (and refunds) when performing the swap:
*
* - `EXACT_INPUT` — requests the output amount for an exact input.
* - If deposit is less than `amountIn`, the deposit is refunded by deadline.
* - If deposit is above than `amountIn`, the swap is processed and the excess is refunded to `refundTo` address after swap is complete.
*
* - `EXACT_OUTPUT` — requests the input amount for an exact output.
* - The output amount (`amountOut`) is fixed; slippage is applied to the **input** side.
* - The quote response includes `amountIn` (the proposed input with slippage tolerance baked in) and `minAmountIn` (the minimum input required).
* - **Important**: `amountIn` will appear higher than `minAmountIn` by approximately your `slippageTolerance`. This is **not** price degradation—it is a buffer to ensure successful execution. Any input amount above what is actually needed for the swap is **refunded** to your `refundTo` address after the swap completes.
* - If the deposit is above `amountIn`, the swap is processed and the excess is refunded to `refundTo` address after swap is complete.
* - If the deposit is less than `minAmountIn`, the deposit is refunded by deadline.
*
* - `FLEX_INPUT` — a flexible input amount that allows for partial deposits and variable amounts.
* - `slippage` applies both to `amountOut` and `amountIn` and defines an acceptable range (`minAmountIn` and `minAmountOut`).
* - Any amount higher than `minAmountIn` is accepted and converted to the output asset as long as `minAmountOut` is met.
* - The deposit must be at least `minAmountIn`, after applying the slippage constraint to the quoted amount. Deposits below `minAmountIn` are refunded if the total received by the deadline is below this amount.
* - If deposits exceed the upper bound, the swap is still processed
*
* - `ANY_INPUT` — collects deposits and converts them to a destination asset. Used for fee aggregation and similar use cases. Only available for authorized partners.
*/
swapType: QuoteRequest.swapType;
/**
* Slippage tolerance for the swap. This value is in basis points (1/100th of a percent), e.g. 100 for 1% slippage.
*/
slippageTolerance: number;
/**
* ID of the origin asset.
*/
originAsset: string;
/**
* Type of deposit address:
* - `ORIGIN_CHAIN` - deposit address on the origin chain.
* - `INTENTS` - the account ID within NEAR Intents to which you should transfer assets.
* - `CONFIDENTIAL_INTENTS` - the account ID within Confidential Intents to which assets are to be transferred. Fund the swap from a Confidential Intents account by submitting a signed transfer intent to the quote `depositAddress`. Direct token transfers are not supported.
*/
depositType: QuoteRequest.depositType;
/**
* ID of the destination asset.
*/
destinationAsset: string;
/**
* Amount to swap as the base amount. It is interpreted as the input or output amount based on the `swapType` flag and is specified in the smallest unit of the currency (e.g., wei for ETH). Must be an integer string; decimal values like "0.01" are invalid—use base units (e.g. "10000000000000000" for 0.01 with 18 decimals).
*/
amount: string;
/**
* Address used for refunds.
*/
refundTo: string;
/**
* Type of refund address:
* - `ORIGIN_CHAIN` - assets are refunded to the `refundTo` address on the origin chain.
* - `INTENTS` - assets are refunded to the `refundTo` Intents account.
* - `CONFIDENTIAL_INTENTS` - assets are refunded to the `refundTo` Confidential Intents account. On Confidential Intents, 1Click settles refunds via signed transfer intent rather than direct token transfer.
*/
refundType: QuoteRequest.refundType;
/**
* Recipient address. The format must match `recipientType`. Destination routing metadata, when required, must be encoded according to the destination chain address format.
*/
recipient: string;
/**
* Addresses of connected wallets.
*/
connectedWallets?: Array<string>;
/**
* Unique client session identifier for 1Click.
*/
sessionId?: string;
/**
* EVM address of a transfer recipient in a virtual chain
*/
virtualChainRecipient?: string;
/**
* EVM address of a refund recipient in a virtual chain
*/
virtualChainRefundRecipient?: string;
/**
* **HIGHLY EXPERIMENTAL** Message to pass to `ft_transfer_call` when withdrawing assets to NEAR.
*
* Otherwise, `ft_transfer` will be used.
*
* **WARNING**: Funds will be lost if used with non NEP-141 tokens, in case of insufficient `storage_deposit` or if the recipient does not implement `ft_on_transfer` method.
*/
customRecipientMsg?: string;
/**
* Type of recipient address:
* - `DESTINATION_CHAIN` - assets are transferred to the chain of `destinationAsset`.
* - `INTENTS` - assets are transferred to an account inside Intents.
* - `CONFIDENTIAL_INTENTS` - assets are transferred to the `recipient` account inside Confidential Intents. On Confidential Intents, 1Click settles swap output via signed transfer intent rather than direct token transfer.
*/
recipientType: QuoteRequest.recipientType;
/**
* Timestamp in ISO format that identifies when the user refund begins if the swap isn't completed by then. It must exceed the time required for the deposit transaction to be mined. For example, Bitcoin may require around one hour depending on the fees paid.
*/
deadline: string;
/**
* Confidentiality mode for this quote. Invite-only for now: if set, API may return an invite-only message until rollout is enabled for your integration.
*/
confidentiality?: QuoteRequest.confidentiality;
/**
* Distribution channel / venue identifier (for example: ledger, trustwallet). Keep lowercase for consistency.
*/
referral?: string;
/**
* Rebate distribution for this quote. Provide up to 3 confidential Intents recipients (for example, `rebate-recipient.near` on confidential Intents); each item defines a recipient and its percent share, and all shares must add up to 100.
*/
rebates?: Array<Rebate>;
/**
* Time in milliseconds the user is willing to wait for a quote from the relay.
* **Defaults to 0ms delay if not specified, if you want to receive the fastest quote.
*/
quoteWaitingTimeMs?: number;
/**
* List of recipients and their fees
*/
appFees?: Array<AppFee>;
}