@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
package/index.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './v0';
package/index.js ADDED
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./v0"), exports);
18
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAoB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airgap/cosmos",
3
- "version": "0.13.11-beta.1",
3
+ "version": "0.13.11-beta.2",
4
4
  "description": "The @airgap/cosmos is a Cosmos implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
5
5
  "keywords": [
6
6
  "airgap",
@@ -17,10 +17,6 @@
17
17
  "publishConfig": {
18
18
  "access": "public"
19
19
  },
20
- "main": "dist/index.js",
21
- "files": [
22
- "dist"
23
- ],
24
20
  "scripts": {
25
21
  "build": "rm -rf ./dist && tsc && node scripts/copy-files-after-build.js",
26
22
  "build-scripts": "tsc scripts/*.ts",
package/v0/index.d.ts ADDED
@@ -0,0 +1,10 @@
1
+ import { CosmosAddress } from './protocol/CosmosAddress';
2
+ import { CosmosCryptoClient } from './protocol/CosmosCryptoClient';
3
+ import { CosmosDelegationActionType, CosmosProtocol } from './protocol/CosmosProtocol';
4
+ import { CosmosProtocolConfig, CosmosProtocolNetwork, CosmosProtocolOptions, MintscanBlockExplorer } from './protocol/CosmosProtocolOptions';
5
+ import { CosmosTransaction } from './protocol/CosmosTransaction';
6
+ import { CosmosUnbondingDelegation, CosmosValidator } from './protocol/CosmosTypes';
7
+ import { SignedCosmosTransaction } from './types/signed-transaction-cosmos';
8
+ import { UnsignedCosmosTransaction } from './types/transaction-cosmos';
9
+ import { SerializableUnsignedCosmosTransaction } from './types/unsigned-transaction-cosmos';
10
+ export { CosmosProtocol, CosmosCryptoClient, MintscanBlockExplorer, CosmosProtocolNetwork, CosmosProtocolConfig, CosmosProtocolOptions, CosmosUnbondingDelegation, CosmosValidator, CosmosDelegationActionType, CosmosAddress, CosmosTransaction, UnsignedCosmosTransaction, SignedCosmosTransaction, SerializableUnsignedCosmosTransaction };
package/v0/index.js ADDED
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosTransaction = exports.CosmosAddress = exports.CosmosDelegationActionType = exports.CosmosProtocolOptions = exports.CosmosProtocolConfig = exports.CosmosProtocolNetwork = exports.MintscanBlockExplorer = exports.CosmosCryptoClient = exports.CosmosProtocol = void 0;
4
+ var coinlib_core_1 = require("@airgap/coinlib-core");
5
+ var serializer_1 = require("@airgap/serializer");
6
+ var CosmosAddress_1 = require("./protocol/CosmosAddress");
7
+ Object.defineProperty(exports, "CosmosAddress", { enumerable: true, get: function () { return CosmosAddress_1.CosmosAddress; } });
8
+ var CosmosCryptoClient_1 = require("./protocol/CosmosCryptoClient");
9
+ Object.defineProperty(exports, "CosmosCryptoClient", { enumerable: true, get: function () { return CosmosCryptoClient_1.CosmosCryptoClient; } });
10
+ var CosmosProtocol_1 = require("./protocol/CosmosProtocol");
11
+ Object.defineProperty(exports, "CosmosDelegationActionType", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosDelegationActionType; } });
12
+ Object.defineProperty(exports, "CosmosProtocol", { enumerable: true, get: function () { return CosmosProtocol_1.CosmosProtocol; } });
13
+ var CosmosProtocolOptions_1 = require("./protocol/CosmosProtocolOptions");
14
+ Object.defineProperty(exports, "CosmosProtocolConfig", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolConfig; } });
15
+ Object.defineProperty(exports, "CosmosProtocolNetwork", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolNetwork; } });
16
+ Object.defineProperty(exports, "CosmosProtocolOptions", { enumerable: true, get: function () { return CosmosProtocolOptions_1.CosmosProtocolOptions; } });
17
+ Object.defineProperty(exports, "MintscanBlockExplorer", { enumerable: true, get: function () { return CosmosProtocolOptions_1.MintscanBlockExplorer; } });
18
+ var CosmosTransaction_1 = require("./protocol/CosmosTransaction");
19
+ Object.defineProperty(exports, "CosmosTransaction", { enumerable: true, get: function () { return CosmosTransaction_1.CosmosTransaction; } });
20
+ var transaction_validator_1 = require("./serializer/validators/transaction-validator");
21
+ // Serializer
22
+ function unsignedTransactionTransformer(value) {
23
+ value.transaction = CosmosTransaction_1.CosmosTransaction.fromJSON(value);
24
+ return value;
25
+ }
26
+ serializer_1.Serializer.addSchema(serializer_1.IACMessageType.TransactionSignRequest, { schema: require('./serializer/schemas/v2/transaction-sign-request-cosmos.json'), transformer: unsignedTransactionTransformer }, coinlib_core_1.MainProtocolSymbols.COSMOS);
27
+ serializer_1.Serializer.addSchema(serializer_1.IACMessageType.TransactionSignResponse, { schema: require('./serializer/schemas/v2/transaction-sign-response-cosmos.json') }, coinlib_core_1.MainProtocolSymbols.COSMOS);
28
+ serializer_1.SerializerV3.addSchema(serializer_1.IACMessageType.TransactionSignRequest, { schema: require('./serializer/schemas/v3/transaction-sign-request-cosmos.json'), transformer: unsignedTransactionTransformer }, coinlib_core_1.MainProtocolSymbols.COSMOS);
29
+ serializer_1.SerializerV3.addSchema(serializer_1.IACMessageType.TransactionSignResponse, { schema: require('./serializer/schemas/v3/transaction-sign-response-cosmos.json') }, coinlib_core_1.MainProtocolSymbols.COSMOS);
30
+ serializer_1.Serializer.addValidator(coinlib_core_1.MainProtocolSymbols.COSMOS, new transaction_validator_1.CosmosTransactionValidatorFactoryV2());
31
+ serializer_1.SerializerV3.addValidator(coinlib_core_1.MainProtocolSymbols.COSMOS, new transaction_validator_1.CosmosTransactionValidatorFactory());
32
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v0/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0D;AAC1D,iDAA6E;AAE7E,0DAAwD;AAqBtD,8FArBO,6BAAa,OAqBP;AApBf,oEAAkE;AAYhE,mGAZO,uCAAkB,OAYP;AAXpB,4DAAsF;AAkBpF,2GAlBO,2CAA0B,OAkBP;AAR1B,+FAVmC,+BAAc,OAUnC;AAThB,0EAA4I;AAa1I,qGAbO,4CAAoB,OAaP;AADpB,sGAZ6B,6CAAqB,OAY7B;AAErB,sGAdoD,6CAAqB,OAcpD;AAHrB,sGAX2E,6CAAqB,OAW3E;AAVvB,kEAAgE;AAkB9D,kGAlBO,qCAAiB,OAkBP;AAhBnB,uFAAsI;AAsBtI,aAAa;AAEb,SAAS,8BAA8B,CAAC,KAA4C;IAClF,KAAK,CAAC,WAAW,GAAG,qCAAiB,CAAC,QAAQ,CAAC,KAAK,CAAQ,CAAA;IAE5D,OAAO,KAAK,CAAA;AACd,CAAC;AAED,uBAAU,CAAC,SAAS,CAClB,2BAAc,CAAC,sBAAsB,EACrC,EAAE,MAAM,EAAE,OAAO,CAAC,8DAA8D,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,EAChI,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AACD,uBAAU,CAAC,SAAS,CAClB,2BAAc,CAAC,uBAAuB,EACtC,EAAE,MAAM,EAAE,OAAO,CAAC,+DAA+D,CAAC,EAAE,EACpF,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AAED,yBAAY,CAAC,SAAS,CACpB,2BAAc,CAAC,sBAAsB,EACrC,EAAE,MAAM,EAAE,OAAO,CAAC,8DAA8D,CAAC,EAAE,WAAW,EAAE,8BAA8B,EAAE,EAChI,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AACD,yBAAY,CAAC,SAAS,CACpB,2BAAc,CAAC,uBAAuB,EACtC,EAAE,MAAM,EAAE,OAAO,CAAC,+DAA+D,CAAC,EAAE,EACpF,kCAAmB,CAAC,MAAM,CAC3B,CAAA;AAED,uBAAU,CAAC,YAAY,CAAC,kCAAmB,CAAC,MAAM,EAAE,IAAI,2DAAmC,EAAE,CAAC,CAAA;AAC9F,yBAAY,CAAC,YAAY,CAAC,kCAAmB,CAAC,MAAM,EAAE,IAAI,yDAAiC,EAAE,CAAC,CAAA"}
@@ -0,0 +1,8 @@
1
+ import { IAirGapAddress } from '@airgap/coinlib-core/interfaces/IAirGapAddress';
2
+ export declare class CosmosAddress implements IAirGapAddress {
3
+ private readonly value;
4
+ private static readonly addressPrefix;
5
+ private constructor();
6
+ static from(publicKey: string): CosmosAddress;
7
+ asString(): string;
8
+ }
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosAddress = void 0;
4
+ // @ts-ignore
5
+ var BECH32 = require("@airgap/coinlib-core/dependencies/src/bech32-1.1.3/index");
6
+ // @ts-ignore
7
+ var RIPEMD160 = require("@airgap/coinlib-core/dependencies/src/ripemd160-2.0.2/index");
8
+ // @ts-ignore
9
+ var sha = require("@airgap/coinlib-core/dependencies/src/sha.js-2.4.11/index");
10
+ var CosmosAddress = /** @class */ (function () {
11
+ function CosmosAddress(value) {
12
+ this.value = value;
13
+ }
14
+ CosmosAddress.from = function (publicKey) {
15
+ var pubkey = Buffer.from(publicKey, 'hex');
16
+ var sha256Hash = sha('sha256').update(pubkey).digest();
17
+ var hash = new RIPEMD160().update(Buffer.from(sha256Hash)).digest();
18
+ var address = BECH32.encode(CosmosAddress.addressPrefix, BECH32.toWords(hash));
19
+ return new CosmosAddress(address);
20
+ };
21
+ CosmosAddress.prototype.asString = function () {
22
+ return this.value;
23
+ };
24
+ CosmosAddress.addressPrefix = 'cosmos';
25
+ return CosmosAddress;
26
+ }());
27
+ exports.CosmosAddress = CosmosAddress;
28
+ //# sourceMappingURL=CosmosAddress.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosAddress.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosAddress.ts"],"names":[],"mappings":";;;AAAA,aAAa;AACb,iFAAmF;AACnF,aAAa;AACb,uFAAyF;AACzF,aAAa;AACb,+EAAiF;AAGjF;IAGE,uBAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAExC,kBAAI,GAAlB,UAAmB,SAAiB;QAClC,IAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAE5C,IAAM,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,CAAA;QAChE,IAAM,IAAI,GAAG,IAAI,SAAS,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;QACrE,IAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,aAAa,EAAE,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAA;QAEhF,OAAO,IAAI,aAAa,CAAC,OAAO,CAAC,CAAA;IACnC,CAAC;IAEM,gCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IAhBuB,2BAAa,GAAW,QAAQ,CAAA;IAiB1D,oBAAC;CAAA,AAlBD,IAkBC;AAlBY,sCAAa"}
@@ -0,0 +1,19 @@
1
+ import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
+ import { JSONConvertible } from '@airgap/coinlib-core/interfaces/JSONConvertible';
3
+ import { RPCConvertible } from '@airgap/coinlib-core/interfaces/RPCConvertible';
4
+ export interface CosmosCoinJSON {
5
+ denom: string;
6
+ amount: string;
7
+ }
8
+ export declare class CosmosCoin implements JSONConvertible, RPCConvertible {
9
+ private static readonly supportedDenominations;
10
+ readonly denom: string;
11
+ readonly amount: string;
12
+ constructor(denom: string, amount: string);
13
+ toJSON(): CosmosCoinJSON;
14
+ static fromJSON(json: CosmosCoinJSON): CosmosCoin;
15
+ static fromCoins(json: CosmosCoinJSON[]): CosmosCoin[];
16
+ static sum(coins: CosmosCoin[]): BigNumber;
17
+ toRPCBody(): any;
18
+ static fromRPCBody(json: any): CosmosCoin;
19
+ }
@@ -0,0 +1,55 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.CosmosCoin = void 0;
7
+ var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
8
+ var errors_1 = require("@airgap/coinlib-core/errors");
9
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
10
+ var CosmosCoin = /** @class */ (function () {
11
+ function CosmosCoin(denom, amount) {
12
+ this.denom = denom;
13
+ this.amount = amount;
14
+ }
15
+ CosmosCoin.prototype.toJSON = function () {
16
+ return {
17
+ amount: this.amount,
18
+ denom: this.denom
19
+ };
20
+ };
21
+ CosmosCoin.fromJSON = function (json) {
22
+ if (!CosmosCoin.supportedDenominations.includes(json.denom)) {
23
+ throw new errors_1.UnsupportedError(coinlib_error_1.Domain.COSMOS, 'Unsupported cosmos denomination');
24
+ }
25
+ return new CosmosCoin(json.denom, json.amount);
26
+ };
27
+ CosmosCoin.fromCoins = function (json) {
28
+ return json
29
+ .map(function (coinJSON) {
30
+ try {
31
+ return CosmosCoin.fromJSON(coinJSON);
32
+ }
33
+ catch (_a) {
34
+ return undefined;
35
+ }
36
+ })
37
+ .filter(function (value) { return value !== undefined; });
38
+ };
39
+ CosmosCoin.sum = function (coins) {
40
+ return coins.reduce(function (current, next) { return current.plus(new bignumber_1.default(next.amount)); }, new bignumber_1.default(0));
41
+ };
42
+ CosmosCoin.prototype.toRPCBody = function () {
43
+ return {
44
+ amount: this.amount,
45
+ denom: this.denom
46
+ };
47
+ };
48
+ CosmosCoin.fromRPCBody = function (json) {
49
+ return new CosmosCoin(json.denom, json.amount);
50
+ };
51
+ CosmosCoin.supportedDenominations = ['uatom'];
52
+ return CosmosCoin;
53
+ }());
54
+ exports.CosmosCoin = CosmosCoin;
55
+ //# sourceMappingURL=CosmosCoin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosCoin.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosCoin.ts"],"names":[],"mappings":";;;;;;AAAA,iHAA0F;AAC1F,sDAA8D;AAC9D,2EAAkE;AASlE;IAKE,oBAAY,KAAa,EAAE,MAAc;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,2BAAM,GAAb;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAEa,mBAAQ,GAAtB,UAAuB,IAAoB;QACzC,IAAI,CAAC,UAAU,CAAC,sBAAsB,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;YAC3D,MAAM,IAAI,yBAAgB,CAAC,sBAAM,CAAC,MAAM,EAAE,iCAAiC,CAAC,CAAA;SAC7E;QAED,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAEa,oBAAS,GAAvB,UAAwB,IAAsB;QAC5C,OAAO,IAAI;aACR,GAAG,CAAC,UAAC,QAAQ;YACZ,IAAI;gBACF,OAAO,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;aACrC;YAAC,WAAM;gBACN,OAAO,SAAS,CAAA;aACjB;QACH,CAAC,CAAC;aACD,MAAM,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,KAAK,SAAS,EAAnB,CAAmB,CAAiB,CAAA;IAC3D,CAAC;IAEa,cAAG,GAAjB,UAAkB,KAAmB;QACnC,OAAO,KAAK,CAAC,MAAM,CAAC,UAAC,OAAO,EAAE,IAAI,IAAK,OAAA,OAAO,CAAC,IAAI,CAAC,IAAI,mBAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,EAAxC,CAAwC,EAAE,IAAI,mBAAS,CAAC,CAAC,CAAC,CAAC,CAAA;IACpG,CAAC;IAEM,8BAAS,GAAhB;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,KAAK,EAAE,IAAI,CAAC,KAAK;SAClB,CAAA;IACH,CAAC;IAEa,sBAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAA;IAChD,CAAC;IAjDuB,iCAAsB,GAAG,CAAC,OAAO,CAAC,CAAA;IAkD5D,iBAAC;CAAA,AAnDD,IAmDC;AAnDY,gCAAU"}
@@ -0,0 +1,8 @@
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
+ }
@@ -0,0 +1,90 @@
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.slice(2), '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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosCryptoClient.js","sourceRoot":"","sources":["../../../src/v0/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,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;gBACxE,IAAI,GAAW,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBACtC,MAAM,GAA0B,SAAS,CAAC,IAAI,CAAC,IAAI,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC,CAAA;gBAElG,sBAAO,YAAK,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAE,EAAA;;;KAC5D;IAEY,0CAAa,GAA1B,UAA2B,OAAe,EAAE,SAAiB,EAAE,SAAiB;;;;gBACxE,YAAY,GAAW,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAA;gBAE7D,UAAU,GAAW,GAAG,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,EAAE,CAAA;gBACxE,WAAW,GAAW,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;gBAEnD,sBAAO,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE,YAAY,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC,EAAA;;;KAClF;IACH,yBAAC;AAAD,CAAC,AArBD,CAAwC,6CAAqB,GAqB5D;AArBY,gDAAkB"}
@@ -0,0 +1,15 @@
1
+ import { JSONConvertible } from '@airgap/coinlib-core/interfaces/JSONConvertible';
2
+ import { RPCConvertible } from '@airgap/coinlib-core/interfaces/RPCConvertible';
3
+ import { CosmosCoin } from './CosmosCoin';
4
+ export declare class CosmosFee implements JSONConvertible, RPCConvertible {
5
+ readonly amount: CosmosCoin[];
6
+ readonly gas: string;
7
+ constructor(amount: CosmosCoin[], gas: string);
8
+ toJSON(): {
9
+ amount: import("./CosmosCoin").CosmosCoinJSON[];
10
+ gas: string;
11
+ };
12
+ static fromJSON(json: any): CosmosFee;
13
+ toRPCBody(): any;
14
+ static fromRPCBody(json: any): CosmosFee;
15
+ }
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosFee = void 0;
4
+ var CosmosCoin_1 = require("./CosmosCoin");
5
+ var CosmosFee = /** @class */ (function () {
6
+ function CosmosFee(amount, gas) {
7
+ this.amount = amount;
8
+ this.gas = gas;
9
+ }
10
+ CosmosFee.prototype.toJSON = function () {
11
+ return {
12
+ amount: this.amount.map(function (value) { return value.toJSON(); }),
13
+ gas: this.gas
14
+ };
15
+ };
16
+ CosmosFee.fromJSON = function (json) {
17
+ return new CosmosFee(json.amount.map(function (value) { return CosmosCoin_1.CosmosCoin.fromJSON(value); }), json.gas);
18
+ };
19
+ CosmosFee.prototype.toRPCBody = function () {
20
+ return {
21
+ amount: this.amount.map(function (value) { return value.toRPCBody(); }),
22
+ gas: this.gas
23
+ };
24
+ };
25
+ CosmosFee.fromRPCBody = function (json) {
26
+ return new CosmosFee(json.amount.map(function (value) { return CosmosCoin_1.CosmosCoin.fromRPCBody(value); }), json.gas);
27
+ };
28
+ return CosmosFee;
29
+ }());
30
+ exports.CosmosFee = CosmosFee;
31
+ //# sourceMappingURL=CosmosFee.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosFee.js","sourceRoot":"","sources":["../../../src/v0/protocol/CosmosFee.ts"],"names":[],"mappings":";;;AAEA,2CAAyC;AAEzC;IAIE,mBAAY,MAAoB,EAAE,GAAW;QAC3C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;IAChB,CAAC;IAEM,0BAAM,GAAb;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,EAAE,EAAd,CAAc,CAAC;YAClD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IACH,CAAC;IAEa,kBAAQ,GAAtB,UAAuB,IAAS;QAC9B,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAU,IAAK,OAAA,uBAAU,CAAC,QAAQ,CAAC,KAAK,CAAC,EAA1B,CAA0B,CAAC,EAC3D,IAAI,CAAC,GAAG,CACT,CAAA;IACH,CAAC;IAEM,6BAAS,GAAhB;QACE,OAAO;YACL,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,SAAS,EAAE,EAAjB,CAAiB,CAAC;YACrD,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IACH,CAAC;IAEa,qBAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,SAAS,CAClB,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAU,IAAK,OAAA,uBAAU,CAAC,WAAW,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,EAC9D,IAAI,CAAC,GAAG,CACT,CAAA;IACH,CAAC;IACH,gBAAC;AAAD,CAAC,AApCD,IAoCC;AApCY,8BAAS"}
@@ -0,0 +1,25 @@
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 './CosmosTypes';
3
+ export declare class CosmosNodeClient {
4
+ readonly baseURL: string;
5
+ useCORSProxy: boolean;
6
+ constructor(baseURL: string, useCORSProxy?: boolean);
7
+ fetchBalance(address: string, totalBalance?: boolean): Promise<BigNumber>;
8
+ fetchSendTransactionsFor(address: string, limit: number, offset: number, isSender?: boolean): Promise<CosmosPagedSendTxsResponse>;
9
+ fetchNodeInfo(): Promise<CosmosNodeInfo>;
10
+ broadcastSignedTransaction(tx_bytes: string): Promise<string>;
11
+ fetchAccount(address: string): Promise<CosmosAccount>;
12
+ fetchDelegations(address: string, filterEmpty?: boolean): Promise<CosmosDelegation[]>;
13
+ fetchTotalDelegatedAmount(address: string): Promise<BigNumber>;
14
+ fetchValidator(address: string): Promise<CosmosValidator>;
15
+ fetchValidators(): Promise<CosmosValidator[]>;
16
+ fetchSelfDelegation(validatorAddress: string): Promise<CosmosDelegation>;
17
+ fetchUnbondingDelegations(delegatorAddress: string): Promise<CosmosUnbondingDelegation[]>;
18
+ fetchTotalUnbondingAmount(address: string): Promise<BigNumber>;
19
+ fetchRewardDetails(delegatorAddress: string): Promise<CosmosRewardDetails[]>;
20
+ fetchTotalReward(delegatorAddress: string): Promise<BigNumber>;
21
+ fetchRewardForDelegation(delegatorAddress: string, validatorAddress: string): Promise<BigNumber>;
22
+ withdrawAllDelegationRewards(delegatorAddress: string, chainID: string, accountNumber: string, sequence: string, gas: BigNumber, fee: BigNumber, memo: string, simulate?: boolean): Promise<string>;
23
+ withdrawDelegationRewards(delegatorAddress: string, validatorAdress: string, chainID: string, accountNumber: string, sequence: string, gas: BigNumber, fee: BigNumber, memo: string, simulate?: boolean): Promise<string>;
24
+ private url;
25
+ }