Skip to content

Commit

Permalink
fix: avoid naet.NodeInterface whenever possible when writing function…
Browse files Browse the repository at this point in the history
…s that use naet.Node. Each function that uses the node should specify explicitly its methods that it uses from naet.Node, perhaps by defining its own interface locally.
  • Loading branch information
randomshinichi committed Jan 21, 2020
1 parent e403a29 commit 245f5e3
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
8 changes: 7 additions & 1 deletion aeternity/aens.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,15 @@ import (
"github.com/aeternity/aepp-sdk-go/v7/transactions"
)

type nodeStatusHeightAccounterBroadcaster interface {
naet.GetStatuser
naet.GetAccounter
broadcastWaitTransactionNodeCapabilities
}

// RegisterName allows one to easily register a name on AENS. It does the
// preclaim, transaction sending, confirmation and claim for you.
func RegisterName(n naet.NodeInterface, acc *account.Account, name string, nameFee *big.Int) (signedTxStr, hash, signature string, blockHeight uint64, blockHash string, err error) {
func RegisterName(n nodeStatusHeightAccounterBroadcaster, acc *account.Account, name string, nameFee *big.Int) (signedTxStr, hash, signature string, blockHeight uint64, blockHash string, err error) {
networkID, err := getNetworkID(n)
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion aeternity/contracts.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ type compileencoder interface {
}

// CreateContract lets one deploy a contract with minimum fuss.
func CreateContract(n naet.NodeInterface, c compileencoder, acc *account.Account, source, function string, args []string, backend string) (signedTxStr, hash, signature string, blockHeight uint64, blockHash string, err error) {
func CreateContract(n nodeStatusHeightAccounterBroadcaster, c compileencoder, acc *account.Account, source, function string, args []string, backend string) (signedTxStr, hash, signature string, blockHeight uint64, blockHash string, err error) {
networkID, err := getNetworkID(n)
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion aeternity/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func SignBroadcastWaitTransaction(tx transactions.Transaction, signingAccount *a
return
}

func getNetworkID(n naet.NodeInterface) (networkID string, err error) {
func getNetworkID(n naet.GetStatuser) (networkID string, err error) {
status, err := n.GetStatus()
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion aeternity/oracles.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
)

// CreateOracle registers a new oracle with the given queryspec and responsespec
func CreateOracle(n naet.NodeInterface, oracleAccount *account.Account, queryspec, responsespec string, queryFee *big.Int, queryTTLType uint64, oracleTTL uint64) (oracleID string, err error) {
func CreateOracle(n nodeStatusHeightAccounterBroadcaster, oracleAccount *account.Account, queryspec, responsespec string, queryFee *big.Int, queryTTLType uint64, oracleTTL uint64) (oracleID string, err error) {
networkID, err := getNetworkID(n)
if err != nil {
return
Expand Down
2 changes: 1 addition & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func Execute(v string) {
// have to maintain a Node global variable (which needs the config vars to be
// read immediately, with this helper function you can defer the reading of the
// variables until the subcommand's execution)
func newAeNode() naet.NodeInterface {
func newAeNode() *naet.Node {
return naet.NewNode(config.Node.URL, debug)
}

Expand Down

0 comments on commit 245f5e3

Please sign in to comment.