Skip to content

Commit

Permalink
Gateway: hardcode response to clientVersion request (#1937)
Browse files Browse the repository at this point in the history
  • Loading branch information
BedrockSquirrel authored May 25, 2024
1 parent 5780140 commit a880b16
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
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/ten"

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

0 comments on commit a880b16

Please sign in to comment.