@airgap/cosmos 0.13.10 → 0.13.11-beta.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 (140) hide show
  1. package/package.json +12 -8
  2. package/airgap-coinlib-cosmos.min.js +0 -86304
  3. package/index.d.ts +0 -1
  4. package/index.js +0 -18
  5. package/index.js.map +0 -1
  6. package/v0/index.d.ts +0 -10
  7. package/v0/index.js +0 -32
  8. package/v0/index.js.map +0 -1
  9. package/v0/protocol/CosmosAddress.d.ts +0 -8
  10. package/v0/protocol/CosmosAddress.js +0 -28
  11. package/v0/protocol/CosmosAddress.js.map +0 -1
  12. package/v0/protocol/CosmosCoin.d.ts +0 -19
  13. package/v0/protocol/CosmosCoin.js +0 -55
  14. package/v0/protocol/CosmosCoin.js.map +0 -1
  15. package/v0/protocol/CosmosCryptoClient.d.ts +0 -8
  16. package/v0/protocol/CosmosCryptoClient.js +0 -90
  17. package/v0/protocol/CosmosCryptoClient.js.map +0 -1
  18. package/v0/protocol/CosmosFee.d.ts +0 -15
  19. package/v0/protocol/CosmosFee.js +0 -31
  20. package/v0/protocol/CosmosFee.js.map +0 -1
  21. package/v0/protocol/CosmosNodeClient.d.ts +0 -25
  22. package/v0/protocol/CosmosNodeClient.js +0 -382
  23. package/v0/protocol/CosmosNodeClient.js.map +0 -1
  24. package/v0/protocol/CosmosProtocol.d.ts +0 -124
  25. package/v0/protocol/CosmosProtocol.js +0 -1155
  26. package/v0/protocol/CosmosProtocol.js.map +0 -1
  27. package/v0/protocol/CosmosProtocolOptions.d.ts +0 -22
  28. package/v0/protocol/CosmosProtocolOptions.js +0 -116
  29. package/v0/protocol/CosmosProtocolOptions.js.map +0 -1
  30. package/v0/protocol/CosmosTransaction.d.ts +0 -37
  31. package/v0/protocol/CosmosTransaction.js +0 -106
  32. package/v0/protocol/CosmosTransaction.js.map +0 -1
  33. package/v0/protocol/CosmosTypes.d.ts +0 -310
  34. package/v0/protocol/CosmosTypes.js +0 -8
  35. package/v0/protocol/CosmosTypes.js.map +0 -1
  36. package/v0/protocol/cosmos-message/CosmosDelegateMessage.d.ts +0 -20
  37. package/v0/protocol/cosmos-message/CosmosDelegateMessage.js +0 -72
  38. package/v0/protocol/cosmos-message/CosmosDelegateMessage.js.map +0 -1
  39. package/v0/protocol/cosmos-message/CosmosMessage.d.ts +0 -39
  40. package/v0/protocol/cosmos-message/CosmosMessage.js +0 -47
  41. package/v0/protocol/cosmos-message/CosmosMessage.js.map +0 -1
  42. package/v0/protocol/cosmos-message/CosmosSendMessage.d.ts +0 -20
  43. package/v0/protocol/cosmos-message/CosmosSendMessage.js +0 -85
  44. package/v0/protocol/cosmos-message/CosmosSendMessage.js.map +0 -1
  45. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +0 -24
  46. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +0 -61
  47. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +0 -1
  48. package/v0/serializer/schemas/v2/transaction-sign-request-cosmos.json +0 -100
  49. package/v0/serializer/schemas/v2/transaction-sign-response-cosmos.json +0 -22
  50. package/v0/serializer/schemas/v3/transaction-sign-request-cosmos.json +0 -100
  51. package/v0/serializer/schemas/v3/transaction-sign-response-cosmos.json +0 -23
  52. package/v0/serializer/validators/transaction-validator.d.ts +0 -15
  53. package/v0/serializer/validators/transaction-validator.js +0 -112
  54. package/v0/serializer/validators/transaction-validator.js.map +0 -1
  55. package/v0/types/signed-transaction-cosmos.d.ts +0 -5
  56. package/v0/types/signed-transaction-cosmos.js +0 -3
  57. package/v0/types/signed-transaction-cosmos.js.map +0 -1
  58. package/v0/types/transaction-cosmos.d.ts +0 -5
  59. package/v0/types/transaction-cosmos.js +0 -3
  60. package/v0/types/transaction-cosmos.js.map +0 -1
  61. package/v0/types/unsigned-transaction-cosmos.d.ts +0 -33
  62. package/v0/types/unsigned-transaction-cosmos.js +0 -10
  63. package/v0/types/unsigned-transaction-cosmos.js.map +0 -1
  64. package/v1/block-explorer/MintscanBlockExplorer.d.ts +0 -9
  65. package/v1/block-explorer/MintscanBlockExplorer.js +0 -74
  66. package/v1/block-explorer/MintscanBlockExplorer.js.map +0 -1
  67. package/v1/data/CosmosAddress.d.ts +0 -7
  68. package/v1/data/CosmosAddress.js +0 -29
  69. package/v1/data/CosmosAddress.js.map +0 -1
  70. package/v1/data/CosmosCoin.d.ts +0 -19
  71. package/v1/data/CosmosCoin.js +0 -55
  72. package/v1/data/CosmosCoin.js.map +0 -1
  73. package/v1/data/CosmosFee.d.ts +0 -15
  74. package/v1/data/CosmosFee.js +0 -31
  75. package/v1/data/CosmosFee.js.map +0 -1
  76. package/v1/data/transaction/CosmosTransaction.d.ts +0 -36
  77. package/v1/data/transaction/CosmosTransaction.js +0 -109
  78. package/v1/data/transaction/CosmosTransaction.js.map +0 -1
  79. package/v1/data/transaction/message/CosmosDelegateMessage.d.ts +0 -19
  80. package/v1/data/transaction/message/CosmosDelegateMessage.js +0 -70
  81. package/v1/data/transaction/message/CosmosDelegateMessage.js.map +0 -1
  82. package/v1/data/transaction/message/CosmosMessage.d.ts +0 -38
  83. package/v1/data/transaction/message/CosmosMessage.js +0 -47
  84. package/v1/data/transaction/message/CosmosMessage.js.map +0 -1
  85. package/v1/data/transaction/message/CosmosSendMessage.d.ts +0 -19
  86. package/v1/data/transaction/message/CosmosSendMessage.js +0 -83
  87. package/v1/data/transaction/message/CosmosSendMessage.js.map +0 -1
  88. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.d.ts +0 -23
  89. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js +0 -61
  90. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js.map +0 -1
  91. package/v1/index.d.ts +0 -9
  92. package/v1/index.js +0 -11
  93. package/v1/index.js.map +0 -1
  94. package/v1/module/CosmosModule.d.ts +0 -15
  95. package/v1/module/CosmosModule.js +0 -107
  96. package/v1/module/CosmosModule.js.map +0 -1
  97. package/v1/node/CosmosNodeClient.d.ts +0 -28
  98. package/v1/node/CosmosNodeClient.js +0 -381
  99. package/v1/node/CosmosNodeClient.js.map +0 -1
  100. package/v1/protocol/CosmosCryptoClient.d.ts +0 -8
  101. package/v1/protocol/CosmosCryptoClient.js +0 -90
  102. package/v1/protocol/CosmosCryptoClient.js.map +0 -1
  103. package/v1/protocol/CosmosProtocol.d.ts +0 -50
  104. package/v1/protocol/CosmosProtocol.js +0 -662
  105. package/v1/protocol/CosmosProtocol.js.map +0 -1
  106. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +0 -7
  107. package/v1/serializer/v3/schemas/converter/transaction-converter.js +0 -37
  108. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +0 -1
  109. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.d.ts +0 -4
  110. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js +0 -3
  111. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js.map +0 -1
  112. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.d.ts +0 -3
  113. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js +0 -3
  114. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js.map +0 -1
  115. package/v1/serializer/v3/schemas/generated/transaction-sign-request-cosmos.json +0 -100
  116. package/v1/serializer/v3/schemas/generated/transaction-sign-response-cosmos.json +0 -19
  117. package/v1/serializer/v3/serializer-companion.d.ts +0 -12
  118. package/v1/serializer/v3/serializer-companion.js +0 -142
  119. package/v1/serializer/v3/serializer-companion.js.map +0 -1
  120. package/v1/serializer/v3/validators/transaction-validators.d.ts +0 -7
  121. package/v1/serializer/v3/validators/transaction-validators.js +0 -88
  122. package/v1/serializer/v3/validators/transaction-validators.js.map +0 -1
  123. package/v1/types/protocol.d.ts +0 -8
  124. package/v1/types/protocol.js +0 -3
  125. package/v1/types/protocol.js.map +0 -1
  126. package/v1/types/rpc.d.ts +0 -286
  127. package/v1/types/rpc.js +0 -3
  128. package/v1/types/rpc.js.map +0 -1
  129. package/v1/types/transaction.d.ts +0 -44
  130. package/v1/types/transaction.js +0 -10
  131. package/v1/types/transaction.js.map +0 -1
  132. package/v1/utils/key.d.ts +0 -3
  133. package/v1/utils/key.js +0 -20
  134. package/v1/utils/key.js.map +0 -1
  135. package/v1/utils/signature.d.ts +0 -2
  136. package/v1/utils/signature.js +0 -13
  137. package/v1/utils/signature.js.map +0 -1
  138. package/v1/utils/transaction.d.ts +0 -1
  139. package/v1/utils/transaction.js +0 -8
  140. package/v1/utils/transaction.js.map +0 -1
