-
Notifications
You must be signed in to change notification settings - Fork 244
ABI to C# code Generation with Blockchain events support #1059
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
Merged
Merged
Changes from 24 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e3d9a98
Renamed some things, made a foundation for the class generator. More …
kantagara 455b53f
Added ICustomContract Interface which all custom contracts will iplement
kantagara 9777e80
Basics done
kantagara 1b48090
Indentation fixes
kantagara b89908a
Removed contract and added a safe guard
kantagara 84ef8ac
Cleanups
kantagara 2bb641f
Adding event subscription possibility, more extensions coming soon.
kantagara fbf0e01
Adding possibility to add websocket into the server settings
kantagara d05568e
Added Event Support.
kantagara 4eea22e
Merge branch 'dev' into nikola/abi-generation
kantagara bfed918
Updated the dlls. Removed TestContract.
kantagara f4738a0
Removed IContractBuilderExtensions
kantagara 5896863
Added more safeguards
kantagara ba8eda3
Fixing Server Settings
kantagara bf0fbef
More fixes.
kantagara 18890ff
Started the work on the class conversion.
kantagara 86ebef2
More work on Custom types.
kantagara 981fb5b
Added a Generic Call to contract so that we can return an actual type…
kantagara cbbf176
Merge branch 'dev' into nikola/abi-generation
kantagara 438a62b
Fixing conflicts with Dev
kantagara 46f22c3
Fixing linter issues
kantagara b7fc141
Removed unnecessary txt file
kantagara 65d8a12
Merge branch 'dev' into nikola/abi-generation
kantagara 369a563
Fixing merge conflicts from dev
kantagara 15b5010
Fixing oleks suggestions
kantagara 98196c4
Fixing names in ABI Converter
kantagara 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
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity.hyperplay/Runtime/Libraries/ChainSafe.Gaming.HyperPlay.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...web3-unity.lootboxes/Chainlink/Runtime/Libraries/ChainSafe.Gaming.Lootboxes.Chainlink.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
...chainsafe.web3-unity.lootboxes/Chainlink/Runtime/Libraries/Chainsafe.Gaming.Chainlink.dll
Binary file not shown.
496 changes: 496 additions & 0 deletions
496
Packages/io.chainsafe.web3-unity/Editor/ABICSharpConverter.cs
Large diffs are not rendered by default.
Oops, something went wrong.
11 changes: 11 additions & 0 deletions
11
Packages/io.chainsafe.web3-unity/Editor/ABICSharpConverter.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or 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 hidden or 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
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Debugging.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Gelato.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessSigner.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
....chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.InProcessTransactionExecutor.dll
Binary file not shown.
Binary file modified
BIN
+1.5 KB
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Marketplace.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.SygmaClient.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.EthereumWindow.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.MetaMask.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.ThirdParty.dll
Binary file not shown.
Binary file modified
BIN
+512 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.Unity.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.WalletConnect.dll
Binary file not shown.
Binary file modified
BIN
+20 KB
(110%)
Packages/io.chainsafe.web3-unity/Runtime/Libraries/ChainSafe.Gaming.dll
Binary file not shown.
125 changes: 125 additions & 0 deletions
125
Packages/io.chainsafe.web3-unity/Runtime/Resources/ABIContractClassTemplate.txt
This file contains hidden or 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,125 @@ | ||
| using System.Threading.Tasks; | ||
| using System; | ||
| using ChainSafe.Gaming.Evm.Transactions; | ||
| using Nethereum.Hex.HexTypes; | ||
| using ChainSafe.Gaming.Evm.Contracts; | ||
| using System.Numerics; | ||
| using Nethereum.RPC.Reactive.Eth.Subscriptions; | ||
| using Nethereum.JsonRpc.WebSocketStreamingClient; | ||
| using Nethereum.ABI.FunctionEncoding.Attributes; | ||
| using Nethereum.Contracts; | ||
| using UnityEngine; | ||
|
|
||
|
|
||
|
|
||
| namespace ChainSafe.Gaming.Evm.Contracts.Custom | ||
| { | ||
| public class {CLASS_NAME} : ICustomContract | ||
| { | ||
|
|
||
| public string ABI => "{CONTRACT_ABI}"; | ||
|
|
||
| public string ContractAddress { get; set; } | ||
|
|
||
| public IContractBuilder ContractBuilder { get; set; } | ||
|
|
||
| public Contract OriginalContract { get; set; } | ||
|
|
||
| public string WebSocketUrl { get; set; } | ||
|
|
||
| public bool Subscribed { get; set; } | ||
|
|
||
| private StreamingWebSocketClient _webSocketClient; | ||
|
|
||
| #region Methods | ||
| {METHODS} | ||
| #endregion | ||
|
|
||
|
|
||
| #region Event Classes | ||
| {EVENT_CLASSES} | ||
| #endregion | ||
|
|
||
| #region Interface Implemented Methods | ||
|
|
||
| public async ValueTask DisposeAsync() | ||
| { | ||
| if(string.IsNullOrEmpty(WebSocketUrl)) | ||
| return; | ||
| if(!Subscribed) | ||
| return; | ||
| Subscribed = false; | ||
| {EVENT_UNSUBSCRIPTION} | ||
| _webSocketClient?.Dispose(); | ||
| } | ||
|
|
||
| public async ValueTask Init() | ||
| { | ||
| if(Subscribed) | ||
| return; | ||
|
|
||
| if(string.IsNullOrEmpty(WebSocketUrl)) | ||
| { | ||
| Debug.LogWarning($"WebSocketUrl is not set for this class. Event Subscriptions will not work."); | ||
| return; | ||
| } | ||
|
|
||
| _webSocketClient ??= new StreamingWebSocketClient(WebSocketUrl); | ||
| await _webSocketClient.StartAsync(); | ||
| Subscribed = true; | ||
|
|
||
| {EVENT_SUBSCRIPTION} | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public IContract Attach(string address) | ||
| { | ||
| return OriginalContract.Attach(address); | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public Task<object[]> Call(string method, object[] parameters = null, TransactionRequest overwrite = null) | ||
| { | ||
| return OriginalContract.Call(method, parameters, overwrite); | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public object[] Decode(string method, string output) | ||
| { | ||
| return OriginalContract.Decode(method, output); | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public Task<object[]> Send(string method, object[] parameters = null, TransactionRequest overwrite = null) | ||
| { | ||
| return OriginalContract.Send(method, parameters, overwrite); | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public Task<(object[] response, TransactionReceipt receipt)> SendWithReceipt(string method, object[] parameters = null, TransactionRequest overwrite = null) | ||
| { | ||
| return OriginalContract.SendWithReceipt(method, parameters, overwrite); | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public Task<HexBigInteger> EstimateGas(string method, object[] parameters, TransactionRequest overwrite = null) | ||
| { | ||
| return OriginalContract.EstimateGas(method, parameters, overwrite); | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public string Calldata(string method, object[] parameters = null) | ||
| { | ||
| return OriginalContract.Calldata(method, parameters); | ||
| } | ||
|
|
||
| [Obsolete("It's not advisable to use this method. Use the pre-generated methods instead.")] | ||
| public Task<TransactionRequest> PrepareTransactionRequest(string method, object[] parameters, TransactionRequest overwrite = null) | ||
| { | ||
| return OriginalContract.PrepareTransactionRequest(method, parameters, overwrite); | ||
| } | ||
| #endregion | ||
| } | ||
|
|
||
| {CUSTOM_CLASSES} | ||
| } |
7 changes: 7 additions & 0 deletions
7
Packages/io.chainsafe.web3-unity/Runtime/Resources/ABIContractClassTemplate.txt.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.