rango-sdk 0.5.1-next.1 → 0.5.1-next.2
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/lib/index.js.map +1 -1
- package/lib/types/api/meta.d.ts +1 -1
- package/lib/types/api/meta.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/services/client.ts +32 -32
- package/src/types/api/meta.ts +4 -1
package/lib/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/services/client.ts", "../../rango-types/src/api/shared/type-gaurds.ts", "../../rango-types/src/api/shared/routing.ts", "../../rango-types/src/api/shared/transactions.ts", "../../rango-types/src/api/shared/txs/cosmos.ts", "../../rango-types/src/api/shared/txs/solana.ts", "../../rango-types/src/api/shared/txs/transfer.ts", "../../rango-types/src/api/shared/txs/tron.ts", "../../rango-types/src/api/shared/txs/ton.ts", "../../rango-types/src/api/main/txs/evm.ts"],
|
|
4
|
-
"sourcesContent": ["import uuid from 'uuid-random'\nimport {\n MetaRequest,\n MetaResponse,\n BestRouteRequest,\n BestRouteResponse,\n CheckApprovalResponse,\n CheckTxStatusRequest,\n TransactionStatusResponse,\n CreateTransactionRequest,\n CreateTransactionResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n RequestOptions,\n BlockchainMeta,\n CompactMetaResponse,\n CompactToken,\n Token,\n MultiRouteRequest,\n MultiRouteResponse,\n ConfirmRouteResponse,\n ConfirmRouteRequest,\n CustomTokenRequest,\n CustomTokenResponse,\n TokenBalanceResponse,\n TokenBalanceRequest,\n SwapperMetaExtended,\n MultipleTokenBalanceRequest,\n MultipleTokenBalanceResponse,\n SearchCustomTokensRequest,\n SearchCustomTokensResponse,\n} from '../types'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddresses = { blockchain: string; address: string }[]\n\nexport class RangoClient {\n private readonly deviceId: string\n private readonly apiKey: string\n private readonly apiUrl: string\n private readonly httpService: AxiosInstance\n\n constructor(apiKey: string, apiUrl?: string) {\n this.apiUrl = apiUrl || 'https://api.rango.exchange'\n this.apiKey = apiKey\n try {\n if (typeof window !== 'undefined') {\n const deviceId = localStorage.getItem('deviceId')\n if (deviceId) {\n this.deviceId = deviceId\n } else {\n const generatedId = uuid()\n localStorage.setItem('deviceId', generatedId)\n this.deviceId = generatedId\n }\n } else {\n this.deviceId = uuid()\n }\n } catch (e) {\n this.deviceId = uuid()\n }\n this.httpService = axios.create({\n baseURL: this.apiUrl,\n })\n }\n\n public async getAllMetadata(\n metaRequest?: MetaRequest,\n options?: RequestOptions\n ): Promise<MetaResponse> {\n const params = {\n ...metaRequest,\n blockchains: metaRequest?.blockchains?.join(),\n swappers: metaRequest?.swappers?.join(),\n swappersGroups: metaRequest?.swappersGroups?.join(),\n transactionTypes: metaRequest?.transactionTypes?.join(),\n }\n const axiosResponse = await this.httpService.get<CompactMetaResponse>(\n `/meta/compact?apiKey=${this.apiKey}`,\n {\n params,\n ...options,\n }\n )\n const reformatTokens = (tokens: CompactToken[]): Token[] =>\n tokens.map((tm) => ({\n blockchain: tm.b,\n symbol: tm.s,\n image: tm.i,\n address: tm.a || null,\n usdPrice: tm.p || null,\n isSecondaryCoin: tm.is || false,\n coinSource: tm.c || null,\n coinSourceUrl: tm.cu || null,\n name: tm.n || null,\n decimals: tm.d,\n isPopular: tm.ip || false,\n supportedSwappers: tm.ss || [],\n }))\n\n const tokens = reformatTokens(axiosResponse.data.tokens)\n const popularTokens = reformatTokens(axiosResponse.data.popularTokens)\n return { ...axiosResponse.data, tokens, popularTokens }\n }\n\n public async getBlockchains(\n options?: RequestOptions\n ): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async getSwappers(\n options?: RequestOptions\n ): Promise<SwapperMetaExtended[]> {\n const axiosResponse = await this.httpService.get<SwapperMetaExtended[]>(\n `/meta/swappers?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async getCustomToken(\n customTokenRequest?: CustomTokenRequest,\n options?: RequestOptions\n ): Promise<CustomTokenResponse> {\n const axiosResponse = await this.httpService.get<CustomTokenResponse>(\n `/meta/custom-token?apiKey=${this.apiKey}`,\n { params: customTokenRequest, ...options }\n )\n return axiosResponse.data\n }\n\n public async searchCustomTokens(\n searchCustomTokensRequest: SearchCustomTokensRequest,\n options?: RequestOptions\n ): Promise<SearchCustomTokensResponse> {\n const axiosResponse =\n await this.httpService.get<SearchCustomTokensResponse>(\n `/meta/token/search?apiKey=${this.apiKey}`,\n { params: searchCustomTokensRequest, ...options }\n )\n return axiosResponse.data\n }\n\n public async getBestRoute(\n requestBody: BestRouteRequest,\n options?: RequestOptions\n ): Promise<BestRouteResponse> {\n const axiosResponse = await this.httpService.post<BestRouteResponse>(\n `/routing/best?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options }\n )\n return axiosResponse.data\n }\n\n public async getAllRoutes(\n requestBody: MultiRouteRequest,\n options?: RequestOptions\n ): Promise<MultiRouteResponse> {\n const axiosResponse = await this.httpService.post<MultiRouteResponse>(\n `/routing/bests?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options }\n )\n return axiosResponse.data\n }\n\n public async confirmRoute(\n requestBody: ConfirmRouteRequest,\n options?: RequestOptions\n ): Promise<ConfirmRouteResponse> {\n const axiosResponse = await this.httpService.post<ConfirmRouteResponse>(\n `/routing/confirm?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options }\n )\n return axiosResponse.data\n }\n\n // @deprecated use confirmRoute instead\n public async confirmRouteRequest(\n requestBody: ConfirmRouteRequest,\n options?: RequestOptions\n ): Promise<ConfirmRouteResponse> {\n const axiosResponse = await this.httpService.post<ConfirmRouteResponse>(\n `/routing/confirm?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options }\n )\n return axiosResponse.data\n }\n\n public async checkApproval(\n requestId: string,\n txId?: string,\n options?: RequestOptions\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/tx/${requestId}/check-approval?apiKey=${this.apiKey}`,\n { params: { txId }, ...options }\n )\n return axiosResponse.data\n }\n\n public async checkStatus(\n requestBody: CheckTxStatusRequest,\n options?: RequestOptions\n ): Promise<TransactionStatusResponse> {\n const axiosResponse =\n await this.httpService.post<TransactionStatusResponse>(\n `/tx/check-status?apiKey=${this.apiKey}`,\n requestBody,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async createTransaction(\n requestBody: CreateTransactionRequest,\n options?: RequestOptions\n ): Promise<CreateTransactionResponse> {\n const axiosResponse =\n await this.httpService.post<CreateTransactionResponse>(\n `/tx/create?apiKey=${this.apiKey}`,\n requestBody,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async reportFailure(\n requestBody: ReportTransactionRequest,\n options?: RequestOptions\n ): Promise<void> {\n await this.httpService.post(\n `/tx/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n ...options,\n }\n )\n }\n\n public async getWalletsDetails(\n walletAddresses: WalletAddresses,\n options?: RequestOptions\n ): Promise<WalletDetailsResponse> {\n let walletAddressesQueryParams = ''\n for (let i = 0; i < walletAddresses.length; i++) {\n const walletAddress = walletAddresses[i]\n walletAddressesQueryParams += `&address=${walletAddress.blockchain}.${walletAddress.address}`\n }\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/wallets/details?apiKey=${this.apiKey}${walletAddressesQueryParams}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async getTokenBalance(\n tokenBalanceRequest: TokenBalanceRequest,\n options?: RequestOptions\n ): Promise<TokenBalanceResponse> {\n const axiosResponse = await this.httpService.get<TokenBalanceResponse>(\n `/wallets/token-balance?apiKey=${this.apiKey}`,\n { params: tokenBalanceRequest, ...options }\n )\n return axiosResponse.data\n }\n\n public async getMultipleTokenBalance(\n requestBody: MultipleTokenBalanceRequest,\n options?: RequestOptions\n ): Promise<MultipleTokenBalanceResponse> {\n const axiosResponse =\n await this.httpService.post<MultipleTokenBalanceResponse>(\n `/wallets/multiple-token-balance?apiKey=${this.apiKey}`,\n requestBody,\n { ...options }\n )\n return axiosResponse.data\n }\n}\n", "import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n HyperliquidBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\n XrplBlockchainMeta,\n} from './meta.js'\n\nexport const isEvmBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is EvmBlockchainMeta => blockchainMeta.type === 'EVM'\n\nexport const isCosmosBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is CosmosBlockchainMeta => blockchainMeta.type === 'COSMOS'\n\nexport const isSolanaBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is SolanaBlockchainMeta => blockchainMeta.type === 'SOLANA'\n\nexport const isTronBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is TronBlockchainMeta => blockchainMeta.type === 'TRON'\n\nexport const isTransferBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is TransferBlockchainMeta =>\n blockchainMeta.type === 'TRANSFER'\n\nexport const isStarknetBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is StarkNetBlockchainMeta =>\n blockchainMeta.type === 'STARKNET'\n\nexport const isTonBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is TonBlockchainMeta => blockchainMeta.type === 'TON'\n\nexport const isXrplBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is XrplBlockchainMeta => blockchainMeta.type === 'XRPL'\n\nexport const isHyperliquidBlockchain = (\n blockchainMeta: BlockchainMeta\n): blockchainMeta is HyperliquidBlockchainMeta =>\n blockchainMeta.type === 'HYPERLIQUID'\n\nexport const evmBlockchains = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isEvmBlockchain)\n\nexport const solanaBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isSolanaBlockchain)\n\nexport const starknetBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isStarknetBlockchain)\n\nexport const tronBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isTronBlockchain)\n\nexport const cosmosBlockchains = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isCosmosBlockchain)\n\nexport const transferBlockchains = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isTransferBlockchain)\n\nexport const tonBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isTonBlockchain)\n\nexport const xrplBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isXrplBlockchain)\n\nexport const hyperliquidBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isHyperliquidBlockchain)\n", "/**\n * Routing Result Type\n *\n */\nexport enum RoutingResultType {\n OK = 'OK',\n HIGH_IMPACT = 'HIGH_IMPACT',\n NO_ROUTE = 'NO_ROUTE',\n INPUT_LIMIT_ISSUE = 'INPUT_LIMIT_ISSUE',\n HIGH_IMPACT_FOR_CREATE_TX = 'HIGH_IMPACT_FOR_CREATE_TX',\n}\n", "/** The type of transaction */\nexport enum TransactionType {\n EVM = 'EVM',\n TRANSFER = 'TRANSFER',\n COSMOS = 'COSMOS',\n SOLANA = 'SOLANA',\n TRON = 'TRON',\n STARKNET = 'STARKNET',\n TON = 'TON',\n SUI = 'SUI',\n XRPL = 'XRPL',\n STELLAR = 'STELLAR',\n HYPERLIQUID = 'HYPERLIQUID',\n}\n\n/**\n * The type of transaction\n * @deprecated use TransactionType instead\n */\nexport enum GenericTransactionType {\n EVM = 'EVM',\n TRANSFER = 'TRANSFER',\n COSMOS = 'COSMOS',\n SOLANA = 'SOLANA',\n}\n\n/** A transaction's url that can be displayed to advanced user to track the progress */\nexport type SwapExplorerUrl = {\n /** A custom display name to help user distinguish the transactions from each other. Example: Inbound, Outbound, Bridge, or null */\n description: string | null\n /** Url of the transaction in blockchain explorer. example: https://etherscan.io/tx/0xa1a3... */\n url: string\n}\n\n/**\n * APIErrorCode\n *\n * Error code of a swap failure\n */\nexport type APIErrorCode =\n | 'TX_FAIL'\n | 'TX_EXPIRED'\n | 'FETCH_TX_FAILED'\n | 'USER_REJECT'\n | 'USER_CANCEL'\n | 'USER_CANCELED_TX'\n | 'CALL_WALLET_FAILED'\n | 'SEND_TX_FAILED'\n | 'CALL_OR_SEND_FAILED'\n | 'TX_FAILED_IN_BLOCKCHAIN'\n | 'CLIENT_UNEXPECTED_BEHAVIOUR'\n | 'INSUFFICIENT_APPROVE'\n\n/**\n * The function checks if a given string value is a valid API error code.\n * @param {string} value - a string that represents a possible API error code.\n * @returns A boolean value is being returned, indicating whether the input `value` is of type\n * `APIErrorCode` or not.\n */\nexport function isAPIErrorCode(value: string): value is APIErrorCode {\n return [\n 'TX_FAIL',\n 'TX_EXPIRED',\n 'FETCH_TX_FAILED',\n 'USER_REJECT',\n 'USER_CANCEL',\n 'USER_CANCELED_TX',\n 'CALL_WALLET_FAILED',\n 'SEND_TX_FAILED',\n 'CALL_OR_SEND_FAILED',\n 'TX_FAILED_IN_BLOCKCHAIN',\n 'CLIENT_UNEXPECTED_BEHAVIOUR',\n 'INSUFFICIENT_APPROVE',\n ].includes(value)\n}\n\n/**\n * ReportTransactionRequest\n *\n * It should be used when an error happened in client and we want to inform server that transaction failed,\n * E.g. user rejected the transaction dialog or and an RPC error raised during signing tx by user.\n */\nexport type ReportTransactionRequest = {\n /** The requestId from best route endpoint */\n requestId: string\n /** Type of the event that happened, example: USER_REJECT */\n eventType: APIErrorCode\n /** Step number in which failure happened */\n step?: number\n /** Reason or message for the error */\n reason?: string\n /** @deprecated A list of key-value for extra details */\n data?: { [key: string]: string }\n /** A list of key-value for pre-defined tags */\n tags?: { wallet?: string; errorCode?: string }\n}\n\n/** The status of transaction in tracking */\nexport enum TransactionStatus {\n FAILED = 'failed',\n RUNNING = 'running',\n SUCCESS = 'success',\n}\n\n/**\n * Response body of check-approval\n * You could stop check approval if:\n * 1- approved successfully\n * => isApproved = true\n * 2- approval transaction failed\n * => isApproved = false && txStatus === 'failed'\n * 3- approval transaction succeeded but currentApprovedAmount is still less than requiredApprovedAmount\n * (e.g. user changed transaction data and enter another approve amount in MetaMask)\n * => isApproved = false && txStatus == 'success'\n */\nexport type CheckApprovalResponse = {\n /** A flag which indicates that the approve tx is done or not */\n isApproved: boolean\n /**\n * Status of approve transaction in blockchain,\n * if isArppoved is false and txStatus is failed, it seems that approve transaction failed in blockchain\n */\n txStatus: TransactionStatus | null\n /** required amount to be approved by user */\n requiredApprovedAmount: string | null\n /** current approved amount by user */\n currentApprovedAmount: string | null\n}\n", "import { AssetWithTicker } from '../common.js'\nimport { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\n/** CosmosCoin */\nexport type CosmosCoin = {\n amount: string\n denom: string\n}\n\n/** CosmosProtoMsg */\nexport type CosmosProtoMsg = {\n type_url: string\n value: number[]\n}\n\n/** CosmosFee representing fee for cosmos transaction */\nexport type CosmosFee = {\n gas: string\n amount: CosmosCoin[]\n}\n\n/** Main transaction object for COSMOS type transactions */\nexport type CosmosMessage = {\n signType: 'AMINO' | 'DIRECT'\n sequence: string | null\n source: number | null\n account_number: number | null\n rpcUrl: string\n chainId: string | null\n msgs: any[] // TODO\n protoMsgs: CosmosProtoMsg[]\n memo: string | null\n fee: CosmosFee | null\n}\n\n/** An alternative to CosmosMessage object for the cosmos wallets that do not support generic Cosmos messages (e.g. XDefi) */\nexport type CosmosRawTransferData = {\n /** The machine-readable amount to transfer, example: 1000000000000000000 */\n amount: string\n /** The asset to be transferred */\n asset: AssetWithTicker\n /** The decimals for this asset, example: 18 */\n decimals: number\n /** Memo of transaction, could be null */\n memo: string | null\n /** The transaction method, example: transfer, deposit */\n method: string\n /** The recipient address of transaction */\n recipient: string\n}\n\n/** A Cosmos transaction, child of GenericTransaction */\nexport interface CosmosTransaction extends BaseTransaction {\n /** This fields equals to COSMOS for all CosmosTransactions */\n type: TransactionType.COSMOS\n /** Address of wallet that this transaction should be executed in, same as the create transaction request's input */\n fromWalletAddress: string\n /** Transaction data */\n data: CosmosMessage\n /** An alternative to CosmosMessage object for the cosmos wallets that do not support generic Cosmos messages */\n rawTransfer: CosmosRawTransferData | null\n}\n\nexport const isCosmosTransaction = (transaction: {\n type: TransactionType\n}): transaction is CosmosTransaction =>\n transaction.type === TransactionType.COSMOS\n", "import { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\n/** Account metadata used to define instructions */\nexport type SolanaInstructionKey = {\n pubkey: string\n isSigner: boolean\n isWritable: boolean\n}\n\n/** Transaction Instruction class */\nexport type SolanaInstruction = {\n keys: SolanaInstructionKey[]\n programId: string\n data: number[]\n}\n\n/** Pair of signature and corresponding public key */\nexport type SolanaSignature = {\n signature: number[]\n publicKey: string\n}\n\n/** This type of transaction is used for all solana transactions */\nexport interface SolanaTransaction extends BaseTransaction {\n /** This fields equals to SOLANA for all SolanaTransactions */\n type: TransactionType.SOLANA\n /** Type of the solana transaction */\n txType: 'LEGACY' | 'VERSIONED'\n /** Source wallet address */\n from: string\n /** Transaction hash used in case of retry */\n identifier: string\n /** A recent blockhash */\n recentBlockhash: string | null\n /** Signatures for the transaction */\n signatures: SolanaSignature[]\n /** The byte array of the transaction */\n serializedMessage: number[] | null\n /** The instructions to atomically execute */\n instructions: SolanaInstruction[]\n}\n\nexport const isSolanaTransaction = (transaction: {\n type: TransactionType\n}): transaction is SolanaTransaction =>\n transaction.type === TransactionType.SOLANA\n", "import { AssetWithTicker } from '../common.js'\nimport { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\nexport type InputToSign = { address: string, signingIndexes: number[] }\n\nexport type PSBT = {\n /** Base 64 representation of the Unsigned PSBT */\n unsignedPsbtBase64: string\n /** Inputs to be signed */\n inputsToSign: InputToSign[]\n}\n\n/** TransferTransaction. This type of transaction is used for UTXO blockchains including BTC, LTC, BCH */\nexport interface Transfer extends BaseTransaction {\n /** This fields equals to TRANSFER for all TransferTransactions */\n type: TransactionType.TRANSFER\n /** The method that should be passed to wallet. examples: deposit, transfer */\n method: string\n asset: AssetWithTicker\n /** The machine-readable amount of transaction, example: 1000000000000000000 */\n amount: string\n /** The decimals of the asset */\n decimals: number\n /** The source wallet address that can sign this transaction */\n fromWalletAddress: string\n /** The destination wallet address that the fund should be sent to */\n recipientAddress: string\n /** The memo of transaction, can be null */\n memo: string | null\n /** PSBT object containing base 64 representation of the Unsigned PSBT along with the inputs to be signed */\n psbt: PSBT | null\n}\n\nexport const isTransferTransaction = (transaction: {\n type: TransactionType\n}): transaction is Transfer => transaction.type === TransactionType.TRANSFER\n", "import { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\nexport type TrxContractParameter = {\n value: unknown\n type_url: string\n}\n\nexport type TrxContractData = {\n parameter: TrxContractParameter\n type: string\n}\n\nexport type TrxRawData = {\n contract: TrxContractData[]\n ref_block_bytes: string\n ref_block_hash: string\n expiration: number\n timestamp: number\n}\n\n/** TronTransaction */\nexport interface TronTransaction extends BaseTransaction {\n /** TransactionType.TRON */\n type: TransactionType.TRON\n /** Whether or not the transaction is an approval transaction. */\n isApprovalTx: boolean\n /** This is the raw data of the transaction. */\n raw_data: TrxRawData | null\n /** The raw hex data of the transaction. */\n raw_data_hex: string | null\n /** The transaction ID. */\n txID: string\n /** boolean */\n visible: boolean\n __payload__: object\n}\n\nexport const isTronTransaction = (transaction: {\n type: TransactionType\n}): transaction is TronTransaction => transaction.type === TransactionType.TRON\n", "import { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\nexport enum TonChainID {\n MAINNET = '-239',\n TESTNET = '-3',\n}\n\n/** Ton transaction message */\nexport interface TonMessage {\n /** Receiver's address */\n address: string\n /** Amount to send in nanoTon */\n amount: string\n /** Contract specific data to add to the transaction */\n stateInit?: string\n /** Contract specific data to add to the transaction */\n payload?: string\n}\n\n/** This type of transaction is used for all Ton transactions */\nexport interface TonTransaction extends BaseTransaction {\n /** This field equals to TON for all Ton transactions */\n type: TransactionType.TON\n /** Sending transaction deadline in unix epoch seconds */\n validUntil: number\n /**\n * The network (mainnet or testnet) where DApp intends to send the transaction. If not set, the transaction is sent to the network currently set in the wallet, but this is not safe and DApp should always strive to set the network. If the network parameter is set, but the wallet has a different network set, the wallet should show an alert and DO NOT ALLOW TO SEND this transaction\n */\n network?: TonChainID\n /** The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default */\n from?: string\n /** Messages to send: min is 1, max is 4 */\n messages: TonMessage[]\n}\n\nexport const isTonTransaction = (transaction: {\n type: TransactionType\n}): transaction is TonTransaction => transaction.type === TransactionType.TON\n", "import { BaseTransaction, TransactionType } from '../../shared/index.js'\n\n/** The transaction object for all EVM-based blockchains, including Ethereum, BSC, Polygon, Harmony, etc */\nexport interface EvmTransaction extends BaseTransaction {\n /** This fields equals to EVM for all EvmTransactions */\n type: TransactionType.EVM\n /**\n * Determines that this transaction is an approval transaction or not, if true user\n * should approve the transaction and call create transaction endpoint again to get the original tx. Beware that most\n * of the fields of this object will be passed directly to the wallet without any change.\n */\n isApprovalTx: boolean\n /** The source wallet address, it can be null */\n from: string | null\n /** Address of destination wallet or the smart contract or token that is going to be called */\n to: string\n /** The data of smart contract call, it can be null in case of native token transfer */\n data: string | null\n /** The amount of transaction in case of native token transfer */\n value: string | null\n /** The nonce value for transaction */\n nonce: string | null\n /** The suggested gas limit for this transaction */\n gasLimit: string | null\n /** The suggested gas price for this transaction */\n gasPrice: string | null\n /** Suggested max priority fee per gas for this transaction */\n maxPriorityFeePerGas: string | null\n /** Suggested max fee per gas for this transaction */\n maxFeePerGas: string | null\n}\n\nexport const isEvmTransaction = (transaction: {\n type: TransactionType\n}): transaction is EvmTransaction => transaction.type === TransactionType.EVM\n"],
|
|
4
|
+
"sourcesContent": ["import uuid from 'uuid-random'\nimport {\n MetaRequest,\n MetaResponse,\n BestRouteRequest,\n BestRouteResponse,\n CheckApprovalResponse,\n CheckTxStatusRequest,\n TransactionStatusResponse,\n CreateTransactionRequest,\n CreateTransactionResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n RequestOptions,\n BlockchainMeta,\n CompactMetaResponse,\n CompactToken,\n Token,\n MultiRouteRequest,\n MultiRouteResponse,\n ConfirmRouteResponse,\n ConfirmRouteRequest,\n CustomTokenRequest,\n CustomTokenResponse,\n TokenBalanceResponse,\n TokenBalanceRequest,\n SwapperMetaExtended,\n MultipleTokenBalanceRequest,\n MultipleTokenBalanceResponse,\n SearchCustomTokensRequest,\n SearchCustomTokensResponse,\n} from '../types'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddresses = { blockchain: string; address: string }[]\n\nexport class RangoClient {\n private readonly deviceId: string\n private readonly apiKey: string\n private readonly apiUrl: string\n private readonly httpService: AxiosInstance\n\n constructor(apiKey: string, apiUrl?: string) {\n this.apiUrl = apiUrl || 'https://api.rango.exchange'\n this.apiKey = apiKey\n try {\n if (typeof window !== 'undefined') {\n const deviceId = localStorage.getItem('deviceId')\n if (deviceId) {\n this.deviceId = deviceId\n } else {\n const generatedId = uuid()\n localStorage.setItem('deviceId', generatedId)\n this.deviceId = generatedId\n }\n } else {\n this.deviceId = uuid()\n }\n } catch (e) {\n this.deviceId = uuid()\n }\n this.httpService = axios.create({\n baseURL: this.apiUrl,\n })\n }\n\n public async getAllMetadata(\n metaRequest?: MetaRequest,\n options?: RequestOptions,\n ): Promise<MetaResponse> {\n const params = {\n ...metaRequest,\n blockchains: metaRequest?.blockchains?.join(),\n swappers: metaRequest?.swappers?.join(),\n swappersGroups: metaRequest?.swappersGroups?.join(),\n transactionTypes: metaRequest?.transactionTypes?.join(),\n }\n const axiosResponse = await this.httpService.get<CompactMetaResponse>(\n `/meta/compact?apiKey=${this.apiKey}`,\n {\n params,\n ...options,\n },\n )\n const reformatTokens = (tokens: CompactToken[]): Token[] =>\n tokens.map((tm) => ({\n blockchain: tm.b,\n symbol: tm.s,\n image: tm.i,\n address: tm.a || null,\n usdPrice: tm.p || null,\n isSecondaryCoin: tm.is || false,\n coinSource: tm.c || null,\n coinSourceUrl: tm.cu || null,\n name: tm.n || null,\n decimals: tm.d,\n isPopular: tm.ip || false,\n supportedSwappers: tm.ss || [],\n }))\n\n const tokens = reformatTokens(axiosResponse.data.tokens)\n const popularTokens = reformatTokens(axiosResponse.data.popularTokens)\n return { ...axiosResponse.data, tokens, popularTokens }\n }\n\n public async getBlockchains(\n options?: RequestOptions,\n ): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options },\n )\n return axiosResponse.data\n }\n\n public async getSwappers(\n options?: RequestOptions,\n ): Promise<SwapperMetaExtended[]> {\n const axiosResponse = await this.httpService.get<SwapperMetaExtended[]>(\n `/meta/swappers?apiKey=${this.apiKey}`,\n { ...options },\n )\n return axiosResponse.data\n }\n\n public async getCustomToken(\n customTokenRequest?: CustomTokenRequest,\n options?: RequestOptions,\n ): Promise<CustomTokenResponse> {\n const axiosResponse = await this.httpService.get<CustomTokenResponse>(\n `/meta/custom-token?apiKey=${this.apiKey}`,\n { params: customTokenRequest, ...options },\n )\n return axiosResponse.data\n }\n\n public async searchCustomTokens(\n searchCustomTokensRequest: SearchCustomTokensRequest,\n options?: RequestOptions,\n ): Promise<SearchCustomTokensResponse> {\n const axiosResponse =\n await this.httpService.get<SearchCustomTokensResponse>(\n `/meta/token/search?apiKey=${this.apiKey}`,\n { params: searchCustomTokensRequest, ...options },\n )\n return axiosResponse.data\n }\n\n public async getBestRoute(\n requestBody: BestRouteRequest,\n options?: RequestOptions,\n ): Promise<BestRouteResponse> {\n const axiosResponse = await this.httpService.post<BestRouteResponse>(\n `/routing/best?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options },\n )\n return axiosResponse.data\n }\n\n public async getAllRoutes(\n requestBody: MultiRouteRequest,\n options?: RequestOptions,\n ): Promise<MultiRouteResponse> {\n const axiosResponse = await this.httpService.post<MultiRouteResponse>(\n `/routing/bests?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options },\n )\n return axiosResponse.data\n }\n\n public async confirmRoute(\n requestBody: ConfirmRouteRequest,\n options?: RequestOptions,\n ): Promise<ConfirmRouteResponse> {\n const axiosResponse = await this.httpService.post<ConfirmRouteResponse>(\n `/routing/confirm?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options },\n )\n return axiosResponse.data\n }\n\n // @deprecated use confirmRoute instead\n public async confirmRouteRequest(\n requestBody: ConfirmRouteRequest,\n options?: RequestOptions,\n ): Promise<ConfirmRouteResponse> {\n const axiosResponse = await this.httpService.post<ConfirmRouteResponse>(\n `/routing/confirm?apiKey=${this.apiKey}`,\n requestBody,\n { headers: { 'X-Rango-Id': this.deviceId }, ...options },\n )\n return axiosResponse.data\n }\n\n public async checkApproval(\n requestId: string,\n txId?: string,\n options?: RequestOptions,\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/tx/${requestId}/check-approval?apiKey=${this.apiKey}`,\n { params: { txId }, ...options },\n )\n return axiosResponse.data\n }\n\n public async checkStatus(\n requestBody: CheckTxStatusRequest,\n options?: RequestOptions,\n ): Promise<TransactionStatusResponse> {\n const axiosResponse =\n await this.httpService.post<TransactionStatusResponse>(\n `/tx/check-status?apiKey=${this.apiKey}`,\n requestBody,\n { ...options },\n )\n return axiosResponse.data\n }\n\n public async createTransaction(\n requestBody: CreateTransactionRequest,\n options?: RequestOptions,\n ): Promise<CreateTransactionResponse> {\n const axiosResponse =\n await this.httpService.post<CreateTransactionResponse>(\n `/tx/create?apiKey=${this.apiKey}`,\n requestBody,\n { ...options },\n )\n return axiosResponse.data\n }\n\n public async reportFailure(\n requestBody: ReportTransactionRequest,\n options?: RequestOptions,\n ): Promise<void> {\n await this.httpService.post(\n `/tx/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n ...options,\n },\n )\n }\n\n public async getWalletsDetails(\n walletAddresses: WalletAddresses,\n options?: RequestOptions,\n ): Promise<WalletDetailsResponse> {\n let walletAddressesQueryParams = ''\n for (let i = 0; i < walletAddresses.length; i++) {\n const walletAddress = walletAddresses[i]\n walletAddressesQueryParams += `&address=${walletAddress.blockchain}.${walletAddress.address}`\n }\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/wallets/details?apiKey=${this.apiKey}${walletAddressesQueryParams}`,\n { ...options },\n )\n return axiosResponse.data\n }\n\n public async getTokenBalance(\n tokenBalanceRequest: TokenBalanceRequest,\n options?: RequestOptions,\n ): Promise<TokenBalanceResponse> {\n const axiosResponse = await this.httpService.get<TokenBalanceResponse>(\n `/wallets/token-balance?apiKey=${this.apiKey}`,\n { params: tokenBalanceRequest, ...options },\n )\n return axiosResponse.data\n }\n\n public async getMultipleTokenBalance(\n requestBody: MultipleTokenBalanceRequest,\n options?: RequestOptions,\n ): Promise<MultipleTokenBalanceResponse> {\n const axiosResponse =\n await this.httpService.post<MultipleTokenBalanceResponse>(\n `/wallets/multiple-token-balance?apiKey=${this.apiKey}`,\n requestBody,\n { ...options },\n )\n return axiosResponse.data\n }\n}\n", "import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n HyperliquidBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\n XrplBlockchainMeta,\n} from './meta.js'\n\nexport const isEvmBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is EvmBlockchainMeta => blockchainMeta.type === 'EVM'\n\nexport const isCosmosBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is CosmosBlockchainMeta => blockchainMeta.type === 'COSMOS'\n\nexport const isSolanaBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is SolanaBlockchainMeta => blockchainMeta.type === 'SOLANA'\n\nexport const isTronBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is TronBlockchainMeta => blockchainMeta.type === 'TRON'\n\nexport const isTransferBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is TransferBlockchainMeta =>\n blockchainMeta.type === 'TRANSFER'\n\nexport const isStarknetBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is StarkNetBlockchainMeta =>\n blockchainMeta.type === 'STARKNET'\n\nexport const isTonBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is TonBlockchainMeta => blockchainMeta.type === 'TON'\n\nexport const isXrplBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is XrplBlockchainMeta => blockchainMeta.type === 'XRPL'\n\nexport const isHyperliquidBlockchain = (\n blockchainMeta: BlockchainMeta,\n): blockchainMeta is HyperliquidBlockchainMeta =>\n blockchainMeta.type === 'HYPERLIQUID'\n\nexport const evmBlockchains = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isEvmBlockchain)\n\nexport const solanaBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isSolanaBlockchain)\n\nexport const starknetBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isStarknetBlockchain)\n\nexport const tronBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isTronBlockchain)\n\nexport const cosmosBlockchains = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isCosmosBlockchain)\n\nexport const transferBlockchains = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isTransferBlockchain)\n\nexport const tonBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isTonBlockchain)\n\nexport const xrplBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isXrplBlockchain)\n\nexport const hyperliquidBlockchain = (blockchains: BlockchainMeta[]) =>\n blockchains.filter(isHyperliquidBlockchain)\n", "/**\n * Routing Result Type\n *\n */\nexport enum RoutingResultType {\n OK = 'OK',\n HIGH_IMPACT = 'HIGH_IMPACT',\n NO_ROUTE = 'NO_ROUTE',\n INPUT_LIMIT_ISSUE = 'INPUT_LIMIT_ISSUE',\n HIGH_IMPACT_FOR_CREATE_TX = 'HIGH_IMPACT_FOR_CREATE_TX',\n}\n", "/** The type of transaction */\nexport enum TransactionType {\n EVM = 'EVM',\n TRANSFER = 'TRANSFER',\n COSMOS = 'COSMOS',\n SOLANA = 'SOLANA',\n TRON = 'TRON',\n STARKNET = 'STARKNET',\n TON = 'TON',\n SUI = 'SUI',\n XRPL = 'XRPL',\n STELLAR = 'STELLAR',\n HYPERLIQUID = 'HYPERLIQUID',\n}\n\n/**\n * The type of transaction\n * @deprecated use TransactionType instead\n */\nexport enum GenericTransactionType {\n EVM = 'EVM',\n TRANSFER = 'TRANSFER',\n COSMOS = 'COSMOS',\n SOLANA = 'SOLANA',\n}\n\n/** A transaction's url that can be displayed to advanced user to track the progress */\nexport type SwapExplorerUrl = {\n /** A custom display name to help user distinguish the transactions from each other. Example: Inbound, Outbound, Bridge, or null */\n description: string | null\n /** Url of the transaction in blockchain explorer. example: https://etherscan.io/tx/0xa1a3... */\n url: string\n}\n\n/**\n * APIErrorCode\n *\n * Error code of a swap failure\n */\nexport type APIErrorCode =\n | 'TX_FAIL'\n | 'TX_EXPIRED'\n | 'FETCH_TX_FAILED'\n | 'USER_REJECT'\n | 'USER_CANCEL'\n | 'USER_CANCELED_TX'\n | 'CALL_WALLET_FAILED'\n | 'SEND_TX_FAILED'\n | 'CALL_OR_SEND_FAILED'\n | 'TX_FAILED_IN_BLOCKCHAIN'\n | 'CLIENT_UNEXPECTED_BEHAVIOUR'\n | 'INSUFFICIENT_APPROVE'\n\n/**\n * The function checks if a given string value is a valid API error code.\n * @param {string} value - a string that represents a possible API error code.\n * @returns A boolean value is being returned, indicating whether the input `value` is of type\n * `APIErrorCode` or not.\n */\nexport function isAPIErrorCode(value: string): value is APIErrorCode {\n return [\n 'TX_FAIL',\n 'TX_EXPIRED',\n 'FETCH_TX_FAILED',\n 'USER_REJECT',\n 'USER_CANCEL',\n 'USER_CANCELED_TX',\n 'CALL_WALLET_FAILED',\n 'SEND_TX_FAILED',\n 'CALL_OR_SEND_FAILED',\n 'TX_FAILED_IN_BLOCKCHAIN',\n 'CLIENT_UNEXPECTED_BEHAVIOUR',\n 'INSUFFICIENT_APPROVE',\n ].includes(value)\n}\n\n/**\n * ReportTransactionRequest\n *\n * It should be used when an error happened in client and we want to inform server that transaction failed,\n * E.g. user rejected the transaction dialog or and an RPC error raised during signing tx by user.\n */\nexport type ReportTransactionRequest = {\n /** The requestId from best route endpoint */\n requestId: string\n /** Type of the event that happened, example: USER_REJECT */\n eventType: APIErrorCode\n /** Step number in which failure happened */\n step?: number\n /** Reason or message for the error */\n reason?: string\n /** @deprecated A list of key-value for extra details */\n data?: { [key: string]: string }\n /** A list of key-value for pre-defined tags */\n tags?: { wallet?: string; errorCode?: string }\n}\n\n/** The status of transaction in tracking */\nexport enum TransactionStatus {\n FAILED = 'failed',\n RUNNING = 'running',\n SUCCESS = 'success',\n}\n\n/**\n * Response body of check-approval\n * You could stop check approval if:\n * 1- approved successfully\n * => isApproved = true\n * 2- approval transaction failed\n * => isApproved = false && txStatus === 'failed'\n * 3- approval transaction succeeded but currentApprovedAmount is still less than requiredApprovedAmount\n * (e.g. user changed transaction data and enter another approve amount in MetaMask)\n * => isApproved = false && txStatus == 'success'\n */\nexport type CheckApprovalResponse = {\n /** A flag which indicates that the approve tx is done or not */\n isApproved: boolean\n /**\n * Status of approve transaction in blockchain,\n * if isArppoved is false and txStatus is failed, it seems that approve transaction failed in blockchain\n */\n txStatus: TransactionStatus | null\n /** required amount to be approved by user */\n requiredApprovedAmount: string | null\n /** current approved amount by user */\n currentApprovedAmount: string | null\n}\n", "import { AssetWithTicker } from '../common.js'\nimport { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\n/** CosmosCoin */\nexport type CosmosCoin = {\n amount: string\n denom: string\n}\n\n/** CosmosProtoMsg */\nexport type CosmosProtoMsg = {\n type_url: string\n value: number[]\n}\n\n/** CosmosFee representing fee for cosmos transaction */\nexport type CosmosFee = {\n gas: string\n amount: CosmosCoin[]\n}\n\n/** Main transaction object for COSMOS type transactions */\nexport type CosmosMessage = {\n signType: 'AMINO' | 'DIRECT'\n sequence: string | null\n source: number | null\n account_number: number | null\n rpcUrl: string\n chainId: string | null\n msgs: any[] // TODO\n protoMsgs: CosmosProtoMsg[]\n memo: string | null\n fee: CosmosFee | null\n}\n\n/** An alternative to CosmosMessage object for the cosmos wallets that do not support generic Cosmos messages (e.g. XDefi) */\nexport type CosmosRawTransferData = {\n /** The machine-readable amount to transfer, example: 1000000000000000000 */\n amount: string\n /** The asset to be transferred */\n asset: AssetWithTicker\n /** The decimals for this asset, example: 18 */\n decimals: number\n /** Memo of transaction, could be null */\n memo: string | null\n /** The transaction method, example: transfer, deposit */\n method: string\n /** The recipient address of transaction */\n recipient: string\n}\n\n/** A Cosmos transaction, child of GenericTransaction */\nexport interface CosmosTransaction extends BaseTransaction {\n /** This fields equals to COSMOS for all CosmosTransactions */\n type: TransactionType.COSMOS\n /** Address of wallet that this transaction should be executed in, same as the create transaction request's input */\n fromWalletAddress: string\n /** Transaction data */\n data: CosmosMessage\n /** An alternative to CosmosMessage object for the cosmos wallets that do not support generic Cosmos messages */\n rawTransfer: CosmosRawTransferData | null\n}\n\nexport const isCosmosTransaction = (transaction: {\n type: TransactionType\n}): transaction is CosmosTransaction =>\n transaction.type === TransactionType.COSMOS\n", "import { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\n/** Account metadata used to define instructions */\nexport type SolanaInstructionKey = {\n pubkey: string\n isSigner: boolean\n isWritable: boolean\n}\n\n/** Transaction Instruction class */\nexport type SolanaInstruction = {\n keys: SolanaInstructionKey[]\n programId: string\n data: number[]\n}\n\n/** Pair of signature and corresponding public key */\nexport type SolanaSignature = {\n signature: number[]\n publicKey: string\n}\n\n/** This type of transaction is used for all solana transactions */\nexport interface SolanaTransaction extends BaseTransaction {\n /** This fields equals to SOLANA for all SolanaTransactions */\n type: TransactionType.SOLANA\n /** Type of the solana transaction */\n txType: 'LEGACY' | 'VERSIONED'\n /** Source wallet address */\n from: string\n /** Transaction hash used in case of retry */\n identifier: string\n /** A recent blockhash */\n recentBlockhash: string | null\n /** Signatures for the transaction */\n signatures: SolanaSignature[]\n /** The byte array of the transaction */\n serializedMessage: number[] | null\n /** The instructions to atomically execute */\n instructions: SolanaInstruction[]\n}\n\nexport const isSolanaTransaction = (transaction: {\n type: TransactionType\n}): transaction is SolanaTransaction =>\n transaction.type === TransactionType.SOLANA\n", "import { AssetWithTicker } from '../common.js'\nimport { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\nexport type InputToSign = { address: string; signingIndexes: number[] }\n\nexport type PSBT = {\n /** Base 64 representation of the Unsigned PSBT */\n unsignedPsbtBase64: string\n /** Inputs to be signed */\n inputsToSign: InputToSign[]\n}\n\n/** TransferTransaction. This type of transaction is used for UTXO blockchains including BTC, LTC, BCH */\nexport interface Transfer extends BaseTransaction {\n /** This fields equals to TRANSFER for all TransferTransactions */\n type: TransactionType.TRANSFER\n /** The method that should be passed to wallet. examples: deposit, transfer */\n method: string\n asset: AssetWithTicker\n /** The machine-readable amount of transaction, example: 1000000000000000000 */\n amount: string\n /** The decimals of the asset */\n decimals: number\n /** The source wallet address that can sign this transaction */\n fromWalletAddress: string\n /** The destination wallet address that the fund should be sent to */\n recipientAddress: string\n /** The memo of transaction, can be null */\n memo: string | null\n /** PSBT object containing base 64 representation of the Unsigned PSBT along with the inputs to be signed */\n psbt: PSBT | null\n}\n\nexport const isTransferTransaction = (transaction: {\n type: TransactionType\n}): transaction is Transfer => transaction.type === TransactionType.TRANSFER\n", "import { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\nexport type TrxContractParameter = {\n value: unknown\n type_url: string\n}\n\nexport type TrxContractData = {\n parameter: TrxContractParameter\n type: string\n}\n\nexport type TrxRawData = {\n contract: TrxContractData[]\n ref_block_bytes: string\n ref_block_hash: string\n expiration: number\n timestamp: number\n}\n\n/** TronTransaction */\nexport interface TronTransaction extends BaseTransaction {\n /** TransactionType.TRON */\n type: TransactionType.TRON\n /** Whether or not the transaction is an approval transaction. */\n isApprovalTx: boolean\n /** This is the raw data of the transaction. */\n raw_data: TrxRawData | null\n /** The raw hex data of the transaction. */\n raw_data_hex: string | null\n /** The transaction ID. */\n txID: string\n /** boolean */\n visible: boolean\n __payload__: object\n}\n\nexport const isTronTransaction = (transaction: {\n type: TransactionType\n}): transaction is TronTransaction => transaction.type === TransactionType.TRON\n", "import { TransactionType } from '../transactions.js'\nimport { BaseTransaction } from './base.js'\n\nexport enum TonChainID {\n MAINNET = '-239',\n TESTNET = '-3',\n}\n\n/** Ton transaction message */\nexport interface TonMessage {\n /** Receiver's address */\n address: string\n /** Amount to send in nanoTon */\n amount: string\n /** Contract specific data to add to the transaction */\n stateInit?: string\n /** Contract specific data to add to the transaction */\n payload?: string\n}\n\n/** This type of transaction is used for all Ton transactions */\nexport interface TonTransaction extends BaseTransaction {\n /** This field equals to TON for all Ton transactions */\n type: TransactionType.TON\n /** Sending transaction deadline in unix epoch seconds */\n validUntil: number\n /**\n * The network (mainnet or testnet) where DApp intends to send the transaction. If not set, the transaction is sent to the network currently set in the wallet, but this is not safe and DApp should always strive to set the network. If the network parameter is set, but the wallet has a different network set, the wallet should show an alert and DO NOT ALLOW TO SEND this transaction\n */\n network?: TonChainID\n /** The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default */\n from?: string\n /** Messages to send: min is 1, max is 4 */\n messages: TonMessage[]\n}\n\nexport const isTonTransaction = (transaction: {\n type: TransactionType\n}): transaction is TonTransaction => transaction.type === TransactionType.TON\n", "import { BaseTransaction, TransactionType } from '../../shared/index.js'\n\n/** The transaction object for all EVM-based blockchains, including Ethereum, BSC, Polygon, Harmony, etc */\nexport interface EvmTransaction extends BaseTransaction {\n /** This fields equals to EVM for all EvmTransactions */\n type: TransactionType.EVM\n /**\n * Determines that this transaction is an approval transaction or not, if true user\n * should approve the transaction and call create transaction endpoint again to get the original tx. Beware that most\n * of the fields of this object will be passed directly to the wallet without any change.\n */\n isApprovalTx: boolean\n /** The source wallet address, it can be null */\n from: string | null\n /** Address of destination wallet or the smart contract or token that is going to be called */\n to: string\n /** The data of smart contract call, it can be null in case of native token transfer */\n data: string | null\n /** The amount of transaction in case of native token transfer */\n value: string | null\n /** The nonce value for transaction */\n nonce: string | null\n /** The suggested gas limit for this transaction */\n gasLimit: string | null\n /** The suggested gas price for this transaction */\n gasPrice: string | null\n /** Suggested max priority fee per gas for this transaction */\n maxPriorityFeePerGas: string | null\n /** Suggested max fee per gas for this transaction */\n maxFeePerGas: string | null\n}\n\nexport const isEvmTransaction = (transaction: {\n type: TransactionType\n}): transaction is EvmTransaction => transaction.type === TransactionType.EVM\n"],
|
|
5
5
|
"mappings": "+EAAA,OAAOA,MAAU,cAgCjB,OAAOC,MAA8B,QAI9B,IAAMC,EAAN,KAAkB,CApCzB,MAoCyB,CAAAC,EAAA,oBAMvB,YAAYC,EAAgBC,EAAiB,CAC3C,KAAK,OAASA,GAAU,6BACxB,KAAK,OAASD,EACd,GAAI,CACF,GAAI,OAAO,OAAW,IAAa,CACjC,IAAME,EAAW,aAAa,QAAQ,UAAU,EAChD,GAAIA,EACF,KAAK,SAAWA,MACX,CACL,IAAMC,EAAcC,EAAK,EACzB,aAAa,QAAQ,WAAYD,CAAW,EAC5C,KAAK,SAAWA,CAClB,CACF,MACE,KAAK,SAAWC,EAAK,CAEzB,MAAY,CACV,KAAK,SAAWA,EAAK,CACvB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ASC,EAAgB,GAArC,EAFL",
|
|
6
6
|
"names": ["uuid", "axios", "RangoClient", "__name", "apiKey", "apiUrl", "deviceId", "generatedId", "uuid", "axios", "metaRequest", "options", "params", "axiosResponse", "reformatTokens", "tokens", "tm", "popularTokens", "customTokenRequest", "searchCustomTokensRequest", "requestBody", "requestId", "txId", "walletAddresses", "walletAddressesQueryParams", "i", "walletAddress", "tokenBalanceRequest", "isEvmBlockchain", "__name", "blockchainMeta", "isCosmosBlockchain", "isSolanaBlockchain", "isTronBlockchain", "isTransferBlockchain", "isStarknetBlockchain", "isTonBlockchain", "isXrplBlockchain", "isHyperliquidBlockchain", "evmBlockchains", "blockchains", "solanaBlockchain", "starknetBlockchain", "tronBlockchain", "cosmosBlockchains", "transferBlockchains", "tonBlockchain", "xrplBlockchain", "hyperliquidBlockchain", "RoutingResultType", "TransactionType", "GenericTransactionType", "TransactionStatus", "isCosmosTransaction", "__name", "transaction", "TransactionType", "isSolanaTransaction", "__name", "transaction", "TransactionType", "isTransferTransaction", "__name", "transaction", "TransactionType", "isTronTransaction", "__name", "transaction", "TransactionType", "TonChainID", "isTonTransaction", "__name", "transaction", "TransactionType", "isEvmTransaction", "__name", "transaction", "TransactionType"]
|
|
7
7
|
}
|
package/lib/types/api/meta.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from 'rango-types/lib/api/main/meta';
|
|
2
2
|
export * from 'rango-types/lib/api/shared/type-gaurds';
|
|
3
|
-
export type { MetaRequest, SwapperMetaExtended } from 'rango-types/lib/api/shared/meta';
|
|
3
|
+
export type { MetaRequest, SwapperMetaExtended, } from 'rango-types/lib/api/shared/meta';
|
|
4
4
|
//# sourceMappingURL=meta.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/types/api/meta.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,YAAY,
|
|
1
|
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../../src/types/api/meta.ts"],"names":[],"mappings":"AAAA,cAAc,+BAA+B,CAAA;AAC7C,cAAc,wCAAwC,CAAA;AACtD,YAAY,EACV,WAAW,EACX,mBAAmB,GACpB,MAAM,iCAAiC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rango-sdk",
|
|
3
|
-
"version": "0.5.1-next.
|
|
3
|
+
"version": "0.5.1-next.2",
|
|
4
4
|
"description": "Rango Exchange SDK for dApps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
"build": "yarn run rangutopia library build --external-all-except=rango-types && yarn post:build",
|
|
19
19
|
"post:build": "yarn mv:file lib",
|
|
20
20
|
"watch": "tsdx watch",
|
|
21
|
-
"lint": "eslint src
|
|
21
|
+
"lint": "eslint src --fix",
|
|
22
22
|
"format": "prettier --write './**/*.{js,jsx,ts,tsx,css,md,json}' --config ../../.prettierrc.json --ignore-path ../../.prettierignore",
|
|
23
23
|
"mv:file": "sh ../../scripts/post-build.sh"
|
|
24
24
|
},
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"license": "GPL-3.0",
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"axios": "^1.7.4",
|
|
47
|
-
"rango-types": "^0.5.1-next.
|
|
47
|
+
"rango-types": "^0.5.1-next.3",
|
|
48
48
|
"uuid-random": "^1.3.2"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
package/src/services/client.ts
CHANGED
|
@@ -66,7 +66,7 @@ export class RangoClient {
|
|
|
66
66
|
|
|
67
67
|
public async getAllMetadata(
|
|
68
68
|
metaRequest?: MetaRequest,
|
|
69
|
-
options?: RequestOptions
|
|
69
|
+
options?: RequestOptions,
|
|
70
70
|
): Promise<MetaResponse> {
|
|
71
71
|
const params = {
|
|
72
72
|
...metaRequest,
|
|
@@ -80,7 +80,7 @@ export class RangoClient {
|
|
|
80
80
|
{
|
|
81
81
|
params,
|
|
82
82
|
...options,
|
|
83
|
-
}
|
|
83
|
+
},
|
|
84
84
|
)
|
|
85
85
|
const reformatTokens = (tokens: CompactToken[]): Token[] =>
|
|
86
86
|
tokens.map((tm) => ({
|
|
@@ -104,80 +104,80 @@ export class RangoClient {
|
|
|
104
104
|
}
|
|
105
105
|
|
|
106
106
|
public async getBlockchains(
|
|
107
|
-
options?: RequestOptions
|
|
107
|
+
options?: RequestOptions,
|
|
108
108
|
): Promise<BlockchainMeta[]> {
|
|
109
109
|
const axiosResponse = await this.httpService.get<BlockchainMeta[]>(
|
|
110
110
|
`/meta/blockchains?apiKey=${this.apiKey}`,
|
|
111
|
-
{ ...options }
|
|
111
|
+
{ ...options },
|
|
112
112
|
)
|
|
113
113
|
return axiosResponse.data
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
public async getSwappers(
|
|
117
|
-
options?: RequestOptions
|
|
117
|
+
options?: RequestOptions,
|
|
118
118
|
): Promise<SwapperMetaExtended[]> {
|
|
119
119
|
const axiosResponse = await this.httpService.get<SwapperMetaExtended[]>(
|
|
120
120
|
`/meta/swappers?apiKey=${this.apiKey}`,
|
|
121
|
-
{ ...options }
|
|
121
|
+
{ ...options },
|
|
122
122
|
)
|
|
123
123
|
return axiosResponse.data
|
|
124
124
|
}
|
|
125
125
|
|
|
126
126
|
public async getCustomToken(
|
|
127
127
|
customTokenRequest?: CustomTokenRequest,
|
|
128
|
-
options?: RequestOptions
|
|
128
|
+
options?: RequestOptions,
|
|
129
129
|
): Promise<CustomTokenResponse> {
|
|
130
130
|
const axiosResponse = await this.httpService.get<CustomTokenResponse>(
|
|
131
131
|
`/meta/custom-token?apiKey=${this.apiKey}`,
|
|
132
|
-
{ params: customTokenRequest, ...options }
|
|
132
|
+
{ params: customTokenRequest, ...options },
|
|
133
133
|
)
|
|
134
134
|
return axiosResponse.data
|
|
135
135
|
}
|
|
136
136
|
|
|
137
137
|
public async searchCustomTokens(
|
|
138
138
|
searchCustomTokensRequest: SearchCustomTokensRequest,
|
|
139
|
-
options?: RequestOptions
|
|
139
|
+
options?: RequestOptions,
|
|
140
140
|
): Promise<SearchCustomTokensResponse> {
|
|
141
141
|
const axiosResponse =
|
|
142
142
|
await this.httpService.get<SearchCustomTokensResponse>(
|
|
143
143
|
`/meta/token/search?apiKey=${this.apiKey}`,
|
|
144
|
-
{ params: searchCustomTokensRequest, ...options }
|
|
144
|
+
{ params: searchCustomTokensRequest, ...options },
|
|
145
145
|
)
|
|
146
146
|
return axiosResponse.data
|
|
147
147
|
}
|
|
148
148
|
|
|
149
149
|
public async getBestRoute(
|
|
150
150
|
requestBody: BestRouteRequest,
|
|
151
|
-
options?: RequestOptions
|
|
151
|
+
options?: RequestOptions,
|
|
152
152
|
): Promise<BestRouteResponse> {
|
|
153
153
|
const axiosResponse = await this.httpService.post<BestRouteResponse>(
|
|
154
154
|
`/routing/best?apiKey=${this.apiKey}`,
|
|
155
155
|
requestBody,
|
|
156
|
-
{ headers: { 'X-Rango-Id': this.deviceId }, ...options }
|
|
156
|
+
{ headers: { 'X-Rango-Id': this.deviceId }, ...options },
|
|
157
157
|
)
|
|
158
158
|
return axiosResponse.data
|
|
159
159
|
}
|
|
160
160
|
|
|
161
161
|
public async getAllRoutes(
|
|
162
162
|
requestBody: MultiRouteRequest,
|
|
163
|
-
options?: RequestOptions
|
|
163
|
+
options?: RequestOptions,
|
|
164
164
|
): Promise<MultiRouteResponse> {
|
|
165
165
|
const axiosResponse = await this.httpService.post<MultiRouteResponse>(
|
|
166
166
|
`/routing/bests?apiKey=${this.apiKey}`,
|
|
167
167
|
requestBody,
|
|
168
|
-
{ headers: { 'X-Rango-Id': this.deviceId }, ...options }
|
|
168
|
+
{ headers: { 'X-Rango-Id': this.deviceId }, ...options },
|
|
169
169
|
)
|
|
170
170
|
return axiosResponse.data
|
|
171
171
|
}
|
|
172
172
|
|
|
173
173
|
public async confirmRoute(
|
|
174
174
|
requestBody: ConfirmRouteRequest,
|
|
175
|
-
options?: RequestOptions
|
|
175
|
+
options?: RequestOptions,
|
|
176
176
|
): Promise<ConfirmRouteResponse> {
|
|
177
177
|
const axiosResponse = await this.httpService.post<ConfirmRouteResponse>(
|
|
178
178
|
`/routing/confirm?apiKey=${this.apiKey}`,
|
|
179
179
|
requestBody,
|
|
180
|
-
{ headers: { 'X-Rango-Id': this.deviceId }, ...options }
|
|
180
|
+
{ headers: { 'X-Rango-Id': this.deviceId }, ...options },
|
|
181
181
|
)
|
|
182
182
|
return axiosResponse.data
|
|
183
183
|
}
|
|
@@ -185,12 +185,12 @@ export class RangoClient {
|
|
|
185
185
|
// @deprecated use confirmRoute instead
|
|
186
186
|
public async confirmRouteRequest(
|
|
187
187
|
requestBody: ConfirmRouteRequest,
|
|
188
|
-
options?: RequestOptions
|
|
188
|
+
options?: RequestOptions,
|
|
189
189
|
): Promise<ConfirmRouteResponse> {
|
|
190
190
|
const axiosResponse = await this.httpService.post<ConfirmRouteResponse>(
|
|
191
191
|
`/routing/confirm?apiKey=${this.apiKey}`,
|
|
192
192
|
requestBody,
|
|
193
|
-
{ headers: { 'X-Rango-Id': this.deviceId }, ...options }
|
|
193
|
+
{ headers: { 'X-Rango-Id': this.deviceId }, ...options },
|
|
194
194
|
)
|
|
195
195
|
return axiosResponse.data
|
|
196
196
|
}
|
|
@@ -198,57 +198,57 @@ export class RangoClient {
|
|
|
198
198
|
public async checkApproval(
|
|
199
199
|
requestId: string,
|
|
200
200
|
txId?: string,
|
|
201
|
-
options?: RequestOptions
|
|
201
|
+
options?: RequestOptions,
|
|
202
202
|
): Promise<CheckApprovalResponse> {
|
|
203
203
|
const axiosResponse = await this.httpService.get<CheckApprovalResponse>(
|
|
204
204
|
`/tx/${requestId}/check-approval?apiKey=${this.apiKey}`,
|
|
205
|
-
{ params: { txId }, ...options }
|
|
205
|
+
{ params: { txId }, ...options },
|
|
206
206
|
)
|
|
207
207
|
return axiosResponse.data
|
|
208
208
|
}
|
|
209
209
|
|
|
210
210
|
public async checkStatus(
|
|
211
211
|
requestBody: CheckTxStatusRequest,
|
|
212
|
-
options?: RequestOptions
|
|
212
|
+
options?: RequestOptions,
|
|
213
213
|
): Promise<TransactionStatusResponse> {
|
|
214
214
|
const axiosResponse =
|
|
215
215
|
await this.httpService.post<TransactionStatusResponse>(
|
|
216
216
|
`/tx/check-status?apiKey=${this.apiKey}`,
|
|
217
217
|
requestBody,
|
|
218
|
-
{ ...options }
|
|
218
|
+
{ ...options },
|
|
219
219
|
)
|
|
220
220
|
return axiosResponse.data
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
public async createTransaction(
|
|
224
224
|
requestBody: CreateTransactionRequest,
|
|
225
|
-
options?: RequestOptions
|
|
225
|
+
options?: RequestOptions,
|
|
226
226
|
): Promise<CreateTransactionResponse> {
|
|
227
227
|
const axiosResponse =
|
|
228
228
|
await this.httpService.post<CreateTransactionResponse>(
|
|
229
229
|
`/tx/create?apiKey=${this.apiKey}`,
|
|
230
230
|
requestBody,
|
|
231
|
-
{ ...options }
|
|
231
|
+
{ ...options },
|
|
232
232
|
)
|
|
233
233
|
return axiosResponse.data
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
public async reportFailure(
|
|
237
237
|
requestBody: ReportTransactionRequest,
|
|
238
|
-
options?: RequestOptions
|
|
238
|
+
options?: RequestOptions,
|
|
239
239
|
): Promise<void> {
|
|
240
240
|
await this.httpService.post(
|
|
241
241
|
`/tx/report-tx?apiKey=${this.apiKey}`,
|
|
242
242
|
requestBody,
|
|
243
243
|
{
|
|
244
244
|
...options,
|
|
245
|
-
}
|
|
245
|
+
},
|
|
246
246
|
)
|
|
247
247
|
}
|
|
248
248
|
|
|
249
249
|
public async getWalletsDetails(
|
|
250
250
|
walletAddresses: WalletAddresses,
|
|
251
|
-
options?: RequestOptions
|
|
251
|
+
options?: RequestOptions,
|
|
252
252
|
): Promise<WalletDetailsResponse> {
|
|
253
253
|
let walletAddressesQueryParams = ''
|
|
254
254
|
for (let i = 0; i < walletAddresses.length; i++) {
|
|
@@ -257,31 +257,31 @@ export class RangoClient {
|
|
|
257
257
|
}
|
|
258
258
|
const axiosResponse = await this.httpService.get<WalletDetailsResponse>(
|
|
259
259
|
`/wallets/details?apiKey=${this.apiKey}${walletAddressesQueryParams}`,
|
|
260
|
-
{ ...options }
|
|
260
|
+
{ ...options },
|
|
261
261
|
)
|
|
262
262
|
return axiosResponse.data
|
|
263
263
|
}
|
|
264
264
|
|
|
265
265
|
public async getTokenBalance(
|
|
266
266
|
tokenBalanceRequest: TokenBalanceRequest,
|
|
267
|
-
options?: RequestOptions
|
|
267
|
+
options?: RequestOptions,
|
|
268
268
|
): Promise<TokenBalanceResponse> {
|
|
269
269
|
const axiosResponse = await this.httpService.get<TokenBalanceResponse>(
|
|
270
270
|
`/wallets/token-balance?apiKey=${this.apiKey}`,
|
|
271
|
-
{ params: tokenBalanceRequest, ...options }
|
|
271
|
+
{ params: tokenBalanceRequest, ...options },
|
|
272
272
|
)
|
|
273
273
|
return axiosResponse.data
|
|
274
274
|
}
|
|
275
275
|
|
|
276
276
|
public async getMultipleTokenBalance(
|
|
277
277
|
requestBody: MultipleTokenBalanceRequest,
|
|
278
|
-
options?: RequestOptions
|
|
278
|
+
options?: RequestOptions,
|
|
279
279
|
): Promise<MultipleTokenBalanceResponse> {
|
|
280
280
|
const axiosResponse =
|
|
281
281
|
await this.httpService.post<MultipleTokenBalanceResponse>(
|
|
282
282
|
`/wallets/multiple-token-balance?apiKey=${this.apiKey}`,
|
|
283
283
|
requestBody,
|
|
284
|
-
{ ...options }
|
|
284
|
+
{ ...options },
|
|
285
285
|
)
|
|
286
286
|
return axiosResponse.data
|
|
287
287
|
}
|
package/src/types/api/meta.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
export * from 'rango-types/lib/api/main/meta'
|
|
2
2
|
export * from 'rango-types/lib/api/shared/type-gaurds'
|
|
3
|
-
export type {
|
|
3
|
+
export type {
|
|
4
|
+
MetaRequest,
|
|
5
|
+
SwapperMetaExtended,
|
|
6
|
+
} from 'rango-types/lib/api/shared/meta'
|