@firmachain/firma-js 0.2.13 → 0.2.17

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 (119) hide show
  1. package/package.json +1 -1
  2. package/dist/index.d.ts +0 -3
  3. package/dist/index.js +0 -15
  4. package/dist/sdk/FirmaBankService.d.ts +0 -15
  5. package/dist/sdk/FirmaBankService.js +0 -211
  6. package/dist/sdk/FirmaChainService.d.ts +0 -8
  7. package/dist/sdk/FirmaChainService.js +0 -86
  8. package/dist/sdk/FirmaConfig.d.ts +0 -16
  9. package/dist/sdk/FirmaConfig.js +0 -55
  10. package/dist/sdk/FirmaContractService.d.ts +0 -30
  11. package/dist/sdk/FirmaContractService.js +0 -394
  12. package/dist/sdk/FirmaDistributionService.d.ts +0 -27
  13. package/dist/sdk/FirmaDistributionService.js +0 -450
  14. package/dist/sdk/FirmaFeeGrantService.d.ts +0 -21
  15. package/dist/sdk/FirmaFeeGrantService.js +0 -341
  16. package/dist/sdk/FirmaGovService.d.ts +0 -35
  17. package/dist/sdk/FirmaGovService.js +0 -775
  18. package/dist/sdk/FirmaIpfsService.d.ts +0 -12
  19. package/dist/sdk/FirmaIpfsService.js +0 -185
  20. package/dist/sdk/FirmaNftService.d.ts +0 -28
  21. package/dist/sdk/FirmaNftService.js +0 -390
  22. package/dist/sdk/FirmaSDK.d.ts +0 -29
  23. package/dist/sdk/FirmaSDK.js +0 -48
  24. package/dist/sdk/FirmaSlashingService.d.ts +0 -9
  25. package/dist/sdk/FirmaSlashingService.js +0 -105
  26. package/dist/sdk/FirmaStakingService.d.ts +0 -34
  27. package/dist/sdk/FirmaStakingService.js +0 -604
  28. package/dist/sdk/FirmaTokenService.d.ts +0 -26
  29. package/dist/sdk/FirmaTokenService.js +0 -416
  30. package/dist/sdk/FirmaUtil.d.ts +0 -22
  31. package/dist/sdk/FirmaUtil.js +0 -151
  32. package/dist/sdk/FirmaWalletService.d.ts +0 -28
  33. package/dist/sdk/FirmaWalletService.js +0 -275
  34. package/dist/sdk/firmachain/bank/BankQueryClient.d.ts +0 -12
  35. package/dist/sdk/firmachain/bank/BankQueryClient.js +0 -116
  36. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +0 -16
  37. package/dist/sdk/firmachain/bank/BankTxClient.js +0 -40
  38. package/dist/sdk/firmachain/bank/index.d.ts +0 -3
  39. package/dist/sdk/firmachain/bank/index.js +0 -15
  40. package/dist/sdk/firmachain/common/ITxClient.d.ts +0 -13
  41. package/dist/sdk/firmachain/common/ITxClient.js +0 -98
  42. package/dist/sdk/firmachain/common/QueryCommon.d.ts +0 -4
  43. package/dist/sdk/firmachain/common/QueryCommon.js +0 -2
  44. package/dist/sdk/firmachain/common/TendermintQueryClient.d.ts +0 -42
  45. package/dist/sdk/firmachain/common/TendermintQueryClient.js +0 -108
  46. package/dist/sdk/firmachain/common/TxCommon.d.ts +0 -94
  47. package/dist/sdk/firmachain/common/TxCommon.js +0 -34
  48. package/dist/sdk/firmachain/common/accounts.d.ts +0 -16
  49. package/dist/sdk/firmachain/common/accounts.js +0 -64
  50. package/dist/sdk/firmachain/common/index.d.ts +0 -2
  51. package/dist/sdk/firmachain/common/index.js +0 -14
  52. package/dist/sdk/firmachain/common/signing.d.ts +0 -10
  53. package/dist/sdk/firmachain/common/signing.js +0 -59
  54. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +0 -37
  55. package/dist/sdk/firmachain/common/signingstargateclient.js +0 -282
  56. package/dist/sdk/firmachain/common/stargateclient.d.ts +0 -46
  57. package/dist/sdk/firmachain/common/stargateclient.js +0 -208
  58. package/dist/sdk/firmachain/contract/ContractQueryClient.d.ts +0 -31
  59. package/dist/sdk/firmachain/contract/ContractQueryClient.js +0 -141
  60. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +0 -16
  61. package/dist/sdk/firmachain/contract/ContractTxClient.js +0 -40
  62. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +0 -69
  63. package/dist/sdk/firmachain/contract/ContractTxTypes.js +0 -442
  64. package/dist/sdk/firmachain/contract/index.d.ts +0 -3
  65. package/dist/sdk/firmachain/contract/index.js +0 -15
  66. package/dist/sdk/firmachain/distribution/DistributionQueryClient.d.ts +0 -18
  67. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +0 -167
  68. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +0 -26
  69. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +0 -48
  70. package/dist/sdk/firmachain/distribution/index.d.ts +0 -3
  71. package/dist/sdk/firmachain/distribution/index.js +0 -16
  72. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.d.ts +0 -17
  73. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +0 -86
  74. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +0 -16
  75. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +0 -40
  76. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.d.ts +0 -76
  77. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +0 -144
  78. package/dist/sdk/firmachain/feegrant/index.d.ts +0 -2
  79. package/dist/sdk/firmachain/feegrant/index.js +0 -15
  80. package/dist/sdk/firmachain/google/protobuf/any.d.ts +0 -128
  81. package/dist/sdk/firmachain/google/protobuf/any.js +0 -105
  82. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +0 -996
  83. package/dist/sdk/firmachain/google/protobuf/descriptor.js +0 -4289
  84. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +0 -91
  85. package/dist/sdk/firmachain/google/protobuf/duration.js +0 -107
  86. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +0 -109
  87. package/dist/sdk/firmachain/google/protobuf/timestamp.js +0 -107
  88. package/dist/sdk/firmachain/gov/GovQueryClient.d.ts +0 -61
  89. package/dist/sdk/firmachain/gov/GovQueryClient.js +0 -152
  90. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +0 -21
  91. package/dist/sdk/firmachain/gov/GovTxClient.js +0 -44
  92. package/dist/sdk/firmachain/gov/index.d.ts +0 -3
  93. package/dist/sdk/firmachain/gov/index.js +0 -16
  94. package/dist/sdk/firmachain/nft/NftQueryClient.d.ts +0 -17
  95. package/dist/sdk/firmachain/nft/NftQueryClient.js +0 -121
  96. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +0 -21
  97. package/dist/sdk/firmachain/nft/NftTxClient.js +0 -44
  98. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +0 -86
  99. package/dist/sdk/firmachain/nft/NftTxTypes.js +0 -424
  100. package/dist/sdk/firmachain/nft/index.d.ts +0 -3
  101. package/dist/sdk/firmachain/nft/index.js +0 -15
  102. package/dist/sdk/firmachain/slashing/SlashingQueryClient.d.ts +0 -22
  103. package/dist/sdk/firmachain/slashing/SlashingQueryClient.js +0 -101
  104. package/dist/sdk/firmachain/slashing/index.d.ts +0 -2
  105. package/dist/sdk/firmachain/slashing/index.js +0 -14
  106. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +0 -93
  107. package/dist/sdk/firmachain/staking/StakingQueryClient.js +0 -223
  108. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +0 -31
  109. package/dist/sdk/firmachain/staking/StakingTxClient.js +0 -52
  110. package/dist/sdk/firmachain/staking/index.d.ts +0 -3
  111. package/dist/sdk/firmachain/staking/index.js +0 -15
  112. package/dist/sdk/firmachain/token/TokenQueryClient.d.ts +0 -24
  113. package/dist/sdk/firmachain/token/TokenQueryClient.js +0 -106
  114. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +0 -26
  115. package/dist/sdk/firmachain/token/TokenTxClient.js +0 -48
  116. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +0 -116
  117. package/dist/sdk/firmachain/token/TokenTxTypes.js +0 -685
  118. package/dist/sdk/firmachain/token/index.d.ts +0 -3
  119. package/dist/sdk/firmachain/token/index.js +0 -15
