@firmachain/firma-js 0.2.14 → 0.2.18

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 (71) hide show
  1. package/dist/index.d.ts +1 -0
  2. package/dist/index.js +1 -0
  3. package/dist/sdk/FirmaBankService.js +3 -3
  4. package/dist/sdk/FirmaContractService.js +8 -8
  5. package/dist/sdk/FirmaDistributionService.d.ts +4 -0
  6. package/dist/sdk/FirmaDistributionService.js +140 -66
  7. package/dist/sdk/FirmaFeeGrantService.js +6 -6
  8. package/dist/sdk/FirmaGovService.js +15 -15
  9. package/dist/sdk/FirmaMobileSDK.d.ts +27 -0
  10. package/dist/sdk/FirmaMobileSDK.js +45 -0
  11. package/dist/sdk/FirmaNftService.js +6 -6
  12. package/dist/sdk/FirmaStakingService.js +10 -10
  13. package/dist/sdk/FirmaTokenService.js +8 -8
  14. package/dist/sdk/FirmaUtil.d.ts +3 -0
  15. package/dist/sdk/FirmaUtil.js +56 -6
  16. package/dist/sdk/FirmaWalletService.d.ts +13 -1
  17. package/dist/sdk/FirmaWalletService.js +39 -5
  18. package/dist/sdk/firmachain/amino/addresses.d.ts +5 -0
  19. package/dist/sdk/firmachain/amino/addresses.js +46 -0
  20. package/dist/sdk/firmachain/amino/aminomsgs.d.ts +281 -0
  21. package/dist/sdk/firmachain/amino/aminomsgs.js +77 -0
  22. package/dist/sdk/firmachain/amino/aminotypes.d.ts +22 -0
  23. package/dist/sdk/firmachain/amino/aminotypes.js +521 -0
  24. package/dist/sdk/firmachain/amino/coins.d.ts +30 -0
  25. package/dist/sdk/firmachain/amino/coins.js +69 -0
  26. package/dist/sdk/firmachain/amino/encoding.d.ts +24 -0
  27. package/dist/sdk/firmachain/amino/encoding.js +234 -0
  28. package/dist/sdk/firmachain/amino/multisig.d.ts +10 -0
  29. package/dist/sdk/firmachain/amino/multisig.js +42 -0
  30. package/dist/sdk/firmachain/amino/paths.d.ts +6 -0
  31. package/dist/sdk/firmachain/amino/paths.js +18 -0
  32. package/dist/sdk/firmachain/amino/pubkeys.d.ts +47 -0
  33. package/dist/sdk/firmachain/amino/pubkeys.js +29 -0
  34. package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +94 -0
  35. package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +437 -0
  36. package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +23 -0
  37. package/dist/sdk/firmachain/amino/secp256k1wallet.js +141 -0
  38. package/dist/sdk/firmachain/amino/signature.d.ts +16 -0
  39. package/dist/sdk/firmachain/amino/signature.js +36 -0
  40. package/dist/sdk/firmachain/amino/signdoc.d.ts +26 -0
  41. package/dist/sdk/firmachain/amino/signdoc.js +42 -0
  42. package/dist/sdk/firmachain/amino/signer.d.ts +33 -0
  43. package/dist/sdk/firmachain/amino/signer.js +2 -0
  44. package/dist/sdk/firmachain/amino/stdtx.d.ts +15 -0
  45. package/dist/sdk/firmachain/amino/stdtx.js +17 -0
  46. package/dist/sdk/firmachain/amino/wallet.d.ts +32 -0
  47. package/dist/sdk/firmachain/amino/wallet.js +132 -0
  48. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +3 -2
  49. package/dist/sdk/firmachain/common/ITxClient.d.ts +4 -2
  50. package/dist/sdk/firmachain/common/ITxClient.js +10 -6
  51. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.d.ts +27 -0
  52. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +165 -0
  53. package/dist/sdk/firmachain/common/LedgerWallet.d.ts +9 -0
  54. package/dist/sdk/firmachain/common/LedgerWallet.js +150 -0
  55. package/dist/sdk/firmachain/common/signing.js +17 -1
  56. package/dist/sdk/firmachain/common/signingstargateclient.js +19 -3
  57. package/dist/sdk/firmachain/common/stargateclient.js +5 -2
  58. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +3 -2
  59. package/dist/sdk/firmachain/contract/ContractTxTypes.js +50 -9
  60. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +3 -2
  61. package/dist/sdk/firmachain/distribution/index.js +0 -1
  62. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +3 -2
  63. package/dist/sdk/firmachain/feegrant/FeeGrantTxTypes.js +63 -13
  64. package/dist/sdk/firmachain/google/protobuf/any.js +3 -2
  65. package/dist/sdk/firmachain/google/protobuf/descriptor.js +1364 -324
  66. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +3 -2
  67. package/dist/sdk/firmachain/gov/index.js +0 -1
  68. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +3 -2
  69. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +3 -2
  70. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +3 -2
  71. package/package.json +1 -1
