rango-sdk 0.0.1

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.
Files changed (59) hide show
  1. package/LICENSE +674 -0
  2. package/README.md +25 -0
  3. package/lib/index.d.ts +3 -0
  4. package/lib/index.d.ts.map +1 -0
  5. package/lib/index.js +17 -0
  6. package/lib/index.js.map +1 -0
  7. package/lib/services/client.d.ts +22 -0
  8. package/lib/services/client.d.ts.map +1 -0
  9. package/lib/services/client.js +159 -0
  10. package/lib/services/client.js.map +1 -0
  11. package/lib/services/httpService.d.ts +2 -0
  12. package/lib/services/httpService.d.ts.map +1 -0
  13. package/lib/services/httpService.js +11 -0
  14. package/lib/services/httpService.js.map +1 -0
  15. package/lib/services/index.d.ts +2 -0
  16. package/lib/services/index.d.ts.map +1 -0
  17. package/lib/services/index.js +6 -0
  18. package/lib/services/index.js.map +1 -0
  19. package/lib/types/api/balance.d.ts +39 -0
  20. package/lib/types/api/balance.d.ts.map +1 -0
  21. package/lib/types/api/balance.js +3 -0
  22. package/lib/types/api/balance.js.map +1 -0
  23. package/lib/types/api/common.d.ts +212 -0
  24. package/lib/types/api/common.d.ts.map +1 -0
  25. package/lib/types/api/common.js +3 -0
  26. package/lib/types/api/common.js.map +1 -0
  27. package/lib/types/api/meta.d.ts +69 -0
  28. package/lib/types/api/meta.d.ts.map +1 -0
  29. package/lib/types/api/meta.js +3 -0
  30. package/lib/types/api/meta.js.map +1 -0
  31. package/lib/types/api/routing.d.ts +137 -0
  32. package/lib/types/api/routing.d.ts.map +1 -0
  33. package/lib/types/api/routing.js +3 -0
  34. package/lib/types/api/routing.js.map +1 -0
  35. package/lib/types/api/transactions.d.ts +169 -0
  36. package/lib/types/api/transactions.d.ts.map +1 -0
  37. package/lib/types/api/transactions.js +22 -0
  38. package/lib/types/api/transactions.js.map +1 -0
  39. package/lib/types/api/txs/cosmos.d.ts +66 -0
  40. package/lib/types/api/txs/cosmos.d.ts.map +1 -0
  41. package/lib/types/api/txs/cosmos.js +3 -0
  42. package/lib/types/api/txs/cosmos.js.map +1 -0
  43. package/lib/types/api/txs/evm.d.ts +29 -0
  44. package/lib/types/api/txs/evm.d.ts.map +1 -0
  45. package/lib/types/api/txs/evm.js +3 -0
  46. package/lib/types/api/txs/evm.js.map +1 -0
  47. package/lib/types/api/txs/index.d.ts +4 -0
  48. package/lib/types/api/txs/index.d.ts.map +1 -0
  49. package/lib/types/api/txs/index.js +16 -0
  50. package/lib/types/api/txs/index.js.map +1 -0
  51. package/lib/types/api/txs/transfer.d.ts +24 -0
  52. package/lib/types/api/txs/transfer.d.ts.map +1 -0
  53. package/lib/types/api/txs/transfer.js +3 -0
  54. package/lib/types/api/txs/transfer.js.map +1 -0
  55. package/lib/types/index.d.ts +7 -0
  56. package/lib/types/index.d.ts.map +1 -0
  57. package/lib/types/index.js +19 -0
  58. package/lib/types/index.js.map +1 -0
  59. package/package.json +59 -0
