Add public key as argument for container_contract.Delete() method #28

Merged
fyrchik merged 1 commit from acid-ant/frostfs-contract:feature/27-cnt-del-add-arg into master 2023-06-16 11:54:53 +00:00
2 changed files with 8 additions and 8 deletions

View file

@ -310,7 +310,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, token []byte) {
func Delete(containerID []byte, signature interop.Signature, publicKey interop.PublicKey, token []byte) {
Review

It should break compatibility with current version of the node. For the Neo VM Delete() with 3 arguments and Delete() with 4 arguments are completely different methods.

I suggest to add one more method and reuse the code of Delete() method. See Put() and PutNamed() methods. So newer versions of node will use new method and older versions stick with current Delete() method.

It should break compatibility with current version of the node. For the Neo VM `Delete()` with 3 arguments and `Delete()` with 4 arguments are completely different methods. I suggest to add one more method and reuse the code of `Delete()` method. See `Put()` and `PutNamed()` methods. So newer versions of node will use new method and older versions stick with current `Delete()` method.
Review

However, if we don't care about compatibility there for some reason, this is okay.

However, if we don't care about compatibility there for some reason, this is okay.
Review
We can mark it as deprecated and use https://github.com/nspcc-dev/neo-go/blob/master/docs/compiler.md#Overloads .
Review
We can mark it as deprecated and use https://github.com/nspcc-dev/neo-go/blob/master/docs/compiler.md#Overloads .
Review

Let's break compatibility because we don't have any public networks to be compatible with.

Let's break compatibility because we don't have any public networks to be compatible with.
ctx := storage.GetContext()
ownerID := getOwnerByID(ctx, containerID)

View file

@ -105,15 +105,15 @@ func TestContainerCount(t *testing.T) {
c.Invoke(t, stackitem.Null{}, "put", cnt3.value, cnt3.sig, cnt3.pub, cnt3.token)
checkContainerList(t, c, [][]byte{cnt1.id[:], cnt2.id[:], cnt3.id[:]})
c.Invoke(t, stackitem.Null{}, "delete", cnt1.id[:], cnt1.sig, cnt1.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt1.id[:], cnt1.sig, cnt1.pub, cnt1.token)
checkCount(t, 2)
checkContainerList(t, c, [][]byte{cnt2.id[:], cnt3.id[:]})
c.Invoke(t, stackitem.Null{}, "delete", cnt2.id[:], cnt2.sig, cnt2.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt2.id[:], cnt2.sig, cnt2.pub, cnt2.token)
checkCount(t, 1)
checkContainerList(t, c, [][]byte{cnt3.id[:]})
c.Invoke(t, stackitem.Null{}, "delete", cnt3.id[:], cnt3.sig, cnt3.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt3.id[:], cnt3.sig, cnt3.pub, cnt3.token)
checkCount(t, 0)
checkContainerList(t, c, [][]byte{})
}
@ -201,7 +201,7 @@ func TestContainerPut(t *testing.T) {
c.InvokeFail(t, "name is already taken", "putNamed", putArgs...)
})
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
cNNS.Invoke(t, stackitem.Null{}, "resolve", "mycnt.frostfs", int64(nns.TXT))
t.Run("register in advance", func(t *testing.T) {
@ -244,14 +244,14 @@ func TestContainerDelete(t *testing.T) {
acc, cnt := addContainer(t, c, cBal)
cAcc := c.WithSigners(acc)
cAcc.InvokeFail(t, common.ErrAlphabetWitnessFailed, "delete",
cnt.id[:], cnt.sig, cnt.token)
cnt.id[:], cnt.sig, cnt.pub, cnt.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
t.Run("missing container", func(t *testing.T) {
id := cnt.id
id[0] ^= 0xFF
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.token)
c.Invoke(t, stackitem.Null{}, "delete", cnt.id[:], cnt.sig, cnt.pub, cnt.token)
})
c.InvokeFail(t, container.NotFoundError, "get", cnt.id[:])