@airgap/cosmos 0.13.11-beta.1 → 0.13.11-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/index.d.ts +1 -0
  2. package/index.js +18 -0
  3. package/index.js.map +1 -0
  4. package/package.json +1 -5
  5. package/v0/index.d.ts +10 -0
  6. package/v0/index.js +32 -0
  7. package/v0/index.js.map +1 -0
  8. package/v0/protocol/CosmosAddress.d.ts +8 -0
  9. package/v0/protocol/CosmosAddress.js +28 -0
  10. package/v0/protocol/CosmosAddress.js.map +1 -0
  11. package/v0/protocol/CosmosCoin.d.ts +19 -0
  12. package/v0/protocol/CosmosCoin.js +55 -0
  13. package/v0/protocol/CosmosCoin.js.map +1 -0
  14. package/v0/protocol/CosmosCryptoClient.d.ts +8 -0
  15. package/v0/protocol/CosmosCryptoClient.js +90 -0
  16. package/v0/protocol/CosmosCryptoClient.js.map +1 -0
  17. package/v0/protocol/CosmosFee.d.ts +15 -0
  18. package/v0/protocol/CosmosFee.js +31 -0
  19. package/v0/protocol/CosmosFee.js.map +1 -0
  20. package/v0/protocol/CosmosNodeClient.d.ts +25 -0
  21. package/v0/protocol/CosmosNodeClient.js +382 -0
  22. package/v0/protocol/CosmosNodeClient.js.map +1 -0
  23. package/v0/protocol/CosmosProtocol.d.ts +124 -0
  24. package/v0/protocol/CosmosProtocol.js +1155 -0
  25. package/v0/protocol/CosmosProtocol.js.map +1 -0
  26. package/v0/protocol/CosmosProtocolOptions.d.ts +22 -0
  27. package/v0/protocol/CosmosProtocolOptions.js +116 -0
  28. package/v0/protocol/CosmosProtocolOptions.js.map +1 -0
  29. package/v0/protocol/CosmosTransaction.d.ts +37 -0
  30. package/v0/protocol/CosmosTransaction.js +106 -0
  31. package/v0/protocol/CosmosTransaction.js.map +1 -0
  32. package/v0/protocol/CosmosTypes.d.ts +310 -0
  33. package/v0/protocol/CosmosTypes.js +8 -0
  34. package/v0/protocol/CosmosTypes.js.map +1 -0
  35. package/v0/protocol/cosmos-message/CosmosDelegateMessage.d.ts +20 -0
  36. package/v0/protocol/cosmos-message/CosmosDelegateMessage.js +72 -0
  37. package/v0/protocol/cosmos-message/CosmosDelegateMessage.js.map +1 -0
  38. package/v0/protocol/cosmos-message/CosmosMessage.d.ts +39 -0
  39. package/v0/protocol/cosmos-message/CosmosMessage.js +47 -0
  40. package/v0/protocol/cosmos-message/CosmosMessage.js.map +1 -0
  41. package/v0/protocol/cosmos-message/CosmosSendMessage.d.ts +20 -0
  42. package/v0/protocol/cosmos-message/CosmosSendMessage.js +85 -0
  43. package/v0/protocol/cosmos-message/CosmosSendMessage.js.map +1 -0
  44. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +24 -0
  45. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +61 -0
  46. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
  47. package/v0/serializer/schemas/v2/transaction-sign-request-cosmos.json +100 -0
  48. package/v0/serializer/schemas/v2/transaction-sign-response-cosmos.json +22 -0
  49. package/v0/serializer/schemas/v3/transaction-sign-request-cosmos.json +100 -0
  50. package/v0/serializer/schemas/v3/transaction-sign-response-cosmos.json +23 -0
  51. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  52. package/v0/serializer/validators/transaction-validator.js +112 -0
  53. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  54. package/v0/types/signed-transaction-cosmos.d.ts +5 -0
  55. package/v0/types/signed-transaction-cosmos.js +3 -0
  56. package/v0/types/signed-transaction-cosmos.js.map +1 -0
  57. package/v0/types/transaction-cosmos.d.ts +5 -0
  58. package/v0/types/transaction-cosmos.js +3 -0
  59. package/v0/types/transaction-cosmos.js.map +1 -0
  60. package/v0/types/unsigned-transaction-cosmos.d.ts +33 -0
  61. package/v0/types/unsigned-transaction-cosmos.js +10 -0
  62. package/v0/types/unsigned-transaction-cosmos.js.map +1 -0
  63. package/v1/block-explorer/MintscanBlockExplorer.d.ts +9 -0
  64. package/v1/block-explorer/MintscanBlockExplorer.js +74 -0
  65. package/v1/block-explorer/MintscanBlockExplorer.js.map +1 -0
  66. package/v1/data/CosmosAddress.d.ts +7 -0
  67. package/v1/data/CosmosAddress.js +29 -0
  68. package/v1/data/CosmosAddress.js.map +1 -0
  69. package/v1/data/CosmosCoin.d.ts +19 -0
  70. package/v1/data/CosmosCoin.js +55 -0
  71. package/v1/data/CosmosCoin.js.map +1 -0
  72. package/v1/data/CosmosFee.d.ts +15 -0
  73. package/v1/data/CosmosFee.js +31 -0
  74. package/v1/data/CosmosFee.js.map +1 -0
  75. package/v1/data/transaction/CosmosTransaction.d.ts +36 -0
  76. package/v1/data/transaction/CosmosTransaction.js +109 -0
  77. package/v1/data/transaction/CosmosTransaction.js.map +1 -0
  78. package/v1/data/transaction/message/CosmosDelegateMessage.d.ts +19 -0
  79. package/v1/data/transaction/message/CosmosDelegateMessage.js +70 -0
  80. package/v1/data/transaction/message/CosmosDelegateMessage.js.map +1 -0
  81. package/v1/data/transaction/message/CosmosMessage.d.ts +38 -0
  82. package/v1/data/transaction/message/CosmosMessage.js +47 -0
  83. package/v1/data/transaction/message/CosmosMessage.js.map +1 -0
  84. package/v1/data/transaction/message/CosmosSendMessage.d.ts +19 -0
  85. package/v1/data/transaction/message/CosmosSendMessage.js +83 -0
  86. package/v1/data/transaction/message/CosmosSendMessage.js.map +1 -0
  87. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.d.ts +23 -0
  88. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js +61 -0
  89. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
  90. package/v1/index.d.ts +10 -0
  91. package/v1/index.js +11 -0
  92. package/v1/index.js.map +1 -0
  93. package/v1/module/CosmosModule.d.ts +15 -0
  94. package/v1/module/CosmosModule.js +107 -0
  95. package/v1/module/CosmosModule.js.map +1 -0
  96. package/v1/module.d.ts +3 -0
  97. package/v1/module.js +24 -0
  98. package/v1/module.js.map +1 -0
  99. package/v1/node/CosmosNodeClient.d.ts +28 -0
  100. package/v1/node/CosmosNodeClient.js +381 -0
  101. package/v1/node/CosmosNodeClient.js.map +1 -0
  102. package/v1/protocol/CosmosCryptoClient.d.ts +8 -0
  103. package/v1/protocol/CosmosCryptoClient.js +90 -0
  104. package/v1/protocol/CosmosCryptoClient.js.map +1 -0
  105. package/v1/protocol/CosmosProtocol.d.ts +53 -0
  106. package/v1/protocol/CosmosProtocol.js +651 -0
  107. package/v1/protocol/CosmosProtocol.js.map +1 -0
  108. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
  109. package/v1/serializer/v3/schemas/converter/transaction-converter.js +37 -0
  110. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  111. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.d.ts +4 -0
  112. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js +3 -0
  113. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js.map +1 -0
  114. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.d.ts +3 -0
  115. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js +3 -0
  116. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js.map +1 -0
  117. package/v1/serializer/v3/schemas/generated/transaction-sign-request-cosmos.json +100 -0
  118. package/v1/serializer/v3/schemas/generated/transaction-sign-response-cosmos.json +19 -0
  119. package/v1/serializer/v3/serializer-companion.d.ts +12 -0
  120. package/v1/serializer/v3/serializer-companion.js +142 -0
  121. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  122. package/v1/serializer/v3/validators/transaction-validators.d.ts +7 -0
  123. package/v1/serializer/v3/validators/transaction-validators.js +88 -0
  124. package/v1/serializer/v3/validators/transaction-validators.js.map +1 -0
  125. package/v1/types/crypto.d.ts +2 -0
  126. package/v1/types/crypto.js +3 -0
  127. package/v1/types/crypto.js.map +1 -0
  128. package/v1/types/protocol.d.ts +8 -0
  129. package/v1/types/protocol.js +3 -0
  130. package/v1/types/protocol.js.map +1 -0
  131. package/v1/types/rpc.d.ts +286 -0
  132. package/v1/types/rpc.js +3 -0
  133. package/v1/types/rpc.js.map +1 -0
  134. package/v1/types/transaction.d.ts +44 -0
  135. package/v1/types/transaction.js +10 -0
  136. package/v1/types/transaction.js.map +1 -0
  137. package/v1/utils/key.d.ts +3 -0
  138. package/v1/utils/key.js +20 -0
  139. package/v1/utils/key.js.map +1 -0
  140. package/v1/utils/signature.d.ts +2 -0
  141. package/v1/utils/signature.js +13 -0
  142. package/v1/utils/signature.js.map +1 -0
  143. package/v1/utils/transaction.d.ts +1 -0
  144. package/v1/utils/transaction.js +8 -0
  145. package/v1/utils/transaction.js.map +1 -0
