rango-sdk-basic 0.1.35 → 0.1.37
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/rango-sdk-basic.cjs.development.js +26 -17
- package/lib/rango-sdk-basic.cjs.development.js.map +1 -1
- package/lib/rango-sdk-basic.cjs.production.min.js +1 -1
- package/lib/rango-sdk-basic.cjs.production.min.js.map +1 -1
- package/lib/rango-sdk-basic.esm.js +26 -17
- package/lib/rango-sdk-basic.esm.js.map +1 -1
- package/lib/services/client.d.ts +2 -2
- package/lib/services/client.d.ts.map +1 -1
- package/lib/types/api/meta.d.ts +1 -0
- package/lib/types/api/meta.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/services/client.ts +16 -2
- package/src/types/api/meta.ts +1 -0
|
@@ -773,23 +773,32 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
773
773
|
}
|
|
774
774
|
var _proto = RangoClient.prototype;
|
|
775
775
|
_proto.meta = /*#__PURE__*/function () {
|
|
776
|
-
var _meta = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
777
|
-
var
|
|
776
|
+
var _meta = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(metaRequest, options) {
|
|
777
|
+
var _metaRequest$blockcha, _metaRequest$swappers, _metaRequest$swappers2, _metaRequest$transact;
|
|
778
|
+
var params, axiosResponse;
|
|
778
779
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
779
780
|
while (1) switch (_context.prev = _context.next) {
|
|
780
781
|
case 0:
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
782
|
+
params = _extends({}, metaRequest, {
|
|
783
|
+
blockchains: metaRequest == null ? void 0 : (_metaRequest$blockcha = metaRequest.blockchains) == null ? void 0 : _metaRequest$blockcha.join(),
|
|
784
|
+
swappers: metaRequest == null ? void 0 : (_metaRequest$swappers = metaRequest.swappers) == null ? void 0 : _metaRequest$swappers.join(),
|
|
785
|
+
swappersGroups: metaRequest == null ? void 0 : (_metaRequest$swappers2 = metaRequest.swappersGroups) == null ? void 0 : _metaRequest$swappers2.join(),
|
|
786
|
+
transactionTypes: metaRequest == null ? void 0 : (_metaRequest$transact = metaRequest.transactionTypes) == null ? void 0 : _metaRequest$transact.join()
|
|
787
|
+
});
|
|
788
|
+
_context.next = 3;
|
|
789
|
+
return this.httpService.get("/basic/meta?apiKey=" + this.apiKey, _extends({
|
|
790
|
+
params: params
|
|
791
|
+
}, options));
|
|
792
|
+
case 3:
|
|
784
793
|
axiosResponse = _context.sent;
|
|
785
794
|
return _context.abrupt("return", axiosResponse.data);
|
|
786
|
-
case
|
|
795
|
+
case 5:
|
|
787
796
|
case "end":
|
|
788
797
|
return _context.stop();
|
|
789
798
|
}
|
|
790
799
|
}, _callee, this);
|
|
791
800
|
}));
|
|
792
|
-
function meta(_x) {
|
|
801
|
+
function meta(_x, _x2) {
|
|
793
802
|
return _meta.apply(this, arguments);
|
|
794
803
|
}
|
|
795
804
|
return meta;
|
|
@@ -811,7 +820,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
811
820
|
}
|
|
812
821
|
}, _callee2, this);
|
|
813
822
|
}));
|
|
814
|
-
function chains(
|
|
823
|
+
function chains(_x3) {
|
|
815
824
|
return _chains.apply(this, arguments);
|
|
816
825
|
}
|
|
817
826
|
return chains;
|
|
@@ -833,7 +842,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
833
842
|
}
|
|
834
843
|
}, _callee3, this);
|
|
835
844
|
}));
|
|
836
|
-
function swappers(
|
|
845
|
+
function swappers(_x4) {
|
|
837
846
|
return _swappers.apply(this, arguments);
|
|
838
847
|
}
|
|
839
848
|
return swappers;
|
|
@@ -855,7 +864,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
855
864
|
}
|
|
856
865
|
}, _callee4, this);
|
|
857
866
|
}));
|
|
858
|
-
function messagingProtocols(
|
|
867
|
+
function messagingProtocols(_x5) {
|
|
859
868
|
return _messagingProtocols.apply(this, arguments);
|
|
860
869
|
}
|
|
861
870
|
return messagingProtocols;
|
|
@@ -889,7 +898,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
889
898
|
}
|
|
890
899
|
}, _callee5, this);
|
|
891
900
|
}));
|
|
892
|
-
function quote(
|
|
901
|
+
function quote(_x6, _x7) {
|
|
893
902
|
return _quote.apply(this, arguments);
|
|
894
903
|
}
|
|
895
904
|
return quote;
|
|
@@ -919,7 +928,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
919
928
|
}
|
|
920
929
|
}, _callee6, this);
|
|
921
930
|
}));
|
|
922
|
-
function isApproved(
|
|
931
|
+
function isApproved(_x8, _x9, _x10) {
|
|
923
932
|
return _isApproved.apply(this, arguments);
|
|
924
933
|
}
|
|
925
934
|
return isApproved;
|
|
@@ -946,7 +955,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
946
955
|
}
|
|
947
956
|
}, _callee7, this);
|
|
948
957
|
}));
|
|
949
|
-
function status(
|
|
958
|
+
function status(_x11, _x12) {
|
|
950
959
|
return _status.apply(this, arguments);
|
|
951
960
|
}
|
|
952
961
|
return status;
|
|
@@ -983,7 +992,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
983
992
|
}
|
|
984
993
|
}, _callee8, this);
|
|
985
994
|
}));
|
|
986
|
-
function swap(
|
|
995
|
+
function swap(_x13, _x14) {
|
|
987
996
|
return _swap.apply(this, arguments);
|
|
988
997
|
}
|
|
989
998
|
return swap;
|
|
@@ -1005,7 +1014,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1005
1014
|
}
|
|
1006
1015
|
}, _callee9, this);
|
|
1007
1016
|
}));
|
|
1008
|
-
function reportFailure(
|
|
1017
|
+
function reportFailure(_x15, _x16) {
|
|
1009
1018
|
return _reportFailure.apply(this, arguments);
|
|
1010
1019
|
}
|
|
1011
1020
|
return reportFailure;
|
|
@@ -1032,7 +1041,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1032
1041
|
}
|
|
1033
1042
|
}, _callee10, this);
|
|
1034
1043
|
}));
|
|
1035
|
-
function balance(
|
|
1044
|
+
function balance(_x17, _x18) {
|
|
1036
1045
|
return _balance.apply(this, arguments);
|
|
1037
1046
|
}
|
|
1038
1047
|
return balance;
|
|
@@ -1073,7 +1082,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1073
1082
|
}
|
|
1074
1083
|
}, _callee11, this, [[0, 6]]);
|
|
1075
1084
|
}));
|
|
1076
|
-
function executeEvmRoute$1(
|
|
1085
|
+
function executeEvmRoute$1(_x19, _x20) {
|
|
1077
1086
|
return _executeEvmRoute2.apply(this, arguments);
|
|
1078
1087
|
}
|
|
1079
1088
|
return executeEvmRoute$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rango-sdk-basic.cjs.development.js","sources":["../src/types/api/common.ts","../../../node_modules/rango-types/src/api/shared/type-gaurds.ts","../../../node_modules/rango-types/src/api/shared/routing.ts","../../../node_modules/rango-types/src/api/shared/transactions.ts","../../../node_modules/rango-types/src/api/shared/txs/ton.ts","../src/types/utils/errors.ts","../src/utils/promise.ts","../src/services/executor.ts","../src/utils/errors.ts","../src/services/client.ts"],"sourcesContent":["import { Asset } from 'rango-types/lib/api/basic'\nexport * from 'rango-types/lib/api/basic/common'\n\nexport function assetToString(asset: Asset): string {\n if (!!asset.address)\n return `${asset.blockchain}.${asset.symbol}--${asset.address}`\n else return `${asset.blockchain}.${asset.symbol}`\n}\n","import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\n} from './meta'\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 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","/**\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}\n","/**\n * The type of transaction\n */\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}\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/**\n * A transaction's url that can be displayed to advanced user to track the progress\n *\n * @property {string} url - Url of the transaction in blockchain explorer. example: https://etherscan.io/tx/0xa1a3...\n * @property {string | null} description - A custom display name to help user distinguish the transactions from each\n * other. Example: Inbound, Outbound, Bridge, or null\n *\n */\nexport type SwapExplorerUrl = {\n description: string | null\n url: string\n}\n\n/**\n * APIErrorCode\n *\n * Error code of a swap failure\n *\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 *\n * @property {string} requestId - The requestId from best route endpoint\n * @property {APIErrorCode} eventType - Type of the event that happened, example: USER_REJECT\n * @property {number} [step] - Step number in which failure happened\n * @property {string} [reason] - Reason or message for the error\n * @property {[key: string]: string} [data] - A list of key-value for extra details\n * @property {wallet?: string, errorCode? string} [tags] - A list of key-value for pre-defined tags\n *\n */\nexport type ReportTransactionRequest = {\n requestId: string\n eventType: APIErrorCode\n step?: number\n reason?: string\n data?: { [key: string]: string }\n tags?: { wallet?: string; errorCode?: string }\n}\n\n/**\n * The status of transaction in tracking\n */\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 *\n * @property {boolean} isApproved - A flag which indicates that the approve tx is done or not\n * @property {TransactionStatus | null} txStatus - Status of approve transaction in blockchain,\n * if isArppoved is false and txStatus is failed, it seems that approve transaction failed in blockchain\n * @property {string | null} requiredApprovedAmount - required amount to be approved by user\n * @property {string | null} currentApprovedAmount - current approved amount by user\n *\n */\nexport type CheckApprovalResponse = {\n isApproved: boolean\n txStatus: TransactionStatus | null\n requiredApprovedAmount: string | null\n currentApprovedAmount: string | null\n}\n","import { TransactionType } from '..'\nimport { BaseTransaction } from './base'\n\nexport enum TonChainID {\n MAINNET = '-239',\n TESTNET = '-3',\n}\n\n/**\n * @property {string} address - Receiver's address\n * @property {string} amount - Amount to send in nanoTon\n * @property {string} [stateInit] - Contract specific data to add to the transaction\n * @property {string} [payload] - Contract specific data to add to the transaction\n */\nexport interface TonMessage {\n address: string\n amount: string\n stateInit?: string\n payload?: string\n}\n\n/**\n * This type of transaction is used for all Ton transactions\n *\n * @property {TransactionType} type - This field equals to TON for all Ton transactions\n * @property {number} validUntil - Sending transaction deadline in unix epoch seconds\n * @property {TonChainID} [network] - 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 * @property {string} [from] - The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default\n * @property {TonMessage[]} messages - Messages to send: min is 1, max is 4\n */\nexport interface TonTransaction extends BaseTransaction {\n type: TransactionType.TON\n validUntil: number\n network?: TonChainID\n from?: string\n messages: TonMessage[]\n}\n\nexport const isTonTransaction = (transaction: {\n type: TransactionType\n}): transaction is TonTransaction => transaction.type === TransactionType.TON\n","export const MetamaskErrorCodes = {\n rpc: {\n invalidInput: -32000,\n resourceNotFound: -32001,\n resourceUnavailable: -32002,\n transactionRejected: -32003,\n methodNotSupported: -32004,\n limitExceeded: -32005,\n parse: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internal: -32603,\n },\n provider: {\n userRejectedRequest: 4001,\n unauthorized: 4100,\n unsupportedMethod: 4200,\n disconnected: 4900,\n chainDisconnected: 4901,\n },\n}\n","export function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","import { Signer } from 'ethers'\nimport { RangoClient } from './client'\nimport { EvmTransaction } from '../types/api/txs'\nimport {\n StatusResponse,\n SwapResponse,\n TransactionStatus,\n TransactionType,\n} from '../types/api/transactions'\nimport { sleep } from '../utils/promise'\n\nexport function prepareEvmTransaction(\n evmTx: EvmTransaction,\n isApprove: boolean\n) {\n const gasPrice =\n !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x')\n ? '0x' + parseInt(evmTx.gasPrice).toString(16)\n : null\n const manipulatedTx = {\n ...evmTx,\n gasPrice,\n }\n let tx = {}\n if (!!manipulatedTx.from) tx = { ...tx, from: manipulatedTx.from }\n if (isApprove) {\n if (!!manipulatedTx.approveTo) tx = { ...tx, to: manipulatedTx.approveTo }\n if (!!manipulatedTx.approveData)\n tx = { ...tx, data: manipulatedTx.approveData }\n } else {\n if (!!manipulatedTx.txTo) tx = { ...tx, to: manipulatedTx.txTo }\n if (!!manipulatedTx.txData) tx = { ...tx, data: manipulatedTx.txData }\n if (!!manipulatedTx.value) tx = { ...tx, value: manipulatedTx.value }\n if (!!manipulatedTx.gasLimit)\n tx = { ...tx, gasLimit: manipulatedTx.gasLimit }\n if (!!manipulatedTx.gasPrice)\n tx = { ...tx, gasPrice: manipulatedTx.gasPrice }\n }\n return tx\n}\n\nasync function checkApprovalSync(\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n): Promise<boolean> {\n while (true) {\n try {\n const approvalResponse = await rangoClient.isApproved(requestId, txId)\n if (approvalResponse?.isApproved) return true\n if (\n !approvalResponse?.isApproved &&\n approvalResponse?.txStatus === TransactionStatus.FAILED\n )\n return false\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n await sleep(3_000)\n }\n}\n\nexport const checkTransactionStatusSync = async (\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n) => {\n let txStatus: StatusResponse | undefined\n while (true) {\n try {\n txStatus = await rangoClient.status({\n requestId,\n txId,\n })\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n if (!!txStatus) {\n if (\n !!txStatus.status &&\n [TransactionStatus.FAILED, TransactionStatus.SUCCESS].includes(\n txStatus.status\n )\n ) {\n return txStatus\n }\n }\n await sleep(3_000)\n }\n}\n\nexport const executeEvmRoute = async (\n client: RangoClient,\n signer: Signer,\n route: SwapResponse\n): Promise<StatusResponse> => {\n const { tx, requestId, error, resultType } = route\n if (resultType != 'OK') throw new Error(resultType)\n if (!!error || !tx)\n throw new Error(error || 'Error creating the transaction.')\n if (tx?.type !== TransactionType.EVM)\n throw new Error('Non Evm transactions are not supported yet.')\n const evmTransaction = tx as EvmTransaction\n if (!evmTransaction) throw new Error('Transaction is null. Please try again!')\n const txChainId = parseInt(evmTransaction.blockChain.chainId || '-1')\n let signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n if (!!evmTransaction.approveTo && !!evmTransaction.approveData) {\n const approveTxData = prepareEvmTransaction(evmTransaction, true)\n const approveTx = await signer.sendTransaction(approveTxData)\n approveTx.wait()\n const isApproved = await checkApprovalSync(\n requestId,\n approveTx.hash,\n client\n )\n if (!isApproved) throw new Error('Error in approve transaction.')\n }\n signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n const mainTxData = prepareEvmTransaction(evmTransaction, false)\n const mainTx = await signer.sendTransaction(mainTxData)\n mainTx.wait()\n const status = await checkTransactionStatusSync(\n requestId,\n mainTx.hash,\n client\n )\n if (status.status !== TransactionStatus.SUCCESS)\n throw new Error(`Cross-chain swap failed. ${status.error || ''}`)\n return status\n}\n","import { getMessageFromCode } from 'eth-rpc-errors'\nimport { MetamaskErrorCodes } from '../types/utils/errors'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const prettifyError = (error: any) => {\n if (!error) return error\n if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001))\n return new Error('Transaction Rejected')\n if (error && typeof error.code === 'number') {\n if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {\n return new Error(getMessageFromCode(error.code))\n }\n if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {\n if (\n error.code === MetamaskErrorCodes.rpc.internal &&\n error.message?.includes('underpriced')\n )\n return new Error('Transaction underpriced')\n if (\n error.message?.includes('intrinsic gas too low') ||\n error.message?.includes('out of gas')\n )\n return new Error('This Gas limit is low.')\n return new Error(getMessageFromCode(error.code))\n }\n }\n if (error.message) return new Error(error.message)\n return error\n}\n","import uuid from 'uuid-random'\n\nimport {\n MetaResponse,\n QuoteRequest,\n QuoteResponse,\n CheckApprovalResponse,\n StatusRequest,\n StatusResponse,\n SwapRequest,\n SwapResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n assetToString,\n BlockchainMeta,\n SwapperMeta,\n RequestOptions,\n MessagingProtocolsResponse,\n} from '../types'\nimport { Signer } from 'ethers'\nimport { executeEvmRoute as executeEvmRoute } from './executor'\nimport { prettifyError } from '../utils/errors'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddress = { 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, debug = false, 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 if (debug) {\n this.httpService.interceptors.request.use((request) => {\n console.log('Starting Request', JSON.stringify(request, null, 2))\n return request\n })\n this.httpService.interceptors.response.use((response) => {\n console.log('Response:', JSON.stringify(response, null, 2))\n return response\n })\n }\n }\n\n public async meta(options?: RequestOptions): Promise<MetaResponse> {\n const axiosResponse = await this.httpService.get<MetaResponse>(\n `/basic/meta?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async chains(options?: RequestOptions): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/basic/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async swappers(options?: RequestOptions): Promise<SwapperMeta[]> {\n const axiosResponse = await this.httpService.get<SwapperMeta[]>(\n `/basic/meta/swappers?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async messagingProtocols(\n options?: RequestOptions\n ): Promise<MessagingProtocolsResponse> {\n const axiosResponse =\n await this.httpService.get<MessagingProtocolsResponse>(\n `/basic/meta/messaging-protocols?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async quote(\n quoteRequest: QuoteRequest,\n options?: RequestOptions\n ): Promise<QuoteResponse> {\n const body = {\n ...quoteRequest,\n from: assetToString(quoteRequest.from),\n to: assetToString(quoteRequest.to),\n swappers:\n !!quoteRequest.swappers && quoteRequest.swappers.length > 0\n ? quoteRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0\n ? quoteRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!quoteRequest.messagingProtocols &&\n quoteRequest.messagingProtocols.length > 0\n ? quoteRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<QuoteResponse>(\n `/basic/quote?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async isApproved(\n requestId: string,\n txId?: string,\n options?: RequestOptions\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/basic/is-approved?apiKey=${this.apiKey}`,\n {\n params: { requestId, txId },\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async status(\n statusRequest: StatusRequest,\n options?: RequestOptions\n ): Promise<StatusResponse> {\n const axiosResponse = await this.httpService.get<StatusResponse>(\n `/basic/status?apiKey=${this.apiKey}`,\n {\n params: statusRequest,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async swap(\n swapRequest: SwapRequest,\n options?: RequestOptions\n ): Promise<SwapResponse> {\n const body = {\n ...swapRequest,\n from: assetToString(swapRequest.from),\n to: assetToString(swapRequest.to),\n referrerAddress: swapRequest.referrerAddress || null,\n referrerFee: swapRequest.referrerFee || null,\n disableEstimate: swapRequest.disableEstimate || false,\n swappers:\n !!swapRequest.swappers && swapRequest.swappers.length > 0\n ? swapRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0\n ? swapRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!swapRequest.messagingProtocols &&\n swapRequest.messagingProtocols.length > 0\n ? swapRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<SwapResponse>(\n `/basic/swap?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\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 `/basic/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n }\n\n public async balance(\n walletAddress: WalletAddress,\n options?: RequestOptions\n ): Promise<WalletDetailsResponse> {\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/basic/balance?apiKey=${this.apiKey}`,\n {\n params: walletAddress,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async executeEvmRoute(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n signer: any,\n route: SwapResponse\n ): Promise<StatusResponse> {\n try {\n return await executeEvmRoute(this, signer as Signer, route)\n } catch (error) {\n const prettifiedError = prettifyError(error)\n try {\n const message = prettifiedError?.message || 'Error executing the route'\n this.reportFailure({\n requestId: route.requestId,\n eventType: 'TX_FAIL',\n reason: message,\n })\n } catch (err) {\n console.log({ err })\n }\n throw prettifiedError\n }\n }\n}\n"],"names":["assetToString","asset","address","blockchain","symbol","blockchainMeta","MetamaskErrorCodes","rpc","invalidInput","resourceNotFound","resourceUnavailable","transactionRejected","methodNotSupported","limitExceeded","parse","invalidRequest","methodNotFound","invalidParams","internal","provider","userRejectedRequest","unauthorized","unsupportedMethod","disconnected","chainDisconnected","sleep","ms","Promise","resolve","setTimeout","prepareEvmTransaction","evmTx","isApprove","gasPrice","startsWith","parseInt","toString","manipulatedTx","tx","from","approveTo","to","approveData","data","txTo","txData","value","gasLimit","checkApprovalSync","requestId","txId","rangoClient","isApproved","approvalResponse","txStatus","TransactionStatus","FAILED","console","log","err","checkTransactionStatusSync","status","SUCCESS","includes","executeEvmRoute","client","signer","route","error","resultType","Error","type","TransactionType","EVM","evmTransaction","txChainId","blockChain","chainId","getChainId","signerChainId","approveTxData","sendTransaction","approveTx","wait","hash","mainTxData","mainTx","prettifyError","code","Object","values","getMessageFromCode","message","RangoClient","apiKey","debug","apiUrl","window","deviceId","localStorage","getItem","generatedId","uuid","setItem","e","httpService","axios","create","baseURL","interceptors","request","use","JSON","stringify","response","meta","options","get","axiosResponse","chains","swappers","messagingProtocols","quote","quoteRequest","body","length","join","undefined","swapperGroups","params","headers","statusRequest","swap","swapRequest","referrerAddress","referrerFee","disableEstimate","reportFailure","requestBody","post","balance","walletAddress","prettifiedError","eventType","reason"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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OAAO,GAAG,CAAAkD,eAAe,oBAAfA,eAAe,CAAElD,OAAO,KAAI,2BAA2B;cACvE,IAAI,CAAC6C,aAAa,CAAC;gBACjBxF,SAAS,EAAEkB,KAAK,CAAClB,SAAS;gBAC1B8F,SAAS,EAAE,SAAS;gBACpBC,MAAM,EAAEpD;eACT,CAAC;aACH,CAAC,OAAOjC,GAAG,EAAE;cACZF,OAAO,CAACC,GAAG,CAAC;gBAAEC,GAAG,EAAHA;eAAK,CAAC;;YACrB,MACKmF,eAAe;UAAA;UAAA;YAAA;;;KAExB;IAAA;MAAA;;IAAA;;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"rango-sdk-basic.cjs.development.js","sources":["../src/types/api/common.ts","../../../node_modules/rango-types/src/api/shared/type-gaurds.ts","../../../node_modules/rango-types/src/api/shared/routing.ts","../../../node_modules/rango-types/src/api/shared/transactions.ts","../../../node_modules/rango-types/src/api/shared/txs/ton.ts","../src/types/utils/errors.ts","../src/utils/promise.ts","../src/services/executor.ts","../src/utils/errors.ts","../src/services/client.ts"],"sourcesContent":["import { Asset } from 'rango-types/lib/api/basic'\nexport * from 'rango-types/lib/api/basic/common'\n\nexport function assetToString(asset: Asset): string {\n if (!!asset.address)\n return `${asset.blockchain}.${asset.symbol}--${asset.address}`\n else return `${asset.blockchain}.${asset.symbol}`\n}\n","import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\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 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","/**\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}\n","/**\n * The type of transaction\n */\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}\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/**\n * A transaction's url that can be displayed to advanced user to track the progress\n *\n * @property {string} url - Url of the transaction in blockchain explorer. example: https://etherscan.io/tx/0xa1a3...\n * @property {string | null} description - A custom display name to help user distinguish the transactions from each\n * other. Example: Inbound, Outbound, Bridge, or null\n *\n */\nexport type SwapExplorerUrl = {\n description: string | null\n url: string\n}\n\n/**\n * APIErrorCode\n *\n * Error code of a swap failure\n *\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 *\n * @property {string} requestId - The requestId from best route endpoint\n * @property {APIErrorCode} eventType - Type of the event that happened, example: USER_REJECT\n * @property {number} [step] - Step number in which failure happened\n * @property {string} [reason] - Reason or message for the error\n * @property {[key: string]: string} [data] - A list of key-value for extra details\n * @property {wallet?: string, errorCode? string} [tags] - A list of key-value for pre-defined tags\n *\n */\nexport type ReportTransactionRequest = {\n requestId: string\n eventType: APIErrorCode\n step?: number\n reason?: string\n data?: { [key: string]: string }\n tags?: { wallet?: string; errorCode?: string }\n}\n\n/**\n * The status of transaction in tracking\n */\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 *\n * @property {boolean} isApproved - A flag which indicates that the approve tx is done or not\n * @property {TransactionStatus | null} txStatus - Status of approve transaction in blockchain,\n * if isArppoved is false and txStatus is failed, it seems that approve transaction failed in blockchain\n * @property {string | null} requiredApprovedAmount - required amount to be approved by user\n * @property {string | null} currentApprovedAmount - current approved amount by user\n *\n */\nexport type CheckApprovalResponse = {\n isApproved: boolean\n txStatus: TransactionStatus | null\n requiredApprovedAmount: string | null\n currentApprovedAmount: string | null\n}\n","import { TransactionType } from '../index.js'\nimport { BaseTransaction } from './base.js'\n\nexport enum TonChainID {\n MAINNET = '-239',\n TESTNET = '-3',\n}\n\n/**\n * @property {string} address - Receiver's address\n * @property {string} amount - Amount to send in nanoTon\n * @property {string} [stateInit] - Contract specific data to add to the transaction\n * @property {string} [payload] - Contract specific data to add to the transaction\n */\nexport interface TonMessage {\n address: string\n amount: string\n stateInit?: string\n payload?: string\n}\n\n/**\n * This type of transaction is used for all Ton transactions\n *\n * @property {TransactionType} type - This field equals to TON for all Ton transactions\n * @property {number} validUntil - Sending transaction deadline in unix epoch seconds\n * @property {TonChainID} [network] - 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 * @property {string} [from] - The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default\n * @property {TonMessage[]} messages - Messages to send: min is 1, max is 4\n */\nexport interface TonTransaction extends BaseTransaction {\n type: TransactionType.TON\n validUntil: number\n network?: TonChainID\n from?: string\n messages: TonMessage[]\n}\n\nexport const isTonTransaction = (transaction: {\n type: TransactionType\n}): transaction is TonTransaction => transaction.type === TransactionType.TON\n","export const MetamaskErrorCodes = {\n rpc: {\n invalidInput: -32000,\n resourceNotFound: -32001,\n resourceUnavailable: -32002,\n transactionRejected: -32003,\n methodNotSupported: -32004,\n limitExceeded: -32005,\n parse: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internal: -32603,\n },\n provider: {\n userRejectedRequest: 4001,\n unauthorized: 4100,\n unsupportedMethod: 4200,\n disconnected: 4900,\n chainDisconnected: 4901,\n },\n}\n","export function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","import { Signer } from 'ethers'\nimport { RangoClient } from './client'\nimport { EvmTransaction } from '../types/api/txs'\nimport {\n StatusResponse,\n SwapResponse,\n TransactionStatus,\n TransactionType,\n} from '../types/api/transactions'\nimport { sleep } from '../utils/promise'\n\nexport function prepareEvmTransaction(\n evmTx: EvmTransaction,\n isApprove: boolean\n) {\n const gasPrice =\n !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x')\n ? '0x' + parseInt(evmTx.gasPrice).toString(16)\n : null\n const manipulatedTx = {\n ...evmTx,\n gasPrice,\n }\n let tx = {}\n if (!!manipulatedTx.from) tx = { ...tx, from: manipulatedTx.from }\n if (isApprove) {\n if (!!manipulatedTx.approveTo) tx = { ...tx, to: manipulatedTx.approveTo }\n if (!!manipulatedTx.approveData)\n tx = { ...tx, data: manipulatedTx.approveData }\n } else {\n if (!!manipulatedTx.txTo) tx = { ...tx, to: manipulatedTx.txTo }\n if (!!manipulatedTx.txData) tx = { ...tx, data: manipulatedTx.txData }\n if (!!manipulatedTx.value) tx = { ...tx, value: manipulatedTx.value }\n if (!!manipulatedTx.gasLimit)\n tx = { ...tx, gasLimit: manipulatedTx.gasLimit }\n if (!!manipulatedTx.gasPrice)\n tx = { ...tx, gasPrice: manipulatedTx.gasPrice }\n }\n return tx\n}\n\nasync function checkApprovalSync(\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n): Promise<boolean> {\n while (true) {\n try {\n const approvalResponse = await rangoClient.isApproved(requestId, txId)\n if (approvalResponse?.isApproved) return true\n if (\n !approvalResponse?.isApproved &&\n approvalResponse?.txStatus === TransactionStatus.FAILED\n )\n return false\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n await sleep(3_000)\n }\n}\n\nexport const checkTransactionStatusSync = async (\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n) => {\n let txStatus: StatusResponse | undefined\n while (true) {\n try {\n txStatus = await rangoClient.status({\n requestId,\n txId,\n })\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n if (!!txStatus) {\n if (\n !!txStatus.status &&\n [TransactionStatus.FAILED, TransactionStatus.SUCCESS].includes(\n txStatus.status\n )\n ) {\n return txStatus\n }\n }\n await sleep(3_000)\n }\n}\n\nexport const executeEvmRoute = async (\n client: RangoClient,\n signer: Signer,\n route: SwapResponse\n): Promise<StatusResponse> => {\n const { tx, requestId, error, resultType } = route\n if (resultType != 'OK') throw new Error(resultType)\n if (!!error || !tx)\n throw new Error(error || 'Error creating the transaction.')\n if (tx?.type !== TransactionType.EVM)\n throw new Error('Non Evm transactions are not supported yet.')\n const evmTransaction = tx as EvmTransaction\n if (!evmTransaction) throw new Error('Transaction is null. Please try again!')\n const txChainId = parseInt(evmTransaction.blockChain.chainId || '-1')\n let signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n if (!!evmTransaction.approveTo && !!evmTransaction.approveData) {\n const approveTxData = prepareEvmTransaction(evmTransaction, true)\n const approveTx = await signer.sendTransaction(approveTxData)\n approveTx.wait()\n const isApproved = await checkApprovalSync(\n requestId,\n approveTx.hash,\n client\n )\n if (!isApproved) throw new Error('Error in approve transaction.')\n }\n signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n const mainTxData = prepareEvmTransaction(evmTransaction, false)\n const mainTx = await signer.sendTransaction(mainTxData)\n mainTx.wait()\n const status = await checkTransactionStatusSync(\n requestId,\n mainTx.hash,\n client\n )\n if (status.status !== TransactionStatus.SUCCESS)\n throw new Error(`Cross-chain swap failed. ${status.error || ''}`)\n return status\n}\n","import { getMessageFromCode } from 'eth-rpc-errors'\nimport { MetamaskErrorCodes } from '../types/utils/errors'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const prettifyError = (error: any) => {\n if (!error) return error\n if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001))\n return new Error('Transaction Rejected')\n if (error && typeof error.code === 'number') {\n if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {\n return new Error(getMessageFromCode(error.code))\n }\n if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {\n if (\n error.code === MetamaskErrorCodes.rpc.internal &&\n error.message?.includes('underpriced')\n )\n return new Error('Transaction underpriced')\n if (\n error.message?.includes('intrinsic gas too low') ||\n error.message?.includes('out of gas')\n )\n return new Error('This Gas limit is low.')\n return new Error(getMessageFromCode(error.code))\n }\n }\n if (error.message) return new Error(error.message)\n return error\n}\n","import uuid from 'uuid-random'\n\nimport {\n MetaRequest,\n MetaResponse,\n QuoteRequest,\n QuoteResponse,\n CheckApprovalResponse,\n StatusRequest,\n StatusResponse,\n SwapRequest,\n SwapResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n assetToString,\n BlockchainMeta,\n SwapperMeta,\n RequestOptions,\n MessagingProtocolsResponse,\n} from '../types'\nimport { Signer } from 'ethers'\nimport { executeEvmRoute as executeEvmRoute } from './executor'\nimport { prettifyError } from '../utils/errors'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddress = { 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, debug = false, 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 if (debug) {\n this.httpService.interceptors.request.use((request) => {\n console.log('Starting Request', JSON.stringify(request, null, 2))\n return request\n })\n this.httpService.interceptors.response.use((response) => {\n console.log('Response:', JSON.stringify(response, null, 2))\n return response\n })\n }\n }\n\n public async meta(\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<MetaResponse>(\n `/basic/meta?apiKey=${this.apiKey}`,\n {\n params,\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async chains(options?: RequestOptions): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/basic/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async swappers(options?: RequestOptions): Promise<SwapperMeta[]> {\n const axiosResponse = await this.httpService.get<SwapperMeta[]>(\n `/basic/meta/swappers?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async messagingProtocols(\n options?: RequestOptions\n ): Promise<MessagingProtocolsResponse> {\n const axiosResponse =\n await this.httpService.get<MessagingProtocolsResponse>(\n `/basic/meta/messaging-protocols?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async quote(\n quoteRequest: QuoteRequest,\n options?: RequestOptions\n ): Promise<QuoteResponse> {\n const body = {\n ...quoteRequest,\n from: assetToString(quoteRequest.from),\n to: assetToString(quoteRequest.to),\n swappers:\n !!quoteRequest.swappers && quoteRequest.swappers.length > 0\n ? quoteRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0\n ? quoteRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!quoteRequest.messagingProtocols &&\n quoteRequest.messagingProtocols.length > 0\n ? quoteRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<QuoteResponse>(\n `/basic/quote?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async isApproved(\n requestId: string,\n txId?: string,\n options?: RequestOptions\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/basic/is-approved?apiKey=${this.apiKey}`,\n {\n params: { requestId, txId },\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async status(\n statusRequest: StatusRequest,\n options?: RequestOptions\n ): Promise<StatusResponse> {\n const axiosResponse = await this.httpService.get<StatusResponse>(\n `/basic/status?apiKey=${this.apiKey}`,\n {\n params: statusRequest,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async swap(\n swapRequest: SwapRequest,\n options?: RequestOptions\n ): Promise<SwapResponse> {\n const body = {\n ...swapRequest,\n from: assetToString(swapRequest.from),\n to: assetToString(swapRequest.to),\n referrerAddress: swapRequest.referrerAddress || null,\n referrerFee: swapRequest.referrerFee || null,\n disableEstimate: swapRequest.disableEstimate || false,\n swappers:\n !!swapRequest.swappers && swapRequest.swappers.length > 0\n ? swapRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0\n ? swapRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!swapRequest.messagingProtocols &&\n swapRequest.messagingProtocols.length > 0\n ? swapRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<SwapResponse>(\n `/basic/swap?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\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 `/basic/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n }\n\n public async balance(\n walletAddress: WalletAddress,\n options?: RequestOptions\n ): Promise<WalletDetailsResponse> {\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/basic/balance?apiKey=${this.apiKey}`,\n {\n params: walletAddress,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async executeEvmRoute(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n signer: any,\n route: SwapResponse\n ): Promise<StatusResponse> {\n try {\n return await executeEvmRoute(this, signer as Signer, route)\n } catch (error) {\n const prettifiedError = prettifyError(error)\n try {\n const message = prettifiedError?.message || 'Error executing the route'\n this.reportFailure({\n requestId: route.requestId,\n eventType: 'TX_FAIL',\n reason: message,\n })\n } catch (err) {\n console.log({ err })\n }\n throw prettifiedError\n }\n }\n}\n"],"names":["assetToString","asset","address","blockchain","symbol","blockchainMeta","MetamaskErrorCodes","rpc","invalidInput","resourceNotFound","resourceUnavailable","transactionRejected","methodNotSupported","limitExceeded","parse","invalidRequest","methodNotFound","invalidParams","internal","provider","userRejectedRequest","unauthorized","unsupportedMethod","disconnected","chainDisconnected","sleep","ms","Promise","resolve","setTimeout","prepareEvmTransaction","evmTx","isApprove","gasPrice","startsWith","parseInt","toString","manipulatedTx","tx","from","approveTo","to","approveData","data","txTo","txData","value","gasLimit","checkApprovalSync","requestId","txId","rangoClient","isApproved","approvalResponse","txStatus","TransactionStatus","FAILED","console","log","err","checkTransactionStatusSync","status","SUCCESS","includes","executeEvmRoute","client","signer","route","error","resultType","Error","type","TransactionType","EVM","evmTransaction","txChainId","blockChain","chainId","getChainId","signerChainId","approveTxData","sendTransaction","approveTx","wait","hash","mainTxData","mainTx","prettifyError","code","Object","values","getMessageFromCode","message","RangoClient","apiKey","debug","apiUrl","window","deviceId","localStorage","getItem","generatedId","uuid","setItem","e","httpService","axios","create","baseURL","interceptors","request","use","JSON","stringify","response","meta","metaRequest","options","params","blockchains","join","swappers","swappersGroups","transactionTypes","get","axiosResponse","chains","messagingProtocols","quote","quoteRequest","body","length","undefined","swapperGroups","headers","statusRequest","swap","swapRequest","referrerAddress","referrerFee","disableEstimate","reportFailure","requestBody","post","balance","walletAddress","prettifiedError","eventType","reason"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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B;MAAA;MAAA;QAAA;UAAA;YAAA;YAAA,OAEI,IAAI,CAACZ,WAAW,CAACmB,GAAG,4BACrB,IAAI,CAAC9B,MAAM;cAElCwB,MAAM,EAAE2B,aAAa;cACrBX,OAAO,EAAE;gBAAE,YAAY,EAAE,IAAI,CAACpC;;eAC3BmB,OAAO,EAEb;UAAA;YAPKQ,aAAa;YAAA,mCAQZA,aAAa,CAAClF,IAAI;UAAA;UAAA;YAAA;;;KAC1B;IAAA;MAAA;;IAAA;;EAAA,OAEYqB,eAAe;IAAA,gGAArB;;IAELE,MAAW,EACXC,KAAmB;MAAA;MAAA;QAAA;UAAA;YAAA;YAAA;YAAA,OAGJH,eAAe,CAAC,IAAI,EAAEE,MAAgB,EAAEC,KAAK,CAAC;UAAA;YAAA;UAAA;YAAA;YAAA;YAErD+E,eAAe,GAAG3D,aAAa,eAAO;YAC5C,IAAI;cACIK,OAAO,GAAG,CAAAsD,eAAe,oBAAfA,eAAe,CAAEtD,OAAO,KAAI,2BAA2B;cACvE,IAAI,CAACiD,aAAa,CAAC;gBACjB5F,SAAS,EAAEkB,KAAK,CAAClB,SAAS;gBAC1BkG,SAAS,EAAE,SAAS;gBACpBC,MAAM,EAAExD;eACT,CAAC;aACH,CAAC,OAAOjC,GAAG,EAAE;cACZF,OAAO,CAACC,GAAG,CAAC;gBAAEC,GAAG,EAAHA;eAAK,CAAC;;YACrB,MACKuF,eAAe;UAAA;UAAA;YAAA;;;KAExB;IAAA;MAAA;;IAAA;;EAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("uuid-random")),r=require("eth-rpc-errors"),n=t(require("axios"));function o(){o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function p(t,e,r,o){var a=Object.create((e&&e.prototype instanceof l?e:l).prototype),i=new I(o||[]);return n(a,"_invoke",{value:T(t,r,i)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=p;var f={};function l(){}function d(){}function v(){}var y={};u(y,i,(function(){return this}));var g=Object.getPrototypeOf,x=g&&g(g(O([])));x&&x!==e&&r.call(x,i)&&(y=x);var m=v.prototype=l.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var o;n(this,"_invoke",{value:function(n,a){function i(){return new e((function(o,i){!function n(o,a,i,s){var c=h(t[o],t,a);if("throw"!==c.type){var u=c.arg,p=u.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(p).then((function(t){u.value=t,i(u)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(n,a,o,i)}))}return o=o?o.then(i,i):i()}})}function T(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=E(i,r);if(s){if(s===f)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=h(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),f;var o=h(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,f;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,f):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,f)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function O(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:N}}function N(){return{value:void 0,done:!0}}return d.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:d,configurable:!0}),d.displayName=u(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(b.prototype),u(b.prototype,s,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new b(p(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},w(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=O,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),f},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),f}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},t}function a(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){a(i,n,o,s,c,"next",t)}function c(t){a(i,n,o,s,c,"throw",t)}s(void 0)}))}}function s(){return(s=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function c(t){return t.address?t.blockchain+"."+t.symbol+"--"+t.address:t.blockchain+"."+t.symbol}var u,p,h,f,l,d=function(t){return"EVM"===t.type},v=function(t){return"COSMOS"===t.type},y=function(t){return"SOLANA"===t.type},g=function(t){return"TRON"===t.type},x=function(t){return"TRANSFER"===t.type},m=function(t){return"STARKNET"===t.type},w=function(t){return"TON"===t.type};(u=exports.RoutingResultType||(exports.RoutingResultType={})).OK="OK",u.HIGH_IMPACT="HIGH_IMPACT",u.NO_ROUTE="NO_ROUTE",u.INPUT_LIMIT_ISSUE="INPUT_LIMIT_ISSUE",(p=exports.TransactionType||(exports.TransactionType={})).EVM="EVM",p.TRANSFER="TRANSFER",p.COSMOS="COSMOS",p.SOLANA="SOLANA",p.TRON="TRON",p.STARKNET="STARKNET",p.TON="TON",(h=exports.GenericTransactionType||(exports.GenericTransactionType={})).EVM="EVM",h.TRANSFER="TRANSFER",h.COSMOS="COSMOS",h.SOLANA="SOLANA",(f=exports.TransactionStatus||(exports.TransactionStatus={})).FAILED="failed",f.RUNNING="running",f.SUCCESS="success",function(t){t.MAINNET="-239",t.TESTNET="-3"}(l||(l={}));var b={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};function T(t){return new Promise((function(e){return setTimeout(e,t)}))}function E(t,e){var r=t.gasPrice&&!t.gasPrice.startsWith("0x")?"0x"+parseInt(t.gasPrice).toString(16):null,n=s({},t,{gasPrice:r}),o={};return n.from&&(o=s({},o,{from:n.from})),e?(n.approveTo&&(o=s({},o,{to:n.approveTo})),n.approveData&&(o=s({},o,{data:n.approveData}))):(n.txTo&&(o=s({},o,{to:n.txTo})),n.txData&&(o=s({},o,{data:n.txData})),n.value&&(o=s({},o,{value:n.value})),n.gasLimit&&(o=s({},o,{gasLimit:n.gasLimit})),n.gasPrice&&(o=s({},o,{gasPrice:n.gasPrice}))),o}function S(t,e,r){return k.apply(this,arguments)}function k(){return(k=i(o().mark((function t(e,r,n){var a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,t.next=4,n.isApproved(e,r);case 4:if(null==(a=t.sent)||!a.isApproved){t.next=7;break}return t.abrupt("return",!0);case 7:if(null!=a&&a.isApproved||(null==a?void 0:a.txStatus)!==exports.TransactionStatus.FAILED){t.next=9;break}return t.abrupt("return",!1);case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),console.log("ignorinig error",{err:t.t0});case 14:return t.next=16,T(3e3);case 16:t.next=0;break;case 18:case"end":return t.stop()}}),t,null,[[1,11]])})))).apply(this,arguments)}var I=function(){var t=i(o().mark((function t(e,r,n){var a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,t.next=4,n.status({requestId:e,txId:r});case 4:a=t.sent,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),console.log("ignorinig error",{err:t.t0});case 10:if(!a){t.next=13;break}if(!a.status||![exports.TransactionStatus.FAILED,exports.TransactionStatus.SUCCESS].includes(a.status)){t.next=13;break}return t.abrupt("return",a);case 13:return t.next=15,T(3e3);case 15:t.next=0;break;case 17:case"end":return t.stop()}}),t,null,[[1,7]])})));return function(e,r,n){return t.apply(this,arguments)}}(),O=function(){var t=i(o().mark((function t(e,r,n){var a,i,s,c,u,p,h,f,l,d,v,y;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=n.tx,i=n.requestId,s=n.error,"OK"==(c=n.resultType)){t.next=3;break}throw new Error(c);case 3:if(!s&&a){t.next=5;break}throw new Error(s||"Error creating the transaction.");case 5:if((null==a?void 0:a.type)===exports.TransactionType.EVM){t.next=7;break}throw new Error("Non Evm transactions are not supported yet.");case 7:if(u=a){t.next=10;break}throw new Error("Transaction is null. Please try again!");case 10:return p=parseInt(u.blockChain.chainId||"-1"),t.next=13,r.getChainId();case 13:if((h=t.sent)===p){t.next=16;break}throw new Error("Signer chainId "+h+" doesn't match required chainId "+p+".");case 16:if(!u.approveTo||!u.approveData){t.next=27;break}return f=E(u,!0),t.next=20,r.sendTransaction(f);case 20:return(l=t.sent).wait(),t.next=24,S(i,l.hash,e);case 24:if(t.sent){t.next=27;break}throw new Error("Error in approve transaction.");case 27:return t.next=29,r.getChainId();case 29:if((h=t.sent)===p){t.next=32;break}throw new Error("Signer chainId "+h+" doesn't match required chainId "+p+".");case 32:return d=E(u,!1),t.next=35,r.sendTransaction(d);case 35:return(v=t.sent).wait(),t.next=39,I(i,v.hash,e);case 39:if((y=t.sent).status===exports.TransactionStatus.SUCCESS){t.next=42;break}throw new Error("Cross-chain swap failed. "+(y.error||""));case 42:return t.abrupt("return",y);case 43:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),N=function(t){if(!t)return t;if(t.code&&("ACTION_REJECTED"===t.code||4001===t.code))return new Error("Transaction Rejected");if(t&&"number"==typeof t.code){if(Object.values(b.provider).includes(t.code))return new Error(r.getMessageFromCode(t.code));var e,n,o;if(Object.values(b.rpc).includes(t.code))return t.code===b.rpc.internal&&null!=(e=t.message)&&e.includes("underpriced")?new Error("Transaction underpriced"):null!=(n=t.message)&&n.includes("intrinsic gas too low")||null!=(o=t.message)&&o.includes("out of gas")?new Error("This Gas limit is low."):new Error(r.getMessageFromCode(t.code))}return t.message?new Error(t.message):t},L=function(){function t(t,r,o){void 0===r&&(r=!1),this.apiUrl=o||"https://api.rango.exchange",this.apiKey=t;try{if("undefined"!=typeof window){var a=localStorage.getItem("deviceId");if(a)this.deviceId=a;else{var i=e();localStorage.setItem("deviceId",i),this.deviceId=i}}else this.deviceId=e()}catch(t){this.deviceId=e()}this.httpService=n.create({baseURL:this.apiUrl}),r&&(this.httpService.interceptors.request.use((function(t){return console.log("Starting Request",JSON.stringify(t,null,2)),t})),this.httpService.interceptors.response.use((function(t){return console.log("Response:",JSON.stringify(t,null,2)),t})))}var r=t.prototype;return r.meta=function(){var t=i(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/meta?apiKey="+this.apiKey,s({},e));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.chains=function(){var t=i(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/meta/blockchains?apiKey="+this.apiKey,s({},e));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.swappers=function(){var t=i(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/meta/swappers?apiKey="+this.apiKey,s({},e));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.messagingProtocols=function(){var t=i(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/meta/messaging-protocols?apiKey="+this.apiKey,s({},e));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.quote=function(){var t=i(o().mark((function t(e,r){var n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s({},e,{from:c(e.from),to:c(e.to),swappers:e.swappers&&e.swappers.length>0?e.swappers.join(","):void 0,swapperGroups:e.swapperGroups&&e.swapperGroups.length>0?e.swapperGroups.join(","):void 0,messagingProtocols:e.messagingProtocols&&e.messagingProtocols.length>0?e.messagingProtocols.join(","):void 0}),t.next=3,this.httpService.get("/basic/quote?apiKey="+this.apiKey,s({params:n,headers:{"X-Rango-Id":this.deviceId}},r));case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.isApproved=function(){var t=i(o().mark((function t(e,r,n){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/is-approved?apiKey="+this.apiKey,s({params:{requestId:e,txId:r},headers:{"X-Rango-Id":this.deviceId}},n));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.status=function(){var t=i(o().mark((function t(e,r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/status?apiKey="+this.apiKey,s({params:e,headers:{"X-Rango-Id":this.deviceId}},r));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.swap=function(){var t=i(o().mark((function t(e,r){var n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s({},e,{from:c(e.from),to:c(e.to),referrerAddress:e.referrerAddress||null,referrerFee:e.referrerFee||null,disableEstimate:e.disableEstimate||!1,swappers:e.swappers&&e.swappers.length>0?e.swappers.join(","):void 0,swapperGroups:e.swapperGroups&&e.swapperGroups.length>0?e.swapperGroups.join(","):void 0,messagingProtocols:e.messagingProtocols&&e.messagingProtocols.length>0?e.messagingProtocols.join(","):void 0}),t.next=3,this.httpService.get("/basic/swap?apiKey="+this.apiKey,s({params:n,headers:{"X-Rango-Id":this.deviceId}},r));case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.reportFailure=function(){var t=i(o().mark((function t(e,r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.post("/basic/report-tx?apiKey="+this.apiKey,e,s({headers:{"X-Rango-Id":this.deviceId}},r));case 2:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.balance=function(){var t=i(o().mark((function t(e,r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/balance?apiKey="+this.apiKey,s({params:e,headers:{"X-Rango-Id":this.deviceId}},r));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.executeEvmRoute=function(){var t=i(o().mark((function t(e,r){var n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O(this,e,r);case 3:return t.abrupt("return",t.sent);case 6:t.prev=6,t.t0=t.catch(0),n=N(t.t0);try{this.reportFailure({requestId:r.requestId,eventType:"TX_FAIL",reason:(null==n?void 0:n.message)||"Error executing the route"})}catch(t){console.log({err:t})}throw n;case 11:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r){return t.apply(this,arguments)}}(),t}();exports.MetamaskErrorCodes=b,exports.RangoClient=L,exports.assetToString=c,exports.cosmosBlockchains=function(t){return t.filter(v)},exports.evmBlockchains=function(t){return t.filter(d)},exports.isCosmosBlockchain=v,exports.isCosmosTransaction=function(t){return t.type===exports.TransactionType.COSMOS},exports.isEvmBlockchain=d,exports.isEvmTransaction=function(t){return t.type===exports.TransactionType.EVM},exports.isSolanaBlockchain=y,exports.isStarknetBlockchain=m,exports.isTonBlockchain=w,exports.isTransferBlockchain=x,exports.isTransferTransaction=function(t){return t.type===exports.TransactionType.TRANSFER},exports.isTronBlockchain=g,exports.solanaBlockchain=function(t){return t.filter(y)},exports.starknetBlockchain=function(t){return t.filter(m)},exports.tonBlockchain=function(t){return t.filter(w)},exports.transferBlockchains=function(t){return t.filter(x)},exports.tronBlockchain=function(t){return t.filter(g)};
|
|
1
|
+
"use strict";function t(t){return t&&"object"==typeof t&&"default"in t?t.default:t}Object.defineProperty(exports,"__esModule",{value:!0});var e=t(require("uuid-random")),r=require("eth-rpc-errors"),n=t(require("axios"));function o(){o=function(){return t};var t={},e=Object.prototype,r=e.hasOwnProperty,n=Object.defineProperty||function(t,e,r){t[e]=r.value},a="function"==typeof Symbol?Symbol:{},i=a.iterator||"@@iterator",s=a.asyncIterator||"@@asyncIterator",c=a.toStringTag||"@@toStringTag";function u(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{u({},"")}catch(t){u=function(t,e,r){return t[e]=r}}function p(t,e,r,o){var a=Object.create((e&&e.prototype instanceof f?e:f).prototype),i=new I(o||[]);return n(a,"_invoke",{value:T(t,r,i)}),a}function l(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}t.wrap=p;var h={};function f(){}function d(){}function v(){}var y={};u(y,i,(function(){return this}));var g=Object.getPrototypeOf,x=g&&g(g(O([])));x&&x!==e&&r.call(x,i)&&(y=x);var m=v.prototype=f.prototype=Object.create(y);function w(t){["next","throw","return"].forEach((function(e){u(t,e,(function(t){return this._invoke(e,t)}))}))}function b(t,e){var o;n(this,"_invoke",{value:function(n,a){function i(){return new e((function(o,i){!function n(o,a,i,s){var c=l(t[o],t,a);if("throw"!==c.type){var u=c.arg,p=u.value;return p&&"object"==typeof p&&r.call(p,"__await")?e.resolve(p.__await).then((function(t){n("next",t,i,s)}),(function(t){n("throw",t,i,s)})):e.resolve(p).then((function(t){u.value=t,i(u)}),(function(t){return n("throw",t,i,s)}))}s(c.arg)}(n,a,o,i)}))}return o=o?o.then(i,i):i()}})}function T(t,e,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var s=E(i,r);if(s){if(s===h)continue;return s}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=l(t,e,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===h)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}function E(t,e){var r=e.method,n=t.iterator[r];if(void 0===n)return e.delegate=null,"throw"===r&&t.iterator.return&&(e.method="return",e.arg=void 0,E(t,e),"throw"===e.method)||"return"!==r&&(e.method="throw",e.arg=new TypeError("The iterator does not provide a '"+r+"' method")),h;var o=l(n,t.iterator,e.arg);if("throw"===o.type)return e.method="throw",e.arg=o.arg,e.delegate=null,h;var a=o.arg;return a?a.done?(e[t.resultName]=a.value,e.next=t.nextLoc,"return"!==e.method&&(e.method="next",e.arg=void 0),e.delegate=null,h):a:(e.method="throw",e.arg=new TypeError("iterator result is not an object"),e.delegate=null,h)}function S(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function k(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function I(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(S,this),this.reset(!0)}function O(t){if(t){var e=t[i];if(e)return e.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,o=function e(){for(;++n<t.length;)if(r.call(t,n))return e.value=t[n],e.done=!1,e;return e.value=void 0,e.done=!0,e};return o.next=o}}return{next:N}}function N(){return{value:void 0,done:!0}}return d.prototype=v,n(m,"constructor",{value:v,configurable:!0}),n(v,"constructor",{value:d,configurable:!0}),d.displayName=u(v,c,"GeneratorFunction"),t.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===d||"GeneratorFunction"===(e.displayName||e.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,v):(t.__proto__=v,u(t,c,"GeneratorFunction")),t.prototype=Object.create(m),t},t.awrap=function(t){return{__await:t}},w(b.prototype),u(b.prototype,s,(function(){return this})),t.AsyncIterator=b,t.async=function(e,r,n,o,a){void 0===a&&(a=Promise);var i=new b(p(e,r,n,o),a);return t.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},w(m),u(m,c,"Generator"),u(m,i,(function(){return this})),u(m,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},t.values=O,I.prototype={constructor:I,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(k),!t)for(var e in this)"t"===e.charAt(0)&&r.call(this,e)&&!isNaN(+e.slice(1))&&(this[e]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var e=this;function n(r,n){return i.type="throw",i.arg=t,e.next=r,n&&(e.method="next",e.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var s=r.call(a,"catchLoc"),c=r.call(a,"finallyLoc");if(s&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,e){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,h):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),h},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),k(r),h}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;k(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,e,r){return this.delegate={iterator:O(t),resultName:e,nextLoc:r},"next"===this.method&&(this.arg=void 0),h}},t}function a(t,e,r,n,o,a,i){try{var s=t[a](i),c=s.value}catch(t){return void r(t)}s.done?e(c):Promise.resolve(c).then(n,o)}function i(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var i=t.apply(e,r);function s(t){a(i,n,o,s,c,"next",t)}function c(t){a(i,n,o,s,c,"throw",t)}s(void 0)}))}}function s(){return(s=Object.assign?Object.assign.bind():function(t){for(var e=1;e<arguments.length;e++){var r=arguments[e];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(t[n]=r[n])}return t}).apply(this,arguments)}function c(t){return t.address?t.blockchain+"."+t.symbol+"--"+t.address:t.blockchain+"."+t.symbol}var u,p,l,h,f,d=function(t){return"EVM"===t.type},v=function(t){return"COSMOS"===t.type},y=function(t){return"SOLANA"===t.type},g=function(t){return"TRON"===t.type},x=function(t){return"TRANSFER"===t.type},m=function(t){return"STARKNET"===t.type},w=function(t){return"TON"===t.type};(u=exports.RoutingResultType||(exports.RoutingResultType={})).OK="OK",u.HIGH_IMPACT="HIGH_IMPACT",u.NO_ROUTE="NO_ROUTE",u.INPUT_LIMIT_ISSUE="INPUT_LIMIT_ISSUE",(p=exports.TransactionType||(exports.TransactionType={})).EVM="EVM",p.TRANSFER="TRANSFER",p.COSMOS="COSMOS",p.SOLANA="SOLANA",p.TRON="TRON",p.STARKNET="STARKNET",p.TON="TON",(l=exports.GenericTransactionType||(exports.GenericTransactionType={})).EVM="EVM",l.TRANSFER="TRANSFER",l.COSMOS="COSMOS",l.SOLANA="SOLANA",(h=exports.TransactionStatus||(exports.TransactionStatus={})).FAILED="failed",h.RUNNING="running",h.SUCCESS="success",function(t){t.MAINNET="-239",t.TESTNET="-3"}(f||(f={}));var b={rpc:{invalidInput:-32e3,resourceNotFound:-32001,resourceUnavailable:-32002,transactionRejected:-32003,methodNotSupported:-32004,limitExceeded:-32005,parse:-32700,invalidRequest:-32600,methodNotFound:-32601,invalidParams:-32602,internal:-32603},provider:{userRejectedRequest:4001,unauthorized:4100,unsupportedMethod:4200,disconnected:4900,chainDisconnected:4901}};function T(t){return new Promise((function(e){return setTimeout(e,t)}))}function E(t,e){var r=t.gasPrice&&!t.gasPrice.startsWith("0x")?"0x"+parseInt(t.gasPrice).toString(16):null,n=s({},t,{gasPrice:r}),o={};return n.from&&(o=s({},o,{from:n.from})),e?(n.approveTo&&(o=s({},o,{to:n.approveTo})),n.approveData&&(o=s({},o,{data:n.approveData}))):(n.txTo&&(o=s({},o,{to:n.txTo})),n.txData&&(o=s({},o,{data:n.txData})),n.value&&(o=s({},o,{value:n.value})),n.gasLimit&&(o=s({},o,{gasLimit:n.gasLimit})),n.gasPrice&&(o=s({},o,{gasPrice:n.gasPrice}))),o}function S(t,e,r){return k.apply(this,arguments)}function k(){return(k=i(o().mark((function t(e,r,n){var a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,t.next=4,n.isApproved(e,r);case 4:if(null==(a=t.sent)||!a.isApproved){t.next=7;break}return t.abrupt("return",!0);case 7:if(null!=a&&a.isApproved||(null==a?void 0:a.txStatus)!==exports.TransactionStatus.FAILED){t.next=9;break}return t.abrupt("return",!1);case 9:t.next=14;break;case 11:t.prev=11,t.t0=t.catch(1),console.log("ignorinig error",{err:t.t0});case 14:return t.next=16,T(3e3);case 16:t.next=0;break;case 18:case"end":return t.stop()}}),t,null,[[1,11]])})))).apply(this,arguments)}var I=function(){var t=i(o().mark((function t(e,r,n){var a;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=1,t.next=4,n.status({requestId:e,txId:r});case 4:a=t.sent,t.next=10;break;case 7:t.prev=7,t.t0=t.catch(1),console.log("ignorinig error",{err:t.t0});case 10:if(!a){t.next=13;break}if(!a.status||![exports.TransactionStatus.FAILED,exports.TransactionStatus.SUCCESS].includes(a.status)){t.next=13;break}return t.abrupt("return",a);case 13:return t.next=15,T(3e3);case 15:t.next=0;break;case 17:case"end":return t.stop()}}),t,null,[[1,7]])})));return function(e,r,n){return t.apply(this,arguments)}}(),O=function(){var t=i(o().mark((function t(e,r,n){var a,i,s,c,u,p,l,h,f,d,v,y;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(a=n.tx,i=n.requestId,s=n.error,"OK"==(c=n.resultType)){t.next=3;break}throw new Error(c);case 3:if(!s&&a){t.next=5;break}throw new Error(s||"Error creating the transaction.");case 5:if((null==a?void 0:a.type)===exports.TransactionType.EVM){t.next=7;break}throw new Error("Non Evm transactions are not supported yet.");case 7:if(u=a){t.next=10;break}throw new Error("Transaction is null. Please try again!");case 10:return p=parseInt(u.blockChain.chainId||"-1"),t.next=13,r.getChainId();case 13:if((l=t.sent)===p){t.next=16;break}throw new Error("Signer chainId "+l+" doesn't match required chainId "+p+".");case 16:if(!u.approveTo||!u.approveData){t.next=27;break}return h=E(u,!0),t.next=20,r.sendTransaction(h);case 20:return(f=t.sent).wait(),t.next=24,S(i,f.hash,e);case 24:if(t.sent){t.next=27;break}throw new Error("Error in approve transaction.");case 27:return t.next=29,r.getChainId();case 29:if((l=t.sent)===p){t.next=32;break}throw new Error("Signer chainId "+l+" doesn't match required chainId "+p+".");case 32:return d=E(u,!1),t.next=35,r.sendTransaction(d);case 35:return(v=t.sent).wait(),t.next=39,I(i,v.hash,e);case 39:if((y=t.sent).status===exports.TransactionStatus.SUCCESS){t.next=42;break}throw new Error("Cross-chain swap failed. "+(y.error||""));case 42:return t.abrupt("return",y);case 43:case"end":return t.stop()}}),t)})));return function(e,r,n){return t.apply(this,arguments)}}(),N=function(t){if(!t)return t;if(t.code&&("ACTION_REJECTED"===t.code||4001===t.code))return new Error("Transaction Rejected");if(t&&"number"==typeof t.code){if(Object.values(b.provider).includes(t.code))return new Error(r.getMessageFromCode(t.code));var e,n,o;if(Object.values(b.rpc).includes(t.code))return t.code===b.rpc.internal&&null!=(e=t.message)&&e.includes("underpriced")?new Error("Transaction underpriced"):null!=(n=t.message)&&n.includes("intrinsic gas too low")||null!=(o=t.message)&&o.includes("out of gas")?new Error("This Gas limit is low."):new Error(r.getMessageFromCode(t.code))}return t.message?new Error(t.message):t},L=function(){function t(t,r,o){void 0===r&&(r=!1),this.apiUrl=o||"https://api.rango.exchange",this.apiKey=t;try{if("undefined"!=typeof window){var a=localStorage.getItem("deviceId");if(a)this.deviceId=a;else{var i=e();localStorage.setItem("deviceId",i),this.deviceId=i}}else this.deviceId=e()}catch(t){this.deviceId=e()}this.httpService=n.create({baseURL:this.apiUrl}),r&&(this.httpService.interceptors.request.use((function(t){return console.log("Starting Request",JSON.stringify(t,null,2)),t})),this.httpService.interceptors.response.use((function(t){return console.log("Response:",JSON.stringify(t,null,2)),t})))}var r=t.prototype;return r.meta=function(){var t=i(o().mark((function t(e,r){var n,a,i,c,u;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return u=s({},e,{blockchains:null==e||null==(n=e.blockchains)?void 0:n.join(),swappers:null==e||null==(a=e.swappers)?void 0:a.join(),swappersGroups:null==e||null==(i=e.swappersGroups)?void 0:i.join(),transactionTypes:null==e||null==(c=e.transactionTypes)?void 0:c.join()}),t.next=3,this.httpService.get("/basic/meta?apiKey="+this.apiKey,s({params:u},r));case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.chains=function(){var t=i(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/meta/blockchains?apiKey="+this.apiKey,s({},e));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.swappers=function(){var t=i(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/meta/swappers?apiKey="+this.apiKey,s({},e));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.messagingProtocols=function(){var t=i(o().mark((function t(e){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/meta/messaging-protocols?apiKey="+this.apiKey,s({},e));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e){return t.apply(this,arguments)}}(),r.quote=function(){var t=i(o().mark((function t(e,r){var n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s({},e,{from:c(e.from),to:c(e.to),swappers:e.swappers&&e.swappers.length>0?e.swappers.join(","):void 0,swapperGroups:e.swapperGroups&&e.swapperGroups.length>0?e.swapperGroups.join(","):void 0,messagingProtocols:e.messagingProtocols&&e.messagingProtocols.length>0?e.messagingProtocols.join(","):void 0}),t.next=3,this.httpService.get("/basic/quote?apiKey="+this.apiKey,s({params:n,headers:{"X-Rango-Id":this.deviceId}},r));case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.isApproved=function(){var t=i(o().mark((function t(e,r,n){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/is-approved?apiKey="+this.apiKey,s({params:{requestId:e,txId:r},headers:{"X-Rango-Id":this.deviceId}},n));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r,n){return t.apply(this,arguments)}}(),r.status=function(){var t=i(o().mark((function t(e,r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/status?apiKey="+this.apiKey,s({params:e,headers:{"X-Rango-Id":this.deviceId}},r));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.swap=function(){var t=i(o().mark((function t(e,r){var n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=s({},e,{from:c(e.from),to:c(e.to),referrerAddress:e.referrerAddress||null,referrerFee:e.referrerFee||null,disableEstimate:e.disableEstimate||!1,swappers:e.swappers&&e.swappers.length>0?e.swappers.join(","):void 0,swapperGroups:e.swapperGroups&&e.swapperGroups.length>0?e.swapperGroups.join(","):void 0,messagingProtocols:e.messagingProtocols&&e.messagingProtocols.length>0?e.messagingProtocols.join(","):void 0}),t.next=3,this.httpService.get("/basic/swap?apiKey="+this.apiKey,s({params:n,headers:{"X-Rango-Id":this.deviceId}},r));case 3:return t.abrupt("return",t.sent.data);case 5:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.reportFailure=function(){var t=i(o().mark((function t(e,r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.post("/basic/report-tx?apiKey="+this.apiKey,e,s({headers:{"X-Rango-Id":this.deviceId}},r));case 2:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.balance=function(){var t=i(o().mark((function t(e,r){return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,this.httpService.get("/basic/balance?apiKey="+this.apiKey,s({params:e,headers:{"X-Rango-Id":this.deviceId}},r));case 2:return t.abrupt("return",t.sent.data);case 4:case"end":return t.stop()}}),t,this)})));return function(e,r){return t.apply(this,arguments)}}(),r.executeEvmRoute=function(){var t=i(o().mark((function t(e,r){var n;return o().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,t.next=3,O(this,e,r);case 3:return t.abrupt("return",t.sent);case 6:t.prev=6,t.t0=t.catch(0),n=N(t.t0);try{this.reportFailure({requestId:r.requestId,eventType:"TX_FAIL",reason:(null==n?void 0:n.message)||"Error executing the route"})}catch(t){console.log({err:t})}throw n;case 11:case"end":return t.stop()}}),t,this,[[0,6]])})));return function(e,r){return t.apply(this,arguments)}}(),t}();exports.MetamaskErrorCodes=b,exports.RangoClient=L,exports.assetToString=c,exports.cosmosBlockchains=function(t){return t.filter(v)},exports.evmBlockchains=function(t){return t.filter(d)},exports.isCosmosBlockchain=v,exports.isCosmosTransaction=function(t){return t.type===exports.TransactionType.COSMOS},exports.isEvmBlockchain=d,exports.isEvmTransaction=function(t){return t.type===exports.TransactionType.EVM},exports.isSolanaBlockchain=y,exports.isStarknetBlockchain=m,exports.isTonBlockchain=w,exports.isTransferBlockchain=x,exports.isTransferTransaction=function(t){return t.type===exports.TransactionType.TRANSFER},exports.isTronBlockchain=g,exports.solanaBlockchain=function(t){return t.filter(y)},exports.starknetBlockchain=function(t){return t.filter(m)},exports.tonBlockchain=function(t){return t.filter(w)},exports.transferBlockchains=function(t){return t.filter(x)},exports.tronBlockchain=function(t){return t.filter(g)};
|
|
2
2
|
//# sourceMappingURL=rango-sdk-basic.cjs.production.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rango-sdk-basic.cjs.production.min.js","sources":["../src/types/api/common.ts","../../../node_modules/rango-types/src/api/shared/type-gaurds.ts","../src/types/utils/errors.ts","../src/utils/promise.ts","../src/services/executor.ts","../src/utils/errors.ts","../src/services/client.ts"],"sourcesContent":["import { Asset } from 'rango-types/lib/api/basic'\nexport * from 'rango-types/lib/api/basic/common'\n\nexport function assetToString(asset: Asset): string {\n if (!!asset.address)\n return `${asset.blockchain}.${asset.symbol}--${asset.address}`\n else return `${asset.blockchain}.${asset.symbol}`\n}\n","import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\n} from './meta'\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 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","export const MetamaskErrorCodes = {\n rpc: {\n invalidInput: -32000,\n resourceNotFound: -32001,\n resourceUnavailable: -32002,\n transactionRejected: -32003,\n methodNotSupported: -32004,\n limitExceeded: -32005,\n parse: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internal: -32603,\n },\n provider: {\n userRejectedRequest: 4001,\n unauthorized: 4100,\n unsupportedMethod: 4200,\n disconnected: 4900,\n chainDisconnected: 4901,\n },\n}\n","export function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","import { Signer } from 'ethers'\nimport { RangoClient } from './client'\nimport { EvmTransaction } from '../types/api/txs'\nimport {\n StatusResponse,\n SwapResponse,\n TransactionStatus,\n TransactionType,\n} from '../types/api/transactions'\nimport { sleep } from '../utils/promise'\n\nexport function prepareEvmTransaction(\n evmTx: EvmTransaction,\n isApprove: boolean\n) {\n const gasPrice =\n !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x')\n ? '0x' + parseInt(evmTx.gasPrice).toString(16)\n : null\n const manipulatedTx = {\n ...evmTx,\n gasPrice,\n }\n let tx = {}\n if (!!manipulatedTx.from) tx = { ...tx, from: manipulatedTx.from }\n if (isApprove) {\n if (!!manipulatedTx.approveTo) tx = { ...tx, to: manipulatedTx.approveTo }\n if (!!manipulatedTx.approveData)\n tx = { ...tx, data: manipulatedTx.approveData }\n } else {\n if (!!manipulatedTx.txTo) tx = { ...tx, to: manipulatedTx.txTo }\n if (!!manipulatedTx.txData) tx = { ...tx, data: manipulatedTx.txData }\n if (!!manipulatedTx.value) tx = { ...tx, value: manipulatedTx.value }\n if (!!manipulatedTx.gasLimit)\n tx = { ...tx, gasLimit: manipulatedTx.gasLimit }\n if (!!manipulatedTx.gasPrice)\n tx = { ...tx, gasPrice: manipulatedTx.gasPrice }\n }\n return tx\n}\n\nasync function checkApprovalSync(\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n): Promise<boolean> {\n while (true) {\n try {\n const approvalResponse = await rangoClient.isApproved(requestId, txId)\n if (approvalResponse?.isApproved) return true\n if (\n !approvalResponse?.isApproved &&\n approvalResponse?.txStatus === TransactionStatus.FAILED\n )\n return false\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n await sleep(3_000)\n }\n}\n\nexport const checkTransactionStatusSync = async (\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n) => {\n let txStatus: StatusResponse | undefined\n while (true) {\n try {\n txStatus = await rangoClient.status({\n requestId,\n txId,\n })\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n if (!!txStatus) {\n if (\n !!txStatus.status &&\n [TransactionStatus.FAILED, TransactionStatus.SUCCESS].includes(\n txStatus.status\n )\n ) {\n return txStatus\n }\n }\n await sleep(3_000)\n }\n}\n\nexport const executeEvmRoute = async (\n client: RangoClient,\n signer: Signer,\n route: SwapResponse\n): Promise<StatusResponse> => {\n const { tx, requestId, error, resultType } = route\n if (resultType != 'OK') throw new Error(resultType)\n if (!!error || !tx)\n throw new Error(error || 'Error creating the transaction.')\n if (tx?.type !== TransactionType.EVM)\n throw new Error('Non Evm transactions are not supported yet.')\n const evmTransaction = tx as EvmTransaction\n if (!evmTransaction) throw new Error('Transaction is null. Please try again!')\n const txChainId = parseInt(evmTransaction.blockChain.chainId || '-1')\n let signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n if (!!evmTransaction.approveTo && !!evmTransaction.approveData) {\n const approveTxData = prepareEvmTransaction(evmTransaction, true)\n const approveTx = await signer.sendTransaction(approveTxData)\n approveTx.wait()\n const isApproved = await checkApprovalSync(\n requestId,\n approveTx.hash,\n client\n )\n if (!isApproved) throw new Error('Error in approve transaction.')\n }\n signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n const mainTxData = prepareEvmTransaction(evmTransaction, false)\n const mainTx = await signer.sendTransaction(mainTxData)\n mainTx.wait()\n const status = await checkTransactionStatusSync(\n requestId,\n mainTx.hash,\n client\n )\n if (status.status !== TransactionStatus.SUCCESS)\n throw new Error(`Cross-chain swap failed. ${status.error || ''}`)\n return status\n}\n","import { getMessageFromCode } from 'eth-rpc-errors'\nimport { MetamaskErrorCodes } from '../types/utils/errors'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const prettifyError = (error: any) => {\n if (!error) return error\n if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001))\n return new Error('Transaction Rejected')\n if (error && typeof error.code === 'number') {\n if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {\n return new Error(getMessageFromCode(error.code))\n }\n if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {\n if (\n error.code === MetamaskErrorCodes.rpc.internal &&\n error.message?.includes('underpriced')\n )\n return new Error('Transaction underpriced')\n if (\n error.message?.includes('intrinsic gas too low') ||\n error.message?.includes('out of gas')\n )\n return new Error('This Gas limit is low.')\n return new Error(getMessageFromCode(error.code))\n }\n }\n if (error.message) return new Error(error.message)\n return error\n}\n","import uuid from 'uuid-random'\n\nimport {\n MetaResponse,\n QuoteRequest,\n QuoteResponse,\n CheckApprovalResponse,\n StatusRequest,\n StatusResponse,\n SwapRequest,\n SwapResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n assetToString,\n BlockchainMeta,\n SwapperMeta,\n RequestOptions,\n MessagingProtocolsResponse,\n} from '../types'\nimport { Signer } from 'ethers'\nimport { executeEvmRoute as executeEvmRoute } from './executor'\nimport { prettifyError } from '../utils/errors'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddress = { 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, debug = false, 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 if (debug) {\n this.httpService.interceptors.request.use((request) => {\n console.log('Starting Request', JSON.stringify(request, null, 2))\n return request\n })\n this.httpService.interceptors.response.use((response) => {\n console.log('Response:', JSON.stringify(response, null, 2))\n return response\n })\n }\n }\n\n public async meta(options?: RequestOptions): Promise<MetaResponse> {\n const axiosResponse = await this.httpService.get<MetaResponse>(\n `/basic/meta?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async chains(options?: RequestOptions): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/basic/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async swappers(options?: RequestOptions): Promise<SwapperMeta[]> {\n const axiosResponse = await this.httpService.get<SwapperMeta[]>(\n `/basic/meta/swappers?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async messagingProtocols(\n options?: RequestOptions\n ): Promise<MessagingProtocolsResponse> {\n const axiosResponse =\n await this.httpService.get<MessagingProtocolsResponse>(\n `/basic/meta/messaging-protocols?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async quote(\n quoteRequest: QuoteRequest,\n options?: RequestOptions\n ): Promise<QuoteResponse> {\n const body = {\n ...quoteRequest,\n from: assetToString(quoteRequest.from),\n to: assetToString(quoteRequest.to),\n swappers:\n !!quoteRequest.swappers && quoteRequest.swappers.length > 0\n ? quoteRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0\n ? quoteRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!quoteRequest.messagingProtocols &&\n quoteRequest.messagingProtocols.length > 0\n ? quoteRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<QuoteResponse>(\n `/basic/quote?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async isApproved(\n requestId: string,\n txId?: string,\n options?: RequestOptions\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/basic/is-approved?apiKey=${this.apiKey}`,\n {\n params: { requestId, txId },\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async status(\n statusRequest: StatusRequest,\n options?: RequestOptions\n ): Promise<StatusResponse> {\n const axiosResponse = await this.httpService.get<StatusResponse>(\n `/basic/status?apiKey=${this.apiKey}`,\n {\n params: statusRequest,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async swap(\n swapRequest: SwapRequest,\n options?: RequestOptions\n ): Promise<SwapResponse> {\n const body = {\n ...swapRequest,\n from: assetToString(swapRequest.from),\n to: assetToString(swapRequest.to),\n referrerAddress: swapRequest.referrerAddress || null,\n referrerFee: swapRequest.referrerFee || null,\n disableEstimate: swapRequest.disableEstimate || false,\n swappers:\n !!swapRequest.swappers && swapRequest.swappers.length > 0\n ? swapRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0\n ? swapRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!swapRequest.messagingProtocols &&\n swapRequest.messagingProtocols.length > 0\n ? swapRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<SwapResponse>(\n `/basic/swap?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\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 `/basic/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n }\n\n public async balance(\n walletAddress: WalletAddress,\n options?: RequestOptions\n ): Promise<WalletDetailsResponse> {\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/basic/balance?apiKey=${this.apiKey}`,\n {\n params: walletAddress,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async executeEvmRoute(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n signer: any,\n route: SwapResponse\n ): Promise<StatusResponse> {\n try {\n return await executeEvmRoute(this, signer as Signer, route)\n } catch (error) {\n const prettifiedError = prettifyError(error)\n try {\n const message = prettifiedError?.message || 'Error executing the route'\n this.reportFailure({\n requestId: route.requestId,\n eventType: 'TX_FAIL',\n reason: message,\n })\n } catch (err) {\n console.log({ err })\n }\n throw prettifiedError\n }\n }\n}\n"],"names":["assetToString","asset","address","blockchain","symbol","blockchainMeta","MetamaskErrorCodes","rpc","invalidInput","resourceNotFound","resourceUnavailable","transactionRejected","methodNotSupported","limitExceeded","parse","invalidRequest","methodNotFound","invalidParams","internal","provider","userRejectedRequest","unauthorized","unsupportedMethod","disconnected","chainDisconnected","sleep","ms","Promise","resolve","setTimeout","prepareEvmTransaction","evmTx","isApprove","gasPrice","startsWith","parseInt","toString","manipulatedTx","tx","from","approveTo","to","approveData","data","txTo","txData","value","gasLimit","checkApprovalSync","_checkApprovalSync","requestId","txId","rangoClient","_context3","isApproved","approvalResponse","txStatus","TransactionStatus","FAILED","console","log","err","checkTransactionStatusSync","_context","status","SUCCESS","includes","executeEvmRoute","client","signer","route","error","resultType","_context2","Error","type","TransactionType","EVM","evmTransaction","txChainId","blockChain","chainId","getChainId","signerChainId","approveTxData","sendTransaction","approveTx","wait","hash","mainTxData","mainTx","prettifyError","code","Object","values","getMessageFromCode","message","_error$message","_error$message2","_error$message3","RangoClient","apiKey","debug","apiUrl","this","window","deviceId","localStorage","getItem","generatedId","uuid","setItem","e","httpService","axios","create","baseURL","interceptors","request","use","JSON","stringify","response","_proto","meta","options","get","chains","swappers","messagingProtocols","_context4","quote","quoteRequest","body","length","join","undefined","swapperGroups","_context5","params","headers","X-Rango-Id","_context6","statusRequest","_context7","swap","swapRequest","referrerAddress","referrerFee","disableEstimate","_context8","reportFailure","requestBody","_context9","post","balance","walletAddress","_context10","_context11","prettifiedError","eventType","reason"],"mappings":"2sOAGgBA,EAAcC,GAC5B,OAAMA,EAAMC,QACAD,EAAME,eAAcF,EAAMG,YAAWH,EAAMC,QACxCD,EAAME,eAAcF,EAAMG,oECuCHC,mHAYEA,uvBCzD7BC,EAAqB,CAChCC,IAAK,CACHC,cAAe,KACfC,kBAAmB,MACnBC,qBAAsB,MACtBC,qBAAsB,MACtBC,oBAAqB,MACrBC,eAAgB,MAChBC,OAAQ,MACRC,gBAAiB,MACjBC,gBAAiB,MACjBC,eAAg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,SAAAA,SAGJ3F,EAAgBqC,KAAMnC,EAAkBC,GAAM,OAAA,iCAAA,OAAAwF,SAAAA,gBAErDC,EAAkBpE,QACxB,IAEEa,KAAK+C,cAAc,CACjBrG,UAAWoB,EAAMpB,UACjB8G,UAAW,UACXC,cAJcF,SAAAA,EAAiB/D,UAAW,8BAM5C,MAAOnC,GACPF,QAAQC,IAAI,CAAEC,IAAAA,IACf,MACKkG,EAAe,QAAA,UAAA,uCAExB,OAAA,cAAA"}
|
|
1
|
+
{"version":3,"file":"rango-sdk-basic.cjs.production.min.js","sources":["../src/types/api/common.ts","../../../node_modules/rango-types/src/api/shared/type-gaurds.ts","../src/types/utils/errors.ts","../src/utils/promise.ts","../src/services/executor.ts","../src/utils/errors.ts","../src/services/client.ts"],"sourcesContent":["import { Asset } from 'rango-types/lib/api/basic'\nexport * from 'rango-types/lib/api/basic/common'\n\nexport function assetToString(asset: Asset): string {\n if (!!asset.address)\n return `${asset.blockchain}.${asset.symbol}--${asset.address}`\n else return `${asset.blockchain}.${asset.symbol}`\n}\n","import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\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 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","export const MetamaskErrorCodes = {\n rpc: {\n invalidInput: -32000,\n resourceNotFound: -32001,\n resourceUnavailable: -32002,\n transactionRejected: -32003,\n methodNotSupported: -32004,\n limitExceeded: -32005,\n parse: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internal: -32603,\n },\n provider: {\n userRejectedRequest: 4001,\n unauthorized: 4100,\n unsupportedMethod: 4200,\n disconnected: 4900,\n chainDisconnected: 4901,\n },\n}\n","export function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","import { Signer } from 'ethers'\nimport { RangoClient } from './client'\nimport { EvmTransaction } from '../types/api/txs'\nimport {\n StatusResponse,\n SwapResponse,\n TransactionStatus,\n TransactionType,\n} from '../types/api/transactions'\nimport { sleep } from '../utils/promise'\n\nexport function prepareEvmTransaction(\n evmTx: EvmTransaction,\n isApprove: boolean\n) {\n const gasPrice =\n !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x')\n ? '0x' + parseInt(evmTx.gasPrice).toString(16)\n : null\n const manipulatedTx = {\n ...evmTx,\n gasPrice,\n }\n let tx = {}\n if (!!manipulatedTx.from) tx = { ...tx, from: manipulatedTx.from }\n if (isApprove) {\n if (!!manipulatedTx.approveTo) tx = { ...tx, to: manipulatedTx.approveTo }\n if (!!manipulatedTx.approveData)\n tx = { ...tx, data: manipulatedTx.approveData }\n } else {\n if (!!manipulatedTx.txTo) tx = { ...tx, to: manipulatedTx.txTo }\n if (!!manipulatedTx.txData) tx = { ...tx, data: manipulatedTx.txData }\n if (!!manipulatedTx.value) tx = { ...tx, value: manipulatedTx.value }\n if (!!manipulatedTx.gasLimit)\n tx = { ...tx, gasLimit: manipulatedTx.gasLimit }\n if (!!manipulatedTx.gasPrice)\n tx = { ...tx, gasPrice: manipulatedTx.gasPrice }\n }\n return tx\n}\n\nasync function checkApprovalSync(\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n): Promise<boolean> {\n while (true) {\n try {\n const approvalResponse = await rangoClient.isApproved(requestId, txId)\n if (approvalResponse?.isApproved) return true\n if (\n !approvalResponse?.isApproved &&\n approvalResponse?.txStatus === TransactionStatus.FAILED\n )\n return false\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n await sleep(3_000)\n }\n}\n\nexport const checkTransactionStatusSync = async (\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n) => {\n let txStatus: StatusResponse | undefined\n while (true) {\n try {\n txStatus = await rangoClient.status({\n requestId,\n txId,\n })\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n if (!!txStatus) {\n if (\n !!txStatus.status &&\n [TransactionStatus.FAILED, TransactionStatus.SUCCESS].includes(\n txStatus.status\n )\n ) {\n return txStatus\n }\n }\n await sleep(3_000)\n }\n}\n\nexport const executeEvmRoute = async (\n client: RangoClient,\n signer: Signer,\n route: SwapResponse\n): Promise<StatusResponse> => {\n const { tx, requestId, error, resultType } = route\n if (resultType != 'OK') throw new Error(resultType)\n if (!!error || !tx)\n throw new Error(error || 'Error creating the transaction.')\n if (tx?.type !== TransactionType.EVM)\n throw new Error('Non Evm transactions are not supported yet.')\n const evmTransaction = tx as EvmTransaction\n if (!evmTransaction) throw new Error('Transaction is null. Please try again!')\n const txChainId = parseInt(evmTransaction.blockChain.chainId || '-1')\n let signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n if (!!evmTransaction.approveTo && !!evmTransaction.approveData) {\n const approveTxData = prepareEvmTransaction(evmTransaction, true)\n const approveTx = await signer.sendTransaction(approveTxData)\n approveTx.wait()\n const isApproved = await checkApprovalSync(\n requestId,\n approveTx.hash,\n client\n )\n if (!isApproved) throw new Error('Error in approve transaction.')\n }\n signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n const mainTxData = prepareEvmTransaction(evmTransaction, false)\n const mainTx = await signer.sendTransaction(mainTxData)\n mainTx.wait()\n const status = await checkTransactionStatusSync(\n requestId,\n mainTx.hash,\n client\n )\n if (status.status !== TransactionStatus.SUCCESS)\n throw new Error(`Cross-chain swap failed. ${status.error || ''}`)\n return status\n}\n","import { getMessageFromCode } from 'eth-rpc-errors'\nimport { MetamaskErrorCodes } from '../types/utils/errors'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const prettifyError = (error: any) => {\n if (!error) return error\n if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001))\n return new Error('Transaction Rejected')\n if (error && typeof error.code === 'number') {\n if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {\n return new Error(getMessageFromCode(error.code))\n }\n if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {\n if (\n error.code === MetamaskErrorCodes.rpc.internal &&\n error.message?.includes('underpriced')\n )\n return new Error('Transaction underpriced')\n if (\n error.message?.includes('intrinsic gas too low') ||\n error.message?.includes('out of gas')\n )\n return new Error('This Gas limit is low.')\n return new Error(getMessageFromCode(error.code))\n }\n }\n if (error.message) return new Error(error.message)\n return error\n}\n","import uuid from 'uuid-random'\n\nimport {\n MetaRequest,\n MetaResponse,\n QuoteRequest,\n QuoteResponse,\n CheckApprovalResponse,\n StatusRequest,\n StatusResponse,\n SwapRequest,\n SwapResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n assetToString,\n BlockchainMeta,\n SwapperMeta,\n RequestOptions,\n MessagingProtocolsResponse,\n} from '../types'\nimport { Signer } from 'ethers'\nimport { executeEvmRoute as executeEvmRoute } from './executor'\nimport { prettifyError } from '../utils/errors'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddress = { 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, debug = false, 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 if (debug) {\n this.httpService.interceptors.request.use((request) => {\n console.log('Starting Request', JSON.stringify(request, null, 2))\n return request\n })\n this.httpService.interceptors.response.use((response) => {\n console.log('Response:', JSON.stringify(response, null, 2))\n return response\n })\n }\n }\n\n public async meta(\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<MetaResponse>(\n `/basic/meta?apiKey=${this.apiKey}`,\n {\n params,\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async chains(options?: RequestOptions): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/basic/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async swappers(options?: RequestOptions): Promise<SwapperMeta[]> {\n const axiosResponse = await this.httpService.get<SwapperMeta[]>(\n `/basic/meta/swappers?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async messagingProtocols(\n options?: RequestOptions\n ): Promise<MessagingProtocolsResponse> {\n const axiosResponse =\n await this.httpService.get<MessagingProtocolsResponse>(\n `/basic/meta/messaging-protocols?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async quote(\n quoteRequest: QuoteRequest,\n options?: RequestOptions\n ): Promise<QuoteResponse> {\n const body = {\n ...quoteRequest,\n from: assetToString(quoteRequest.from),\n to: assetToString(quoteRequest.to),\n swappers:\n !!quoteRequest.swappers && quoteRequest.swappers.length > 0\n ? quoteRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0\n ? quoteRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!quoteRequest.messagingProtocols &&\n quoteRequest.messagingProtocols.length > 0\n ? quoteRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<QuoteResponse>(\n `/basic/quote?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async isApproved(\n requestId: string,\n txId?: string,\n options?: RequestOptions\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/basic/is-approved?apiKey=${this.apiKey}`,\n {\n params: { requestId, txId },\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async status(\n statusRequest: StatusRequest,\n options?: RequestOptions\n ): Promise<StatusResponse> {\n const axiosResponse = await this.httpService.get<StatusResponse>(\n `/basic/status?apiKey=${this.apiKey}`,\n {\n params: statusRequest,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async swap(\n swapRequest: SwapRequest,\n options?: RequestOptions\n ): Promise<SwapResponse> {\n const body = {\n ...swapRequest,\n from: assetToString(swapRequest.from),\n to: assetToString(swapRequest.to),\n referrerAddress: swapRequest.referrerAddress || null,\n referrerFee: swapRequest.referrerFee || null,\n disableEstimate: swapRequest.disableEstimate || false,\n swappers:\n !!swapRequest.swappers && swapRequest.swappers.length > 0\n ? swapRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0\n ? swapRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!swapRequest.messagingProtocols &&\n swapRequest.messagingProtocols.length > 0\n ? swapRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<SwapResponse>(\n `/basic/swap?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\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 `/basic/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n }\n\n public async balance(\n walletAddress: WalletAddress,\n options?: RequestOptions\n ): Promise<WalletDetailsResponse> {\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/basic/balance?apiKey=${this.apiKey}`,\n {\n params: walletAddress,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async executeEvmRoute(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n signer: any,\n route: SwapResponse\n ): Promise<StatusResponse> {\n try {\n return await executeEvmRoute(this, signer as Signer, route)\n } catch (error) {\n const prettifiedError = prettifyError(error)\n try {\n const message = prettifiedError?.message || 'Error executing the route'\n this.reportFailure({\n requestId: route.requestId,\n eventType: 'TX_FAIL',\n reason: message,\n })\n } catch (err) {\n console.log({ err })\n }\n throw prettifiedError\n }\n }\n}\n"],"names":["assetToString","asset","address","blockchain","symbol","blockchainMeta","MetamaskErrorCodes","rpc","invalidInput","resourceNotFound","resourceUnavailable","transactionRejected","methodNotSupported","limitExceeded","parse","invalidRequest","methodNotFound","invalidParams","internal","provider","userRejectedRequest","unauthorized","unsupportedMethod","disconnected","chainDisconnected","sleep","ms","Promise","resolve","setTimeout","prepareEvmTransaction","evmTx","isApprove","gasPrice","startsWith","parseInt","toString","manipulatedTx","tx","from","approveTo","to","approveData","data","txTo","txData","value","gasLimit","checkApprovalSync","_checkApprovalSync","requestId","txId","rangoClient","_context3","isApproved","approvalResponse","txStatus","TransactionStatus","FAILED","console","log","err","checkTransactionStatusSync","_context","status","SUCCESS","includes","executeEvmRoute","client","signer","route","error","resultType","_context2","Error","type","TransactionType","EVM","evmTransaction","txChainId","blockChain","chainId","getChainId","signerChainId","approveTxData","sendTransaction","approveTx","wait","hash","mainTxData","mainTx","prettifyError","code","Object","values","getMessageFromCode","message","_error$message","_error$message2","_error$message3","RangoClient","apiKey","debug","apiUrl","this","window","deviceId","localStorage","getItem","generatedId","uuid","setItem","e","httpService","axios","create","baseURL","interceptors","request","use","JSON","stringify","response","_proto","meta","metaRequest","options","params","blockchains","_metaRequest$blockcha","join","swappers","_metaRequest$swappers","swappersGroups","_metaRequest$swappers2","transactionTypes","_metaRequest$transact","get","chains","messagingProtocols","_context4","quote","quoteRequest","body","length","undefined","swapperGroups","_context5","headers","X-Rango-Id","_context6","statusRequest","_context7","swap","swapRequest","referrerAddress","referrerFee","disableEstimate","_context8","reportFailure","requestBody","_context9","post","balance","walletAddress","_context10","_context11","prettifiedError","eventType","reason"],"mappings":"2sOAGgBA,EAAcC,GAC5B,OAAMA,EAAMC,QACAD,EAAME,eAAcF,EAAMG,YAAWH,EAAMC,QACxCD,EAAME,eAAcF,EAAMG,oECuCHC,mHAYEA,uvBCzD7BC,EAAqB,CAChCC,IAAK,CACHC,cAAe,KACfC,kBAAmB,MACnBC,qBAAsB,MACtBC,qBAAsB,MACtBC,oBAAqB,MACrBC,eAAgB,MAChBC,OAAQ,MACRC,gBAAiB,MACjBC,gBAAiB,MACjBC,eAAgB,MAChBC,UAAW,OAEbC,SAAU,CACRC,oBAAqB,KACrBC,aAAc,KACdC,kBAAmB,KACnBC,aAAc,KACdC,kBAAmB,gBCnBPC,EAAMC,GACpB,OAAO,IAAIC,SAAQ,SAACC,GAAO,OAAKC,WAAWD,EAASF,eCUtCI,EACdC,EACAC,GAEA,IAAMC,EACFF,EAAME,WAAaF,EAAME,SAASC,WAAW,MAC3C,KAAOC,SAASJ,EAAME,UAAUG,SAAS,IACzC,KACAC,OACDN,GACHE,SAAAA,IAEEK,EAAK,GAeT,OAdMD,EAAcE,OAAMD,OAAUA,GAAIC,KAAMF,EAAcE,QACxDP,GACIK,EAAcG,YAAWF,OAAUA,GAAIG,GAAIJ,EAAcG,aACzDH,EAAcK,cAClBJ,OAAUA,GAAIK,KAAMN,EAAcK,iBAE9BL,EAAcO,OAAMN,OAAUA,GAAIG,GAAIJ,EAAcO,QACpDP,EAAcQ,SAAQP,OAAUA,GAAIK,KAAMN,EAAcQ,UACxDR,EAAcS,QAAOR,OAAUA,GAAIQ,MAAOT,EAAcS,SACxDT,EAAcU,WAClBT,OAAUA,GAAIS,SAAUV,EAAcU,YAClCV,EAAcJ,WAClBK,OAAUA,GAAIL,SAAUI,EAAcJ,aAEnCK,EACR,SAEcU,SAAiB,+BAAA,aAmB/B,OA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BACrBjC,KAAKH,UAEzB0B,OAAQgB,EACRK,QAAS,CAAEC,aAAc7C,KAAKE,WAC3BoB,IAEN,OAPkB,gCAQEnF,MAAI,OAAA,UAAA,+BAC1B,OAAA,cAAA,mCAAAgF,EAEYoC,yBAAa,kBAAnB,WACLC,EACAlC,GAAwB,6BAAA,6BAAA,OAAA,OAAAmC,SAElBzD,KAAKS,YAAYiD,gCACM1D,KAAKH,OAChC2D,KAEEZ,QAAS,CAAEC,aAAc7C,KAAKE,WAC3BoB,IAEN,OAAA,UAAA,+BACF,OAAA,cAAA,mCAAAH,EAEYwC,mBAAO,kBAAb,WACLC,EACAtC,GAAwB,6BAAA,6BAAA,OAAA,OAAAuC,SAEI7D,KAAKS,YAAYwB,6BAClBjC,KAAKH,UAE5B0B,OAAQqC,EACRhB,QAAS,CAAEC,aAAc7C,KAAKE,WAC3BoB,IAEN,OAPkB,gCAQEnF,MAAI,OAAA,UAAA,+BAC1B,OAAA,cAAA,mCAAAgF,EAEYxD,2BAAe,kBAArB,WAELE,EACAC,GAAmB,MAAA,6BAAA,6BAAA,OAAA,OAAAgG,SAAAA,SAGJnG,EAAgBqC,KAAMnC,EAAkBC,GAAM,OAAA,iCAAA,OAAAgG,SAAAA,gBAErDC,EAAkB5E,QACxB,IAEEa,KAAKuD,cAAc,CACjB7G,UAAWoB,EAAMpB,UACjBsH,UAAW,UACXC,cAJcF,SAAAA,EAAiBvE,UAAW,8BAM5C,MAAOnC,GACPF,QAAQC,IAAI,CAAEC,IAAAA,IACf,MACK0G,EAAe,QAAA,UAAA,uCAExB,OAAA,cAAA"}
|
|
@@ -778,23 +778,32 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
778
778
|
}
|
|
779
779
|
var _proto = RangoClient.prototype;
|
|
780
780
|
_proto.meta = /*#__PURE__*/function () {
|
|
781
|
-
var _meta = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(options) {
|
|
782
|
-
var
|
|
781
|
+
var _meta = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(metaRequest, options) {
|
|
782
|
+
var _metaRequest$blockcha, _metaRequest$swappers, _metaRequest$swappers2, _metaRequest$transact;
|
|
783
|
+
var params, axiosResponse;
|
|
783
784
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
784
785
|
while (1) switch (_context.prev = _context.next) {
|
|
785
786
|
case 0:
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
787
|
+
params = _extends({}, metaRequest, {
|
|
788
|
+
blockchains: metaRequest == null ? void 0 : (_metaRequest$blockcha = metaRequest.blockchains) == null ? void 0 : _metaRequest$blockcha.join(),
|
|
789
|
+
swappers: metaRequest == null ? void 0 : (_metaRequest$swappers = metaRequest.swappers) == null ? void 0 : _metaRequest$swappers.join(),
|
|
790
|
+
swappersGroups: metaRequest == null ? void 0 : (_metaRequest$swappers2 = metaRequest.swappersGroups) == null ? void 0 : _metaRequest$swappers2.join(),
|
|
791
|
+
transactionTypes: metaRequest == null ? void 0 : (_metaRequest$transact = metaRequest.transactionTypes) == null ? void 0 : _metaRequest$transact.join()
|
|
792
|
+
});
|
|
793
|
+
_context.next = 3;
|
|
794
|
+
return this.httpService.get("/basic/meta?apiKey=" + this.apiKey, _extends({
|
|
795
|
+
params: params
|
|
796
|
+
}, options));
|
|
797
|
+
case 3:
|
|
789
798
|
axiosResponse = _context.sent;
|
|
790
799
|
return _context.abrupt("return", axiosResponse.data);
|
|
791
|
-
case
|
|
800
|
+
case 5:
|
|
792
801
|
case "end":
|
|
793
802
|
return _context.stop();
|
|
794
803
|
}
|
|
795
804
|
}, _callee, this);
|
|
796
805
|
}));
|
|
797
|
-
function meta(_x) {
|
|
806
|
+
function meta(_x, _x2) {
|
|
798
807
|
return _meta.apply(this, arguments);
|
|
799
808
|
}
|
|
800
809
|
return meta;
|
|
@@ -816,7 +825,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
816
825
|
}
|
|
817
826
|
}, _callee2, this);
|
|
818
827
|
}));
|
|
819
|
-
function chains(
|
|
828
|
+
function chains(_x3) {
|
|
820
829
|
return _chains.apply(this, arguments);
|
|
821
830
|
}
|
|
822
831
|
return chains;
|
|
@@ -838,7 +847,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
838
847
|
}
|
|
839
848
|
}, _callee3, this);
|
|
840
849
|
}));
|
|
841
|
-
function swappers(
|
|
850
|
+
function swappers(_x4) {
|
|
842
851
|
return _swappers.apply(this, arguments);
|
|
843
852
|
}
|
|
844
853
|
return swappers;
|
|
@@ -860,7 +869,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
860
869
|
}
|
|
861
870
|
}, _callee4, this);
|
|
862
871
|
}));
|
|
863
|
-
function messagingProtocols(
|
|
872
|
+
function messagingProtocols(_x5) {
|
|
864
873
|
return _messagingProtocols.apply(this, arguments);
|
|
865
874
|
}
|
|
866
875
|
return messagingProtocols;
|
|
@@ -894,7 +903,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
894
903
|
}
|
|
895
904
|
}, _callee5, this);
|
|
896
905
|
}));
|
|
897
|
-
function quote(
|
|
906
|
+
function quote(_x6, _x7) {
|
|
898
907
|
return _quote.apply(this, arguments);
|
|
899
908
|
}
|
|
900
909
|
return quote;
|
|
@@ -924,7 +933,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
924
933
|
}
|
|
925
934
|
}, _callee6, this);
|
|
926
935
|
}));
|
|
927
|
-
function isApproved(
|
|
936
|
+
function isApproved(_x8, _x9, _x10) {
|
|
928
937
|
return _isApproved.apply(this, arguments);
|
|
929
938
|
}
|
|
930
939
|
return isApproved;
|
|
@@ -951,7 +960,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
951
960
|
}
|
|
952
961
|
}, _callee7, this);
|
|
953
962
|
}));
|
|
954
|
-
function status(
|
|
963
|
+
function status(_x11, _x12) {
|
|
955
964
|
return _status.apply(this, arguments);
|
|
956
965
|
}
|
|
957
966
|
return status;
|
|
@@ -988,7 +997,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
988
997
|
}
|
|
989
998
|
}, _callee8, this);
|
|
990
999
|
}));
|
|
991
|
-
function swap(
|
|
1000
|
+
function swap(_x13, _x14) {
|
|
992
1001
|
return _swap.apply(this, arguments);
|
|
993
1002
|
}
|
|
994
1003
|
return swap;
|
|
@@ -1010,7 +1019,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1010
1019
|
}
|
|
1011
1020
|
}, _callee9, this);
|
|
1012
1021
|
}));
|
|
1013
|
-
function reportFailure(
|
|
1022
|
+
function reportFailure(_x15, _x16) {
|
|
1014
1023
|
return _reportFailure.apply(this, arguments);
|
|
1015
1024
|
}
|
|
1016
1025
|
return reportFailure;
|
|
@@ -1037,7 +1046,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1037
1046
|
}
|
|
1038
1047
|
}, _callee10, this);
|
|
1039
1048
|
}));
|
|
1040
|
-
function balance(
|
|
1049
|
+
function balance(_x17, _x18) {
|
|
1041
1050
|
return _balance.apply(this, arguments);
|
|
1042
1051
|
}
|
|
1043
1052
|
return balance;
|
|
@@ -1078,7 +1087,7 @@ var RangoClient = /*#__PURE__*/function () {
|
|
|
1078
1087
|
}
|
|
1079
1088
|
}, _callee11, this, [[0, 6]]);
|
|
1080
1089
|
}));
|
|
1081
|
-
function executeEvmRoute$1(
|
|
1090
|
+
function executeEvmRoute$1(_x19, _x20) {
|
|
1082
1091
|
return _executeEvmRoute2.apply(this, arguments);
|
|
1083
1092
|
}
|
|
1084
1093
|
return executeEvmRoute$1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rango-sdk-basic.esm.js","sources":["../src/types/api/common.ts","../../../node_modules/rango-types/src/api/shared/type-gaurds.ts","../../../node_modules/rango-types/src/api/shared/routing.ts","../../../node_modules/rango-types/src/api/shared/transactions.ts","../../../node_modules/rango-types/src/api/shared/txs/ton.ts","../src/types/utils/errors.ts","../src/utils/promise.ts","../src/services/executor.ts","../src/utils/errors.ts","../src/services/client.ts"],"sourcesContent":["import { Asset } from 'rango-types/lib/api/basic'\nexport * from 'rango-types/lib/api/basic/common'\n\nexport function assetToString(asset: Asset): string {\n if (!!asset.address)\n return `${asset.blockchain}.${asset.symbol}--${asset.address}`\n else return `${asset.blockchain}.${asset.symbol}`\n}\n","import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\n} from './meta'\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 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","/**\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}\n","/**\n * The type of transaction\n */\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}\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/**\n * A transaction's url that can be displayed to advanced user to track the progress\n *\n * @property {string} url - Url of the transaction in blockchain explorer. example: https://etherscan.io/tx/0xa1a3...\n * @property {string | null} description - A custom display name to help user distinguish the transactions from each\n * other. Example: Inbound, Outbound, Bridge, or null\n *\n */\nexport type SwapExplorerUrl = {\n description: string | null\n url: string\n}\n\n/**\n * APIErrorCode\n *\n * Error code of a swap failure\n *\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 *\n * @property {string} requestId - The requestId from best route endpoint\n * @property {APIErrorCode} eventType - Type of the event that happened, example: USER_REJECT\n * @property {number} [step] - Step number in which failure happened\n * @property {string} [reason] - Reason or message for the error\n * @property {[key: string]: string} [data] - A list of key-value for extra details\n * @property {wallet?: string, errorCode? string} [tags] - A list of key-value for pre-defined tags\n *\n */\nexport type ReportTransactionRequest = {\n requestId: string\n eventType: APIErrorCode\n step?: number\n reason?: string\n data?: { [key: string]: string }\n tags?: { wallet?: string; errorCode?: string }\n}\n\n/**\n * The status of transaction in tracking\n */\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 *\n * @property {boolean} isApproved - A flag which indicates that the approve tx is done or not\n * @property {TransactionStatus | null} txStatus - Status of approve transaction in blockchain,\n * if isArppoved is false and txStatus is failed, it seems that approve transaction failed in blockchain\n * @property {string | null} requiredApprovedAmount - required amount to be approved by user\n * @property {string | null} currentApprovedAmount - current approved amount by user\n *\n */\nexport type CheckApprovalResponse = {\n isApproved: boolean\n txStatus: TransactionStatus | null\n requiredApprovedAmount: string | null\n currentApprovedAmount: string | null\n}\n","import { TransactionType } from '..'\nimport { BaseTransaction } from './base'\n\nexport enum TonChainID {\n MAINNET = '-239',\n TESTNET = '-3',\n}\n\n/**\n * @property {string} address - Receiver's address\n * @property {string} amount - Amount to send in nanoTon\n * @property {string} [stateInit] - Contract specific data to add to the transaction\n * @property {string} [payload] - Contract specific data to add to the transaction\n */\nexport interface TonMessage {\n address: string\n amount: string\n stateInit?: string\n payload?: string\n}\n\n/**\n * This type of transaction is used for all Ton transactions\n *\n * @property {TransactionType} type - This field equals to TON for all Ton transactions\n * @property {number} validUntil - Sending transaction deadline in unix epoch seconds\n * @property {TonChainID} [network] - 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 * @property {string} [from] - The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default\n * @property {TonMessage[]} messages - Messages to send: min is 1, max is 4\n */\nexport interface TonTransaction extends BaseTransaction {\n type: TransactionType.TON\n validUntil: number\n network?: TonChainID\n from?: string\n messages: TonMessage[]\n}\n\nexport const isTonTransaction = (transaction: {\n type: TransactionType\n}): transaction is TonTransaction => transaction.type === TransactionType.TON\n","export const MetamaskErrorCodes = {\n rpc: {\n invalidInput: -32000,\n resourceNotFound: -32001,\n resourceUnavailable: -32002,\n transactionRejected: -32003,\n methodNotSupported: -32004,\n limitExceeded: -32005,\n parse: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internal: -32603,\n },\n provider: {\n userRejectedRequest: 4001,\n unauthorized: 4100,\n unsupportedMethod: 4200,\n disconnected: 4900,\n chainDisconnected: 4901,\n },\n}\n","export function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","import { Signer } from 'ethers'\nimport { RangoClient } from './client'\nimport { EvmTransaction } from '../types/api/txs'\nimport {\n StatusResponse,\n SwapResponse,\n TransactionStatus,\n TransactionType,\n} from '../types/api/transactions'\nimport { sleep } from '../utils/promise'\n\nexport function prepareEvmTransaction(\n evmTx: EvmTransaction,\n isApprove: boolean\n) {\n const gasPrice =\n !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x')\n ? '0x' + parseInt(evmTx.gasPrice).toString(16)\n : null\n const manipulatedTx = {\n ...evmTx,\n gasPrice,\n }\n let tx = {}\n if (!!manipulatedTx.from) tx = { ...tx, from: manipulatedTx.from }\n if (isApprove) {\n if (!!manipulatedTx.approveTo) tx = { ...tx, to: manipulatedTx.approveTo }\n if (!!manipulatedTx.approveData)\n tx = { ...tx, data: manipulatedTx.approveData }\n } else {\n if (!!manipulatedTx.txTo) tx = { ...tx, to: manipulatedTx.txTo }\n if (!!manipulatedTx.txData) tx = { ...tx, data: manipulatedTx.txData }\n if (!!manipulatedTx.value) tx = { ...tx, value: manipulatedTx.value }\n if (!!manipulatedTx.gasLimit)\n tx = { ...tx, gasLimit: manipulatedTx.gasLimit }\n if (!!manipulatedTx.gasPrice)\n tx = { ...tx, gasPrice: manipulatedTx.gasPrice }\n }\n return tx\n}\n\nasync function checkApprovalSync(\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n): Promise<boolean> {\n while (true) {\n try {\n const approvalResponse = await rangoClient.isApproved(requestId, txId)\n if (approvalResponse?.isApproved) return true\n if (\n !approvalResponse?.isApproved &&\n approvalResponse?.txStatus === TransactionStatus.FAILED\n )\n return false\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n await sleep(3_000)\n }\n}\n\nexport const checkTransactionStatusSync = async (\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n) => {\n let txStatus: StatusResponse | undefined\n while (true) {\n try {\n txStatus = await rangoClient.status({\n requestId,\n txId,\n })\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n if (!!txStatus) {\n if (\n !!txStatus.status &&\n [TransactionStatus.FAILED, TransactionStatus.SUCCESS].includes(\n txStatus.status\n )\n ) {\n return txStatus\n }\n }\n await sleep(3_000)\n }\n}\n\nexport const executeEvmRoute = async (\n client: RangoClient,\n signer: Signer,\n route: SwapResponse\n): Promise<StatusResponse> => {\n const { tx, requestId, error, resultType } = route\n if (resultType != 'OK') throw new Error(resultType)\n if (!!error || !tx)\n throw new Error(error || 'Error creating the transaction.')\n if (tx?.type !== TransactionType.EVM)\n throw new Error('Non Evm transactions are not supported yet.')\n const evmTransaction = tx as EvmTransaction\n if (!evmTransaction) throw new Error('Transaction is null. Please try again!')\n const txChainId = parseInt(evmTransaction.blockChain.chainId || '-1')\n let signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n if (!!evmTransaction.approveTo && !!evmTransaction.approveData) {\n const approveTxData = prepareEvmTransaction(evmTransaction, true)\n const approveTx = await signer.sendTransaction(approveTxData)\n approveTx.wait()\n const isApproved = await checkApprovalSync(\n requestId,\n approveTx.hash,\n client\n )\n if (!isApproved) throw new Error('Error in approve transaction.')\n }\n signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n const mainTxData = prepareEvmTransaction(evmTransaction, false)\n const mainTx = await signer.sendTransaction(mainTxData)\n mainTx.wait()\n const status = await checkTransactionStatusSync(\n requestId,\n mainTx.hash,\n client\n )\n if (status.status !== TransactionStatus.SUCCESS)\n throw new Error(`Cross-chain swap failed. ${status.error || ''}`)\n return status\n}\n","import { getMessageFromCode } from 'eth-rpc-errors'\nimport { MetamaskErrorCodes } from '../types/utils/errors'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const prettifyError = (error: any) => {\n if (!error) return error\n if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001))\n return new Error('Transaction Rejected')\n if (error && typeof error.code === 'number') {\n if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {\n return new Error(getMessageFromCode(error.code))\n }\n if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {\n if (\n error.code === MetamaskErrorCodes.rpc.internal &&\n error.message?.includes('underpriced')\n )\n return new Error('Transaction underpriced')\n if (\n error.message?.includes('intrinsic gas too low') ||\n error.message?.includes('out of gas')\n )\n return new Error('This Gas limit is low.')\n return new Error(getMessageFromCode(error.code))\n }\n }\n if (error.message) return new Error(error.message)\n return error\n}\n","import uuid from 'uuid-random'\n\nimport {\n MetaResponse,\n QuoteRequest,\n QuoteResponse,\n CheckApprovalResponse,\n StatusRequest,\n StatusResponse,\n SwapRequest,\n SwapResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n assetToString,\n BlockchainMeta,\n SwapperMeta,\n RequestOptions,\n MessagingProtocolsResponse,\n} from '../types'\nimport { Signer } from 'ethers'\nimport { executeEvmRoute as executeEvmRoute } from './executor'\nimport { prettifyError } from '../utils/errors'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddress = { 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, debug = false, 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 if (debug) {\n this.httpService.interceptors.request.use((request) => {\n console.log('Starting Request', JSON.stringify(request, null, 2))\n return request\n })\n this.httpService.interceptors.response.use((response) => {\n console.log('Response:', JSON.stringify(response, null, 2))\n return response\n })\n }\n }\n\n public async meta(options?: RequestOptions): Promise<MetaResponse> {\n const axiosResponse = await this.httpService.get<MetaResponse>(\n `/basic/meta?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async chains(options?: RequestOptions): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/basic/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async swappers(options?: RequestOptions): Promise<SwapperMeta[]> {\n const axiosResponse = await this.httpService.get<SwapperMeta[]>(\n `/basic/meta/swappers?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async messagingProtocols(\n options?: RequestOptions\n ): Promise<MessagingProtocolsResponse> {\n const axiosResponse =\n await this.httpService.get<MessagingProtocolsResponse>(\n `/basic/meta/messaging-protocols?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async quote(\n quoteRequest: QuoteRequest,\n options?: RequestOptions\n ): Promise<QuoteResponse> {\n const body = {\n ...quoteRequest,\n from: assetToString(quoteRequest.from),\n to: assetToString(quoteRequest.to),\n swappers:\n !!quoteRequest.swappers && quoteRequest.swappers.length > 0\n ? quoteRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0\n ? quoteRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!quoteRequest.messagingProtocols &&\n quoteRequest.messagingProtocols.length > 0\n ? quoteRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<QuoteResponse>(\n `/basic/quote?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async isApproved(\n requestId: string,\n txId?: string,\n options?: RequestOptions\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/basic/is-approved?apiKey=${this.apiKey}`,\n {\n params: { requestId, txId },\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async status(\n statusRequest: StatusRequest,\n options?: RequestOptions\n ): Promise<StatusResponse> {\n const axiosResponse = await this.httpService.get<StatusResponse>(\n `/basic/status?apiKey=${this.apiKey}`,\n {\n params: statusRequest,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async swap(\n swapRequest: SwapRequest,\n options?: RequestOptions\n ): Promise<SwapResponse> {\n const body = {\n ...swapRequest,\n from: assetToString(swapRequest.from),\n to: assetToString(swapRequest.to),\n referrerAddress: swapRequest.referrerAddress || null,\n referrerFee: swapRequest.referrerFee || null,\n disableEstimate: swapRequest.disableEstimate || false,\n swappers:\n !!swapRequest.swappers && swapRequest.swappers.length > 0\n ? swapRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0\n ? swapRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!swapRequest.messagingProtocols &&\n swapRequest.messagingProtocols.length > 0\n ? swapRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<SwapResponse>(\n `/basic/swap?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\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 `/basic/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n }\n\n public async balance(\n walletAddress: WalletAddress,\n options?: RequestOptions\n ): Promise<WalletDetailsResponse> {\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/basic/balance?apiKey=${this.apiKey}`,\n {\n params: walletAddress,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async executeEvmRoute(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n signer: any,\n route: SwapResponse\n ): Promise<StatusResponse> {\n try {\n return await executeEvmRoute(this, signer as Signer, route)\n } catch (error) {\n const prettifiedError = prettifyError(error)\n try {\n const message = prettifiedError?.message || 'Error executing the route'\n this.reportFailure({\n requestId: route.requestId,\n eventType: 'TX_FAIL',\n reason: message,\n })\n } catch (err) {\n console.log({ err })\n }\n throw prettifiedError\n }\n }\n}\n"],"names":["assetToString","asset","address","blockchain","symbol","blockchainMeta","MetamaskErrorCodes","rpc","invalidInput","resourceNotFound","resourceUnavailable","transactionRejected","methodNotSupported","limitExceeded","parse","invalidRequest","methodNotFound","invalidParams","internal","provider","userRejectedRequest","unauthorized","unsupportedMethod","disconnected","chainDisconnected","sleep","ms","Promise","resolve","setTimeout","prepareEvmTransaction","evmTx","isApprove","gasPrice","startsWith","parseInt","toString","manipulatedTx","tx","from","approveTo","to","approveData","data","txTo","txData","value","gasLimit","checkApprovalSync","requestId","txId","rangoClient","isApproved","approvalResponse","txStatus","TransactionStatus","FAILED","console","log","err","checkTransactionStatusSync","status","SUCCESS","includes","executeEvmRoute","client","signer","route","error","resultType","Error","type","TransactionType","EVM","evmTransaction","txChainId","blockChain","chainId","getChainId","signerChainId","approveTxData","sendTransaction","approveTx","wait","hash","mainTxData","mainTx","prettifyError","code","Object","values","getMessageFromCode","message","RangoClient","apiKey","debug","apiUrl","window","deviceId","localStorage","getItem","generatedId","uuid","setItem","e","httpService","axios","create","baseURL","interceptors","request","use","JSON","stringify","response","meta","options","get","axiosResponse","chains","swappers","messagingProtocols","quote","quoteRequest","body","length","join","undefined","swapperGroups","params","headers","statusRequest","swap","swapRequest","referrerAddress","referrerFee","disableEstimate","reportFailure","requestBody","post","balance","walletAddress","prettifiedError","eventType","reason"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAGgBA,aAAa,CAACC,KAAY;EACxC,IAAI,CAAC,CAACA,KAAK,CAACC,OAAO,EACjB,OAAUD,KAAK,CAACE,UAAU,SAAIF,KAAK,CAACG,MAAM,UAAKH,KAAK,CAACC,OAAO,CAAE,KAC3D,OAAUD,KAAK,CAACE,UAAU,SAAIF,KAAK,CAACG,MAAM;AACjD;;mBCkC8B,2BAAA;;;qDAIUC;;;AAGtC;;;AAKF;;;yDAI0CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzD1C;;;;AAIA;AAAA;gCAAY;;;;;;ACJZ;;;AAGA;AAAA;;;;;;;;;AAUA;;;;AAIA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqBA;;;;;;ICtCaC,kBAAkB,GAAG;EAChCC,GAAG,EAAE;IACHC,YAAY,EAAE,CAAC,KAAK;IACpBC,gBAAgB,EAAE,CAAC,KAAK;IACxBC,mBAAmB,EAAE,CAAC,KAAK;IAC3BC,mBAAmB,EAAE,CAAC,KAAK;IAC3BC,kBAAkB,EAAE,CAAC,KAAK;IAC1BC,aAAa,EAAE,CAAC,KAAK;IACrBC,KAAK,EAAE,CAA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AI,CAACX,WAAW,CAACY,GAAG,4BACrB,IAAI,CAACvB,MAAM;cAElCmC,MAAM,EAAEY,aAAa;cACrBX,OAAO,EAAE;gBAAE,YAAY,EAAE,IAAI,CAAChC;;eAC3BkB,OAAO,EAEb;UAAA;YAPKE,aAAa;YAAA,mCAQZA,aAAa,CAAC3E,IAAI;UAAA;UAAA;YAAA;;;KAC1B;IAAA;MAAA;;IAAA;;EAAA,OAEYqB,eAAe;IAAA,gGAArB;;IAELE,MAAW,EACXC,KAAmB;MAAA;MAAA;QAAA;UAAA;YAAA;YAAA;YAAA,OAGJH,eAAe,CAAC,IAAI,EAAEE,MAAgB,EAAEC,KAAK,CAAC;UAAA;YAAA;UAAA;YAAA;YAAA;YAErD2E,eAAe,GAAGvD,aAAa,eAAO;YAC5C,IAAI;cACIK,OAAO,GAAG,CAAAkD,eAAe,oBAAfA,eAAe,CAAElD,OAAO,KAAI,2BAA2B;cACvE,IAAI,CAAC6C,aAAa,CAAC;gBACjBxF,SAAS,EAAEkB,KAAK,CAAClB,SAAS;gBAC1B8F,SAAS,EAAE,SAAS;gBACpBC,MAAM,EAAEpD;eACT,CAAC;aACH,CAAC,OAAOjC,GAAG,EAAE;cACZF,OAAO,CAACC,GAAG,CAAC;gBAAEC,GAAG,EAAHA;eAAK,CAAC;;YACrB,MACKmF,eAAe;UAAA;UAAA;YAAA;;;KAExB;IAAA;MAAA;;IAAA;;EAAA;AAAA;;;;"}
|
|
1
|
+
{"version":3,"file":"rango-sdk-basic.esm.js","sources":["../src/types/api/common.ts","../../../node_modules/rango-types/src/api/shared/type-gaurds.ts","../../../node_modules/rango-types/src/api/shared/routing.ts","../../../node_modules/rango-types/src/api/shared/transactions.ts","../../../node_modules/rango-types/src/api/shared/txs/ton.ts","../src/types/utils/errors.ts","../src/utils/promise.ts","../src/services/executor.ts","../src/utils/errors.ts","../src/services/client.ts"],"sourcesContent":["import { Asset } from 'rango-types/lib/api/basic'\nexport * from 'rango-types/lib/api/basic/common'\n\nexport function assetToString(asset: Asset): string {\n if (!!asset.address)\n return `${asset.blockchain}.${asset.symbol}--${asset.address}`\n else return `${asset.blockchain}.${asset.symbol}`\n}\n","import {\n BlockchainMeta,\n CosmosBlockchainMeta,\n EvmBlockchainMeta,\n SolanaBlockchainMeta,\n StarkNetBlockchainMeta,\n TonBlockchainMeta,\n TransferBlockchainMeta,\n TronBlockchainMeta,\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 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","/**\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}\n","/**\n * The type of transaction\n */\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}\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/**\n * A transaction's url that can be displayed to advanced user to track the progress\n *\n * @property {string} url - Url of the transaction in blockchain explorer. example: https://etherscan.io/tx/0xa1a3...\n * @property {string | null} description - A custom display name to help user distinguish the transactions from each\n * other. Example: Inbound, Outbound, Bridge, or null\n *\n */\nexport type SwapExplorerUrl = {\n description: string | null\n url: string\n}\n\n/**\n * APIErrorCode\n *\n * Error code of a swap failure\n *\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 *\n * @property {string} requestId - The requestId from best route endpoint\n * @property {APIErrorCode} eventType - Type of the event that happened, example: USER_REJECT\n * @property {number} [step] - Step number in which failure happened\n * @property {string} [reason] - Reason or message for the error\n * @property {[key: string]: string} [data] - A list of key-value for extra details\n * @property {wallet?: string, errorCode? string} [tags] - A list of key-value for pre-defined tags\n *\n */\nexport type ReportTransactionRequest = {\n requestId: string\n eventType: APIErrorCode\n step?: number\n reason?: string\n data?: { [key: string]: string }\n tags?: { wallet?: string; errorCode?: string }\n}\n\n/**\n * The status of transaction in tracking\n */\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 *\n * @property {boolean} isApproved - A flag which indicates that the approve tx is done or not\n * @property {TransactionStatus | null} txStatus - Status of approve transaction in blockchain,\n * if isArppoved is false and txStatus is failed, it seems that approve transaction failed in blockchain\n * @property {string | null} requiredApprovedAmount - required amount to be approved by user\n * @property {string | null} currentApprovedAmount - current approved amount by user\n *\n */\nexport type CheckApprovalResponse = {\n isApproved: boolean\n txStatus: TransactionStatus | null\n requiredApprovedAmount: string | null\n currentApprovedAmount: string | null\n}\n","import { TransactionType } from '../index.js'\nimport { BaseTransaction } from './base.js'\n\nexport enum TonChainID {\n MAINNET = '-239',\n TESTNET = '-3',\n}\n\n/**\n * @property {string} address - Receiver's address\n * @property {string} amount - Amount to send in nanoTon\n * @property {string} [stateInit] - Contract specific data to add to the transaction\n * @property {string} [payload] - Contract specific data to add to the transaction\n */\nexport interface TonMessage {\n address: string\n amount: string\n stateInit?: string\n payload?: string\n}\n\n/**\n * This type of transaction is used for all Ton transactions\n *\n * @property {TransactionType} type - This field equals to TON for all Ton transactions\n * @property {number} validUntil - Sending transaction deadline in unix epoch seconds\n * @property {TonChainID} [network] - 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 * @property {string} [from] - The sender address in '<wc>:<hex>' format from which DApp intends to send the transaction. Current account.address by default\n * @property {TonMessage[]} messages - Messages to send: min is 1, max is 4\n */\nexport interface TonTransaction extends BaseTransaction {\n type: TransactionType.TON\n validUntil: number\n network?: TonChainID\n from?: string\n messages: TonMessage[]\n}\n\nexport const isTonTransaction = (transaction: {\n type: TransactionType\n}): transaction is TonTransaction => transaction.type === TransactionType.TON\n","export const MetamaskErrorCodes = {\n rpc: {\n invalidInput: -32000,\n resourceNotFound: -32001,\n resourceUnavailable: -32002,\n transactionRejected: -32003,\n methodNotSupported: -32004,\n limitExceeded: -32005,\n parse: -32700,\n invalidRequest: -32600,\n methodNotFound: -32601,\n invalidParams: -32602,\n internal: -32603,\n },\n provider: {\n userRejectedRequest: 4001,\n unauthorized: 4100,\n unsupportedMethod: 4200,\n disconnected: 4900,\n chainDisconnected: 4901,\n },\n}\n","export function sleep(ms: number) {\n return new Promise((resolve) => setTimeout(resolve, ms))\n}\n","import { Signer } from 'ethers'\nimport { RangoClient } from './client'\nimport { EvmTransaction } from '../types/api/txs'\nimport {\n StatusResponse,\n SwapResponse,\n TransactionStatus,\n TransactionType,\n} from '../types/api/transactions'\nimport { sleep } from '../utils/promise'\n\nexport function prepareEvmTransaction(\n evmTx: EvmTransaction,\n isApprove: boolean\n) {\n const gasPrice =\n !!evmTx.gasPrice && !evmTx.gasPrice.startsWith('0x')\n ? '0x' + parseInt(evmTx.gasPrice).toString(16)\n : null\n const manipulatedTx = {\n ...evmTx,\n gasPrice,\n }\n let tx = {}\n if (!!manipulatedTx.from) tx = { ...tx, from: manipulatedTx.from }\n if (isApprove) {\n if (!!manipulatedTx.approveTo) tx = { ...tx, to: manipulatedTx.approveTo }\n if (!!manipulatedTx.approveData)\n tx = { ...tx, data: manipulatedTx.approveData }\n } else {\n if (!!manipulatedTx.txTo) tx = { ...tx, to: manipulatedTx.txTo }\n if (!!manipulatedTx.txData) tx = { ...tx, data: manipulatedTx.txData }\n if (!!manipulatedTx.value) tx = { ...tx, value: manipulatedTx.value }\n if (!!manipulatedTx.gasLimit)\n tx = { ...tx, gasLimit: manipulatedTx.gasLimit }\n if (!!manipulatedTx.gasPrice)\n tx = { ...tx, gasPrice: manipulatedTx.gasPrice }\n }\n return tx\n}\n\nasync function checkApprovalSync(\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n): Promise<boolean> {\n while (true) {\n try {\n const approvalResponse = await rangoClient.isApproved(requestId, txId)\n if (approvalResponse?.isApproved) return true\n if (\n !approvalResponse?.isApproved &&\n approvalResponse?.txStatus === TransactionStatus.FAILED\n )\n return false\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n await sleep(3_000)\n }\n}\n\nexport const checkTransactionStatusSync = async (\n requestId: string,\n txId: string,\n rangoClient: RangoClient\n) => {\n let txStatus: StatusResponse | undefined\n while (true) {\n try {\n txStatus = await rangoClient.status({\n requestId,\n txId,\n })\n } catch (err) {\n console.log('ignorinig error', { err })\n }\n if (!!txStatus) {\n if (\n !!txStatus.status &&\n [TransactionStatus.FAILED, TransactionStatus.SUCCESS].includes(\n txStatus.status\n )\n ) {\n return txStatus\n }\n }\n await sleep(3_000)\n }\n}\n\nexport const executeEvmRoute = async (\n client: RangoClient,\n signer: Signer,\n route: SwapResponse\n): Promise<StatusResponse> => {\n const { tx, requestId, error, resultType } = route\n if (resultType != 'OK') throw new Error(resultType)\n if (!!error || !tx)\n throw new Error(error || 'Error creating the transaction.')\n if (tx?.type !== TransactionType.EVM)\n throw new Error('Non Evm transactions are not supported yet.')\n const evmTransaction = tx as EvmTransaction\n if (!evmTransaction) throw new Error('Transaction is null. Please try again!')\n const txChainId = parseInt(evmTransaction.blockChain.chainId || '-1')\n let signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n if (!!evmTransaction.approveTo && !!evmTransaction.approveData) {\n const approveTxData = prepareEvmTransaction(evmTransaction, true)\n const approveTx = await signer.sendTransaction(approveTxData)\n approveTx.wait()\n const isApproved = await checkApprovalSync(\n requestId,\n approveTx.hash,\n client\n )\n if (!isApproved) throw new Error('Error in approve transaction.')\n }\n signerChainId = await signer.getChainId()\n if (signerChainId !== txChainId) {\n throw new Error(\n `Signer chainId ${signerChainId} doesn't match required chainId ${txChainId}.`\n )\n }\n const mainTxData = prepareEvmTransaction(evmTransaction, false)\n const mainTx = await signer.sendTransaction(mainTxData)\n mainTx.wait()\n const status = await checkTransactionStatusSync(\n requestId,\n mainTx.hash,\n client\n )\n if (status.status !== TransactionStatus.SUCCESS)\n throw new Error(`Cross-chain swap failed. ${status.error || ''}`)\n return status\n}\n","import { getMessageFromCode } from 'eth-rpc-errors'\nimport { MetamaskErrorCodes } from '../types/utils/errors'\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const prettifyError = (error: any) => {\n if (!error) return error\n if (error.code && (error.code === 'ACTION_REJECTED' || error.code === 4001))\n return new Error('Transaction Rejected')\n if (error && typeof error.code === 'number') {\n if (Object.values(MetamaskErrorCodes.provider).includes(error.code)) {\n return new Error(getMessageFromCode(error.code))\n }\n if (Object.values(MetamaskErrorCodes.rpc).includes(error.code)) {\n if (\n error.code === MetamaskErrorCodes.rpc.internal &&\n error.message?.includes('underpriced')\n )\n return new Error('Transaction underpriced')\n if (\n error.message?.includes('intrinsic gas too low') ||\n error.message?.includes('out of gas')\n )\n return new Error('This Gas limit is low.')\n return new Error(getMessageFromCode(error.code))\n }\n }\n if (error.message) return new Error(error.message)\n return error\n}\n","import uuid from 'uuid-random'\n\nimport {\n MetaRequest,\n MetaResponse,\n QuoteRequest,\n QuoteResponse,\n CheckApprovalResponse,\n StatusRequest,\n StatusResponse,\n SwapRequest,\n SwapResponse,\n ReportTransactionRequest,\n WalletDetailsResponse,\n assetToString,\n BlockchainMeta,\n SwapperMeta,\n RequestOptions,\n MessagingProtocolsResponse,\n} from '../types'\nimport { Signer } from 'ethers'\nimport { executeEvmRoute as executeEvmRoute } from './executor'\nimport { prettifyError } from '../utils/errors'\nimport axios, { AxiosInstance } from 'axios'\n\ntype WalletAddress = { 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, debug = false, 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 if (debug) {\n this.httpService.interceptors.request.use((request) => {\n console.log('Starting Request', JSON.stringify(request, null, 2))\n return request\n })\n this.httpService.interceptors.response.use((response) => {\n console.log('Response:', JSON.stringify(response, null, 2))\n return response\n })\n }\n }\n\n public async meta(\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<MetaResponse>(\n `/basic/meta?apiKey=${this.apiKey}`,\n {\n params,\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async chains(options?: RequestOptions): Promise<BlockchainMeta[]> {\n const axiosResponse = await this.httpService.get<BlockchainMeta[]>(\n `/basic/meta/blockchains?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async swappers(options?: RequestOptions): Promise<SwapperMeta[]> {\n const axiosResponse = await this.httpService.get<SwapperMeta[]>(\n `/basic/meta/swappers?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async messagingProtocols(\n options?: RequestOptions\n ): Promise<MessagingProtocolsResponse> {\n const axiosResponse =\n await this.httpService.get<MessagingProtocolsResponse>(\n `/basic/meta/messaging-protocols?apiKey=${this.apiKey}`,\n { ...options }\n )\n return axiosResponse.data\n }\n\n public async quote(\n quoteRequest: QuoteRequest,\n options?: RequestOptions\n ): Promise<QuoteResponse> {\n const body = {\n ...quoteRequest,\n from: assetToString(quoteRequest.from),\n to: assetToString(quoteRequest.to),\n swappers:\n !!quoteRequest.swappers && quoteRequest.swappers.length > 0\n ? quoteRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!quoteRequest.swapperGroups && quoteRequest.swapperGroups.length > 0\n ? quoteRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!quoteRequest.messagingProtocols &&\n quoteRequest.messagingProtocols.length > 0\n ? quoteRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<QuoteResponse>(\n `/basic/quote?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async isApproved(\n requestId: string,\n txId?: string,\n options?: RequestOptions\n ): Promise<CheckApprovalResponse> {\n const axiosResponse = await this.httpService.get<CheckApprovalResponse>(\n `/basic/is-approved?apiKey=${this.apiKey}`,\n {\n params: { requestId, txId },\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async status(\n statusRequest: StatusRequest,\n options?: RequestOptions\n ): Promise<StatusResponse> {\n const axiosResponse = await this.httpService.get<StatusResponse>(\n `/basic/status?apiKey=${this.apiKey}`,\n {\n params: statusRequest,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async swap(\n swapRequest: SwapRequest,\n options?: RequestOptions\n ): Promise<SwapResponse> {\n const body = {\n ...swapRequest,\n from: assetToString(swapRequest.from),\n to: assetToString(swapRequest.to),\n referrerAddress: swapRequest.referrerAddress || null,\n referrerFee: swapRequest.referrerFee || null,\n disableEstimate: swapRequest.disableEstimate || false,\n swappers:\n !!swapRequest.swappers && swapRequest.swappers.length > 0\n ? swapRequest.swappers.join(',')\n : undefined,\n swapperGroups:\n !!swapRequest.swapperGroups && swapRequest.swapperGroups.length > 0\n ? swapRequest.swapperGroups.join(',')\n : undefined,\n messagingProtocols:\n !!swapRequest.messagingProtocols &&\n swapRequest.messagingProtocols.length > 0\n ? swapRequest.messagingProtocols.join(',')\n : undefined,\n }\n const axiosResponse = await this.httpService.get<SwapResponse>(\n `/basic/swap?apiKey=${this.apiKey}`,\n {\n params: body,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\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 `/basic/report-tx?apiKey=${this.apiKey}`,\n requestBody,\n {\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n }\n\n public async balance(\n walletAddress: WalletAddress,\n options?: RequestOptions\n ): Promise<WalletDetailsResponse> {\n const axiosResponse = await this.httpService.get<WalletDetailsResponse>(\n `/basic/balance?apiKey=${this.apiKey}`,\n {\n params: walletAddress,\n headers: { 'X-Rango-Id': this.deviceId },\n ...options,\n }\n )\n return axiosResponse.data\n }\n\n public async executeEvmRoute(\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n signer: any,\n route: SwapResponse\n ): Promise<StatusResponse> {\n try {\n return await executeEvmRoute(this, signer as Signer, route)\n } catch (error) {\n const prettifiedError = prettifyError(error)\n try {\n const message = prettifiedError?.message || 'Error executing the route'\n this.reportFailure({\n requestId: route.requestId,\n eventType: 'TX_FAIL',\n reason: message,\n })\n } catch (err) {\n console.log({ err })\n }\n throw prettifiedError\n }\n }\n}\n"],"names":["assetToString","asset","address","blockchain","symbol","blockchainMeta","MetamaskErrorCodes","rpc","invalidInput","resourceNotFound","resourceUnavailable","transactionRejected","methodNotSupported","limitExceeded","parse","invalidRequest","methodNotFound","invalidParams","internal","provider","userRejectedRequest","unauthorized","unsupportedMethod","disconnected","chainDisconnected","sleep","ms","Promise","resolve","setTimeout","prepareEvmTransaction","evmTx","isApprove","gasPrice","startsWith","parseInt","toString","manipulatedTx","tx","from","approveTo","to","approveData","data","txTo","txData","value","gasLimit","checkApprovalSync","requestId","txId","rangoClient","isApproved","approvalResponse","txStatus","TransactionStatus","FAILED","console","log","err","checkTransactionStatusSync","status","SUCCESS","includes","executeEvmRoute","client","signer","route","error","resultType","Error","type","TransactionType","EVM","evmTransaction","txChainId","blockChain","chainId","getChainId","signerChainId","approveTxData","sendTransaction","approveTx","wait","hash","mainTxData","mainTx","prettifyError","code","Object","values","getMessageFromCode","message","RangoClient","apiKey","debug","apiUrl","window","deviceId","localStorage","getItem","generatedId","uuid","setItem","e","httpService","axios","create","baseURL","interceptors","request","use","JSON","stringify","response","meta","metaRequest","options","params","blockchains","join","swappers","swappersGroups","transactionTypes","get","axiosResponse","chains","messagingProtocols","quote","quoteRequest","body","length","undefined","swapperGroups","headers","statusRequest","swap","swapRequest","referrerAddress","referrerFee","disableEstimate","reportFailure","requestBody","post","balance","walletAddress","prettifiedError","eventType","reason"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAGgBA,aAAa,CAACC,KAAY;EACxC,IAAI,CAAC,CAACA,KAAK,CAACC,OAAO,EACjB,OAAUD,KAAK,CAACE,UAAU,SAAIF,KAAK,CAACG,MAAM,UAAKH,KAAK,CAACC,OAAO,CAAE,KAC3D,OAAUD,KAAK,CAACE,UAAU,SAAIF,KAAK,CAACG,MAAM;AACjD;;mBCkC8B,2BAAA;;;qDAIUC;;;AAGtC;;;AAKF;;;yDAI0CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACzD1C;;;;AAIA;AAAA;gCAAY;;;;;;ACJZ;;;AAGA;AAAA;;;;;;;;;AAUA;;;;AAIA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACqBA;;;;;;ICtCaC,kBAAkB,GAAG;EAChCC,GAAG,EAAE;IACHC,YAAY,EAAE,CAAC,KAAK;IACpBC,gBAAgB,EAAE,CAAC,KAAK;IACxBC,mBAAmB,EAAE,CAAC,KAAK;IAC3BC,mBAAmB,EAAE,CAA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D;eACT,CAAC;aACH,CAAC,OAAOjC,GAAG,EAAE;cACZF,OAAO,CAACC,GAAG,CAAC;gBAAEC,GAAG,EAAHA;eAAK,CAAC;;YACrB,MACKuF,eAAe;UAAA;UAAA;YAAA;;;KAExB;IAAA;MAAA;;IAAA;;EAAA;AAAA;;;;"}
|
package/lib/services/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { MetaResponse, QuoteRequest, QuoteResponse, CheckApprovalResponse, StatusRequest, StatusResponse, SwapRequest, SwapResponse, ReportTransactionRequest, WalletDetailsResponse, BlockchainMeta, SwapperMeta, RequestOptions, MessagingProtocolsResponse } from '../types';
|
|
1
|
+
import { MetaRequest, MetaResponse, QuoteRequest, QuoteResponse, CheckApprovalResponse, StatusRequest, StatusResponse, SwapRequest, SwapResponse, ReportTransactionRequest, WalletDetailsResponse, BlockchainMeta, SwapperMeta, RequestOptions, MessagingProtocolsResponse } from '../types';
|
|
2
2
|
declare type WalletAddress = {
|
|
3
3
|
blockchain: string;
|
|
4
4
|
address: string;
|
|
@@ -9,7 +9,7 @@ export declare class RangoClient {
|
|
|
9
9
|
private readonly apiUrl;
|
|
10
10
|
private readonly httpService;
|
|
11
11
|
constructor(apiKey: string, debug?: boolean, apiUrl?: string);
|
|
12
|
-
meta(options?: RequestOptions): Promise<MetaResponse>;
|
|
12
|
+
meta(metaRequest?: MetaRequest, options?: RequestOptions): Promise<MetaResponse>;
|
|
13
13
|
chains(options?: RequestOptions): Promise<BlockchainMeta[]>;
|
|
14
14
|
swappers(options?: RequestOptions): Promise<SwapperMeta[]>;
|
|
15
15
|
messagingProtocols(options?: RequestOptions): Promise<MessagingProtocolsResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/services/client.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,aAAa,EACb,cAAc,EACd,WA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
+
{"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/types/api/meta.ts"],"names":[],"mappings":"AAAA,cAAc,gCAAgC,CAAA;AAC9C,cAAc,wCAAwC,CAAA;AACtD,YAAY,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rango-sdk-basic",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.37",
|
|
4
4
|
"description": "Rango Exchange Basic SDK for dApps",
|
|
5
5
|
"module": "lib/rango-sdk-basic.esm.js",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"bignumber.js": "^9.1.1",
|
|
47
47
|
"eth-rpc-errors": "^4.0.3",
|
|
48
48
|
"ethers": "^5.7.2",
|
|
49
|
-
"rango-types": "^0.1.
|
|
49
|
+
"rango-types": "^0.1.47",
|
|
50
50
|
"uuid-random": "^1.3.2"
|
|
51
51
|
},
|
|
52
52
|
"publishConfig": {
|
package/src/services/client.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import uuid from 'uuid-random'
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
MetaRequest,
|
|
4
5
|
MetaResponse,
|
|
5
6
|
QuoteRequest,
|
|
6
7
|
QuoteResponse,
|
|
@@ -64,10 +65,23 @@ export class RangoClient {
|
|
|
64
65
|
}
|
|
65
66
|
}
|
|
66
67
|
|
|
67
|
-
public async meta(
|
|
68
|
+
public async meta(
|
|
69
|
+
metaRequest?: MetaRequest,
|
|
70
|
+
options?: RequestOptions
|
|
71
|
+
): Promise<MetaResponse> {
|
|
72
|
+
const params = {
|
|
73
|
+
...metaRequest,
|
|
74
|
+
blockchains: metaRequest?.blockchains?.join(),
|
|
75
|
+
swappers: metaRequest?.swappers?.join(),
|
|
76
|
+
swappersGroups: metaRequest?.swappersGroups?.join(),
|
|
77
|
+
transactionTypes: metaRequest?.transactionTypes?.join(),
|
|
78
|
+
}
|
|
68
79
|
const axiosResponse = await this.httpService.get<MetaResponse>(
|
|
69
80
|
`/basic/meta?apiKey=${this.apiKey}`,
|
|
70
|
-
{
|
|
81
|
+
{
|
|
82
|
+
params,
|
|
83
|
+
...options,
|
|
84
|
+
}
|
|
71
85
|
)
|
|
72
86
|
return axiosResponse.data
|
|
73
87
|
}
|
package/src/types/api/meta.ts
CHANGED