@airgap/cosmos 0.13.7-beta.21 → 0.13.7-beta.23

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 (154) hide show
  1. package/airgap-coinlib-cosmos.min.js +32425 -18722
  2. package/index.d.ts +1 -10
  3. package/index.js +15 -15
  4. package/index.js.map +1 -1
  5. package/package.json +4 -2
  6. package/v0/index.d.ts +10 -0
  7. package/v0/index.js +32 -0
  8. package/v0/index.js.map +1 -0
  9. package/{protocol → v0/protocol}/CosmosAddress.d.ts +0 -0
  10. package/{protocol → v0/protocol}/CosmosAddress.js +0 -0
  11. package/v0/protocol/CosmosAddress.js.map +1 -0
  12. package/{protocol → v0/protocol}/CosmosCoin.d.ts +0 -0
  13. package/{protocol → v0/protocol}/CosmosCoin.js +0 -0
  14. package/v0/protocol/CosmosCoin.js.map +1 -0
  15. package/{protocol → v0/protocol}/CosmosCryptoClient.d.ts +0 -0
  16. package/{protocol → v0/protocol}/CosmosCryptoClient.js +3 -1
  17. package/v0/protocol/CosmosCryptoClient.js.map +1 -0
  18. package/{protocol → v0/protocol}/CosmosFee.d.ts +0 -0
  19. package/{protocol → v0/protocol}/CosmosFee.js +0 -0
  20. package/v0/protocol/CosmosFee.js.map +1 -0
  21. package/{protocol → v0/protocol}/CosmosNodeClient.d.ts +0 -0
  22. package/{protocol → v0/protocol}/CosmosNodeClient.js +15 -15
  23. package/v0/protocol/CosmosNodeClient.js.map +1 -0
  24. package/{protocol → v0/protocol}/CosmosProtocol.d.ts +0 -0
  25. package/{protocol → v0/protocol}/CosmosProtocol.js +22 -20
  26. package/v0/protocol/CosmosProtocol.js.map +1 -0
  27. package/{protocol → v0/protocol}/CosmosProtocolOptions.d.ts +0 -0
  28. package/{protocol → v0/protocol}/CosmosProtocolOptions.js +4 -2
  29. package/v0/protocol/CosmosProtocolOptions.js.map +1 -0
  30. package/{protocol → v0/protocol}/CosmosTransaction.d.ts +0 -0
  31. package/{protocol → v0/protocol}/CosmosTransaction.js +0 -0
  32. package/v0/protocol/CosmosTransaction.js.map +1 -0
  33. package/{protocol → v0/protocol}/CosmosTypes.d.ts +0 -0
  34. package/{protocol → v0/protocol}/CosmosTypes.js +0 -0
  35. package/v0/protocol/CosmosTypes.js.map +1 -0
  36. package/{protocol → v0/protocol}/cosmos-message/CosmosDelegateMessage.d.ts +0 -0
  37. package/{protocol → v0/protocol}/cosmos-message/CosmosDelegateMessage.js +0 -0
  38. package/v0/protocol/cosmos-message/CosmosDelegateMessage.js.map +1 -0
  39. package/{protocol → v0/protocol}/cosmos-message/CosmosMessage.d.ts +0 -0
  40. package/{protocol → v0/protocol}/cosmos-message/CosmosMessage.js +0 -0
  41. package/v0/protocol/cosmos-message/CosmosMessage.js.map +1 -0
  42. package/{protocol → v0/protocol}/cosmos-message/CosmosSendMessage.d.ts +0 -0
  43. package/{protocol → v0/protocol}/cosmos-message/CosmosSendMessage.js +9 -7
  44. package/v0/protocol/cosmos-message/CosmosSendMessage.js.map +1 -0
  45. package/{protocol → v0/protocol}/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +0 -0
  46. package/{protocol → v0/protocol}/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +0 -0
  47. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
  48. package/v0/serializer/schemas/v2/transaction-sign-request-cosmos.json +100 -0
  49. package/v0/serializer/schemas/v2/transaction-sign-response-cosmos.json +22 -0
  50. package/v0/serializer/schemas/v3/transaction-sign-request-cosmos.json +100 -0
  51. package/v0/serializer/schemas/v3/transaction-sign-response-cosmos.json +19 -0
  52. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  53. package/v0/serializer/validators/transaction-validator.js +112 -0
  54. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  55. package/v0/types/signed-transaction-cosmos.d.ts +5 -0
  56. package/{types → v0/types}/signed-transaction-cosmos.js +0 -0
  57. package/v0/types/signed-transaction-cosmos.js.map +1 -0
  58. package/{types → v0/types}/transaction-cosmos.d.ts +0 -0
  59. package/{types → v0/types}/transaction-cosmos.js +0 -0
  60. package/v0/types/transaction-cosmos.js.map +1 -0
  61. package/{types → v0/types}/unsigned-transaction-cosmos.d.ts +2 -2
  62. package/{types → v0/types}/unsigned-transaction-cosmos.js +0 -0
  63. package/v0/types/unsigned-transaction-cosmos.js.map +1 -0
  64. package/v1/block-explorer/MintscanBlockExplorer.d.ts +9 -0
  65. package/v1/block-explorer/MintscanBlockExplorer.js +74 -0
  66. package/v1/block-explorer/MintscanBlockExplorer.js.map +1 -0
  67. package/v1/data/CosmosAddress.d.ts +7 -0
  68. package/v1/data/CosmosAddress.js +26 -0
  69. package/v1/data/CosmosAddress.js.map +1 -0
  70. package/v1/data/CosmosCoin.d.ts +19 -0
  71. package/v1/data/CosmosCoin.js +55 -0
  72. package/v1/data/CosmosCoin.js.map +1 -0
  73. package/v1/data/CosmosFee.d.ts +15 -0
  74. package/v1/data/CosmosFee.js +31 -0
  75. package/v1/data/CosmosFee.js.map +1 -0
  76. package/v1/data/transaction/CosmosTransaction.d.ts +36 -0
  77. package/v1/data/transaction/CosmosTransaction.js +107 -0
  78. package/v1/data/transaction/CosmosTransaction.js.map +1 -0
  79. package/v1/data/transaction/message/CosmosDelegateMessage.d.ts +19 -0
  80. package/v1/data/transaction/message/CosmosDelegateMessage.js +70 -0
  81. package/v1/data/transaction/message/CosmosDelegateMessage.js.map +1 -0
  82. package/v1/data/transaction/message/CosmosMessage.d.ts +38 -0
  83. package/v1/data/transaction/message/CosmosMessage.js +47 -0
  84. package/v1/data/transaction/message/CosmosMessage.js.map +1 -0
  85. package/v1/data/transaction/message/CosmosSendMessage.d.ts +19 -0
  86. package/v1/data/transaction/message/CosmosSendMessage.js +83 -0
  87. package/v1/data/transaction/message/CosmosSendMessage.js.map +1 -0
  88. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.d.ts +23 -0
  89. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js +61 -0
  90. package/v1/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
  91. package/v1/index.d.ts +9 -0
  92. package/v1/index.js +11 -0
  93. package/v1/index.js.map +1 -0
  94. package/v1/module/CosmosModule.d.ts +8 -0
  95. package/v1/module/CosmosModule.js +86 -0
  96. package/v1/module/CosmosModule.js.map +1 -0
  97. package/v1/node/CosmosNodeClient.d.ts +28 -0
  98. package/v1/node/CosmosNodeClient.js +381 -0
  99. package/v1/node/CosmosNodeClient.js.map +1 -0
  100. package/v1/protocol/CosmosCryptoClient.d.ts +8 -0
  101. package/v1/protocol/CosmosCryptoClient.js +88 -0
  102. package/v1/protocol/CosmosCryptoClient.js.map +1 -0
  103. package/v1/protocol/CosmosProtocol.d.ts +50 -0
  104. package/v1/protocol/CosmosProtocol.js +658 -0
  105. package/v1/protocol/CosmosProtocol.js.map +1 -0
  106. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
  107. package/v1/serializer/v3/schemas/converter/transaction-converter.js +21 -0
  108. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  109. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.d.ts +4 -0
  110. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js +3 -0
  111. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js.map +1 -0
  112. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.d.ts +3 -0
  113. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js +3 -0
  114. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js.map +1 -0
  115. package/v1/serializer/v3/schemas/generated/transaction-sign-request-cosmos.json +107 -0
  116. package/v1/serializer/v3/schemas/generated/transaction-sign-response-cosmos.json +19 -0
  117. package/v1/serializer/v3/validators/transaction-validators.d.ts +10 -0
  118. package/v1/serializer/v3/validators/transaction-validators.js +97 -0
  119. package/v1/serializer/v3/validators/transaction-validators.js.map +1 -0
  120. package/v1/types/protocol.d.ts +8 -0
  121. package/v1/types/protocol.js +3 -0
  122. package/v1/types/protocol.js.map +1 -0
  123. package/v1/types/rpc.d.ts +286 -0
  124. package/v1/types/rpc.js +3 -0
  125. package/v1/types/rpc.js.map +1 -0
  126. package/v1/types/transaction.d.ts +44 -0
  127. package/v1/types/transaction.js +10 -0
  128. package/v1/types/transaction.js.map +1 -0
  129. package/v1/utils/key.d.ts +3 -0
  130. package/v1/utils/key.js +20 -0
  131. package/v1/utils/key.js.map +1 -0
  132. package/v1/utils/signature.d.ts +2 -0
  133. package/v1/utils/signature.js +13 -0
  134. package/v1/utils/signature.js.map +1 -0
  135. package/v1/utils/transaction.d.ts +1 -0
  136. package/v1/utils/transaction.js +8 -0
  137. package/v1/utils/transaction.js.map +1 -0
  138. package/protocol/CosmosAddress.js.map +0 -1
  139. package/protocol/CosmosCoin.js.map +0 -1
  140. package/protocol/CosmosCryptoClient.js.map +0 -1
  141. package/protocol/CosmosFee.js.map +0 -1
  142. package/protocol/CosmosNodeClient.js.map +0 -1
  143. package/protocol/CosmosProtocol.js.map +0 -1
  144. package/protocol/CosmosProtocolOptions.js.map +0 -1
  145. package/protocol/CosmosTransaction.js.map +0 -1
  146. package/protocol/CosmosTypes.js.map +0 -1
  147. package/protocol/cosmos-message/CosmosDelegateMessage.js.map +0 -1
  148. package/protocol/cosmos-message/CosmosMessage.js.map +0 -1
  149. package/protocol/cosmos-message/CosmosSendMessage.js.map +0 -1
  150. package/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +0 -1
  151. package/types/signed-transaction-cosmos.d.ts +0 -6
  152. package/types/signed-transaction-cosmos.js.map +0 -1
  153. package/types/transaction-cosmos.js.map +0 -1
  154. package/types/unsigned-transaction-cosmos.js.map +0 -1
