Skip to content

Commit 38aebc0

Browse files
committed
Add basic Solana and EVM Chain capabilities interfaces
1 parent 8dad34f commit 38aebc0

File tree

3 files changed

+70
-0
lines changed

3 files changed

+70
-0
lines changed

pkg/types/evm_chain_reader.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
package types
2+
3+
import (
4+
"context"
5+
"fmt"
6+
)
7+
8+
type UnimplementedEVMChainReader struct{}
9+
10+
var _ EVMChainReader = UnimplementedEVMChainReader{}
11+
12+
func (u UnimplementedEVMChainReader) ReadContract(_ context.Context, _ string, _ []byte) ([]byte, error) {
13+
return []byte{}, fmt.Errorf("not implemented")
14+
}

pkg/types/relayer.go

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,38 @@ type NodeStatus struct {
7878
State string
7979
}
8080

81+
type SolanaAccount struct {
82+
// Number of lamports assigned to this account
83+
Lamports uint64
84+
85+
// Pubkey of the program this account has been assigned to
86+
Owner [32]byte
87+
88+
// Data associated with the account encoded as "base58", "base64", or "base64+zstd"
89+
Data []byte
90+
91+
// Boolean indicating if the account contains a program (and is strictly read-only)
92+
Executable bool
93+
94+
// The epoch at which this account will next owe rent
95+
RentEpoch *big.Int
96+
}
97+
98+
type SolanaChainReader interface {
99+
FindProgramAddress(seed [][]byte, programID [32]byte) ([32]byte, error)
100+
GetAccountData(ctx context.Context, programIDs [32]byte) (SolanaAccount, error)
101+
GetMultipleAccountData(ctx context.Context, programIDs [][32]byte) ([]SolanaAccount, error)
102+
}
103+
104+
type EVMChainReader interface {
105+
ReadContract(ctx context.Context, method string, encodedParams []byte) ([]byte, error)
106+
}
107+
108+
type ChainCapabilities interface {
109+
SolanaChainReader
110+
EVMChainReader
111+
}
112+
81113
// ChainService is a sub-interface that encapsulates the explicit interactions with a chain, rather than through a provider.
82114
type ChainService interface {
83115
Service
@@ -99,6 +131,8 @@ type ChainService interface {
99131
type Relayer interface {
100132
ChainService
101133

134+
ChainCapabilities
135+
102136
// NewContractWriter returns a new ContractWriter.
103137
// The format of config depends on the implementation.
104138
NewContractWriter(ctx context.Context, config []byte) (ContractWriter, error)

pkg/types/solana_chain_reader.go

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package types
2+
3+
import (
4+
"context"
5+
"fmt"
6+
)
7+
8+
type UnimplementedSolanaChainReader struct{}
9+
10+
var _ SolanaChainReader = UnimplementedSolanaChainReader{}
11+
12+
func (u UnimplementedSolanaChainReader) FindProgramAddress(_ [][]byte, _ [32]byte) ([32]byte, error) {
13+
return [32]byte{}, fmt.Errorf("not implemented")
14+
}
15+
16+
func (u UnimplementedSolanaChainReader) GetAccountData(_ context.Context, _ [32]byte) (SolanaAccount, error) {
17+
return SolanaAccount{}, fmt.Errorf("not implemented")
18+
}
19+
20+
func (u UnimplementedSolanaChainReader) GetMultipleAccountData(_ context.Context, _ [][32]byte) ([]SolanaAccount, error) {
21+
return []SolanaAccount{}, fmt.Errorf("not implemented")
22+
}

0 commit comments

Comments
 (0)