@firmachain/firma-js 0.2.32 → 0.2.35

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 (87) hide show
  1. package/dist/index.js +5 -1
  2. package/dist/sdk/FirmaAuthzService.js +20 -20
  3. package/dist/sdk/FirmaBankService.js +2 -2
  4. package/dist/sdk/FirmaContractService.js +14 -16
  5. package/dist/sdk/FirmaCosmWasmService.js +27 -29
  6. package/dist/sdk/FirmaDistributionService.js +10 -10
  7. package/dist/sdk/FirmaFeeGrantService.js +6 -6
  8. package/dist/sdk/FirmaGovService.js +26 -26
  9. package/dist/sdk/FirmaIbcService.js +4 -4
  10. package/dist/sdk/FirmaIpfsService.js +1 -1
  11. package/dist/sdk/FirmaNftService.js +9 -9
  12. package/dist/sdk/FirmaStakingService.js +10 -10
  13. package/dist/sdk/FirmaTokenService.js +16 -16
  14. package/dist/sdk/FirmaUtil.d.ts +13 -1
  15. package/dist/sdk/FirmaUtil.js +145 -14
  16. package/dist/sdk/FirmaWalletService.js +3 -3
  17. package/dist/sdk/firmachain/amino/addresses.js +11 -11
  18. package/dist/sdk/firmachain/amino/aminotypes.js +36 -32
  19. package/dist/sdk/firmachain/amino/encoding.js +30 -26
  20. package/dist/sdk/firmachain/amino/multisig.js +5 -5
  21. package/dist/sdk/firmachain/amino/signature.js +4 -4
  22. package/dist/sdk/firmachain/amino/signdoc.js +1 -1
  23. package/dist/sdk/firmachain/amino/wallet.js +14 -10
  24. package/dist/sdk/firmachain/authz/AuthzQueryClient.js +3 -3
  25. package/dist/sdk/firmachain/authz/AuthzTxClient.d.ts +5 -4
  26. package/dist/sdk/firmachain/authz/AuthzTxClient.js +6 -3
  27. package/dist/sdk/firmachain/authz/index.js +5 -1
  28. package/dist/sdk/firmachain/bank/BankQueryClient.js +4 -4
  29. package/dist/sdk/firmachain/bank/BankTxClient.d.ts +4 -3
  30. package/dist/sdk/firmachain/bank/BankTxClient.js +5 -2
  31. package/dist/sdk/firmachain/bank/index.js +5 -1
  32. package/dist/sdk/firmachain/common/CommonTxClient.d.ts +7 -0
  33. package/dist/sdk/firmachain/common/CommonTxClient.js +79 -0
  34. package/dist/sdk/firmachain/common/ITxClient.d.ts +3 -3
  35. package/dist/sdk/firmachain/common/ITxClient.js +14 -8
  36. package/dist/sdk/firmachain/common/LedgerSigningStargateClient.js +2 -2
  37. package/dist/sdk/firmachain/common/LedgerWallet.js +14 -10
  38. package/dist/sdk/firmachain/common/accounts.js +2 -2
  39. package/dist/sdk/firmachain/common/index.js +5 -1
  40. package/dist/sdk/firmachain/common/signing.js +9 -5
  41. package/dist/sdk/firmachain/common/signingaminostargateclient.js +16 -16
  42. package/dist/sdk/firmachain/common/signingstargateclient.d.ts +15 -8
  43. package/dist/sdk/firmachain/common/signingstargateclient.js +82 -19
  44. package/dist/sdk/firmachain/common/stargateclient.js +6 -6
  45. package/dist/sdk/firmachain/contract/ContractQueryClient.js +2 -2
  46. package/dist/sdk/firmachain/contract/ContractTxClient.d.ts +4 -3
  47. package/dist/sdk/firmachain/contract/ContractTxClient.js +5 -2
  48. package/dist/sdk/firmachain/contract/ContractTxTypes.d.ts +4 -4
  49. package/dist/sdk/firmachain/contract/index.js +5 -1
  50. package/dist/sdk/firmachain/cosmwasm/CosmWasmQueryClient.js +7 -7
  51. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.d.ts +8 -7
  52. package/dist/sdk/firmachain/cosmwasm/CosmWasmTxClient.js +9 -6
  53. package/dist/sdk/firmachain/cosmwasm/index.js +5 -1
  54. package/dist/sdk/firmachain/distribution/DistributionQueryClient.js +5 -5
  55. package/dist/sdk/firmachain/distribution/DistributionTxClient.d.ts +6 -5
  56. package/dist/sdk/firmachain/distribution/DistributionTxClient.js +7 -4
  57. package/dist/sdk/firmachain/distribution/index.js +5 -1
  58. package/dist/sdk/firmachain/feegrant/FeeGrantQueryClient.js +2 -2
  59. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.d.ts +4 -3
  60. package/dist/sdk/firmachain/feegrant/FeeGrantTxClient.js +5 -2
  61. package/dist/sdk/firmachain/feegrant/index.js +5 -1
  62. package/dist/sdk/firmachain/google/protobuf/any.d.ts +1 -1
  63. package/dist/sdk/firmachain/google/protobuf/descriptor.d.ts +27 -27
  64. package/dist/sdk/firmachain/google/protobuf/duration.d.ts +1 -1
  65. package/dist/sdk/firmachain/google/protobuf/timestamp.d.ts +1 -1
  66. package/dist/sdk/firmachain/gov/GovQueryClient.js +2 -2
  67. package/dist/sdk/firmachain/gov/GovTxClient.d.ts +5 -4
  68. package/dist/sdk/firmachain/gov/GovTxClient.js +6 -3
  69. package/dist/sdk/firmachain/gov/index.js +5 -1
  70. package/dist/sdk/firmachain/ibc/IbcQueryClient.js +1 -1
  71. package/dist/sdk/firmachain/ibc/IbcTxClient.d.ts +3 -2
  72. package/dist/sdk/firmachain/ibc/IbcTxClient.js +4 -1
  73. package/dist/sdk/firmachain/ibc/index.js +5 -1
  74. package/dist/sdk/firmachain/nft/NftTxClient.d.ts +5 -4
  75. package/dist/sdk/firmachain/nft/NftTxClient.js +6 -3
  76. package/dist/sdk/firmachain/nft/NftTxTypes.d.ts +6 -6
  77. package/dist/sdk/firmachain/nft/index.js +5 -1
  78. package/dist/sdk/firmachain/slashing/index.js +5 -1
  79. package/dist/sdk/firmachain/staking/StakingQueryClient.js +8 -8
  80. package/dist/sdk/firmachain/staking/StakingTxClient.d.ts +7 -6
  81. package/dist/sdk/firmachain/staking/StakingTxClient.js +8 -5
  82. package/dist/sdk/firmachain/staking/index.js +5 -1
  83. package/dist/sdk/firmachain/token/TokenTxClient.d.ts +6 -5
  84. package/dist/sdk/firmachain/token/TokenTxClient.js +7 -4
  85. package/dist/sdk/firmachain/token/TokenTxTypes.d.ts +8 -8
  86. package/dist/sdk/firmachain/token/index.js +5 -1
  87. package/package.json +2 -4
