Skip to content

Commit

Permalink
Add back support for eth namespace
Browse files Browse the repository at this point in the history
  • Loading branch information
jdowning100 committed Jan 8, 2024
1 parent e779b56 commit f289fb1
Show file tree
Hide file tree
Showing 7 changed files with 62 additions and 2 deletions.
2 changes: 1 addition & 1 deletion background/services/chain/serial-fallback-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ export default class SerialFallbackProvider extends QuaisJsonRpcProvider {
override async send(method: string, params: unknown[]): Promise<unknown> {
// Since we can reliably return the chainId with absolutely no communication with
// the provider - we can return it without needing to worry about routing rpc calls
if (method === "quai_chainId") {
if (method === "quai_chainId" || method === "eth_chainId") {
return this.cachedChainId
}

Expand Down
43 changes: 43 additions & 0 deletions background/services/internal-ethereum-provider/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,10 @@ export default class InternalEthereumProviderService extends BaseService<Events>
case "quai_signTypedData_v1":
case "quai_signTypedData_v3":
case "quai_signTypedData_v4":
case "eth_signTypedData":
case "eth_signTypedData_v1":
case "eth_signTypedData_v3":
case "eth_signTypedData_v4":
return this.signTypedData({
account: {
address: params[0] as string,
Expand Down Expand Up @@ -239,6 +243,42 @@ export default class InternalEthereumProviderService extends BaseService<Events>
case "net_version":
case "web3_clientVersion":
case "web3_sha3":
case "eth_blockNumber":
case "eth_call":
case "eth_estimateGas":
case "eth_feeHistory":
case "eth_gasPrice":
case "eth_getBalance":
case "eth_getBlockByHash":
case "eth_getBlockByNumber":
case "eth_getBlockTransactionCountByHash":
case "eth_getBlockTransactionCountByNumber":
case "eth_getCode":
case "eth_getFilterChanges":
case "eth_getFilterLogs":
case "eth_getLogs":
case "eth_getProof":
case "eth_getStorageAt":
case "eth_getTransactionByBlockHashAndIndex":
case "eth_getTransactionByBlockNumberAndIndex":
case "eth_getTransactionByHash":
case "eth_getTransactionCount":
case "eth_getTransactionReceipt":
case "eth_getUncleByBlockHashAndIndex":
case "eth_getUncleByBlockNumberAndIndex":
case "eth_getUncleCountByBlockHash":
case "eth_getUncleCountByBlockNumber":
case "eth_maxPriorityFeePerGas":
case "eth_newBlockFilter":
case "eth_newFilter":
case "eth_newPendingTransactionFilter":
case "eth_nodeLocation":
case "eth_protocolVersion":
case "eth_sendRawTransaction":
case "eth_subscribe":
case "eth_syncing":
case "eth_uninstallFilter":
case "eth_unsubscribe":
return this.chainService.send(
method,
params,
Expand All @@ -250,6 +290,7 @@ export default class InternalEthereumProviderService extends BaseService<Events>
const { address } = await this.preferenceService.getSelectedAccount()
return [address]
}
case "eth_sendTransaction":
case "quai_sendTransaction":
return this.signTransaction(
{
Expand All @@ -260,6 +301,7 @@ export default class InternalEthereumProviderService extends BaseService<Events>
await this.chainService.broadcastSignedTransaction(signed)
return signed.hash
})
case "eth_signTransaction":
case "quai_signTransaction":
return this.signTransaction(
params[0] as JsonRpcTransactionRequest,
Expand All @@ -274,6 +316,7 @@ export default class InternalEthereumProviderService extends BaseService<Events>
}
)
)
case "eth_sign":
case "quai_sign": // --- important wallet methods ---
return this.signData(
{
Expand Down
7 changes: 7 additions & 0 deletions background/services/provider-bridge/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,10 @@ export default class ProviderBridgeService extends BaseService<Events> {
case "quai_signTypedData_v1":
case "quai_signTypedData_v3":
case "quai_signTypedData_v4":
case "eth_signTypedData":
case "eth_signTypedData_v1":
case "eth_signTypedData_v3":
case "eth_signTypedData_v4":
checkPermissionSignTypedData(
params[0] as HexString,
enablingPermission
Expand All @@ -483,6 +487,7 @@ export default class ProviderBridgeService extends BaseService<Events> {
origin,
showExtensionPopup(AllowedQueryParamPage.signData)
)
case "eth_sign":
case "quai_sign":
checkPermissionSign(params[0] as HexString, enablingPermission)

Expand All @@ -501,6 +506,8 @@ export default class ProviderBridgeService extends BaseService<Events> {
origin,
showExtensionPopup(AllowedQueryParamPage.personalSignData)
)
case "eth_signTransaction":
case "eth_sendTransaction":
case "quai_signTransaction":
case "quai_sendTransaction":
checkPermissionSignTransaction(
Expand Down
1 change: 1 addition & 0 deletions background/services/provider-bridge/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ export function parseRPCRequestParams(
params: RPCRequest["params"]
): RPCRequest["params"] {
switch (method) {
case "eth_sign":
case "quai_sign":
return sameEVMAddress(
params[0] as HexString,
Expand Down
6 changes: 6 additions & 0 deletions background/services/wallet-connect/eip155-request-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ export function approveEIP155Request(
case "personal_sign":
case "quai_signTransaction":
case "quai_sendTransaction":
case "eth_sign":
case "eth_sendTransaction":
case "eth_signTransaction":
return formatJsonRpcResult(id, signedMessage)

default:
Expand Down Expand Up @@ -72,6 +75,9 @@ export function processRequestParams(
case "personal_sign":
case "quai_sendTransaction":
case "quai_signTransaction":
case "eth_sign":
case "eth_sendTransaction":
case "eth_signTransaction":
return {
id,
topic,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ export function processLegacyRequestParams(
case "personal_sign":
case "quai_sendTransaction":
case "quai_signTransaction":
case "eth_signTypedData":
case "eth_sendTransaction":
case "eth_signTransaction":
return payload
default:
return undefined
Expand Down
2 changes: 1 addition & 1 deletion manifest/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
],
"content_scripts": [
{
"matches": ["file://*/*", "http://localhost/*", "https://*/*"],
"matches": ["file://*/*", "http://localhost/*", "http://127.0.0.1/*", "http://0.0.0.0/*", "https://*/*"],
"js": ["provider-bridge.js"],
"run_at": "document_start",
"all_frames": true
Expand Down

0 comments on commit f289fb1

Please sign in to comment.