@airgap/cosmos-core 0.13.11-beta.14

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 (77) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +11 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +18 -0
  5. package/index.js.map +1 -0
  6. package/package.json +59 -0
  7. package/v1/index.d.ts +18 -0
  8. package/v1/index.js +29 -0
  9. package/v1/index.js.map +1 -0
  10. package/v1/node/CosmosNodeClient.d.ts +29 -0
  11. package/v1/node/CosmosNodeClient.js +383 -0
  12. package/v1/node/CosmosNodeClient.js.map +1 -0
  13. package/v1/protocol/CosmosBaseProtocol.d.ts +109 -0
  14. package/v1/protocol/CosmosBaseProtocol.js +1005 -0
  15. package/v1/protocol/CosmosBaseProtocol.js.map +1 -0
  16. package/v1/protocol/CosmosCryptoClient.d.ts +8 -0
  17. package/v1/protocol/CosmosCryptoClient.js +90 -0
  18. package/v1/protocol/CosmosCryptoClient.js.map +1 -0
  19. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +7 -0
  20. package/v1/serializer/v3/schemas/converter/transaction-converter.js +37 -0
  21. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  22. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.d.ts +4 -0
  23. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js +3 -0
  24. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-cosmos.js.map +1 -0
  25. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.d.ts +3 -0
  26. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js +3 -0
  27. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-cosmos.js.map +1 -0
  28. package/v1/serializer/v3/schemas/generated/transaction-sign-request-cosmos.json +100 -0
  29. package/v1/serializer/v3/schemas/generated/transaction-sign-response-cosmos.json +19 -0
  30. package/v1/serializer/v3/validators/transaction-validators.d.ts +7 -0
  31. package/v1/serializer/v3/validators/transaction-validators.js +88 -0
  32. package/v1/serializer/v3/validators/transaction-validators.js.map +1 -0
  33. package/v1/types/crypto.d.ts +2 -0
  34. package/v1/types/crypto.js +3 -0
  35. package/v1/types/crypto.js.map +1 -0
  36. package/v1/types/data/CosmosAddress.d.ts +7 -0
  37. package/v1/types/data/CosmosAddress.js +30 -0
  38. package/v1/types/data/CosmosAddress.js.map +1 -0
  39. package/v1/types/data/CosmosCoin.d.ts +18 -0
  40. package/v1/types/data/CosmosCoin.js +56 -0
  41. package/v1/types/data/CosmosCoin.js.map +1 -0
  42. package/v1/types/data/CosmosFee.d.ts +15 -0
  43. package/v1/types/data/CosmosFee.js +31 -0
  44. package/v1/types/data/CosmosFee.js.map +1 -0
  45. package/v1/types/data/transaction/CosmosTransaction.d.ts +36 -0
  46. package/v1/types/data/transaction/CosmosTransaction.js +109 -0
  47. package/v1/types/data/transaction/CosmosTransaction.js.map +1 -0
  48. package/v1/types/data/transaction/message/CosmosDelegateMessage.d.ts +19 -0
  49. package/v1/types/data/transaction/message/CosmosDelegateMessage.js +70 -0
  50. package/v1/types/data/transaction/message/CosmosDelegateMessage.js.map +1 -0
  51. package/v1/types/data/transaction/message/CosmosMessage.d.ts +38 -0
  52. package/v1/types/data/transaction/message/CosmosMessage.js +47 -0
  53. package/v1/types/data/transaction/message/CosmosMessage.js.map +1 -0
  54. package/v1/types/data/transaction/message/CosmosSendMessage.d.ts +19 -0
  55. package/v1/types/data/transaction/message/CosmosSendMessage.js +83 -0
  56. package/v1/types/data/transaction/message/CosmosSendMessage.js.map +1 -0
  57. package/v1/types/data/transaction/message/CosmosWithdrawDelegationRewardMessage.d.ts +23 -0
  58. package/v1/types/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js +61 -0
  59. package/v1/types/data/transaction/message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
  60. package/v1/types/protocol.d.ts +10 -0
  61. package/v1/types/protocol.js +3 -0
  62. package/v1/types/protocol.js.map +1 -0
  63. package/v1/types/rpc.d.ts +286 -0
  64. package/v1/types/rpc.js +3 -0
  65. package/v1/types/rpc.js.map +1 -0
  66. package/v1/types/transaction.d.ts +50 -0
  67. package/v1/types/transaction.js +18 -0
  68. package/v1/types/transaction.js.map +1 -0
  69. package/v1/utils/key.d.ts +3 -0
  70. package/v1/utils/key.js +20 -0
  71. package/v1/utils/key.js.map +1 -0
  72. package/v1/utils/signature.d.ts +2 -0
  73. package/v1/utils/signature.js +13 -0
  74. package/v1/utils/signature.js.map +1 -0
  75. package/v1/utils/transaction.d.ts +1 -0
  76. package/v1/utils/transaction.js +8 -0
  77. package/v1/utils/transaction.js.map +1 -0
