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

Gateway: hardcode response to clientVersion request #1937

Merged
merged 2 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
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
11 changes: 11 additions & 0 deletions integration/networktest/tests/gateway/gateway_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,17 @@ func TestGatewayHappyPath(t *testing.T) {
return fmt.Errorf("expected net_version to be %s but got %s", expectedResult, result)
}

// check web3_clientVersion response
var cvResult string
err = rpcClient.CallContext(ctx, &cvResult, "web3_clientVersion")
if err != nil {
return fmt.Errorf("failed to get web3_clientVersion: %w", err)
}
fmt.Println("web3_clientVersion response:", cvResult)
if cvResult == "" {
return fmt.Errorf("expected web3_clientVersion to be non-empty")
}

return nil
}),
),
Expand Down
20 changes: 20 additions & 0 deletions tools/walletextension/rpcapi/web3_api.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package rpcapi

import (
"context"
)

var _hardcodedClientVersion = "Geth/v10.0.0/drpc"

type Web3API struct {
we *Services
}

func NewWeb3API(we *Services) *Web3API {
return &Web3API{we}
}

func (api *Web3API) ClientVersion(_ context.Context) (*string, error) {
// todo: have this return the Ten version from the node
return &_hardcodedClientVersion, nil
}
3 changes: 3 additions & 0 deletions tools/walletextension/walletextension_container.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@ func NewContainerFromConfig(config wecommon.Config, logger gethlog.Logger) *Cont
}, {
Namespace: "net",
Service: rpcapi.NewNetAPI(walletExt),
}, {
Namespace: "web3",
Service: rpcapi.NewWeb3API(walletExt),
},
})

Expand Down
Loading