8ceba2a7c2
Define InnerRingList function that calls "innerRingList" method of particular smart contract. Define InnerRingListViaStorage function that reads address of smart contract from the storage by key, and calls InnerRingList with the result. Reuse these functions in all contracts. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
24 lines
738 B
Go
24 lines
738 B
Go
package common
|
|
|
|
import (
|
|
"github.com/nspcc-dev/neo-go/pkg/interop"
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
|
"github.com/nspcc-dev/neo-go/pkg/interop/storage"
|
|
)
|
|
|
|
const irListMethod = "innerRingList"
|
|
|
|
// InnerRingList returns list of inner ring nodes through calling
|
|
// "innerRingList" method of smart contract.
|
|
//
|
|
// Address of smart contract is received from storage by key.
|
|
func InnerRingListViaStorage(ctx storage.Context, key interface{}) []IRNode {
|
|
sc := storage.Get(ctx, key).([]byte)
|
|
return InnerRingList(sc)
|
|
}
|
|
|
|
// InnerRingList gets list of inner ring through
|
|
// calling "innerRingList" method of smart contract.
|
|
func InnerRingList(sc interop.Hash160) []IRNode {
|
|
return contract.Call(sc, irListMethod).([]IRNode)
|
|
}
|