diff --git a/pastel/cascade_multi_volume.go b/pastel/cascade_multi_volume.go new file mode 100644 index 000000000..1611f1e54 --- /dev/null +++ b/pastel/cascade_multi_volume.go @@ -0,0 +1,8 @@ +package pastel + +type CascadeMultiVolumeTicket struct { + ID string `json:"id"` + HumanReadableIdentifier string `json:"human_readable_identifier"` + SHA3256HashOfOriginalFile string `json:"sha3_256_hash_of_original_file"` + Volumes map[string]string `json:"volumes"` +} \ No newline at end of file diff --git a/pastel/client.go b/pastel/client.go index 5a015d0c6..6e5ec8063 100644 --- a/pastel/client.go +++ b/pastel/client.go @@ -3,6 +3,7 @@ package pastel import ( "context" "encoding/base64" + "encoding/json" "fmt" "net" "strconv" @@ -12,6 +13,7 @@ import ( "github.com/pastelnetwork/gonode/common/errors" "github.com/pastelnetwork/gonode/common/log" "github.com/pastelnetwork/gonode/pastel/jsonrpc" + "github.com/pastelnetwork/gonode/common/utils" ) const ( @@ -531,6 +533,32 @@ func (client *client) RegisterActionTicket(ctx context.Context, request Register return txID.TxID, nil } +func (client *client) RegisterCascadeMultiVolumeTicket(ctx context.Context, ticket CascadeMultiVolumeTicket) (string, error){ + ticketJSON, err := json.Marshal(ticket) + if err != nil { + return "", errors.Errorf("failed to call register action ticket: %w", err) + } + ticketBlob := base64.StdEncoding.EncodeToString(ticketJSON) + + hash, _ := utils.Sha3256hash(ticketJSON) + // Assuming some additional data or parameters are needed, similar to the RegisterNFTRequest example + params := []interface{}{ + "register", + "contract", + ticketBlob, + ticket.ID, + hash, + } + + resp := make(map[string]interface{}) + if err := client.callFor(ctx, &resp, "tickets", params...); err != nil { + return "", errors.Errorf("failed to call register contract: %w", err) + } + log.WithContext(ctx).WithField("resp", resp).WithField("txid", ticket.ID).Info("RegisterCascadeMultiVolumeTicket Response") + + return ticket.ID, nil +} + func (client *client) ActivateActionTicket(ctx context.Context, request ActivateActionRequest) (string, error) { var txID struct { TxID string `json:"txid"` diff --git a/pastel/pastel.go b/pastel/pastel.go index ed6e1067b..4f187e0b0 100644 --- a/pastel/pastel.go +++ b/pastel/pastel.go @@ -239,4 +239,7 @@ type Client interface { //NFTStorageFee returns the fee of NFT storage //Command `tickets tools estimatenftstoragefee ` NFTStorageFee(ctx context.Context, sizeInMB int) (*NFTStorageFeeEstimate, error) + + // RegisterCascadeMultiVolumeTicket registers a cascade multi-volume ticket + RegisterCascadeMultiVolumeTicket(ctx context.Context, ticket CascadeMultiVolumeTicket) (string, error) }