@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,286 @@
1
+ import { CosmosCoinJSON } from './data/CosmosCoin';
2
+ export interface CosmosNodeInfo {
3
+ protocol_version: {
4
+ p2p: string;
5
+ block: string;
6
+ app: string;
7
+ };
8
+ id: string;
9
+ listen_addr: string;
10
+ network: string;
11
+ version: string;
12
+ channels: string;
13
+ moniker: string;
14
+ other: {
15
+ tx_index: string;
16
+ rpc_address: string;
17
+ };
18
+ }
19
+ export interface CosmosAccount {
20
+ type: string;
21
+ value: CosmosAccountValue;
22
+ }
23
+ export interface CosmosAccountValue {
24
+ account_number: string;
25
+ address: string;
26
+ coins: CosmosAccountCoin[];
27
+ sequence?: string;
28
+ public_key?: string;
29
+ }
30
+ export interface CosmosAccountCoin {
31
+ denom: string;
32
+ amount: string;
33
+ }
34
+ export interface CosmosDelegation {
35
+ delegation: {
36
+ delegator_address: string;
37
+ validator_address: string;
38
+ shares: string;
39
+ };
40
+ balance: {
41
+ denom: string;
42
+ amount: string;
43
+ };
44
+ }
45
+ export interface CosmosUnbondingDelegation {
46
+ delegator_address: string;
47
+ validator_address: string;
48
+ entries: {
49
+ creation_height: string;
50
+ completion_time: string;
51
+ initial_balance: string;
52
+ balance: string;
53
+ }[];
54
+ }
55
+ export interface CosmosValidator {
56
+ operator_address: string;
57
+ consensus_pubkey: string;
58
+ jailed: boolean;
59
+ status: number;
60
+ tokens: string;
61
+ delegator_shares: string;
62
+ description: CosmosValidatorDescription;
63
+ unbonding_height: string;
64
+ unbonding_time: string;
65
+ commission: CosmosValidatorCommission;
66
+ min_self_delegation: string;
67
+ }
68
+ export interface CosmosValidatorDescription {
69
+ moniker: string;
70
+ identity: string;
71
+ website: string;
72
+ details: string;
73
+ }
74
+ export interface CosmosValidatorCommission {
75
+ commission_rates: CosmosValidatorCommissionRate;
76
+ update_time: string;
77
+ }
78
+ export interface CosmosValidatorCommissionRate {
79
+ rate: string;
80
+ max_rate: string;
81
+ max_change_rate: string;
82
+ }
83
+ export interface CosmosBroadcastSignedTransactionResponse {
84
+ tx_response: TxResponse;
85
+ }
86
+ export interface CosmosRewardDetails {
87
+ validator_address: string;
88
+ reward: {
89
+ denom: string;
90
+ amount: number;
91
+ }[];
92
+ }
93
+ export interface CosmosSendTx {
94
+ height: string;
95
+ txhash: string;
96
+ gas_wanted: string;
97
+ gas_used: string;
98
+ tx: {
99
+ type: string;
100
+ value: {
101
+ msg: [
102
+ {
103
+ type: string;
104
+ value: {
105
+ from_address: string;
106
+ to_address: string;
107
+ amount: [
108
+ {
109
+ denom: string;
110
+ amount: string;
111
+ }
112
+ ];
113
+ };
114
+ }
115
+ ];
116
+ fee: {
117
+ amount: [
118
+ {
119
+ denom: string;
120
+ amount: string;
121
+ }
122
+ ];
123
+ gas: string;
124
+ };
125
+ memo: string;
126
+ };
127
+ };
128
+ timestamp: string;
129
+ }
130
+ export interface Amount {
131
+ denom: string;
132
+ amount: string;
133
+ }
134
+ export interface Message {
135
+ '@type': string;
136
+ delegator_address?: string;
137
+ validator_address?: string;
138
+ from_address?: string;
139
+ to_address?: string;
140
+ amount?: Amount | Amount[];
141
+ }
142
+ export interface Body {
143
+ messages: Message[];
144
+ memo: string;
145
+ timeout_height: string;
146
+ extension_options: any[];
147
+ non_critical_extension_options: any[];
148
+ }
149
+ export interface PublicKey {
150
+ '@type': string;
151
+ key: string;
152
+ }
153
+ export interface Single {
154
+ mode: string;
155
+ }
156
+ export interface ModeInfo {
157
+ single: Single;
158
+ }
159
+ export interface SignerInfo {
160
+ public_key: PublicKey;
161
+ mode_info: ModeInfo;
162
+ sequence: string;
163
+ }
164
+ export interface Amount2 {
165
+ denom: string;
166
+ amount: string;
167
+ }
168
+ export interface Fee {
169
+ amount: Amount2[];
170
+ gas_limit: string;
171
+ payer: string;
172
+ granter: string;
173
+ }
174
+ export interface AuthInfo {
175
+ signer_infos: SignerInfo[];
176
+ fee: Fee;
177
+ }
178
+ export interface Tx {
179
+ body: Body;
180
+ auth_info: AuthInfo;
181
+ signatures: string[];
182
+ }
183
+ export interface Attribute {
184
+ key: string;
185
+ value: string;
186
+ }
187
+ export interface Event {
188
+ type: string;
189
+ attributes: Attribute[];
190
+ }
191
+ export interface Log {
192
+ msg_index: number;
193
+ log: string;
194
+ events: Event[];
195
+ }
196
+ export interface Amount3 {
197
+ denom: string;
198
+ amount: string;
199
+ }
200
+ export interface StakingMessage {
201
+ '@type': string;
202
+ delegator_address: string;
203
+ validator_address: string;
204
+ amount?: CosmosCoinJSON;
205
+ }
206
+ export interface SendMessage {
207
+ '@type': string;
208
+ from_address: string;
209
+ to_address: string;
210
+ amount: CosmosCoinJSON[];
211
+ }
212
+ export interface Body2 {
213
+ messages: any;
214
+ memo: string;
215
+ timeout_height: string;
216
+ extension_options: any[];
217
+ non_critical_extension_options: any[];
218
+ }
219
+ export interface PublicKey2 {
220
+ '@type': string;
221
+ key: string;
222
+ }
223
+ export interface Single2 {
224
+ mode: string;
225
+ }
226
+ export interface ModeInfo2 {
227
+ single: Single2;
228
+ }
229
+ export interface SignerInfo2 {
230
+ public_key: PublicKey2;
231
+ mode_info: ModeInfo2;
232
+ sequence: string;
233
+ }
234
+ export interface Amount4 {
235
+ denom: string;
236
+ amount: string;
237
+ }
238
+ export interface Fee2 {
239
+ amount: Amount4[];
240
+ gas_limit: string;
241
+ payer: string;
242
+ granter: string;
243
+ }
244
+ export interface AuthInfo2 {
245
+ signer_infos: SignerInfo2[];
246
+ fee: Fee2;
247
+ }
248
+ export interface Tx2 {
249
+ '@type': string;
250
+ body: Body2;
251
+ auth_info: AuthInfo2;
252
+ signatures: string[];
253
+ }
254
+ export interface Attribute2 {
255
+ key: string;
256
+ value: string;
257
+ index: boolean;
258
+ }
259
+ export interface Event2 {
260
+ type: string;
261
+ attributes: Attribute2[];
262
+ }
263
+ export interface TxResponse {
264
+ height: string;
265
+ txhash: string;
266
+ codespace: string;
267
+ code: number;
268
+ data: string;
269
+ raw_log: string;
270
+ logs: Log[];
271
+ info: string;
272
+ gas_wanted: string;
273
+ gas_used: string;
274
+ tx: Tx2;
275
+ timestamp: string;
276
+ events: Event2[];
277
+ }
278
+ export interface Pagination {
279
+ next_key?: any;
280
+ total: string;
281
+ }
282
+ export interface CosmosPagedSendTxsResponse {
283
+ txs: Tx[];
284
+ tx_responses: TxResponse[];
285
+ pagination: Pagination;
286
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=rpc.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.js","sourceRoot":"","sources":["../../../src/v1/types/rpc.ts"],"names":[],"mappings":""}
@@ -0,0 +1,50 @@
1
+ import { SignedTransaction, TransactionCursor, UnsignedTransaction } from '@airgap/module-kit';
2
+ declare enum CosmosMessageTypeIndex {
3
+ SEND = 0,
4
+ DELEGATE = 1,
5
+ UNDELEGATE = 2,
6
+ WITHDRAW_DELEGATION_REWARD = 3
7
+ }
8
+ export declare enum CosmosDelegationActionType {
9
+ DELEGATE = "delegate",
10
+ UNDELEGATE = "undelegate",
11
+ WITHDRAW_ALL_REWARDS = "withdraw_all_rewards",
12
+ WITHDRAW_VALIDATOR_REWARDS = "withdraw_validator_rewards"
13
+ }
14
+ interface CosmosCoin {
15
+ denom: string;
16
+ amount: string;
17
+ }
18
+ interface CosmosMessage {
19
+ type: CosmosMessageTypeIndex;
20
+ amount: CosmosCoin[];
21
+ fromAddress: string;
22
+ toAddress: string;
23
+ }
24
+ interface CosmosFee {
25
+ amount: CosmosCoin[];
26
+ gas: string;
27
+ }
28
+ export interface CosmosSignedTransaction extends SignedTransaction {
29
+ encoded: string;
30
+ }
31
+ export interface CosmosUnsignedTransaction extends UnsignedTransaction {
32
+ messages: CosmosMessage[];
33
+ fee: CosmosFee;
34
+ memo: string;
35
+ chainID: string;
36
+ accountNumber: string;
37
+ sequence: string;
38
+ }
39
+ export interface CosmosTransactionCursor extends TransactionCursor {
40
+ limit: number;
41
+ sender: {
42
+ total: number;
43
+ offset: number;
44
+ };
45
+ recipient: {
46
+ total: number;
47
+ offset: number;
48
+ };
49
+ }
50
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CosmosDelegationActionType = void 0;
4
+ var CosmosMessageTypeIndex;
5
+ (function (CosmosMessageTypeIndex) {
6
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["SEND"] = 0] = "SEND";
7
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["DELEGATE"] = 1] = "DELEGATE";
8
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["UNDELEGATE"] = 2] = "UNDELEGATE";
9
+ CosmosMessageTypeIndex[CosmosMessageTypeIndex["WITHDRAW_DELEGATION_REWARD"] = 3] = "WITHDRAW_DELEGATION_REWARD";
10
+ })(CosmosMessageTypeIndex || (CosmosMessageTypeIndex = {}));
11
+ var CosmosDelegationActionType;
12
+ (function (CosmosDelegationActionType) {
13
+ CosmosDelegationActionType["DELEGATE"] = "delegate";
14
+ CosmosDelegationActionType["UNDELEGATE"] = "undelegate";
15
+ CosmosDelegationActionType["WITHDRAW_ALL_REWARDS"] = "withdraw_all_rewards";
16
+ CosmosDelegationActionType["WITHDRAW_VALIDATOR_REWARDS"] = "withdraw_validator_rewards";
17
+ })(CosmosDelegationActionType = exports.CosmosDelegationActionType || (exports.CosmosDelegationActionType = {}));
18
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/v1/types/transaction.ts"],"names":[],"mappings":";;;AAEA,IAAK,sBAKJ;AALD,WAAK,sBAAsB;IACzB,mEAAQ,CAAA;IACR,2EAAY,CAAA;IACZ,+EAAc,CAAA;IACd,+GAA8B,CAAA;AAChC,CAAC,EALI,sBAAsB,KAAtB,sBAAsB,QAK1B;AAED,IAAY,0BAKX;AALD,WAAY,0BAA0B;IACpC,mDAAqB,CAAA;IACrB,uDAAyB,CAAA;IACzB,2EAA6C,CAAA;IAC7C,uFAAyD,CAAA;AAC3D,CAAC,EALW,0BAA0B,GAA1B,kCAA0B,KAA1B,kCAA0B,QAKrC"}
@@ -0,0 +1,3 @@
1
+ import { PublicKey, SecretKey } from '@airgap/module-kit';
2
+ export declare function convertSecretKey(secretKey: SecretKey, targetFormat: SecretKey['format']): SecretKey;
3
+ export declare function convertPublicKey(publicKey: PublicKey, targetFormat: PublicKey['format']): PublicKey;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertPublicKey = exports.convertSecretKey = void 0;
4
+ var coinlib_core_1 = require("@airgap/coinlib-core");
5
+ var errors_1 = require("@airgap/coinlib-core/errors");
6
+ function convertSecretKey(secretKey, targetFormat) {
7
+ if (secretKey.format === targetFormat) {
8
+ return secretKey;
9
+ }
10
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, 'Unsupported secret key conversion.');
11
+ }
12
+ exports.convertSecretKey = convertSecretKey;
13
+ function convertPublicKey(publicKey, targetFormat) {
14
+ if (publicKey.format === targetFormat) {
15
+ return publicKey;
16
+ }
17
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, 'Unsupported public key conversion.');
18
+ }
19
+ exports.convertPublicKey = convertPublicKey;
20
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../../../src/v1/utils/key.ts"],"names":[],"mappings":";;;AAAA,qDAA6C;AAC7C,sDAA8D;AAG9D,SAAgB,gBAAgB,CAAC,SAAoB,EAAE,YAAiC;IACtF,IAAI,SAAS,CAAC,MAAM,KAAK,YAAY,EAAE;QACrC,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAA;AACjF,CAAC;AAND,4CAMC;AAED,SAAgB,gBAAgB,CAAC,SAAoB,EAAE,YAAiC;IACtF,IAAI,SAAS,CAAC,MAAM,KAAK,YAAY,EAAE;QACrC,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAA;AACjF,CAAC;AAND,4CAMC"}
@@ -0,0 +1,2 @@
1
+ import { Signature } from '@airgap/module-kit';
2
+ export declare function convertSignature(signature: Signature, targetFormat: Signature['format']): Signature;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.convertSignature = void 0;
4
+ var coinlib_core_1 = require("@airgap/coinlib-core");
5
+ var errors_1 = require("@airgap/coinlib-core/errors");
6
+ function convertSignature(signature, targetFormat) {
7
+ if (signature.format === targetFormat) {
8
+ return signature;
9
+ }
10
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, 'Unsupported signature key conversion.');
11
+ }
12
+ exports.convertSignature = convertSignature;
13
+ //# sourceMappingURL=signature.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signature.js","sourceRoot":"","sources":["../../../src/v1/utils/signature.ts"],"names":[],"mappings":";;;AAAA,qDAA6C;AAC7C,sDAA8D;AAG9D,SAAgB,gBAAgB,CAAC,SAAoB,EAAE,YAAiC;IACtF,IAAI,SAAS,CAAC,MAAM,KAAK,YAAY,EAAE;QACrC,OAAO,SAAS,CAAA;KACjB;IAED,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,MAAM,EAAE,uCAAuC,CAAC,CAAA;AACpF,CAAC;AAND,4CAMC"}
@@ -0,0 +1 @@
1
+ export declare function calculateTransactionLimit(limit: number, selfTotal: number, otherTotal: number, selfOffset: number, otherOffset: number): number;
@@ -0,0 +1,8 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.calculateTransactionLimit = void 0;
4
+ function calculateTransactionLimit(limit, selfTotal, otherTotal, selfOffset, otherOffset) {
5
+ return Math.min(Math.max(Math.ceil(limit / 2), limit - (otherTotal - otherOffset)), selfTotal - selfOffset);
6
+ }
7
+ exports.calculateTransactionLimit = calculateTransactionLimit;
8
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/v1/utils/transaction.ts"],"names":[],"mappings":";;;AAAA,SAAgB,yBAAyB,CACvC,KAAa,EACb,SAAiB,EACjB,UAAkB,EAClB,UAAkB,EAClB,WAAmB;IAEnB,OAAO,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,GAAG,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,UAAU,GAAG,WAAW,CAAC,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC,CAAA;AAC7G,CAAC;AARD,8DAQC"}