@@ -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/types/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 } 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<_Units extends string>(network: CosmosProtocolNetwork): AirGapTransaction<_Units>[];
34
+ static fromJSON(json: CosmosUnsignedTransaction): CosmosTransaction;
35
+ static fromRPCBody(json: any): CosmosTransaction;
36
+ }
@@ -0,0 +1,109 @@
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
+ json = JSON.parse(JSON.stringify(json));
72
+ var messages = json.messages.map(function (value) {
73
+ var type = value.type;
74
+ switch (type) {
75
+ case CosmosMessage_1.CosmosMessageType.Send.index:
76
+ return CosmosSendMessage_1.CosmosSendMessage.fromJSON(value);
77
+ case CosmosMessage_1.CosmosMessageType.Delegate.index:
78
+ case CosmosMessage_1.CosmosMessageType.Undelegate.index:
79
+ return CosmosDelegateMessage_1.CosmosDelegateMessage.fromJSON(value);
80
+ case CosmosMessage_1.CosmosMessageType.WithdrawDelegationReward.index:
81
+ return CosmosWithdrawDelegationRewardMessage_1.CosmosWithdrawDelegationRewardMessage.fromJSON(value);
82
+ default:
83
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.COSMOS, 'Unknown message');
84
+ }
85
+ });
86
+ return new CosmosTransaction(messages, CosmosFee_1.CosmosFee.fromJSON(json.fee), json.memo, json.chainID, json.accountNumber, json.sequence);
87
+ };
88
+ CosmosTransaction.fromRPCBody = function (json) {
89
+ json = JSON.parse(JSON.stringify(json));
90
+ var messages = json.msgs.map(function (value) {
91
+ var type = value.type;
92
+ switch (type) {
93
+ case CosmosMessage_1.CosmosMessageType.Send.value:
94
+ return CosmosSendMessage_1.CosmosSendMessage.fromRPCBody(value);
95
+ case CosmosMessage_1.CosmosMessageType.Delegate.value:
96
+ case CosmosMessage_1.CosmosMessageType.Undelegate.value:
97
+ return CosmosDelegateMessage_1.CosmosDelegateMessage.fromRPCBody(value);
98
+ case CosmosMessage_1.CosmosMessageType.WithdrawDelegationReward.value:
99
+ return CosmosWithdrawDelegationRewardMessage_1.CosmosWithdrawDelegationRewardMessage.fromRPCBody(value);
100
+ default:
101
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.COSMOS, 'Unknown message');
102
+ }
103
+ });
104
+ return new CosmosTransaction(messages, CosmosFee_1.CosmosFee.fromRPCBody(json.fee), json.memo, json.chain_id, json.account_number, json.sequence);
105
+ };
106
+ return CosmosTransaction;
107
+ }());
108
+ exports.CosmosTransaction = CosmosTransaction;
109
+ //# sourceMappingURL=CosmosTransaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosTransaction.js","sourceRoot":"","sources":["../../../../../src/v1/types/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,CAAC,UAAC,KAAK,IAAK,OAAA,KAAK,CAAC,MAAM,EAAE,EAAd,CAAc,CAAC;YACtD,QAAQ,EAAE,IAAI,CAAC,QAAQ;SACxB,CAAA;IACH,CAAC;IAEM,qCAAS,GAAhB;QACE,OAAO;YACL,cAAc,EAAE,IAAI,CAAC,aAAa;YAClC,QAAQ,EA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mosProtocolNetwork } 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<_Units extends string>(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<_Units>;
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/types/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;QAC9E,OAAO,IAAI,qBAAqB,CAC9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AAS,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 } 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<_Units extends string>(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<_Units>;
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/types/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 } 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<_Units extends string>(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<_Units>;
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/types/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,WAAW;gBAC7B,SAAS,EAAE,IAAI,CAA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,UAAU,EAAE,IAAI,CAAC,SAAS;aAC3B;SACF,CAAA;IACH,CAAC;IAEM,+CAAmB,GAA1B,UAAkD,OAA8B,EAAE,GAAW;QAC3F,OAAO;YACL,IAAI,EAAE,CAAC,IAAI,CAAC,WAAW,CAAC;YACxB,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC;YACpB,SAAS,EAAE,KAAK;YAEhB,MAAM,EAAE,IAAA,sBAAS,EACf,IAAI,CAAC,MAAM;iBACR,GAAG,CAAC,UAAC,KAAiB,IAAK,OAAA,IAAI,mBAAS,CAAC,KAAK,CAAC,MAAM,CAAC,EAA3B,CAA2B,CAAC;iBACvD,MAAM,CAAC,UAAC,IAAe,EAAE,IAAe,IAAK,OAAA,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,EAAf,CAAe,CAAC;iBAC7D,QAAQ,CAAC,EAAE,CAAC,EACf,YAAY,CACb;YACD,GAAG,EAAE,IAAA,sBAAS,EAAC,GAAG,EAAE,YAAY,CAAC;YAEjC,OAAO,SAAA;YACP,IAAI,EAAE,0CAAqB,CAAC,KAAK;YACjC,IAAI,EAAE,IAAI,CAAC,SAAS,EAAE;SACvB,CAAA;IACH,CAAC;IAEa,6BAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,iBAAiB,CAC1B,IAAI,CAAC,KAAK,CAAC,YAAY,EACvB,IAAI,CAAC,KAAK,CAAC,UAAU,EACrB,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,UAAC,KAAU,IAAK,OAAA,uBAAU,CAAC,WAAW,CAAC,KAAK,CAAC,EAA7B,CAA6B,CAAC,CACrE,CAAA;IACH,CAAC;IACH,wBAAC;AAAD,CAAC,AAxFD,IAwFC;AAxFY,8CAAiB"}
@@ -0,0 +1,23 @@
1
+ import { EncodeObject } from '@airgap/coinlib-core/dependencies/src/cosmjs';
2
+ import { AirGapTransaction } from '@airgap/module-kit';
3
+ import { CosmosProtocolNetwork } 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<_Units extends string>(network: CosmosProtocolNetwork, fee: string): AirGapTransaction<_Units>;
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
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosWithdrawDelegationRewardMessage = void 0;
4
+ var module_kit_1 = require("@airgap/module-kit");
5
+ var CosmosMessage_1 = require("./CosmosMessage");
6
+ var CosmosWithdrawDelegationRewardMessage = /** @class */ (function () {
7
+ function CosmosWithdrawDelegationRewardMessage(delegatorAddress, validatorAddress) {
8
+ this.type = CosmosMessage_1.CosmosMessageType.WithdrawDelegationReward;
9
+ this.delegatorAddress = delegatorAddress;
10
+ this.validatorAddress = validatorAddress;
11
+ }
12
+ CosmosWithdrawDelegationRewardMessage.prototype.toEncodeObject = function () {
13
+ return {
14
+ typeUrl: this.type.value,
15
+ value: {
16
+ delegatorAddress: this.delegatorAddress,
17
+ validatorAddress: this.validatorAddress
18
+ }
19
+ };
20
+ };
21
+ CosmosWithdrawDelegationRewardMessage.fromEncodeObject = function (encodeObject) {
22
+ return new CosmosWithdrawDelegationRewardMessage(encodeObject.value.delegatorAddress, encodeObject.value.validatorAddress);
23
+ };
24
+ CosmosWithdrawDelegationRewardMessage.prototype.toAirGapTransaction = function (network, fee) {
25
+ return {
26
+ from: [this.delegatorAddress],
27
+ to: [this.validatorAddress],
28
+ isInbound: false,
29
+ amount: (0, module_kit_1.newAmount)('0', 'blockchain'),
30
+ fee: (0, module_kit_1.newAmount)(fee, 'blockchain'),
31
+ network: network,
32
+ json: this.toRPCBody()
33
+ };
34
+ };
35
+ CosmosWithdrawDelegationRewardMessage.prototype.toJSON = function () {
36
+ return {
37
+ type: this.type.index,
38
+ amount: [{ denom: '', amount: '' }],
39
+ fromAddress: this.delegatorAddress,
40
+ toAddress: this.validatorAddress
41
+ };
42
+ };
43
+ CosmosWithdrawDelegationRewardMessage.fromJSON = function (json) {
44
+ return new CosmosWithdrawDelegationRewardMessage(json.fromAddress, json.toAddress);
45
+ };
46
+ CosmosWithdrawDelegationRewardMessage.prototype.toRPCBody = function () {
47
+ return {
48
+ type: this.type.value,
49
+ value: {
50
+ delegator_address: this.delegatorAddress,
51
+ validator_address: this.validatorAddress
52
+ }
53
+ };
54
+ };
55
+ CosmosWithdrawDelegationRewardMessage.fromRPCBody = function (json) {
56
+ return new CosmosWithdrawDelegationRewardMessage(json.value.delegator_address, json.value.validator_address);
57
+ };
58
+ return CosmosWithdrawDelegationRewardMessage;
59
+ }());
60
+ exports.CosmosWithdrawDelegationRewardMessage = CosmosWithdrawDelegationRewardMessage;
61
+ //# sourceMappingURL=CosmosWithdrawDelegationRewardMessage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosWithdrawDelegationRewardMessage.js","sourceRoot":"","sources":["../../../../../../src/v1/types/data/transaction/message/CosmosWithdrawDelegationRewardMessage.ts"],"names":[],"mappings":";;;AACA,iDAAiE;AAIjE,iDAAqF;AAErF;IAKE,+CAAY,gBAAwB,EAAE,gBAAwB;QAF9C,SAAI,GAAsB,iCAAiB,CAAC,wBAAwB,CAAA;QAGlF,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAA;QACxC,IAAI,CA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OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,KAAK;YACrB,KAAK,EAAE;gBACL,iBAAiB,EAAE,IAAI,CAAC,gBAAgB;gBACxC,iBAAiB,EAAE,IAAI,CAAC,gBAAgB;aACzC;SACF,CAAA;IACH,CAAC;IAEa,iDAAW,GAAzB,UAA0B,IAAS;QACjC,OAAO,IAAI,qCAAqC,CAAC,IAAI,CAAC,KAAK,CAAC,iBAAiB,EAAE,IAAI,CAAC,KAAK,CAAC,iBAAiB,CAAC,CAAA;IAC9G,CAAC;IACH,4CAAC;AAAD,CAAC,AA/DD,IA+DC;AA/DY,sFAAqC"}
@@ -0,0 +1,10 @@
1
+ import { Amount, ProtocolNetwork } from '@airgap/module-kit';
2
+ export interface CosmosProtocolNetwork extends ProtocolNetwork {
3
+ useCORSProxy?: boolean;
4
+ }
5
+ export interface CosmosProtocolOptions<Units extends string> {
6
+ network: CosmosProtocolNetwork;
7
+ addressPrefix: string;
8
+ baseUnit: Units;
9
+ defaultGas: Amount<Units>;
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/types/protocol.ts"],"names":[],"mappings":""}