2020-12-21 13:47:02 +00:00
|
|
|
package audit
|
|
|
|
|
|
|
|
import (
|
2022-01-31 12:32:51 +00:00
|
|
|
"fmt"
|
|
|
|
|
2023-03-07 13:38:26 +00:00
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/morph/client"
|
2022-01-31 12:32:51 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
2020-12-21 13:47:02 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Client is a wrapper over StaticClient
|
|
|
|
// which makes calls with the names and arguments
|
2023-02-05 15:59:38 +00:00
|
|
|
// of the FrostFS Audit contract.
|
2020-12-21 13:47:02 +00:00
|
|
|
//
|
|
|
|
// Working client must be created via constructor New.
|
|
|
|
// Using the Client that has been created with new(Client)
|
|
|
|
// expression (or just declaring a Client variable) is unsafe
|
|
|
|
// and can lead to panic.
|
|
|
|
type Client struct {
|
|
|
|
client *client.StaticClient // static Audit contract client
|
|
|
|
}
|
|
|
|
|
|
|
|
const (
|
2022-01-29 13:06:36 +00:00
|
|
|
putResultMethod = "put"
|
|
|
|
getResultMethod = "get"
|
|
|
|
listResultsMethod = "list"
|
|
|
|
listByEpochResultsMethod = "listByEpoch"
|
|
|
|
listByCIDResultsMethod = "listByCID"
|
|
|
|
listByNodeResultsMethod = "listByNode"
|
2020-12-21 13:47:02 +00:00
|
|
|
)
|
|
|
|
|
2022-01-31 12:32:51 +00:00
|
|
|
// NewFromMorph returns the wrapper instance from the raw morph client.
|
|
|
|
func NewFromMorph(cli *client.Client, contract util.Uint160, fee fixedn.Fixed8, opts ...client.StaticClientOption) (*Client, error) {
|
|
|
|
sc, err := client.NewStatic(cli, contract, fee, opts...)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("could not create static client of audit contract: %w", err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Client{client: sc}, nil
|
2020-12-25 10:20:09 +00:00
|
|
|
}
|