Commit graph

302 commits

Author SHA1 Message Date
Evgeniy Stratonikov
ec21c14ca9 gomod: upgrade yaml package from v2 to v3
Close #2085.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-05-30 15:26:17 +03:00
Elizaveta Chichindaeva
28908aa3cf [#2442] English Check
Signed-off-by: Elizaveta Chichindaeva <elizaveta@nspcc.ru>
2022-05-04 19:48:27 +03:00
Evgeniy Stratonikov
739db259e3 smartcontract: remove unused ParameterFromStackItem
It is exists from the times we used `smartcontract.Parameter` somewhere
in the `NotificationEvent`/`ApplicationLog`. `stackitem.ToJSON` now
handles this.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-04-01 08:38:35 +03:00
Evgeniy Stratonikov
fe0cd5fe32 smartcontract: remove EncodeBinary for Parameter
It seems, we don't use it anywhere.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-04-01 08:38:35 +03:00
Evgeniy Stratonikov
0b0d39f797 smartcontract: allow to use *big.Int numbers for integers
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-04-01 08:38:34 +03:00
Anna Shaleva
2096ad6e81 *: remove io/ioutil uses
Close #1764.
2022-03-17 19:39:18 +03:00
Roman Khimov
b65ab011fe
Merge pull request #2349 from nspcc-dev/codegen-contract
cli/smartcontract: generate bindings to an existing contract
2022-02-24 15:51:33 +03:00
Anna Shaleva
0357d9f4f4 smartcontract: add hash check to paramcontext
Close #2344.
2022-02-24 10:21:08 +03:00
Evgeniy Stratonikov
da03d895de cli/smartcontract: generate bindings to an existing contract
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-23 15:40:06 +03:00
Evgeniy Stratonikov
4aab85ef51 callflag: allow to marshal call flags in YAML
Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2022-02-21 10:43:35 +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
Roman Khimov
42a9d3d7b8 nef: add Source field
Follow neo-project/neo#2605.
2021-09-24 00:19:37 +03:00
Roman Khimov
68af14100c
Merge pull request #2174 from nspcc-dev/states-diff_testnet_284177
smartcontract: escape non-ascii characters for manifest.Extra SI
2021-09-15 15:07:25 +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
Evgeniy Stratonikov
918d7e65bf smartcontract: unmarhal null values properly
First we unmarshal `null` to `[]byte`, then we marshal it to the empty
string.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-09-14 13:28:01 +03:00
Anna Shaleva
61fd7bd6ba core: avoid nil values during natives manifest marshalling 2021-09-10 11:38:59 +03:00
Evgeniy Stratonikov
cff8b1c24e stackitem: use Bool item directly
It is always copied.

Signed-off-by: Evgeniy Stratonikov <evgeniy@nspcc.ru>
2021-08-12 17:53:36 +03:00
Roman Khimov
06c3dda5d1
Merge pull request #2093 from nspcc-dev/states-exchange/drop-nep17-balance-state
core: implement dynamic NEP17 balances tracking
2021-07-29 19:08:42 +03:00
Anna Shaleva
c0a2c74e0c core: maintain a set of NEP17-compliant contracts 2021-07-28 13:22:53 +03:00
Roman Khimov
6103da8d10 context: read item key in LE
Hi, neo-project/neo#938.
2021-07-23 12:43:04 +03:00
Roman Khimov
efb67a0ea3 context: scripts and signatures are base64-encoded in C# now
So use base64 too and add compatibility test. Unfortunately this breaks
support for old (hex-based) files, but those should be completed a long time
ago.
2021-07-23 11:57:35 +03:00
Roman Khimov
cbe1eeb08c smartcontract: add support for valueless Parameters
This is fine:
            {
               "type" : "Signature"
            },
2021-07-23 11:57:13 +03:00
Roman Khimov
59b4377f90 context: support Neo.Network.P2P.Payloads.Transaction type
C# now uses this one, so use it by default, but also accept old one.
2021-07-23 11:33:51 +03:00
Roman Khimov
ac126a300b callflag: add C#-compliant JSONization, fix #2040 2021-07-06 11:17:12 +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
9d2712573f *: enable godot linter and fix all its warnings
It's important for NeoGo to have clean documentation. No functional changes.
2021-05-12 23:17:03 +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
Anna Shaleva
4b933f88a7 core: simplify interop functions
We now have the only interop table (system interops).
2021-05-12 13:30:01 +03:00
Anna Shaleva
6d59689d9c core: rename Neo.Crypto.CheckMultisig interop 2021-05-11 18:38:14 +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
Anna Shaleva
28b74cb647 smartcontract: add ExpandParameterToEmitable method
It'll help to convert Parameter to a atandard type which then can be
emitted ass an array item.
2021-04-16 17:30:25 +03:00
Roman Khimov
d314f82db3 transaction: drop Network from Transaction
We only need it when signing/verifying.
2021-03-26 13:45:18 +03:00
Roman Khimov
df12adaa9e crypto: remove crypto.Verifiable interface
We can now verify any hash.Hashable thing.
2021-03-26 13:45:18 +03:00
Anna Shaleva
e5cdecfa9f core: fix transaction hashes 2021-03-18 17:57:54 +03:00
Roman Khimov
9d500b86fc context: s/hex/data/ for JSON
See neo-project/neo#2394.
2021-03-12 13:10:24 +03:00
Roman Khimov
dc980b5847 sc/context: add network magic into the context
See neo-project/neo#2393, we need this to be able to sign multisig
transactions.
2021-03-12 12:59:14 +03:00
Roman Khimov
4462a6a6b7 change block/tx/extensible signing process, fix #1741
Sign [magic, hash], see neo-project/neo#2314.
2021-03-12 11:27:50 +03:00
Roman Khimov
3e9bd0be72 smartcontract: use base64 encoding for verifiable items
See neo-project/neo#1199.
2021-03-11 19:55:20 +03:00
Evgeniy Stratonikov
1cb25d3190 native: use proper types in manifest 2021-03-11 11:48:38 +03:00
Anna Shaleva
9015e50847 core: refactor Neo.Crypto.CheckMultisigWithECDsaSecpr1
Rename it to Neo.Crypto.CheckMultisig and remove `message` parameter.
2021-03-10 21:46:05 +03:00
Evgeniy Stratonikov
106c27782e cli/wallet: allow to cosign with a contract
Contracts have empty verification script and their hash is
calculated differently.
2021-03-09 15:45:02 +03:00
Evgeniy Stratonikov
b9136dbfc0 smartcontract: use hash in GetWitness()
All necessary info must already be in context.
2021-03-09 15:45:02 +03:00
Evgeniy Stratonikov
20d2386414 smartcontract: use script instead of address in context 2021-03-09 15:45:02 +03:00
Evgeniy Stratonikov
7a176727ca smartcontract: add GetMajorityNodeCount() 2021-03-09 13:46:44 +03:00
Roman Khimov
abee3b5b05
Merge pull request #1722 from nspcc-dev/fix/nep11
smartcontract: add NEP-11 standard check
2021-02-22 22:27:09 +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
Anna Shaleva
488e75a246 cli: add filebytes parameter type 2021-02-19 10:52:45 +03:00
Anna Shaleva
0f1473897b core: temp manifest.Extra marshalling fix
Manifest.Extra still serialized as JSON message with undefined  order
of items, so it affects contract states dumps.
2021-02-12 23:48:30 +03:00
Roman Khimov
a3abdbd7f0 manifest: add duplicate events/methods checks to ABI
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
dc3967ae7b manifest: add manifest validity checks
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
284476c070 manifest: add Permission and Permissions validity checks
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
15ed905757 manifest: add validity checks for Parameter
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
f0c3066ef6 manifest: add method validity check
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
f3c761e4c2 manifest: move Parameter into a file of its own 2021-02-09 22:31:26 +03:00
Roman Khimov
0b2e9312af manifest: add event validity check
Refs. #1699.
2021-02-09 22:31:26 +03:00
Roman Khimov
f78e3fb290 manifest: move Event into a file of its own 2021-02-09 22:31:26 +03:00
Roman Khimov
e9ea89b4e3 manifest: add group signature length check
Refs. #1699.
2021-02-09 22:31:24 +03:00
Roman Khimov
296c7a10fc manifest: move Group code into a file of its own 2021-02-09 22:31:22 +03:00
Roman Khimov
1a4958b1d5 manifest: add ABI validity check
Some methods must be defined in a valid ABI. Refs. neo-project/neo#2263.
2021-02-08 13:27:39 +03:00
Roman Khimov
5ba074b4cf manifest: return an error from IsValid
Be more specific.
2021-02-08 12:04:57 +03:00
Roman Khimov
211fe307ee manifest: move ABI code into file of its own
Make it a little more convenient to work with it.
2021-02-08 11:55:16 +03:00
Roman Khimov
60dfffc574 manifest: remove no longer used Serializable interface
It was used when manifests were saved into JSON.
2021-02-08 10:52:53 +03:00
Roman Khimov
e4b5b59663
Merge pull request #1704 from nspcc-dev/binary_manifest
core: serialise manifest as stackitem
2021-02-05 23:58:07 +03:00
Roman Khimov
cd9b34416e native: call onNEP11Transfer for NEP-11 transfers
See neo-project/neo#2287.
2021-02-05 20:48:45 +03:00
Anna Shaleva
a2715404d0 core: serialise manifest as stackitem 2021-02-05 19:10:15 +03:00
Roman Khimov
a442e1530d native: rename onPayment into onNEP17Payment
Follow neo-project/neo#2287.
2021-02-05 16:09:51 +03:00
Evgeniy Stratonikov
73f888f02e core: allow to overload contract methods
Multiple methods with different parameter count can co-exist.
2021-01-27 12:51:07 +03:00
Evgeniy Stratonikov
719dceff77 nef: merge Compiler and Version fields 2021-01-19 11:19:28 +03:00
Evgeniy Stratonikov
0bbdee2ce1 nef: add Reserved bytes 2021-01-19 11:19:28 +03:00
Evgeniy Stratonikov
52843fc1bf nef: add Tokens field 2021-01-19 11:19:24 +03:00
Evgenii Stratonikov
dbe81f9b80 smartcontract: move flags to a separate package 2021-01-14 17:52:09 +03:00
Evgeniy Stratonikov
11191c0a08 nef: support JSON serialization 2021-01-13 15:26:35 +03:00
Roman Khimov
2e0fe370cf nef: lower MaxScriptLength
Follow neo-project/neo#2119 changes.
2020-12-14 15:24:15 +03:00
Roman Khimov
fc361213a7
Merge pull request #1608 from nspcc-dev/core/callflags
core: adjust call flags
2020-12-11 19:23:15 +03:00
Anna Shaleva
fadbae8997 core: rename call flags
Also new States flag is added and ReadOnly flag is adjusted.
2020-12-11 10:34:01 +03:00
Evgenii Stratonikov
ec1ff42872 manifest: add Safe flag for NEP-17 methods 2020-12-10 18:04:49 +03:00
Evgenii Stratonikov
ea4d14d20d manifest/standard: check Safe flag in Comply() 2020-12-08 13:47:05 +03:00
Evgenii Stratonikov
b7e86fa6a3 manifest: add Safe flag to method descriptor
`interop.Contex.AddMethod` sets `Safe` flag for native
contracts. This allows not to forget to change manifest
when changing call flags.
Also fixed invalid `Safe` flags for `Notary` and `Designate` contracts.
2020-12-08 13:27:43 +03:00
Roman Khimov
1672887123 nef: increase version field to 32 bytes
Follow recent C# changes.
2020-11-30 11:26:29 +03:00
Roman Khimov
4d0eaef510 nef: treat Version as string
Following changes in C# code and simpilifying things a lot.
2020-11-27 21:47:08 +03:00
Roman Khimov
e12c52f588 nef: change checksum calculation scheme
It's now being calculated for whole file, not just header.
2020-11-27 21:47:08 +03:00
Roman Khimov
0c7e727859 nef: drop scripthash
It's no longer a part of the file.
2020-11-27 21:47:08 +03:00
Roman Khimov
c5e39dfabf nef: forbid NEFs with zero-length scripts 2020-11-26 18:30:53 +03:00
Roman Khimov
b92ea2a48a manifest/compiler: drop hashes from ABI and debug info
See neo-project/neo-devpack-dotnet#391 and neo-project/neo#2044.
2020-11-26 18:30:49 +03:00
Roman Khimov
34d2eaf00e manifest: update maximum possible length
As per neo-project/neo#2002.
2020-11-26 18:07:20 +03:00
Evgenii Stratonikov
279b769fa3 manifest: support interface checking
There are some standards (NEP5, etc.) which impose
some restrictions on what methods and events a contract
must contain and their signatures. This commit supports
checking if arbitrary manifest complies with the standard.
2020-11-26 12:50:29 +03:00