@firmachain/firma-js 0.2.31 → 0.2.34

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 (103) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/sdk/FirmaAuthzService.d.ts +13 -4
  3. package/dist/sdk/FirmaAuthzService.js +29 -26
  4. package/dist/sdk/FirmaBankService.js +2 -2
  5. package/dist/sdk/FirmaContractService.js +14 -16
  6. package/dist/sdk/FirmaCosmWasmService.js +27 -29
  7. package/dist/sdk/FirmaDistributionService.js +10 -10
  8. package/dist/sdk/FirmaFeeGrantService.js +6 -6
  9. package/dist/sdk/FirmaGovService.js +26 -26
  10. package/dist/sdk/FirmaIbcService.d.ts +15 -0
  11. package/dist/sdk/FirmaIbcService.js +144 -0
  12. package/dist/sdk/FirmaIpfsService.js +1 -1
  13. package/dist/sdk/FirmaNftService.js +9 -9
  14. package/dist/sdk/FirmaSDK.d.ts +3 -1
  15. package/dist/sdk/FirmaSDK.js +4 -1
  16. package/dist/sdk/FirmaStakingService.d.ts +17 -5
  17. package/dist/sdk/FirmaStakingService.js +22 -18
  18. package/dist/sdk/FirmaTokenService.js +16 -16
  19. package/dist/sdk/FirmaUtil.d.ts +19 -1
  20. package/dist/sdk/FirmaUtil.js +198 -3
  21. package/dist/sdk/FirmaWalletService.d.ts +3 -0
  22. package/dist/sdk/FirmaWalletService.js +21 -13
  23. package/dist/sdk/firmachain/amino/addresses.js +11 -11
  24. package/dist/sdk/firmachain/amino/aminotypes.js +36 -32
  25. package/dist/sdk/firmachain/amino/encoding.js +30 -26
  26. package/dist/sdk/firmachain/amino/multisig.js +5 -5
  27. package/dist/sdk/firmachain/amino/signature.js +4 -4
  28. package/dist/sdk/firmachain/amino/signdoc.js +1 -1
  29. package/dist/sdk/firmachain/amino/signer.d.ts +1 -2
  30. package/dist/sdk/firmachain/amino/wallet.js +14 -10
  31. package/dist/sdk/firmachain/authz/AuthzQueryClient.d.ts +13 -3
  32. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +42 -15
  33. package/dist/sdk/firmachain/authz/AuthzTxClient.d.ts +5 -4
  34. package/dist/sdk/firmachain/authz/AuthzTxClient.js +6 -3
  35. package/dist/sdk/firmachain/authz/index.js +5 -1
  36. package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
  37. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +4 -3
  38. package/dist/sdk/firmachain/bank/BankTxClient.js +5 -2
  39. package/dist/sdk/firmachain/bank/index.js +5 -1
  40. package/dist/sdk/firmachain/common/CommonTxClient.d.ts +7 -0
  41. package/dist/sdk/firmachain/common/CommonTxClient.js +79 -0
  42. package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -3
  43. package/dist/sdk/firmachain/common/ITxClient.js +14 -8
  44. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +2 -2
  45. package/dist/sdk/firmachain/common/LedgerWallet.js +14 -10
  46. package/dist/sdk/firmachain/common/accounts.js +2 -2
  47. package/dist/sdk/firmachain/common/index.js +5 -1
  48. package/dist/sdk/firmachain/common/signing.js +9 -5
  49. package/dist/sdk/firmachain/common/signingaminostargateclient.d.ts +50 -0
  50. package/dist/sdk/firmachain/common/signingaminostargateclient.js +267 -0
  51. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +15 -8
  52. package/dist/sdk/firmachain/common/signingstargateclient.js +82 -19
  53. package/dist/sdk/firmachain/common/stargateclient.js +6 -6
  54. package/dist/sdk/firmachain/contract/ContractQueryClient.js +2 -2
  55. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +4 -3
  56. package/dist/sdk/firmachain/contract/ContractTxClient.js +5 -2
  57. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +4 -4
  58. package/dist/sdk/firmachain/contract/index.js +5 -1
  59. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +7 -7
  60. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.d.ts +8 -7
  61. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.js +9 -6
  62. package/dist/sdk/firmachain/cosmwasm/index.js +5 -1
  63. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +5 -5
  64. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +6 -5
  65. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +7 -4
  66. package/dist/sdk/firmachain/distribution/index.js +5 -1
  67. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +2 -2
  68. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +4 -3
  69. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +5 -2
  70. package/dist/sdk/firmachain/feegrant/index.js +5 -1
  71. package/dist/sdk/firmachain/google/protobuf/any.d.ts +1 -1
  72. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +27 -27
  73. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +1 -1
  74. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +1 -1
  75. package/dist/sdk/firmachain/gov/GovQueryClient.js +2 -2
  76. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +5 -4
  77. package/dist/sdk/firmachain/gov/GovTxClient.js +6 -3
  78. package/dist/sdk/firmachain/gov/index.js +5 -1
  79. package/dist/sdk/firmachain/ibc/IbcQueryClient.d.ts +34 -0
  80. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +71 -0
  81. package/dist/sdk/firmachain/ibc/IbcTxClient.d.ts +13 -0
  82. package/dist/sdk/firmachain/ibc/IbcTxClient.js +39 -0
  83. package/dist/sdk/firmachain/ibc/index.d.ts +3 -0
  84. package/dist/sdk/firmachain/ibc/index.js +19 -0
  85. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +5 -4
  86. package/dist/sdk/firmachain/nft/NftTxClient.js +6 -3
  87. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +6 -6
  88. package/dist/sdk/firmachain/nft/index.js +5 -1
  89. package/dist/sdk/firmachain/slashing/index.js +5 -1
  90. package/dist/sdk/firmachain/staking/StakingQueryClient.d.ts +17 -4
  91. package/dist/sdk/firmachain/staking/StakingQueryClient.js +44 -24
  92. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +7 -6
  93. package/dist/sdk/firmachain/staking/StakingTxClient.js +8 -5
  94. package/dist/sdk/firmachain/staking/index.js +5 -1
  95. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +6 -5
  96. package/dist/sdk/firmachain/token/TokenTxClient.js +7 -4
  97. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +8 -8
  98. package/dist/sdk/firmachain/token/index.js +5 -1
  99. package/package.json +2 -3
  100. package/dist/sdk/firmachain/amino/secp256k1hdwallet.d.ts +0 -94
  101. package/dist/sdk/firmachain/amino/secp256k1hdwallet.js +0 -437
  102. package/dist/sdk/firmachain/amino/secp256k1wallet.d.ts +0 -23
  103. package/dist/sdk/firmachain/amino/secp256k1wallet.js +0 -141
