@firmachain/firma-js 0.2.32 → 0.2.33

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 (40) hide show
  1. package/dist/sdk/FirmaAuthzService.js +15 -15
  2. package/dist/sdk/FirmaBankService.js +1 -1
  3. package/dist/sdk/FirmaContractService.js +10 -12
  4. package/dist/sdk/FirmaCosmWasmService.js +18 -18
  5. package/dist/sdk/FirmaDistributionService.js +5 -5
  6. package/dist/sdk/FirmaFeeGrantService.js +3 -3
  7. package/dist/sdk/FirmaGovService.js +19 -19
  8. package/dist/sdk/FirmaIbcService.js +3 -3
  9. package/dist/sdk/FirmaNftService.js +6 -6
  10. package/dist/sdk/FirmaStakingService.js +5 -5
  11. package/dist/sdk/FirmaTokenService.js +12 -12
  12. package/dist/sdk/FirmaUtil.d.ts +11 -1
  13. package/dist/sdk/FirmaUtil.js +137 -11
  14. package/dist/sdk/firmachain/authz/AuthzTxClient.d.ts +5 -4
  15. package/dist/sdk/firmachain/authz/AuthzTxClient.js +6 -3
  16. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +4 -3
  17. package/dist/sdk/firmachain/bank/BankTxClient.js +5 -2
  18. package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -3
  19. package/dist/sdk/firmachain/common/ITxClient.js +14 -8
  20. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +15 -8
  21. package/dist/sdk/firmachain/common/signingstargateclient.js +68 -9
  22. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +4 -3
  23. package/dist/sdk/firmachain/contract/ContractTxClient.js +5 -2
  24. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.d.ts +8 -7
  25. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.js +9 -6
  26. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +6 -5
  27. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +7 -4
  28. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +4 -3
  29. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +5 -2
  30. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +5 -4
  31. package/dist/sdk/firmachain/gov/GovTxClient.js +6 -3
  32. package/dist/sdk/firmachain/ibc/IbcTxClient.d.ts +3 -2
  33. package/dist/sdk/firmachain/ibc/IbcTxClient.js +4 -1
  34. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +5 -4
  35. package/dist/sdk/firmachain/nft/NftTxClient.js +6 -3
  36. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +7 -6
  37. package/dist/sdk/firmachain/staking/StakingTxClient.js +8 -5
  38. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +6 -5
  39. package/dist/sdk/firmachain/token/TokenTxClient.js +7 -4
  40. package/package.json +3 -3
