Roman Khimov
1b83dc2476
*: improve for loop syntax
...
Mostly it's about Go 1.22+ syntax with ranging over integers, but it also
prefers ranging over slices where possible (it makes code a little better to
read).
Notice that we have a number of dangerous loops where slices are mutated
during loop execution, many of these can't be converted since we need proper
length evalutation at every iteration.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:45:18 +03:00
Roman Khimov
a50723ff72
*: use cmp.Or where appropriate
...
It's slightly less efficient (all comparisons are always made), but for
strings/ints it's negligible performance difference, while the code looks a
tiny bit better.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
d5b7fc54e7
manifest: deduplicate test logic a bit with slices.Concat
...
LIkely it's more readable this way.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 17:00:11 +03:00
Roman Khimov
49438798b5
manifest: deduplicate duplicate-checking code
...
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
db820cb0dc
manifest: rework method duplicate check
...
Don't use an additional type, it's inconvenient and this method is not
performance-critical.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
7f1690a840
manifest: use slices.SortFunc, deduplicate PermissionDesc code
...
Simplify Less and Equals, fix Equals as well for PermissionWildcard (it was
reporting false erroneously).
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
de665b5567
*: use slices.Sort() where appropriate
...
It's always faster for simple types.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
a30792dbb6
*: use slices.Index/slices.Contains where appropriate
...
This doesn't touch performance-sensitive parts, but simplifies a lot of code.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-27 08:24:52 +03:00
Roman Khimov
9e112fc024
*: use slices.Clone instead of make/copy
...
It's much easier this way.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-24 22:41:48 +03:00
Anna Shaleva
2c7430583c
smartcontrct: take care of manifest permission descriptor wildcardness
...
Starting from b10af1ed31
(*WildPermissionDescs).Add method's call is not enough to construct a
proper restricted permission descriptor, because Wildcard field should
be set properly at the same time. Ref. #3523 .
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2024-08-05 16:05:59 +03:00
Roman Khimov
b10af1ed31
manifest: make default trusts invalid
...
Refs. #3522 . The core problem is the same as for groups/features: we can't
allow empty trusts when they're unmarshalled from JSON. But unlike others we
can't easily differentiate missing any value with other cases because the
default value for WildPermissionDescs is a valid thing. Adding an additional
field makes it invalid and we can build around it. Other options are
implementing custom UnmarshalJSON for Manifest (too much for this) or making
Trusts a pointer (an option, but can fail in too many ways).
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-26 15:18:25 +03:00
Roman Khimov
58ab24efdb
manifest: don't accept manifests with invalid features
...
Refs. #3522 .
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-26 15:18:25 +03:00
Roman Khimov
e861aeec2e
manifest: disallow null groups, fix #3522
...
IsValid() is used by both compiler and ContractManagement then.
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-07-26 11:22:44 +03:00
Ekaterina Pavlova
ae3515e819
crypto: add StringCompressed() for PublicKey
...
Add StringCompressed to get a string representation of the key in
compressed form.
Close #3263
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-04-11 15:24:46 +03:00
Ekaterina Pavlova
baac738ec3
smartcontract: add test of extraToStackItem with double quotes
...
C# double quotes marshalling compatibility test.
Refs #3284
Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
2024-01-12 11:18:24 +03:00
Anna Shaleva
910d53b27b
core: do not check manifest size on deploy/update
...
Manifest will be a part of the state.Contract which will be checked on its
way to the storage. Tiny optimisation which allows not to serialize manifest
twice. Ref. https://github.com/nspcc-dev/neo-go/pull/3218#discussion_r1402374232 .
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-22 20:17:09 +03:00
Anna Shaleva
6824bd9f40
smartcontract: require manifest serialization in (*Manifest).IsValid
...
Port the restrictive part of https://github.com/neo-project/neo/pull/2948 .
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-22 19:39:03 +03:00
Anna Shaleva
fdcc369d60
manifest: add compatibility test for Permissions and Trust serialization
...
We already have tests for Permission deserialisation, so port the first
part of https://github.com/neo-project/neo/pull/2948 .
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-11-18 13:32:28 +03:00
Anna Shaleva
2581146a01
smartcontract: fix wildcard trusts deserialization
...
If manifest trusts presented as Null stackitem, then they should be
treated as wildcard, not as restricted.
It's not the same problem as described and fixed in
https://github.com/neo-project/neo/pull/2901 and
https://github.com/neo-project/neo/pull/2892 , although these
two PRs are related.
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-09-25 11:53:47 +03:00
Anna Shaleva
60795a899f
smartcontract: improve invalid notification error text
...
Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
2023-08-18 12:02:43 +03:00
Roman Khimov
433275265f
*: use require.ErrorIs instead of require.True(t, error.Is())
...
This is just a much better way to do the same thing. Inspired by
nspcc-dev/neofs-sdk-go#407 .
Signed-off-by: Roman Khimov <roman@nspcc.ru>
2023-05-04 17:03:47 +03:00
Anna Shaleva
6b21ad9922
*: replace interface{}
with any
keyword
...
Everywhere including examples, external interop APIs, bindings generators
code and in other valuable places. A couple of `interface{}` usages are
intentionally left in the CHANGELOG.md, documentation and tests.
2023-04-04 13:22:42 +03:00
Roman Khimov
e0eff94094
standard: correct Comply* comments
2022-10-27 18:32:00 +03:00
Roman Khimov
64b603b056
standard: export standard definitions
...
Make Comply* functions useful and expose standard definitions for some reuse.
2022-10-27 18:32:00 +03:00
Roman Khimov
79887f9d78
runtime: check notifications against ABI
...
Related to #2703 , just a logged thing for now.
2022-10-04 17:52:38 +03:00
Anna Shaleva
15732580eb
smartcontract: improve manifest validness errors
...
It should be clear from error what's wrong with ABI
(specify bad method/event/parameter identifier).
2022-08-22 14:59:28 +03:00
Anna Shaleva
725e8779a1
compiler: always ensure manifest passes base check
2022-08-02 17:37:43 +03:00
Elizaveta Chichindaeva
28908aa3cf
[ #2442 ] English Check
...
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Anna Shaleva
9c2e92d7d9
compiler: check overloaded methods for safeness one more time
...
It's possible that overloaded method is marked as `safe` in manifest, so
that it must have `save` field set to true after its name was
overwritten.
2022-01-21 18:03:04 +03:00
Anna Shaleva
fa1174ec7e
smartcontract: adjust NEP11-D standard
...
Method `ownerOf` returns iterator which should be of the type
InteropInterface.
2022-01-21 18:03:04 +03:00
Roman Khimov
ce9d0b22cf
*: use NEP-XX naming consistently in docs/comments
...
Standards are NEP-11 and NEP-17, not NEP11, not NEP17, not anything
else. Variable/function names of course can use whatever fits, but documents
and comments should be consistent wrt this.
2021-11-19 12:58:46 +03:00
Roman Khimov
9875799893
transaction: add new Rules witness scope
...
See neo-project/neo#2622 . The implementation is somewhat asymmetric (and not
very efficient) for binary/JSON encoding/decoding, but it should be
sufficient.
2021-11-12 15:29:28 +03:00
Anna Shaleva
dfc0b25cfe
gomod: use nspcc-dev's fork of go-ordered-json
...
Escape non-ASCII characters while JSON encoding.
2021-09-15 15:01:01 +03:00
Anna Shaleva
c0a2c74e0c
core: maintain a set of NEP17-compliant contracts
2021-07-28 13:22:53 +03:00
Evgeniy Stratonikov
c9e6350915
manifest: fix group permission handling
...
We need to have at least one matching group in the manifest.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-30 11:02:45 +03:00
Evgeniy Stratonikov
4283e1003f
manifest: fix wildcard permission handling
...
Wildcard contract can coexist with restricted set of methods.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-30 11:00:06 +03:00
Evgeniy Stratonikov
9c06ba6b07
smartcontract: marshal manifest Extra
field as object, fix #2021
...
This is needed to strip whitespace which can be present.
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-06-29 11:39:56 +03:00
Roman Khimov
b8ba923874
standard: improve testing code
...
staticcheck: SA4021: x = append(y) is equivalent to x = y
2021-05-12 19:12:09 +03:00
Roman Khimov
ba5273999f
Merge pull request #1950 from nspcc-dev/nep11/data
...
*: add `data` to NEP11 Transfer
2021-05-06 10:39:56 +03:00
Anna Shaleva
d0c64347ab
*: add data
to NEP11 Transfer
2021-05-05 19:44:29 +03:00
Anna Shaleva
efe9bee1ff
smartcontract: refactor manifest.FromStackItem test
...
We need a good case to ensure that error cases constructed well.
2021-05-05 18:54:42 +03:00
Anna Shaleva
50fc9bf766
smartcontract: use permission descriptors for manifest's trusts
2021-05-05 17:40:10 +03:00
Evgeniy Stratonikov
bb039ef035
manifest: add features
field
2021-05-04 13:10:46 +03:00
Anna Shaleva
28b78d1a6c
smartcontract: remove NEP10 standard name
...
It's unused.
2021-04-30 11:38:11 +03:00
Evgeniy Stratonikov
1cb25d3190
native: use proper types in manifest
2021-03-11 11:48:38 +03:00
Evgeniy Stratonikov
b38443fe20
smartcontract: add checks for onNEP*Payable methods
...
When they are present in contract, we want them
to have correct signature.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
d89f055697
smartcontract: add checks for parameter names
...
It can be annoying to use parameter names as specified by standard,
so a separate `CheckABI` is supported.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
9d4ccf0fcc
smartcontract: add test for Optional methods
...
They should be checked only if name + parameter count matches.
This is how methods are identified in NEO.
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
eb26a61078
smartcontract: remove IsNEP17()
2021-02-19 17:06:07 +03:00
Evgeniy Stratonikov
9c0bbd0bfd
smartcontract: add NEP-11 standard check
...
The only method missing is name, because it is
provided in manifest.
2021-02-19 17:06:07 +03:00