@@ -1,107 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.CosmosModule = void 0;
40
- var coinlib_core_1 = require("@airgap/coinlib-core");
41
- var errors_1 = require("@airgap/coinlib-core/errors");
42
- var module_kit_1 = require("@airgap/module-kit");
43
- var MintscanBlockExplorer_1 = require("../block-explorer/MintscanBlockExplorer");
44
- var CosmosProtocol_1 = require("../protocol/CosmosProtocol");
45
- var serializer_companion_1 = require("../serializer/v3/serializer-companion");
46
- var CosmosModule = /** @class */ (function () {
47
- function CosmosModule() {
48
- var _a;
49
- this.networkRegistries = (_a = {},
50
- _a[coinlib_core_1.MainProtocolSymbols.COSMOS] = new module_kit_1.ModuleNetworkRegistry({
51
- supportedNetworks: [CosmosProtocol_1.COSMOS_MAINNET_PROTOCOL_NETWORK]
52
- }),
53
- _a);
54
- this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
55
- }
56
- CosmosModule.prototype.createOfflineProtocol = function (identifier) {
57
- return __awaiter(this, void 0, void 0, function () {
58
- return __generator(this, function (_a) {
59
- return [2 /*return*/, this.createProtocol(identifier)];
60
- });
61
- });
62
- };
63
- CosmosModule.prototype.createOnlineProtocol = function (identifier, networkId) {
64
- var _a;
65
- return __awaiter(this, void 0, void 0, function () {
66
- var network;
67
- return __generator(this, function (_b) {
68
- network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
69
- if (network === undefined) {
70
- throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.COSMOS, 'Protocol network type not supported.');
71
- }
72
- return [2 /*return*/, this.createProtocol(identifier, network)];
73
- });
74
- });
75
- };
76
- CosmosModule.prototype.createBlockExplorer = function (identifier, networkId) {
77
- var _a;
78
- return __awaiter(this, void 0, void 0, function () {
79
- var network;
80
- return __generator(this, function (_b) {
81
- network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
82
- if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
83
- throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.COSMOS, 'Block Explorer network type not supported.');
84
- }
85
- return [2 /*return*/, new MintscanBlockExplorer_1.MintscanBlockExplorer()];
86
- });
87
- });
88
- };
89
- CosmosModule.prototype.createV3SerializerCompanion = function () {
90
- return __awaiter(this, void 0, void 0, function () {
91
- return __generator(this, function (_a) {
92
- return [2 /*return*/, new serializer_companion_1.CosmosV3SerializerCompanion()];
93
- });
94
- });
95
- };
96
- CosmosModule.prototype.createProtocol = function (identifier, network) {
97
- switch (identifier) {
98
- case coinlib_core_1.MainProtocolSymbols.COSMOS:
99
- return (0, CosmosProtocol_1.createCosmosProtocol)({ network: network });
100
- default:
101
- throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported."));
102
- }
103
- };
104
- return CosmosModule;
105
- }());
106
- exports.CosmosModule = CosmosModule;
107
- //# sourceMappingURL=CosmosModule.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CosmosModule.js","sourceRoot":"","sources":["../../../src/v1/module/CosmosModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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AAE,EAAA;;;KACzC;IAEO,qCAAc,GAAtB,UAAuB,UAA8B,EAAE,OAAyB;QAC9E,QAAQ,UAAU,EAAE;YAClB,KAAK,kCAAmB,CAAC,MAAM;gBAC7B,OAAO,IAAA,qCAAoB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAA;YAC1C;gBACE,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,SAAS,EAAE,mBAAY,UAAU,oBAAiB,CAAC,CAAA;SAC/F;IACH,CAAC;IACH,mBAAC;AAAD,CAAC,AA1CD,IA0CC;AA1CY,oCAAY"}
@@ -1,28 +0,0 @@
1
- import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
- import { CosmosAccount, CosmosDelegation, CosmosNodeInfo, CosmosPagedSendTxsResponse, CosmosRewardDetails, CosmosUnbondingDelegation, CosmosValidator } from '../types/rpc';
3
- export declare class CosmosNodeClient {
4
- readonly baseURL: string;
5
- useCORSProxy: boolean;
6
- constructor(baseURL: string, useCORSProxy?: boolean);
7
- fetchBalance(address: string): Promise<{
8
- total: BigNumber;
9
- available: BigNumber;
10
- }>;
11
- fetchSendTransactionsFor(address: string, limit: number, offset: number, isSender?: boolean): Promise<CosmosPagedSendTxsResponse>;
12
- fetchNodeInfo(): Promise<CosmosNodeInfo>;
13
- broadcastSignedTransaction(tx_bytes: string): Promise<string>;
14
- fetchAccount(address: string): Promise<CosmosAccount>;
15
- fetchDelegations(address: string, filterEmpty?: boolean): Promise<CosmosDelegation[]>;
16
- fetchTotalDelegatedAmount(address: string): Promise<BigNumber>;
17
- fetchValidator(address: string): Promise<CosmosValidator>;
18
- fetchValidators(): Promise<CosmosValidator[]>;
19
- fetchSelfDelegation(validatorAddress: string): Promise<CosmosDelegation>;
20
- fetchUnbondingDelegations(delegatorAddress: string): Promise<CosmosUnbondingDelegation[]>;
21
- fetchTotalUnbondingAmount(address: string): Promise<BigNumber>;
22
- fetchRewardDetails(delegatorAddress: string): Promise<CosmosRewardDetails[]>;
23
- fetchTotalReward(delegatorAddress: string): Promise<BigNumber>;
24
- fetchRewardForDelegation(delegatorAddress: string, validatorAddress: string): Promise<BigNumber>;
25
- withdrawAllDelegationRewards(delegatorAddress: string, chainID: string, accountNumber: string, sequence: string, gas: BigNumber, fee: BigNumber, memo: string, simulate?: boolean): Promise<string>;
26
- withdrawDelegationRewards(delegatorAddress: string, validatorAdress: string, chainID: string, accountNumber: string, sequence: string, gas: BigNumber, fee: BigNumber, memo: string, simulate?: boolean): Promise<string>;
27
- private url;
28
- }
@@ -1,381 +0,0 @@
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("../data/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) {
53
- return __awaiter(this, void 0, void 0, function () {
54
- var response, data, availableBalance, totalBalance;
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*/, 3];
62
- availableBalance = CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(data));
63
- return [4 /*yield*/, Promise.all([
64
- this.fetchTotalReward(address),
65
- this.fetchTotalUnbondingAmount(address),
66
- this.fetchTotalDelegatedAmount(address)
67
- ])];
68
- case 2:
69
- totalBalance = (_a.sent()).reduce(function (current, next) { return current.plus(next); }, new bignumber_1.default(availableBalance));
70
- return [2 /*return*/, {
71
- total: totalBalance.decimalPlaces(0, bignumber_1.default.ROUND_FLOOR),
72
- available: availableBalance.decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)
73
- }];
74
- case 3: return [2 /*return*/, { total: new bignumber_1.default(0), available: new bignumber_1.default(0) }];
75
- }
76
- });
77
- });
78
- };
79
- CosmosNodeClient.prototype.fetchSendTransactionsFor = function (address, limit, offset, isSender) {
80
- if (isSender === void 0) { isSender = true; }
81
- return __awaiter(this, void 0, void 0, function () {
82
- var response;
83
- return __generator(this, function (_a) {
84
- switch (_a.label) {
85
- 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")))];
86
- case 1:
87
- response = _a.sent();
88
- return [2 /*return*/, response.data];
89
- }
90
- });
91
- });
92
- };
93
- CosmosNodeClient.prototype.fetchNodeInfo = function () {
94
- return __awaiter(this, void 0, void 0, function () {
95
- var response, nodeInfo;
96
- return __generator(this, function (_a) {
97
- switch (_a.label) {
98
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/node_info"))];
99
- case 1:
100
- response = _a.sent();
101
- nodeInfo = response.data.node_info;
102
- return [2 /*return*/, nodeInfo];
103
- }
104
- });
105
- });
106
- };
107
- CosmosNodeClient.prototype.broadcastSignedTransaction = function (tx_bytes) {
108
- return __awaiter(this, void 0, void 0, function () {
109
- var response;
110
- return __generator(this, function (_a) {
111
- switch (_a.label) {
112
- case 0: return [4 /*yield*/, index_1.default.post(this.url("/cosmos/tx/v1beta1/txs"), {
113
- tx_bytes: tx_bytes,
114
- mode: 'BROADCAST_MODE_ASYNC'
115
- }, {
116
- headers: {
117
- 'Content-type': 'application/json'
118
- }
119
- })];
120
- case 1:
121
- response = _a.sent();
122
- return [2 /*return*/, response.data.tx_response.txhash];
123
- }
124
- });
125
- });
126
- };
127
- CosmosNodeClient.prototype.fetchAccount = function (address) {
128
- return __awaiter(this, void 0, void 0, function () {
129
- var response, account;
130
- return __generator(this, function (_a) {
131
- switch (_a.label) {
132
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/auth/accounts/".concat(address)))];
133
- case 1:
134
- response = _a.sent();
135
- account = response.data.result;
136
- return [2 /*return*/, account];
137
- }
138
- });
139
- });
140
- };
141
- CosmosNodeClient.prototype.fetchDelegations = function (address, filterEmpty) {
142
- if (filterEmpty === void 0) { filterEmpty = true; }
143
- return __awaiter(this, void 0, void 0, function () {
144
- var response, delegations;
145
- return __generator(this, function (_a) {
146
- switch (_a.label) {
147
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/staking/delegators/".concat(address, "/delegations")))];
148
- case 1:
149
- response = _a.sent();
150
- if (response.data === null) {
151
- return [2 /*return*/, []];
152
- }
153
- delegations = response.data.result;
154
- return [2 /*return*/, filterEmpty ? delegations.filter(function (delegation) { return new bignumber_1.default(delegation.balance.amount).gt(0); }) : delegations];
155
- }
156
- });
157
- });
158
- };
159
- CosmosNodeClient.prototype.fetchTotalDelegatedAmount = function (address) {
160
- return __awaiter(this, void 0, void 0, function () {
161
- var delegations, balances;
162
- return __generator(this, function (_a) {
163
- switch (_a.label) {
164
- case 0: return [4 /*yield*/, this.fetchDelegations(address)];
165
- case 1:
166
- delegations = _a.sent();
167
- balances = delegations.map(function (delegation) { return delegation.balance; });
168
- return [2 /*return*/, CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(balances)).decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
169
- }
170
- });
171
- });
172
- };
173
- CosmosNodeClient.prototype.fetchValidator = function (address) {
174
- return __awaiter(this, void 0, void 0, function () {
175
- var response, validator;
176
- return __generator(this, function (_a) {
177
- switch (_a.label) {
178
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/staking/validators/".concat(address)))];
179
- case 1:
180
- response = _a.sent();
181
- validator = response.data.result;
182
- return [2 /*return*/, validator];
183
- }
184
- });
185
- });
186
- };
187
- CosmosNodeClient.prototype.fetchValidators = function () {
188
- return __awaiter(this, void 0, void 0, function () {
189
- var response, validators;
190
- return __generator(this, function (_a) {
191
- switch (_a.label) {
192
- case 0: return [4 /*yield*/, index_1.default.get(this.url('/staking/validators'))];
193
- case 1:
194
- response = _a.sent();
195
- validators = response.data.result;
196
- return [2 /*return*/, validators];
197
- }
198
- });
199
- });
200
- };
201
- CosmosNodeClient.prototype.fetchSelfDelegation = function (validatorAddress) {
202
- return __awaiter(this, void 0, void 0, function () {
203
- var validatorInfo, operatorAddress, response, delegation;
204
- return __generator(this, function (_a) {
205
- switch (_a.label) {
206
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/distribution/validators/".concat(validatorAddress)))];
207
- case 1:
208
- validatorInfo = _a.sent();
209
- operatorAddress = validatorInfo.data.result.operator_address;
210
- return [4 /*yield*/, index_1.default.get(this.url("/staking/delegators/".concat(operatorAddress, "/delegations/").concat(validatorAddress)))];
211
- case 2:
212
- response = _a.sent();
213
- delegation = response.data.result;
214
- return [2 /*return*/, delegation];
215
- }
216
- });
217
- });
218
- };
219
- CosmosNodeClient.prototype.fetchUnbondingDelegations = function (delegatorAddress) {
220
- return __awaiter(this, void 0, void 0, function () {
221
- var response, unbondingDelegations;
222
- return __generator(this, function (_a) {
223
- switch (_a.label) {
224
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/staking/delegators/".concat(delegatorAddress, "/unbonding_delegations")))];
225
- case 1:
226
- response = _a.sent();
227
- unbondingDelegations = response.data.result;
228
- return [2 /*return*/, unbondingDelegations];
229
- }
230
- });
231
- });
232
- };
233
- CosmosNodeClient.prototype.fetchTotalUnbondingAmount = function (address) {
234
- return __awaiter(this, void 0, void 0, function () {
235
- var unbondingDelegations, unbondings;
236
- return __generator(this, function (_a) {
237
- switch (_a.label) {
238
- case 0: return [4 /*yield*/, this.fetchUnbondingDelegations(address)];
239
- case 1:
240
- unbondingDelegations = _a.sent();
241
- if (unbondingDelegations) {
242
- unbondings = unbondingDelegations.map(function (delegation) { return delegation.entries; }).reduce(function (current, next) { return current.concat(next); }, []);
243
- return [2 /*return*/, unbondings
244
- .reduce(function (current, next) { return current.plus(new bignumber_1.default(next.balance)); }, new bignumber_1.default(0))
245
- .decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
246
- }
247
- return [2 /*return*/, new bignumber_1.default(0)];
248
- }
249
- });
250
- });
251
- };
252
- CosmosNodeClient.prototype.fetchRewardDetails = function (delegatorAddress) {
253
- return __awaiter(this, void 0, void 0, function () {
254
- return __generator(this, function (_a) {
255
- return [2 /*return*/, index_1.default.get(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards")))
256
- .then(function (response) { var _a; return ((_a = response.data.result.rewards) !== null && _a !== void 0 ? _a : []); })
257
- .catch(function () { return []; })];
258
- });
259
- });
260
- };
261
- CosmosNodeClient.prototype.fetchTotalReward = function (delegatorAddress) {
262
- return __awaiter(this, void 0, void 0, function () {
263
- var totalRewards;
264
- return __generator(this, function (_a) {
265
- switch (_a.label) {
266
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards")))
267
- .then(function (response) { return response.data.result.total; })
268
- .catch(function () { return []; })];
269
- case 1:
270
- totalRewards = _a.sent();
271
- if ((totalRewards === null || totalRewards === void 0 ? void 0 : totalRewards.length) > 0) {
272
- return [2 /*return*/, CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(totalRewards)).decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
273
- }
274
- return [2 /*return*/, new bignumber_1.default(0)];
275
- }
276
- });
277
- });
278
- };
279
- CosmosNodeClient.prototype.fetchRewardForDelegation = function (delegatorAddress, validatorAddress) {
280
- return __awaiter(this, void 0, void 0, function () {
281
- var totalRewards;
282
- return __generator(this, function (_a) {
283
- switch (_a.label) {
284
- case 0: return [4 /*yield*/, index_1.default.get(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards/").concat(validatorAddress)))
285
- .then(function (response) { return response.data.result; })
286
- .catch(function () { return []; })];
287
- case 1:
288
- totalRewards = _a.sent();
289
- if ((totalRewards === null || totalRewards === void 0 ? void 0 : totalRewards.length) > 0) {
290
- return [2 /*return*/, CosmosCoin_1.CosmosCoin.sum(CosmosCoin_1.CosmosCoin.fromCoins(totalRewards)).decimalPlaces(0, bignumber_1.default.ROUND_FLOOR)];
291
- }
292
- return [2 /*return*/, new bignumber_1.default(0)];
293
- }
294
- });
295
- });
296
- };
297
- CosmosNodeClient.prototype.withdrawAllDelegationRewards = function (delegatorAddress, chainID, accountNumber, sequence, gas, fee, memo, simulate) {
298
- if (simulate === void 0) { simulate = false; }
299
- return __awaiter(this, void 0, void 0, function () {
300
- var body, response;
301
- return __generator(this, function (_a) {
302
- switch (_a.label) {
303
- case 0:
304
- body = {
305
- base_req: {
306
- from: delegatorAddress,
307
- memo: memo,
308
- chain_id: chainID,
309
- account_number: accountNumber,
310
- sequence: sequence,
311
- gas: gas.toFixed(),
312
- gas_adjustment: '1.2',
313
- fees: [
314
- {
315
- denom: 'uatom',
316
- amount: fee.toFixed()
317
- }
318
- ],
319
- simulate: simulate
320
- }
321
- };
322
- return [4 /*yield*/, index_1.default.post(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards")), JSON.stringify(body), {
323
- headers: {
324
- 'Content-type': 'application/json'
325
- }
326
- })];
327
- case 1:
328
- response = _a.sent();
329
- return [2 /*return*/, response.data.hash];
330
- }
331
- });
332
- });
333
- };
334
- CosmosNodeClient.prototype.withdrawDelegationRewards = function (delegatorAddress, validatorAdress, chainID, accountNumber, sequence, gas, fee, memo, simulate) {
335
- if (simulate === void 0) { simulate = false; }
336
- return __awaiter(this, void 0, void 0, function () {
337
- var body, response;
338
- return __generator(this, function (_a) {
339
- switch (_a.label) {
340
- case 0:
341
- body = {
342
- base_req: {
343
- from: delegatorAddress,
344
- memo: memo,
345
- chain_id: chainID,
346
- account_number: accountNumber,
347
- sequence: sequence,
348
- gas: gas.toFixed(),
349
- gas_adjustment: '1.2',
350
- fees: [
351
- {
352
- denom: 'uatom',
353
- amount: fee.toFixed()
354
- }
355
- ],
356
- simulate: simulate
357
- }
358
- };
359
- return [4 /*yield*/, index_1.default.post(this.url("/distribution/delegators/".concat(delegatorAddress, "/rewards/").concat(validatorAdress)), JSON.stringify(body), {
360
- headers: {
361
- 'Content-type': 'application/json'
362
- }
363
- })];
364
- case 1:
365
- response = _a.sent();
366
- return [2 /*return*/, response.data.hash];
367
- }
368
- });
369
- });
370
- };
371
- CosmosNodeClient.prototype.url = function (path) {
372
- var result = "".concat(this.baseURL).concat(path);
373
- if (this.useCORSProxy) {
374
- result = "https://cors-proxy.airgap.prod.gke.papers.tech/proxy?url=".concat(encodeURI(result));
375
- }
376
- return result;
377
- };
378
- return CosmosNodeClient;
379
- }());
380
- exports.CosmosNodeClient = CosmosNodeClient;
381
- //# sourceMappingURL=CosmosNodeClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CosmosNodeClient.js","sourceRoot":"","sources":["../../../src/v1/node/CosmosNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mGAA+F;AAC/F,iHAA0F;AAE1F,iDAA+C;AAa/C;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;;;;;4BACtB,qBAAM,eAAK,CAAC,GAAG,CAAC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G,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"}
@@ -1,8 +0,0 @@
1
- import { Secp256k1CryptoClient } from '@airgap/coinlib-core/protocols/Secp256k1CryptoClient';
2
- export declare class CosmosCryptoClient extends Secp256k1CryptoClient {
3
- constructor();
4
- signMessage(message: string, keypair: {
5
- privateKey: string;
6
- }): Promise<string>;
7
- verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
8
- }
@@ -1,90 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- 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;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- Object.defineProperty(exports, "__esModule", { value: true });
54
- exports.CosmosCryptoClient = void 0;
55
- // @ts-ignore
56
- var SECP256K1 = require("@airgap/coinlib-core/dependencies/src/secp256k1-3.7.1/elliptic");
57
- // @ts-ignore
58
- var sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
59
- var Secp256k1CryptoClient_1 = require("@airgap/coinlib-core/protocols/Secp256k1CryptoClient");
60
- var CosmosCryptoClient = /** @class */ (function (_super) {
61
- __extends(CosmosCryptoClient, _super);
62
- function CosmosCryptoClient() {
63
- return _super.call(this) || this;
64
- }
65
- CosmosCryptoClient.prototype.signMessage = function (message, keypair) {
66
- return __awaiter(this, void 0, void 0, function () {
67
- var sha256Hash, hash, signed;
68
- return __generator(this, function (_a) {
69
- sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
70
- hash = Buffer.from(sha256Hash);
71
- signed = SECP256K1.sign(hash, Buffer.from(keypair.privateKey, 'hex'));
72
- return [2 /*return*/, "0x".concat(Buffer.from(signed.signature).toString('hex'))];
73
- });
74
- });
75
- };
76
- CosmosCryptoClient.prototype.verifyMessage = function (message, signature, publicKey) {
77
- return __awaiter(this, void 0, void 0, function () {
78
- var rawSignature, sha256Hash, messageHash;
79
- return __generator(this, function (_a) {
80
- rawSignature = Buffer.from(signature.replace(/^0x/, ''), 'hex');
81
- sha256Hash = sha('sha256').update(Buffer.from(message)).digest();
82
- messageHash = Buffer.from(sha256Hash);
83
- return [2 /*return*/, SECP256K1.verify(messageHash, rawSignature, Buffer.from(publicKey, 'hex'))];
84
- });
85
- });
86
- };
87
- return CosmosCryptoClient;
88
- }(Secp256k1CryptoClient_1.Secp256k1CryptoClient));
89
- exports.CosmosCryptoClient = CosmosCryptoClient;
90
- //# sourceMappingURL=CosmosCryptoClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"CosmosCryptoClient.js","sourceRoot":"","sources":["../../../src/v1/protocol/CosmosCryptoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,0FAA4F;AAC5F,aAAa;AACb,+EAAiF;AACjF,8FAA4F;AAE5F;IAAwC,sCAAqB;IAC3D;eACE,iBAAO;IACT,CAAC;IAEY,wCAAW,GAAxB,UAAyB,OAAe,EAAE,OAA+B;;;;gBACjE,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC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