diff --git a/base/base.go b/base/base.go index 5c1d10c..036bdcc 100644 --- a/base/base.go +++ b/base/base.go @@ -86,6 +86,8 @@ func GetChainName(id uint64) string { return "OK" case MATIC: return "Polygon" + case HEIMDALL: + return "Heimdall" case NEO3: return "NEO3" case SWITCHEO: diff --git a/chains/chain.go b/chains/chain.go index e932d2b..cd3fe94 100644 --- a/chains/chain.go +++ b/chains/chain.go @@ -18,6 +18,7 @@ package chains import ( + "context" "fmt" "strings" "sync" @@ -44,7 +45,7 @@ type SDK interface { type Nodes interface { Height() uint64 - WaitTillHeight(uint64, time.Duration) uint64 + WaitTillHeight(context.Context, uint64, time.Duration) (uint64, bool) Available() bool Node() SDK } @@ -77,7 +78,7 @@ func (s *ChainSDK) Height() uint64 { return s.height } -func (s *ChainSDK) WaitTillHeight(height uint64, interval time.Duration) uint64 { +func (s *ChainSDK) WaitTillHeight(ctx context.Context, height uint64, interval time.Duration) (uint64, bool) { if interval == 0 { interval = s.interval } @@ -86,9 +87,13 @@ func (s *ChainSDK) WaitTillHeight(height uint64, interval time.Duration) uint64 if err != nil { log.Error("Failed to get chain latest height err ", "chain", s.ChainID, "err", err) } else if h >= height { - return h + return h, true + } + select { + case <-ctx.Done(): + return h, false + case <-time.After(interval): } - time.Sleep(interval) } } diff --git a/wallet/poly.go b/wallet/poly.go index d62ef9f..d7824ad 100644 --- a/wallet/poly.go +++ b/wallet/poly.go @@ -23,12 +23,7 @@ import ( sdk "github.com/polynetwork/poly-go-sdk" ) -type PolySignerConfig struct { - Path string - Password string -} - -func NewPolySigner(config *PolySignerConfig) (signer *sdk.Account, err error) { +func NewPolySigner(config *Config) (signer *sdk.Account, err error) { if config == nil { return nil, fmt.Errorf("Missing poly wallet config") }