@@ -0,0 +1,382 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ var __importDefault = (this && this.__importDefault) || function (mod) {
39
+ return (mod && mod.__esModule) ? mod : { "default": mod };
40
+ };
41
+ Object.defineProperty(exports, "__esModule", { value: true });
42
+ exports.CosmosNodeClient = void 0;
43
+ var index_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0/index"));
44
+ var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
45
+ var CosmosCoin_1 = require("./CosmosCoin");
46
+ var CosmosNodeClient = /** @class */ (function () {
47
+ function CosmosNodeClient(baseURL, useCORSProxy) {
48
+ if (useCORSProxy === void 0) { useCORSProxy = false; }
49
+ this.baseURL = baseURL;
50
+ this.useCORSProxy = useCORSProxy;
51
+ }
52
+ CosmosNodeClient.prototype.fetchBalance = function (address, totalBalance) {
53
+ return __awaiter(this, void 0, void 0, function () {
54
+ var response, data, availableBalance, totalBalance_1;
55
+ return __generator(this, function (_a) {
56
+ switch (_a.label) {
57
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/bank/balances/".concat(address)))];
58
+ case 1:
59
+ response = _a.sent();
60
+ data = response.data.result;
61
+ if (!(data.length > 0)) return [3 /*break*/, 5];
62
+ availableBalance = CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(data));
63
+ if (!totalBalance) return [3 /*break*/, 3];
64
+ return [4 /*yield*/, Promise.all([
65
+ this.fetchTotalReward(address),
66
+ this.fetchTotalUnbondingAmount(address),
67
+ this.fetchTotalDelegatedAmount(address)
68
+ ])];
69
+ case 2:
70
+ totalBalance_1 = (_a.sent()).reduce(function (current, next) { return current.plus(next); }, new bignumber_1.default(availableBalance));
71
+ return [2 /*return*/, totalBalance_1.decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
72
+ case 3: return [2 /*return*/, new bignumber_1.default(availableBalance).decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
73
+ case 4: return [3 /*break*/, 6];
74
+ case 5: return [2 /*return*/, new bignumber_1.default(0)];
75
+ case 6: return [2 /*return*/];
76
+ }
77
+ });
78
+ });
79
+ };
80
+ CosmosNodeClient.prototype.fetchSendTransactionsFor = function (address, limit, offset, isSender) {
81
+ if (isSender === void 0) { isSender = true; }
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var response;
84
+ return __generator(this, function (_a) {
85
+ switch (_a.label) {
86
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/cosmos/tx/v1beta1/txs?events=".concat(isSender ? 'transfer.sender' : 'transfer.recipient', "='").concat(address, "'&pagination.limit=").concat(limit, "&pagination.offset=").concat(offset, "&orderBy=ORDER_BY_DESC")))];
87
+ case 1:
88
+ response = _a.sent();
89
+ return [2 /*return*/, response.data];
90
+ }
91
+ });
92
+ });
93
+ };
94
+ CosmosNodeClient.prototype.fetchNodeInfo = function () {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var response, nodeInfo;
97
+ return __generator(this, function (_a) {
98
+ switch (_a.label) {
99
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/node_info"))];
100
+ case 1:
101
+ response = _a.sent();
102
+ nodeInfo = response.data.node_info;
103
+ return [2 /*return*/, nodeInfo];
104
+ }
105
+ });
106
+ });
107
+ };
108
+ CosmosNodeClient.prototype.broadcastSignedTransaction = function (tx_bytes) {
109
+ return __awaiter(this, void 0, void 0, function () {
110
+ var response;
111
+ return __generator(this, function (_a) {
112
+ switch (_a.label) {
113
+ case 0: return [4 /*yield*/, index_1.default.post(this.url("/cosmos/tx/v1beta1/txs"), {
114
+ tx_bytes: tx_bytes,
115
+ mode: 'BROADCAST_MODE_ASYNC'
116
+ }, {
117
+ headers: {
118
+ 'Content-type': 'application/json'
119
+ }
120
+ })];
121
+ case 1:
122
+ response = _a.sent();
123
+ return [2 /*return*/, response.data.tx_response.txhash];
124
+ }
125
+ });
126
+ });
127
+ };
128
+ CosmosNodeClient.prototype.fetchAccount = function (address) {
129
+ return __awaiter(this, void 0, void 0, function () {
130
+ var response, account;
131
+ return __generator(this, function (_a) {
132
+ switch (_a.label) {
133
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/auth/accounts/".concat(address)))];
134
+ case 1:
135
+ response = _a.sent();
136
+ account = response.data.result;
137
+ return [2 /*return*/, account];
138
+ }
139
+ });
140
+ });
141
+ };
142
+ CosmosNodeClient.prototype.fetchDelegations = function (address, filterEmpty) {
143
+ if (filterEmpty === void 0) { filterEmpty = true; }
144
+ return __awaiter(this, void 0, void 0, function () {
145
+ var response, delegations;
146
+ return __generator(this, function (_a) {
147
+ switch (_a.label) {
148
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/staking/delegators/".concat(address, "/delegations")))];
149
+ case 1:
150
+ response = _a.sent();
151
+ if (response.data === null) {
152
+ return [2 /*return*/, []];
153
+ }
154
+ delegations = response.data.result;
155
+ return [2 /*return*/, filterEmpty ? delegations.filter(function (delegation) { return new bignumber_1.default(delegation.balance.amount).gt(0); }) : delegations];
156
+ }
157
+ });
158
+ });
159
+ };
160
+ CosmosNodeClient.prototype.fetchTotalDelegatedAmount = function (address) {
161
+ return __awaiter(this, void 0, void 0, function () {
162
+ var delegations, balances;
163
+ return __generator(this, function (_a) {
164
+ switch (_a.label) {
165
+ case 0: return [4 /*yield*/, this.fetchDelegations(address)];
166
+ case 1:
167
+ delegations = _a.sent();
168
+ balances = delegations.map(function (delegation) { return delegation.balance; });
169
+ return [2 /*return*/, CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(balances)).decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
170
+ }
171
+ });
172
+ });
173
+ };
174
+ CosmosNodeClient.prototype.fetchValidator = function (address) {
175
+ return __awaiter(this, void 0, void 0, function () {
176
+ var response, validator;
177
+ return __generator(this, function (_a) {
178
+ switch (_a.label) {
179
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/staking/validators/".concat(address)))];
180
+ case 1:
181
+ response = _a.sent();
182
+ validator = response.data.result;
183
+ return [2 /*return*/, validator];
184
+ }
185
+ });
186
+ });
187
+ };
188
+ CosmosNodeClient.prototype.fetchValidators = function () {
189
+ return __awaiter(this, void 0, void 0, function () {
190
+ var response, validators;
191
+ return __generator(this, function (_a) {
192
+ switch (_a.label) {
193
+ case 0: return [4 /*yield*/, index_1.default.get(this.url('/staking/validators'))];
194
+ case 1:
195
+ response = _a.sent();
196
+ validators = response.data.result;
197
+ return [2 /*return*/, validators];
198
+ }
199
+ });
200
+ });
201
+ };
202
+ CosmosNodeClient.prototype.fetchSelfDelegation = function (validatorAddress) {
203
+ return __awaiter(this, void 0, void 0, function () {
204
+ var validatorInfo, operatorAddress, response, delegation;
205
+ return __generator(this, function (_a) {
206
+ switch (_a.label) {
207
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/distribution/validators/".concat(validatorAddress)))];
208
+ case 1:
209
+ validatorInfo = _a.sent();
210
+ operatorAddress = validatorInfo.data.result.operator_address;
211
+ return [4 /*yield*/, index_1.default.get(this.url("/staking/delegators/".concat(operatorAddress, "/delegations/").concat(validatorAddress)))];
212
+ case 2:
213
+ response = _a.sent();
214
+ delegation = response.data.result;
215
+ return [2 /*return*/, delegation];
216
+ }
217
+ });
218
+ });
219
+ };
220
+ CosmosNodeClient.prototype.fetchUnbondingDelegations = function (delegatorAddress) {
221
+ return __awaiter(this, void 0, void 0, function () {
222
+ var response, unbondingDelegations;
223
+ return __generator(this, function (_a) {
224
+ switch (_a.label) {
225
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/staking/delegators/".concat(delegatorAddress, "/unbonding_delegations")))];
226
+ case 1:
227
+ response = _a.sent();
228
+ unbondingDelegations = response.data.result;
229
+ return [2 /*return*/, unbondingDelegations];
230
+ }
231
+ });
232
+ });
233
+ };
234
+ CosmosNodeClient.prototype.fetchTotalUnbondingAmount = function (address) {
235
+ return __awaiter(this, void 0, void 0, function () {
236
+ var unbondingDelegations, unbondings;
237
+ return __generator(this, function (_a) {
238
+ switch (_a.label) {
239
+ case 0: return [4 /*yield*/, this.fetchUnbondingDelegations(address)];
240
+ case 1:
241
+ unbondingDelegations = _a.sent();
242
+ if (unbondingDelegations) {
243
+ unbondings = unbondingDelegations.map(function (delegation) { return delegation.entries; }).reduce(function (current, next) { return current.concat(next); }, []);
244
+ return [2 /*return*/, unbondings
245
+ .reduce(function (current, next) { return current.plus(new bignumber_1.default(next.balance)); }, new bignumber_1.default(0))
246
+ .decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
247
+ }
248
+ return [2 /*return*/, new bignumber_1.default(0)];
249
+ }
250
+ });
251
+ });
252
+ };
253
+ CosmosNodeClient.prototype.fetchRewardDetails = function (delegatorAddress) {
254
+ return __awaiter(this, void 0, void 0, function () {
255
+ return __generator(this, function (_a) {
256
+ return [2 /*return*/, index_1.default.get(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards")))
257
+ .then(function (response) { var _a; return ((_a = response.data.result.rewards) !== null && _a !== void 0 ? _a : []); })
258
+ .catch(function () { return []; })];
259
+ });
260
+ });
261
+ };
262
+ CosmosNodeClient.prototype.fetchTotalReward = function (delegatorAddress) {
263
+ return __awaiter(this, void 0, void 0, function () {
264
+ var totalRewards;
265
+ return __generator(this, function (_a) {
266
+ switch (_a.label) {
267
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards")))
268
+ .then(function (response) { return response.data.result.total; })
269
+ .catch(function () { return []; })];
270
+ case 1:
271
+ totalRewards = _a.sent();
272
+ if ((totalRewards === null || totalRewards === void 0 ? void 0 : totalRewards.length) > 0) {
273
+ return [2 /*return*/, CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(totalRewards)).decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
274
+ }
275
+ return [2 /*return*/, new bignumber_1.default(0)];
276
+ }
277
+ });
278
+ });
279
+ };
280
+ CosmosNodeClient.prototype.fetchRewardForDelegation = function (delegatorAddress, validatorAddress) {
281
+ return __awaiter(this, void 0, void 0, function () {
282
+ var totalRewards;
283
+ return __generator(this, function (_a) {
284
+ switch (_a.label) {
285
+ case 0: return [4 /*yield*/, index_1.default.get(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards/").concat(validatorAddress)))
286
+ .then(function (response) { return response.data.result; })
287
+ .catch(function () { return []; })];
288
+ case 1:
289
+ totalRewards = _a.sent();
290
+ if ((totalRewards === null || totalRewards === void 0 ? void 0 : totalRewards.length) > 0) {
291
+ return [2 /*return*/, CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(totalRewards)).decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
292
+ }
293
+ return [2 /*return*/, new bignumber_1.default(0)];
294
+ }
295
+ });
296
+ });
297
+ };
298
+ CosmosNodeClient.prototype.withdrawAllDelegationRewards = function (delegatorAddress, chainID, accountNumber, sequence, gas, fee, memo, simulate) {
299
+ if (simulate === void 0) { simulate = false; }
300
+ return __awaiter(this, void 0, void 0, function () {
301
+ var body, response;
302
+ return __generator(this, function (_a) {
303
+ switch (_a.label) {
304
+ case 0:
305
+ body = {
306
+ base_req: {
307
+ from: delegatorAddress,
308
+ memo: memo,
309
+ chain_id: chainID,
310
+ account_number: accountNumber,
311
+ sequence: sequence,
312
+ gas: gas.toFixed(),
313
+ gas_adjustment: '1.2',
314
+ fees: [
315
+ {
316
+ denom: 'uatom',
317
+ amount: fee.toFixed()
318
+ }
319
+ ],
320
+ simulate: simulate
321
+ }
322
+ };
323
+ return [4 /*yield*/, index_1.default.post(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards")), JSON.stringify(body), {
324
+ headers: {
325
+ 'Content-type': 'application/json'
326
+ }
327
+ })];
328
+ case 1:
329
+ response = _a.sent();
330
+ return [2 /*return*/, response.data.hash];
331
+ }
332
+ });
333
+ });
334
+ };
335
+ CosmosNodeClient.prototype.withdrawDelegationRewards = function (delegatorAddress, validatorAdress, chainID, accountNumber, sequence, gas, fee, memo, simulate) {
336
+ if (simulate === void 0) { simulate = false; }
337
+ return __awaiter(this, void 0, void 0, function () {
338
+ var body, response;
339
+ return __generator(this, function (_a) {
340
+ switch (_a.label) {
341
+ case 0:
342
+ body = {
343
+ base_req: {
344
+ from: delegatorAddress,
345
+ memo: memo,
346
+ chain_id: chainID,
347
+ account_number: accountNumber,
348
+ sequence: sequence,
349
+ gas: gas.toFixed(),
350
+ gas_adjustment: '1.2',
351
+ fees: [
352
+ {
353
+ denom: 'uatom',
354
+ amount: fee.toFixed()
355
+ }
356
+ ],
357
+ simulate: simulate
358
+ }
359
+ };
360
+ return [4 /*yield*/, index_1.default.post(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards/").concat(validatorAdress)), JSON.stringify(body), {
361
+ headers: {
362
+ 'Content-type': 'application/json'
363
+ }
364
+ })];
365
+ case 1:
366
+ response = _a.sent();
367
+ return [2 /*return*/, response.data.hash];
368
+ }
369
+ });
370
+ });
371
+ };
372
+ CosmosNodeClient.prototype.url = function (path) {
373
+ var result = "".concat(this.baseURL).concat(path);
374
+ if (this.useCORSProxy) {
375
+ result = "https://cors-proxy.airgap.prod.gke.papers.tech/proxy?url=".concat(encodeURI(result));
376
+ }
377
+ return result;
378
+ };
379
+ return CosmosNodeClient;
380
+ }());
381
+ exports.CosmosNodeClient = CosmosNodeClient;
382
+ //# sourceMappingURL=CosmosNodeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosNodeClient.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mGAA+F;AAC/F,iHAA0F;AAC1F,2CAAyC;AAazC;IACE,0BAA4B,OAAe,EAAS,YAA6B;QAA7B,6BAAA,EAAA,oBAA6B;QAArD,YAAO,GAAP,OAAO,CAAQ;QAAS,iBAAY,GAAZ,YAAY,CAAiB;IAAG,CAAC;IAExE,uCAAY,GAAzB,UAA0B,OAAe,EAAE,YAAsB;;;;;4BAC9C,qBAAM,eAAK,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,yBAAkB,OAAO,CAAE,CAAC,CAAC,EAAA;;wBAAjE,QAAQ,GAAG,SAAsD;wBACjE,IAAI,GAAwB,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAA;6BAClD,CAAA,IAAI,CAAC,MAAM,GAAG,CAAC,CAAA,EAAf,wBAAe;wBACX,gBAAgB,GAAG,uBAAU,CAAC,GAAG,CAAC,uBAAU,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAA;6BAC/D,YAAY,EAAZ,wBAAY;wBAEZ,qBAAM,OAAO,CAAC,GAAG,CAAC;gCAChB,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;gCAC9B,IAAI,CAAC,yBAAyB,CAAC,OAAO,CAAC;gCACvC,IAAI,CAAC,yBAAyB,CA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AI,MAAA;gCACJ,QAAQ,EAAE,OAAO;gCACjB,cAAc,EAAE,aAAa;gCAC7B,QAAQ,UAAA;gCACR,GAAG,EAAE,GAAG,CAAC,OAAO,EAAE;gCAClB,cAAc,EAAE,KAAK;gCACrB,IAAI,EAAE;oCACJ;wCACE,KAAK,EAAE,OAAO;wCACd,MAAM,EAAE,GAAG,CAAC,OAAO,EAAE;qCACtB;iCACF;gCACD,QAAQ,UAAA;6BACT;yBACF,CAAA;wBACgB,qBAAM,eAAK,CAAC,IAAI,CAC/B,IAAI,CAAC,GAAG,CAAC,mCAA4B,gBAAgB,sBAAY,eAAe,CAAE,CAAC,EACnF,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,EACpB;gCACE,OAAO,EAAE;oCACP,cAAc,EAAE,kBAAkB;iCACnC;6BACF,CACF,EAAA;;wBARK,QAAQ,GAAG,SAQhB;wBAED,sBAAO,QAAQ,CAAC,IAAI,CAAC,IAAI,EAAA;;;;KAC1B;IAEO,8BAAG,GAAX,UAAY,IAAY;QACtB,IAAI,MAAM,GAAG,UAAG,IAAI,CAAC,OAAO,SAAG,IAAI,CAAE,CAAA;QACrC,IAAI,IAAI,CAAC,YAAY,EAAE;YACrB,MAAM,GAAG,mEAA4D,SAAS,CAAC,MAAM,CAAC,CAAE,CAAA;SACzF;QAED,OAAO,MAAM,CAAA;IACf,CAAC;IACH,uBAAC;AAAD,CAAC,AAxPD,IAwPC;AAxPY,4CAAgB"}
@@ -0,0 +1,124 @@
1
+ /// <reference types="node" />
2
+ import { KeyPair } from '@airgap/coinlib-core/data/KeyPair';
3
+ import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
4
+ import { AirGapTransactionStatus, IAirGapTransaction } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
5
+ import { DelegateeDetails, DelegationDetails, DelegatorDetails, ICoinDelegateProtocol } from '@airgap/coinlib-core/protocols/ICoinDelegateProtocol';
6
+ import { CurrencyUnit, FeeDefaults } from '@airgap/coinlib-core/protocols/ICoinProtocol';
7
+ import { ICoinSubProtocol } from '@airgap/coinlib-core/protocols/ICoinSubProtocol';
8
+ import { NonExtendedProtocol } from '@airgap/coinlib-core/protocols/NonExtendedProtocol';
9
+ import { ProtocolSymbols } from '@airgap/coinlib-core/utils/ProtocolSymbols';
10
+ import { CosmosCryptoClient } from './CosmosCryptoClient';
11
+ import { CosmosNodeClient } from './CosmosNodeClient';
12
+ import { CosmosAddressCursor, CosmosAddressResult, CosmosDelegation, CosmosUnbondingDelegation, CosmosValidator } from './CosmosTypes';
13
+ import { CosmosProtocolOptions } from './CosmosProtocolOptions';
14
+ import { CosmosTransaction } from './CosmosTransaction';
15
+ import { CosmosTransactionCursor, CosmosTransactionResult } from './CosmosTypes';
16
+ import { UnsignedCosmosTransaction } from '../types/transaction-cosmos';
17
+ import { SignedCosmosTransaction } from '../types/signed-transaction-cosmos';
18
+ export declare enum CosmosDelegationActionType {
19
+ DELEGATE = "delegate",
20
+ UNDELEGATE = "undelegate",
21
+ WITHDRAW_ALL_REWARDS = "withdraw_all_rewards",
22
+ WITHDRAW_VALIDATOR_REWARDS = "withdraw_validator_rewards"
23
+ }
24
+ export declare class CosmosProtocol extends NonExtendedProtocol implements ICoinDelegateProtocol {
25
+ readonly options: CosmosProtocolOptions;
26
+ symbol: string;
27
+ name: string;
28
+ marketSymbol: string;
29
+ feeSymbol: string;
30
+ feeDefaults: FeeDefaults;
31
+ decimals: number;
32
+ feeDecimals: number;
33
+ identifier: ProtocolSymbols;
34
+ units: CurrencyUnit[];
35
+ supportsHD: boolean;
36
+ standardDerivationPath: string;
37
+ addressIsCaseSensitive: boolean;
38
+ addressValidationPattern: string;
39
+ addressPlaceholder: string;
40
+ private readonly defaultGas;
41
+ readonly cryptoClient: CosmosCryptoClient;
42
+ get nodeClient(): CosmosNodeClient;
43
+ constructor(options?: CosmosProtocolOptions);
44
+ getSymbol(): Promise<string>;
45
+ getName(): Promise<string>;
46
+ getMarketSymbol(): Promise<string>;
47
+ getFeeSymbol(): Promise<string>;
48
+ getFeeDefaults(): Promise<FeeDefaults>;
49
+ getDecimals(): Promise<number>;
50
+ getFeeDecimals(): Promise<number>;
51
+ getIdentifier(): Promise<ProtocolSymbols>;
52
+ getUnits(): Promise<CurrencyUnit[]>;
53
+ getSupportsHD(): Promise<boolean>;
54
+ getStandardDerivationPath(): Promise<string>;
55
+ getAddressIsCaseSensitive(): Promise<boolean>;
56
+ getAddressValidationPattern(): Promise<string>;
57
+ getAddressPlaceholder(): Promise<string>;
58
+ getOptions(): Promise<CosmosProtocolOptions>;
59
+ getBlockExplorerLinkForAddress(address: string): Promise<string>;
60
+ getBlockExplorerLinkForTxId(txId: string): Promise<string>;
61
+ generateKeyPair(mnemonic: string, derivationPath?: string, password?: string): KeyPair;
62
+ private generateKeyPairFromNode;
63
+ getPublicKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
64
+ getPrivateKeyFromMnemonic(mnemonic: string, derivationPath: string, password?: string): Promise<string>;
65
+ getPublicKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
66
+ getPublicKeyFromPrivateKey(privateKey: Buffer): Buffer;
67
+ getPrivateKeyFromHexSecret(secret: string, derivationPath: string): Promise<string>;
68
+ getAddressFromPublicKey(publicKey: string, cursor?: CosmosAddressCursor): Promise<CosmosAddressResult>;
69
+ getAddressesFromPublicKey(publicKey: string, cursor?: CosmosAddressCursor): Promise<CosmosAddressResult[]>;
70
+ getTransactionsFromPublicKey(publicKey: string, limit: number, cursor?: CosmosTransactionCursor): Promise<CosmosTransactionResult>;
71
+ getTransactionsFromAddresses(addresses: string[], limit: number, cursor?: CosmosTransactionCursor): Promise<CosmosTransactionResult>;
72
+ signWithPrivateKey(privateKey: string, transaction: CosmosTransaction): Promise<string>;
73
+ getTransactionDetails(transaction: UnsignedCosmosTransaction): Promise<IAirGapTransaction[]>;
74
+ getTransactionDetailsFromSigned(transaction: SignedCosmosTransaction): Promise<IAirGapTransaction[]>;
75
+ getBalanceOfAddresses(addresses: string[]): Promise<string>;
76
+ getBalanceOfPublicKey(publicKey: string): Promise<string>;
77
+ getAvailableBalanceOfAddresses(addresses: string[]): Promise<string>;
78
+ getBalanceOfPublicKeyForSubProtocols(publicKey: string, subProtocols: ICoinSubProtocol[]): Promise<string[]>;
79
+ private getBalance;
80
+ estimateMaxTransactionValueFromPublicKey(publicKey: string, recipients: string[], fee?: string): Promise<string>;
81
+ estimateFeeDefaultsFromPublicKey(publicKey: string, recipients: string[], values: string[], data?: any): Promise<FeeDefaults>;
82
+ prepareTransactionFromPublicKey(publicKey: string, recipients: string[], values: string[], fee: string, data?: {
83
+ memo?: string;
84
+ }): Promise<CosmosTransaction>;
85
+ getDefaultDelegatee(): Promise<string>;
86
+ getCurrentDelegateesForPublicKey(publicKey: string): Promise<string[]>;
87
+ getCurrentDelegateesForAddress(address: string): Promise<string[]>;
88
+ getDelegateeDetails(address: string): Promise<DelegateeDetails>;
89
+ isPublicKeyDelegating(publicKey: string): Promise<boolean>;
90
+ isAddressDelegating(address: string): Promise<boolean>;
91
+ getDelegatorDetailsFromPublicKey(publicKey: string): Promise<DelegatorDetails>;
92
+ getDelegatorDetailsFromAddress(address: string): Promise<DelegatorDetails>;
93
+ getDelegationDetailsFromPublicKey(publicKey: string, delegatees: string[]): Promise<DelegationDetails>;
94
+ getDelegationDetailsFromAddress(address: string, delegatees: string[]): Promise<DelegationDetails>;
95
+ prepareDelegatorActionFromPublicKey(publicKey: string, type: CosmosDelegationActionType, data?: any): Promise<CosmosTransaction[]>;
96
+ undelegate(publicKey: string, validatorAddress: string, amount: string, memo?: string): Promise<CosmosTransaction>;
97
+ delegate(publicKey: string, validatorAddress: string | string[], amount: string, undelegate?: boolean, memo?: string): Promise<CosmosTransaction>;
98
+ withdrawDelegationRewards(publicKey: string, _validatorAddresses?: string[], memo?: string): Promise<CosmosTransaction>;
99
+ withdrawAllDelegationRewards(delegatorAddress: string, fee: BigNumber, memo?: string): Promise<string>;
100
+ fetchTotalReward(delegatorAddress: string): Promise<BigNumber>;
101
+ fetchRewardForDelegation(delegatorAddress: string, validatorAddress: string): Promise<BigNumber>;
102
+ fetchDelegations(address: string): Promise<CosmosDelegation[]>;
103
+ fetchTotalDelegatedAmount(address: string): Promise<BigNumber>;
104
+ fetchValidator(address: string): Promise<CosmosValidator>;
105
+ fetchUnbondingDelegations(delegatorAddress: string): Promise<CosmosUnbondingDelegation[]>;
106
+ fetchTotalUnbondingAmount(address: string): Promise<BigNumber>;
107
+ fetchValidators(): Promise<CosmosValidator[]>;
108
+ fetchSelfDelegation(address: string): Promise<CosmosDelegation>;
109
+ broadcastTransaction(rawTransaction: string): Promise<string>;
110
+ private getDelegatorDetails;
111
+ private getAvailableDelegatorActions;
112
+ signMessage(message: string, keypair: {
113
+ privateKey: string;
114
+ }): Promise<string>;
115
+ verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
116
+ encryptAsymmetric(message: string, publicKey: string): Promise<string>;
117
+ decryptAsymmetric(message: string, keypair: {
118
+ publicKey: string;
119
+ privateKey: string;
120
+ }): Promise<string>;
121
+ encryptAES(message: string, privateKey: string): Promise<string>;
122
+ decryptAES(message: string, privateKey: string): Promise<string>;
123
+ getTransactionStatuses(transactionHashes: string[]): Promise<AirGapTransactionStatus[]>;
124
+ }