Compare commits
6 commits
master
...
temp/suppo
Author | SHA1 | Date | |
---|---|---|---|
15fe9453ab | |||
dd6fe3f10e | |||
f7fe65fbea | |||
939dcb941e | |||
9d8a3c672c | |||
375289f8cf |
5 changed files with 90 additions and 17 deletions
|
@ -30,7 +30,7 @@ events:
|
||||||
- name: DeleteSuccess
|
- name: DeleteSuccess
|
||||||
parameters:
|
parameters:
|
||||||
- name: containerID
|
- name: containerID
|
||||||
type: Hash256
|
type: ByteArray
|
||||||
- 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 interop.Hash256, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
|
func Delete(containerID []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
|
||||||
ctx := storage.GetContext()
|
ctx := storage.GetContext()
|
||||||
|
|
||||||
ownerID := getOwnerByID(ctx, containerID)
|
ownerID := getOwnerByID(ctx, containerID)
|
||||||
|
|
|
@ -47,6 +47,12 @@ events:
|
||||||
type: ByteArray
|
type: ByteArray
|
||||||
- name: keys
|
- name: keys
|
||||||
type: Array
|
type: Array
|
||||||
|
- name: AlphabetUpdate
|
||||||
|
parameters:
|
||||||
|
- name: id
|
||||||
|
type: ByteArray
|
||||||
|
- name: alphabet
|
||||||
|
type: Array
|
||||||
- name: SetConfig
|
- name: SetConfig
|
||||||
parameters:
|
parameters:
|
||||||
- name: id
|
- name: id
|
||||||
|
|
|
@ -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 util.Uint256
|
ContainerID []byte
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 util.Uint256, signature []byte, publicKey *keys.PublicKey, token []byte) (util.Uint256, uint32, error) {
|
func (c *Contract) Delete(containerID []byte, 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 util.Uint256, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
func (c *Contract) DeleteTransaction(containerID []byte, 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 util.Uint256, signature []byte,
|
||||||
// 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 util.Uint256, signature []byte, publicKey *keys.PublicKey, token []byte) (*transaction.Transaction, error) {
|
func (c *Contract) DeleteUnsigned(containerID []byte, 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -502,17 +502,7 @@ func (e *DeleteSuccessEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
err error
|
err error
|
||||||
)
|
)
|
||||||
index++
|
index++
|
||||||
e.ContainerID, err = func(item stackitem.Item) (util.Uint256, error) {
|
e.ContainerID, err = arr[index].TryBytes()
|
||||||
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)
|
||||||
}
|
}
|
||||||
|
|
|
@ -50,6 +50,12 @@ type UnbindEvent struct {
|
||||||
Keys []any
|
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.
|
// SetConfigEvent represents "SetConfig" event emitted by the contract.
|
||||||
type SetConfigEvent struct {
|
type SetConfigEvent struct {
|
||||||
Id []byte
|
Id []byte
|
||||||
|
@ -704,6 +710,77 @@ func (e *UnbindEvent) FromStackItem(item *stackitem.Array) error {
|
||||||
return nil
|
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
|
// SetConfigEventsFromApplicationLog retrieves a set of all emitted events
|
||||||
// with "SetConfig" name from the provided [result.ApplicationLog].
|
// with "SetConfig" name from the provided [result.ApplicationLog].
|
||||||
func SetConfigEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetConfigEvent, error) {
|
func SetConfigEventsFromApplicationLog(log *result.ApplicationLog) ([]*SetConfigEvent, error) {
|
||||||
|
|
Loading…
Reference in a new issue