carbon-js-sdk 0.10.3 → 0.10.5

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.
@@ -189,6 +189,7 @@ export declare class CarbonWallet {
189
189
  getSmartWalletPrivateKey(blockchain?: SmartWalletBlockchain): Buffer | null;
190
190
  reconnectTmClient(fallbackConfig: OverrideConfig | null): Promise<void>;
191
191
  private reloadAccountInfo;
192
+ private delay;
192
193
  private getAccount;
193
194
  reloadAccountSequence(): Promise<void>;
194
195
  reloadMergeAccountStatus(): Promise<void>;
@@ -244,7 +244,7 @@ class CarbonWallet {
244
244
  const isEvmWallet = this.isEvmWallet();
245
245
  if (hasEvmAddressBalances && !hasCarbonBalances && !isEvmWallet) {
246
246
  this.sequenceInvalidated = true;
247
- throw new Error('Transaction is not allowed from a non-evm wallet for an account with only funds in evm address');
247
+ throw new Error(`Transaction is not allowed from a non-evm wallet for an account with only funds in evm address: evmAddress: ${this.evmBech32Address}, carbonAddress: ${this.bech32Address}`);
248
248
  }
249
249
  });
250
250
  }
@@ -646,24 +646,34 @@ class CarbonWallet {
646
646
  return (_a = bech32Acc !== null && bech32Acc !== void 0 ? bech32Acc : evmBech32Acc) !== null && _a !== void 0 ? _a : undefined;
647
647
  });
648
648
  }
649
- getAccount(queryAddress) {
649
+ delay(ms) {
650
+ return new Promise(resolve => setTimeout(resolve, ms));
651
+ }
652
+ getAccount(queryAddress, retryCount = 0) {
650
653
  return __awaiter(this, void 0, void 0, function* () {
651
654
  try {
652
- const account = (yield this.getQueryClient().auth.Account({ address: queryAddress })).account;
653
- if (!account)
654
- return;
655
- const { accountNumber, sequence, address } = auth_1.BaseAccount.decode(account.value);
656
- return {
657
- address,
658
- accountNumber: accountNumber.toNumber(),
659
- sequence: sequence.toNumber(),
660
- };
655
+ const result = yield this.getQueryClient().auth.Account({ address: queryAddress });
656
+ if (result === null || result === void 0 ? void 0 : result.account) {
657
+ const { accountNumber, sequence, address } = auth_1.BaseAccount.decode(result.account.value);
658
+ return {
659
+ address,
660
+ pubkey: null,
661
+ accountNumber: accountNumber.toNumber(),
662
+ sequence: sequence.toNumber(),
663
+ };
664
+ }
661
665
  }
662
666
  catch (error) {
663
667
  if (!this.isAccountNotFoundError(error, queryAddress))
664
668
  throw error;
665
669
  }
666
- return;
670
+ // when grant is just created, querying grantee account info immediately may fail maybe due to backend caching
671
+ // retry query after 1s to buffer for backend to catch up
672
+ if (retryCount < 1) {
673
+ yield this.delay(1000);
674
+ return this.getAccount(queryAddress, retryCount + 1);
675
+ }
676
+ return undefined;
667
677
  });
668
678
  }
669
679
  reloadAccountSequence() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "carbon-js-sdk",
3
- "version": "0.10.3",
3
+ "version": "0.10.5",
4
4
  "description": "TypeScript SDK for Carbon blockchain",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",