Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: Provider is incompatible with ethers v4 #171

Merged
merged 2 commits into from
May 21, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions packages/safe-apps-provider/dist/provider.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,5 @@ export declare class SafeAppProvider implements EIP1193Provider {
method: string;
params?: any[];
}): Promise<any>;
send(request: any, callback: (error: any, response?: any) => void): void;
}
7 changes: 7 additions & 0 deletions packages/safe-apps-provider/dist/provider.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/safe-apps-provider/dist/provider.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions packages/safe-apps-provider/src/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,4 +156,13 @@ export class SafeAppProvider implements EIP1193Provider {
throw Error(`"${request.method}" not implemented`);
}
}

// this method is needed for ethers v4
// https://github.com/ethers-io/ethers.js/blob/427e16826eb15d52d25c4f01027f8db22b74b76c/src.ts/providers/web3-provider.ts#L41-L55
send(request: any, callback: (error: any, response?: any) => void): void {
if (!request) callback('Undefined request');
this.request(request)
.then((result) => callback(null, { jsonrpc: '2.0', id: request.id, result }))
.catch((error) => callback(error, null));
}
}