Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 36 additions & 80 deletions relayer/chainreader/config/config.go
Original file line number Diff line number Diff line change
@@ -1,82 +1,38 @@
package config

import (
"github.com/smartcontractkit/chainlink-common/pkg/types"
)

type ChainReaderConfig struct {
IsLoopPlugin bool
Modules map[string]*ChainReaderModule
}

type ChainReaderModule struct {
// The module name (optional). When not provided, the key in the map under which this module
// is stored is used.
Name string
Functions map[string]*ChainReaderFunction
Events map[string]*ChainReaderEvent
}

type ChainReaderFunction struct {
// The function name (optional). When not provided, the key in the map under which this function
// is stored is used.
Name string
Params []AptosFunctionParam

ResultFieldRenames map[string]RenamedField
ResultTupleToStruct []string
ResultUnwrapStruct []string
}

type AptosFunctionParam struct {
// The function parameter name.
Name string
// The function parameter Move type.
Type string
// True if this is a required parameter, false otherwise.
Required bool
// If this is not a required parameter and it is not provided, this default value will be used.
DefaultValue any
}

type ChainReaderEvent struct {
// The struct where the event handle is defined.
EventHandleStructName string

// The name of the event handle field.
// This field can be defined as path to the nested
// struct that stores the event, e.g. "token_pool_state.burned_events"
EventHandleFieldName string

// The event account address.
// This field can be defined in several ways:
// - Empty string, which means the event account address is the address of the bound contract.
// - An exact address hex string (eg. 0x1234 or 1234) containing the events.
// - A fully qualified function name (eg. 0x1234::my_contract::get_event_address) which
// takes no parameters and returns the actual event account address.
// - A name containing the module name and function name components
// (eg. my_first_contract::get_event_address) stored at the address of the bound contract,
// which takes no parameters and returns the actual event account address.
EventAccountAddress string

// Renames of event field names (optional). When not provided, the field names are used as-is.
EventFieldRenames map[string]RenamedField

// Renames provided filters to match the event field names (optional). When not provided, the filters are used as-is.
EventFilterRenames map[string]string
}

type RenamedField struct {
// The new field name (optional). This does not need to be provided if this field does not need
// to be renamed.
NewName string

// Rename sub-fields. This assumes that the event field value is a struct or a map with string keys.
SubFieldRenames map[string]RenamedField
}

type SequenceWithMetadata struct {
Sequence types.Sequence
TxVersion uint64
TxHash string
}
import "github.com/smartcontractkit/chainlink-common/pkg/types/aptos"

// Deprecated
//
//go:fix inline
type ChainReaderConfig = aptos.ContractReaderConfig

// Deprecated
//
//go:fix inline
type ChainReaderModule = aptos.ContractReaderModule

// Deprecated
//
//go:fix inline
type ChainReaderFunction = aptos.ContractReaderFunction

// Deprecated
//
//go:fix inline
type AptosFunctionParam = aptos.FunctionParam

// Deprecated
//
//go:fix inline
type ChainReaderEvent = aptos.ContractReaderEvent

// Deprecated
//
//go:fix inline
type RenamedField = aptos.RenamedField

// Deprecated
//
//go:fix inline
type SequenceWithMetadata = aptos.SequenceWithMetadata
2 changes: 2 additions & 0 deletions relayer/chainreader/loop/loop_reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ import (
// Both `logger` and `cr` parameters must be non-nil.
//
// Deprecated: use loop.NewLoopChainReader
//
//go:fix inline
func NewLoopChainReader(logger logger.Logger, cr types.ContractReader) types.ContractReader {
return loop.NewLoopChainReader(logger, cr)
}
49 changes: 23 additions & 26 deletions relayer/chainwriter/config.go
Original file line number Diff line number Diff line change
@@ -1,37 +1,34 @@
package chainwriter

import (
crconfig "github.com/smartcontractkit/chainlink-aptos/relayer/chainreader/config"
"github.com/smartcontractkit/chainlink-common/pkg/types/aptos"
)

type FeeStrategy int
// Deprecated
//
//go:fix inline
type FeeStrategy = aptos.FeeStrategy

// Deprecated
//
//go:fix inline
const (
DeprioritizedFeeStrategy FeeStrategy = -1
DefaultFeeStrategy FeeStrategy = 0
PrioritizedFeeStrategy FeeStrategy = 1
DeprioritizedFeeStrategy = aptos.DeprioritizedFeeStrategy
DefaultFeeStrategy = aptos.DefaultFeeStrategy
PrioritizedFeeStrategy = aptos.PrioritizedFeeStrategy
)

type ChainWriterConfig struct {
Modules map[string]*ChainWriterModule
FeeStrategy FeeStrategy
}
// Deprecated
//
//go:fix inline
type ChainWriterConfig = aptos.ContractWriterConfig

type ChainWriterModule struct {
// The module name (optional). When not provided, the key in the map under which this module
// is stored is used.
Name string
Functions map[string]*ChainWriterFunction
}
// Deprecated
//
//go:fix inline
type ChainWriterModule = aptos.ContractWriterModule

type ChainWriterFunction struct {
// The function name (optional). When not provided, the key in the map under which this function
// is stored is used.
Name string
// The public key of the sending account.
PublicKey string
// The account address (optional). When not provided, the address is calculated
// from the public key.
FromAddress string
Params []crconfig.AptosFunctionParam
}
// Deprecated
//
//go:fix inline
type ChainWriterFunction = aptos.ContractWriterFunction
4 changes: 4 additions & 0 deletions relayer/codec/decode_util.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,15 @@ package codec
import "github.com/smartcontractkit/chainlink-aptos/codec"

// Deprecated: use codec.DecodeAptosJsonArray
//
//go:fix inline
func DecodeAptosJsonArray(from []any, to ...any) error {
return codec.DecodeAptosJsonArray(from, to...)
}

// Deprecated: use codec.DecodeAptosJsonValue
//
//go:fix inline
func DecodeAptosJsonValue(from any, to any) error {
return codec.DecodeAptosJsonValue(from, to)
}
1 change: 1 addition & 0 deletions relayer/relay.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ var _ types.AptosService = (*relayer)(nil)
var _ loop.Relayer = (*relayer)(nil)

type relayer struct {
types.UnimplementedRelayer
chain chain.Chain
lggr logger.Logger

Expand Down
5 changes: 3 additions & 2 deletions relayer/testutils/keystore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@ import (
"fmt"
"testing"

"github.com/smartcontractkit/chainlink-common/pkg/loop"
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
)

type TestKeystore struct {
core.UnimplementedKeystore
t *testing.T
Keys map[string]ed25519.PrivateKey
}

var _ loop.Keystore = &TestKeystore{}
var _ core.Keystore = &TestKeystore{}

func NewTestKeystore(t *testing.T) *TestKeystore {
return &TestKeystore{t: t, Keys: map[string]ed25519.PrivateKey{}}
Expand Down
1 change: 1 addition & 0 deletions relayer/write_target/write_target_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"time"

"github.com/shopspring/decimal"

"github.com/smartcontractkit/chainlink-common/pkg/beholder"
"github.com/smartcontractkit/chainlink-common/pkg/capabilities"
"github.com/smartcontractkit/chainlink-common/pkg/capabilities/consensus/ocr3/types"
Expand Down
Loading