carbon-js-sdk 0.5.3 → 0.5.4

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.
@@ -354,13 +354,14 @@ class CarbonWallet {
354
354
  sendInitialMergeAccountTx(msgs, opts) {
355
355
  return __awaiter(this, void 0, void 0, function* () {
356
356
  let msg;
357
- try {
358
- yield this.reloadMergeAccountStatus();
359
- if (!this.accountMerged && msgs[0].typeUrl !== util_1.CarbonTx.Types.MsgMergeAccount) {
360
- const account = yield this.getQueryClient().auth.Account({ address: this.bech32Address }).then(res => res.account).catch((err) => __awaiter(this, void 0, void 0, function* () {
361
- return (yield this.getQueryClient().auth.Account({ address: this.evmBech32Address })).account;
362
- }));
363
- const { address, sequence, accountNumber } = auth_1.BaseAccount.decode(account.value);
357
+ yield this.reloadMergeAccountStatus();
358
+ if (!this.accountMerged && msgs[0].typeUrl !== util_1.CarbonTx.Types.MsgMergeAccount) {
359
+ const accountInfo = yield this.reloadAccountInfo();
360
+ if (!accountInfo) {
361
+ throw new Error('Account not found!');
362
+ }
363
+ const { address, sequence, accountNumber } = accountInfo;
364
+ try {
364
365
  msg = {
365
366
  typeUrl: util_1.CarbonTx.Types.MsgMergeAccount,
366
367
  value: codec_1.MsgMergeAccount.fromPartial({
@@ -368,15 +369,16 @@ class CarbonWallet {
368
369
  pubKey: this.publicKey.toString('hex')
369
370
  })
370
371
  };
371
- const modifiedOpts = Object.assign(Object.assign({}, opts), { sequence: sequence.toNumber(), accountNumber: accountNumber.toNumber() });
372
+ const modifiedOpts = Object.assign(Object.assign({}, opts), { sequence,
373
+ accountNumber });
372
374
  yield this.signAndBroadcast([msg], modifiedOpts, { mode: tx_1.BroadcastTxMode.BroadcastTxBlock });
373
375
  this.updateMergeAccountStatus();
374
376
  yield util_1.GenericUtils.callIgnoreError(() => { var _a; return (_a = this.onBroadcastTxSuccess) === null || _a === void 0 ? void 0 : _a.call(this, [msg]); });
375
377
  }
376
- }
377
- catch (error) {
378
- yield util_1.GenericUtils.callIgnoreError(() => { var _a; return (_a = this.onBroadcastTxFail) === null || _a === void 0 ? void 0 : _a.call(this, [msg]); });
379
- throw error;
378
+ catch (error) {
379
+ yield util_1.GenericUtils.callIgnoreError(() => { var _a; return (_a = this.onBroadcastTxFail) === null || _a === void 0 ? void 0 : _a.call(this, [msg]); });
380
+ throw error;
381
+ }
380
382
  }
381
383
  });
382
384
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.5.3",
3
+ "version": "0.5.4",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",