Compare commits

..

8 commits

Author SHA1 Message Date
201db45bd7
[#142] common: Update version
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2024-12-12 15:25:14 +03:00
e002a1fa80
[#142] common: Downgrade previous version
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2024-12-12 15:25:02 +03:00
31709a3d95
[#141] frostfsid: Remove address index in DeleteSubject()
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2024-12-12 14:42:03 +03:00
3c7a9cb743
[#136] container/test: Move container domain to constant
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2024-12-12 13:19:34 +03:00
780b48cedf
[#136] container: Add SetAdmin
SetAdmin will allow to manage the root domain of the container.

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2024-12-12 13:19:34 +03:00
a3021f18cf [#135] frostfsid: Make migration idempotent
Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
2024-12-12 06:28:19 +00:00
891e268170
[#138] frostfs: Remove AlphabetUpdate event from the configuration
It does not exist in code.
Refs #7.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-12-11 14:36:55 +03:00
762d7f9f9f
[#134] container: Use Hash256 for container ID in Delete()
This is what we use inside Put(). It leads to a better auto-generated
code.

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
2024-12-05 11:38:07 +03:00
5 changed files with 17 additions and 90 deletions

View file

@ -30,7 +30,7 @@ events:
- name: DeleteSuccess
parameters:
- name: containerID
type: ByteArray
type: Hash256
- name: SetEACLSuccess
parameters:
- name: containerID

View file

@ -279,7 +279,7 @@ func checkNiceNameAvailable(nnsContractAddr interop.Hash160, domain string) bool
// API.
//
// If the container doesn't exist, it panics with NotFoundError.
func Delete(containerID []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
func Delete(containerID interop.Hash256, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
ctx := storage.GetContext()
ownerID := getOwnerByID(ctx, containerID)

View file

@ -47,12 +47,6 @@ events:
type: ByteArray
- name: keys
type: Array
- name: AlphabetUpdate
parameters:
- name: id
type: ByteArray
- name: alphabet
type: Array
- name: SetConfig
parameters:
- name: id

View file

@ -25,7 +25,7 @@ type PutSuccessEvent struct {
// DeleteSuccessEvent represents "DeleteSuccess" event emitted by the contract.
type DeleteSuccessEvent struct {
ContainerID []byte
ContainerID util.Uint256
}
// SetEACLSuccessEvent represents "SetEACLSuccess" event emitted by the contract.
@ -163,14 +163,14 @@ func (c *ContractReader) Version() (*big.Int, error) {
// Delete creates a transaction invoking `delete` method of the contract.
// This transaction is signed and immediately sent to the network.
// The values returned are its hash, ValidUntilBlock value and error if any.
func (c *Contract) Delete(containerID []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (util.Uint256, uint32, error) {
func (c *Contract) Delete(containerID util.Uint256, signature []byte, publicKey *keys.PublicKey, token []byte) (util.Uint256, uint32, error) {
return c.actor.SendCall(c.hash, "delete", containerID, signature, publicKey, token)
}
// DeleteTransaction creates a transaction invoking `delete` method of the contract.
// This transaction is signed, but not sent to the network, instead it's
// returned to the caller.
func (c *Contract) DeleteTransaction(containerID []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
func (c *Contract) DeleteTransaction(containerID util.Uint256, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
return c.actor.MakeCall(c.hash, "delete", containerID, signature, publicKey, token)
}
@ -178,7 +178,7 @@ func (c *Contract) DeleteTransaction(containerID []byte, signature []byte, publi
// This transaction is not signed, it's simply returned to the caller.
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
func (c *Contract) DeleteUnsigned(containerID []byte, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
func (c *Contract) DeleteUnsigned(containerID util.Uint256, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
return c.actor.MakeUnsignedCall(c.hash, "delete", nil, containerID, signature, publicKey, token)
}
@ -502,7 +502,17 @@ func (e *DeleteSuccessEvent) FromStackItem(item *stackitem.Array) error {
err error
)
index++
e.ContainerID, err = arr[index].TryBytes()
e.ContainerID, err = func(item stackitem.Item) (util.Uint256, error) {
b, err := item.TryBytes()
if err != nil {
return util.Uint256{}, err
}
u, err := util.Uint256DecodeBytesBE(b)
if err != nil {
return util.Uint256{}, err
}
return u, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field ContainerID: %w", err)
}

View file

@ -50,12 +50,6 @@ type UnbindEvent struct {
Keys []any
}
// AlphabetUpdateEvent represents "AlphabetUpdate" event emitted by the contract.
type AlphabetUpdateEvent struct {
Id []byte
Alphabet []any
}
// SetConfigEvent represents "SetConfig" event emitted by the contract.
type SetConfigEvent struct {
Id []byte
@ -710,77 +704,6 @@ func (e *UnbindEvent) FromStackItem(item *stackitem.Array) error {
return nil
}
// AlphabetUpdateEventsFromApplicationLog retrieves a set of all emitted events
// with "AlphabetUpdate" name from the provided [result.ApplicationLog].
func AlphabetUpdateEventsFromApplicationLog(log *result.ApplicationLog) ([]*AlphabetUpdateEvent, error) {
if log == nil {
return nil, errors.New("nil application log")
}
var res []*AlphabetUpdateEvent
for i, ex := range log.Executions {
for j, e := range ex.Events {
if e.Name != "AlphabetUpdate" {
continue
}
event := new(AlphabetUpdateEvent)
err := event.FromStackItem(e.Item)
if err != nil {
return nil, fmt.Errorf("failed to deserialize AlphabetUpdateEvent from stackitem (execution #%d, event #%d): %w", i, j, err)
}
res = append(res, event)
}
}
return res, nil
}
// FromStackItem converts provided [stackitem.Array] to AlphabetUpdateEvent or
// returns an error if it's not possible to do to so.
func (e *AlphabetUpdateEvent) FromStackItem(item *stackitem.Array) error {
if item == nil {
return errors.New("nil item")
}
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return errors.New("not an array")
}
if len(arr) != 2 {
return errors.New("wrong number of structure elements")
}
var (
index = -1
err error
)
index++
e.Id, err = arr[index].TryBytes()
if err != nil {
return fmt.Errorf("field Id: %w", err)
}
index++
e.Alphabet, err = func(item stackitem.Item) ([]any, error) {
arr, ok := item.Value().([]stackitem.Item)
if !ok {
return nil, errors.New("not an array")
}
res := make([]any, len(arr))
for i := range res {
res[i], err = arr[i].Value(), error(nil)
if err != nil {
return nil, fmt.Errorf("item %d: %w", i, err)
}
}
return res, nil
}(arr[index])
if err != nil {
return fmt.Errorf("field Alphabet: %w", err)
}
return nil
}
// SetConfigEventsFromApplicationLog retrieves a set of all emitted events
// with "SetConfig" name from the provided [result.ApplicationLog].
func SetConfigEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetConfigEvent, error) {