-
Notifications
You must be signed in to change notification settings - Fork 102
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
Sync neo changes #391
Merged
Merged
Sync neo changes #391
Changes from 50 commits
Commits
Show all changes
55 commits
Select commit
Hold shift + click to select a range
4c2e79d
Initial commit
shargon f5f161b
Remove hash from ABI
shargon 38e0590
Clean lines
shargon 9c8e7db
Fixes
shargon 5379d41
Merge remote-tracking branch 'neo-project/master' into sync-nep17
shargon 7ad9b72
Fix some UT
shargon 4448877
Change name to manifest
shargon cc4cced
Merge branch 'master' into sync-nep17
shargon 88fa514
Update nuget
shargon 6947047
Update NEP17.cs
shargon c0db531
Merge branch 'master' into sync-nep17
shargon f4df31a
Fix more UT
shargon 2ec0748
Some fixes
shargon 9894e83
Fix Contract
shargon 821f834
Update NEP17.Owner.cs
shargon 057d5ba
Update NEP17.Methods.cs
shargon 9e79f27
Merge branch 'master' into sync-nep17
shargon af62c81
Add data to Transfer
shargon 32905b6
add data to onPayment
shargon 1650325
Remove name
shargon afad1b1
Merge branch 'master' into sync-nep17
shargon 425718f
Update src/Neo.Compiler.MSIL/Neo.Compiler.MSIL.csproj
shargon ecdb308
Fix NEF Version
shargon 0fafec4
Fix UT
shargon 0633281
Fix test
shargon 3de92ed
Add OnPayment() for Mint()
superboyiii 9110b42
Fix
superboyiii ba8a716
Fix
superboyiii c496fe8
Format
superboyiii da701ad
Format
superboyiii 2e4fc2c
Format
superboyiii 1cfec66
Update NEP17.Owner.cs
shargon e1eff81
Update templates/Template.NEP17.CSharp/NEP17.cs
shargon 560e161
Update templates/Template.NEP17.CSharp/NEP17.Methods.cs
shargon 0ef68d9
Update AssetStorage.cs
shargon b7d657a
Update AssetStorage.cs
shargon c75bb6b
Update AssetStorage.cs
shargon a33b14b
Merge pull request #9 from superboyiii/sync-nep17
shargon d1d2300
Update templates/Template.NEP17.CSharp/NEP17.cs
shargon 0b9fd67
Update templates/Template.NEP17.CSharp/NEP17.Methods.cs
shargon 0c27e44
Rename to ContractNameAttribute & fix invocation counter
shargon e3d02dc
Change mint
shargon 5db20de
Rename to IsDeployed
shargon ad2d89e
Use DisplayName
shargon c903184
Fix mint
shargon 882a721
Fix
shargon bd4c246
Optimize Mint
erikzhang 8d0d298
Remove GetTransactionAmount
erikzhang 493b278
Fix claim gas
erikzhang 15f9de1
Add IsValid
shargon 8d1e266
Update NEP17.Crowdsale.cs
erikzhang 0823a31
Update src/Neo.SmartContract.Framework/UInt160.cs
shargon 7992c3a
Remove Size from UInt160 and UInt256
erikzhang befe380
Update UInt256.cs
erikzhang a572293
Fix UT
erikzhang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
using Neo.SmartContract.Framework.Services.System; | ||
using System; | ||
using System.Numerics; | ||
|
||
namespace Template.NEP17.CSharp | ||
{ | ||
public partial class NEP17 : SmartContract | ||
{ | ||
public static void OnPayment(UInt160 from, BigInteger amount, object data) | ||
{ | ||
if (AssetStorage.GetPaymentStatus()) | ||
{ | ||
if (ExecutionEngine.CallingScriptHash == NEO.Hash) | ||
Mint(amount * TokensPerNEO); | ||
else if (ExecutionEngine.CallingScriptHash == GAS.Hash && from != null) | ||
Mint(amount * TokensPerGAS); | ||
erikzhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
else | ||
erikzhang marked this conversation as resolved.
Show resolved
Hide resolved
|
||
throw new Exception("Wrong calling script hash"); | ||
} | ||
else | ||
{ | ||
throw new Exception("Payment is disable on this contract!"); | ||
} | ||
} | ||
|
||
private static bool Mint(BigInteger amount) | ||
{ | ||
var totalSupply = TotalSupplyStorage.Get(); | ||
if (totalSupply <= 0) throw new Exception("Contract not deployed."); | ||
|
||
var avaliable_supply = MaxSupply - totalSupply; | ||
|
||
if (amount <= 0) throw new Exception("Amount cannot be zero."); | ||
if (amount > avaliable_supply) throw new Exception("Insufficient supply for mint tokens."); | ||
|
||
Transaction tx = (Transaction)ExecutionEngine.ScriptContainer; | ||
AssetStorage.Increase(tx.Sender, amount); | ||
TotalSupplyStorage.Increase(amount); | ||
|
||
OnTransfer(null, tx.Sender, amount); | ||
return true; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using Neo; | ||
using Neo.SmartContract.Framework; | ||
using Neo.SmartContract.Framework.Services.Neo; | ||
|
||
namespace Template.NEP17.CSharp | ||
{ | ||
public partial class NEP17 : SmartContract | ||
{ | ||
private static bool ValidateAddress(UInt160 address) => address.IsValid && !address.IsZero; | ||
private static bool IsDeployed(UInt160 address) => Blockchain.GetContract(address) != null; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@devhawk do you need the name in
debugExport
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I need whatever unique identifier is used to identify the contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a design document describing how contract deploy and invoke is supposed to work now? I am all for having a stable contract identifier other than the script hash, though it's not clear what the new design is?
One question - Have we considered the impact on dynamic contract invocations scenarios. Using script hash to invoke a contract means that any calling contracts break when a dependent contract is updated. That is, I was calling a specific contract by script hash it will be obvious something has changed if that script hash is no longer valid. With a stable identifier, will it still be obvious if a dependent contract has made a backwards incompatible change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @devhawk, thinking in this perspective you mentioned, it may be important to create a flag that says that the contract trust any update on the dynamic invoked contract.
For instance, most of the DeFi projects are relying on external dynamic invoked contracts. In this sense, consider the need of mutual update is something plausible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect that dynamic invoke scenarios always require "mutual update" as you called it @vncoelho. I'm not sure it's a good idea to make the change less obvious. Right now, if you update your contract it breaks anyone who calls it since the hash changes. If we keep the hash, will that allow a developer to publish a malicious contract update w/o their users noticing?