@ledgerhq/live-common 25.2.0-next.0 → 25.2.0-next.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 (316) hide show
  1. package/lib/__tests__/test-helpers/setup.js +1 -0
  2. package/lib/__tests__/test-helpers/setup.js.map +1 -1
  3. package/lib/account/helpers.d.ts.map +1 -1
  4. package/lib/account/helpers.js +1 -0
  5. package/lib/account/helpers.js.map +1 -1
  6. package/lib/account/serialization.d.ts.map +1 -1
  7. package/lib/account/serialization.js +4 -0
  8. package/lib/account/serialization.js.map +1 -1
  9. package/lib/data/icons/react/index.d.ts +1 -0
  10. package/lib/data/icons/react/index.d.ts.map +1 -1
  11. package/lib/data/icons/react/index.js +7 -5
  12. package/lib/data/icons/react/index.js.map +1 -1
  13. package/lib/data/icons/react/osmo.d.ts +8 -0
  14. package/lib/data/icons/react/osmo.d.ts.map +1 -0
  15. package/lib/data/icons/react/osmo.js +39 -0
  16. package/lib/data/icons/react/osmo.js.map +1 -0
  17. package/lib/data/icons/reactNative/index.d.ts +1 -0
  18. package/lib/data/icons/reactNative/index.d.ts.map +1 -1
  19. package/lib/data/icons/reactNative/index.js +7 -5
  20. package/lib/data/icons/reactNative/index.js.map +1 -1
  21. package/lib/data/icons/reactNative/osmo.d.ts +8 -0
  22. package/lib/data/icons/reactNative/osmo.d.ts.map +1 -0
  23. package/lib/data/icons/reactNative/osmo.js +40 -0
  24. package/lib/data/icons/reactNative/osmo.js.map +1 -0
  25. package/lib/env.d.ts +15 -5
  26. package/lib/env.d.ts.map +1 -1
  27. package/lib/env.js +10 -0
  28. package/lib/env.js.map +1 -1
  29. package/lib/env.react.d.ts +1 -1
  30. package/lib/env.react.d.ts.map +1 -1
  31. package/lib/families/cosmos/CosmosValidatorsManager.d.ts +26 -0
  32. package/lib/families/cosmos/CosmosValidatorsManager.d.ts.map +1 -0
  33. package/lib/families/cosmos/CosmosValidatorsManager.js +365 -0
  34. package/lib/families/cosmos/CosmosValidatorsManager.js.map +1 -0
  35. package/lib/families/cosmos/account.d.ts +2 -2
  36. package/lib/families/cosmos/account.d.ts.map +1 -1
  37. package/lib/families/cosmos/account.js +19 -6
  38. package/lib/families/cosmos/account.js.map +1 -1
  39. package/lib/families/cosmos/api/Cosmos.d.ts +27 -15
  40. package/lib/families/cosmos/api/Cosmos.d.ts.map +1 -1
  41. package/lib/families/cosmos/api/Cosmos.js +418 -410
  42. package/lib/families/cosmos/api/Cosmos.js.map +1 -1
  43. package/lib/families/cosmos/bridge/js.d.ts.map +1 -1
  44. package/lib/families/cosmos/bridge/js.js +5 -5
  45. package/lib/families/cosmos/bridge/js.js.map +1 -1
  46. package/lib/families/cosmos/bridge/mock.js +1 -1
  47. package/lib/families/cosmos/bridge/mock.js.map +1 -1
  48. package/lib/families/cosmos/bridge.integration.test.js +5 -5
  49. package/lib/families/cosmos/bridge.integration.test.js.map +1 -1
  50. package/lib/families/cosmos/cli-transaction.d.ts +3 -3
  51. package/lib/families/cosmos/cli-transaction.d.ts.map +1 -1
  52. package/lib/families/cosmos/cli-transaction.js +4 -5
  53. package/lib/families/cosmos/cli-transaction.js.map +1 -1
  54. package/lib/families/cosmos/js-buildTransaction.js +3 -3
  55. package/lib/families/cosmos/js-buildTransaction.js.map +1 -1
  56. package/lib/families/cosmos/js-createTransaction.js +1 -1
  57. package/lib/families/cosmos/js-createTransaction.js.map +1 -1
  58. package/lib/families/cosmos/js-getTransactionStatus.d.ts +17 -3
  59. package/lib/families/cosmos/js-getTransactionStatus.d.ts.map +1 -1
  60. package/lib/families/cosmos/js-getTransactionStatus.js +224 -176
  61. package/lib/families/cosmos/js-getTransactionStatus.js.map +1 -1
  62. package/lib/families/cosmos/js-prepareTransaction.js +2 -2
  63. package/lib/families/cosmos/js-prepareTransaction.js.map +1 -1
  64. package/lib/families/cosmos/js-signOperation.js +3 -3
  65. package/lib/families/cosmos/js-signOperation.js.map +1 -1
  66. package/lib/families/cosmos/js-synchronisation.js +2 -2
  67. package/lib/families/cosmos/js-synchronisation.js.map +1 -1
  68. package/lib/families/cosmos/logic.js +1 -1
  69. package/lib/families/cosmos/logic.js.map +1 -1
  70. package/lib/families/cosmos/mock.js +1 -1
  71. package/lib/families/cosmos/mock.js.map +1 -1
  72. package/lib/families/cosmos/react.d.ts +4 -4
  73. package/lib/families/cosmos/react.d.ts.map +1 -1
  74. package/lib/families/cosmos/react.js +59 -26
  75. package/lib/families/cosmos/react.js.map +1 -1
  76. package/lib/families/cosmos/react.test.js +17 -15
  77. package/lib/families/cosmos/react.test.js.map +1 -1
  78. package/lib/families/cosmos/specs.js +2 -2
  79. package/lib/families/cosmos/specs.js.map +1 -1
  80. package/lib/families/cosmos/speculos-deviceActions.d.ts.map +1 -1
  81. package/lib/families/cosmos/speculos-deviceActions.js +1 -1
  82. package/lib/families/cosmos/speculos-deviceActions.js.map +1 -1
  83. package/lib/families/cosmos/transaction.d.ts +2 -2
  84. package/lib/families/cosmos/transaction.d.ts.map +1 -1
  85. package/lib/families/cosmos/transaction.js +4 -4
  86. package/lib/families/cosmos/transaction.js.map +1 -1
  87. package/lib/families/cosmos/types.d.ts +31 -13
  88. package/lib/families/cosmos/types.d.ts.map +1 -1
  89. package/lib/families/cosmos/utils.d.ts +1 -0
  90. package/lib/families/cosmos/utils.d.ts.map +1 -1
  91. package/lib/families/cosmos/utils.js +7 -1
  92. package/lib/families/cosmos/utils.js.map +1 -1
  93. package/lib/families/cosmos/validators.d.ts +3 -5
  94. package/lib/families/cosmos/validators.d.ts.map +1 -1
  95. package/lib/families/cosmos/validators.js +4 -317
  96. package/lib/families/cosmos/validators.js.map +1 -1
  97. package/lib/families/osmosis/OsmosisSupplyTypes.d.ts +48 -0
  98. package/lib/families/osmosis/OsmosisSupplyTypes.d.ts.map +1 -0
  99. package/lib/families/osmosis/OsmosisSupplyTypes.js +3 -0
  100. package/lib/families/osmosis/OsmosisSupplyTypes.js.map +1 -0
  101. package/lib/families/osmosis/account.d.ts +14 -0
  102. package/lib/families/osmosis/account.d.ts.map +1 -0
  103. package/lib/families/osmosis/account.js +60 -0
  104. package/lib/families/osmosis/account.js.map +1 -0
  105. package/lib/families/osmosis/api/sdk.d.ts +35 -0
  106. package/lib/families/osmosis/api/sdk.d.ts.map +1 -0
  107. package/lib/families/osmosis/api/sdk.js +478 -0
  108. package/lib/families/osmosis/api/sdk.js.map +1 -0
  109. package/lib/families/osmosis/api/sdk.types.d.ts +57 -0
  110. package/lib/families/osmosis/api/sdk.types.d.ts.map +1 -0
  111. package/lib/families/osmosis/api/sdk.types.js +15 -0
  112. package/lib/families/osmosis/api/sdk.types.js.map +1 -0
  113. package/lib/families/osmosis/api/sdk.unit.test.d.ts +2 -0
  114. package/lib/families/osmosis/api/sdk.unit.test.d.ts.map +1 -0
  115. package/lib/families/osmosis/api/sdk.unit.test.js +50 -0
  116. package/lib/families/osmosis/api/sdk.unit.test.js.map +1 -0
  117. package/lib/families/osmosis/bridge/js.d.ts +8 -0
  118. package/lib/families/osmosis/bridge/js.d.ts.map +1 -0
  119. package/lib/families/osmosis/bridge/js.js +98 -0
  120. package/lib/families/osmosis/bridge/js.js.map +1 -0
  121. package/lib/families/osmosis/bridge.integration.test.d.ts +2 -0
  122. package/lib/families/osmosis/bridge.integration.test.d.ts.map +1 -0
  123. package/lib/families/osmosis/bridge.integration.test.js +383 -0
  124. package/lib/families/osmosis/bridge.integration.test.js.map +1 -0
  125. package/lib/families/osmosis/cli-transaction.d.ts +38 -0
  126. package/lib/families/osmosis/cli-transaction.d.ts.map +1 -0
  127. package/lib/families/osmosis/cli-transaction.js +119 -0
  128. package/lib/families/osmosis/cli-transaction.js.map +1 -0
  129. package/lib/families/osmosis/deviceTransactionConfig.d.ts +25 -0
  130. package/lib/families/osmosis/deviceTransactionConfig.d.ts.map +1 -0
  131. package/lib/families/osmosis/deviceTransactionConfig.js +132 -0
  132. package/lib/families/osmosis/deviceTransactionConfig.js.map +1 -0
  133. package/lib/families/osmosis/errors.d.ts +4 -0
  134. package/lib/families/osmosis/errors.d.ts.map +1 -0
  135. package/lib/families/osmosis/errors.js +8 -0
  136. package/lib/families/osmosis/errors.js.map +1 -0
  137. package/lib/families/osmosis/hw-getAddress.d.ts +4 -0
  138. package/lib/families/osmosis/hw-getAddress.d.ts.map +1 -0
  139. package/lib/families/osmosis/hw-getAddress.js +64 -0
  140. package/lib/families/osmosis/hw-getAddress.js.map +1 -0
  141. package/lib/families/osmosis/js-buildTransaction.d.ts +14 -0
  142. package/lib/families/osmosis/js-buildTransaction.d.ts.map +1 -0
  143. package/lib/families/osmosis/js-buildTransaction.js +303 -0
  144. package/lib/families/osmosis/js-buildTransaction.js.map +1 -0
  145. package/lib/families/osmosis/js-estimateMaxSpendable.d.ts +15 -0
  146. package/lib/families/osmosis/js-estimateMaxSpendable.d.ts.map +1 -0
  147. package/lib/families/osmosis/js-estimateMaxSpendable.js +67 -0
  148. package/lib/families/osmosis/js-estimateMaxSpendable.js.map +1 -0
  149. package/lib/families/osmosis/js-getFeesForTransaction.d.ts +15 -0
  150. package/lib/families/osmosis/js-getFeesForTransaction.d.ts.map +1 -0
  151. package/lib/families/osmosis/js-getFeesForTransaction.js +85 -0
  152. package/lib/families/osmosis/js-getFeesForTransaction.js.map +1 -0
  153. package/lib/families/osmosis/js-getTransactionStatus.d.ts +3 -0
  154. package/lib/families/osmosis/js-getTransactionStatus.d.ts.map +1 -0
  155. package/lib/families/osmosis/js-getTransactionStatus.js +10 -0
  156. package/lib/families/osmosis/js-getTransactionStatus.js.map +1 -0
  157. package/lib/families/osmosis/js-signOperation.d.ts +10 -0
  158. package/lib/families/osmosis/js-signOperation.d.ts.map +1 -0
  159. package/lib/families/osmosis/js-signOperation.js +211 -0
  160. package/lib/families/osmosis/js-signOperation.js.map +1 -0
  161. package/lib/families/osmosis/js-synchronization.d.ts +9 -0
  162. package/lib/families/osmosis/js-synchronization.d.ts.map +1 -0
  163. package/lib/families/osmosis/js-synchronization.js +176 -0
  164. package/lib/families/osmosis/js-synchronization.js.map +1 -0
  165. package/lib/families/osmosis/js-transaction.d.ts +23 -0
  166. package/lib/families/osmosis/js-transaction.d.ts.map +1 -0
  167. package/lib/families/osmosis/js-transaction.js +177 -0
  168. package/lib/families/osmosis/js-transaction.js.map +1 -0
  169. package/lib/families/osmosis/logic.d.ts +5 -0
  170. package/lib/families/osmosis/logic.d.ts.map +1 -0
  171. package/lib/families/osmosis/logic.js +22 -0
  172. package/lib/families/osmosis/logic.js.map +1 -0
  173. package/lib/families/osmosis/preloadedData.d.ts +9 -0
  174. package/lib/families/osmosis/preloadedData.d.ts.map +1 -0
  175. package/lib/families/osmosis/preloadedData.js +32 -0
  176. package/lib/families/osmosis/preloadedData.js.map +1 -0
  177. package/lib/families/osmosis/serialization.d.ts +7 -0
  178. package/lib/families/osmosis/serialization.d.ts.map +1 -0
  179. package/lib/families/osmosis/serialization.js +5 -0
  180. package/lib/families/osmosis/serialization.js.map +1 -0
  181. package/lib/families/osmosis/specs.d.ts +7 -0
  182. package/lib/families/osmosis/specs.d.ts.map +1 -0
  183. package/lib/families/osmosis/specs.js +402 -0
  184. package/lib/families/osmosis/specs.js.map +1 -0
  185. package/lib/families/osmosis/speculos-deviceActions.d.ts +7 -0
  186. package/lib/families/osmosis/speculos-deviceActions.d.ts.map +1 -0
  187. package/lib/families/osmosis/speculos-deviceActions.js +120 -0
  188. package/lib/families/osmosis/speculos-deviceActions.js.map +1 -0
  189. package/lib/families/osmosis/transaction.d.ts +10 -0
  190. package/lib/families/osmosis/transaction.d.ts.map +1 -0
  191. package/lib/families/osmosis/transaction.js +13 -0
  192. package/lib/families/osmosis/transaction.js.map +1 -0
  193. package/lib/families/osmosis/types.d.ts +38 -0
  194. package/lib/families/osmosis/types.d.ts.map +1 -0
  195. package/lib/families/osmosis/types.js +3 -0
  196. package/lib/families/osmosis/types.js.map +1 -0
  197. package/lib/families/osmosis/utils.d.ts +8 -0
  198. package/lib/families/osmosis/utils.d.ts.map +1 -0
  199. package/lib/families/osmosis/utils.js +28 -0
  200. package/lib/families/osmosis/utils.js.map +1 -0
  201. package/lib/families/osmosis/validators.d.ts +4 -0
  202. package/lib/families/osmosis/validators.d.ts.map +1 -0
  203. package/lib/families/osmosis/validators.js +131 -0
  204. package/lib/families/osmosis/validators.js.map +1 -0
  205. package/lib/featureFlags/defaultFeatures.d.ts.map +1 -1
  206. package/lib/featureFlags/defaultFeatures.js +3 -0
  207. package/lib/featureFlags/defaultFeatures.js.map +1 -1
  208. package/lib/generated/account.d.ts +7 -1
  209. package/lib/generated/account.d.ts.map +1 -1
  210. package/lib/generated/account.js +4 -2
  211. package/lib/generated/account.js.map +1 -1
  212. package/lib/generated/bridge/js.d.ts +4 -0
  213. package/lib/generated/bridge/js.d.ts.map +1 -1
  214. package/lib/generated/bridge/js.js +14 -12
  215. package/lib/generated/bridge/js.js.map +1 -1
  216. package/lib/generated/cli-transaction.d.ts +33 -2
  217. package/lib/generated/cli-transaction.d.ts.map +1 -1
  218. package/lib/generated/cli-transaction.js +14 -12
  219. package/lib/generated/cli-transaction.js.map +1 -1
  220. package/lib/generated/deviceTransactionConfig.d.ts +4 -1
  221. package/lib/generated/deviceTransactionConfig.d.ts.map +1 -1
  222. package/lib/generated/deviceTransactionConfig.js +14 -12
  223. package/lib/generated/deviceTransactionConfig.js.map +1 -1
  224. package/lib/generated/hw-getAddress.d.ts +1 -0
  225. package/lib/generated/hw-getAddress.d.ts.map +1 -1
  226. package/lib/generated/hw-getAddress.js +14 -12
  227. package/lib/generated/hw-getAddress.js.map +1 -1
  228. package/lib/generated/specs.d.ts +3 -0
  229. package/lib/generated/specs.d.ts.map +1 -1
  230. package/lib/generated/specs.js +14 -12
  231. package/lib/generated/specs.js.map +1 -1
  232. package/lib/generated/speculos-deviceActions.d.ts +3 -0
  233. package/lib/generated/speculos-deviceActions.d.ts.map +1 -1
  234. package/lib/generated/speculos-deviceActions.js +14 -12
  235. package/lib/generated/speculos-deviceActions.js.map +1 -1
  236. package/lib/generated/transaction.d.ts +9 -1
  237. package/lib/generated/transaction.d.ts.map +1 -1
  238. package/lib/generated/transaction.js +14 -12
  239. package/lib/generated/transaction.js.map +1 -1
  240. package/lib/generated/types.d.ts +8 -4
  241. package/lib/generated/types.d.ts.map +1 -1
  242. package/lib/reconciliation.d.ts.map +1 -1
  243. package/lib/reconciliation.js +9 -0
  244. package/lib/reconciliation.js.map +1 -1
  245. package/package.json +8 -3
  246. package/src/__tests__/test-helpers/setup.ts +1 -0
  247. package/src/account/helpers.ts +1 -0
  248. package/src/account/serialization.ts +6 -0
  249. package/src/data/icons/react/index.tsx +1 -0
  250. package/src/data/icons/react/osmo.tsx +14 -0
  251. package/src/data/icons/reactNative/index.tsx +1 -0
  252. package/src/data/icons/reactNative/osmo.tsx +15 -0
  253. package/src/data/icons/svg/OSMO.svg +7 -0
  254. package/src/env.ts +10 -0
  255. package/src/families/cosmos/CosmosValidatorsManager.ts +420 -0
  256. package/src/families/cosmos/account.ts +29 -10
  257. package/src/families/cosmos/api/Cosmos.ts +267 -257
  258. package/src/families/cosmos/bridge/js.ts +6 -7
  259. package/src/families/cosmos/bridge/mock.ts +1 -1
  260. package/src/families/cosmos/bridge.integration.test.ts +5 -5
  261. package/src/families/cosmos/cli-transaction.ts +7 -8
  262. package/src/families/cosmos/js-buildTransaction.ts +4 -4
  263. package/src/families/cosmos/js-createTransaction.ts +1 -1
  264. package/src/families/cosmos/js-getTransactionStatus.ts +276 -226
  265. package/src/families/cosmos/js-prepareTransaction.ts +3 -3
  266. package/src/families/cosmos/js-signOperation.ts +4 -4
  267. package/src/families/cosmos/js-synchronisation.ts +3 -3
  268. package/src/families/cosmos/logic.ts +1 -1
  269. package/src/families/cosmos/mock.ts +1 -1
  270. package/src/families/cosmos/react.test.ts +25 -14
  271. package/src/families/cosmos/react.ts +73 -21
  272. package/src/families/cosmos/specs.ts +2 -2
  273. package/src/families/cosmos/speculos-deviceActions.ts +1 -2
  274. package/src/families/cosmos/transaction.ts +4 -6
  275. package/src/families/cosmos/types.ts +41 -13
  276. package/src/families/cosmos/utils.ts +8 -0
  277. package/src/families/cosmos/validators.ts +5 -363
  278. package/src/families/osmosis/OsmosisSupplyTypes.ts +53 -0
  279. package/src/families/osmosis/__snapshots__/bridge.integration.test.ts.snap +852 -0
  280. package/src/families/osmosis/account.ts +65 -0
  281. package/src/families/osmosis/api/sdk.ts +530 -0
  282. package/src/families/osmosis/api/sdk.types.ts +65 -0
  283. package/src/families/osmosis/api/sdk.unit.test.ts +70 -0
  284. package/src/families/osmosis/bridge/js.ts +64 -0
  285. package/src/families/osmosis/bridge.integration.test.ts +467 -0
  286. package/src/families/osmosis/cli-transaction.ts +145 -0
  287. package/src/families/osmosis/deviceTransactionConfig.ts +174 -0
  288. package/src/families/osmosis/errors.ts +13 -0
  289. package/src/families/osmosis/hw-getAddress.ts +14 -0
  290. package/src/families/osmosis/js-buildTransaction.ts +306 -0
  291. package/src/families/osmosis/js-estimateMaxSpendable.ts +26 -0
  292. package/src/families/osmosis/js-getFeesForTransaction.ts +44 -0
  293. package/src/families/osmosis/js-getTransactionStatus.ts +9 -0
  294. package/src/families/osmosis/js-signOperation.ts +172 -0
  295. package/src/families/osmosis/js-synchronization.ts +122 -0
  296. package/src/families/osmosis/js-transaction.ts +96 -0
  297. package/src/families/osmosis/logic.ts +26 -0
  298. package/src/families/osmosis/preloadedData.ts +32 -0
  299. package/src/families/osmosis/serialization.ts +6 -0
  300. package/src/families/osmosis/specs.ts +393 -0
  301. package/src/families/osmosis/speculos-deviceActions.ts +94 -0
  302. package/src/families/osmosis/transaction.ts +20 -0
  303. package/src/families/osmosis/types.ts +48 -0
  304. package/src/families/osmosis/utils.ts +31 -0
  305. package/src/families/osmosis/validators.ts +79 -0
  306. package/src/featureFlags/defaultFeatures.ts +3 -0
  307. package/src/generated/account.ts +3 -0
  308. package/src/generated/bridge/js.ts +3 -0
  309. package/src/generated/cli-transaction.ts +3 -0
  310. package/src/generated/deviceTransactionConfig.ts +5 -0
  311. package/src/generated/hw-getAddress.ts +3 -0
  312. package/src/generated/specs.ts +3 -0
  313. package/src/generated/speculos-deviceActions.ts +3 -0
  314. package/src/generated/transaction.ts +3 -0
  315. package/src/generated/types.ts +8 -0
  316. package/src/reconciliation.ts +16 -0
