Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fix transport check
  • Loading branch information
jiexi committed Nov 21, 2025
commit b55e9376d97fb85a4b67a7f407ca7ee122c24004
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@ export class MultichainApiClientWrapperTransport implements Transport {
constructor(private multichainSDK: MultichainSDK) {
}

isTransportDefined(): boolean {
try {
return Boolean(this.multichainSDK.transport)
} catch (error) {
return false;
}
}

clearNotificationCallbacks() {
this.notificationCallbacks.clear();
}
Expand Down Expand Up @@ -74,7 +82,7 @@ export class MultichainApiClientWrapperTransport implements Transport {
}

onNotification(callback: (data: unknown) => void) {
if (!this.multichainSDK.transport) {
if (!this.isTransportDefined()) {
this.notificationCallbacks.add(callback);
return () => {
this.notificationCallbacks.delete(callback);
Expand Down Expand Up @@ -108,7 +116,7 @@ export class MultichainApiClientWrapperTransport implements Transport {
}

async #walletGetSession(request: TransportRequestWithId) {
if (!this.multichainSDK.transport) {
if (!this.isTransportDefined()) {
return {
jsonrpc: '2.0',
id: request.id,
Expand All @@ -121,7 +129,7 @@ export class MultichainApiClientWrapperTransport implements Transport {
}

async #walletRevokeSession(request: TransportRequestWithId) {
if (!this.multichainSDK.transport) {
if (!this.isTransportDefined()) {
return { jsonrpc: '2.0', id: request.id, result: true };
}

Expand All @@ -134,7 +142,7 @@ export class MultichainApiClientWrapperTransport implements Transport {
}

async #walletInvokeMethod(request: TransportRequestWithId) {
if (!this.multichainSDK.transport) {
if (!this.isTransportDefined()) {
return { error: providerErrors.unauthorized() }
}
return this.multichainSDK.invokeMethod(request.params as InvokeMethodOptions)
Expand Down