Skip to content

Commit

Permalink
Adding ETH fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
y3fers0n committed Jun 11, 2024
1 parent 5b54668 commit ccfacb5
Showing 1 changed file with 18 additions and 6 deletions.
24 changes: 18 additions & 6 deletions packages/ethereum/EthereumProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,14 +146,20 @@ export class EthereumProvider
typeof methodOrPayload === 'string' &&
(!callbackOrArgs || Array.isArray(callbackOrArgs))
) {
const context = this;

return new Promise((resolve, reject) => {
try {
this.request({
const req = context.request({
method: methodOrPayload,
params: callbackOrArgs as unknown[],
})
.then(resolve)
.catch(reject);
});

if (req instanceof Promise) {
req.then(resolve).catch(reject);
} else {
resolve(req);
}
} catch (error) {
reject(error);
}
Expand Down Expand Up @@ -191,9 +197,15 @@ export class EthereumProvider
};

if (this.mobileAdapter) {
return this.handleStaticRequests(args, () =>
const req = this.handleStaticRequests(args, () =>
this.mobileAdapter.request(args),
) as Promise<T>;
);

if (req instanceof Promise) {
return req;
} else {
return Promise.resolve(req) as Promise<T>;
}
}

return this.handleStaticRequests(args, next) as Promise<T>;
Expand Down

0 comments on commit ccfacb5

Please sign in to comment.