@@ -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/v1/data/CosmosCoin.ts"],"names":[],"mappings":";;;;;;AAAA,iH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,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,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/v1/data/CosmosFee.ts"],"names":[],"mappings":";;;AAGA,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,36 @@
1
+ import { EncodeObject } from '@airgap/coinlib-core/dependencies/src/cosmjs';
2
+ import { JSONConvertible } from '@airgap/coinlib-core/interfaces/JSONConvertible';
3
+ import { RPCConvertible } from '@airgap/coinlib-core/interfaces/RPCConvertible';
4
+ import { AirGapTransaction } from '@airgap/module-kit';
5
+ import { CosmosProtocolNetwork, CosmosUnits } from '../../types/protocol';
6
+ import { CosmosUnsignedTransaction } from '../../types/transaction';
7
+ import { CosmosFee } from '../CosmosFee';
8
+ import { CosmosMessage } from './message/CosmosMessage';
9
+ export interface Encodable {
10
+ toEncodeObject(): EncodeObject;
11
+ }
12
+ export declare class CosmosTransaction implements JSONConvertible, RPCConvertible, Encodable {
13
+ readonly messages: CosmosMessage[];
14
+ readonly fee: CosmosFee;
15
+ readonly memo: string;
16
+ readonly chainID: string;
17
+ readonly accountNumber: string;
18
+ readonly sequence: string;
19
+ constructor(messages: CosmosMessage[], fee: CosmosFee, memo: string, chainID: string, accountNumber: string, sequence: string);
20
+ toJSON(): {
21
+ accountNumber: string;
22
+ chainID: string;
23
+ fee: {
24
+ amount: import("../CosmosCoin").CosmosCoinJSON[];
25
+ gas: string;
26
+ };
27
+ memo: string;
28
+ messages: import("./message/CosmosMessage").CosmosMessageJSON[];
29
+ sequence: string;
30
+ };
31
+ toRPCBody(): any;
32
+ toEncodeObject(): EncodeObject;
33
+ toAirGapTransactions(network: CosmosProtocolNetwork): AirGapTransaction<CosmosUnits>[];
34
+ static fromJSON(json: CosmosUnsignedTransaction): CosmosTransaction;
35
+ static fromRPCBody(json: any): CosmosTransaction;
36
+ }
@@ -0,0 +1,107 @@
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.CosmosTransaction = 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 CosmosFee_1 = require("../CosmosFee");
11
+ var CosmosDelegateMessage_1 = require("./message/CosmosDelegateMessage");
12
+ var CosmosMessage_1 = require("./message/CosmosMessage");
13
+ var CosmosSendMessage_1 = require("./message/CosmosSendMessage");
14
+ var CosmosWithdrawDelegationRewardMessage_1 = require("./message/CosmosWithdrawDelegationRewardMessage");
15
+ var CosmosTransaction = /** @class */ (function () {
16
+ function CosmosTransaction(messages, fee, memo, chainID, accountNumber, sequence) {
17
+ this.messages = messages;
18
+ this.fee = fee;
19
+ this.memo = memo;
20
+ this.chainID = chainID;
21
+ this.accountNumber = accountNumber;
22
+ this.sequence = sequence;
23
+ }
24
+ CosmosTransaction.prototype.toJSON = function () {
25
+ return {
26
+ accountNumber: this.accountNumber,
27
+ chainID: this.chainID,
28
+ fee: this.fee.toJSON(),
29
+ memo: this.memo,
30
+ messages: this.messages.map(function (value) { return value.toJSON(); }),
31
+ sequence: this.sequence
32
+ };
33
+ };
34
+ CosmosTransaction.prototype.toRPCBody = function () {
35
+ return {
36
+ account_number: this.accountNumber,
37
+ chain_id: this.chainID,
38
+ fee: this.fee.toRPCBody(),
39
+ memo: this.memo,
40
+ msgs: this.messages.map(function (value) { return value.toRPCBody(); }),
41
+ sequence: this.sequence
42
+ };
43
+ };
44
+ CosmosTransaction.prototype.toEncodeObject = function () {
45
+ return {
46
+ typeUrl: '/cosmos.tx.v1beta1.TxBody',
47
+ value: {
48
+ messages: this.messages.map(function (msg) { return msg.toEncodeObject(); }),
49
+ memo: this.memo
50
+ }
51
+ };
52
+ };
53
+ CosmosTransaction.prototype.toAirGapTransactions = function (network) {
54
+ var _this = this;
55
+ var fee = this.fee.amount.map(function (value) { return new bignumber_1.default(value.amount); }).reduce(function (prev, next) { return prev.plus(next); });
56
+ return this.messages
57
+ .map(function (message) { return message.toAirGapTransaction(network, fee.toString(10)); })
58
+ .map(function (tx) {
59
+ if (!tx.json) {
60
+ tx.json = {};
61
+ }
62
+ tx.json.accountNumber = _this.accountNumber;
63
+ tx.json.chainID = _this.chainID;
64
+ tx.json.memo = _this.memo;
65
+ tx.json.sequence = _this.sequence;
66
+ tx.arbitraryData = _this.memo;
67
+ return tx;
68
+ });
69
+ };
70
+ CosmosTransaction.fromJSON = function (json) {
71
+ var messages = json.messages.map(function (value) {
72
+ var type = value.type;
73
+ switch (type) {
74
+ case CosmosMessage_1.CosmosMessageType.Send.index:
75
+ return CosmosSendMessage_1.CosmosSendMessage.fromJSON(value);
76
+ case CosmosMessage_1.CosmosMessageType.Delegate.index:
77
+ case CosmosMessage_1.CosmosMessageType.Undelegate.index:
78
+ return CosmosDelegateMessage_1.CosmosDelegateMessage.fromJSON(value);
79
+ case CosmosMessage_1.CosmosMessageType.WithdrawDelegationReward.index:
80
+ return CosmosWithdrawDelegationRewardMessage_1.CosmosWithdrawDelegationRewardMessage.fromJSON(value);
81
+ default:
82
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.COSMOS, 'Unknown message');
83
+ }
84
+ });
85
+ return new CosmosTransaction(messages, CosmosFee_1.CosmosFee.fromJSON(json.fee), json.memo, json.chainID, json.accountNumber, json.sequence);
86
+ };
87
+ CosmosTransaction.fromRPCBody = function (json) {
88
+ var messages = json.msgs.map(function (value) {
89
+ var type = value.type;
90
+ switch (type) {
91
+ case CosmosMessage_1.CosmosMessageType.Send.value:
92
+ return CosmosSendMessage_1.CosmosSendMessage.fromRPCBody(value);
93
+ case CosmosMessage_1.CosmosMessageType.Delegate.value:
94
+ case CosmosMessage_1.CosmosMessageType.Undelegate.value:
95
+ return CosmosDelegateMessage_1.CosmosDelegateMessage.fromRPCBody(value);
96
+ case CosmosMessage_1.CosmosMessageType.WithdrawDelegationReward.value:
97
+ return CosmosWithdrawDelegationRewardMessage_1.CosmosWithdrawDelegationRewardMessage.fromRPCBody(value);
98
+ default:
99
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.COSMOS, 'Unknown message');
100
+ }
101
+ });
102
+ return new CosmosTransaction(messages, CosmosFee_1.CosmosFee.fromRPCBody(json.fee), json.memo, json.chain_id, json.account_number, json.sequence);
103
+ };
104
+ return CosmosTransaction;
105
+ }());
106
+ exports.CosmosTransaction = CosmosTransaction;
107
+ //# sourceMappingURL=CosmosTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosTransaction.js","sourceRoot":"","sources":["../../../../src/v1/data/transaction/CosmosTransaction.ts"],"names":[],"mappings":";;;;;;AAAA,iHAA0F;AAE1F,sDAA+D;AAC/D,2EAAkE;AAOlE,0CAAwC;AAExC,yEAAuE;AACvE,yDAAkG;AAClG,iEAA+D;AAC/D,yGAAuG;AAMvG;IAQE,2BAAY,QAAyB,EAAE,GAAc,EAAE,IAAY,EAAE,OAAe,EAAE,aAAqB,EAAE,QAAgB;QAC3H,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;QACxB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAA;QACd,IAAI,CAAC,IAAI,GAAG,IAAI,CAAA;QAChB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;QACtB,IAAI,CAAC,aAAa,GAAG,aAAa,CAAA;QAClC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;IAEM,kCAAM,GAAb;QACE,OAAO;YACL,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,MAAM,EAAE;YACtB,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,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GapTransaction } from '@airgap/module-kit';
3
+ import { CosmosProtocolNetwork, CosmosUnits } from '../../../types/protocol';
4
+ import { CosmosCoin } from '../../CosmosCoin';
5
+ import { CosmosMessage, CosmosMessageJSON, CosmosMessageType } from './CosmosMessage';
6
+ export declare class CosmosDelegateMessage implements CosmosMessage {
7
+ readonly delegatorAddress: string;
8
+ readonly validatorAddress: string;
9
+ readonly amount: CosmosCoin;
10
+ readonly type: CosmosMessageType;
11
+ constructor(delegatorAddress: string, validatorAddress: string, amount: CosmosCoin, undelegate?: boolean);
12
+ toEncodeObject(): EncodeObject;
13
+ static fromEncodeObject(encodeObject: EncodeObject): CosmosDelegateMessage;
14
+ toJSON(): CosmosMessageJSON;
15
+ static fromJSON(json: CosmosMessageJSON): CosmosDelegateMessage;
16
+ toRPCBody(): any;
17
+ toAirGapTransaction(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<CosmosUnits>;
18
+ static fromRPCBody(json: any): CosmosDelegateMessage;
19
+ }
@@ -0,0 +1,70 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosDelegateMessage = void 0;
4
+ var IAirGapTransaction_1 = require("@airgap/coinlib-core/interfaces/IAirGapTransaction");
5
+ var module_kit_1 = require("@airgap/module-kit");
6
+ var CosmosCoin_1 = require("../../CosmosCoin");
7
+ var CosmosMessage_1 = require("./CosmosMessage");
8
+ var CosmosDelegateMessage = /** @class */ (function () {
9
+ function CosmosDelegateMessage(delegatorAddress, validatorAddress, amount, undelegate) {
10
+ if (undelegate === void 0) { undelegate = false; }
11
+ this.delegatorAddress = delegatorAddress;
12
+ this.validatorAddress = validatorAddress;
13
+ this.amount = amount;
14
+ this.type = undelegate ? CosmosMessage_1.CosmosMessageType.Undelegate : CosmosMessage_1.CosmosMessageType.Delegate;
15
+ }
16
+ CosmosDelegateMessage.prototype.toEncodeObject = function () {
17
+ return {
18
+ typeUrl: this.type.value,
19
+ value: {
20
+ delegatorAddress: this.delegatorAddress,
21
+ validatorAddress: this.validatorAddress,
22
+ amount: this.amount
23
+ }
24
+ };
25
+ };
26
+ CosmosDelegateMessage.fromEncodeObject = function (encodeObject) {
27
+ var _a, _b, _c, _d;
28
+ var undelegate = encodeObject.typeUrl === CosmosMessage_1.CosmosMessageType.Undelegate.value;
29
+ return new CosmosDelegateMessage(encodeObject.value.delegatorAddress, encodeObject.value.validatorAddress, new CosmosCoin_1.CosmosCoin((_b = (_a = encodeObject.value.amount) === null || _a === void 0 ? void 0 : _a.denom) !== null && _b !== void 0 ? _b : 'uatom', (_d = (_c = encodeObject.value.amount) === null || _c === void 0 ? void 0 : _c.amount) !== null && _d !== void 0 ? _d : '0'), undelegate);
30
+ };
31
+ CosmosDelegateMessage.prototype.toJSON = function () {
32
+ return {
33
+ type: this.type.index,
34
+ amount: [this.amount.toJSON()],
35
+ fromAddress: this.delegatorAddress,
36
+ toAddress: this.validatorAddress
37
+ };
38
+ };
39
+ CosmosDelegateMessage.fromJSON = function (json) {
40
+ return new CosmosDelegateMessage(json.fromAddress, json.toAddress, CosmosCoin_1.CosmosCoin.fromJSON(json.amount[0]), json.type === CosmosMessage_1.CosmosMessageType.Undelegate.index);
41
+ };
42
+ CosmosDelegateMessage.prototype.toRPCBody = function () {
43
+ return {
44
+ type: this.type.value,
45
+ value: {
46
+ amount: this.amount.toRPCBody(),
47
+ delegator_address: this.delegatorAddress,
48
+ validator_address: this.validatorAddress
49
+ }
50
+ };
51
+ };
52
+ CosmosDelegateMessage.prototype.toAirGapTransaction = function (network, fee) {
53
+ return {
54
+ from: [this.delegatorAddress],
55
+ to: [this.validatorAddress],
56
+ isInbound: false,
57
+ amount: (0, module_kit_1.newAmount)(this.amount.amount, 'blockchain'),
58
+ fee: (0, module_kit_1.newAmount)(fee, 'blockchain'),
59
+ network: network,
60
+ type: this.type.index === CosmosMessage_1.CosmosMessageTypeIndex.DELEGATE ? IAirGapTransaction_1.AirGapTransactionType.DELEGATE : IAirGapTransaction_1.AirGapTransactionType.UNDELEGATE,
61
+ json: this.toRPCBody()
62
+ };
63
+ };
64
+ CosmosDelegateMessage.fromRPCBody = function (json) {
65
+ return new CosmosDelegateMessage(json.value.delegator_address, json.value.validator_address, CosmosCoin_1.CosmosCoin.fromRPCBody(json.value.amount), json.type === CosmosMessage_1.CosmosMessageType.Undelegate.value);
66
+ };
67
+ return CosmosDelegateMessage;
68
+ }());
69
+ exports.CosmosDelegateMessage = CosmosDelegateMessage;
70
+ //# sourceMappingURL=CosmosDelegateMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosDelegateMessage.js","sourceRoot":"","sources":["../../../../../src/v1/data/transaction/message/CosmosDelegateMessage.ts"],"names":[],"mappings":";;;AACA,yFAA0F;AAC1F,iDAAiE;AAGjE,+CAA6C;AAE7C,iDAA6G;AAE7G;IAOE,+BAAY,gBAAwB,EAAE,gBAAwB,EAAE,MAAkB,EAAE,UAA2B;QAA3B,2BAAA,EAAA,kBAA2B;QAC7G,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;QACpB,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC,iCAAiB,CAAC,UAAU,CAAC,CAAC,CAAC,iCAAiB,CAAC,QAAQ,CAAA;IACpF,CAAC;IAEM,8CAAc,GAArB;QACE,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACxB,KAAK,EAAE;gBACL,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,gBAAgB,EAAE,IAAI,CAAC,gBAAgB;gBACvC,MAAM,EAAE,IAAI,CAAC,MAAM;aACpB;SACF,CAAA;IACH,CAAC;IAEa,sCAAgB,GAA9B,UAA+B,YAA0B;;QACvD,IAAM,UAAU,GAAG,YAAY,CAAC,OAAO,KAAK,iCAAiB,CAAC,UAAU,CAAC,KAAK,CAAA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AI,CAAC,gBAAgB,CAAC;YAC3B,SAAS,EAAE,KAAK;YAEhB,MAAM,EAAE,IAAA,sBAAS,EAAC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC;YACnD,GAAG,EAAE,IAAA,sBAAS,EAAC,GAAG,EAAE,YAAY,CAAC;YAEjC,OAAO,SAAA;YACP,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK,KAAK,sCAAsB,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAAqB,CAAC,QAAQ,CAAC,CAAC,CAAC,0CAAqB,CAAC,UAAU;YAC7H,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE;SACvB,CAAA;IACH,CAAC;IAEa,iCAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,qBAAqB,CAC9B,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAC5B,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAC5B,uBAAU,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,EACzC,IAAI,CAAC,IAAI,KAAK,iCAAiB,CAAC,UAAU,CAAC,KAAK,CACjD,CAAA;IACH,CAAC;IACH,4BAAC;AAAD,CAAC,AAvFD,IAuFC;AAvFY,sDAAqB"}
@@ -0,0 +1,38 @@
1
+ import { JSONConvertible } from '@airgap/coinlib-core/interfaces/JSONConvertible';
2
+ import { RPCConvertible } from '@airgap/coinlib-core/interfaces/RPCConvertible';
3
+ import { AirGapTransaction } from '@airgap/module-kit';
4
+ import { CosmosProtocolNetwork, CosmosUnits } from '../../../types/protocol';
5
+ import { CosmosCoinJSON } from '../../CosmosCoin';
6
+ import { Encodable } from '../CosmosTransaction';
7
+ export interface CosmosMessageJSON {
8
+ type: CosmosMessageTypeIndex;
9
+ amount: CosmosCoinJSON[];
10
+ fromAddress: string;
11
+ toAddress: string;
12
+ }
13
+ export declare enum CosmosMessageTypeIndex {
14
+ SEND = 0,
15
+ DELEGATE = 1,
16
+ UNDELEGATE = 2,
17
+ WITHDRAW_DELEGATION_REWARD = 3
18
+ }
19
+ export declare enum CosmosMessageTypeValue {
20
+ SEND = "/cosmos.bank.v1beta1.MsgSend",
21
+ DELEGATE = "/cosmos.staking.v1beta1.MsgDelegate",
22
+ UNDELEGATE = "/cosmos.staking.v1beta1.MsgUndelegate",
23
+ WITHDRAW_DELEGATION_REWARD = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward"
24
+ }
25
+ export declare class CosmosMessageType {
26
+ static Send: CosmosMessageType;
27
+ static Delegate: CosmosMessageType;
28
+ static Undelegate: CosmosMessageType;
29
+ static WithdrawDelegationReward: CosmosMessageType;
30
+ readonly index: CosmosMessageTypeIndex;
31
+ readonly value: string;
32
+ constructor(index: CosmosMessageTypeIndex);
33
+ }
34
+ export interface CosmosMessage extends JSONConvertible, RPCConvertible, Encodable {
35
+ type: CosmosMessageType;
36
+ toAirGapTransaction(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<CosmosUnits>;
37
+ toJSON(): CosmosMessageJSON;
38
+ }
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosMessageType = exports.CosmosMessageTypeValue = exports.CosmosMessageTypeIndex = void 0;
4
+ var errors_1 = require("@airgap/coinlib-core/errors");
5
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
6
+ var CosmosMessageTypeIndex;
7
+ (function (CosmosMessageTypeIndex) {
8
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["SEND"] = 0] = "SEND";
9
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["DELEGATE"] = 1] = "DELEGATE";
10
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["UNDELEGATE"] = 2] = "UNDELEGATE";
11
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["WITHDRAW_DELEGATION_REWARD"] = 3] = "WITHDRAW_DELEGATION_REWARD";
12
+ })(CosmosMessageTypeIndex = exports.CosmosMessageTypeIndex || (exports.CosmosMessageTypeIndex = {}));
13
+ var CosmosMessageTypeValue;
14
+ (function (CosmosMessageTypeValue) {
15
+ CosmosMessageTypeValue["SEND"] = "/cosmos.bank.v1beta1.MsgSend";
16
+ CosmosMessageTypeValue["DELEGATE"] = "/cosmos.staking.v1beta1.MsgDelegate";
17
+ CosmosMessageTypeValue["UNDELEGATE"] = "/cosmos.staking.v1beta1.MsgUndelegate";
18
+ CosmosMessageTypeValue["WITHDRAW_DELEGATION_REWARD"] = "/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward";
19
+ })(CosmosMessageTypeValue = exports.CosmosMessageTypeValue || (exports.CosmosMessageTypeValue = {}));
20
+ var CosmosMessageType = /** @class */ (function () {
21
+ function CosmosMessageType(index) {
22
+ this.index = index;
23
+ switch (index) {
24
+ case CosmosMessageTypeIndex.SEND:
25
+ this.value = CosmosMessageTypeValue.SEND;
26
+ break;
27
+ case CosmosMessageTypeIndex.DELEGATE:
28
+ this.value = CosmosMessageTypeValue.DELEGATE;
29
+ break;
30
+ case CosmosMessageTypeIndex.UNDELEGATE:
31
+ this.value = CosmosMessageTypeValue.UNDELEGATE;
32
+ break;
33
+ case CosmosMessageTypeIndex.WITHDRAW_DELEGATION_REWARD:
34
+ this.value = CosmosMessageTypeValue.WITHDRAW_DELEGATION_REWARD;
35
+ break;
36
+ default:
37
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.COSMOS, 'Unknown message');
38
+ }
39
+ }
40
+ CosmosMessageType.Send = new CosmosMessageType(CosmosMessageTypeIndex.SEND);
41
+ CosmosMessageType.Delegate = new CosmosMessageType(CosmosMessageTypeIndex.DELEGATE);
42
+ CosmosMessageType.Undelegate = new CosmosMessageType(CosmosMessageTypeIndex.UNDELEGATE);
43
+ CosmosMessageType.WithdrawDelegationReward = new CosmosMessageType(CosmosMessageTypeIndex.WITHDRAW_DELEGATION_REWARD);
44
+ return CosmosMessageType;
45
+ }());
46
+ exports.CosmosMessageType = CosmosMessageType;
47
+ //# sourceMappingURL=CosmosMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosMessage.js","sourceRoot":"","sources":["../../../../../src/v1/data/transaction/message/CosmosMessage.ts"],"names":[],"mappings":";;;AAAA,sDAA+D;AAC/D,2EAAkE;AAgBlE,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAChC,mEAAQ,CAAA;IACR,2EAAY,CAAA;IACZ,+EAAc,CAAA;IACd,+GAA8B,CAAA;AAChC,CAAC,EALW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAKjC;AAED,IAAY,sBAKX;AALD,WAAY,sBAAsB;IAChC,+DAAqC,CAAA;IACrC,0EAAgD,CAAA;IAChD,8EAAoD,CAAA;IACpD,gHAAsF,CAAA;AACxF,CAAC,EALW,sBAAsB,GAAtB,8BAAsB,KAAtB,8BAAsB,QAKjC;AAED;IASE,2BAAY,KAA6B;QACvC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAA;QAClB,QAAQ,KAAK,EAAE;YACb,KAAK,sBAAsB,CAAC,IAAI;gBAC9B,IAAI,CAAC,KAAK,GAAG,sBAAsB,CAAC,IAAI,CAAA;gBACxC,MAAK;YACP,KAAK,sBAAsB,CAAC,QAAQ;gBAClC,IAAI,CAAC,KAAK,GAAG,sBAAsB,CAAC,QAAQ,CAAA;gBAC5C,MAAK;YACP,KAAK,sBAAsB,CAAC,UAAU;gBACpC,IAAI,CAAC,KAAK,GAAG,sBAAsB,CAAC,UAAU,CAAA;gBAC9C,MAAK;YACP,KAAK,sBAAsB,CAAC,0BAA0B;gBACpD,IAAI,CAAC,KAAK,GAAG,sBAAsB,CAAC,0BAA0B,CAAA;gBAC9D,MAAK;YACP;gBACE,MAAM,IAAI,0BAAiB,CAAC,sBAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAA;SAChE;IACH,CAAC;IA1Ba,sBAAI,GAAsB,IAAI,iBAAiB,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAA;IAC5E,0BAAQ,GAAsB,IAAI,iBAAiB,CAAC,sBAAsB,CAAC,QAAQ,CAAC,CAAA;IACpF,4BAAU,GAAsB,IAAI,iBAAiB,CAAC,sBAAsB,CAAC,UAAU,CAAC,CAAA;IACxF,0CAAwB,GAAsB,IAAI,iBAAiB,CAAC,sBAAsB,CAAC,0BAA0B,CAAC,CAAA;IAwBtI,wBAAC;CAAA,AA5BD,IA4BC;AA5BY,8CAAiB"}
@@ -0,0 +1,19 @@
1
+ import { EncodeObject } from '@airgap/coinlib-core/dependencies/src/cosmjs';
2
+ import { AirGapTransaction } from '@airgap/module-kit';
3
+ import { CosmosProtocolNetwork, CosmosUnits } from '../../../types/protocol';
4
+ import { CosmosCoin } from '../../CosmosCoin';
5
+ import { CosmosMessage, CosmosMessageJSON, CosmosMessageType } from './CosmosMessage';
6
+ export declare class CosmosSendMessage implements CosmosMessage {
7
+ readonly fromAddress: string;
8
+ readonly toAddress: string;
9
+ readonly amount: CosmosCoin[];
10
+ readonly type: CosmosMessageType;
11
+ constructor(fromAddress: string, toAddress: string, amount: CosmosCoin[]);
12
+ toEncodeObject(): EncodeObject;
13
+ static fromEncodeObject(encodeObject: EncodeObject): CosmosSendMessage;
14
+ toJSON(): CosmosMessageJSON;
15
+ static fromJSON(json: CosmosMessageJSON): CosmosSendMessage;
16
+ toRPCBody(): any;
17
+ toAirGapTransaction(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<CosmosUnits>;
18
+ static fromRPCBody(json: any): CosmosSendMessage;
19
+ }
@@ -0,0 +1,83 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ exports.CosmosSendMessage = void 0;
16
+ var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
17
+ var IAirGapTransaction_1 = require("@airgap/coinlib-core/interfaces/IAirGapTransaction");
18
+ var module_kit_1 = require("@airgap/module-kit");
19
+ var CosmosCoin_1 = require("../../CosmosCoin");
20
+ var CosmosMessage_1 = require("./CosmosMessage");
21
+ var CosmosSendMessage = /** @class */ (function () {
22
+ function CosmosSendMessage(fromAddress, toAddress, amount) {
23
+ this.type = CosmosMessage_1.CosmosMessageType.Send;
24
+ this.fromAddress = fromAddress;
25
+ this.toAddress = toAddress;
26
+ this.amount = amount;
27
+ }
28
+ CosmosSendMessage.prototype.toEncodeObject = function () {
29
+ return {
30
+ typeUrl: this.type.value,
31
+ value: {
32
+ fromAddress: this.fromAddress,
33
+ toAddress: this.toAddress,
34
+ amount: __spreadArray([], this.amount, true)
35
+ }
36
+ };
37
+ };
38
+ CosmosSendMessage.fromEncodeObject = function (encodeObject) {
39
+ return new CosmosSendMessage(encodeObject.value.fromAddress, encodeObject.value.toAddress, encodeObject.value.amount.map(function (amount) { return new CosmosCoin_1.CosmosCoin(amount.denom, amount.amount); }));
40
+ };
41
+ CosmosSendMessage.prototype.toJSON = function () {
42
+ return {
43
+ type: this.type.index,
44
+ amount: this.amount.map(function (value) { return value.toJSON(); }),
45
+ fromAddress: this.fromAddress,
46
+ toAddress: this.toAddress
47
+ };
48
+ };
49
+ CosmosSendMessage.fromJSON = function (json) {
50
+ return new CosmosSendMessage(json.fromAddress, json.toAddress, json.amount.map(function (value) { return CosmosCoin_1.CosmosCoin.fromJSON(value); }));
51
+ };
52
+ CosmosSendMessage.prototype.toRPCBody = function () {
53
+ return {
54
+ type: this.type.value,
55
+ value: {
56
+ amount: this.amount.map(function (value) { return value.toRPCBody(); }),
57
+ from_address: this.fromAddress,
58
+ to_address: this.toAddress
59
+ }
60
+ };
61
+ };
62
+ CosmosSendMessage.prototype.toAirGapTransaction = function (network, fee) {
63
+ return {
64
+ from: [this.fromAddress],
65
+ to: [this.toAddress],
66
+ isInbound: false,
67
+ amount: (0, module_kit_1.newAmount)(this.amount
68
+ .map(function (value) { return new bignumber_1.default(value.amount); })
69
+ .reduce(function (prev, next) { return prev.plus(next); })
70
+ .toString(10), 'blockchain'),
71
+ fee: (0, module_kit_1.newAmount)(fee, 'blockchain'),
72
+ network: network,
73
+ type: IAirGapTransaction_1.AirGapTransactionType.SPEND,
74
+ json: this.toRPCBody()
75
+ };
76
+ };
77
+ CosmosSendMessage.fromRPCBody = function (json) {
78
+ return new CosmosSendMessage(json.value.from_address, json.value.to_address, json.value.amount.map(function (value) { return CosmosCoin_1.CosmosCoin.fromRPCBody(value); }));
79
+ };
80
+ return CosmosSendMessage;
81
+ }());
82
+ exports.CosmosSendMessage = CosmosSendMessage;
83
+ //# sourceMappingURL=CosmosSendMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosSendMessage.js","sourceRoot":"","sources":["../../../../../src/v1/data/transaction/message/CosmosSendMessage.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,iHAA0F;AAE1F,yFAA0F;AAC1F,iDAAiE;AAGjE,+CAA6D;AAE7D,iDAAqF;AAErF;IAOE,2BAAY,WAAmB,EAAE,SAAiB,EAAE,MAAoB;QAFxD,SAAI,GAAsB,iCAAiB,CAAC,IAAI,CAAA;QAG9D,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAA;QAC1B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAA;IACtB,CAAC;IAEM,0CAAc,GAArB;QACE,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACxB,KAAK,EAAE;gBACL,WAAW,EAAE,IAAI,CAAC,WAA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CosmosProtocolNetwork, CosmosUnits } from '../../../types/protocol';
4
+ import { CosmosMessage, CosmosMessageJSON, CosmosMessageType } from './CosmosMessage';
5
+ export declare class CosmosWithdrawDelegationRewardMessage implements CosmosMessage {
6
+ readonly delegatorAddress: string;
7
+ readonly validatorAddress: string;
8
+ readonly type: CosmosMessageType;
9
+ constructor(delegatorAddress: string, validatorAddress: string);
10
+ toEncodeObject(): EncodeObject;
11
+ static fromEncodeObject(encodeObject: EncodeObject): CosmosWithdrawDelegationRewardMessage;
12
+ toAirGapTransaction(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<CosmosUnits>;
13
+ toJSON(): CosmosMessageJSON;
14
+ static fromJSON(json: CosmosMessageJSON): CosmosWithdrawDelegationRewardMessage;
15
+ toRPCBody(): {
16
+ type: string;
17
+ value: {
18
+ delegator_address: string;
19
+ validator_address: string;
20
+ };
21
+ };
22
+ static fromRPCBody(json: any): CosmosWithdrawDelegationRewardMessage;
23
+ }