@@ -0,0 +1,137 @@
1
+ import type { Amount, Asset, SwapResult } from './common';
2
+ import type { TransactionType } from './transactions';
3
+ /**
4
+ * All user wallets for a specific blockchain
5
+ *
6
+ * @property {string} blockchain - The blockchain that wallets belong to
7
+ * @property {string[]} addresses - List of user wallet addresses for the specified blockchain
8
+ *
9
+ */
10
+ export declare type UserWalletBlockchain = {
11
+ blockchain: string;
12
+ addresses: string[];
13
+ };
14
+ /**
15
+ * Full information of a path of multiple swaps that should be executed by user to swap X to Y
16
+ *
17
+ * @property {string} outputAmount - The estimation of Rango from output amount of Y
18
+ * @property {SwapResult[]} swaps - List of required swaps to swap X to Y with the expected outputAmount
19
+ *
20
+ */
21
+ export declare type SimulationResult = {
22
+ outputAmount: string;
23
+ swaps: SwapResult[];
24
+ };
25
+ /**
26
+ * Describing a required Asset for swapping X to Y and check if the wallet has enough balance or not
27
+ *
28
+ * @property {Asset} asset - asset required for fee or balance
29
+ * @property {Asset} requiredAmount
30
+ * @property {Amount} currentAmount
31
+ * @property {boolean} ok - If true, means this requirement is fulfilled, false means swap may fail due to insufficient balance
32
+ * @property {string} reason - 'FEE' | 'FEE_AND_INPUT_ASSET' | 'INPUT_ASSET'
33
+ *
34
+ */
35
+ export declare type WalletRequiredAssets = {
36
+ asset: Asset;
37
+ requiredAmount: Amount;
38
+ currentAmount: Amount;
39
+ ok: boolean;
40
+ reason: 'FEE' | 'FEE_AND_INPUT_ASSET' | 'INPUT_ASSET';
41
+ };
42
+ /**
43
+ * The validation status of a wallet
44
+ *
45
+ * @property {string} address - The address of wallet
46
+ * @property {boolean} addressIsValid - If false, the wallet address is invalid for the given blockchain
47
+ * @property {WalletRequiredAssets[]} requiredAssets - The list of required assets for swapping X to Y in this wallet
48
+ * and the status to indicate whether these assets are missing or not
49
+ * @property {boolean} validResult - If false, Rango was unable to fetch the balance of this address to check the
50
+ * requiredAssets availability
51
+ *
52
+ */
53
+ export declare type WalletValidationStatus = {
54
+ address: string;
55
+ addressIsValid: boolean;
56
+ requiredAssets: WalletRequiredAssets[];
57
+ validResult: boolean;
58
+ };
59
+ /**
60
+ * The blockchain that this validation data belongs to
61
+ *
62
+ * @property {string} blockchain - The blockchain of validation
63
+ * @property {WalletValidationStatus[]} wallets - The status of validation for all the wallets of the specific blockchain
64
+ *
65
+ */
66
+ export declare type BlockchainValidationStatus = {
67
+ blockchain: string;
68
+ wallets: WalletValidationStatus[];
69
+ };
70
+ /**
71
+ * Body of routing request
72
+ *
73
+ * @property {Asset} from - The source asset
74
+ * @property {Asset} to - The destination asset
75
+ * @property {string} amount - The human-readable amount of asset X that is going to be swapped, example: 0.28
76
+ * @property {boolean} checkPrerequisites - It should be false when client just likes to preview the route to user,
77
+ * and true when user really accepted to swap. If true, server will be much slower to respond, but will check some
78
+ * pre-requisites including balance of X and required fees in user's wallets
79
+ * @property {{ [key: string]: string }} selectedWallets - Map of blockchain to selected address
80
+ * @property {string | null} [affiliateRef] - The affiliate ref that client likes to send to Rango, so in cases of
81
+ * 1inch, Thorchain, etc. that support affiliation, the referrer will earn some money if user accept the route and
82
+ * signs the transactions. example: K3ldk3
83
+ * @property {boolean} [disableMultiStepTx] - It should be true when client doesn't want multi step transactions
84
+ * @property {string[]} [blockchains] - The list of all accepted blockchains, empty list means no filter is required
85
+ * @property {string[]} [swappers] - The list of all accepted swappers, empty list means no filter is required
86
+ * @property {string[]} [transactionTypes] - The list of all accepted transaction types containing [EVM, TRANSFER, COSMOS]
87
+ *
88
+ */
89
+ export declare type BestRouteRequest = {
90
+ from: Asset;
91
+ to: Asset;
92
+ amount: string;
93
+ checkPrerequisites: boolean;
94
+ connectedWallets: UserWalletBlockchain[];
95
+ selectedWallets: {
96
+ [key: string]: string;
97
+ };
98
+ affiliateRef?: string | null;
99
+ disableMultiStepTx?: boolean;
100
+ blockchains?: string[];
101
+ swappers?: string[];
102
+ transactionTypes?: TransactionType[];
103
+ };
104
+ /**
105
+ * The response of best route, if the result fields is null, it means that no route is found
106
+ *
107
+ * @property {string} requestId - The unique requestId generated for this request by server. It should be passed down
108
+ * to all other endpoints if this swap continues on, example: d10657ce-b13a-405c-825b-b47f8a5016ad
109
+ * @property {string} requestAmount - The human readable amount from the request
110
+ * @property {Asset} from
111
+ * @property {Asset} to
112
+ * @property {SimulationResult | null} result
113
+ * @property {BlockchainValidationStatus[] | null} validationStatus - Pre-requisite check result, it will be null if
114
+ * request.checkPrerequisites is false
115
+ * @property {string[]} diagnosisMessages - list of string messages that might be cause of not finding the route.
116
+ * It's just for display purpose
117
+ * @property {string[]} missingBlockchains - List of all blockchains which are necessary to be present for the best
118
+ * route and user has not provided any connected wallets for it. Null or empty list indicates that there is no problem.
119
+ * @property {boolean} processingLimitReached - A warning that indicates that it took too much time to find the best
120
+ * route and server could not find any routes from X to Y
121
+ * @property {boolean} walletNotSupportingFromBlockchain - A warning indicating that none of your wallets have the same
122
+ * blockchain as X asset
123
+ *
124
+ */
125
+ export declare type BestRouteResponse = {
126
+ requestId: string;
127
+ requestAmount: string;
128
+ from: Asset;
129
+ to: Asset;
130
+ result: SimulationResult | null;
131
+ validationStatus: BlockchainValidationStatus[] | null;
132
+ diagnosisMessages: string[] | null;
133
+ missingBlockchains: string[] | null;
134
+ processingLimitReached: boolean;
135
+ walletNotSupportingFromBlockchain: boolean;
136
+ };
137
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../../../src/types/api/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,UAAU,CAAA;AACzD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAA;AAErD;;;;;;GAMG;AACH,oBAAY,oBAAoB,GAAG;IACjC,UAAU,EAAE,MAAM,CAAA;IAClB,SAAS,EAAE,MAAM,EAAE,CAAA;CACpB,CAAA;AAED;;;;;;GAMG;AACH,oBAAY,gBAAgB,GAAG;IAC7B,YAAY,EAAE,MAAM,CAAA;IACpB,KAAK,EAAE,UAAU,EAAE,CAAA;CACpB,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,oBAAoB,GAAG;IACjC,KAAK,EAAE,KAAK,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;IACrB,EAAE,EAAE,OAAO,CAAA;IACX,MAAM,EAAE,KAAK,GAAG,qBAAqB,GAAG,aAAa,CAAA;CACtD,CAAA;AAED;;;;;;;;;;GAUG;AACH,oBAAY,sBAAsB,GAAG;IACnC,OAAO,EAAE,MAAM,CAAA;IACf,cAAc,EAAE,OAAO,CAAA;IACvB,cAAc,EAAE,oBAAoB,EAAE,CAAA;IACtC,WAAW,EAAE,OAAO,CAAA;CACrB,CAAA;AAED;;;;;;GAMG;AACH,oBAAY,0BAA0B,GAAG;IACvC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,sBAAsB,EAAE,CAAA;CAClC,CAAA;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,oBAAY,gBAAgB,GAAG;IAC7B,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IACT,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,OAAO,CAAA;IAC3B,gBAAgB,EAAE,oBAAoB,EAAE,CAAA;IACxC,eAAe,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;IAC1C,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5B,kBAAkB,CAAC,EAAE,OAAO,CAAA;IAC5B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAA;IACtB,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAA;IACnB,gBAAgB,CAAC,EAAE,eAAe,EAAE,CAAA;CACrC,CAAA;AAED;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,oBAAY,iBAAiB,GAAG;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,aAAa,EAAE,MAAM,CAAA;IACrB,IAAI,EAAE,KAAK,CAAA;IACX,EAAE,EAAE,KAAK,CAAA;IACT,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAA;IAC/B,gBAAgB,EAAE,0BAA0B,EAAE,GAAG,IAAI,CAAA;IACrD,iBAAiB,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IAClC,kBAAkB,EAAE,MAAM,EAAE,GAAG,IAAI,CAAA;IACnC,sBAAsB,EAAE,OAAO,CAAA;IAC/B,iCAAiC,EAAE,OAAO,CAAA;CAC3C,CAAA"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../../../src/types/api/routing.ts"],"names":[],"mappings":""}
@@ -0,0 +1,169 @@
1
+ /**
2
+ * The type of transaction
3
+ */
4
+ export declare enum TransactionType {
5
+ EVM = "EVM",
6
+ TRANSFER = "TRANSFER",
7
+ COSMOS = "COSMOS"
8
+ }
9
+ /**
10
+ * Parent model for all types of transactions
11
+ * Check EvmTransaction, TransferTransaction and CosmosTransaction models for more details
12
+ *
13
+ */
14
+ export declare type GenericTransaction = {
15
+ type: TransactionType;
16
+ };
17
+ /**
18
+ * Data of referral rewards of a transaction
19
+ *
20
+ * @property {string} blockChain - The blockchain that reward is generated in, example: BSC
21
+ * @property {string | null} address - The smart contract address of rewarded asset, null for native assets
22
+ * @property {string} symbol - The symbol of the asset that is rewarded, example: ADA
23
+ * @property {number} decimals - The decimals of the rewarded asset, example: 18
24
+ * @property {string} amount - The machine-readable amount of the reward, example: 1000000000000000000
25
+ *
26
+ */
27
+ export declare type TransactionStatusReferral = {
28
+ blockChain: string;
29
+ address: string | null;
30
+ symbol: string;
31
+ decimals: number;
32
+ amount: string;
33
+ };
34
+ /**
35
+ * Settings of user for swaps
36
+ *
37
+ * @property {string} slippage - Amount of users' preferred slippage in percent
38
+ *
39
+ */
40
+ export declare type UserSettings = {
41
+ slippage: string;
42
+ };
43
+ /**
44
+ * List of validations that Rango should do
45
+ *
46
+ * @property {boolean} balance - If true [Recommended], Rango will check that user has the required balance for swap
47
+ * @property {boolean} fee - If true [Recommended], Rango will check that user has the required fees in the wallet
48
+ *
49
+ */
50
+ export declare type CreateTransactionValidation = {
51
+ balance: boolean;
52
+ fee: boolean;
53
+ };
54
+ /**
55
+ * A transaction's url that can be displayed to advanced user to track the progress
56
+ *
57
+ * @property {string} url - Url of the transaction in blockchain explorer. example: https://etherscan.io/tx/0xa1a3...
58
+ * @property {string | null} description - A custom display name to help user distinguish the transactions from each
59
+ * other. Example: Inbound, Outbound, Bridge, or null
60
+ *
61
+ */
62
+ export declare type SwapExplorerUrl = {
63
+ description: string | null;
64
+ url: string;
65
+ };
66
+ /**
67
+ * Request body of check tx status
68
+ *
69
+ * @property {string} requestId - The unique ID which is generated in best route endpoint
70
+ * @property {number} step - 1-based step number of a complex multi-step swap, example: 1, 2, ...
71
+ * @property {number} txId - Tx hash that wallet returned, example: 0xa1a37ce2063c4764da27d990a22a0c89ed8ac585286a77a...
72
+ *
73
+ */
74
+ export declare type CheckTxStatusRequest = {
75
+ requestId: string;
76
+ step: number;
77
+ txId: string;
78
+ };
79
+ /**
80
+ * Request body of createTransaction endpoint
81
+ *
82
+ * @property {string} requestId - The unique ID which is generated in best route endpoint
83
+ * @property {number} step - 1-based step number of a complex multi-step swap, example: 1, 2, ...
84
+ * @property {UserSettings} userSettings - user settings for swap
85
+ * @property {CreateTransactionValidation} validations - validation checks we are interested to check by Rango before starting swap
86
+ *
87
+ */
88
+ export declare type CreateTransactionRequest = {
89
+ requestId: string;
90
+ step: number;
91
+ userSettings: UserSettings;
92
+ validations: CreateTransactionValidation;
93
+ };
94
+ /**
95
+ * Data of the event including its type and an extra metadata
96
+ * It should be used when an error happened in client and we want to inform server that transaction failed,
97
+ * E.g. user rejected the transaction dialog or and an RPC error raised during signing tx by user.
98
+ *
99
+ * @property {string} requestId - The requestId from best route endpoint
100
+ * @property {string} eventType - Type of the event that happened, example: TX_FAIL
101
+ * @property {[key: string]: string} data - A list of key-value for extra details
102
+ *
103
+ */
104
+ export declare type ReportTransactionRequest = {
105
+ requestId: string;
106
+ eventType: 'TX_FAIL';
107
+ data: {
108
+ [key: string]: string;
109
+ };
110
+ };
111
+ /**
112
+ * The status of transaction in tracking
113
+ */
114
+ export declare enum TransactionStatus {
115
+ FAILED = "failed",
116
+ RUNNING = "running",
117
+ SUCCESS = "success"
118
+ }
119
+ /**
120
+ * Response of check transaction status containing the latest status of transaction
121
+ *
122
+ * @property {TransactionStatus | null} status - Status of the transaction, while the status is running or null, client
123
+ * should retry until it turns into success or fail
124
+ * @property {number} timestamp - The timestamp of the executed transaction. Beware that timestamp can be null even if
125
+ * the status is successful or failed, example: 1635271424813
126
+ * @property {string | null} extraMessage - A message in case of failure, that can be shown to user
127
+ * @property {string | null} outputAmount - The output amount of the transaction if it was successful, exmaple: 0.28
128
+ * @property {GenericTransaction | null} newTx - if a transaction needs more than one-step transaction to by signed by
129
+ * user, next step transaction will be returned in this field.
130
+ * @property {string | null} diagnosisUrl - In some special cases [ex: AnySwap], user should follow some steps outside
131
+ * Rango to get its assets. You can show this link to user to help him
132
+ * @property {SwapExplorerUrl[] | null} explorerUrl - List of explorer urls for the transactions that happened in this step.
133
+ * @property {TransactionStatusReferral[] | null} referrals - List of referral reward for the dApp and Rango
134
+ *
135
+ */
136
+ export declare type TransactionStatusResponse = {
137
+ status: TransactionStatus | null;
138
+ timestamp: number | null;
139
+ extraMessage: string | null;
140
+ outputAmount: string | null;
141
+ newTx: GenericTransaction | null;
142
+ diagnosisUrl: string | null;
143
+ explorerUrl: SwapExplorerUrl[] | null;
144
+ referrals: TransactionStatusReferral[] | null;
145
+ };
146
+ /**
147
+ * Response body of check-approval
148
+ *
149
+ * @property {boolean} isApproved - A flag which indicates that the approve tx is done or not
150
+ *
151
+ */
152
+ export declare type CheckApprovalResponse = {
153
+ isApproved: boolean;
154
+ };
155
+ /**
156
+ * Response body of create transaction, to see a list of example transactions
157
+ * @see https://rango.exchange/apis/docs/tx-example
158
+ *
159
+ * @property {string | null} error - Error message about the incident if ok == false
160
+ * @property {boolean} ok - If true, Rango has created a non-null transaction and error message is null
161
+ * @property {GenericTransaction | null} transaction - Transaction's raw data
162
+ *
163
+ */
164
+ export declare type CreateTransactionResponse = {
165
+ error: string | null;
166
+ ok: boolean;
167
+ transaction: GenericTransaction | null;
168
+ };
169
+ //# sourceMappingURL=transactions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.d.ts","sourceRoot":"","sources":["../../../src/types/api/transactions.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,oBAAY,eAAe;IACzB,GAAG,QAAQ;IACX,QAAQ,aAAa;IACrB,MAAM,WAAW;CAClB;AAED;;;;GAIG;AACH,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,eAAe,CAAA;CACtB,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,yBAAyB,GAAG;IACtC,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,MAAM,EAAE,MAAM,CAAA;CACf,CAAA;AAED;;;;;GAKG;AACH,oBAAY,YAAY,GAAG;IACzB,QAAQ,EAAE,MAAM,CAAA;CACjB,CAAA;AAED;;;;;;GAMG;AACH,oBAAY,2BAA2B,GAAG;IACxC,OAAO,EAAE,OAAO,CAAA;IAChB,GAAG,EAAE,OAAO,CAAA;CACb,CAAA;AAED;;;;;;;GAOG;AACH,oBAAY,eAAe,GAAG;IAC5B,WAAW,EAAE,MAAM,GAAG,IAAI,CAAA;IAC1B,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;;;;;;GAOG;AACH,oBAAY,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AAED;;;;;;;;GAQG;AACH,oBAAY,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,IAAI,EAAE,MAAM,CAAA;IACZ,YAAY,EAAE,YAAY,CAAA;IAC1B,WAAW,EAAE,2BAA2B,CAAA;CACzC,CAAA;AAED;;;;;;;;;GASG;AACH,oBAAY,wBAAwB,GAAG;IACrC,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,SAAS,CAAA;IACpB,IAAI,EAAE;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;KAAE,CAAA;CAChC,CAAA;AAED;;GAEG;AACH,oBAAY,iBAAiB;IAC3B,MAAM,WAAW;IACjB,OAAO,YAAY;IACnB,OAAO,YAAY;CACpB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,oBAAY,yBAAyB,GAAG;IACtC,MAAM,EAAE,iBAAiB,GAAG,IAAI,CAAA;IAChC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACxB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,KAAK,EAAE,kBAAkB,GAAG,IAAI,CAAA;IAChC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,WAAW,EAAE,eAAe,EAAE,GAAG,IAAI,CAAA;IACrC,SAAS,EAAE,yBAAyB,EAAE,GAAG,IAAI,CAAA;CAC9C,CAAA;AAED;;;;;GAKG;AACH,oBAAY,qBAAqB,GAAG;IAClC,UAAU,EAAE,OAAO,CAAA;CACpB,CAAA;AAED;;;;;;;;GAQG;AACH,oBAAY,yBAAyB,GAAG;IACtC,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,EAAE,EAAE,OAAO,CAAA;IACX,WAAW,EAAE,kBAAkB,GAAG,IAAI,CAAA;CACvC,CAAA"}
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TransactionStatus = exports.TransactionType = void 0;
4
+ /**
5
+ * The type of transaction
6
+ */
7
+ var TransactionType;
8
+ (function (TransactionType) {
9
+ TransactionType["EVM"] = "EVM";
10
+ TransactionType["TRANSFER"] = "TRANSFER";
11
+ TransactionType["COSMOS"] = "COSMOS";
12
+ })(TransactionType = exports.TransactionType || (exports.TransactionType = {}));
13
+ /**
14
+ * The status of transaction in tracking
15
+ */
16
+ var TransactionStatus;
17
+ (function (TransactionStatus) {
18
+ TransactionStatus["FAILED"] = "failed";
19
+ TransactionStatus["RUNNING"] = "running";
20
+ TransactionStatus["SUCCESS"] = "success";
21
+ })(TransactionStatus = exports.TransactionStatus || (exports.TransactionStatus = {}));
22
+ //# sourceMappingURL=transactions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transactions.js","sourceRoot":"","sources":["../../../src/types/api/transactions.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,8BAAW,CAAA;IACX,wCAAqB,CAAA;IACrB,oCAAiB,CAAA;AACnB,CAAC,EAJW,eAAe,GAAf,uBAAe,KAAf,uBAAe,QAI1B;AA8GD;;GAEG;AACH,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,wCAAmB,CAAA;IACnB,wCAAmB,CAAA;AACrB,CAAC,EAJW,iBAAiB,GAAjB,yBAAiB,KAAjB,yBAAiB,QAI5B"}
@@ -0,0 +1,66 @@
1
+ import type { AssetWithTicker } from '../common';
2
+ import type { GenericTransaction } from '../transactions';
3
+ /**
4
+ * CosmosCoin representing fee coins
5
+ */
6
+ export declare type CosmosCoin = {
7
+ amount: string;
8
+ denom: string;
9
+ };
10
+ /**
11
+ * CosmosStdFee representing fee for cosmos transaction
12
+ */
13
+ export declare type CosmosStdFee = {
14
+ amount: CosmosCoin[];
15
+ gas: string;
16
+ };
17
+ /**
18
+ * Main transaction object for COSMOS type transactions (including Terra, Osmosis, ...)
19
+ */
20
+ export declare type CosmosMessage = {
21
+ signType: 'AMINO' | 'DIRECT';
22
+ sequence: string | null;
23
+ source: number | null;
24
+ account_number: number | null;
25
+ rpcUrl: string | null;
26
+ chainId: string | null;
27
+ msgs: any[];
28
+ protoMsgs: any[];
29
+ memo: string | null;
30
+ fee: CosmosStdFee | null;
31
+ };
32
+ /**
33
+ * An alternative to CosmosMessage object for the cosmos wallets that do not support generic Cosmos messages (e.g. XDefi)
34
+ *
35
+ * @property {AssetWithTicker} asset - The asset to be transferred
36
+ * @property {string} amount - The machine-readable amount to transfer, example: 1000000000000000000
37
+ * @property {number} decimals - The decimals for this asset, example: 18
38
+ * @property {string | null} memo - Memo of transaction, could be null
39
+ * @property {string} method - The transaction method, example: transfer, deposit
40
+ * @property {string} recipient - The recipient address of transaction
41
+ *
42
+ */
43
+ export declare type CosmosRawTransferData = {
44
+ amount: string;
45
+ asset: AssetWithTicker;
46
+ decimals: number;
47
+ memo: string | null;
48
+ method: string;
49
+ recipient: string;
50
+ };
51
+ /**
52
+ * A Cosmos transaction, child of GenericTransaction
53
+ *
54
+ * @property {string} blockChain - The blockchain that this transaction will be executed in, same as the input blockchain of creating transaction
55
+ * @property {string} fromWalletAddress - Address of wallet that this transaction should be executed in, same as the create transaction request's input
56
+ * @property {CosmosMessage} data - Transaction data
57
+ * @property {CosmosRawTransferData} rawTransfer - An alternative to CosmosMessage object for the cosmos wallets that do not support generic Cosmos messages
58
+ *
59
+ */
60
+ export interface CosmosTransaction extends GenericTransaction {
61
+ blockChain: string;
62
+ fromWalletAddress: string;
63
+ data: CosmosMessage;
64
+ rawTransfer: CosmosRawTransferData;
65
+ }
66
+ //# sourceMappingURL=cosmos.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosmos.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/cosmos.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD;;GAEG;AACH,oBAAY,UAAU,GAAG;IACvB,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,MAAM,CAAA;CACd,CAAA;AAED;;GAEG;AACH,oBAAY,YAAY,GAAG;IACzB,MAAM,EAAE,UAAU,EAAE,CAAA;IACpB,GAAG,EAAE,MAAM,CAAA;CACZ,CAAA;AAED;;GAEG;AACH,oBAAY,aAAa,GAAG;IAC1B,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAAA;IAC5B,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,cAAc,EAAE,MAAM,GAAG,IAAI,CAAA;IAC7B,MAAM,EAAE,MAAM,GAAG,IAAI,CAAA;IACrB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;IACtB,IAAI,EAAE,GAAG,EAAE,CAAA;IACX,SAAS,EAAE,GAAG,EAAE,CAAA;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,GAAG,EAAE,YAAY,GAAG,IAAI,CAAA;CACzB,CAAA;AAED;;;;;;;;;;GAUG;AACH,oBAAY,qBAAqB,GAAG;IAClC,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,eAAe,CAAA;IACtB,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,MAAM,EAAE,MAAM,CAAA;IACd,SAAS,EAAE,MAAM,CAAA;CAClB,CAAA;AAED;;;;;;;;GAQG;AACH,MAAM,WAAW,iBAAkB,SAAQ,kBAAkB;IAC3D,UAAU,EAAE,MAAM,CAAA;IAClB,iBAAiB,EAAE,MAAM,CAAA;IACzB,IAAI,EAAE,aAAa,CAAA;IACnB,WAAW,EAAE,qBAAqB,CAAA;CACnC"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=cosmos.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cosmos.js","sourceRoot":"","sources":["../../../../src/types/api/txs/cosmos.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import type { GenericTransaction } from '../transactions';
2
+ /**
3
+ * The transaction object for all EVM-based blockchains, including Ethereum, BSC, Polygon, Harmony, etc
4
+ *
5
+ * @property {boolean} isApprovalTx - Determines that this transaction is an approval transaction or not, if true user
6
+ * should approve the transaction and call create transaction endpoint again to get the original tx. Beware that most
7
+ * of the fields of this object will be passed directly to the wallet without any change.
8
+ * @property {string} blockChain - The blockchain that this transaction is going to run in
9
+ * @property {string | null} from - The source wallet address, it can be null
10
+ * @property {string} to - Address of destination wallet or the smart contract or token that is going to be called
11
+ * @property {string | null} data - The data of smart contract call, it can be null in case of native token transfer
12
+ * @property {string | null} value - The amount of transaction in case of native token transfer
13
+ * @property {string | null} nonce - The nonce value for transaction
14
+ * @property {string | null} gasPrice - The suggested gas price for this transaction
15
+ * @property {string | null} gasLimit - The suggested gas limit for this transaction
16
+ *
17
+ */
18
+ export interface EvmTransaction extends GenericTransaction {
19
+ isApprovalTx: boolean;
20
+ blockChain: string;
21
+ from: string | null;
22
+ to: string;
23
+ data: string | null;
24
+ value: string | null;
25
+ nonce: string | null;
26
+ gasLimit: string | null;
27
+ gasPrice: string | null;
28
+ }
29
+ //# sourceMappingURL=evm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/evm.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD;;;;;;;;;;;;;;;GAeG;AACH,MAAM,WAAW,cAAe,SAAQ,kBAAkB;IACxD,YAAY,EAAE,OAAO,CAAA;IACrB,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;CACxB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=evm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evm.js","sourceRoot":"","sources":["../../../../src/types/api/txs/evm.ts"],"names":[],"mappings":""}
@@ -0,0 +1,4 @@
1
+ export * from './evm';
2
+ export * from './cosmos';
3
+ export * from './transfer';
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAA;AACrB,cAAc,UAAU,CAAA;AACxB,cAAc,YAAY,CAAA"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./evm"), exports);
14
+ __exportStar(require("./cosmos"), exports);
15
+ __exportStar(require("./transfer"), exports);
16
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/types/api/txs/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,wCAAqB;AACrB,2CAAwB;AACxB,6CAA0B"}
@@ -0,0 +1,24 @@
1
+ import type { AssetWithTicker } from '../common';
2
+ import type { GenericTransaction } from '../transactions';
3
+ /**
4
+ * TransferTransaction. This type of transaction is used for non-EVM and non-Cosmos blockchains including BTC, LTC, BCH
5
+ *
6
+ * @property {string} method - The method that should be passed to wallet. examples: deposit, transfer
7
+ * @property {AssetWithTicker} asset
8
+ * @property {string} amount - The machine-readable amount of transaction, example: 1000000000000000000
9
+ * @property {number} decimals - The decimals of the asset
10
+ * @property {string} fromWalletAddress - The source wallet address that can sign this transaction
11
+ * @property {string} recipientAddress - The destination wallet address that the fund should be sent to
12
+ * @property {string | null} memo - The memo of transaction, can be null
13
+ *
14
+ */
15
+ export interface Transfer extends GenericTransaction {
16
+ method: string;
17
+ asset: AssetWithTicker;
18
+ amount: string;
19
+ decimals: number;
20
+ fromWalletAddress: string;
21
+ recipientAddress: string;
22
+ memo: string | null;
23
+ }
24
+ //# sourceMappingURL=transfer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.d.ts","sourceRoot":"","sources":["../../../../src/types/api/txs/transfer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,WAAW,CAAA;AAChD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAEzD;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,QAAS,SAAQ,kBAAkB;IAClD,MAAM,EAAE,MAAM,CAAA;IACd,KAAK,EAAE,eAAe,CAAA;IACtB,MAAM,EAAE,MAAM,CAAA;IACd,QAAQ,EAAE,MAAM,CAAA;IAChB,iBAAiB,EAAE,MAAM,CAAA;IACzB,gBAAgB,EAAE,MAAM,CAAA;IACxB,IAAI,EAAE,MAAM,GAAG,IAAI,CAAA;CACpB"}
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transfer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transfer.js","sourceRoot":"","sources":["../../../../src/types/api/txs/transfer.ts"],"names":[],"mappings":""}
@@ -0,0 +1,7 @@
1
+ export * from './api/balance';
2
+ export * from './api/common';
3
+ export * from './api/meta';
4
+ export * from './api/routing';
5
+ export * from './api/transactions';
6
+ export * from './api/txs';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,cAAc,CAAA;AAC5B,cAAc,YAAY,CAAA;AAC1B,cAAc,eAAe,CAAA;AAC7B,cAAc,oBAAoB,CAAA;AAClC,cAAc,WAAW,CAAA"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
+ }) : (function(o, m, k, k2) {
6
+ if (k2 === undefined) k2 = k;
7
+ o[k2] = m[k];
8
+ }));
9
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ __exportStar(require("./api/balance"), exports);
14
+ __exportStar(require("./api/common"), exports);
15
+ __exportStar(require("./api/meta"), exports);
16
+ __exportStar(require("./api/routing"), exports);
17
+ __exportStar(require("./api/transactions"), exports);
18
+ __exportStar(require("./api/txs"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,gDAA6B;AAC7B,+CAA4B;AAC5B,6CAA0B;AAC1B,gDAA6B;AAC7B,qDAAkC;AAClC,4CAAyB"}
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "rango-sdk",
3
+ "version": "0.0.1",
4
+ "description": "Rango Exchange SDK for dApps",
5
+ "main": "lib/index.js",
6
+ "types": "lib",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/rango-exchange/rango-sdk.git"
10
+ },
11
+ "homepage": "https://github.com/rango-exchange/rango-sdk",
12
+ "bugs": {
13
+ "url": "https://github.com/rango-exchange/rango-sdk/issues"
14
+ },
15
+ "scripts": {
16
+ "test": "jest --config jestconfig.json",
17
+ "build": "tsc",
18
+ "format": "prettier --write ./src",
19
+ "lint": "eslint */**/*.{js,ts} --quiet --fix",
20
+ "semantic-release": "semantic-release"
21
+ },
22
+ "keywords": [
23
+ "Rango Exchange",
24
+ "SDK",
25
+ "Cross-Chain",
26
+ "Multi-Chain"
27
+ ],
28
+ "files": [
29
+ "lib/**/*"
30
+ ],
31
+ "author": "rango.exchange",
32
+ "license": "GPL-3.0",
33
+ "devDependencies": {
34
+ "@types/jest": "^27.4.0",
35
+ "@types/uuid": "^8.3.4",
36
+ "@typescript-eslint/eslint-plugin": "^5.9.1",
37
+ "@typescript-eslint/parser": "^5.9.1",
38
+ "eslint": "^8.6.0",
39
+ "eslint-config-prettier": "^8.3.0",
40
+ "eslint-plugin-import": "^2.25.4",
41
+ "eslint-plugin-prettier": "^4.0.0",
42
+ "jest": "^27.4.7",
43
+ "prettier": "^2.5.1",
44
+ "semantic-release": "^19.0.2",
45
+ "ts-jest": "^27.1.3",
46
+ "typescript": "^4.5.4"
47
+ },
48
+ "dependencies": {
49
+ "axios": "^0.24.0",
50
+ "bignumber.js": "^9.0.2",
51
+ "uuid": "^8.3.2"
52
+ },
53
+ "publishConfig": {
54
+ "access": "public",
55
+ "branches": [
56
+ "master"
57
+ ]
58
+ }
59
+ }