@@ -1,275 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.FirmaWalletService = void 0;
40
- var proto_signing_1 = require("@cosmjs/proto-signing");
41
- var crypto_1 = require("@cosmjs/crypto");
42
- var FirmaUtil_1 = require("./FirmaUtil");
43
- var CryptoJS = require("crypto-js");
44
- var FirmaWalletService = /** @class */ (function () {
45
- function FirmaWalletService(config) {
46
- this.config = config;
47
- this.mnemonic = "";
48
- this.privateKey = "";
49
- this.accountIndex = 0;
50
- }
51
- FirmaWalletService.prototype.getHdPath = function () {
52
- return this.config.hdPath;
53
- };
54
- FirmaWalletService.prototype.getPrefix = function () {
55
- return this.config.prefix;
56
- };
57
- FirmaWalletService.prototype.getRawWallet = function () {
58
- return this.wallet;
59
- };
60
- FirmaWalletService.prototype.getPrivateKey = function () {
61
- return this.privateKey;
62
- };
63
- FirmaWalletService.prototype.getMnemonic = function () {
64
- return this.mnemonic;
65
- };
66
- FirmaWalletService.prototype.getAddress = function () {
67
- return __awaiter(this, void 0, void 0, function () {
68
- var accounts, error_1;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
71
- case 0:
72
- _a.trys.push([0, 2, , 3]);
73
- return [4 /*yield*/, this.wallet.getAccounts()];
74
- case 1:
75
- accounts = _a.sent();
76
- return [2 /*return*/, accounts[0].address];
77
- case 2:
78
- error_1 = _a.sent();
79
- FirmaUtil_1.FirmaUtil.printLog(error_1);
80
- throw error_1;
81
- case 3: return [2 /*return*/];
82
- }
83
- });
84
- });
85
- };
86
- FirmaWalletService.getHdPath = function (hdPath, accountIndex) {
87
- try {
88
- return [crypto_1.stringToPath(hdPath + accountIndex + "'/0/0")];
89
- }
90
- catch (error) {
91
- FirmaUtil_1.FirmaUtil.printLog(error);
92
- throw error;
93
- }
94
- };
95
- FirmaWalletService.prototype.initFromMnemonic = function (mnemonic, accountIndex) {
96
- if (accountIndex === void 0) { accountIndex = 0; }
97
- return __awaiter(this, void 0, void 0, function () {
98
- var privateKey, error_2;
99
- return __generator(this, function (_a) {
100
- switch (_a.label) {
101
- case 0:
102
- _a.trys.push([0, 3, , 4]);
103
- this.mnemonic = mnemonic;
104
- this.accountIndex = accountIndex;
105
- return [4 /*yield*/, this.getPrivateKeyInternal(this.mnemonic, this.accountIndex)];
106
- case 1:
107
- privateKey = _a.sent();
108
- return [4 /*yield*/, this.initFromPrivateKey(privateKey)];
109
- case 2:
110
- _a.sent();
111
- return [2 /*return*/, { success: true }];
112
- case 3:
113
- error_2 = _a.sent();
114
- FirmaUtil_1.FirmaUtil.printLog(error_2);
115
- throw error_2;
116
- case 4: return [2 /*return*/];
117
- }
118
- });
119
- });
120
- };
121
- FirmaWalletService.prototype.getPrivateKeyInternal = function (mnemonic, accountIndex) {
122
- return __awaiter(this, void 0, void 0, function () {
123
- var mnemonicChecked, seed, hdpath, privkey, privateKey, error_3;
124
- return __generator(this, function (_a) {
125
- switch (_a.label) {
126
- case 0:
127
- _a.trys.push([0, 2, , 3]);
128
- mnemonicChecked = new crypto_1.EnglishMnemonic(mnemonic);
129
- return [4 /*yield*/, crypto_1.Bip39.mnemonicToSeed(mnemonicChecked)];
130
- case 1:
131
- seed = _a.sent();
132
- hdpath = FirmaWalletService.getHdPath(this.getHdPath(), this.accountIndex);
133
- privkey = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, seed, hdpath[0]).privkey;
134
- privateKey = "0x" + Buffer.from(privkey).toString("hex");
135
- return [2 /*return*/, privateKey];
136
- case 2:
137
- error_3 = _a.sent();
138
- FirmaUtil_1.FirmaUtil.printLog(error_3);
139
- throw error_3;
140
- case 3: return [2 /*return*/];
141
- }
142
- });
143
- });
144
- };
145
- FirmaWalletService.prototype.initFromPrivateKey = function (privateKey) {
146
- return __awaiter(this, void 0, void 0, function () {
147
- var tempPrivateKey, _a, error_4;
148
- return __generator(this, function (_b) {
149
- switch (_b.label) {
150
- case 0:
151
- _b.trys.push([0, 2, , 3]);
152
- tempPrivateKey = Buffer.from(privateKey.replace("0x", ""), "hex");
153
- _a = this;
154
- return [4 /*yield*/, proto_signing_1.DirectSecp256k1Wallet.fromKey(tempPrivateKey, this.getPrefix())];
155
- case 1:
156
- _a.wallet = _b.sent();
157
- this.privateKey = privateKey;
158
- return [3 /*break*/, 3];
159
- case 2:
160
- error_4 = _b.sent();
161
- FirmaUtil_1.FirmaUtil.printLog(error_4);
162
- throw error_4;
163
- case 3: return [2 /*return*/];
164
- }
165
- });
166
- });
167
- };
168
- FirmaWalletService.prototype.decryptData = function (data) {
169
- try {
170
- var bytes = CryptoJS.AES.decrypt(data, this.getPrivateKey());
171
- return bytes.toString(CryptoJS.enc.Utf8);
172
- }
173
- catch (error) {
174
- FirmaUtil_1.FirmaUtil.printLog(error);
175
- throw error;
176
- }
177
- };
178
- FirmaWalletService.prototype.encryptData = function (data) {
179
- try {
180
- return CryptoJS.AES.encrypt(data, this.getPrivateKey()).toString();
181
- }
182
- catch (error) {
183
- FirmaUtil_1.FirmaUtil.printLog(error);
184
- throw error;
185
- }
186
- };
187
- FirmaWalletService.prototype.newWallet = function () {
188
- return __awaiter(this, void 0, void 0, function () {
189
- var mnemonic, wallet, error_5;
190
- return __generator(this, function (_a) {
191
- switch (_a.label) {
192
- case 0:
193
- _a.trys.push([0, 3, , 4]);
194
- return [4 /*yield*/, this.generateMnemonic()];
195
- case 1:
196
- mnemonic = _a.sent();
197
- return [4 /*yield*/, this.fromMnemonic(mnemonic)];
198
- case 2:
199
- wallet = _a.sent();
200
- return [2 /*return*/, wallet];
201
- case 3:
202
- error_5 = _a.sent();
203
- FirmaUtil_1.FirmaUtil.printLog(error_5);
204
- throw error_5;
205
- case 4: return [2 /*return*/];
206
- }
207
- });
208
- });
209
- };
210
- FirmaWalletService.prototype.fromMnemonic = function (mnemonic, accountIndex) {
211
- if (accountIndex === void 0) { accountIndex = 0; }
212
- return __awaiter(this, void 0, void 0, function () {
213
- var wallet, error_6;
214
- return __generator(this, function (_a) {
215
- switch (_a.label) {
216
- case 0:
217
- _a.trys.push([0, 2, , 3]);
218
- wallet = new FirmaWalletService(this.config);
219
- return [4 /*yield*/, wallet.initFromMnemonic(mnemonic, accountIndex)];
220
- case 1:
221
- _a.sent();
222
- return [2 /*return*/, wallet];
223
- case 2:
224
- error_6 = _a.sent();
225
- FirmaUtil_1.FirmaUtil.printLog(error_6);
226
- throw error_6;
227
- case 3: return [2 /*return*/];
228
- }
229
- });
230
- });
231
- };
232
- FirmaWalletService.prototype.fromPrivateKey = function (privateKey) {
233
- return __awaiter(this, void 0, void 0, function () {
234
- var wallet, error_7;
235
- return __generator(this, function (_a) {
236
- switch (_a.label) {
237
- case 0:
238
- _a.trys.push([0, 2, , 3]);
239
- wallet = new FirmaWalletService(this.config);
240
- return [4 /*yield*/, wallet.initFromPrivateKey(privateKey)];
241
- case 1:
242
- _a.sent();
243
- return [2 /*return*/, wallet];
244
- case 2:
245
- error_7 = _a.sent();
246
- FirmaUtil_1.FirmaUtil.printLog(error_7);
247
- throw error_7;
248
- case 3: return [2 /*return*/];
249
- }
250
- });
251
- });
252
- };
253
- FirmaWalletService.prototype.generateMnemonic = function () {
254
- return __awaiter(this, void 0, void 0, function () {
255
- var wallet, error_8;
256
- return __generator(this, function (_a) {
257
- switch (_a.label) {
258
- case 0:
259
- _a.trys.push([0, 2, , 3]);
260
- return [4 /*yield*/, proto_signing_1.DirectSecp256k1HdWallet.generate(24)];
261
- case 1:
262
- wallet = _a.sent();
263
- return [2 /*return*/, wallet.mnemonic];
264
- case 2:
265
- error_8 = _a.sent();
266
- FirmaUtil_1.FirmaUtil.printLog(error_8);
267
- throw error_8;
268
- case 3: return [2 /*return*/];
269
- }
270
- });
271
- });
272
- };
273
- return FirmaWalletService;
274
- }());
275
- exports.FirmaWalletService = FirmaWalletService;
@@ -1,12 +0,0 @@
1
- export interface Token {
2
- denom: string;
3
- amount: string;
4
- }
5
- export declare class BankQueryClient {
6
- private readonly axios;
7
- constructor(baseUrl: string);
8
- querySupplyOf(denom: string): Promise<string>;
9
- queryTokenBalance(address: string, denom: string): Promise<Token>;
10
- queryBalanceList(address: string): Promise<Token[]>;
11
- queryBalance(address: string, denom: string): Promise<Token>;
12
- }
@@ -1,116 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- var __importDefault = (this && this.__importDefault) || function (mod) {
39
- return (mod && mod.__esModule) ? mod : { "default": mod };
40
- };
41
- Object.defineProperty(exports, "__esModule", { value: true });
42
- exports.BankQueryClient = void 0;
43
- var axios_1 = __importDefault(require("axios"));
44
- var BankQueryClient = /** @class */ (function () {
45
- function BankQueryClient(baseUrl) {
46
- this.axios = axios_1.default.create({
47
- baseURL: baseUrl,
48
- headers: {
49
- Accept: "application/json",
50
- },
51
- timeout: 15000,
52
- });
53
- }
54
- BankQueryClient.prototype.querySupplyOf = function (denom) {
55
- return __awaiter(this, void 0, void 0, function () {
56
- var path, result;
57
- return __generator(this, function (_a) {
58
- switch (_a.label) {
59
- case 0:
60
- path = "/cosmos/bank/v1beta1/supply/" + denom;
61
- return [4 /*yield*/, this.axios.get(path)];
62
- case 1:
63
- result = _a.sent();
64
- return [2 /*return*/, result.data.amount.amount];
65
- }
66
- });
67
- });
68
- };
69
- BankQueryClient.prototype.queryTokenBalance = function (address, denom) {
70
- return __awaiter(this, void 0, void 0, function () {
71
- var path, result;
72
- return __generator(this, function (_a) {
73
- switch (_a.label) {
74
- case 0:
75
- path = "/cosmos/bank/v1beta1/balances/" + address + "/" + denom;
76
- return [4 /*yield*/, this.axios.get(path)];
77
- case 1:
78
- result = _a.sent();
79
- return [2 /*return*/, result.data.balance];
80
- }
81
- });
82
- });
83
- };
84
- BankQueryClient.prototype.queryBalanceList = function (address) {
85
- return __awaiter(this, void 0, void 0, function () {
86
- var path, result;
87
- return __generator(this, function (_a) {
88
- switch (_a.label) {
89
- case 0:
90
- path = "/cosmos/bank/v1beta1/balances/" + address;
91
- return [4 /*yield*/, this.axios.get(path)];
92
- case 1:
93
- result = _a.sent();
94
- return [2 /*return*/, result.data.balances];
95
- }
96
- });
97
- });
98
- };
99
- BankQueryClient.prototype.queryBalance = function (address, denom) {
100
- return __awaiter(this, void 0, void 0, function () {
101
- var path, result;
102
- return __generator(this, function (_a) {
103
- switch (_a.label) {
104
- case 0:
105
- path = "/cosmos/bank/v1beta1/balances/" + address + "/" + denom;
106
- return [4 /*yield*/, this.axios.get(path)];
107
- case 1:
108
- result = _a.sent();
109
- return [2 /*return*/, result.data.balance];
110
- }
111
- });
112
- });
113
- };
114
- return BankQueryClient;
115
- }());
116
- exports.BankQueryClient = BankQueryClient;
@@ -1,16 +0,0 @@
1
- import { EncodeObject, OfflineDirectSigner } from "@cosmjs/proto-signing";
2
- import { MsgSend, MsgMultiSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
3
- import { ITxClient } from "../common/ITxClient";
4
- export interface MsgSendEncodeObject extends EncodeObject {
5
- readonly typeUrl: "/cosmos.bank.v1beta1.MsgSend";
6
- readonly value: Partial<MsgSend>;
7
- }
8
- export interface MsgMultiSendEncodeObject extends EncodeObject {
9
- readonly typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend";
10
- readonly value: Partial<MsgMultiSend>;
11
- }
12
- export declare class BankTxClient extends ITxClient {
13
- constructor(wallet: OfflineDirectSigner, address: string);
14
- msgSend(data: MsgSend): MsgSendEncodeObject;
15
- msgMultiSend(data: MsgMultiSend): MsgMultiSendEncodeObject;
16
- }
@@ -1,40 +0,0 @@
1
- "use strict";
2
- var __extends = (this && this.__extends) || (function () {
3
- var extendStatics = function (d, b) {
4
- extendStatics = Object.setPrototypeOf ||
5
- ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
- function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
- return extendStatics(d, b);
8
- };
9
- return function (d, b) {
10
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports.BankTxClient = void 0;
19
- var proto_signing_1 = require("@cosmjs/proto-signing");
20
- var tx_1 = require("cosmjs-types/cosmos/bank/v1beta1/tx");
21
- var ITxClient_1 = require("../common/ITxClient");
22
- var types = [
23
- ["/cosmos.bank.v1beta1.MsgSend", tx_1.MsgSend],
24
- ["/cosmos.bank.v1beta1.MsgMultiSend", tx_1.MsgMultiSend]
25
- ];
26
- var registry = new proto_signing_1.Registry(types);
27
- var BankTxClient = /** @class */ (function (_super) {
28
- __extends(BankTxClient, _super);
29
- function BankTxClient(wallet, address) {
30
- return _super.call(this, wallet, address, registry) || this;
31
- }
32
- BankTxClient.prototype.msgSend = function (data) {
33
- return { typeUrl: "/cosmos.bank.v1beta1.MsgSend", value: data };
34
- };
35
- BankTxClient.prototype.msgMultiSend = function (data) {
36
- return { typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", value: data };
37
- };
38
- return BankTxClient;
39
- }(ITxClient_1.ITxClient));
40
- exports.BankTxClient = BankTxClient;
@@ -1,3 +0,0 @@
1
- export * from './BankTxClient';
2
- export * from './BankQueryClient';
3
- export * from '../common';
@@ -1,15 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
10
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
11
- };
12
- Object.defineProperty(exports, "__esModule", { value: true });
13
- __exportStar(require("./BankTxClient"), exports);
14
- __exportStar(require("./BankQueryClient"), exports);
15
- __exportStar(require("../common"), exports);
@@ -1,13 +0,0 @@
1
- import { Registry, EncodeObject, OfflineDirectSigner } from "@cosmjs/proto-signing";
2
- import { SignAndBroadcastOptions } from ".";
3
- import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
4
- import { BroadcastTxResponse } from "./stargateclient";
5
- export declare class ITxClient {
6
- private readonly wallet;
7
- private readonly serverUrl;
8
- private readonly registry;
9
- constructor(wallet: OfflineDirectSigner, serverUrl: string, registry: Registry);
10
- sign(msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions): Promise<TxRaw>;
11
- broadcast(txRaw: TxRaw): Promise<BroadcastTxResponse>;
12
- signAndBroadcast(msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions): Promise<BroadcastTxResponse>;
13
- }
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- var __generator = (this && this.__generator) || function (thisArg, body) {
12
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
- function verb(n) { return function (v) { return step([n, v]); }; }
15
- function step(op) {
16
- if (f) throw new TypeError("Generator is already executing.");
17
- while (_) try {
18
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
- if (y = 0, t) op = [op[0] & 2, t.value];
20
- switch (op[0]) {
21
- case 0: case 1: t = op; break;
22
- case 4: _.label++; return { value: op[1], done: false };
23
- case 5: _.label++; y = op[1]; op = [0]; continue;
24
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
- default:
26
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
- if (t[2]) _.ops.pop();
31
- _.trys.pop(); continue;
32
- }
33
- op = body.call(thisArg, _);
34
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
- }
37
- };
38
- Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.ITxClient = void 0;
40
- var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
41
- var signingstargateclient_1 = require("./signingstargateclient");
42
- var ITxClient = /** @class */ (function () {
43
- function ITxClient(wallet, serverUrl, registry) {
44
- this.wallet = wallet;
45
- this.serverUrl = serverUrl;
46
- this.registry = registry;
47
- }
48
- ITxClient.prototype.sign = function (msgs, _a) {
49
- var fee = _a.fee, memo = _a.memo;
50
- return __awaiter(this, void 0, void 0, function () {
51
- var client, address;
52
- return __generator(this, function (_b) {
53
- switch (_b.label) {
54
- case 0: return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.connectWithSigner(this.serverUrl, this.wallet, this.registry)];
55
- case 1:
56
- client = _b.sent();
57
- return [4 /*yield*/, this.wallet.getAccounts()];
58
- case 2:
59
- address = (_b.sent())[0].address;
60
- return [4 /*yield*/, client.sign(address, msgs, fee, memo)];
61
- case 3: return [2 /*return*/, _b.sent()];
62
- }
63
- });
64
- });
65
- };
66
- ITxClient.prototype.broadcast = function (txRaw) {
67
- return __awaiter(this, void 0, void 0, function () {
68
- var client, txBytes;
69
- return __generator(this, function (_a) {
70
- switch (_a.label) {
71
- case 0: return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.connectWithSigner(this.serverUrl, this.wallet, this.registry)];
72
- case 1:
73
- client = _a.sent();
74
- txBytes = tx_1.TxRaw.encode(txRaw).finish();
75
- return [4 /*yield*/, client.broadcastTx(txBytes)];
76
- case 2: return [2 /*return*/, _a.sent()];
77
- }
78
- });
79
- });
80
- };
81
- ITxClient.prototype.signAndBroadcast = function (msgs, _a) {
82
- var fee = _a.fee, memo = _a.memo;
83
- return __awaiter(this, void 0, void 0, function () {
84
- var _b;
85
- return __generator(this, function (_c) {
86
- switch (_c.label) {
87
- case 0:
88
- _b = this.broadcast;
89
- return [4 /*yield*/, this.sign(msgs, { fee: fee, memo: memo })];
90
- case 1: return [4 /*yield*/, _b.apply(this, [_c.sent()])];
91
- case 2: return [2 /*return*/, _c.sent()];
92
- }
93
- });
94
- });
95
- };
96
- return ITxClient;
97
- }());
98
- exports.ITxClient = ITxClient;
@@ -1,4 +0,0 @@
1
- export interface Pagination {
2
- next_key: string;
3
- total: number;
4
- }
@@ -1,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,42 +0,0 @@
1
- export interface ChainSyncInfo {
2
- latest_block_hash: string;
3
- latest_app_hash: string;
4
- latest_block_height: string;
5
- latest_block_time: string;
6
- earliest_block_hash: string;
7
- earliest_app_hash: string;
8
- earliest_block_height: string;
9
- earliest_block_time: string;
10
- catching_up: boolean;
11
- }
12
- export interface TransactionEvent {
13
- type: string;
14
- attributes: {
15
- key: string;
16
- value: string;
17
- index: boolean;
18
- }[];
19
- }
20
- export interface TransactionHash {
21
- hash: string;
22
- height: string;
23
- index: number;
24
- tx_result: {
25
- code: number;
26
- data: string;
27
- log: string;
28
- info: string;
29
- gas_wanted: string;
30
- gas_used: string;
31
- events: TransactionEvent[];
32
- codespace: string;
33
- };
34
- tx: string;
35
- }
36
- export declare class TendermintQueryClient {
37
- private readonly axios;
38
- constructor(baseUrl: string);
39
- queryEstimateGas(hexTx: string): Promise<number>;
40
- queryChainSyncInfo(): Promise<ChainSyncInfo>;
41
- queryTransactionHash(txHash: string): Promise<TransactionHash>;
42
- }