Skip to content

Commit 4716e3e

Browse files
committed
Add more documentation and move ExternalAdapter interface to core/securemint
1 parent 1dce37c commit 4716e3e

File tree

3 files changed

+48
-39
lines changed

3 files changed

+48
-39
lines changed

pkg/loop/internal/reportingplugin/securemint/external_adapter_pb.go

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ import (
1313
"github.com/smartcontractkit/chainlink-common/pkg/types/core"
1414
)
1515

16-
var _ core.ExternalAdapter = (*externalAdapterClient)(nil)
17-
1816
// externalAdapterClient is a protobuf client that implements the core.ExternalAdapter interface.
1917
// It's basically a wrapper around the protobuf external adapter client so that it can be used as a core.ExternalAdapter.
2018
type externalAdapterClient struct {
2119
lggr logger.Logger
2220
grpc pb.ExternalAdapterClient
2321
}
2422

23+
var _ core.ExternalAdapter = (*externalAdapterClient)(nil)
24+
2525
func newExternalAdapterClient(lggr logger.Logger, cc grpc.ClientConnInterface) *externalAdapterClient {
2626
return &externalAdapterClient{lggr: logger.Named(lggr, "ExternalAdapterClient"), grpc: pb.NewExternalAdapterClient(cc)}
2727
}
@@ -92,7 +92,6 @@ func newExternalAdapterServer(lggr logger.Logger, impl core.ExternalAdapter) *ex
9292
return &externalAdapterServer{lggr: logger.Named(lggr, "ExternalAdapterServer"), impl: impl}
9393
}
9494

95-
// TODO(gg): add unit tests for this
9695
func (d *externalAdapterServer) GetPayload(ctx context.Context, request *pb.Blocks) (*pb.ExternalAdapterPayload, error) {
9796
d.lggr.Infof("GetPayload request pb server: %+v", request)
9897

pkg/types/core/secure_mint_interface.go

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,10 @@ package core
22

33
import (
44
"context"
5-
"math/big"
6-
"time"
75

86
"github.com/smartcontractkit/chainlink-common/pkg/logger"
97
"github.com/smartcontractkit/chainlink-common/pkg/services"
8+
"github.com/smartcontractkit/chainlink-common/pkg/types/core/securemint"
109
"github.com/smartcontractkit/libocr/offchainreporting2plus/ocr3types"
1110
)
1211

@@ -16,40 +15,7 @@ const PluginSecureMintName = "securemint"
1615
type PluginSecureMint interface {
1716
services.Service
1817
// NewSecureMintFactory returns a ReportingPluginFactory for the secure mint plugin.
19-
NewSecureMintFactory(ctx context.Context, lggr logger.Logger, externalAdapter ExternalAdapter) (ReportingPluginFactory[ChainSelector], error)
20-
}
21-
22-
// ExternalAdapter is an alias for por.ExternalAdapter
23-
// TODO(gg): maybe move all por types that are used by the client (core node) to cl-common?
24-
// TODO(gg): Otherwise add godoc to all below types.
25-
// TODO(gg): should we put this under core/secure_mint? Or rename to SecureMintExternalAdapter? `core.ExternalAdapter` seems too broad for what it's doing.
26-
type ExternalAdapter interface {
27-
GetPayload(ctx context.Context, blocks Blocks) (ExternalAdapterPayload, error)
28-
}
29-
30-
type BlockNumber uint64
31-
32-
type ChainSelector uint64
33-
34-
type Blocks map[ChainSelector]BlockNumber
35-
36-
type BlockMintablePair struct {
37-
Block BlockNumber
38-
Mintable *big.Int
39-
}
40-
41-
type Mintables map[ChainSelector]BlockMintablePair
42-
43-
type ReserveInfo struct {
44-
ReserveAmount *big.Int
45-
Timestamp time.Time
46-
}
47-
48-
type ExternalAdapterPayload struct {
49-
Mintables Mintables // The mintable amounts for each chain and its block.
50-
ReserveInfo ReserveInfo // The latest reserve amount and timestamp used to calculate the minting allowance above.
51-
52-
LatestBlocks Blocks // The latest blocks for each chain.
18+
NewSecureMintFactory(ctx context.Context, lggr logger.Logger, externalAdapter securemint.ExternalAdapter) (ReportingPluginFactory[securemint.ChainSelector], error)
5319
}
5420

5521
// ReportingPluginFactory wraps ocr3types.ReportingPluginFactory[RI] to add a Service to it.
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package securemint
2+
3+
import (
4+
"context"
5+
"math/big"
6+
"time"
7+
)
8+
9+
// ExternalAdapter is an alias for por.ExternalAdapter
10+
// TODO(gg): maybe move all por types that are used by the client (core node) to cl-common?
11+
12+
// ExternalAdapter is the component used by the secure mint plugin to request various secure mint related data points.
13+
type ExternalAdapter interface {
14+
GetPayload(ctx context.Context, blocks Blocks) (ExternalAdapterPayload, error)
15+
}
16+
17+
type BlockNumber uint64
18+
19+
type ChainSelector uint64
20+
21+
// Blocks contains the latest blocks per chain selector.
22+
type Blocks map[ChainSelector]BlockNumber
23+
24+
// BlockMintablePair is a mintable amount at a certain block number.
25+
type BlockMintablePair struct {
26+
Block BlockNumber
27+
Mintable *big.Int
28+
}
29+
30+
type Mintables map[ChainSelector]BlockMintablePair
31+
32+
// ReserveInfo is a reserve amount at a certain timestamp.
33+
type ReserveInfo struct {
34+
ReserveAmount *big.Int
35+
Timestamp time.Time
36+
}
37+
38+
// ExternalAdapterPayload is the response from an EA containing various secure mint related data points.
39+
type ExternalAdapterPayload struct {
40+
Mintables Mintables // The mintable amounts for each chain and its block.
41+
ReserveInfo ReserveInfo // The latest reserve amount and timestamp used to calculate the minting allowance above.
42+
43+
LatestBlocks Blocks // The latest blocks for each chain.
44+
}

0 commit comments

Comments
 (0)