@@ -185,7 +185,7 @@ var NftService = /** @class */ (function () {
185
185
  NftService.prototype.getSignedTxTransfer = function (wallet, toAddress, nftID, txMisc) {
186
186
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
187
187
  return __awaiter(this, void 0, void 0, function () {
188
- var address, nftTxClient, message, error_7;
188
+ var address, message, nftTxClient, error_7;
189
189
  return __generator(this, function (_a) {
190
190
  switch (_a.label) {
191
191
  case 0:
@@ -193,8 +193,8 @@ var NftService = /** @class */ (function () {
193
193
  return [4 /*yield*/, wallet.getAddress()];
194
194
  case 1:
195
195
  address = _a.sent();
196
+ message = nft_1.NftTxClient.msgTransfer({ owner: address, toAddress: toAddress, nftId: parseInt(nftID) });
196
197
  nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
197
- message = nftTxClient.msgTransfer({ owner: address, toAddress: toAddress, nftId: parseInt(nftID) });
198
198
  return [4 /*yield*/, nftTxClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
199
199
  case 2: return [2 /*return*/, _a.sent()];
200
200
  case 3:
@@ -254,7 +254,7 @@ var NftService = /** @class */ (function () {
254
254
  NftService.prototype.getSignedTxBurn = function (wallet, nftID, txMisc) {
255
255
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
256
256
  return __awaiter(this, void 0, void 0, function () {
257
- var address, nftTxClient, message, error_10;
257
+ var address, message, nftTxClient, error_10;
258
258
  return __generator(this, function (_a) {
259
259
  switch (_a.label) {
260
260
  case 0:
@@ -262,8 +262,8 @@ var NftService = /** @class */ (function () {
262
262
  return [4 /*yield*/, wallet.getAddress()];
263
263
  case 1:
264
264
  address = _a.sent();
265
+ message = nft_1.NftTxClient.msgBurn({ owner: address, nftId: parseInt(nftID) });
265
266
  nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
266
- message = nftTxClient.msgBurn({ owner: address, nftId: parseInt(nftID) });
267
267
  return [4 /*yield*/, nftTxClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
268
268
  case 2: return [2 /*return*/, _a.sent()];
269
269
  case 3:
@@ -323,7 +323,7 @@ var NftService = /** @class */ (function () {
323
323
  NftService.prototype.getSignedTxMint = function (wallet, tokenURI, txMisc) {
324
324
  if (txMisc === void 0) { txMisc = FirmaUtil_1.DefaultTxMisc; }
325
325
  return __awaiter(this, void 0, void 0, function () {
326
- var address, nftTxClient, message, error_13;
326
+ var address, message, nftTxClient, error_13;
327
327
  return __generator(this, function (_a) {
328
328
  switch (_a.label) {
329
329
  case 0:
@@ -331,8 +331,8 @@ var NftService = /** @class */ (function () {
331
331
  return [4 /*yield*/, wallet.getAddress()];
332
332
  case 1:
333
333
  address = _a.sent();
334
+ message = nft_1.NftTxClient.msgMint({ owner: address, tokenURI: tokenURI });
334
335
  nftTxClient = new nft_1.NftTxClient(wallet, this.config.rpcAddress);
335
- message = nftTxClient.msgMint({ owner: address, tokenURI: tokenURI });
336
336
  return [4 /*yield*/, nftTxClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
337
337
  case 2: return [2 /*return*/, _a.sent()];
338
338
  case 3:
@@ -125,7 +125,7 @@ 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
@@ -154,7 +154,7 @@ 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
@@ -183,7 +183,7 @@ 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,
@@ -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,
@@ -238,7 +238,7 @@ 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,
@@ -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,12 +145,12 @@ 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
  });
153
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
154
154
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
155
155
  case 2: return [2 /*return*/, _a.sent()];
156
156
  case 3:
@@ -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,12 +173,12 @@ 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
  });
181
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
182
182
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
183
183
  case 2: return [2 /*return*/, _a.sent()];
184
184
  case 3:
@@ -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,13 +201,13 @@ 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
  });
210
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
211
211
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
212
212
  case 2: return [2 /*return*/, _a.sent()];
213
213
  case 3:
@@ -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,6 +240,7 @@ var TokenService = /** @class */ (function () {
241
240
  mintable: isMintable,
242
241
  burnable: isBurnable
243
242
  });
243
+ txClient = new token_1.TokenTxClient(wallet, this.config.rpcAddress);
244
244
  return [4 /*yield*/, txClient.sign([message], FirmaUtil_1.getSignAndBroadcastOption(this.config.denom, txMisc))];
245
245
  case 2: return [2 /*return*/, _a.sent()];
246
246
  case 3:
@@ -1,9 +1,11 @@
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
5
  import { ArbitraryVerifyData } from "./firmachain/common/signingaminostargateclient";
6
+ import { EncodeObject, Registry } from "@cosmjs/proto-signing";
6
7
  import { FirmaWalletService } from "./FirmaWalletService";
8
+ import { Any } from "./firmachain/google/protobuf/any";
7
9
  export declare class FirmaUtil {
8
10
  static config: FirmaConfig;
9
11
  static readonly FctDecimal: number;
@@ -34,6 +36,14 @@ export declare class FirmaUtil {
34
36
  static printLog(log: any): void;
35
37
  static experimentalAdr36Sign(wallet: FirmaWalletService, data: string): Promise<ArbitraryVerifyData>;
36
38
  static experimentalAdr36Verify(data: ArbitraryVerifyData, checkMsg: string): Promise<boolean>;
39
+ private static recoverSigningAddress;
40
+ private static verifySignature;
41
+ static verifyDirectSignature(address: string, signature: string, signDoc: SignDoc): Promise<boolean>;
42
+ static parseSignDocValues(signDocString: any): any;
43
+ static stringifySignDocValues(signDoc: any): any;
44
+ static makeSignDoc(registry: Registry, signerAddress: string, messages: readonly EncodeObject[], txMisc?: TxMisc): Promise<SignDoc>;
45
+ static makeSignDocWithStringify(registry: Registry, signerAddress: string, messages: readonly EncodeObject[], txMisc?: TxMisc): Promise<SignDoc>;
46
+ static getAnyData(registry: Registry, message: EncodeObject): Any;
37
47
  }
38
48
  export declare const DefaultTxMisc: {
39
49
  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,12 +56,18 @@ 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"));
45
67
  var CryptoJS = require("crypto-js");
46
68
  var sha1 = require("crypto-js/sha1");
47
69
  var sha256 = require("crypto-js/sha256");
48
70
  var encHex = require("crypto-js/enc-hex");
49
- var signingaminostargateclient_1 = require("./firmachain/common/signingaminostargateclient");
50
- var proto_signing_1 = require("@cosmjs/proto-signing");
51
71
  var FirmaUtil = /** @class */ (function () {
52
72
  function FirmaUtil(firmaConfig) {
53
73
  FirmaUtil.config = firmaConfig;
@@ -89,22 +109,25 @@ var FirmaUtil = /** @class */ (function () {
89
109
  return Number.parseInt(newBig);
90
110
  };
91
111
  FirmaUtil.arrayBufferToBase64 = function (buffer) {
92
- var binary = '';
112
+ return Buffer.from(buffer).toString("base64");
113
+ /*var binary = '';
93
114
  var bytes = new Uint8Array(buffer);
94
115
  var len = bytes.byteLength;
95
116
  for (var i = 0; i < len; i++) {
96
117
  binary += String.fromCharCode(bytes[i]);
97
118
  }
98
- return btoa(binary);
119
+ return btoa(binary);*/
99
120
  };
100
121
  FirmaUtil.base64ToArrayBuffer = function (base64) {
101
- var binary_string = atob(base64);
102
- var len = binary_string.length;
103
- var bytes = new Uint8Array(len);
104
- for (var i = 0; i < len; i++) {
105
- bytes[i] = binary_string.charCodeAt(i);
106
- }
107
- return bytes;
122
+ var buffer = Buffer.from(base64, "base64");
123
+ return new Uint8Array(buffer);
124
+ /* var binary_string = atob(base64);
125
+ var len = binary_string.length;
126
+ var bytes = new Uint8Array(len);
127
+ for (var i = 0; i < len; i++) {
128
+ bytes[i] = binary_string.charCodeAt(i);
129
+ }
130
+ return bytes;*/
108
131
  };
109
132
  FirmaUtil.getTokenStringFromUToken = function (uTokenAmount, decimal) {
110
133
  var fixedUTokenAmount = Math.floor(uTokenAmount);
@@ -291,6 +314,109 @@ var FirmaUtil = /** @class */ (function () {
291
314
  });
292
315
  });
293
316
  };
317
+ FirmaUtil.recoverSigningAddress = function (signature, hash, recoveryIndex) {
318
+ return __awaiter(this, void 0, void 0, function () {
319
+ var sig, extendedSig, recoveredPubKey, _a;
320
+ return __generator(this, function (_b) {
321
+ switch (_b.label) {
322
+ case 0:
323
+ if (recoveryIndex > 3) {
324
+ throw new Error('Invalid recovery index');
325
+ }
326
+ sig = crypto_1.Secp256k1Signature.fromFixedLength(encoding_2.fromBase64(signature));
327
+ extendedSig = new crypto_1.ExtendedSecp256k1Signature(sig.r(), sig.s(), recoveryIndex);
328
+ _b.label = 1;
329
+ case 1:
330
+ _b.trys.push([1, 3, , 4]);
331
+ return [4 /*yield*/, crypto_1.Secp256k1.recoverPubkey(extendedSig, hash)];
332
+ case 2:
333
+ recoveredPubKey = _b.sent();
334
+ return [2 /*return*/, amino_1.pubkeyToAddress({
335
+ type: 'tendermint/PubKeySecp256k1',
336
+ value: encoding_2.toBase64(crypto_1.Secp256k1.compressPubkey(recoveredPubKey)),
337
+ }, 'firma')];
338
+ case 3:
339
+ _a = _b.sent();
340
+ return [2 /*return*/, null];
341
+ case 4: return [2 /*return*/];
342
+ }
343
+ });
344
+ });
345
+ };
346
+ FirmaUtil.verifySignature = function (address, signature, hash) {
347
+ return __awaiter(this, void 0, void 0, function () {
348
+ var i, recoveredAddress;
349
+ return __generator(this, function (_a) {
350
+ switch (_a.label) {
351
+ case 0:
352
+ i = 0;
353
+ _a.label = 1;
354
+ case 1:
355
+ if (!(i < 4)) return [3 /*break*/, 4];
356
+ return [4 /*yield*/, this.recoverSigningAddress(signature, hash, i)];
357
+ case 2:
358
+ recoveredAddress = _a.sent();
359
+ if (recoveredAddress === address) {
360
+ return [2 /*return*/, true];
361
+ }
362
+ _a.label = 3;
363
+ case 3:
364
+ i++;
365
+ return [3 /*break*/, 1];
366
+ case 4: return [2 /*return*/, false];
367
+ }
368
+ });
369
+ });
370
+ };
371
+ FirmaUtil.verifyDirectSignature = function (address, signature, signDoc) {
372
+ var messageHash = crypto_1.sha256(proto_signing_1.makeSignBytes(signDoc));
373
+ return this.verifySignature(address, signature, messageHash);
374
+ };
375
+ ;
376
+ FirmaUtil.parseSignDocValues = function (signDocString) {
377
+ return __assign(__assign({}, signDocString), { bodyBytes: encoding_2.fromHex(signDocString.bodyBytes), authInfoBytes: encoding_2.fromHex(signDocString.authInfoBytes), accountNumber: new long_1.default(signDocString.accountNumber) });
378
+ };
379
+ FirmaUtil.stringifySignDocValues = function (signDoc) {
380
+ return __assign(__assign({}, signDoc), { bodyBytes: encoding_2.toHex(signDoc.bodyBytes), authInfoBytes: encoding_2.toHex(signDoc.authInfoBytes), accountNumber: signDoc.accountNumber.toString(16) });
381
+ };
382
+ FirmaUtil.makeSignDoc = function (registry, signerAddress, messages, txMisc) {
383
+ if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
384
+ return __awaiter(this, void 0, void 0, function () {
385
+ var result, chainID, serverUrl;
386
+ return __generator(this, function (_a) {
387
+ switch (_a.label) {
388
+ case 0:
389
+ result = FirmaUtil.getSignAndBroadcastOption(FirmaUtil.config.denom, txMisc);
390
+ chainID = FirmaUtil.config.chainID;
391
+ serverUrl = FirmaUtil.config.rpcAddress;
392
+ return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.makeSignDocForSend(signerAddress, messages, result.fee, result.memo, serverUrl, chainID, registry)];
393
+ case 1: return [2 /*return*/, _a.sent()];
394
+ }
395
+ });
396
+ });
397
+ };
398
+ FirmaUtil.makeSignDocWithStringify = function (registry, signerAddress, messages, txMisc) {
399
+ if (txMisc === void 0) { txMisc = exports.DefaultTxMisc; }
400
+ return __awaiter(this, void 0, void 0, function () {
401
+ var signDoc, stringSignDoc;
402
+ return __generator(this, function (_a) {
403
+ switch (_a.label) {
404
+ case 0: return [4 /*yield*/, this.makeSignDoc(registry, signerAddress, messages, txMisc)];
405
+ case 1:
406
+ signDoc = _a.sent();
407
+ stringSignDoc = this.stringifySignDocValues(signDoc);
408
+ return [2 /*return*/, stringSignDoc];
409
+ }
410
+ });
411
+ });
412
+ };
413
+ FirmaUtil.getAnyData = function (registry, message) {
414
+ var anyData = any_1.Any.fromPartial({
415
+ typeUrl: message.typeUrl,
416
+ value: registry.encode(message)
417
+ });
418
+ return anyData;
419
+ };
294
420
  FirmaUtil.FctDecimal = 6;
295
421
  return FirmaUtil;
296
422
  }());
@@ -1,4 +1,4 @@
1
- import { EncodeObject } from "@cosmjs/proto-signing";
1
+ import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { MsgExec, MsgGrant, MsgRevoke } from "./AuthzTxTypes";
3
3
  import { ITxClient } from "../common/ITxClient";
4
4
  import { FirmaWalletService } from "../../FirmaWalletService";
@@ -16,7 +16,8 @@ export interface MsgRevokeAllowanceEncodeObject extends EncodeObject {
16
16
  }
17
17
  export declare class AuthzTxClient extends ITxClient {
18
18
  constructor(wallet: FirmaWalletService, serverUrl: string);
19
- msgExecAllowance(data: MsgExec): MsgExecAllowanceEncodeObject;
20
- msgGrantAllowance(data: MsgGrant): MsgGrantAllowanceEncodeObject;
21
- msgRevokeAllowance(data: MsgRevoke): MsgRevokeAllowanceEncodeObject;
19
+ static getRegistry(): Registry;
20
+ static msgExecAllowance(data: MsgExec): MsgExecAllowanceEncodeObject;
21
+ static msgGrantAllowance(data: MsgGrant): MsgGrantAllowanceEncodeObject;
22
+ static msgRevokeAllowance(data: MsgRevoke): MsgRevokeAllowanceEncodeObject;
22
23
  }
@@ -30,13 +30,16 @@ var AuthzTxClient = /** @class */ (function (_super) {
30
30
  function AuthzTxClient(wallet, serverUrl) {
31
31
  return _super.call(this, wallet, serverUrl, registry) || this;
32
32
  }
33
- AuthzTxClient.prototype.msgExecAllowance = function (data) {
33
+ AuthzTxClient.getRegistry = function () {
34
+ return registry;
35
+ };
36
+ AuthzTxClient.msgExecAllowance = function (data) {
34
37
  return { typeUrl: "/cosmos.authz.v1beta1.MsgExec", value: data };
35
38
  };
36
- AuthzTxClient.prototype.msgGrantAllowance = function (data) {
39
+ AuthzTxClient.msgGrantAllowance = function (data) {
37
40
  return { typeUrl: "/cosmos.authz.v1beta1.MsgGrant", value: data };
38
41
  };
39
- AuthzTxClient.prototype.msgRevokeAllowance = function (data) {
42
+ AuthzTxClient.msgRevokeAllowance = function (data) {
40
43
  return { typeUrl: "/cosmos.authz.v1beta1.MsgRevoke", value: data };
41
44
  };
42
45
  return AuthzTxClient;
@@ -1,4 +1,4 @@
1
- import { EncodeObject } from "@cosmjs/proto-signing";
1
+ import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { MsgSend, MsgMultiSend } from "cosmjs-types/cosmos/bank/v1beta1/tx";
3
3
  import { FirmaWalletService } from "../../FirmaWalletService";
4
4
  import { ITxClient } from "../common/ITxClient";
@@ -12,6 +12,7 @@ export interface MsgMultiSendEncodeObject extends EncodeObject {
12
12
  }
13
13
  export declare class BankTxClient extends ITxClient {
14
14
  constructor(wallet: FirmaWalletService, address: string);
15
- msgSend(data: MsgSend): MsgSendEncodeObject;
16
- msgMultiSend(data: MsgMultiSend): MsgMultiSendEncodeObject;
15
+ static getRegistry(): Registry;
16
+ static msgSend(data: MsgSend): MsgSendEncodeObject;
17
+ static msgMultiSend(data: MsgMultiSend): MsgMultiSendEncodeObject;
17
18
  }
@@ -29,10 +29,13 @@ var BankTxClient = /** @class */ (function (_super) {
29
29
  function BankTxClient(wallet, address) {
30
30
  return _super.call(this, wallet, address, registry) || this;
31
31
  }
32
- BankTxClient.prototype.msgSend = function (data) {
32
+ BankTxClient.getRegistry = function () {
33
+ return registry;
34
+ };
35
+ BankTxClient.msgSend = function (data) {
33
36
  return { typeUrl: "/cosmos.bank.v1beta1.MsgSend", value: data };
34
37
  };
35
- BankTxClient.prototype.msgMultiSend = function (data) {
38
+ BankTxClient.msgMultiSend = function (data) {
36
39
  return { typeUrl: "/cosmos.bank.v1beta1.MsgMultiSend", value: data };
37
40
  };
38
41
  return BankTxClient;
@@ -1,18 +1,18 @@
1
1
  import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { SignAndBroadcastOptions } from ".";
3
- import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
3
+ import { SignDoc, TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
4
+ import { TxRawExt } from "./signingstargateclient";
4
5
  import { BroadcastTxResponse } from "./stargateclient";
5
6
  import { FirmaWalletService } from "../../FirmaWalletService";
6
- import { Any } from "cosmjs-types/google/protobuf/any";
7
7
  export declare class ITxClient {
8
8
  private readonly wallet;
9
9
  private readonly serverUrl;
10
10
  private readonly registry;
11
11
  private rawWallet;
12
12
  constructor(wallet: FirmaWalletService, serverUrl: string, registry: Registry);
13
- getAnyData(message: EncodeObject): Any;
14
13
  getRegistry(): Registry;
15
14
  sign(msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions): Promise<TxRaw>;
16
15
  broadcast(txRaw: TxRaw): Promise<BroadcastTxResponse>;
17
16
  signAndBroadcast(msgs: EncodeObject[], { fee, memo }: SignAndBroadcastOptions): Promise<BroadcastTxResponse>;
17
+ signDirectForSignDoc(signerAddress: string, signDoc: SignDoc): Promise<TxRawExt>;
18
18
  }
@@ -39,7 +39,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.ITxClient = void 0;
40
40
  var tx_1 = require("cosmjs-types/cosmos/tx/v1beta1/tx");
41
41
  var signingstargateclient_1 = require("./signingstargateclient");
42
- var any_1 = require("cosmjs-types/google/protobuf/any");
43
42
  var ITxClient = /** @class */ (function () {
44
43
  function ITxClient(wallet, serverUrl, registry) {
45
44
  this.wallet = wallet;
@@ -47,13 +46,6 @@ var ITxClient = /** @class */ (function () {
47
46
  this.registry = registry;
48
47
  this.rawWallet = wallet.getRawWallet();
49
48
  }
50
- ITxClient.prototype.getAnyData = function (message) {
51
- var anyData = any_1.Any.fromPartial({
52
- typeUrl: message.typeUrl,
53
- value: this.getRegistry().encode(message)
54
- });
55
- return anyData;
56
- };
57
49
  ITxClient.prototype.getRegistry = function () { return this.registry; };
58
50
  ITxClient.prototype.sign = function (msgs, _a) {
59
51
  var fee = _a.fee, memo = _a.memo;
@@ -106,6 +98,20 @@ var ITxClient = /** @class */ (function () {
106
98
  });
107
99
  });
108
100
  };
101
+ ITxClient.prototype.signDirectForSignDoc = function (signerAddress, signDoc) {
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ var client;
104
+ return __generator(this, function (_a) {
105
+ switch (_a.label) {
106
+ case 0: return [4 /*yield*/, signingstargateclient_1.SigningStargateClient.connectWithSigner(this.serverUrl, this.rawWallet, this.registry)];
107
+ case 1:
108
+ client = _a.sent();
109
+ return [4 /*yield*/, client.signDirectForSignDoc(signerAddress, signDoc)];
110
+ case 2: return [2 /*return*/, _a.sent()];
111
+ }
112
+ });
113
+ });
114
+ };
109
115
  return ITxClient;
110
116
  }());
111
117
  exports.ITxClient = ITxClient;
@@ -1,6 +1,6 @@
1
1
  import { EncodeObject, OfflineDirectSigner, Registry } from "@cosmjs/proto-signing";
2
2
  import { Tendermint34Client } from "@cosmjs/tendermint-rpc";
3
- import { TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
3
+ import { SignDoc, TxRaw } from "cosmjs-types/cosmos/tx/v1beta1/tx";
4
4
  import { StdFee } from ".";
5
5
  import { Account } from "./accounts";
6
6
  import { BroadcastTxResponse, StargateClient } from "./stargateclient";
@@ -13,14 +13,20 @@ export interface SequenceResponse {
13
13
  readonly accountNumber: number;
14
14
  readonly sequence: number;
15
15
  }
16
+ export interface TxRawExt {
17
+ readonly txRaw: TxRaw;
18
+ readonly signature: string;
19
+ }
16
20
  export declare class SigningStargateClient extends StargateClient {
17
21
  private readonly signer;
18
22
  private readonly registry;
19
23
  private chainId;
20
24
  private static _endpoint;
21
- static connectWithSigner(endpoint: string, signer: OfflineDirectSigner, registry: Registry): Promise<SigningStargateClient>;
22
- protected constructor(tmClient: Tendermint34Client | undefined, signer: OfflineDirectSigner, registry: Registry);
25
+ private getSigner;
26
+ static connectWithSigner(endpoint: string, signer: OfflineDirectSigner | undefined, registry: Registry): Promise<SigningStargateClient>;
27
+ protected constructor(tmClient: Tendermint34Client | undefined, signer: OfflineDirectSigner | undefined, registry: Registry);
23
28
  signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee, memo?: string): Promise<BroadcastTxResponse>;
29
+ static makeSignDocForSend(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee, memo: string, serverUrl: string, chainId: string, registry: Registry): Promise<SignDoc>;
24
30
  sign(signerAddress: string, messages: readonly EncodeObject[], fee: StdFee, memo: string, explicitSignerData?: SignerData): Promise<TxRaw>;
25
31
  getChainId(): Promise<string>;
26
32
  /**
@@ -28,10 +34,11 @@ export declare class SigningStargateClient extends StargateClient {
28
34
  * This is called AccAddress in Cosmos SDK, which is basically an alias for raw binary data.
29
35
  * The result is typically 20 bytes long but not restricted to that.
30
36
  */
31
- private toAccAddress;
32
- getAccount(address: string): Promise<Account | undefined>;
33
- getSequence(address: string): Promise<SequenceResponse>;
34
- private makeSignerInfos;
35
- private makeAuthInfoBytes;
37
+ private static toAccAddress;
38
+ static getAccount(address: string): Promise<Account | undefined>;
39
+ static getSequence(address: string): Promise<SequenceResponse>;
40
+ private static makeSignerInfos;
41
+ private static makeAuthInfoBytes;
36
42
  private signDirect;
43
+ signDirectForSignDoc(signerAddress: string, signDoc: SignDoc): Promise<TxRawExt>;
37
44
  }