Skip to content

Commit

Permalink
feat: add neded changes for proxy service
Browse files Browse the repository at this point in the history
  • Loading branch information
pablocampogo committed Nov 15, 2024
1 parent fcfe6e8 commit 114276e
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ Before you begin, ensure you have the following installed on your system:
```json
{
"chainName": "ethereum",
"chainType": "evm",
"methods": [
{
Expand All @@ -96,6 +97,7 @@ Before you begin, ensure you have the following installed on your system:
- **`Solana`**: the solana go's standard [CommitmentType](https://github.com/gagliardetto/solana-go/blob/main/rpc/types.go#L431)
- **Explanation of Fields**:
- **`chainName`**: Name of the chain of the config file, this field is just for trackability purposes it is not used in this repo
- **`chainType`**: Chain type of the chain of the config file, this field is a enum specified on `ChainType` in the `custom-rpc-methods/custom_rpc_methods.go` file
- **`customMethod`**: The method name used to retrieve data along with the getter struct (block number in the case of EVM).
- **`originalMethod`**: The original method name without the getter struct support.
Expand Down
13 changes: 13 additions & 0 deletions custom-rpc-methods/custom_rpc_methods.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type Method struct {
}

type MethodsConfig struct {
ChainName string `json:"chainName"`
ChainType ChainType `json:"chainType"`
Methods []Method `json:"methods"`
}
Expand All @@ -63,6 +64,18 @@ type CustomRpcMethodBuilder interface {
ChangeCustomMethodsResponses(responses []*models.RPCResJSON, changedMethods, idsHolder map[string]string, customMethodsMap map[string][]GetterTypesHolder) ([]*models.RPCResJSON, error)
}

// ImplementationPublicData is the interface of functions of public data to be used from repos that import the compatibility layer
type ImplementationPublicData interface {
GetChainType() ChainType
SupportsRange() bool
}

// ChainTypeToPublicData is a map to be able to fetch various data from chain type when compatibility layer is expoted
var ChainTypeToPublicData map[ChainType]ImplementationPublicData = map[ChainType]ImplementationPublicData{
ChainTypeEVM: EVMImpl{},
ChainTypeSolana: SolanaImpl{},
}

type CustomMethodHolder struct {
ChainTypeToMethodBuilder map[ChainType]CustomRpcMethodBuilder
CustomMethodToChainType map[string]ChainType
Expand Down
1 change: 1 addition & 0 deletions supported-chains/blast.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"chainName": "blast",
"chainType": "evm",
"methods": [
{
Expand Down
1 change: 1 addition & 0 deletions supported-chains/erigon.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"chainName": "erigon",
"chainType": "evm",
"methods": [
{
Expand Down
1 change: 1 addition & 0 deletions supported-chains/ethereum.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"chainName": "ethereum",
"chainType": "evm",
"methods": [
{
Expand Down
1 change: 1 addition & 0 deletions supported-chains/polygon-bor.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"chainName": "polygon-bor",
"chainType": "evm",
"methods": [
{
Expand Down
1 change: 1 addition & 0 deletions supported-chains/solana.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"chainName": "solana",
"chainType": "solana",
"methods": [
{
Expand Down

0 comments on commit 114276e

Please sign in to comment.