@@ -75,455 +75,463 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
75
75
  return (mod && mod.__esModule) ? mod : { "default": mod };
76
76
  };
77
77
  exports.__esModule = true;
78
- exports.broadcast = exports.simulate = exports.isValidRecipent = exports.getChainId = exports.getAccount = exports.getAccountInfo = void 0;
78
+ exports.defaultCosmosAPI = exports.CosmosAPI = void 0;
79
79
  var env_1 = require("../../../env");
80
80
  var bignumber_js_1 = __importDefault(require("bignumber.js"));
81
81
  var network_1 = __importDefault(require("../../../network"));
82
82
  var operation_1 = require("../../../operation");
83
83
  var defaultEndpoint = (0, env_1.getEnv)("API_COSMOS_BLOCKCHAIN_EXPLORER_API_ENDPOINT").replace(/\/$/, "");
84
- var getAccountInfo = function (address, currency) { return __awaiter(void 0, void 0, void 0, function () {
85
- var _a, _b, accountNumber, sequence, balances, blockHeight, txs, delegations, redelegations, unbondings, withdrawAddress, e_1;
86
- return __generator(this, function (_c) {
87
- switch (_c.label) {
88
- case 0:
89
- _c.trys.push([0, 2, , 3]);
90
- return [4 /*yield*/, Promise.all([
91
- (0, exports.getAccount)(address),
92
- getAllBalances(address, currency),
93
- getHeight(),
94
- getTransactions(address),
95
- getDelegations(address, currency),
96
- getRedelegations(address),
97
- getUnbondings(address),
98
- getWithdrawAddress(address),
99
- ])];
100
- case 1:
101
- _a = __read.apply(void 0, [_c.sent(), 8]), _b = _a[0], accountNumber = _b.accountNumber, sequence = _b.sequence, balances = _a[1], blockHeight = _a[2], txs = _a[3], delegations = _a[4], redelegations = _a[5], unbondings = _a[6], withdrawAddress = _a[7];
102
- return [2 /*return*/, {
103
- balances: balances,
104
- blockHeight: blockHeight,
105
- txs: txs,
106
- delegations: delegations,
107
- redelegations: redelegations,
108
- unbondings: unbondings,
109
- withdrawAddress: withdrawAddress,
110
- accountNumber: accountNumber,
111
- sequence: sequence
112
- }];
113
- case 2:
114
- e_1 = _c.sent();
115
- throw new Error("\"Error during cosmos synchronization: \"".concat(e_1.message));
116
- case 3: return [2 /*return*/];
117
- }
118
- });
119
- }); };
120
- exports.getAccountInfo = getAccountInfo;
121
- var getAccount = function (address) { return __awaiter(void 0, void 0, void 0, function () {
122
- var response, data, e_2;
123
- return __generator(this, function (_a) {
124
- switch (_a.label) {
125
- case 0:
126
- response = {
127
- address: address,
128
- accountNumber: 0,
129
- sequence: 0
130
- };
131
- _a.label = 1;
132
- case 1:
133
- _a.trys.push([1, 3, , 4]);
134
- return [4 /*yield*/, (0, network_1["default"])({
135
- method: "GET",
136
- url: "".concat(defaultEndpoint, "/cosmos/auth/v1beta1/accounts/").concat(address)
137
- })];
138
- case 2:
139
- data = (_a.sent()).data;
140
- if (data.account.address) {
141
- response.address = data.account.address;
84
+ var CosmosAPI = /** @class */ (function () {
85
+ function CosmosAPI() {
86
+ var _this = this;
87
+ this._defaultEndpoint = defaultEndpoint;
88
+ this._namespace = "cosmos";
89
+ this.getAccountInfo = function (address, currency) { return __awaiter(_this, void 0, void 0, function () {
90
+ var _a, _b, accountNumber, sequence, balances, blockHeight, txs, delegations, redelegations, unbondings, withdrawAddress, e_1;
91
+ return __generator(this, function (_c) {
92
+ switch (_c.label) {
93
+ case 0:
94
+ _c.trys.push([0, 2, , 3]);
95
+ return [4 /*yield*/, Promise.all([
96
+ this.getAccount(address),
97
+ this.getAllBalances(address, currency),
98
+ this.getHeight(),
99
+ this.getTransactions(address),
100
+ this.getDelegations(address, currency),
101
+ this.getRedelegations(address),
102
+ this.getUnbondings(address),
103
+ this.getWithdrawAddress(address),
104
+ ])];
105
+ case 1:
106
+ _a = __read.apply(void 0, [_c.sent(), 8]), _b = _a[0], accountNumber = _b.accountNumber, sequence = _b.sequence, balances = _a[1], blockHeight = _a[2], txs = _a[3], delegations = _a[4], redelegations = _a[5], unbondings = _a[6], withdrawAddress = _a[7];
107
+ return [2 /*return*/, {
108
+ balances: balances,
109
+ blockHeight: blockHeight,
110
+ txs: txs,
111
+ delegations: delegations,
112
+ redelegations: redelegations,
113
+ unbondings: unbondings,
114
+ withdrawAddress: withdrawAddress,
115
+ accountNumber: accountNumber,
116
+ sequence: sequence
117
+ }];
118
+ case 2:
119
+ e_1 = _c.sent();
120
+ throw new Error("\"Error during cosmos synchronization: \"".concat(e_1.message));
121
+ case 3: return [2 /*return*/];
142
122
  }
143
- if (data.account.account_number) {
144
- response.accountNumber = parseInt(data.account.account_number);
123
+ });
124
+ }); };
125
+ this.getAccount = function (address) { return __awaiter(_this, void 0, void 0, function () {
126
+ var response, data, e_2;
127
+ return __generator(this, function (_a) {
128
+ switch (_a.label) {
129
+ case 0:
130
+ response = {
131
+ address: address,
132
+ accountNumber: 0,
133
+ sequence: 0
134
+ };
135
+ _a.label = 1;
136
+ case 1:
137
+ _a.trys.push([1, 3, , 4]);
138
+ return [4 /*yield*/, (0, network_1["default"])({
139
+ method: "GET",
140
+ url: "".concat(this._defaultEndpoint, "/cosmos/auth/v1beta1/accounts/").concat(address)
141
+ })];
142
+ case 2:
143
+ data = (_a.sent()).data;
144
+ if (data.account.address) {
145
+ response.address = data.account.address;
146
+ }
147
+ if (data.account.account_number) {
148
+ response.accountNumber = parseInt(data.account.account_number);
149
+ }
150
+ if (data.account.sequence) {
151
+ response.sequence = parseInt(data.account.sequence);
152
+ }
153
+ return [3 /*break*/, 4];
154
+ case 3:
155
+ e_2 = _a.sent();
156
+ return [3 /*break*/, 4];
157
+ case 4: return [2 /*return*/, response];
145
158
  }
146
- if (data.account.sequence) {
147
- response.sequence = parseInt(data.account.sequence);
159
+ });
160
+ }); };
161
+ this.getChainId = function () { return __awaiter(_this, void 0, void 0, function () {
162
+ var data;
163
+ return __generator(this, function (_a) {
164
+ switch (_a.label) {
165
+ case 0: return [4 /*yield*/, (0, network_1["default"])({
166
+ method: "GET",
167
+ url: "".concat(this._defaultEndpoint, "/node_info")
168
+ })];
169
+ case 1:
170
+ data = (_a.sent()).data;
171
+ return [2 /*return*/, data.node_info.network];
148
172
  }
149
- return [3 /*break*/, 4];
150
- case 3:
151
- e_2 = _a.sent();
152
- return [3 /*break*/, 4];
153
- case 4: return [2 /*return*/, response];
154
- }
155
- });
156
- }); };
157
- exports.getAccount = getAccount;
158
- var getChainId = function () { return __awaiter(void 0, void 0, void 0, function () {
159
- var data;
160
- return __generator(this, function (_a) {
161
- switch (_a.label) {
162
- case 0: return [4 /*yield*/, (0, network_1["default"])({
163
- method: "GET",
164
- url: "".concat(defaultEndpoint, "/node_info")
165
- })];
166
- case 1:
167
- data = (_a.sent()).data;
168
- return [2 /*return*/, data.node_info.network];
169
- }
170
- });
171
- }); };
172
- exports.getChainId = getChainId;
173
- var getHeight = function () { return __awaiter(void 0, void 0, void 0, function () {
174
- var data;
175
- return __generator(this, function (_a) {
176
- switch (_a.label) {
177
- case 0: return [4 /*yield*/, (0, network_1["default"])({
178
- method: "GET",
179
- url: "".concat(defaultEndpoint, "/cosmos/base/tendermint/v1beta1/blocks/latest")
180
- })];
181
- case 1:
182
- data = (_a.sent()).data;
183
- return [2 /*return*/, data.block.header.height];
184
- }
185
- });
186
- }); };
187
- var getAllBalances = function (address, currency) { return __awaiter(void 0, void 0, void 0, function () {
188
- var data, amount, _a, _b, elem;
189
- var e_3, _c;
190
- return __generator(this, function (_d) {
191
- switch (_d.label) {
192
- case 0: return [4 /*yield*/, (0, network_1["default"])({
193
- method: "GET",
194
- url: "".concat(defaultEndpoint, "/cosmos/bank/v1beta1/balances/").concat(address)
195
- })];
196
- case 1:
197
- data = (_d.sent()).data;
198
- amount = new bignumber_js_1["default"](0);
199
- try {
200
- for (_a = __values(data.balances), _b = _a.next(); !_b.done; _b = _a.next()) {
201
- elem = _b.value;
202
- if (elem.denom === currency.units[1].code)
203
- amount = amount.plus(elem.amount);
204
- }
173
+ });
174
+ }); };
175
+ this.getHeight = function () { return __awaiter(_this, void 0, void 0, function () {
176
+ var data;
177
+ return __generator(this, function (_a) {
178
+ switch (_a.label) {
179
+ case 0: return [4 /*yield*/, (0, network_1["default"])({
180
+ method: "GET",
181
+ url: "".concat(this._defaultEndpoint, "/cosmos/base/tendermint/v1beta1/blocks/latest")
182
+ })];
183
+ case 1:
184
+ data = (_a.sent()).data;
185
+ return [2 /*return*/, data.block.header.height];
205
186
  }
206
- catch (e_3_1) { e_3 = { error: e_3_1 }; }
207
- finally {
208
- try {
209
- if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
210
- }
211
- finally { if (e_3) throw e_3.error; }
212
- }
213
- return [2 /*return*/, amount];
214
- }
215
- });
216
- }); };
217
- var getDelegations = function (address, currency) { return __awaiter(void 0, void 0, void 0, function () {
218
- var delegations, data1, status, statusMap, _a, _b, d, data2, e_4_1, data3, _c, _d, r, delegations_1, delegations_1_1, d, _e, _f, reward;
219
- var e_4, _g, e_5, _h, e_6, _j, e_7, _k;
220
- return __generator(this, function (_l) {
221
- switch (_l.label) {
222
- case 0:
223
- delegations = [];
224
- return [4 /*yield*/, (0, network_1["default"])({
225
- method: "GET",
226
- url: "".concat(defaultEndpoint, "/cosmos/staking/v1beta1/delegations/").concat(address)
227
- })];
228
- case 1:
229
- data1 = (_l.sent()).data;
230
- data1.delegation_responses = data1.delegation_responses.filter(function (d) { return d.balance.amount !== "0"; });
231
- status = "unbonded";
232
- statusMap = {
233
- BOND_STATUS_UNBONDED: "unbonded",
234
- BOND_STATUS_UNBONDING: "unbonding",
235
- BOND_STATUS_BONDED: "bonded"
236
- };
237
- _l.label = 2;
238
- case 2:
239
- _l.trys.push([2, 7, 8, 9]);
240
- _a = __values(data1.delegation_responses), _b = _a.next();
241
- _l.label = 3;
242
- case 3:
243
- if (!!_b.done) return [3 /*break*/, 6];
244
- d = _b.value;
245
- return [4 /*yield*/, (0, network_1["default"])({
246
- method: "GET",
247
- url: "".concat(defaultEndpoint, "/cosmos/staking/v1beta1/validators/").concat(d.delegation.validator_address)
248
- })];
249
- case 4:
250
- data2 = (_l.sent()).data;
251
- status = statusMap[data2.validator.status] || "unbonded";
252
- delegations.push({
253
- validatorAddress: d.delegation.validator_address,
254
- amount: d.balance.denom === currency.units[1].code
255
- ? new bignumber_js_1["default"](d.balance.amount)
256
- : new bignumber_js_1["default"](0),
257
- pendingRewards: new bignumber_js_1["default"](0),
258
- status: status
259
- });
260
- _l.label = 5;
261
- case 5:
262
- _b = _a.next();
263
- return [3 /*break*/, 3];
264
- case 6: return [3 /*break*/, 9];
265
- case 7:
266
- e_4_1 = _l.sent();
267
- e_4 = { error: e_4_1 };
268
- return [3 /*break*/, 9];
269
- case 8:
270
- try {
271
- if (_b && !_b.done && (_g = _a["return"])) _g.call(_a);
187
+ });
188
+ }); };
189
+ this.getAllBalances = function (address, currency) { return __awaiter(_this, void 0, void 0, function () {
190
+ var data, amount, _a, _b, elem;
191
+ var e_3, _c;
192
+ return __generator(this, function (_d) {
193
+ switch (_d.label) {
194
+ case 0: return [4 /*yield*/, (0, network_1["default"])({
195
+ method: "GET",
196
+ url: "".concat(this._defaultEndpoint, "/cosmos/bank/v1beta1/balances/").concat(address)
197
+ })];
198
+ case 1:
199
+ data = (_d.sent()).data;
200
+ amount = new bignumber_js_1["default"](0);
201
+ try {
202
+ for (_a = __values(data.balances), _b = _a.next(); !_b.done; _b = _a.next()) {
203
+ elem = _b.value;
204
+ if (elem.denom === currency.units[1].code)
205
+ amount = amount.plus(elem.amount);
206
+ }
207
+ }
208
+ catch (e_3_1) { e_3 = { error: e_3_1 }; }
209
+ finally {
210
+ try {
211
+ if (_b && !_b.done && (_c = _a["return"])) _c.call(_a);
212
+ }
213
+ finally { if (e_3) throw e_3.error; }
214
+ }
215
+ return [2 /*return*/, amount];
272
216
  }
273
- finally { if (e_4) throw e_4.error; }
274
- return [7 /*endfinally*/];
275
- case 9: return [4 /*yield*/, (0, network_1["default"])({
276
- method: "GET",
277
- url: "".concat(defaultEndpoint, "/cosmos/distribution/v1beta1/delegators/").concat(address, "/rewards")
278
- })];
279
- case 10:
280
- data3 = (_l.sent()).data;
281
- try {
282
- for (_c = __values(data3.rewards), _d = _c.next(); !_d.done; _d = _c.next()) {
283
- r = _d.value;
217
+ });
218
+ }); };
219
+ this.getDelegations = function (address, currency) { return __awaiter(_this, void 0, void 0, function () {
220
+ var delegations, data1, status, statusMap, _a, _b, d, data2, e_4_1, data3, _c, _d, r, delegations_1, delegations_1_1, d, _e, _f, reward;
221
+ var e_4, _g, e_5, _h, e_6, _j, e_7, _k;
222
+ return __generator(this, function (_l) {
223
+ switch (_l.label) {
224
+ case 0:
225
+ delegations = [];
226
+ return [4 /*yield*/, (0, network_1["default"])({
227
+ method: "GET",
228
+ url: "".concat(this._defaultEndpoint, "/cosmos/staking/v1beta1/delegations/").concat(address)
229
+ })];
230
+ case 1:
231
+ data1 = (_l.sent()).data;
232
+ data1.delegation_responses = data1.delegation_responses.filter(function (d) { return d.balance.amount !== "0"; });
233
+ status = "unbonded";
234
+ statusMap = {
235
+ BOND_STATUS_UNBONDED: "unbonded",
236
+ BOND_STATUS_UNBONDING: "unbonding",
237
+ BOND_STATUS_BONDED: "bonded"
238
+ };
239
+ _l.label = 2;
240
+ case 2:
241
+ _l.trys.push([2, 7, 8, 9]);
242
+ _a = __values(data1.delegation_responses), _b = _a.next();
243
+ _l.label = 3;
244
+ case 3:
245
+ if (!!_b.done) return [3 /*break*/, 6];
246
+ d = _b.value;
247
+ return [4 /*yield*/, (0, network_1["default"])({
248
+ method: "GET",
249
+ url: "".concat(this._defaultEndpoint, "/cosmos/staking/v1beta1/validators/").concat(d.delegation.validator_address)
250
+ })];
251
+ case 4:
252
+ data2 = (_l.sent()).data;
253
+ status = statusMap[data2.validator.status] || "unbonded";
254
+ delegations.push({
255
+ validatorAddress: d.delegation.validator_address,
256
+ amount: d.balance.denom === currency.units[1].code
257
+ ? new bignumber_js_1["default"](d.balance.amount)
258
+ : new bignumber_js_1["default"](0),
259
+ pendingRewards: new bignumber_js_1["default"](0),
260
+ status: status
261
+ });
262
+ _l.label = 5;
263
+ case 5:
264
+ _b = _a.next();
265
+ return [3 /*break*/, 3];
266
+ case 6: return [3 /*break*/, 9];
267
+ case 7:
268
+ e_4_1 = _l.sent();
269
+ e_4 = { error: e_4_1 };
270
+ return [3 /*break*/, 9];
271
+ case 8:
284
272
  try {
285
- for (delegations_1 = (e_6 = void 0, __values(delegations)), delegations_1_1 = delegations_1.next(); !delegations_1_1.done; delegations_1_1 = delegations_1.next()) {
286
- d = delegations_1_1.value;
287
- if (r.validator_address === d.validatorAddress) {
288
- try {
289
- for (_e = (e_7 = void 0, __values(r.reward)), _f = _e.next(); !_f.done; _f = _e.next()) {
290
- reward = _f.value;
291
- d.pendingRewards = d.pendingRewards.plus(new bignumber_js_1["default"](reward.amount).integerValue());
273
+ if (_b && !_b.done && (_g = _a["return"])) _g.call(_a);
274
+ }
275
+ finally { if (e_4) throw e_4.error; }
276
+ return [7 /*endfinally*/];
277
+ case 9: return [4 /*yield*/, (0, network_1["default"])({
278
+ method: "GET",
279
+ url: "".concat(this._defaultEndpoint, "/cosmos/distribution/v1beta1/delegators/").concat(address, "/rewards")
280
+ })];
281
+ case 10:
282
+ data3 = (_l.sent()).data;
283
+ try {
284
+ for (_c = __values(data3.rewards), _d = _c.next(); !_d.done; _d = _c.next()) {
285
+ r = _d.value;
286
+ try {
287
+ for (delegations_1 = (e_6 = void 0, __values(delegations)), delegations_1_1 = delegations_1.next(); !delegations_1_1.done; delegations_1_1 = delegations_1.next()) {
288
+ d = delegations_1_1.value;
289
+ if (r.validator_address === d.validatorAddress) {
290
+ try {
291
+ for (_e = (e_7 = void 0, __values(r.reward)), _f = _e.next(); !_f.done; _f = _e.next()) {
292
+ reward = _f.value;
293
+ d.pendingRewards = d.pendingRewards.plus(new bignumber_js_1["default"](reward.amount).integerValue());
294
+ }
295
+ }
296
+ catch (e_7_1) { e_7 = { error: e_7_1 }; }
297
+ finally {
298
+ try {
299
+ if (_f && !_f.done && (_k = _e["return"])) _k.call(_e);
300
+ }
301
+ finally { if (e_7) throw e_7.error; }
302
+ }
292
303
  }
293
304
  }
294
- catch (e_7_1) { e_7 = { error: e_7_1 }; }
295
- finally {
296
- try {
297
- if (_f && !_f.done && (_k = _e["return"])) _k.call(_e);
298
- }
299
- finally { if (e_7) throw e_7.error; }
305
+ }
306
+ catch (e_6_1) { e_6 = { error: e_6_1 }; }
307
+ finally {
308
+ try {
309
+ if (delegations_1_1 && !delegations_1_1.done && (_j = delegations_1["return"])) _j.call(delegations_1);
300
310
  }
311
+ finally { if (e_6) throw e_6.error; }
301
312
  }
302
313
  }
303
314
  }
304
- catch (e_6_1) { e_6 = { error: e_6_1 }; }
315
+ catch (e_5_1) { e_5 = { error: e_5_1 }; }
305
316
  finally {
306
317
  try {
307
- if (delegations_1_1 && !delegations_1_1.done && (_j = delegations_1["return"])) _j.call(delegations_1);
318
+ if (_d && !_d.done && (_h = _c["return"])) _h.call(_c);
308
319
  }
309
- finally { if (e_6) throw e_6.error; }
320
+ finally { if (e_5) throw e_5.error; }
310
321
  }
311
- }
312
- }
313
- catch (e_5_1) { e_5 = { error: e_5_1 }; }
314
- finally {
315
- try {
316
- if (_d && !_d.done && (_h = _c["return"])) _h.call(_c);
317
- }
318
- finally { if (e_5) throw e_5.error; }
322
+ return [2 /*return*/, delegations];
319
323
  }
320
- return [2 /*return*/, delegations];
321
- }
322
- });
323
- }); };
324
- var getRedelegations = function (address) { return __awaiter(void 0, void 0, void 0, function () {
325
- var redelegations, data, _a, _b, r, _c, _d, entry;
326
- var e_8, _e, e_9, _f;
327
- return __generator(this, function (_g) {
328
- switch (_g.label) {
329
- case 0:
330
- redelegations = [];
331
- return [4 /*yield*/, (0, network_1["default"])({
332
- method: "GET",
333
- url: "".concat(defaultEndpoint, "/cosmos/staking/v1beta1/delegators/").concat(address, "/redelegations")
334
- })];
335
- case 1:
336
- data = (_g.sent()).data;
337
- try {
338
- for (_a = __values(data.redelegation_responses), _b = _a.next(); !_b.done; _b = _a.next()) {
339
- r = _b.value;
324
+ });
325
+ }); };
326
+ this.getRedelegations = function (address) { return __awaiter(_this, void 0, void 0, function () {
327
+ var redelegations, data, _a, _b, r, _c, _d, entry;
328
+ var e_8, _e, e_9, _f;
329
+ return __generator(this, function (_g) {
330
+ switch (_g.label) {
331
+ case 0:
332
+ redelegations = [];
333
+ return [4 /*yield*/, (0, network_1["default"])({
334
+ method: "GET",
335
+ url: "".concat(this._defaultEndpoint, "/cosmos/staking/v1beta1/delegators/").concat(address, "/redelegations")
336
+ })];
337
+ case 1:
338
+ data = (_g.sent()).data;
340
339
  try {
341
- for (_c = (e_9 = void 0, __values(r.entries)), _d = _c.next(); !_d.done; _d = _c.next()) {
342
- entry = _d.value;
343
- redelegations.push({
344
- validatorSrcAddress: r.redelegation.validator_src_address,
345
- validatorDstAddress: r.redelegation.validator_dst_address,
346
- amount: new bignumber_js_1["default"](entry.redelegation_entry.initial_balance),
347
- completionDate: new Date(entry.redelegation_entry.completion_time)
348
- });
340
+ for (_a = __values(data.redelegation_responses), _b = _a.next(); !_b.done; _b = _a.next()) {
341
+ r = _b.value;
342
+ try {
343
+ for (_c = (e_9 = void 0, __values(r.entries)), _d = _c.next(); !_d.done; _d = _c.next()) {
344
+ entry = _d.value;
345
+ redelegations.push({
346
+ validatorSrcAddress: r.redelegation.validator_src_address,
347
+ validatorDstAddress: r.redelegation.validator_dst_address,
348
+ amount: new bignumber_js_1["default"](entry.redelegation_entry.initial_balance),
349
+ completionDate: new Date(entry.redelegation_entry.completion_time)
350
+ });
351
+ }
352
+ }
353
+ catch (e_9_1) { e_9 = { error: e_9_1 }; }
354
+ finally {
355
+ try {
356
+ if (_d && !_d.done && (_f = _c["return"])) _f.call(_c);
357
+ }
358
+ finally { if (e_9) throw e_9.error; }
359
+ }
349
360
  }
350
361
  }
351
- catch (e_9_1) { e_9 = { error: e_9_1 }; }
362
+ catch (e_8_1) { e_8 = { error: e_8_1 }; }
352
363
  finally {
353
364
  try {
354
- if (_d && !_d.done && (_f = _c["return"])) _f.call(_c);
365
+ if (_b && !_b.done && (_e = _a["return"])) _e.call(_a);
355
366
  }
356
- finally { if (e_9) throw e_9.error; }
367
+ finally { if (e_8) throw e_8.error; }
357
368
  }
358
- }
359
- }
360
- catch (e_8_1) { e_8 = { error: e_8_1 }; }
361
- finally {
362
- try {
363
- if (_b && !_b.done && (_e = _a["return"])) _e.call(_a);
364
- }
365
- finally { if (e_8) throw e_8.error; }
369
+ return [2 /*return*/, redelegations];
366
370
  }
367
- return [2 /*return*/, redelegations];
368
- }
369
- });
370
- }); };
371
- var getUnbondings = function (address) { return __awaiter(void 0, void 0, void 0, function () {
372
- var unbondings, data, _a, _b, u, _c, _d, entry;
373
- var e_10, _e, e_11, _f;
374
- return __generator(this, function (_g) {
375
- switch (_g.label) {
376
- case 0:
377
- unbondings = [];
378
- return [4 /*yield*/, (0, network_1["default"])({
379
- method: "GET",
380
- url: "".concat(defaultEndpoint, "/cosmos/staking/v1beta1/delegators/").concat(address, "/unbonding_delegations")
381
- })];
382
- case 1:
383
- data = (_g.sent()).data;
384
- try {
385
- for (_a = __values(data.unbonding_responses), _b = _a.next(); !_b.done; _b = _a.next()) {
386
- u = _b.value;
371
+ });
372
+ }); };
373
+ this.getUnbondings = function (address) { return __awaiter(_this, void 0, void 0, function () {
374
+ var unbondings, data, _a, _b, u, _c, _d, entry;
375
+ var e_10, _e, e_11, _f;
376
+ return __generator(this, function (_g) {
377
+ switch (_g.label) {
378
+ case 0:
379
+ unbondings = [];
380
+ return [4 /*yield*/, (0, network_1["default"])({
381
+ method: "GET",
382
+ url: "".concat(this._defaultEndpoint, "/cosmos/staking/v1beta1/delegators/").concat(address, "/unbonding_delegations")
383
+ })];
384
+ case 1:
385
+ data = (_g.sent()).data;
387
386
  try {
388
- for (_c = (e_11 = void 0, __values(u.entries)), _d = _c.next(); !_d.done; _d = _c.next()) {
389
- entry = _d.value;
390
- unbondings.push({
391
- validatorAddress: u.validator_address,
392
- amount: new bignumber_js_1["default"](entry.initial_balance),
393
- completionDate: new Date(entry.completion_time)
394
- });
387
+ for (_a = __values(data.unbonding_responses), _b = _a.next(); !_b.done; _b = _a.next()) {
388
+ u = _b.value;
389
+ try {
390
+ for (_c = (e_11 = void 0, __values(u.entries)), _d = _c.next(); !_d.done; _d = _c.next()) {
391
+ entry = _d.value;
392
+ unbondings.push({
393
+ validatorAddress: u.validator_address,
394
+ amount: new bignumber_js_1["default"](entry.initial_balance),
395
+ completionDate: new Date(entry.completion_time)
396
+ });
397
+ }
398
+ }
399
+ catch (e_11_1) { e_11 = { error: e_11_1 }; }
400
+ finally {
401
+ try {
402
+ if (_d && !_d.done && (_f = _c["return"])) _f.call(_c);
403
+ }
404
+ finally { if (e_11) throw e_11.error; }
405
+ }
395
406
  }
396
407
  }
397
- catch (e_11_1) { e_11 = { error: e_11_1 }; }
408
+ catch (e_10_1) { e_10 = { error: e_10_1 }; }
398
409
  finally {
399
410
  try {
400
- if (_d && !_d.done && (_f = _c["return"])) _f.call(_c);
411
+ if (_b && !_b.done && (_e = _a["return"])) _e.call(_a);
401
412
  }
402
- finally { if (e_11) throw e_11.error; }
413
+ finally { if (e_10) throw e_10.error; }
403
414
  }
404
- }
415
+ return [2 /*return*/, unbondings];
405
416
  }
406
- catch (e_10_1) { e_10 = { error: e_10_1 }; }
407
- finally {
408
- try {
409
- if (_b && !_b.done && (_e = _a["return"])) _e.call(_a);
410
- }
411
- finally { if (e_10) throw e_10.error; }
417
+ });
418
+ }); };
419
+ this.getWithdrawAddress = function (address) { return __awaiter(_this, void 0, void 0, function () {
420
+ var data;
421
+ return __generator(this, function (_a) {
422
+ switch (_a.label) {
423
+ case 0: return [4 /*yield*/, (0, network_1["default"])({
424
+ method: "GET",
425
+ url: "".concat(this._defaultEndpoint, "/cosmos/distribution/v1beta1/delegators/").concat(address, "/withdraw_address")
426
+ })];
427
+ case 1:
428
+ data = (_a.sent()).data;
429
+ return [2 /*return*/, data.withdraw_address];
412
430
  }
413
- return [2 /*return*/, unbondings];
414
- }
415
- });
416
- }); };
417
- var getWithdrawAddress = function (address) { return __awaiter(void 0, void 0, void 0, function () {
418
- var data;
419
- return __generator(this, function (_a) {
420
- switch (_a.label) {
421
- case 0: return [4 /*yield*/, (0, network_1["default"])({
422
- method: "GET",
423
- url: "".concat(defaultEndpoint, "/cosmos/distribution/v1beta1/delegators/").concat(address, "/withdraw_address")
424
- })];
425
- case 1:
426
- data = (_a.sent()).data;
427
- return [2 /*return*/, data.withdraw_address];
428
- }
429
- });
430
- }); };
431
- var getTransactions = function (address) { return __awaiter(void 0, void 0, void 0, function () {
432
- var receive, send;
433
- return __generator(this, function (_a) {
434
- switch (_a.label) {
435
- case 0: return [4 /*yield*/, (0, network_1["default"])({
436
- method: "GET",
437
- url: "".concat(defaultEndpoint, "/cosmos/tx/v1beta1/txs?events=") +
438
- encodeURI("transfer.recipient='".concat(address, "'"))
439
- })];
440
- case 1:
441
- receive = _a.sent();
442
- return [4 /*yield*/, (0, network_1["default"])({
443
- method: "GET",
444
- url: "".concat(defaultEndpoint, "/cosmos/tx/v1beta1/txs?events=") +
445
- encodeURI("message.sender='".concat(address, "'"))
446
- })];
447
- case 2:
448
- send = _a.sent();
449
- return [2 /*return*/, __spreadArray(__spreadArray([], __read(receive.data.tx_responses), false), __read(send.data.tx_responses), false)];
450
- }
451
- });
452
- }); };
453
- var isValidRecipent = function (address) { return __awaiter(void 0, void 0, void 0, function () {
454
- var e_12;
455
- return __generator(this, function (_a) {
456
- switch (_a.label) {
457
- case 0:
458
- _a.trys.push([0, 2, , 3]);
459
- return [4 /*yield*/, (0, network_1["default"])({
460
- method: "GET",
461
- url: "".concat(defaultEndpoint, "/cosmos/bank/v1beta1/balances/").concat(address)
462
- })];
463
- case 1:
464
- _a.sent();
465
- return [2 /*return*/, true];
466
- case 2:
467
- e_12 = _a.sent();
468
- return [2 /*return*/, false];
469
- case 3: return [2 /*return*/];
470
- }
471
- });
472
- }); };
473
- exports.isValidRecipent = isValidRecipent;
474
- var simulate = function (tx_bytes) { return __awaiter(void 0, void 0, void 0, function () {
475
- var data, e_13;
476
- var _a;
477
- return __generator(this, function (_b) {
478
- switch (_b.label) {
479
- case 0:
480
- _b.trys.push([0, 2, , 3]);
481
- return [4 /*yield*/, (0, network_1["default"])({
482
- method: "POST",
483
- url: "".concat(defaultEndpoint, "/cosmos/tx/v1beta1/simulate"),
484
- data: {
485
- tx_bytes: tx_bytes
431
+ });
432
+ }); };
433
+ this.getTransactions = function (address) { return __awaiter(_this, void 0, void 0, function () {
434
+ var receive, send;
435
+ return __generator(this, function (_a) {
436
+ switch (_a.label) {
437
+ case 0:
438
+ if (this._namespace === "osmosis") {
439
+ return [2 /*return*/, []];
486
440
  }
487
- })];
488
- case 1:
489
- data = (_b.sent()).data;
490
- return [2 /*return*/, new bignumber_js_1["default"](((_a = data === null || data === void 0 ? void 0 : data.gas_info) === null || _a === void 0 ? void 0 : _a.gas_used) || 0)];
491
- case 2:
492
- e_13 = _b.sent();
493
- return [2 /*return*/, new bignumber_js_1["default"](0)];
494
- case 3: return [2 /*return*/];
495
- }
496
- });
497
- }); };
498
- exports.simulate = simulate;
499
- var broadcast = function (_a) {
500
- var _b = _a.signedOperation, operation = _b.operation, signature = _b.signature;
501
- return __awaiter(void 0, void 0, void 0, function () {
502
- var data;
503
- return __generator(this, function (_c) {
504
- switch (_c.label) {
505
- case 0: return [4 /*yield*/, (0, network_1["default"])({
506
- method: "POST",
507
- url: "".concat(defaultEndpoint, "/cosmos/tx/v1beta1/txs"),
508
- data: {
509
- tx_bytes: Array.from(Uint8Array.from(Buffer.from(signature, "hex"))),
510
- mode: "BROADCAST_MODE_SYNC"
511
- }
512
- })];
513
- case 1:
514
- data = (_c.sent()).data;
515
- if (data.tx_response.code != 0) {
516
- // error codes: https://github.com/cosmos/cosmos-sdk/blob/master/types/errors/errors.go
517
- throw new Error("invalid broadcast return (code: " +
518
- (data.tx_response.code || "?") +
519
- ", message: '" +
520
- (data.tx_response.raw_log || "") +
521
- "')");
441
+ return [4 /*yield*/, (0, network_1["default"])({
442
+ method: "GET",
443
+ url: "".concat(this._defaultEndpoint, "/cosmos/tx/v1beta1/txs?events=") +
444
+ encodeURI("transfer.recipient='".concat(address, "'"))
445
+ })];
446
+ case 1:
447
+ receive = _a.sent();
448
+ return [4 /*yield*/, (0, network_1["default"])({
449
+ method: "GET",
450
+ url: "".concat(this._defaultEndpoint, "/cosmos/tx/v1beta1/txs?events=") +
451
+ encodeURI("message.sender='".concat(address, "'"))
452
+ })];
453
+ case 2:
454
+ send = _a.sent();
455
+ return [2 /*return*/, __spreadArray(__spreadArray([], __read(receive.data.tx_responses), false), __read(send.data.tx_responses), false)];
456
+ }
457
+ });
458
+ }); };
459
+ this.isValidRecipent = function (address) { return __awaiter(_this, void 0, void 0, function () {
460
+ var e_12;
461
+ return __generator(this, function (_a) {
462
+ switch (_a.label) {
463
+ case 0:
464
+ _a.trys.push([0, 2, , 3]);
465
+ return [4 /*yield*/, (0, network_1["default"])({
466
+ method: "GET",
467
+ url: "".concat(this._defaultEndpoint, "/cosmos/bank/v1beta1/balances/").concat(address)
468
+ })];
469
+ case 1:
470
+ _a.sent();
471
+ return [2 /*return*/, true];
472
+ case 2:
473
+ e_12 = _a.sent();
474
+ return [2 /*return*/, false];
475
+ case 3: return [2 /*return*/];
476
+ }
477
+ });
478
+ }); };
479
+ this.simulate = function (tx_bytes) { return __awaiter(_this, void 0, void 0, function () {
480
+ var data, e_13;
481
+ var _a;
482
+ return __generator(this, function (_b) {
483
+ switch (_b.label) {
484
+ case 0:
485
+ _b.trys.push([0, 2, , 3]);
486
+ return [4 /*yield*/, (0, network_1["default"])({
487
+ method: "POST",
488
+ url: "".concat(this._defaultEndpoint, "/cosmos/tx/v1beta1/simulate"),
489
+ data: {
490
+ tx_bytes: tx_bytes
491
+ }
492
+ })];
493
+ case 1:
494
+ data = (_b.sent()).data;
495
+ return [2 /*return*/, new bignumber_js_1["default"](((_a = data === null || data === void 0 ? void 0 : data.gas_info) === null || _a === void 0 ? void 0 : _a.gas_used) || 0)];
496
+ case 2:
497
+ e_13 = _b.sent();
498
+ return [2 /*return*/, new bignumber_js_1["default"](0)];
499
+ case 3: return [2 /*return*/];
500
+ }
501
+ });
502
+ }); };
503
+ this.broadcast = function (_a) {
504
+ var _b = _a.signedOperation, operation = _b.operation, signature = _b.signature;
505
+ return __awaiter(_this, void 0, void 0, function () {
506
+ var data;
507
+ return __generator(this, function (_c) {
508
+ switch (_c.label) {
509
+ case 0: return [4 /*yield*/, (0, network_1["default"])({
510
+ method: "POST",
511
+ url: "".concat(this._defaultEndpoint, "/cosmos/tx/v1beta1/txs"),
512
+ data: {
513
+ tx_bytes: Array.from(Uint8Array.from(Buffer.from(signature, "hex"))),
514
+ mode: "BROADCAST_MODE_SYNC"
515
+ }
516
+ })];
517
+ case 1:
518
+ data = (_c.sent()).data;
519
+ if (data.tx_response.code != 0) {
520
+ // error codes: https://github.com/cosmos/cosmos-sdk/blob/master/types/errors/errors.go
521
+ throw new Error("invalid broadcast return (code: " +
522
+ (data.tx_response.code || "?") +
523
+ ", message: '" +
524
+ (data.tx_response.raw_log || "") +
525
+ "')");
526
+ }
527
+ return [2 /*return*/, (0, operation_1.patchOperationWithHash)(operation, data.tx_response.txhash)];
522
528
  }
523
- return [2 /*return*/, (0, operation_1.patchOperationWithHash)(operation, data.tx_response.txhash)];
524
- }
525
- });
526
- });
527
- };
528
- exports.broadcast = broadcast;
529
+ });
530
+ });
531
+ };
532
+ }
533
+ return CosmosAPI;
534
+ }());
535
+ exports.CosmosAPI = CosmosAPI;
536
+ exports.defaultCosmosAPI = new CosmosAPI();
529
537
  //# sourceMappingURL=Cosmos.js.map