-
Notifications
You must be signed in to change notification settings - Fork 1k
Implement NEP-17 #2024
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
Changes from 13 commits
c937be2
a374286
427a595
1da0df6
153c250
8179ae3
2d909a0
bbffc39
772b566
ec0264a
7b59c50
a87d7f3
ec77bc9
5074b27
fde07e8
849ce9a
2f4ae86
9bb5e85
fb0128e
a4e9e5b
259be1e
7aef12a
41a0871
93c4cfd
2d6d40a
af57798
6a03132
dfb2f06
202c005
de0fabb
d43e7ee
ce9876b
5f7630d
b774259
a75d5f0
6734e60
06517a5
d33ff2f
93f6f5c
134e024
fff5001
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -68,7 +68,21 @@ internal protected virtual void Mint(ApplicationEngine engine, UInt160 account, | |
| state.Balance += amount; | ||
| storage = engine.Snapshot.Storages.GetAndChange(CreateStorageKey(Prefix_TotalSupply), () => new StorageItem(BigInteger.Zero)); | ||
| storage.Add(amount); | ||
| engine.SendNotification(Hash, "Transfer", new Array { StackItem.Null, account.ToArray(), amount }); | ||
| onPostTransfer(engine, null, account, amount); | ||
| } | ||
|
|
||
| private void onPostTransfer(ApplicationEngine engine, UInt160 from, UInt160 to, BigInteger amount) | ||
| { | ||
| // Send notification | ||
|
|
||
| engine.SendNotification(Hash, "Transfer", | ||
| new Array { from == null ? StackItem.Null : from.ToArray(), to == null ? StackItem.Null : to.ToArray(), amount }); | ||
|
|
||
| if (!engine.ContractExists(to, "onPayment")) return; | ||
|
||
|
|
||
| // Call onPayment method if exists | ||
|
|
||
| engine.CallContractInternal(to, "onPayment", new Array(engine.ReferenceCounter) { amount }, CallFlags.All, ApplicationEngine.CheckReturnType.DropResult); | ||
| } | ||
|
|
||
| internal protected virtual void Burn(ApplicationEngine engine, UInt160 account, BigInteger amount) | ||
|
|
@@ -86,7 +100,7 @@ internal protected virtual void Burn(ApplicationEngine engine, UInt160 account, | |
| state.Balance -= amount; | ||
| storage = engine.Snapshot.Storages.GetAndChange(CreateStorageKey(Prefix_TotalSupply)); | ||
| storage.Add(-amount); | ||
| engine.SendNotification(Hash, "Transfer", new Array { account.ToArray(), StackItem.Null, amount }); | ||
| onPostTransfer(engine, account, null, amount); | ||
| } | ||
|
|
||
| [ContractMethod(0_01000000, CallFlags.AllowStates)] | ||
|
|
@@ -105,7 +119,7 @@ public virtual BigInteger BalanceOf(StoreView snapshot, UInt160 account) | |
| return storage.GetInteroperable<TState>().Balance; | ||
| } | ||
|
|
||
| [ContractMethod(0_08000000, CallFlags.AllowModifyStates)] | ||
| [ContractMethod(0_09000000, CallFlags.AllowModifyStates)] | ||
| protected virtual bool Transfer(ApplicationEngine engine, UInt160 from, UInt160 to, BigInteger amount) | ||
| { | ||
| if (amount.Sign < 0) throw new ArgumentOutOfRangeException(nameof(amount)); | ||
|
|
@@ -146,7 +160,7 @@ protected virtual bool Transfer(ApplicationEngine engine, UInt160 from, UInt160 | |
| state_to.Balance += amount; | ||
| } | ||
| } | ||
| engine.SendNotification(Hash, "Transfer", new Array { from.ToArray(), to.ToArray(), amount }); | ||
| onPostTransfer(engine, from, to, amount); | ||
| return true; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.