@@ -224,7 +224,7 @@ var FirmaGovService = /** @class */ (function () {
224
224
  switch (_a.label) {
225
225
  case 0:
226
226
  _a.trys.push([0, 3, , 4]);
227
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
227
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
228
228
  sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT) };
229
229
  proposal = gov_2.TextProposal.fromPartial({
230
230
  title: title,
@@ -257,7 +257,7 @@ var FirmaGovService = /** @class */ (function () {
257
257
  switch (_a.label) {
258
258
  case 0:
259
259
  _a.trys.push([0, 3, , 4]);
260
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
260
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
261
261
  initialDepositAmount = {
262
262
  denom: this.config.denom,
263
263
  amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
@@ -297,7 +297,7 @@ var FirmaGovService = /** @class */ (function () {
297
297
  switch (_a.label) {
298
298
  case 0:
299
299
  _a.trys.push([0, 3, , 4]);
300
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
300
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
301
301
  initialDepositAmount = {
302
302
  denom: this.config.denom,
303
303
  amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
@@ -338,7 +338,7 @@ var FirmaGovService = /** @class */ (function () {
338
338
  switch (_a.label) {
339
339
  case 0:
340
340
  _a.trys.push([0, 3, , 4]);
341
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
341
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
342
342
  initialDepositAmount = {
343
343
  denom: this.config.denom,
344
344
  amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
@@ -379,7 +379,7 @@ var FirmaGovService = /** @class */ (function () {
379
379
  switch (_a.label) {
380
380
  case 0:
381
381
  _a.trys.push([0, 3, , 4]);
382
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
382
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
383
383
  initialDepositAmount = {
384
384
  denom: this.config.denom,
385
385
  amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(initialDepositFCT)
@@ -425,7 +425,7 @@ var FirmaGovService = /** @class */ (function () {
425
425
  return [4 /*yield*/, this.getSignedTxSubmitCancelSoftwareUpgradeProposal(wallet, title, description, initialDeposit, txMisc)];
426
426
  case 1:
427
427
  txRaw = _a.sent();
428
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
428
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
429
429
  return [4 /*yield*/, txClient.broadcast(txRaw)];
430
430
  case 2: return [2 /*return*/, _a.sent()];
431
431
  case 3:
@@ -456,7 +456,7 @@ var FirmaGovService = /** @class */ (function () {
456
456
  return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDeposit, plan, txMisc)];
457
457
  case 1:
458
458
  txRaw = _a.sent();
459
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
459
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
460
460
  return [4 /*yield*/, txClient.broadcast(txRaw)];
461
461
  case 2: return [2 /*return*/, _a.sent()];
462
462
  case 3:
@@ -486,7 +486,7 @@ var FirmaGovService = /** @class */ (function () {
486
486
  return [4 /*yield*/, this.getSignedTxSubmitSoftwareUpgradeProposal(wallet, title, description, initialDeposit, plan, txMisc)];
487
487
  case 1:
488
488
  txRaw = _a.sent();
489
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
489
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
490
490
  return [4 /*yield*/, txClient.broadcast(txRaw)];
491
491
  case 2: return [2 /*return*/, _a.sent()];
492
492
  case 3:
@@ -509,7 +509,7 @@ var FirmaGovService = /** @class */ (function () {
509
509
  return [4 /*yield*/, this.getSignedTxSubmitParameterChangeProposal(wallet, title, description, initialDeposit, paramList, txMisc)];
510
510
  case 1:
511
511
  txRaw = _a.sent();
512
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
512
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
513
513
  return [4 /*yield*/, txClient.broadcast(txRaw)];
514
514
  case 2: return [2 /*return*/, _a.sent()];
515
515
  case 3:
@@ -532,7 +532,7 @@ var FirmaGovService = /** @class */ (function () {
532
532
  return [4 /*yield*/, this.getSignedTxSubmitCommunityPoolSpendProposal(wallet, title, description, initialDeposit, amount, recipient, txMisc)];
533
533
  case 1:
534
534
  txRaw = _a.sent();
535
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
535
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
536
536
  return [4 /*yield*/, txClient.broadcast(txRaw)];
537
537
  case 2: return [2 /*return*/, _a.sent()];
538
538
  case 3:
@@ -555,7 +555,7 @@ var FirmaGovService = /** @class */ (function () {
555
555
  return [4 /*yield*/, this.getSignedTxSubmitTextProposal(wallet, title, description, initialDeposit, txMisc)];
556
556
  case 1:
557
557
  txRaw = _a.sent();
558
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
558
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
559
559
  return [4 /*yield*/, txClient.broadcast(txRaw)];
560
560
  case 2: return [2 /*return*/, _a.sent()];
561
561
  case 3:
@@ -578,7 +578,7 @@ var FirmaGovService = /** @class */ (function () {
578
578
  return [4 /*yield*/, wallet.getAddress()];
579
579
  case 1:
580
580
  voter = _a.sent();
581
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
581
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
582
582
  message = txClient.msgVote({ proposalId: proposalId, voter: voter, option: option });
583
583
  return [4 /*yield*/, txClient.sign([message], gov_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
584
584
  case 2: return [2 /*return*/, _a.sent()];
@@ -603,7 +603,7 @@ var FirmaGovService = /** @class */ (function () {
603
603
  return [4 /*yield*/, this.getSignedTxVote(wallet, longId, option, txMisc)];
604
604
  case 1:
605
605
  txRaw = _a.sent();
606
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
606
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
607
607
  return [4 /*yield*/, txClient.broadcast(txRaw)];
608
608
  case 2: return [2 /*return*/, _a.sent()];
609
609
  case 3:
@@ -623,7 +623,7 @@ var FirmaGovService = /** @class */ (function () {
623
623
  switch (_a.label) {
624
624
  case 0:
625
625
  _a.trys.push([0, 3, , 4]);
626
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
626
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
627
627
  return [4 /*yield*/, wallet.getAddress()];
628
628
  case 1:
629
629
  depositor = _a.sent();
@@ -652,7 +652,7 @@ var FirmaGovService = /** @class */ (function () {
652
652
  return [4 /*yield*/, this.getSignedTxDeposit(wallet, longId, amount, txMisc)];
653
653
  case 1:
654
654
  txRaw = _a.sent();
655
- txClient = new gov_1.GovTxClient(wallet.getRawWallet(), this.config.rpcAddress);
655
+ txClient = new gov_1.GovTxClient(wallet, this.config.rpcAddress);
656
656
  return [4 /*yield*/, txClient.broadcast(txRaw)];
657
657
  case 2: return [2 /*return*/, _a.sent()];
658
658
  case 3:
@@ -0,0 +1,27 @@
1
+ import { FirmaConfig } from "./FirmaConfig";
2
+ import { FirmaBankService } from "./FirmaBankService";
3
+ import { FirmaFeeGrantService } from "./FirmaFeeGrantService";
4
+ import { FirmaStakingService } from "./FirmaStakingService";
5
+ import { FirmaDistributionService } from "./FirmaDistributionService";
6
+ import { NftService } from "./FirmaNftService";
7
+ import { TokenService } from "./FirmaTokenService";
8
+ import { ContractService } from "./FirmaContractService";
9
+ import { FirmaWalletService } from "./FirmaWalletService";
10
+ import { FirmaGovService } from "./FirmaGovService";
11
+ import { ChainService } from "./FirmaChainService";
12
+ import { SlashingService } from "./FirmaSlashingService";
13
+ export declare class FirmaMobileSDK {
14
+ Config: FirmaConfig;
15
+ Wallet: FirmaWalletService;
16
+ Bank: FirmaBankService;
17
+ FeeGrant: FirmaFeeGrantService;
18
+ Staking: FirmaStakingService;
19
+ Distribution: FirmaDistributionService;
20
+ Gov: FirmaGovService;
21
+ Nft: NftService;
22
+ Token: TokenService;
23
+ Contract: ContractService;
24
+ BlockChain: ChainService;
25
+ Slashing: SlashingService;
26
+ constructor(Config: FirmaConfig, Wallet?: FirmaWalletService, Bank?: FirmaBankService, FeeGrant?: FirmaFeeGrantService, Staking?: FirmaStakingService, Distribution?: FirmaDistributionService, Gov?: FirmaGovService, Nft?: NftService, Token?: TokenService, Contract?: ContractService, BlockChain?: ChainService, Slashing?: SlashingService);
27
+ }
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FirmaMobileSDK = void 0;
4
+ var FirmaBankService_1 = require("./FirmaBankService");
5
+ var FirmaFeeGrantService_1 = require("./FirmaFeeGrantService");
6
+ var FirmaStakingService_1 = require("./FirmaStakingService");
7
+ var FirmaDistributionService_1 = require("./FirmaDistributionService");
8
+ var FirmaNftService_1 = require("./FirmaNftService");
9
+ var FirmaTokenService_1 = require("./FirmaTokenService");
10
+ var FirmaContractService_1 = require("./FirmaContractService");
11
+ var FirmaWalletService_1 = require("./FirmaWalletService");
12
+ var FirmaUtil_1 = require("./FirmaUtil");
13
+ var FirmaGovService_1 = require("./FirmaGovService");
14
+ var FirmaChainService_1 = require("./FirmaChainService");
15
+ var FirmaSlashingService_1 = require("./FirmaSlashingService");
16
+ var FirmaMobileSDK = /** @class */ (function () {
17
+ function FirmaMobileSDK(Config, Wallet, Bank, FeeGrant, Staking, Distribution, Gov, Nft, Token, Contract, BlockChain, Slashing) {
18
+ if (Wallet === void 0) { Wallet = new FirmaWalletService_1.FirmaWalletService(Config); }
19
+ if (Bank === void 0) { Bank = new FirmaBankService_1.FirmaBankService(Config); }
20
+ if (FeeGrant === void 0) { FeeGrant = new FirmaFeeGrantService_1.FirmaFeeGrantService(Config); }
21
+ if (Staking === void 0) { Staking = new FirmaStakingService_1.FirmaStakingService(Config); }
22
+ if (Distribution === void 0) { Distribution = new FirmaDistributionService_1.FirmaDistributionService(Config); }
23
+ if (Gov === void 0) { Gov = new FirmaGovService_1.FirmaGovService(Config); }
24
+ if (Nft === void 0) { Nft = new FirmaNftService_1.NftService(Config); }
25
+ if (Token === void 0) { Token = new FirmaTokenService_1.TokenService(Config); }
26
+ if (Contract === void 0) { Contract = new FirmaContractService_1.ContractService(Config); }
27
+ if (BlockChain === void 0) { BlockChain = new FirmaChainService_1.ChainService(Config); }
28
+ if (Slashing === void 0) { Slashing = new FirmaSlashingService_1.SlashingService(Config); }
29
+ this.Config = Config;
30
+ this.Wallet = Wallet;
31
+ this.Bank = Bank;
32
+ this.FeeGrant = FeeGrant;
33
+ this.Staking = Staking;
34
+ this.Distribution = Distribution;
35
+ this.Gov = Gov;
36
+ this.Nft = Nft;
37
+ this.Token = Token;
38
+ this.Contract = Contract;
39
+ this.BlockChain = BlockChain;
40
+ this.Slashing = Slashing;
41
+ FirmaUtil_1.FirmaUtil.config = Config;
42
+ }
43
+ return FirmaMobileSDK;
44
+ }());
45
+ exports.FirmaMobileSDK = FirmaMobileSDK;
@@ -211,7 +211,7 @@ var NftService = /** @class */ (function () {
211
211
  return [4 /*yield*/, wallet.getAddress()];
212
212
  case 1:
213
213
  address = _a.sent();
214
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
214
+ nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
215
215
  message = nftTxClient.msgTransfer({ owner: address, toAddress: toAddress, nftId: parseInt(nftID) });
216
216
  return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
217
217
  case 2: return [2 /*return*/, _a.sent()];
@@ -235,7 +235,7 @@ var NftService = /** @class */ (function () {
235
235
  return [4 /*yield*/, this.getSignedTxTransfer(wallet, toAddress, nftID, txMisc)];
236
236
  case 1:
237
237
  txRaw = _a.sent();
238
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
238
+ nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
239
239
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
240
240
  case 2: return [2 /*return*/, _a.sent()];
241
241
  case 3:
@@ -280,7 +280,7 @@ var NftService = /** @class */ (function () {
280
280
  return [4 /*yield*/, wallet.getAddress()];
281
281
  case 1:
282
282
  address = _a.sent();
283
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
283
+ nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
284
284
  message = nftTxClient.msgBurn({ owner: address, nftId: parseInt(nftID) });
285
285
  return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
286
286
  case 2: return [2 /*return*/, _a.sent()];
@@ -304,7 +304,7 @@ var NftService = /** @class */ (function () {
304
304
  return [4 /*yield*/, this.getSignedTxBurn(wallet, nftID, txMisc)];
305
305
  case 1:
306
306
  txRaw = _a.sent();
307
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
307
+ nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
308
308
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
309
309
  case 2: return [2 /*return*/, _a.sent()];
310
310
  case 3:
@@ -349,7 +349,7 @@ var NftService = /** @class */ (function () {
349
349
  return [4 /*yield*/, wallet.getAddress()];
350
350
  case 1:
351
351
  address = _a.sent();
352
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
352
+ nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
353
353
  message = nftTxClient.msgMint({ owner: address, tokenURI: tokenURI });
354
354
  return [4 /*yield*/, nftTxClient.sign([message], nft_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
355
355
  case 2: return [2 /*return*/, _a.sent()];
@@ -373,7 +373,7 @@ var NftService = /** @class */ (function () {
373
373
  return [4 /*yield*/, this.getSignedTxMint(wallet, tokenURI, txMisc)];
374
374
  case 1:
375
375
  txRaw = _a.sent();
376
- nftTxClient = new nft_1.NftTxClient(wallet.getRawWallet(), this.config.rpcAddress);
376
+ nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
377
377
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
378
378
  case 2: return [2 /*return*/, _a.sent()];
379
379
  case 3:
@@ -117,7 +117,7 @@ var FirmaStakingService = /** @class */ (function () {
117
117
  switch (_a.label) {
118
118
  case 0:
119
119
  _a.trys.push([0, 3, , 4]);
120
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
120
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
121
121
  return [4 /*yield*/, wallet.getAddress()];
122
122
  case 1:
123
123
  address = _a.sent();
@@ -146,7 +146,7 @@ var FirmaStakingService = /** @class */ (function () {
146
146
  switch (_a.label) {
147
147
  case 0:
148
148
  _a.trys.push([0, 3, , 4]);
149
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
149
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
150
150
  return [4 /*yield*/, wallet.getAddress()];
151
151
  case 1:
152
152
  address = _a.sent();
@@ -175,7 +175,7 @@ var FirmaStakingService = /** @class */ (function () {
175
175
  switch (_a.label) {
176
176
  case 0:
177
177
  _a.trys.push([0, 3, , 4]);
178
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
178
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
179
179
  return [4 /*yield*/, wallet.getAddress()];
180
180
  case 1:
181
181
  address = _a.sent();
@@ -205,7 +205,7 @@ var FirmaStakingService = /** @class */ (function () {
205
205
  switch (_a.label) {
206
206
  case 0:
207
207
  _a.trys.push([0, 2, , 3]);
208
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
208
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
209
209
  message = txClient.msgCreateValidator({
210
210
  description: validatorInfo.description,
211
211
  commission: validatorInfo.commission,
@@ -234,7 +234,7 @@ var FirmaStakingService = /** @class */ (function () {
234
234
  switch (_a.label) {
235
235
  case 0:
236
236
  _a.trys.push([0, 2, , 3]);
237
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
237
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
238
238
  message = txClient.msgEditValidator({
239
239
  validatorAddress: validatorAddress,
240
240
  description: description,
@@ -263,7 +263,7 @@ var FirmaStakingService = /** @class */ (function () {
263
263
  return [4 /*yield*/, this.getSignedTxCreateValidator(wallet, validatorInfo, txMisc)];
264
264
  case 1:
265
265
  txRaw = _a.sent();
266
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
266
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
267
267
  return [4 /*yield*/, txClient.broadcast(txRaw)];
268
268
  case 2: return [2 /*return*/, _a.sent()];
269
269
  case 3:
@@ -286,7 +286,7 @@ var FirmaStakingService = /** @class */ (function () {
286
286
  return [4 /*yield*/, this.getSignedTxEditValidator(wallet, validatorAddress, description, commissionRate, minSelfDelegation, txMisc)];
287
287
  case 1:
288
288
  txRaw = _a.sent();
289
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
289
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
290
290
  return [4 /*yield*/, txClient.broadcast(txRaw)];
291
291
  case 2: return [2 /*return*/, _a.sent()];
292
292
  case 3:
@@ -309,7 +309,7 @@ var FirmaStakingService = /** @class */ (function () {
309
309
  return [4 /*yield*/, this.getSignedTxRedelegate(wallet, validatorSrcAddress, validatorDstAddress, amount, txMisc)];
310
310
  case 1:
311
311
  txRaw = _a.sent();
312
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
312
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
313
313
  return [4 /*yield*/, txClient.broadcast(txRaw)];
314
314
  case 2: return [2 /*return*/, _a.sent()];
315
315
  case 3:
@@ -332,7 +332,7 @@ var FirmaStakingService = /** @class */ (function () {
332
332
  return [4 /*yield*/, this.getSignedTxUndelegate(wallet, targetAddress, amount, txMisc)];
333
333
  case 1:
334
334
  txRaw = _a.sent();
335
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
335
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
336
336
  return [4 /*yield*/, txClient.broadcast(txRaw)];
337
337
  case 2: return [2 /*return*/, _a.sent()];
338
338
  case 3:
@@ -355,7 +355,7 @@ var FirmaStakingService = /** @class */ (function () {
355
355
  return [4 /*yield*/, this.getSignedTxDelegate(wallet, targetAddress, amount, txMisc)];
356
356
  case 1:
357
357
  txRaw = _a.sent();
358
- txClient = new staking_1.StakingTxClient(wallet.getRawWallet(), this.config.rpcAddress);
358
+ txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
359
359
  return [4 /*yield*/, txClient.broadcast(txRaw)];
360
360
  case 2: return [2 /*return*/, _a.sent()];
361
361
  case 3:
@@ -145,7 +145,7 @@ var TokenService = /** @class */ (function () {
145
145
  return [4 /*yield*/, wallet.getAddress()];
146
146
  case 1:
147
147
  address = _a.sent();
148
- txClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
148
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
149
149
  message = txClient.msgUpdateTokenURI({
150
150
  owner: address,
151
151
  tokenID: tokenID,
@@ -173,7 +173,7 @@ var TokenService = /** @class */ (function () {
173
173
  return [4 /*yield*/, wallet.getAddress()];
174
174
  case 1:
175
175
  address = _a.sent();
176
- txClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
176
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
177
177
  message = txClient.msgBurn({
178
178
  owner: address,
179
179
  tokenID: tokenID,
@@ -201,7 +201,7 @@ var TokenService = /** @class */ (function () {
201
201
  return [4 /*yield*/, wallet.getAddress()];
202
202
  case 1:
203
203
  address = _a.sent();
204
- txClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
204
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
205
205
  message = txClient.msgMint({
206
206
  owner: address,
207
207
  tokenID: tokenID,
@@ -230,7 +230,7 @@ var TokenService = /** @class */ (function () {
230
230
  return [4 /*yield*/, wallet.getAddress()];
231
231
  case 1:
232
232
  address = _a.sent();
233
- txClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
233
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
234
234
  message = txClient.msgCreateToken({
235
235
  owner: address,
236
236
  name: tokenName,
@@ -265,7 +265,7 @@ var TokenService = /** @class */ (function () {
265
265
  return [4 /*yield*/, this.getSignedTxCreateToken(wallet, tokenName, tokenSymbol, tokenURI, newTotalSupply, decimal, isMintable, isBurnable, txMisc)];
266
266
  case 1:
267
267
  txRaw = _a.sent();
268
- nftTxClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
268
+ nftTxClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
269
269
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
270
270
  case 2: return [2 /*return*/, _a.sent()];
271
271
  case 3:
@@ -289,7 +289,7 @@ var TokenService = /** @class */ (function () {
289
289
  return [4 /*yield*/, this.getSignedTxMint(wallet, tokenID, newAmount, toAddress, txMisc)];
290
290
  case 1:
291
291
  txRaw = _a.sent();
292
- nftTxClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
292
+ nftTxClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
293
293
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
294
294
  case 2: return [2 /*return*/, _a.sent()];
295
295
  case 3:
@@ -313,7 +313,7 @@ var TokenService = /** @class */ (function () {
313
313
  return [4 /*yield*/, this.getSignedTxBurn(wallet, tokenID, newAmount, txMisc)];
314
314
  case 1:
315
315
  txRaw = _a.sent();
316
- nftTxClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
316
+ nftTxClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
317
317
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
318
318
  case 2: return [2 /*return*/, _a.sent()];
319
319
  case 3:
@@ -336,7 +336,7 @@ var TokenService = /** @class */ (function () {
336
336
  return [4 /*yield*/, this.getSignedTxUpdateTokenURI(wallet, tokenID, tokenURI, txMisc)];
337
337
  case 1:
338
338
  txRaw = _a.sent();
339
- nftTxClient = new token_1.TokenTxClient(wallet.getRawWallet(), this.config.rpcAddress);
339
+ nftTxClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
340
340
  return [4 /*yield*/, nftTxClient.broadcast(txRaw)];
341
341
  case 2: return [2 /*return*/, _a.sent()];
342
342
  case 3:
@@ -1,5 +1,6 @@
1
1
  import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
2
2
  import { FirmaConfig } from "./FirmaConfig";
3
+ import { SignerData } from "./firmachain/common/LedgerSigningStargateClient";
3
4
  export declare class FirmaUtil {
4
5
  static config: FirmaConfig;
5
6
  static readonly FctDecimal: number;
@@ -17,6 +18,8 @@ export declare class FirmaUtil {
17
18
  static isValidAddress(address: string): boolean;
18
19
  static getValOperAddressFromAccAddress(address: string): string;
19
20
  static getAccAddressFromValOperAddress(address: string): string;
21
+ static getSignerDataForLedger(address: string): Promise<SignerData>;
20
22
  static estimateGas(txRaw: TxRaw): Promise<number>;
23
+ static estimateGasRaw(txRaw: Uint8Array): Promise<number>;
21
24
  static printLog(log: any): void;
22
25
  }
@@ -40,10 +40,11 @@ exports.FirmaUtil = void 0;
40
40
  var fs_1 = require("fs");
41
41
  var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
42
42
  var TendermintQueryClient_1 = require("./firmachain/common/TendermintQueryClient");
43
+ var encoding_1 = require("@cosmjs/encoding");
44
+ var LedgerSigningStargateClient_1 = require("./firmachain/common/LedgerSigningStargateClient");
43
45
  var CryptoJS = require("crypto-js");
44
46
  var sha256 = require("crypto-js/sha256");
45
47
  var encHex = require("crypto-js/enc-hex");
46
- var encoding_1 = require("@cosmjs/encoding");
47
48
  var FirmaUtil = /** @class */ (function () {
48
49
  function FirmaUtil(firmaConfig) {
49
50
  FirmaUtil.config = firmaConfig;
@@ -101,7 +102,8 @@ var FirmaUtil = /** @class */ (function () {
101
102
  };
102
103
  FirmaUtil.isValidAddress = function (address) {
103
104
  try {
104
- var data = encoding_1.Bech32.decode(address).data;
105
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
106
+ encoding_1.Bech32.decode(address).data;
105
107
  return true;
106
108
  }
107
109
  catch (e) {
@@ -116,9 +118,32 @@ var FirmaUtil = /** @class */ (function () {
116
118
  var data = encoding_1.Bech32.decode(address).data;
117
119
  return encoding_1.Bech32.encode(FirmaUtil.config.prefix, data);
118
120
  };
121
+ FirmaUtil.getSignerDataForLedger = function (address) {
122
+ return __awaiter(this, void 0, void 0, function () {
123
+ var signingClient, sequence, error_1;
124
+ return __generator(this, function (_a) {
125
+ switch (_a.label) {
126
+ case 0:
127
+ _a.trys.push([0, 3, , 4]);
128
+ return [4 /*yield*/, LedgerSigningStargateClient_1.LedgerSigningStargateClient.connectWithSigner(FirmaUtil.config.rpcAddress)];
129
+ case 1:
130
+ signingClient = _a.sent();
131
+ return [4 /*yield*/, signingClient.getSignerData(address)];
132
+ case 2:
133
+ sequence = _a.sent();
134
+ return [2 /*return*/, sequence];
135
+ case 3:
136
+ error_1 = _a.sent();
137
+ FirmaUtil.printLog(error_1);
138
+ throw error_1;
139
+ case 4: return [2 /*return*/];
140
+ }
141
+ });
142
+ });
143
+ };
119
144
  FirmaUtil.estimateGas = function (txRaw) {
120
145
  return __awaiter(this, void 0, void 0, function () {
121
- var encodedTx, hexTx, queryClient, gas, multiplier, error_1;
146
+ var encodedTx, hexTx, queryClient, gas, multiplier, error_2;
122
147
  return __generator(this, function (_a) {
123
148
  switch (_a.label) {
124
149
  case 0:
@@ -132,9 +157,34 @@ var FirmaUtil = /** @class */ (function () {
132
157
  multiplier = 1.25;
133
158
  return [2 /*return*/, Math.ceil(gas * multiplier)];
134
159
  case 2:
135
- error_1 = _a.sent();
136
- FirmaUtil.printLog(error_1);
137
- throw error_1;
160
+ error_2 = _a.sent();
161
+ FirmaUtil.printLog(error_2);
162
+ throw error_2;
163
+ case 3: return [2 /*return*/];
164
+ }
165
+ });
166
+ });
167
+ };
168
+ FirmaUtil.estimateGasRaw = function (txRaw) {
169
+ return __awaiter(this, void 0, void 0, function () {
170
+ var encodedTx, hexTx, queryClient, gas, multiplier, error_3;
171
+ return __generator(this, function (_a) {
172
+ switch (_a.label) {
173
+ case 0:
174
+ _a.trys.push([0, 2, , 3]);
175
+ encodedTx = Uint8Array.from(txRaw);
176
+ hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
177
+ console.log("hexTx:" + hexTx);
178
+ queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
179
+ return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
180
+ case 1:
181
+ gas = _a.sent();
182
+ multiplier = 1.25;
183
+ return [2 /*return*/, Math.ceil(gas * multiplier)];
184
+ case 2:
185
+ error_3 = _a.sent();
186
+ FirmaUtil.printLog(error_3);
187
+ throw error_3;
138
188
  case 3: return [2 /*return*/];
139
189
  }
140
190
  });
@@ -1,16 +1,28 @@
1
- import { DirectSecp256k1Wallet } from "@cosmjs/proto-signing";
1
+ import { DirectSecp256k1Wallet, Registry } from "@cosmjs/proto-signing";
2
+ import { EncodeObject } from "@cosmjs/proto-signing";
2
3
  import { FirmaConfig } from "./FirmaConfig";
4
+ import { SignAndBroadcastOptions } from "./firmachain/common";
5
+ import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
6
+ export interface LedgerWalletInterface {
7
+ getAddress(): Promise<string>;
8
+ sign(message: string): Promise<Uint8Array>;
9
+ getPublicKey(): Promise<Uint8Array>;
10
+ }
3
11
  export declare class FirmaWalletService {
4
12
  private readonly config;
5
13
  private mnemonic;
6
14
  private privateKey;
7
15
  private accountIndex;
8
16
  private wallet;
17
+ private ledger;
9
18
  getHdPath(): string;
10
19
  getPrefix(): string;
11
20
  getRawWallet(): DirectSecp256k1Wallet;
12
21
  getPrivateKey(): string;
13
22
  getMnemonic(): string;
23
+ isLedger(): boolean;
24
+ initFromLedger(ledger: LedgerWalletInterface): Promise<FirmaWalletService>;
25
+ signLedger(messages: EncodeObject[], option: SignAndBroadcastOptions, registry: Registry): Promise<TxRaw>;
14
26
  getAddress(): Promise<string>;
15
27
  constructor(config: FirmaConfig);
16
28
  private static getHdPath;
@@ -40,6 +40,7 @@ exports.FirmaWalletService = void 0;
40
40
  var proto_signing_1 = require("@cosmjs/proto-signing");
41
41
  var crypto_1 = require("@cosmjs/crypto");
42
42
  var FirmaUtil_1 = require("./FirmaUtil");
43
+ var LedgerWallet_1 = require("./firmachain/common/LedgerWallet");
43
44
  var CryptoJS = require("crypto-js");
44
45
  var FirmaWalletService = /** @class */ (function () {
45
46
  function FirmaWalletService(config) {
@@ -63,22 +64,55 @@ var FirmaWalletService = /** @class */ (function () {
63
64
  FirmaWalletService.prototype.getMnemonic = function () {
64
65
  return this.mnemonic;
65
66
  };
67
+ FirmaWalletService.prototype.isLedger = function () {
68
+ return (this.ledger != null);
69
+ };
70
+ FirmaWalletService.prototype.initFromLedger = function (ledger) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var wallet;
73
+ return __generator(this, function (_a) {
74
+ try {
75
+ wallet = new FirmaWalletService(this.config);
76
+ wallet.ledger = ledger;
77
+ return [2 /*return*/, wallet];
78
+ }
79
+ catch (error) {
80
+ FirmaUtil_1.FirmaUtil.printLog(error);
81
+ throw error;
82
+ }
83
+ return [2 /*return*/];
84
+ });
85
+ });
86
+ };
87
+ FirmaWalletService.prototype.signLedger = function (messages, option, registry) {
88
+ return __awaiter(this, void 0, void 0, function () {
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0: return [4 /*yield*/, LedgerWallet_1.signFromLedger(this.ledger, messages, option, registry)];
92
+ case 1: return [2 /*return*/, _a.sent()];
93
+ }
94
+ });
95
+ });
96
+ };
66
97
  FirmaWalletService.prototype.getAddress = function () {
67
98
  return __awaiter(this, void 0, void 0, function () {
68
99
  var accounts, error_1;
69
100
  return __generator(this, function (_a) {
70
101
  switch (_a.label) {
71
102
  case 0:
72
- _a.trys.push([0, 2, , 3]);
73
- return [4 /*yield*/, this.wallet.getAccounts()];
74
- case 1:
103
+ _a.trys.push([0, 4, , 5]);
104
+ if (!(this.ledger != null)) return [3 /*break*/, 2];
105
+ return [4 /*yield*/, this.ledger.getAddress()];
106
+ case 1: return [2 /*return*/, _a.sent()];
107
+ case 2: return [4 /*yield*/, this.wallet.getAccounts()];
108
+ case 3:
75
109
  accounts = _a.sent();
76
110
  return [2 /*return*/, accounts[0].address];
77
- case 2:
111
+ case 4:
78
112
  error_1 = _a.sent();
79
113
  FirmaUtil_1.FirmaUtil.printLog(error_1);
80
114
  throw error_1;
81
- case 3: return [2 /*return*/];
115
+ case 5: return [2 /*return*/];
82
116
  }
83
117
  });
84
118
  });
@@ -0,0 +1,5 @@
1
+ import { Pubkey } from "./pubkeys";
2
+ export declare function rawEd25519PubkeyToRawAddress(pubkeyData: Uint8Array): Uint8Array;
3
+ export declare function rawSecp256k1PubkeyToRawAddress(pubkeyData: Uint8Array): Uint8Array;
4
+ export declare function pubkeyToRawAddress(pubkey: Pubkey): Uint8Array;
5
+ export declare function pubkeyToAddress(pubkey: Pubkey, prefix: string): string;