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

feat: add jsonrpc gateway support #1183

Merged

Conversation

alidevjimmy
Copy link
Contributor

Description

Added JSON-RPC gateway support for gRPC server using protoc-gen-jrpc-gateway protoc generator plugin and jrpc for json-rpc server.
I tested it manually and it works fine but I'll write tests for it.

@alidevjimmy alidevjimmy changed the title Feat add jsonrpc gateway support Feat: add jsonrpc gateway support Mar 28, 2024
Makefile Outdated Show resolved Hide resolved
config/config.go Show resolved Hide resolved
www/grpc/buf/buf.gen.yaml Outdated Show resolved Hide resolved
www/jsonrpc/server.go Outdated Show resolved Hide resolved
@b00f
Copy link
Collaborator

b00f commented Mar 29, 2024

@alidevjimmy, you can use commands like make fmt and make check to ensure that linting and formatting pass.

@b00f b00f changed the title Feat: add jsonrpc gateway support feat: add jsonrpc gateway support Mar 29, 2024
@b00f b00f added the www label Mar 29, 2024
www/jsonrpc/server.go Outdated Show resolved Hide resolved
www/jsonrpc/server.go Outdated Show resolved Hide resolved
client: client,
}
}

Copy link
Collaborator

@b00f b00f Mar 29, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You need to add a function here like:

// RegisterBlockchainMethods registers the JSON-RPC methods for the Blockchain service with "mux".
// The handlers convert JSON-RPC requests to gRPC requests and forward them to the gRPC endpoint over "conn".
// The results are then converted back to JSON-RPC responses.
func RegisterTransactionHandler(ctx context.Context, mux *jgw.ServerMux, conn *grpc.ClientConn) error {
	return mux.RegisterMethods(ctx, BlockchainMethods(NewTransactionClient(conn)))
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can give a type to: func(ctx context.Context, params json.RawMessage) (interface{}, error)

go.mod Outdated Show resolved Hide resolved
@alidevjimmy alidevjimmy force-pushed the feat-add-jsonrpc-gateway-support branch from 520887f to 389e25b Compare March 29, 2024 17:53
Copy link

codecov bot commented Mar 30, 2024

Codecov Report

Merging #1183 (456b274) into main (41d10ee) will decrease coverage by 0.04%.
The diff coverage is 68.42%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1183      +/-   ##
==========================================
- Coverage   81.37%   81.33%   -0.04%     
==========================================
  Files         179      179              
  Lines        9481     9496      +15     
==========================================
+ Hits         7715     7724       +9     
- Misses       1381     1386       +5     
- Partials      385      386       +1     

node/node.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
config/example_config.toml Show resolved Hide resolved
@themantre themantre merged commit 7377e5c into pactus-project:main Mar 30, 2024
11 of 12 checks passed
@alidevjimmy alidevjimmy deleted the feat-add-jsonrpc-gateway-support branch March 31, 2024 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants