Merge pull request #2695 from nspcc-dev/call-version
interop: implement System.Contract.CallWithVersion
This commit is contained in:
commit
29564bdda2
29 changed files with 95 additions and 43 deletions
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/engine
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/events
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/iterator
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -3,8 +3,8 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd-nns
|
|||
go 1.17
|
||||
|
||||
require (
|
||||
github.com/nspcc-dev/neo-go v0.99.4-0.20220920064337-0477f83ea87e
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
github.com/nspcc-dev/neo-go v0.99.4-0.20220921144034-25667914faf5
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
github.com/stretchr/testify v1.7.0
|
||||
)
|
||||
|
||||
|
|
|
@ -198,12 +198,12 @@ github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRW
|
|||
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 h1:n4ZaFCKt1pQJd7PXoMJabZWK9ejjbLOVrkl/lOUmshg=
|
||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22/go.mod h1:79bEUDEviBHJMFV6Iq6in57FEOCMcRhfQnfaf0ETA5U=
|
||||
github.com/nspcc-dev/neo-go v0.99.2-pre.0.20220809124015-119b40c37815 h1:tk05Q+2Fi6VRI6whnxrn5fh1cK1VKZ/MqLaLkCQzlPg=
|
||||
github.com/nspcc-dev/neo-go v0.99.2-pre.0.20220809124015-119b40c37815/go.mod h1:9P0yWqhZX7i/ChJ+zjtiStO1uPTolPFUM+L5oNznU8E=
|
||||
github.com/nspcc-dev/neo-go v0.99.4-0.20220920064337-0477f83ea87e h1:kWNDuDjY1TKa8CyFcRrhc+y6Vg466IyKznPb3bpm8dc=
|
||||
github.com/nspcc-dev/neo-go v0.99.4-0.20220920064337-0477f83ea87e/go.mod h1:sZxLhLjdbk1/YIUAfrGemaHLZmnq6H8lyQMfo75sNbw=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go v0.99.4-0.20220921144034-25667914faf5 h1:Ws7+4nbejBl6tpknmAOtaHQDY0DSmtkdjhsTHnbfosY=
|
||||
github.com/nspcc-dev/neo-go v0.99.4-0.20220921144034-25667914faf5/go.mod h1:NraCCLE6Ky5F3zjuAiv45gaN08AZtDvs41cYofXTibA=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/rfc6979 v0.2.0 h1:3e1WNxrN60/6N0DW7+UYisLeZJyfqZTNOjeV/toYvOE=
|
||||
github.com/nspcc-dev/rfc6979 v0.2.0/go.mod h1:exhIh1PdpDC5vQmyEsGvc4YDM/lyQp/452QxGq/UEso=
|
||||
github.com/nxadm/tail v1.4.4 h1:DQuhQpB1tVlglWS2hLQ5OV6B5r8aGxSrPc5Qo6uTN78=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/oracle
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/runtime
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/storage
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/timer
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
2
go.mod
2
go.mod
|
@ -13,7 +13,7 @@ require (
|
|||
github.com/mr-tron/base58 v1.2.0
|
||||
github.com/nspcc-dev/dbft v0.0.0-20220902113116-58a5e763e647
|
||||
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659
|
||||
github.com/nspcc-dev/rfc6979 v0.2.0
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible
|
||||
|
|
4
go.sum
4
go.sum
|
@ -260,8 +260,8 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
|
|||
github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
|
||||
github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg=
|
||||
github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ=
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/oracle
|
|||
|
||||
go 1.17
|
||||
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2
|
||||
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2 h1:BC/DKmjW+ArkqXTQjbVt7XubCJnDiCenH0pUI15gUyQ=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220920063704-7e13140b04c2/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde h1:lCxgDeSYpP71aGVKIllNYEMySlZPZGaYFMdwy2y8PZs=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220921143844-8bcf36a91dde/go.mod h1:23bBw0v6pBYcrWs8CBEEDIEDJNbcFoIh8pGGcf2Vv8s=
|
||||
|
|
|
@ -13,6 +13,7 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/core/dao"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/native"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/native/nativenames"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/state"
|
||||
"github.com/nspcc-dev/neo-go/pkg/core/storage"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
|
@ -519,3 +520,31 @@ func TestCallTConversionErrors(t *testing.T) {
|
|||
require.Error(t, err)
|
||||
})
|
||||
}
|
||||
|
||||
func TestCallWithVersion(t *testing.T) {
|
||||
bc, acc := chain.NewSingle(t)
|
||||
e := neotest.NewExecutor(t, bc, acc, acc)
|
||||
src := `package foo
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
util "github.com/nspcc-dev/neo-go/pkg/interop/lib/contract"
|
||||
)
|
||||
func CallWithVersion(hash interop.Hash160, version int, method string) interface{} {
|
||||
return util.CallWithVersion(hash, version, method, contract.All)
|
||||
}`
|
||||
ctr := neotest.CompileSource(t, e.CommitteeHash, strings.NewReader(src), &compiler.Options{Name: "Helper"})
|
||||
e.DeployContract(t, ctr, nil)
|
||||
c := e.CommitteeInvoker(ctr.Hash)
|
||||
|
||||
policyH := state.CreateNativeContractHash(nativenames.Policy)
|
||||
t.Run("good", func(t *testing.T) {
|
||||
c.Invoke(t, e.Chain.GetBaseExecFee(), "callWithVersion", policyH.BytesBE(), 0, "getExecFeeFactor")
|
||||
})
|
||||
t.Run("unknown contract", func(t *testing.T) {
|
||||
c.InvokeFail(t, "unknown contract", "callWithVersion", util.Uint160{1, 2, 3}.BytesBE(), 0, "getExecFeeFactor")
|
||||
})
|
||||
t.Run("invalid version", func(t *testing.T) {
|
||||
c.InvokeFail(t, "contract version mismatch", "callWithVersion", policyH.BytesBE(), 1, "getExecFeeFactor")
|
||||
})
|
||||
}
|
||||
|
|
23
pkg/interop/lib/contract/contract.go
Normal file
23
pkg/interop/lib/contract/contract.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package contract
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/contract"
|
||||
"github.com/nspcc-dev/neo-go/pkg/interop/native/management"
|
||||
)
|
||||
|
||||
// CallWithVersion is a utility function that executes the previously deployed
|
||||
// blockchain contract with the specified version (update counter) and hash
|
||||
// (20 bytes in BE form) using the provided arguments and call flags. It fails
|
||||
// if the contract has version mismatch. It returns whatever this contract
|
||||
// returns. This function uses `System.Contract.Call` syscall.
|
||||
func CallWithVersion(scriptHash interop.Hash160, version int, method string, f contract.CallFlag, args ...interface{}) interface{} {
|
||||
cs := management.GetContract(scriptHash)
|
||||
if cs == nil {
|
||||
panic("unknown contract")
|
||||
}
|
||||
if cs.UpdateCounter != version {
|
||||
panic("contract version mismatch")
|
||||
}
|
||||
return contract.Call(scriptHash, method, f, args...)
|
||||
}
|
|
@ -225,7 +225,7 @@ func AppCallNoArgs(w *io.BinWriter, scriptHash util.Uint160, operation string, f
|
|||
Syscall(w, interopnames.SystemContractCall)
|
||||
}
|
||||
|
||||
// AppCall emits an APPCALL with the default parameters to the given operation and arguments.
|
||||
// AppCall emits SYSCALL with System.Contract.Call parameter for given contract, operation, call flag and arguments.
|
||||
func AppCall(w *io.BinWriter, scriptHash util.Uint160, operation string, f callflag.CallFlag, args ...interface{}) {
|
||||
Array(w, args...)
|
||||
AppCallNoArgs(w, scriptHash, operation, f)
|
||||
|
|
Loading…
Reference in a new issue