@@ -125,12 +125,12 @@ var FirmaStakingService = /** @class */ (function () {
125
125
  case 1:
126
126
  address = _a.sent();
127
127
  sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
128
- message = txClient.msgDelegate({
128
+ message = staking_1.StakingTxClient.msgDelegate({
129
129
  delegatorAddress: address,
130
130
  validatorAddress: validatorAddres,
131
131
  amount: sendAmount
132
132
  });
133
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
133
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
134
134
  case 2: return [2 /*return*/, _a.sent()];
135
135
  case 3:
136
136
  error_4 = _a.sent();
@@ -154,12 +154,12 @@ var FirmaStakingService = /** @class */ (function () {
154
154
  case 1:
155
155
  address = _a.sent();
156
156
  sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
157
- message = txClient.msgUndelegate({
157
+ message = staking_1.StakingTxClient.msgUndelegate({
158
158
  delegatorAddress: address,
159
159
  validatorAddress: validatorAddres,
160
160
  amount: sendAmount
161
161
  });
162
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
162
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
163
163
  case 2: return [2 /*return*/, _a.sent()];
164
164
  case 3:
165
165
  error_5 = _a.sent();
@@ -183,13 +183,13 @@ var FirmaStakingService = /** @class */ (function () {
183
183
  case 1:
184
184
  address = _a.sent();
185
185
  sendAmount = { denom: this.config.denom, amount: FirmaUtil_1.FirmaUtil.getUFCTStringFromFCT(amount) };
186
- message = txClient.msgRedelegate({
186
+ message = staking_1.StakingTxClient.msgRedelegate({
187
187
  delegatorAddress: address,
188
188
  validatorSrcAddress: validatorSrcAddress,
189
189
  validatorDstAddress: validatorDstAddress,
190
190
  amount: sendAmount
191
191
  });
192
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
192
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
193
193
  case 2: return [2 /*return*/, _a.sent()];
194
194
  case 3:
195
195
  error_6 = _a.sent();
@@ -209,7 +209,7 @@ var FirmaStakingService = /** @class */ (function () {
209
209
  case 0:
210
210
  _a.trys.push([0, 2, , 3]);
211
211
  txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
212
- message = txClient.msgCreateValidator({
212
+ message = staking_1.StakingTxClient.msgCreateValidator({
213
213
  description: validatorInfo.description,
214
214
  commission: validatorInfo.commission,
215
215
  minSelfDelegation: validatorInfo.minSelfDelegation,
@@ -218,7 +218,7 @@ var FirmaStakingService = /** @class */ (function () {
218
218
  pubkey: validatorInfo.pubkey,
219
219
  value: validatorInfo.value
220
220
  });
221
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
221
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
222
222
  case 1: return [2 /*return*/, _a.sent()];
223
223
  case 2:
224
224
  error_7 = _a.sent();
@@ -238,13 +238,13 @@ var FirmaStakingService = /** @class */ (function () {
238
238
  case 0:
239
239
  _a.trys.push([0, 2, , 3]);
240
240
  txClient = new staking_1.StakingTxClient(wallet, this.config.rpcAddress);
241
- message = txClient.msgEditValidator({
241
+ message = staking_1.StakingTxClient.msgEditValidator({
242
242
  validatorAddress: validatorAddress,
243
243
  description: description,
244
244
  commissionRate: commissionRate,
245
245
  minSelfDelegation: minSelfDelegation
246
246
  });
247
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
247
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
248
248
  case 1: return [2 /*return*/, _a.sent()];
249
249
  case 2:
250
250
  error_8 = _a.sent();
@@ -455,7 +455,8 @@ var FirmaStakingService = /** @class */ (function () {
455
455
  });
456
456
  });
457
457
  };
458
- FirmaStakingService.prototype.getUndelegationListFromValidator = function (valoperAddress) {
458
+ FirmaStakingService.prototype.getUndelegationListFromValidator = function (valoperAddress, paginationKey) {
459
+ if (paginationKey === void 0) { paginationKey = ""; }
459
460
  return __awaiter(this, void 0, void 0, function () {
460
461
  var queryClient, result, error_18;
461
462
  return __generator(this, function (_a) {
@@ -463,7 +464,7 @@ var FirmaStakingService = /** @class */ (function () {
463
464
  case 0:
464
465
  _a.trys.push([0, 2, , 3]);
465
466
  queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
466
- return [4 /*yield*/, queryClient.queryGetUndelegationListFromValidator(valoperAddress)];
467
+ return [4 /*yield*/, queryClient.queryGetUndelegationListFromValidator(valoperAddress, paginationKey)];
467
468
  case 1:
468
469
  result = _a.sent();
469
470
  return [2 /*return*/, result];
@@ -476,7 +477,8 @@ var FirmaStakingService = /** @class */ (function () {
476
477
  });
477
478
  });
478
479
  };
479
- FirmaStakingService.prototype.getDelegationListFromValidator = function (valoperAddress) {
480
+ FirmaStakingService.prototype.getDelegationListFromValidator = function (valoperAddress, paginationKey) {
481
+ if (paginationKey === void 0) { paginationKey = ""; }
480
482
  return __awaiter(this, void 0, void 0, function () {
481
483
  var queryClient, result, error_19;
482
484
  return __generator(this, function (_a) {
@@ -484,7 +486,7 @@ var FirmaStakingService = /** @class */ (function () {
484
486
  case 0:
485
487
  _a.trys.push([0, 2, , 3]);
486
488
  queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
487
- return [4 /*yield*/, queryClient.queryGetDelegateListFromValidator(valoperAddress)];
489
+ return [4 /*yield*/, queryClient.queryGetDelegateListFromValidator(valoperAddress, paginationKey)];
488
490
  case 1:
489
491
  result = _a.sent();
490
492
  return [2 /*return*/, result];
@@ -497,7 +499,8 @@ var FirmaStakingService = /** @class */ (function () {
497
499
  });
498
500
  });
499
501
  };
500
- FirmaStakingService.prototype.getTotalDelegationInfo = function (address) {
502
+ FirmaStakingService.prototype.getTotalDelegationInfo = function (address, paginationKey) {
503
+ if (paginationKey === void 0) { paginationKey = ""; }
501
504
  return __awaiter(this, void 0, void 0, function () {
502
505
  var queryClient, result, error_20;
503
506
  return __generator(this, function (_a) {
@@ -505,7 +508,7 @@ var FirmaStakingService = /** @class */ (function () {
505
508
  case 0:
506
509
  _a.trys.push([0, 2, , 3]);
507
510
  queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
508
- return [4 /*yield*/, queryClient.queryGetTotalDelegationInfo(address)];
511
+ return [4 /*yield*/, queryClient.queryGetTotalDelegationInfo(address, paginationKey)];
509
512
  case 1:
510
513
  result = _a.sent();
511
514
  return [2 /*return*/, result];
@@ -581,7 +584,8 @@ var FirmaStakingService = /** @class */ (function () {
581
584
  });
582
585
  });
583
586
  };
584
- FirmaStakingService.prototype.getValidatorList = function () {
587
+ FirmaStakingService.prototype.getValidatorList = function (paginationKey) {
588
+ if (paginationKey === void 0) { paginationKey = ""; }
585
589
  return __awaiter(this, void 0, void 0, function () {
586
590
  var queryClient, result, error_24;
587
591
  return __generator(this, function (_a) {
@@ -589,7 +593,7 @@ var FirmaStakingService = /** @class */ (function () {
589
593
  case 0:
590
594
  _a.trys.push([0, 2, , 3]);
591
595
  queryClient = new staking_1.StakingQueryClient(this.config.restApiAddress);
592
- return [4 /*yield*/, queryClient.queryValidators()];
596
+ return [4 /*yield*/, queryClient.queryValidators(paginationKey)];
593
597
  case 1:
594
598
  result = _a.sent();
595
599
  return [2 /*return*/, result];
@@ -137,7 +137,7 @@ var TokenService = /** @class */ (function () {
137
137
  TokenService.prototype.getSignedTxUpdateTokenURI = function (wallet, tokenID, tokenURI, txMisc) {
138
138
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
139
139
  return __awaiter(this, void 0, void 0, function () {
140
- var address, txClient, message, error_5;
140
+ var address, message, txClient, error_5;
141
141
  return __generator(this, function (_a) {
142
142
  switch (_a.label) {
143
143
  case 0:
@@ -145,13 +145,13 @@ 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, this.config.rpcAddress);
149
- message = txClient.msgUpdateTokenURI({
148
+ message = token_1.TokenTxClient.msgUpdateTokenURI({
150
149
  owner: address,
151
150
  tokenID: tokenID,
152
151
  tokenURI: tokenURI
153
152
  });
154
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
153
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
154
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
155
155
  case 2: return [2 /*return*/, _a.sent()];
156
156
  case 3:
157
157
  error_5 = _a.sent();
@@ -165,7 +165,7 @@ var TokenService = /** @class */ (function () {
165
165
  TokenService.prototype.getSignedTxBurn = function (wallet, tokenID, amount, txMisc) {
166
166
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
167
167
  return __awaiter(this, void 0, void 0, function () {
168
- var address, txClient, message, error_6;
168
+ var address, message, txClient, error_6;
169
169
  return __generator(this, function (_a) {
170
170
  switch (_a.label) {
171
171
  case 0:
@@ -173,13 +173,13 @@ 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, this.config.rpcAddress);
177
- message = txClient.msgBurn({
176
+ message = token_1.TokenTxClient.msgBurn({
178
177
  owner: address,
179
178
  tokenID: tokenID,
180
179
  amount: amount
181
180
  });
182
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
181
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
182
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
183
183
  case 2: return [2 /*return*/, _a.sent()];
184
184
  case 3:
185
185
  error_6 = _a.sent();
@@ -193,7 +193,7 @@ var TokenService = /** @class */ (function () {
193
193
  TokenService.prototype.getSignedTxMint = function (wallet, tokenID, amount, toAddress, txMisc) {
194
194
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
195
195
  return __awaiter(this, void 0, void 0, function () {
196
- var address, txClient, message, error_7;
196
+ var address, message, txClient, error_7;
197
197
  return __generator(this, function (_a) {
198
198
  switch (_a.label) {
199
199
  case 0:
@@ -201,14 +201,14 @@ 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, this.config.rpcAddress);
205
- message = txClient.msgMint({
204
+ message = token_1.TokenTxClient.msgMint({
206
205
  owner: address,
207
206
  tokenID: tokenID,
208
207
  amount: amount,
209
208
  toAddress: toAddress
210
209
  });
211
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
210
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
211
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
212
212
  case 2: return [2 /*return*/, _a.sent()];
213
213
  case 3:
214
214
  error_7 = _a.sent();
@@ -222,7 +222,7 @@ var TokenService = /** @class */ (function () {
222
222
  TokenService.prototype.getSignedTxCreateToken = function (wallet, tokenName, tokenSymbol, tokenURI, totalSupply, decimal, isMintable, isBurnable, txMisc) {
223
223
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
224
224
  return __awaiter(this, void 0, void 0, function () {
225
- var address, txClient, message, error_8;
225
+ var address, message, txClient, error_8;
226
226
  return __generator(this, function (_a) {
227
227
  switch (_a.label) {
228
228
  case 0:
@@ -230,8 +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, this.config.rpcAddress);
234
- message = txClient.msgCreateToken({
233
+ message = token_1.TokenTxClient.msgCreateToken({
235
234
  owner: address,
236
235
  name: tokenName,
237
236
  symbol: tokenSymbol,
@@ -241,7 +240,8 @@ var TokenService = /** @class */ (function () {
241
240
  mintable: isMintable,
242
241
  burnable: isBurnable
243
242
  });
244
- return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
243
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
244
+ return [4 /*yield*/, txClient.sign([message], (0, FirmaUtil_1.getSignAndBroadcastOption)(this.config.denom, txMisc))];
245
245
  case 2: return [2 /*return*/, _a.sent()];
246
246
  case 3:
247
247
  error_8 = _a.sent();
@@ -1,7 +1,12 @@
1
- import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
1
+ import { SignDoc, TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
2
2
  import { FirmaConfig } from "./FirmaConfig";
3
3
  import { SignerData } from "./firmachain/common/LedgerSigningStargateClient";
4
4
  import { SignAndBroadcastOptions, TxMisc } from "./firmachain/common";
5
+ import { ArbitraryVerifyData } from "./firmachain/common/signingaminostargateclient";
6
+ import { EncodeObject, Registry } from "@cosmjs/proto-signing";
7
+ import { FirmaWalletService } from "./FirmaWalletService";
8
+ import { Any } from "./firmachain/google/protobuf/any";
9
+ import { CommonTxClient } from "./firmachain/common/CommonTxClient";
5
10
  export declare class FirmaUtil {
6
11
  static config: FirmaConfig;
7
12
  static readonly FctDecimal: number;
@@ -11,6 +16,8 @@ export declare class FirmaUtil {
11
16
  static getTokenStringFromUTokenStr(uTokenAmount: string, decimal: number): string;
12
17
  static getUTokenStringFromToken(tokenAmount: number, decimal: number): string;
13
18
  static getUTokenFromToken(tokenAmount: number, decimal: number): number;
19
+ static arrayBufferToBase64(buffer: Uint8Array): string;
20
+ static base64ToArrayBuffer(base64: string): Uint8Array;
14
21
  static getTokenStringFromUToken(uTokenAmount: number, decimal: number): string;
15
22
  static getUFCTStringFromFCTStr(fctAmount: string): string;
16
23
  static getUFCTFromFCT(fctAmount: number): number;
@@ -28,6 +35,17 @@ export declare class FirmaUtil {
28
35
  static estimateGas(txRaw: TxRaw): Promise<number>;
29
36
  static estimateGasRaw(txRaw: Uint8Array): Promise<number>;
30
37
  static printLog(log: any): void;
38
+ static experimentalAdr36Sign(wallet: FirmaWalletService, data: string): Promise<ArbitraryVerifyData>;
39
+ static experimentalAdr36Verify(data: ArbitraryVerifyData, checkMsg: string): Promise<boolean>;
40
+ private static recoverSigningAddress;
41
+ private static verifySignature;
42
+ static verifyDirectSignature(address: string, signature: string, signDoc: SignDoc): Promise<boolean>;
43
+ static parseSignDocValues(signDocString: any): any;
44
+ static stringifySignDocValues(signDoc: any): any;
45
+ static makeSignDoc(signerAddress: string, messages: readonly EncodeObject[], txMisc?: TxMisc): Promise<SignDoc>;
46
+ static makeSignDocWithStringify(signerAddress: string, messages: readonly EncodeObject[], txMisc?: TxMisc): Promise<SignDoc>;
47
+ static getAnyData(registry: Registry, message: EncodeObject): Any;
48
+ static getCommonTxClient(aliceWallet: FirmaWalletService): CommonTxClient;
31
49
  }
32
50
  export declare const DefaultTxMisc: {
33
51
  memo: string;
@@ -1,4 +1,15 @@
1
1
  "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
2
13
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
14
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
15
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -35,6 +46,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
46
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
47
  }
37
48
  };
49
+ var __importDefault = (this && this.__importDefault) || function (mod) {
50
+ return (mod && mod.__esModule) ? mod : { "default": mod };
51
+ };
38
52
  Object.defineProperty(exports, "__esModule", { value: true });
39
53
  exports.getSignAndBroadcastOption = exports.DefaultTxMisc = exports.FirmaUtil = void 0;
40
54
  var fs_1 = require("fs");
@@ -42,6 +56,15 @@ var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
42
56
  var TendermintQueryClient_1 = require("./firmachain/common/TendermintQueryClient");
43
57
  var encoding_1 = require("@cosmjs/encoding");
44
58
  var LedgerSigningStargateClient_1 = require("./firmachain/common/LedgerSigningStargateClient");
59
+ var encoding_2 = require("@cosmjs/encoding");
60
+ var crypto_1 = require("@cosmjs/crypto");
61
+ var amino_1 = require("@cosmjs/amino");
62
+ var signingaminostargateclient_1 = require("./firmachain/common/signingaminostargateclient");
63
+ var proto_signing_1 = require("@cosmjs/proto-signing");
64
+ var signingstargateclient_1 = require("./firmachain/common/signingstargateclient");
65
+ var any_1 = require("./firmachain/google/protobuf/any");
66
+ var long_1 = __importDefault(require("long"));
67
+ var CommonTxClient_1 = require("./firmachain/common/CommonTxClient");
45
68
  var CryptoJS = require("crypto-js");
46
69
  var sha1 = require("crypto-js/sha1");
47
70
  var sha256 = require("crypto-js/sha256");
@@ -86,6 +109,27 @@ var FirmaUtil = /** @class */ (function () {
86
109
  var newBig = big.toFixed(0);
87
110
  return Number.parseInt(newBig);
88
111
  };
112
+ FirmaUtil.arrayBufferToBase64 = function (buffer) {
113
+ return Buffer.from(buffer).toString("base64");
114
+ /*var binary = '';
115
+ var bytes = new Uint8Array(buffer);
116
+ var len = bytes.byteLength;
117
+ for (var i = 0; i < len; i++) {
118
+ binary += String.fromCharCode(bytes[i]);
119
+ }
120
+ return btoa(binary);*/
121
+ };
122
+ FirmaUtil.base64ToArrayBuffer = function (base64) {
123
+ var buffer = Buffer.from(base64, "base64");
124
+ return new Uint8Array(buffer);
125
+ /* var binary_string = atob(base64);
126
+ var len = binary_string.length;
127
+ var bytes = new Uint8Array(len);
128
+ for (var i = 0; i < len; i++) {
129
+ bytes[i] = binary_string.charCodeAt(i);
130
+ }
131
+ return bytes;*/
132
+ };
89
133
  FirmaUtil.getTokenStringFromUToken = function (uTokenAmount, decimal) {
90
134
  var fixedUTokenAmount = Math.floor(uTokenAmount);
91
135
  var decimalMutiplyer = Math.pow(10, decimal);
@@ -181,7 +225,7 @@ var FirmaUtil = /** @class */ (function () {
181
225
  case 0:
182
226
  _a.trys.push([0, 2, , 3]);
183
227
  encodedTx = Uint8Array.from(tx_1.TxRaw.encode(txRaw).finish());
184
- hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
228
+ hexTx = "0x".concat(Buffer.from(encodedTx).toString("hex"));
185
229
  queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
186
230
  return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
187
231
  case 1:
@@ -205,7 +249,7 @@ var FirmaUtil = /** @class */ (function () {
205
249
  case 0:
206
250
  _a.trys.push([0, 2, , 3]);
207
251
  encodedTx = Uint8Array.from(txRaw);
208
- hexTx = "0x" + Buffer.from(encodedTx).toString("hex");
252
+ hexTx = "0x".concat(Buffer.from(encodedTx).toString("hex"));
209
253
  console.log("hexTx:" + hexTx);
210
254
  queryClient = new TendermintQueryClient_1.TendermintQueryClient(FirmaUtil.config.rpcAddress);
211
255
  return [4 /*yield*/, queryClient.queryEstimateGas(hexTx)];
@@ -225,7 +269,158 @@ var FirmaUtil = /** @class */ (function () {
225
269
  FirmaUtil.printLog = function (log) {
226
270
  if (FirmaUtil.config.isShowLog === false)
227
271
  return;
228
- console.log("[FirmaSDK] " + log);
272
+ console.log("[FirmaSDK] ".concat(log));
273
+ };
274
+ FirmaUtil.experimentalAdr36Sign = function (wallet, data) {
275
+ return __awaiter(this, void 0, void 0, function () {
276
+ var registry, aliceClient, address, userData, error_4;
277
+ return __generator(this, function (_a) {
278
+ switch (_a.label) {
279
+ case 0:
280
+ _a.trys.push([0, 4, , 5]);
281
+ registry = new proto_signing_1.Registry();
282
+ return [4 /*yield*/, signingaminostargateclient_1.SigningAminoStargateClient.connectWithSigner(FirmaUtil.config.rpcAddress, wallet.getRawAminoWallet(), registry)];
283
+ case 1:
284
+ aliceClient = _a.sent();
285
+ return [4 /*yield*/, wallet.getAddress()];
286
+ case 2:
287
+ address = _a.sent();
288
+ userData = Buffer.from(data);
289
+ return [4 /*yield*/, aliceClient.experimentalAdr36Sign(address, userData)];
290
+ case 3: return [2 /*return*/, _a.sent()];
291
+ case 4:
292
+ error_4 = _a.sent();
293
+ FirmaUtil.printLog(error_4);
294
+ throw error_4;
295
+ case 5: return [2 /*return*/];
296
+ }
297
+ });
298
+ });
299
+ };
300
+ FirmaUtil.experimentalAdr36Verify = function (data, checkMsg) {
301
+ return __awaiter(this, void 0, void 0, function () {
302
+ var error_5;
303
+ return __generator(this, function (_a) {
304
+ switch (_a.label) {
305
+ case 0:
306
+ _a.trys.push([0, 2, , 3]);
307
+ return [4 /*yield*/, signingaminostargateclient_1.SigningAminoStargateClient.experimentalAdr36Verify(data, checkMsg)];
308
+ case 1: return [2 /*return*/, _a.sent()];
309
+ case 2:
310
+ error_5 = _a.sent();
311
+ FirmaUtil.printLog(error_5);
312
+ throw error_5;
313
+ case 3: return [2 /*return*/];
314
+ }
315
+ });
316
+ });
317
+ };
318
+ FirmaUtil.recoverSigningAddress = function (signature, hash, recoveryIndex) {
319
+ return __awaiter(this, void 0, void 0, function () {
320
+ var sig, extendedSig, recoveredPubKey, _a;
321
+ return __generator(this, function (_b) {
322
+ switch (_b.label) {
323
+ case 0:
324
+ if (recoveryIndex > 3) {
325
+ throw new Error('Invalid recovery index');
326
+ }
327
+ sig = crypto_1.Secp256k1Signature.fromFixedLength((0, encoding_2.fromBase64)(signature));
328
+ extendedSig = new crypto_1.ExtendedSecp256k1Signature(sig.r(), sig.s(), recoveryIndex);
329
+ _b.label = 1;
330
+ case 1:
331
+ _b.trys.push([1, 3, , 4]);
332
+ return [4 /*yield*/, crypto_1.Secp256k1.recoverPubkey(extendedSig, hash)];
333
+ case 2:
334
+ recoveredPubKey = _b.sent();
335
+ return [2 /*return*/, (0, amino_1.pubkeyToAddress)({
336
+ type: 'tendermint/PubKeySecp256k1',
337
+ value: (0, encoding_2.toBase64)(crypto_1.Secp256k1.compressPubkey(recoveredPubKey)),
338
+ }, 'firma')];
339
+ case 3:
340
+ _a = _b.sent();
341
+ return [2 /*return*/, null];
342
+ case 4: return [2 /*return*/];
343
+ }
344
+ });
345
+ });
346
+ };
347
+ FirmaUtil.verifySignature = function (address, signature, hash) {
348
+ return __awaiter(this, void 0, void 0, function () {
349
+ var i, recoveredAddress;
350
+ return __generator(this, function (_a) {
351
+ switch (_a.label) {
352
+ case 0:
353
+ i = 0;
354
+ _a.label = 1;
355
+ case 1:
356
+ if (!(i < 4)) return [3 /*break*/, 4];
357
+ return [4 /*yield*/, this.recoverSigningAddress(signature, hash, i)];
358
+ case 2:
359
+ recoveredAddress = _a.sent();
360
+ if (recoveredAddress === address) {
361
+ return [2 /*return*/, true];
362
+ }
363
+ _a.label = 3;
364
+ case 3:
365
+ i++;
366
+ return [3 /*break*/, 1];
367
+ case 4: return [2 /*return*/, false];
368
+ }
369
+ });
370
+ });
371
+ };
372
+ FirmaUtil.verifyDirectSignature = function (address, signature, signDoc) {
373
+ var messageHash = (0, crypto_1.sha256)((0, proto_signing_1.makeSignBytes)(signDoc));
374
+ return this.verifySignature(address, signature, messageHash);
375
+ };
376
+ ;
377
+ FirmaUtil.parseSignDocValues = function (signDocString) {
378
+ return __assign(__assign({}, signDocString), { bodyBytes: (0, encoding_2.fromHex)(signDocString.bodyBytes), authInfoBytes: (0, encoding_2.fromHex)(signDocString.authInfoBytes), accountNumber: new long_1.default(signDocString.accountNumber) });
379
+ };
380
+ FirmaUtil.stringifySignDocValues = function (signDoc) {
381
+ return __assign(__assign({}, signDoc), { bodyBytes: (0, encoding_2.toHex)(signDoc.bodyBytes), authInfoBytes: (0, encoding_2.toHex)(signDoc.authInfoBytes), accountNumber: signDoc.accountNumber.toString(16) });
382
+ };
383
+ FirmaUtil.makeSignDoc = function (signerAddress, messages, txMisc) {
384
+ if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
385
+ return __awaiter(this, void 0, void 0, function () {
386
+ var result, chainID, serverUrl, registry;
387
+ return __generator(this, function (_a) {
388
+ switch (_a.label) {
389
+ case 0:
390
+ result = FirmaUtil.getSignAndBroadcastOption(FirmaUtil.config.denom, txMisc);
391
+ chainID = FirmaUtil.config.chainID;
392
+ serverUrl = FirmaUtil.config.rpcAddress;
393
+ registry = CommonTxClient_1.CommonTxClient.getRegistry();
394
+ return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.makeSignDocForSend(signerAddress, messages, result.fee, result.memo, serverUrl, chainID, registry)];
395
+ case 1: return [2 /*return*/, _a.sent()];
396
+ }
397
+ });
398
+ });
399
+ };
400
+ FirmaUtil.makeSignDocWithStringify = function (signerAddress, messages, txMisc) {
401
+ if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
402
+ return __awaiter(this, void 0, void 0, function () {
403
+ var signDoc, stringSignDoc;
404
+ return __generator(this, function (_a) {
405
+ switch (_a.label) {
406
+ case 0: return [4 /*yield*/, this.makeSignDoc(signerAddress, messages, txMisc)];
407
+ case 1:
408
+ signDoc = _a.sent();
409
+ stringSignDoc = this.stringifySignDocValues(signDoc);
410
+ return [2 /*return*/, stringSignDoc];
411
+ }
412
+ });
413
+ });
414
+ };
415
+ FirmaUtil.getAnyData = function (registry, message) {
416
+ var anyData = any_1.Any.fromPartial({
417
+ typeUrl: message.typeUrl,
418
+ value: registry.encode(message)
419
+ });
420
+ return anyData;
421
+ };
422
+ FirmaUtil.getCommonTxClient = function (aliceWallet) {
423
+ return new CommonTxClient_1.CommonTxClient(aliceWallet, FirmaUtil.config.rpcAddress);
229
424
  };
230
425
  FirmaUtil.FctDecimal = 6;
231
426
  return FirmaUtil;
@@ -4,16 +4,19 @@ import { FirmaConfig } from "./FirmaConfig";
4
4
  import { SignAndBroadcastOptions } from "./firmachain/common";
5
5
  import { LedgerWalletInterface } from "./firmachain/common/LedgerWallet";
6
6
  import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
7
+ import { Secp256k1Wallet } from "@cosmjs/amino";
7
8
  export declare class FirmaWalletService {
8
9
  private readonly config;
9
10
  private mnemonic;
10
11
  private privateKey;
11
12
  private accountIndex;
13
+ private aminoWallet;
12
14
  private wallet;
13
15
  private ledger;
14
16
  getHdPath(): string;
15
17
  getPrefix(): string;
16
18
  getRawWallet(): DirectSecp256k1Wallet;
19
+ getRawAminoWallet(): Secp256k1Wallet;
17
20
  getPrivateKey(): string;
18
21
  getMnemonic(): string;
19
22
  isLedger(): boolean;
@@ -41,6 +41,7 @@ var proto_signing_1 = require("@cosmjs/proto-signing");
41
41
  var crypto_1 = require("@cosmjs/crypto");
42
42
  var FirmaUtil_1 = require("./FirmaUtil");
43
43
  var LedgerWallet_1 = require("./firmachain/common/LedgerWallet");
44
+ var amino_1 = require("@cosmjs/amino");
44
45
  var CryptoJS = require("crypto-js");
45
46
  var FirmaWalletService = /** @class */ (function () {
46
47
  function FirmaWalletService(config) {
@@ -58,6 +59,9 @@ var FirmaWalletService = /** @class */ (function () {
58
59
  FirmaWalletService.prototype.getRawWallet = function () {
59
60
  return this.wallet;
60
61
  };
62
+ FirmaWalletService.prototype.getRawAminoWallet = function () {
63
+ return this.aminoWallet;
64
+ };
61
65
  FirmaWalletService.prototype.getPrivateKey = function () {
62
66
  return this.privateKey;
63
67
  };
@@ -88,7 +92,7 @@ var FirmaWalletService = /** @class */ (function () {
88
92
  return __awaiter(this, void 0, void 0, function () {
89
93
  return __generator(this, function (_a) {
90
94
  switch (_a.label) {
91
- case 0: return [4 /*yield*/, LedgerWallet_1.signFromLedger(this.ledger, messages, option, registry)];
95
+ case 0: return [4 /*yield*/, (0, LedgerWallet_1.signFromLedger)(this.ledger, messages, option, registry)];
92
96
  case 1: return [2 /*return*/, _a.sent()];
93
97
  }
94
98
  });
@@ -119,7 +123,7 @@ var FirmaWalletService = /** @class */ (function () {
119
123
  };
120
124
  FirmaWalletService.getHdPath = function (hdPath, accountIndex) {
121
125
  try {
122
- return [crypto_1.stringToPath(hdPath + accountIndex + "'/0/0")];
126
+ return [(0, crypto_1.stringToPath)(hdPath + accountIndex + "'/0/0")];
123
127
  }
124
128
  catch (error) {
125
129
  FirmaUtil_1.FirmaUtil.printLog(error);
@@ -163,9 +167,9 @@ var FirmaWalletService = /** @class */ (function () {
163
167
  return [4 /*yield*/, crypto_1.Bip39.mnemonicToSeed(mnemonicChecked)];
164
168
  case 1:
165
169
  seed = _a.sent();
166
- hdpath = FirmaWalletService.getHdPath(this.getHdPath(), this.accountIndex);
170
+ hdpath = FirmaWalletService.getHdPath(this.getHdPath(), accountIndex);
167
171
  privkey = crypto_1.Slip10.derivePath(crypto_1.Slip10Curve.Secp256k1, seed, hdpath[0]).privkey;
168
- privateKey = "0x" + Buffer.from(privkey).toString("hex");
172
+ privateKey = "0x".concat(Buffer.from(privkey).toString("hex"));
169
173
  return [2 /*return*/, privateKey];
170
174
  case 2:
171
175
  error_3 = _a.sent();
@@ -178,23 +182,27 @@ var FirmaWalletService = /** @class */ (function () {
178
182
  };
179
183
  FirmaWalletService.prototype.initFromPrivateKey = function (privateKey) {
180
184
  return __awaiter(this, void 0, void 0, function () {
181
- var tempPrivateKey, _a, error_4;
182
- return __generator(this, function (_b) {
183
- switch (_b.label) {
185
+ var tempPrivateKey, _a, _b, error_4;
186
+ return __generator(this, function (_c) {
187
+ switch (_c.label) {
184
188
  case 0:
185
- _b.trys.push([0, 2, , 3]);
189
+ _c.trys.push([0, 3, , 4]);
186
190
  tempPrivateKey = Buffer.from(privateKey.replace("0x", ""), "hex");
187
191
  _a = this;
188
192
  return [4 /*yield*/, proto_signing_1.DirectSecp256k1Wallet.fromKey(tempPrivateKey, this.getPrefix())];
189
193
  case 1:
190
- _a.wallet = _b.sent();
191
- this.privateKey = privateKey;
192
- return [3 /*break*/, 3];
194
+ _a.wallet = _c.sent();
195
+ _b = this;
196
+ return [4 /*yield*/, amino_1.Secp256k1Wallet.fromKey(tempPrivateKey, this.getPrefix())];
193
197
  case 2:
194
- error_4 = _b.sent();
198
+ _b.aminoWallet = _c.sent();
199
+ this.privateKey = privateKey;
200
+ return [3 /*break*/, 4];
201
+ case 3:
202
+ error_4 = _c.sent();
195
203
  FirmaUtil_1.FirmaUtil.printLog(error_4);
196
204
  throw error_4;
197
- case 3: return [2 /*return*/];
205
+ case 4: return [2 /*return*/];
198
206
  }
199
207
  });
200
208
  });