chainlink-common icon indicating copy to clipboard operation
chainlink-common copied to clipboard

[BCFR-147][common] - Add codec chain agnostic modifier for converting byte array address to string

Open Farber98 opened this issue 1 year ago • 0 comments

Description

This PR introduces a chain-agnostic solution for transforming address byte arrays into string representations. To do so, it uses a modifier that supports chain-specific logic. The modifier is injected during relayer contractReader configuration.

Key Changes

  • AddressModifier Interface: Provides an abstraction for encoding/decoding addresses across different chains. Will be implemented in each relayer with corresponding chain-specific logic.
type AddressModifier interface {
    EncodeAddress([]byte) (string, error)
    DecodeAddress(string) ([]byte, error)
    Length() int
}
  • AddressBytesToStringModifierConfig: This config struct skips the modifier in JSON serialization to avoid serialization issues and it will be injected later.
type AddressBytesToStringModifierConfig struct {
    Fields   []string
    Modifier AddressModifier `json:"-"` 
}

Resources

Related PRs

  • https://github.com/smartcontractkit/chainlink-solana/pull/875
  • https://github.com/smartcontractkit/chainlink/pull/14620

core ref: bcfr-147-add-address-to-string-modifier solana ref: bcfr-147-add-address-to-string-modifier

Farber98 avatar Oct 01 '24 14:10 Farber98