@hashgraphonline/hashinal-wc 1.0.94 → 1.0.96
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
|
-
|
|
4883
|
+
return this.signClient.request({
|
|
4884
4884
|
topic: this.topic,
|
|
4885
4885
|
request,
|
|
4886
|
-
chainId: ledgerIdToCAIPChainId(this.ledgerId)
|
|
4887
|
-
|
|
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
|
|
5295
|
+
const hasSigner = this.signers.some((signer) => signer.topic === topic);
|
|
5303
5296
|
if (!session) {
|
|
5304
|
-
if (
|
|
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 (!
|
|
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);
|
|
@@ -5962,7 +5947,13 @@ class HashinalsWalletConnectSDK {
|
|
|
5962
5947
|
const cachedSigner = this.dAppConnector.signers.find(
|
|
5963
5948
|
(signer_) => signer_.getAccountId().toString() === cachedAccountId
|
|
5964
5949
|
);
|
|
5950
|
+
if (!cachedSigner) {
|
|
5951
|
+
return null;
|
|
5952
|
+
}
|
|
5965
5953
|
const accountId = (_b = cachedSigner == null ? void 0 : cachedSigner.getAccountId()) == null ? void 0 : _b.toString();
|
|
5954
|
+
if (!accountId) {
|
|
5955
|
+
return null;
|
|
5956
|
+
}
|
|
5966
5957
|
const network = cachedSigner.getLedgerId();
|
|
5967
5958
|
return {
|
|
5968
5959
|
accountId,
|
|
@@ -6122,7 +6113,12 @@ class HashinalsWalletConnectSDK {
|
|
|
6122
6113
|
try {
|
|
6123
6114
|
const defaultNetwork = savedNetwork === "mainnet" ? LedgerId.MAINNET : LedgerId.TESTNET;
|
|
6124
6115
|
const network = networkOverride || defaultNetwork;
|
|
6125
|
-
await this.init(
|
|
6116
|
+
await this.init(
|
|
6117
|
+
PROJECT_ID,
|
|
6118
|
+
APP_METADATA,
|
|
6119
|
+
network,
|
|
6120
|
+
onSessionIframeCreated
|
|
6121
|
+
);
|
|
6126
6122
|
const balance = await this.getAccountBalance();
|
|
6127
6123
|
return {
|
|
6128
6124
|
accountId: savedAccountId,
|
|
@@ -6135,8 +6131,16 @@ class HashinalsWalletConnectSDK {
|
|
|
6135
6131
|
}
|
|
6136
6132
|
} else if (networkOverride) {
|
|
6137
6133
|
try {
|
|
6138
|
-
this.logger.info(
|
|
6139
|
-
|
|
6134
|
+
this.logger.info(
|
|
6135
|
+
"initializing normally through override.",
|
|
6136
|
+
networkOverride
|
|
6137
|
+
);
|
|
6138
|
+
await this.init(
|
|
6139
|
+
PROJECT_ID,
|
|
6140
|
+
APP_METADATA,
|
|
6141
|
+
networkOverride,
|
|
6142
|
+
onSessionIframeCreated
|
|
6143
|
+
);
|
|
6140
6144
|
this.logger.info("initialized", networkOverride);
|
|
6141
6145
|
await this.connectViaDappBrowser();
|
|
6142
6146
|
this.logger.info("connected via dapp browser");
|
|
@@ -6156,7 +6160,9 @@ class HashinalsWalletConnectSDK {
|
|
|
6156
6160
|
this.extensionCheckInterval = setInterval(() => {
|
|
6157
6161
|
var _a;
|
|
6158
6162
|
const extensions = ((_a = this.dAppConnector) == null ? void 0 : _a.extensions) || [];
|
|
6159
|
-
const availableExtension = extensions.find(
|
|
6163
|
+
const availableExtension = extensions.find(
|
|
6164
|
+
(ext) => ext.availableInIframe
|
|
6165
|
+
);
|
|
6160
6166
|
if (availableExtension && !this.hasCalledExtensionCallback) {
|
|
6161
6167
|
this.hasCalledExtensionCallback = true;
|
|
6162
6168
|
callback(availableExtension);
|