container: Use Hash256 for container ID in Delete() #134
6 changed files with 37 additions and 11 deletions
16
CHANGELOG.md
16
CHANGELOG.md
|
@ -1,6 +1,7 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
Changelog for FrostFS Contract
|
Changelog for FrostFS Contract
|
||||||
|
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -9,6 +10,21 @@ Changelog for FrostFS Contract
|
||||||
### Updated
|
### Updated
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
|
## [0.21.0]
|
||||||
|
|
||||||
|
### Added
|
||||||
|
- Mention domain name in error messages in the nns contract (#92)
|
||||||
|
- Emit DeleteRecord event on record deletion in the nns contract (#114)
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
- Allow to register TLD automatically (#114)
|
||||||
|
- Use frostfsid claims as a permission to create TLD (#115)
|
||||||
|
- Ensure subject keys are unique (#118, #129)
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
- Terminate session in `ReadIteratorItems()` (#85)
|
||||||
|
- Declare `nns.getAllRecords` as safe (#131)
|
||||||
|
|
||||||
## [0.20.0]
|
## [0.20.0]
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
2
VERSION
2
VERSION
|
@ -1 +1 @@
|
||||||
v0.20.0
|
v0.21.0
|
||||||
|
|
|
@ -4,15 +4,15 @@ import "github.com/nspcc-dev/neo-go/pkg/interop/native/std"
|
||||||
|
|
||||||
const (
|
const (
|
||||||
major = 0
|
major = 0
|
||||||
minor = 20
|
minor = 21
|
||||||
patch = 0
|
patch = 0
|
||||||
|
|
||||||
// Versions from which an update should be performed.
|
// Versions from which an update should be performed.
|
||||||
// These should be used in a group (so prevMinor can be equal to minor if there are
|
// These should be used in a group (so prevMinor can be equal to minor if there are
|
||||||
// any migration routines.
|
// any migration routines.
|
||||||
prevMajor = 0
|
prevMajor = 0
|
||||||
prevMinor = 19
|
prevMinor = 20
|
||||||
prevPatch = 3
|
prevPatch = 0
|
||||||
|
|
||||||
Version = major*1_000_000 + minor*1_000 + patch
|
Version = major*1_000_000 + minor*1_000 + patch
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ events:
|
||||||
- name: DeleteSuccess
|
- name: DeleteSuccess
|
||||||
parameters:
|
parameters:
|
||||||
- name: containerID
|
- name: containerID
|
||||||
type: ByteArray
|
type: Hash256
|
||||||
- name: SetEACLSuccess
|
- name: SetEACLSuccess
|
||||||
parameters:
|
parameters:
|
||||||
- name: containerID
|
- name: containerID
|
||||||
|
|
|
@ -279,7 +279,7 @@ func checkNiceNameAvailable(nnsContractAddr interop.Hash160, domain string) bool
|
||||||
// API.
|
// API.
|
||||||
//
|
//
|
||||||
// If the container doesn't exist, it panics with NotFoundError.
|
// 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()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
ownerID := getOwnerByID(ctx, containerID)
|
ownerID := getOwnerByID(ctx, containerID)
|
||||||
|
|
|
@ -25,7 +25,7 @@ type PutSuccessEvent struct {
|
||||||
|
|
||||||
// DeleteSuccessEvent represents "DeleteSuccess" event emitted by the contract.
|
// DeleteSuccessEvent represents "DeleteSuccess" event emitted by the contract.
|
||||||
type DeleteSuccessEvent struct {
|
type DeleteSuccessEvent struct {
|
||||||
ContainerID []byte
|
ContainerID util.Uint256
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetEACLSuccessEvent represents "SetEACLSuccess" event emitted by the contract.
|
// 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.
|
// Delete creates a transaction invoking `delete` method of the contract.
|
||||||
// This transaction is signed and immediately sent to the network.
|
// This transaction is signed and immediately sent to the network.
|
||||||
// The values returned are its hash, ValidUntilBlock value and error if any.
|
// 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)
|
return c.actor.SendCall(c.hash, "delete", containerID, signature, publicKey, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
// DeleteTransaction creates a transaction invoking `delete` method of the contract.
|
// DeleteTransaction creates a transaction invoking `delete` method of the contract.
|
||||||
// This transaction is signed, but not sent to the network, instead it's
|
// This transaction is signed, but not sent to the network, instead it's
|
||||||
// returned to the caller.
|
// 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)
|
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.
|
// 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,
|
// Any fields of it that do not affect fees can be changed (ValidUntilBlock,
|
||||||
// Nonce), fee values (NetworkFee, SystemFee) can be increased as well.
|
// 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)
|
return c.actor.MakeUnsignedCall(c.hash, "delete", nil, containerID, signature, publicKey, token)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +480,17 @@ func (e *DeleteSuccessEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
index++
|
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 {
|
if err != nil {
|
||||||
return fmt.Errorf("field ContainerID: %w", err)
|
return fmt.Errorf("field ContainerID: %w", err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue