@hashgraphonline/hashinal-wc 1.0.94 → 1.0.95

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.
@@ -4880,15 +4880,11 @@ class DAppSigner {
4880
4880
  }
4881
4881
  if (this.extensionId)
4882
4882
  extensionOpen(this.extensionId);
4883
- const dAppRequest = {
4883
+ return this.signClient.request({
4884
4884
  topic: this.topic,
4885
4885
  request,
4886
- chainId: ledgerIdToCAIPChainId(this.ledgerId),
4887
- // hardcode expiry to 5 minutes
4888
- expiry: 300
4889
- };
4890
- this.logger.debug("Sending request to wallet", dAppRequest);
4891
- return this.signClient.request(dAppRequest);
4886
+ chainId: ledgerIdToCAIPChainId(this.ledgerId)
4887
+ });
4892
4888
  }
4893
4889
  getAccountId() {
4894
4890
  return this.accountId;
@@ -5181,9 +5177,6 @@ class DAppConnector {
5181
5177
  this.signers = existingSessions.flatMap((session) => this.createSigners(session));
5182
5178
  else
5183
5179
  this.checkIframeConnect();
5184
- setInterval(() => {
5185
- this.validateAndRefreshSigners();
5186
- }, 1e4);
5187
5180
  this.walletConnectClient.on("session_event", this.handleSessionEvent.bind(this));
5188
5181
  this.walletConnectClient.on("session_update", this.handleSessionUpdate.bind(this));
5189
5182
  this.walletConnectClient.on("session_delete", this.handleSessionDelete.bind(this));
@@ -5299,26 +5292,18 @@ class DAppConnector {
5299
5292
  return false;
5300
5293
  }
5301
5294
  const session = this.walletConnectClient.session.get(topic);
5302
- const signer = this.signers.find((signer2) => signer2.topic === topic);
5295
+ const hasSigner = this.signers.some((signer) => signer.topic === topic);
5303
5296
  if (!session) {
5304
- if (Boolean(signer)) {
5297
+ if (hasSigner) {
5305
5298
  this.logger.warn(`Signer exists but no session found for topic: ${topic}`);
5306
5299
  this.handleSessionDelete({ topic });
5307
5300
  }
5308
5301
  return false;
5309
5302
  }
5310
- if (!Boolean(signer)) {
5303
+ if (!hasSigner) {
5311
5304
  this.logger.warn(`Session exists but no signer found for topic: ${topic}`);
5312
5305
  return false;
5313
5306
  }
5314
- this.logger.info(`Session validated for topic: ${topic} - will extend expiry`);
5315
- this.walletConnectClient.extend({
5316
- topic
5317
- }).then(() => {
5318
- this.logger.info(`Session extended for topic: ${topic}`);
5319
- }).catch((e) => {
5320
- this.logger.error("Error extending session:", e);
5321
- });
5322
5307
  return true;
5323
5308
  } catch (e) {
5324
5309
  this.logger.error("Error validating session:", e);
@@ -5963,6 +5948,9 @@ class HashinalsWalletConnectSDK {
5963
5948
  (signer_) => signer_.getAccountId().toString() === cachedAccountId
5964
5949
  );
5965
5950
  const accountId = (_b = cachedSigner == null ? void 0 : cachedSigner.getAccountId()) == null ? void 0 : _b.toString();
5951
+ if (!accountId) {
5952
+ return null;
5953
+ }
5966
5954
  const network = cachedSigner.getLedgerId();
5967
5955
  return {
5968
5956
  accountId,
@@ -6122,7 +6110,12 @@ class HashinalsWalletConnectSDK {
6122
6110
  try {
6123
6111
  const defaultNetwork = savedNetwork === "mainnet" ? LedgerId.MAINNET : LedgerId.TESTNET;
6124
6112
  const network = networkOverride || defaultNetwork;
6125
- await this.init(PROJECT_ID, APP_METADATA, network, onSessionIframeCreated);
6113
+ await this.init(
6114
+ PROJECT_ID,
6115
+ APP_METADATA,
6116
+ network,
6117
+ onSessionIframeCreated
6118
+ );
6126
6119
  const balance = await this.getAccountBalance();
6127
6120
  return {
6128
6121
  accountId: savedAccountId,
@@ -6135,8 +6128,16 @@ class HashinalsWalletConnectSDK {
6135
6128
  }
6136
6129
  } else if (networkOverride) {
6137
6130
  try {
6138
- this.logger.info("initializing normally through override.", networkOverride);
6139
- await this.init(PROJECT_ID, APP_METADATA, networkOverride, onSessionIframeCreated);
6131
+ this.logger.info(
6132
+ "initializing normally through override.",
6133
+ networkOverride
6134
+ );
6135
+ await this.init(
6136
+ PROJECT_ID,
6137
+ APP_METADATA,
6138
+ networkOverride,
6139
+ onSessionIframeCreated
6140
+ );
6140
6141
  this.logger.info("initialized", networkOverride);
6141
6142
  await this.connectViaDappBrowser();
6142
6143
  this.logger.info("connected via dapp browser");
@@ -6156,7 +6157,9 @@ class HashinalsWalletConnectSDK {
6156
6157
  this.extensionCheckInterval = setInterval(() => {
6157
6158
  var _a;
6158
6159
  const extensions = ((_a = this.dAppConnector) == null ? void 0 : _a.extensions) || [];
6159
- const availableExtension = extensions.find((ext) => ext.availableInIframe);
6160
+ const availableExtension = extensions.find(
6161
+ (ext) => ext.availableInIframe
6162
+ );
6160
6163
  if (availableExtension && !this.hasCalledExtensionCallback) {
6161
6164
  this.hasCalledExtensionCallback = true;
6162
6165
  callback(availableExtension);