Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement NEP-17 #2024

Merged
merged 41 commits into from
Nov 18, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
c937be2
If exists
shargon Oct 26, 2020
a374286
Call onPayment if to it's a smart contract
shargon Oct 27, 2020
427a595
Increase cost in transfer
shargon Oct 27, 2020
1da0df6
Merge branch 'master' into allow-call-if-exists
shargon Oct 27, 2020
153c250
Remove Mint check
shargon Oct 27, 2020
8179ae3
Merge remote-tracking branch 'origin/allow-call-if-exists' into allow…
shargon Oct 27, 2020
2d909a0
Merge branch 'master' into allow-call-if-exists
shargon Oct 28, 2020
bbffc39
return
shargon Oct 28, 2020
772b566
Remove extra args
shargon Oct 28, 2020
ec0264a
Drop result
shargon Oct 29, 2020
7b59c50
Merge branch 'master' into allow-call-if-exists
shargon Oct 29, 2020
a87d7f3
Clean code
shargon Oct 29, 2020
ec77bc9
Merge remote-tracking branch 'origin/allow-call-if-exists' into allow…
shargon Oct 29, 2020
5074b27
Merge branch 'master' into allow-call-if-exists
shargon Nov 4, 2020
fde07e8
Method.Exists
shargon Nov 4, 2020
849ce9a
Merge remote-tracking branch 'origin/allow-call-if-exists' into allow…
shargon Nov 4, 2020
2f4ae86
Rename
erikzhang Nov 5, 2020
9bb5e85
protected
erikzhang Nov 5, 2020
fb0128e
Update ApplicationEngine.Contract.cs
erikzhang Nov 5, 2020
a4e9e5b
Merge branch 'master' into allow-call-if-exists
shargon Nov 10, 2020
259be1e
Fix merge
shargon Nov 10, 2020
7aef12a
Merge branch 'master' into allow-call-if-exists
shargon Nov 12, 2020
41a0871
Add Name in Extra
shargon Nov 12, 2020
93c4cfd
Name in manifest
shargon Nov 12, 2020
2d6d40a
Merge remote-tracking branch 'neo-project/master' into allow-call-if-…
shargon Nov 12, 2020
af57798
Fix UT
shargon Nov 12, 2020
6a03132
dotnet format
shargon Nov 12, 2020
dfb2f06
Remove Method.Exists
shargon Nov 13, 2020
202c005
Clean code
shargon Nov 13, 2020
de0fabb
Move filed `Name`
erikzhang Nov 15, 2020
d43e7ee
Rename
erikzhang Nov 15, 2020
ce9876b
Update null checks
erikzhang Nov 15, 2020
5f7630d
Fix CallFromNativeContract parameters
erikzhang Nov 15, 2020
b774259
Update AssetDescriptor.cs
erikzhang Nov 15, 2020
a75d5f0
Fix UT
erikzhang Nov 15, 2020
6734e60
format
erikzhang Nov 15, 2020
06517a5
Shargon's suggestion
erikzhang Nov 17, 2020
d33ff2f
Update src/neo/SmartContract/Native/Tokens/Nep17Token.cs
erikzhang Nov 18, 2020
93f6f5c
Merge branch 'master' into allow-call-if-exists
erikzhang Nov 18, 2020
134e024
Fix
erikzhang Nov 18, 2020
fff5001
Merge branch 'master' into allow-call-if-exists
erikzhang Nov 18, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/neo/SmartContract/ApplicationEngine.Contract.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,17 @@ private void CallContractInternal(UInt160 contractHash, string method, Array arg
if (method.StartsWith('_')) throw new ArgumentException($"Invalid Method Name: {method}");

ContractState contract = Snapshot.Contracts.TryGet(contractHash);
if (contract is null) throw new InvalidOperationException($"Called Contract Does Not Exist: {contractHash}");
if (contract is null)
{
if (flags.HasFlag(CallFlags.IfExists)) return;
throw new InvalidOperationException($"Called Contract Does Not Exist: {contractHash}");
}
ContractMethodDescriptor md = contract.Manifest.Abi.GetMethod(method);
if (md is null) throw new InvalidOperationException($"Method {method} Does Not Exist In Contract {contractHash}");
if (md is null)
{
if (flags.HasFlag(CallFlags.IfExists)) return;
throw new InvalidOperationException($"Method {method} Does Not Exist In Contract {contractHash}");
}

ContractManifest currentManifest = Snapshot.Contracts.TryGet(CurrentScriptHash)?.Manifest;
if (currentManifest != null && !currentManifest.CanCall(contract.Manifest, method))
Expand Down
2 changes: 2 additions & 0 deletions src/neo/SmartContract/CallFlags.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ public enum CallFlags : byte
AllowCall = 0b00000100,
AllowNotify = 0b00001000,

IfExists = 0b10000000,

ReadOnly = AllowStates | AllowCall | AllowNotify,
All = AllowStates | AllowModifyStates | AllowCall | AllowNotify
erikzhang marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down