@@ -77,7 +77,7 @@ function isMsgSignData(msg) {
77
77
  var castedMsg = msg;
78
78
  if (castedMsg.type !== "sign/MsgSignData")
79
79
  return false;
80
- if (!utils_1.isNonNullObject(castedMsg.value))
80
+ if (!(0, utils_1.isNonNullObject)(castedMsg.value))
81
81
  return false;
82
82
  if (typeof castedMsg.value.signer !== "string")
83
83
  return false;
@@ -128,7 +128,7 @@ var SigningAminoStargateClient = /** @class */ (function (_super) {
128
128
  type: "sign/MsgSignData",
129
129
  value: {
130
130
  signer: signerAddress,
131
- data: encoding_1.toBase64(d),
131
+ data: (0, encoding_1.toBase64)(d),
132
132
  },
133
133
  }); });
134
134
  return [4 /*yield*/, this.signer.getAccounts()];
@@ -137,15 +137,15 @@ var SigningAminoStargateClient = /** @class */ (function (_super) {
137
137
  if (!accountFromSigner) {
138
138
  throw new Error("Failed to retrieve account from signer");
139
139
  }
140
- signDoc = amino_1.makeSignDoc(msgs, fee, chainId, memo, accountNumber, sequence);
140
+ signDoc = (0, amino_1.makeSignDoc)(msgs, fee, chainId, memo, accountNumber, sequence);
141
141
  return [4 /*yield*/, this.signer.signAmino(signerAddress, signDoc)];
142
142
  case 2:
143
143
  _a = _b.sent(), signature = _a.signature, signed = _a.signed;
144
- if (!fast_deep_equal_1.default(signDoc, signed)) {
144
+ if (!(0, fast_deep_equal_1.default)(signDoc, signed)) {
145
145
  throw new Error("The signed document differs from the signing instruction. This is not supported for ADR-036.");
146
146
  }
147
- signatureResult = tx_1.makeStdTx(signDoc, signature);
148
- decodeData = amino_1.decodeSignature(signatureResult.signatures[0]);
147
+ signatureResult = (0, tx_1.makeStdTx)(signDoc, signature);
148
+ decodeData = (0, amino_1.decodeSignature)(signatureResult.signatures[0]);
149
149
  jsonData = {
150
150
  type: "sign/MsgSignData",
151
151
  signer: signatureResult.msg[0].value.signer,
@@ -164,7 +164,7 @@ var SigningAminoStargateClient = /** @class */ (function (_super) {
164
164
  return __generator(this, function (_a) {
165
165
  switch (_a.label) {
166
166
  case 0:
167
- newSignature = amino_1.encodeSecp256k1Signature(FirmaUtil_1.FirmaUtil.base64ToArrayBuffer(data.pubkey), FirmaUtil_1.FirmaUtil.base64ToArrayBuffer(data.signature));
167
+ newSignature = (0, amino_1.encodeSecp256k1Signature)(FirmaUtil_1.FirmaUtil.base64ToArrayBuffer(data.pubkey), FirmaUtil_1.FirmaUtil.base64ToArrayBuffer(data.signature));
168
168
  signed = {
169
169
  fee: {
170
170
  gas: "0",
@@ -202,15 +202,15 @@ var SigningAminoStargateClient = /** @class */ (function (_super) {
202
202
  if (signatures.length !== 1)
203
203
  throw new Error("Must have exactly one signature to be supported.");
204
204
  signature = signatures[0];
205
- if (!amino_2.isSecp256k1Pubkey(signature.pub_key)) {
205
+ if (!(0, amino_2.isSecp256k1Pubkey)(signature.pub_key)) {
206
206
  throw new Error("Only secp256k1 signatures are supported.");
207
207
  }
208
- signBytes = amino_2.serializeSignDoc(amino_1.makeSignDoc(signed.msg, signed.fee, chainId, signed.memo, accountNumber, sequence));
209
- prehashed = crypto_1.sha256(signBytes);
210
- secpSignature = crypto_2.Secp256k1Signature.fromFixedLength(encoding_2.fromBase64(signature.signature));
211
- rawSecp256k1Pubkey = encoding_2.fromBase64(signature.pub_key.value);
212
- rawSignerAddress = amino_3.rawSecp256k1PubkeyToRawAddress(rawSecp256k1Pubkey);
213
- if (signedMessages.some(function (msg) { return !utils_2.arrayContentEquals(encoding_1.Bech32.decode(msg.value.signer).data, rawSignerAddress); })) {
208
+ signBytes = (0, amino_2.serializeSignDoc)((0, amino_1.makeSignDoc)(signed.msg, signed.fee, chainId, signed.memo, accountNumber, sequence));
209
+ prehashed = (0, crypto_1.sha256)(signBytes);
210
+ secpSignature = crypto_2.Secp256k1Signature.fromFixedLength((0, encoding_2.fromBase64)(signature.signature));
211
+ rawSecp256k1Pubkey = (0, encoding_2.fromBase64)(signature.pub_key.value);
212
+ rawSignerAddress = (0, amino_3.rawSecp256k1PubkeyToRawAddress)(rawSecp256k1Pubkey);
213
+ if (signedMessages.some(function (msg) { return !(0, utils_2.arrayContentEquals)(encoding_1.Bech32.decode(msg.value.signer).data, rawSignerAddress); })) {
214
214
  throw new Error("Found mismatch between signer in message and public key");
215
215
  }
216
216
  return [4 /*yield*/, crypto_2.Secp256k1.verifySignature(secpSignature, prehashed, rawSecp256k1Pubkey)];
@@ -237,7 +237,7 @@ var SigningAminoStargateClient = /** @class */ (function (_super) {
237
237
  case 0:
238
238
  _a.trys.push([0, 2, , 3]);
239
239
  accAddress = this.toAccAddress(address);
240
- hexAccAddress = "0x01" + Buffer.from(accAddress).toString("hex");
240
+ hexAccAddress = "0x01".concat(Buffer.from(accAddress).toString("hex"));
241
241
  axios = axios_1.default.create({
242
242
  baseURL: SigningAminoStargateClient._endpoint,
243
243
  headers: {
@@ -251,7 +251,7 @@ var SigningAminoStargateClient = /** @class */ (function (_super) {
251
251
  result = _a.sent();
252
252
  finalData = result.data.result.response.value;
253
253
  account = any_1.Any.decode(Buffer.from(finalData, "base64"));
254
- finalAccount = accounts_1.accountFromAny(account);
254
+ finalAccount = (0, accounts_1.accountFromAny)(account);
255
255
  return [2 /*return*/, finalAccount];
256
256
  case 2:
257
257
  error_1 = _a.sent();
@@ -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
  }
@@ -66,10 +66,14 @@ var __read = (this && this.__read) || function (o, n) {
66
66
  }
67
67
  return ar;
68
68
  };
69
- var __spreadArray = (this && this.__spreadArray) || function (to, from) {
70
- for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
71
- to[j] = from[i];
72
- return to;
69
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
70
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
71
+ if (ar || !(i in from)) {
72
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
73
+ ar[i] = from[i];
74
+ }
75
+ }
76
+ return to.concat(ar || Array.prototype.slice.call(from));
73
77
  };
74
78
  var __importDefault = (this && this.__importDefault) || function (mod) {
75
79
  return (mod && mod.__esModule) ? mod : { "default": mod };
@@ -97,6 +101,9 @@ var SigningStargateClient = /** @class */ (function (_super) {
97
101
  _this.signer = signer;
98
102
  return _this;
99
103
  }
104
+ SigningStargateClient.prototype.getSigner = function () {
105
+ return this.signer;
106
+ };
100
107
  SigningStargateClient.connectWithSigner = function (endpoint, signer, registry) {
101
108
  return __awaiter(this, void 0, void 0, function () {
102
109
  var tmClient;
@@ -127,6 +134,38 @@ var SigningStargateClient = /** @class */ (function (_super) {
127
134
  });
128
135
  });
129
136
  };
137
+ SigningStargateClient.makeSignDocForSend = function (signerAddress, messages, fee, memo, serverUrl, chainId, registry) {
138
+ return __awaiter(this, void 0, void 0, function () {
139
+ var _a, accountNumber, sequence, account, rawSecp256k1Pubkey, pubkey, txBodyEncodeObject, txBodyBytes, gasLimit, authInfoBytes;
140
+ return __generator(this, function (_b) {
141
+ switch (_b.label) {
142
+ case 0:
143
+ SigningStargateClient._endpoint = serverUrl;
144
+ return [4 /*yield*/, SigningStargateClient.getSequence(signerAddress)];
145
+ case 1:
146
+ _a = _b.sent(), accountNumber = _a.accountNumber, sequence = _a.sequence;
147
+ return [4 /*yield*/, SigningStargateClient.getAccount(signerAddress)];
148
+ case 2:
149
+ account = _b.sent();
150
+ if (account == null)
151
+ throw new Error("Failed to retrieve account from signer");
152
+ rawSecp256k1Pubkey = (0, encoding_1.fromBase64)(account.pubkey.value);
153
+ pubkey = (0, proto_signing_1.encodePubkey)((0, encoding_3.encodeSecp256k1Pubkey)(rawSecp256k1Pubkey));
154
+ txBodyEncodeObject = {
155
+ typeUrl: "/cosmos.tx.v1beta1.TxBody",
156
+ value: {
157
+ messages: messages,
158
+ memo: memo,
159
+ },
160
+ };
161
+ txBodyBytes = registry.encode(txBodyEncodeObject);
162
+ gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
163
+ authInfoBytes = this.makeAuthInfoBytes([{ pubkey: pubkey, sequence: sequence }], fee.amount, gasLimit, fee.granter);
164
+ return [2 /*return*/, (0, proto_signing_1.makeSignDoc)(txBodyBytes, authInfoBytes, chainId, accountNumber)];
165
+ }
166
+ });
167
+ });
168
+ };
130
169
  SigningStargateClient.prototype.sign = function (signerAddress, messages, fee, memo, explicitSignerData) {
131
170
  return __awaiter(this, void 0, void 0, function () {
132
171
  var signerData, _a, accountNumber, sequence, chainId;
@@ -136,7 +175,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
136
175
  if (!explicitSignerData) return [3 /*break*/, 1];
137
176
  signerData = explicitSignerData;
138
177
  return [3 /*break*/, 4];
139
- case 1: return [4 /*yield*/, this.getSequence(signerAddress)];
178
+ case 1: return [4 /*yield*/, SigningStargateClient.getSequence(signerAddress)];
140
179
  case 2:
141
180
  _a = _b.sent(), accountNumber = _a.accountNumber, sequence = _a.sequence;
142
181
  return [4 /*yield*/, this.getChainId()];
@@ -178,10 +217,10 @@ var SigningStargateClient = /** @class */ (function (_super) {
178
217
  * This is called AccAddress in Cosmos SDK, which is basically an alias for raw binary data.
179
218
  * The result is typically 20 bytes long but not restricted to that.
180
219
  */
181
- SigningStargateClient.prototype.toAccAddress = function (address) {
220
+ SigningStargateClient.toAccAddress = function (address) {
182
221
  return encoding_2.Bech32.decode(address).data;
183
222
  };
184
- SigningStargateClient.prototype.getAccount = function (address) {
223
+ SigningStargateClient.getAccount = function (address) {
185
224
  return __awaiter(this, void 0, void 0, function () {
186
225
  var accAddress, hexAccAddress, axios, path, result, finalData, account, finalAccount, error_1;
187
226
  return __generator(this, function (_a) {
@@ -189,7 +228,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
189
228
  case 0:
190
229
  _a.trys.push([0, 2, , 3]);
191
230
  accAddress = this.toAccAddress(address);
192
- hexAccAddress = "0x01" + Buffer.from(accAddress).toString("hex");
231
+ hexAccAddress = "0x01".concat(Buffer.from(accAddress).toString("hex"));
193
232
  axios = axios_1.default.create({
194
233
  baseURL: SigningStargateClient._endpoint,
195
234
  headers: {
@@ -203,7 +242,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
203
242
  result = _a.sent();
204
243
  finalData = result.data.result.response.value;
205
244
  account = any_1.Any.decode(Buffer.from(finalData, "base64"));
206
- finalAccount = accounts_1.accountFromAny(account);
245
+ finalAccount = (0, accounts_1.accountFromAny)(account);
207
246
  return [2 /*return*/, finalAccount];
208
247
  case 2:
209
248
  error_1 = _a.sent();
@@ -213,7 +252,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
213
252
  });
214
253
  });
215
254
  };
216
- SigningStargateClient.prototype.getSequence = function (address) {
255
+ SigningStargateClient.getSequence = function (address) {
217
256
  return __awaiter(this, void 0, void 0, function () {
218
257
  var account;
219
258
  return __generator(this, function (_a) {
@@ -232,7 +271,7 @@ var SigningStargateClient = /** @class */ (function (_super) {
232
271
  });
233
272
  });
234
273
  };
235
- SigningStargateClient.prototype.makeSignerInfos = function (signers, signMode) {
274
+ SigningStargateClient.makeSignerInfos = function (signers, signMode) {
236
275
  return signers.map(function (_a) {
237
276
  var pubkey = _a.pubkey, sequence = _a.sequence;
238
277
  return ({
@@ -244,12 +283,12 @@ var SigningStargateClient = /** @class */ (function (_super) {
244
283
  });
245
284
  });
246
285
  };
247
- SigningStargateClient.prototype.makeAuthInfoBytes = function (signers, feeAmount, gasLimit, granter, signMode) {
286
+ SigningStargateClient.makeAuthInfoBytes = function (signers, feeAmount, gasLimit, granter, signMode) {
248
287
  if (signMode === void 0) { signMode = signing_1.SignMode.SIGN_MODE_DIRECT; }
249
288
  var authInfo = {
250
289
  signerInfos: this.makeSignerInfos(signers, signMode),
251
290
  fee: {
252
- amount: __spreadArray([], __read(feeAmount)),
291
+ amount: __spreadArray([], __read(feeAmount), false),
253
292
  gasLimit: long_1.default.fromNumber(gasLimit),
254
293
  granter: granter,
255
294
  },
@@ -262,13 +301,13 @@ var SigningStargateClient = /** @class */ (function (_super) {
262
301
  var accountFromSigner, pubkey, txBodyEncodeObject, txBodyBytes, gasLimit, authInfoBytes, signDoc, _b, signature, signed;
263
302
  return __generator(this, function (_c) {
264
303
  switch (_c.label) {
265
- case 0: return [4 /*yield*/, this.signer.getAccounts()];
304
+ case 0: return [4 /*yield*/, this.getSigner().getAccounts()];
266
305
  case 1:
267
306
  accountFromSigner = (_c.sent()).find(function (account) { return account.address === signerAddress; });
268
307
  if (!accountFromSigner) {
269
308
  throw new Error("Failed to retrieve account from signer");
270
309
  }
271
- pubkey = proto_signing_1.encodePubkey(encoding_3.encodeSecp256k1Pubkey(accountFromSigner.pubkey));
310
+ pubkey = (0, proto_signing_1.encodePubkey)((0, encoding_3.encodeSecp256k1Pubkey)(accountFromSigner.pubkey));
272
311
  txBodyEncodeObject = {
273
312
  typeUrl: "/cosmos.tx.v1beta1.TxBody",
274
313
  value: {
@@ -278,20 +317,44 @@ var SigningStargateClient = /** @class */ (function (_super) {
278
317
  };
279
318
  txBodyBytes = this.registry.encode(txBodyEncodeObject);
280
319
  gasLimit = math_1.Int53.fromString(fee.gas).toNumber();
281
- authInfoBytes = this.makeAuthInfoBytes([{ pubkey: pubkey, sequence: sequence }], fee.amount, gasLimit, fee.granter);
282
- signDoc = proto_signing_1.makeSignDoc(txBodyBytes, authInfoBytes, chainId, accountNumber);
283
- return [4 /*yield*/, this.signer.signDirect(signerAddress, signDoc)];
320
+ authInfoBytes = SigningStargateClient.makeAuthInfoBytes([{ pubkey: pubkey, sequence: sequence }], fee.amount, gasLimit, fee.granter);
321
+ signDoc = (0, proto_signing_1.makeSignDoc)(txBodyBytes, authInfoBytes, chainId, accountNumber);
322
+ return [4 /*yield*/, this.getSigner().signDirect(signerAddress, signDoc)];
284
323
  case 2:
285
324
  _b = _c.sent(), signature = _b.signature, signed = _b.signed;
286
325
  return [2 /*return*/, tx_1.TxRaw.fromPartial({
287
326
  bodyBytes: signed.bodyBytes,
288
327
  authInfoBytes: signed.authInfoBytes,
289
- signatures: [encoding_1.fromBase64(signature.signature)],
328
+ signatures: [(0, encoding_1.fromBase64)(signature.signature)],
290
329
  })];
291
330
  }
292
331
  });
293
332
  });
294
333
  };
334
+ SigningStargateClient.prototype.signDirectForSignDoc = function (signerAddress, signDoc) {
335
+ return __awaiter(this, void 0, void 0, function () {
336
+ var accountFromSigner, _a, signature, signed, txRaw;
337
+ return __generator(this, function (_b) {
338
+ switch (_b.label) {
339
+ case 0: return [4 /*yield*/, this.getSigner().getAccounts()];
340
+ case 1:
341
+ accountFromSigner = (_b.sent()).find(function (account) { return account.address === signerAddress; });
342
+ if (!accountFromSigner) {
343
+ throw new Error("Failed to retrieve account from signer");
344
+ }
345
+ return [4 /*yield*/, this.getSigner().signDirect(signerAddress, signDoc)];
346
+ case 2:
347
+ _a = _b.sent(), signature = _a.signature, signed = _a.signed;
348
+ txRaw = tx_1.TxRaw.fromPartial({
349
+ bodyBytes: signed.bodyBytes,
350
+ authInfoBytes: signed.authInfoBytes,
351
+ signatures: [(0, encoding_1.fromBase64)(signature.signature)],
352
+ });
353
+ return [2 /*return*/, { txRaw: txRaw, signature: signature.signature }];
354
+ }
355
+ });
356
+ });
357
+ };
295
358
  SigningStargateClient._endpoint = "";
296
359
  return SigningStargateClient;
297
360
  }(stargateclient_1.StargateClient));
@@ -108,7 +108,7 @@ var StargateClient = /** @class */ (function () {
108
108
  var results;
109
109
  return __generator(this, function (_b) {
110
110
  switch (_b.label) {
111
- case 0: return [4 /*yield*/, this.txsQuery("tx.hash='" + id + "'")];
111
+ case 0: return [4 /*yield*/, this.txsQuery("tx.hash='".concat(id, "'"))];
112
112
  case 1:
113
113
  results = _b.sent();
114
114
  return [2 /*return*/, (_a = results[0]) !== null && _a !== void 0 ? _a : null];
@@ -139,9 +139,9 @@ var StargateClient = /** @class */ (function () {
139
139
  switch (_a.label) {
140
140
  case 0:
141
141
  if (timedOut) {
142
- throw new TimeoutError("Transaction with ID " + txId + " was submitted but was not yet found on the chain. You might want to check later.", txId);
142
+ throw new TimeoutError("Transaction with ID ".concat(txId, " was submitted but was not yet found on the chain. You might want to check later."), txId);
143
143
  }
144
- return [4 /*yield*/, utils_1.sleep(pollIntervalMs)];
144
+ return [4 /*yield*/, (0, utils_1.sleep)(pollIntervalMs)];
145
145
  case 1:
146
146
  _a.sent();
147
147
  return [4 /*yield*/, this.getTx(txId)];
@@ -167,9 +167,9 @@ var StargateClient = /** @class */ (function () {
167
167
  case 2:
168
168
  broadcasted = _a.sent();
169
169
  if (broadcasted.code) {
170
- throw new Error("Broadcasting transaction failed with code " + broadcasted.code + " (codespace: " + broadcasted.codeSpace + "). Log: " + broadcasted.log);
170
+ throw new Error("Broadcasting transaction failed with code ".concat(broadcasted.code, " (codespace: ").concat(broadcasted.codeSpace, "). Log: ").concat(broadcasted.log));
171
171
  }
172
- transactionId = encoding_1.toHex(broadcasted.hash).toUpperCase();
172
+ transactionId = (0, encoding_1.toHex)(broadcasted.hash).toUpperCase();
173
173
  return [2 /*return*/, new Promise(function (resolve, reject) {
174
174
  return pollForTx(transactionId).then(function (value) {
175
175
  clearTimeout(txPollTimeout);
@@ -194,7 +194,7 @@ var StargateClient = /** @class */ (function () {
194
194
  return [2 /*return*/, results.txs.map(function (tx) {
195
195
  return {
196
196
  height: tx.height,
197
- hash: encoding_1.toHex(tx.hash).toUpperCase(),
197
+ hash: (0, encoding_1.toHex)(tx.hash).toUpperCase(),
198
198
  code: tx.result.code,
199
199
  rawLog: tx.result.log || "",
200
200
  tx: tx.tx,
@@ -87,7 +87,7 @@ var ContractQueryClient = /** @class */ (function () {
87
87
  return __generator(this, function (_a) {
88
88
  switch (_a.label) {
89
89
  case 0:
90
- path = "/firmachain/firmachain/contract/contractFile/" + fileHash;
90
+ path = "/firmachain/firmachain/contract/contractFile/".concat(fileHash);
91
91
  return [4 /*yield*/, this.axios.get(path)];
92
92
  case 1:
93
93
  result = _a.sent();
@@ -122,7 +122,7 @@ var ContractQueryClient = /** @class */ (function () {
122
122
  return __generator(this, function (_a) {
123
123
  switch (_a.label) {
124
124
  case 0:
125
- path = "/firmachain/firmachain/contract/contractLog/" + logId;
125
+ path = "/firmachain/firmachain/contract/contractLog/".concat(logId);
126
126
  return [4 /*yield*/, this.axios.get(path)];
127
127
  case 1:
128
128
  result = _a.sent();
@@ -1,4 +1,4 @@
1
- import { EncodeObject } from "@cosmjs/proto-signing";
1
+ import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { MsgCreateContractFile, MsgAddContractLog } from "./ContractTxTypes";
3
3
  import { ITxClient } from "../common/ITxClient";
4
4
  import { FirmaWalletService } from "../../FirmaWalletService";
@@ -12,6 +12,7 @@ export interface MsgCreateContractFileEncodeObject extends EncodeObject {
12
12
  }
13
13
  export declare class ContractTxClient extends ITxClient {
14
14
  constructor(wallet: FirmaWalletService, serverUrl: string);
15
- msgAddContractLog(data: MsgAddContractLog): MsgAddContractLogEncodeObject;
16
- msgCreateContractFile(data: MsgCreateContractFile): MsgCreateContractFileEncodeObject;
15
+ static getRegistry(): Registry;
16
+ static msgAddContractLog(data: MsgAddContractLog): MsgAddContractLogEncodeObject;
17
+ static msgCreateContractFile(data: MsgCreateContractFile): MsgCreateContractFileEncodeObject;
17
18
  }
@@ -29,10 +29,13 @@ var ContractTxClient = /** @class */ (function (_super) {
29
29
  function ContractTxClient(wallet, serverUrl) {
30
30
  return _super.call(this, wallet, serverUrl, registry) || this;
31
31
  }
32
- ContractTxClient.prototype.msgAddContractLog = function (data) {
32
+ ContractTxClient.getRegistry = function () {
33
+ return registry;
34
+ };
35
+ ContractTxClient.msgAddContractLog = function (data) {
33
36
  return { typeUrl: "/firmachain.firmachain.contract.MsgAddContractLog", value: data };
34
37
  };
35
- ContractTxClient.prototype.msgCreateContractFile = function (data) {
38
+ ContractTxClient.msgCreateContractFile = function (data) {
36
39
  return { typeUrl: "/firmachain.firmachain.contract.MsgCreateContractFile", value: data };
37
40
  };
38
41
  return ContractTxClient;
@@ -22,28 +22,28 @@ export interface MsgAddContractLogResponse {
22
22
  }
23
23
  export declare const MsgCreateContractFile: {
24
24
  encode(message: MsgCreateContractFile, writer?: Writer): Writer;
25
- decode(input: Reader | Uint8Array, length?: number | undefined): MsgCreateContractFile;
25
+ decode(input: Reader | Uint8Array, length?: number): MsgCreateContractFile;
26
26
  fromJSON(object: any): MsgCreateContractFile;
27
27
  toJSON(message: MsgCreateContractFile): unknown;
28
28
  fromPartial(object: DeepPartial<MsgCreateContractFile>): MsgCreateContractFile;
29
29
  };
30
30
  export declare const MsgCreateContractFileResponse: {
31
31
  encode(_: MsgCreateContractFileResponse, writer?: Writer): Writer;
32
- decode(input: Reader | Uint8Array, length?: number | undefined): MsgCreateContractFileResponse;
32
+ decode(input: Reader | Uint8Array, length?: number): MsgCreateContractFileResponse;
33
33
  fromJSON(_: any): MsgCreateContractFileResponse;
34
34
  toJSON(_: MsgCreateContractFileResponse): unknown;
35
35
  fromPartial(_: DeepPartial<MsgCreateContractFileResponse>): MsgCreateContractFileResponse;
36
36
  };
37
37
  export declare const MsgAddContractLog: {
38
38
  encode(message: MsgAddContractLog, writer?: Writer): Writer;
39
- decode(input: Reader | Uint8Array, length?: number | undefined): MsgAddContractLog;
39
+ decode(input: Reader | Uint8Array, length?: number): MsgAddContractLog;
40
40
  fromJSON(object: any): MsgAddContractLog;
41
41
  toJSON(message: MsgAddContractLog): unknown;
42
42
  fromPartial(object: DeepPartial<MsgAddContractLog>): MsgAddContractLog;
43
43
  };
44
44
  export declare const MsgAddContractLogResponse: {
45
45
  encode(message: MsgAddContractLogResponse, writer?: Writer): Writer;
46
- decode(input: Reader | Uint8Array, length?: number | undefined): MsgAddContractLogResponse;
46
+ decode(input: Reader | Uint8Array, length?: number): MsgAddContractLogResponse;
47
47
  fromJSON(object: any): MsgAddContractLogResponse;
48
48
  toJSON(message: MsgAddContractLogResponse): unknown;
49
49
  fromPartial(object: DeepPartial<MsgAddContractLogResponse>): MsgAddContractLogResponse;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];
@@ -72,7 +72,7 @@ var CosmWasmQueryClient = /** @class */ (function () {
72
72
  return __generator(this, function (_a) {
73
73
  switch (_a.label) {
74
74
  case 0:
75
- path = "/cosmwasm/wasm/v1/code/" + codeId;
75
+ path = "/cosmwasm/wasm/v1/code/".concat(codeId);
76
76
  return [4 /*yield*/, this.axios.get(path)];
77
77
  case 1:
78
78
  result = _a.sent();
@@ -87,7 +87,7 @@ var CosmWasmQueryClient = /** @class */ (function () {
87
87
  return __generator(this, function (_a) {
88
88
  switch (_a.label) {
89
89
  case 0:
90
- path = "/cosmwasm/wasm/v1/code/" + codeId + "/contracts";
90
+ path = "/cosmwasm/wasm/v1/code/".concat(codeId, "/contracts");
91
91
  return [4 /*yield*/, this.axios.get(path)];
92
92
  case 1:
93
93
  result = _a.sent();
@@ -102,7 +102,7 @@ var CosmWasmQueryClient = /** @class */ (function () {
102
102
  return __generator(this, function (_a) {
103
103
  switch (_a.label) {
104
104
  case 0:
105
- path = "/cosmwasm/wasm/v1/contract/" + contractAddress;
105
+ path = "/cosmwasm/wasm/v1/contract/".concat(contractAddress);
106
106
  return [4 /*yield*/, this.axios.get(path)];
107
107
  case 1:
108
108
  result = _a.sent();
@@ -117,7 +117,7 @@ var CosmWasmQueryClient = /** @class */ (function () {
117
117
  return __generator(this, function (_a) {
118
118
  switch (_a.label) {
119
119
  case 0:
120
- path = "/cosmwasm/wasm/v1/contract/" + contractAddress + "/history";
120
+ path = "/cosmwasm/wasm/v1/contract/".concat(contractAddress, "/history");
121
121
  return [4 /*yield*/, this.axios.get(path)];
122
122
  case 1:
123
123
  result = _a.sent();
@@ -133,7 +133,7 @@ var CosmWasmQueryClient = /** @class */ (function () {
133
133
  switch (_a.label) {
134
134
  case 0:
135
135
  hexStringBase64 = Buffer.from(hexString, 'hex').toString('base64');
136
- path = "/cosmwasm/wasm/v1/contract/" + contractAddress + "/raw/" + hexStringBase64;
136
+ path = "/cosmwasm/wasm/v1/contract/".concat(contractAddress, "/raw/").concat(hexStringBase64);
137
137
  return [4 /*yield*/, this.axios.get(path)];
138
138
  case 1:
139
139
  result = _a.sent();
@@ -149,7 +149,7 @@ var CosmWasmQueryClient = /** @class */ (function () {
149
149
  switch (_a.label) {
150
150
  case 0:
151
151
  queryBase64 = Buffer.from(query, 'binary').toString('base64');
152
- path = "/cosmwasm/wasm/v1/contract/" + contractAddress + "/smart/" + queryBase64;
152
+ path = "/cosmwasm/wasm/v1/contract/".concat(contractAddress, "/smart/").concat(queryBase64);
153
153
  return [4 /*yield*/, this.axios.get(path)];
154
154
  case 1:
155
155
  result = _a.sent();
@@ -164,7 +164,7 @@ var CosmWasmQueryClient = /** @class */ (function () {
164
164
  return __generator(this, function (_a) {
165
165
  switch (_a.label) {
166
166
  case 0:
167
- path = "/cosmwasm/wasm/v1/contract/" + contractAddress + "/state";
167
+ path = "/cosmwasm/wasm/v1/contract/".concat(contractAddress, "/state");
168
168
  return [4 /*yield*/, this.axios.get(path)];
169
169
  case 1:
170
170
  result = _a.sent();
@@ -1,4 +1,4 @@
1
- import { EncodeObject } from "@cosmjs/proto-signing";
1
+ import { Registry, EncodeObject } from "@cosmjs/proto-signing";
2
2
  import { ITxClient } from "../common/ITxClient";
3
3
  import { FirmaWalletService } from "../../FirmaWalletService";
4
4
  import { MsgClearAdmin, MsgExecuteContract, MsgMigrateContract, MsgStoreCode, MsgInstantiateContract, MsgUpdateAdmin } from "cosmjs-types/cosmwasm/wasm/v1/tx";
@@ -28,10 +28,11 @@ export interface MsgExecuteContractEncodeObject extends EncodeObject {
28
28
  }
29
29
  export declare class CosmWasmTxClient extends ITxClient {
30
30
  constructor(wallet: FirmaWalletService, serverUrl: string);
31
- msgStoreCode(data: MsgStoreCode): MsgStoreCodeEncodeObject;
32
- msgInstantiateContract(data: MsgInstantiateContract): MsgInstantiateContractEncodeObject;
33
- msgExecuteContract(data: MsgExecuteContract): MsgExecuteContractEncodeObject;
34
- msgUpdateAdmin(data: MsgUpdateAdmin): MsgUpdateAdminEncodeObject;
35
- msgClearAdmin(data: MsgClearAdmin): MsgClearAdminEncodeObject;
36
- msgMigrateContract(data: MsgMigrateContract): MsgMigrateContractEncodeObject;
31
+ static getRegistry(): Registry;
32
+ static msgStoreCode(data: MsgStoreCode): MsgStoreCodeEncodeObject;
33
+ static msgInstantiateContract(data: MsgInstantiateContract): MsgInstantiateContractEncodeObject;
34
+ static msgExecuteContract(data: MsgExecuteContract): MsgExecuteContractEncodeObject;
35
+ static msgUpdateAdmin(data: MsgUpdateAdmin): MsgUpdateAdminEncodeObject;
36
+ static msgClearAdmin(data: MsgClearAdmin): MsgClearAdminEncodeObject;
37
+ static msgMigrateContract(data: MsgMigrateContract): MsgMigrateContractEncodeObject;
37
38
  }
@@ -33,22 +33,25 @@ var CosmWasmTxClient = /** @class */ (function (_super) {
33
33
  function CosmWasmTxClient(wallet, serverUrl) {
34
34
  return _super.call(this, wallet, serverUrl, registry) || this;
35
35
  }
36
- CosmWasmTxClient.prototype.msgStoreCode = function (data) {
36
+ CosmWasmTxClient.getRegistry = function () {
37
+ return registry;
38
+ };
39
+ CosmWasmTxClient.msgStoreCode = function (data) {
37
40
  return { typeUrl: "/cosmwasm.wasm.v1.MsgStoreCode", value: data };
38
41
  };
39
- CosmWasmTxClient.prototype.msgInstantiateContract = function (data) {
42
+ CosmWasmTxClient.msgInstantiateContract = function (data) {
40
43
  return { typeUrl: "/cosmwasm.wasm.v1.MsgInstantiateContract", value: data };
41
44
  };
42
- CosmWasmTxClient.prototype.msgExecuteContract = function (data) {
45
+ CosmWasmTxClient.msgExecuteContract = function (data) {
43
46
  return { typeUrl: "/cosmwasm.wasm.v1.MsgExecuteContract", value: data };
44
47
  };
45
- CosmWasmTxClient.prototype.msgUpdateAdmin = function (data) {
48
+ CosmWasmTxClient.msgUpdateAdmin = function (data) {
46
49
  return { typeUrl: "/cosmwasm.wasm.v1.MsgUpdateAdmin", value: data };
47
50
  };
48
- CosmWasmTxClient.prototype.msgClearAdmin = function (data) {
51
+ CosmWasmTxClient.msgClearAdmin = function (data) {
49
52
  return { typeUrl: "/cosmwasm.wasm.v1.MsgClearAdmin", value: data };
50
53
  };
51
- CosmWasmTxClient.prototype.msgMigrateContract = function (data) {
54
+ CosmWasmTxClient.msgMigrateContract = function (data) {
52
55
  return { typeUrl: "/cosmwasm.wasm.v1.MsgMigrateContract", value: data };
53
56
  };
54
57
  return CosmWasmTxClient;
@@ -1,7 +1,11 @@
1
1
  "use strict";
2
2
  var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
3
  if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
5
9
  }) : (function(o, m, k, k2) {
6
10
  if (k2 === undefined) k2 = k;
7
11
  o[k2] = m[k];