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

Implement Stacks Blockchain Provider #315

Open
CyrusVorwald opened this issue Jul 28, 2024 · 0 comments
Open

Implement Stacks Blockchain Provider #315

CyrusVorwald opened this issue Jul 28, 2024 · 0 comments
Assignees

Comments

@CyrusVorwald
Copy link

The provider serves as the main interface between our relay system and the Stacks blockchain. It uses the Stacks RPC client to perform blockchain-specific operations required by our relay system.

Structure, configuration, and initialization
Create a Provider struct that implements the common ChainProvider interface from a Config struct, a Stacks client, and a logger.

Implement a Config struct that satisfies the Config interface and additionally any Stacks-specific configuration:

type Config struct {
    provider.CommonConfig `json:",inline" yaml:",inline"`
    // Add Stacks-specific fields here
}

Implement the following methods for the Config struct:

NewProvider(context.Context, *zap.Logger, string, bool, string) (ChainProvider, error)
SetWallet(string)
GetWallet() string
Validate() error
Enabled() bool

Implementation of ChainProvider interface

NID() string
Name() string
Init(context.Context, string, kms.KMS) error
Type() string
Config() Config
Listener(ctx context.Context, lastSavedHeight uint64, blockInfo chan *types.BlockInfo) error
Route(ctx context.Context, message *types.Message, callback types.TxResponseFunc) error
ShouldReceiveMessage(ctx context.Context, message *types.Message) (bool, error)
ShouldSendMessage(ctx context.Context, message *types.Message) (bool, error)
SetLastSavedHeightFunc(func() uint64)
MessageReceived(ctx context.Context, key *types.MessageKey) (bool, error)
SetAdmin(context.Context, string) error
FinalityBlock(ctx context.Context) uint64
GenerateMessages(ctx context.Context, messageKey *types.MessageKeyWithMessageHeight) ([]*types.Message, error)
QueryBalance(ctx context.Context, addr string) (*types.Coin, error)
NewKeystore(string) (string, error)
RestoreKeystore(context.Context) error
ImportKeystore(context.Context, string, string) (string, error)
RevertMessage(context.Context, *big.Int) error
GetFee(context.Context, string, bool) (uint64, error)
SetFee(context.Context, string, *big.Int, *big.Int) error
ClaimFee(context.Context) error

Implementation of ChainQuery interface

QueryLatestHeight(ctx context.Context) (uint64, error)
QueryTransactionReceipt(ctx context.Context, txHash string) (*types.Receipt, error)

Acceptance criteria

  • The Stacks provider implements all methods required by the ChainProvider interface
  • The provider integrates with the Stacks client
  • Unit tests cover all methods with >80% code coverage
  • Integration tests confirm functionality against Stacks testnet
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant