Skip to content

Commit

Permalink
Fixed NEthereum linking
Browse files Browse the repository at this point in the history
  • Loading branch information
Eugene Alekseev committed Apr 26, 2022
1 parent a701abd commit 06241a9
Show file tree
Hide file tree
Showing 13 changed files with 106 additions and 23 deletions.
2 changes: 1 addition & 1 deletion Assets/AnkrSDK/Examples/Scripts/DTO/TransferEventDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using AnkrSDK.Core.Data;
using Nethereum.ABI.FunctionEncoding.Attributes;

namespace AnkrSDK.Examples.DTO
namespace AnkrSDK.DTO
{
[Event("Transfer")]
public class TransferEventDTO : EventDTOBase
Expand Down
4 changes: 2 additions & 2 deletions Assets/AnkrSDK/Examples/Scripts/ERC20Example/ERC20Example.cs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
using System;
using System;
using System.Numerics;
using AnkrSDK.Core.Data;
using AnkrSDK.Core.Data.ContractMessages.ERC721;
using AnkrSDK.Core.Events.Implementation;
using AnkrSDK.Core.Implementation;
using AnkrSDK.Core.Infrastructure;
using AnkrSDK.Examples.DTO;
using AnkrSDK.DTO;
using AnkrSDK.UseCases;
using Nethereum.RPC.Eth.DTOs;
using UnityEngine;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
using AnkrSDK.Core.Data.ContractMessages.ERC721;
using AnkrSDK.Core.Implementation;
using AnkrSDK.Core.Infrastructure;
using AnkrSDK.Examples.DTO;
using AnkrSDK.DTO;
using AnkrSDK.UseCases;
using Nethereum.RPC.Eth.DTOs;
using UnityEngine;
Expand Down Expand Up @@ -51,9 +51,9 @@ public async void GetEvents()
{
var filters = new EventFilterData()
{
fromBlock = BlockParameter.CreateEarliest(),
toBlock = BlockParameter.CreateLatest(),
filterTopic2 = new [] { EthHandler.DefaultAccount }
FromBlock = BlockParameter.CreateEarliest(),
ToBlock = BlockParameter.CreateLatest(),
FilterTopic2 = new [] { EthHandler.DefaultAccount }
};
var events = await _erc721Contract.GetEvents<TransferEventDTO>(filters);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using AnkrSDK.Core.Data;
using AnkrSDK.Core.Implementation;
using AnkrSDK.Core.Infrastructure;
using AnkrSDK.Examples.DTO;
using AnkrSDK.DTO;
using AnkrSDK.Examples.ERC20Example;
using AnkrSDK.UseCases;
using Cysharp.Threading.Tasks;
Expand Down Expand Up @@ -45,7 +45,7 @@ public async UniTaskVoid SubscribeWithTopics()
{
var filters = new EventFilterData
{
filterTopic2 = new[] { EthHandler.DefaultAccount }
FilterTopic2 = new[] { EthHandler.DefaultAccount }
};

_subscription = await _eventSubscriber.Subscribe(
Expand All @@ -64,7 +64,7 @@ public async UniTaskVoid SubscribeWithRequest()
_subscription = await _eventSubscriber.Subscribe(
filtersRequest,
ERC20ContractInformation.ContractAddress,
(TransferEventDTO t) => ReceiveEvent(t)
ReceiveEvent
);
}

Expand Down
6 changes: 5 additions & 1 deletion Assets/AnkrSDK/Examples/UseCases/MobileUseCaseIndex.unity
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 0
m_IsActive: 1
--- !u!224 &588941422
RectTransform:
m_ObjectHideFlags: 0
Expand Down Expand Up @@ -1557,6 +1557,10 @@ PrefabInstance:
propertyPath: _ankrBannerAdSprite
value:
objectReference: {fileID: 1144955346}
- target: {fileID: 5976548454594715780, guid: 07258a25cdc3d4865ab09752afd70613, type: 3}
propertyPath: m_IsActive
value: 1
objectReference: {fileID: 0}
- target: {fileID: 8547154265603219201, guid: 07258a25cdc3d4865ab09752afd70613, type: 3}
propertyPath: m_Name
value: UseCase-Ads
Expand Down
38 changes: 38 additions & 0 deletions Assets/AnkrSDK/Plugins/Nethereum/link.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<linker>
<assembly fullname="System" preserve="all">
<type fullname="System.ComponentModel.TypeConverter" preserve="all"/>
<type fullname="System.ComponentModel.ArrayConverter" preserve="all"/>
<type fullname="System.ComponentModel.BaseNumberConverter" preserve="all"/>
<type fullname="System.ComponentModel.BooleanConverter" preserve="all"/>
<type fullname="System.ComponentModel.ByteConverter" preserve="all"/>
<type fullname="System.ComponentModel.CharConverter" preserve="all"/>
<type fullname="System.ComponentModel.CollectionConverter" preserve="all"/>
<type fullname="System.ComponentModel.ComponentConverter" preserve="all"/>
<type fullname="System.ComponentModel.CultureInfoConverter" preserve="all"/>
<type fullname="System.ComponentModel.DateTimeConverter" preserve="all"/>
<type fullname="System.ComponentModel.DecimalConverter" preserve="all"/>
<type fullname="System.ComponentModel.DoubleConverter" preserve="all"/>
<type fullname="System.ComponentModel.EnumConverter" preserve="all"/>
<type fullname="System.ComponentModel.ExpandableObjectConverter" preserve="all"/>
<type fullname="System.ComponentModel.Int16Converter" preserve="all"/>
<type fullname="System.ComponentModel.Int32Converter" preserve="all"/>
<type fullname="System.ComponentModel.Int64Converter" preserve="all"/>
<type fullname="System.ComponentModel.NullableConverter" preserve="all"/>
<type fullname="System.ComponentModel.SByteConverter" preserve="all"/>
<type fullname="System.ComponentModel.SingleConverter" preserve="all"/>
<type fullname="System.ComponentModel.StringConverter" preserve="all"/>
<type fullname="System.ComponentModel.TimeSpanConverter" preserve="all"/>
<type fullname="System.ComponentModel.UInt16Converter" preserve="all"/>
<type fullname="System.ComponentModel.UInt32Converter" preserve="all"/>
<type fullname="System.ComponentModel.UInt64Converter" preserve="all"/>
</assembly>
<assembly fullname="Nethereum.ABI" preserve="all"/>
<assembly fullname="Nethereum.Hex" preserve="all"/>
<assembly fullname="Nethereum.RPC" preserve="all"/>
<assembly fullname="Nethereum.RLP" preserve="all"/>
<assembly fullname="Nethereum.Contracts" preserve="all"/>
<assembly fullname="Nethereum.Util" preserve="all"/>
<assembly fullname="Nethereum.Signer" preserve="all"/>
<assembly fullname="Nethereum.JsonRpc.Client" preserve="all"/>
<assembly fullname="Nethereum.Unity" preserve="all"/>
</linker>
7 changes: 7 additions & 0 deletions Assets/AnkrSDK/Plugins/Nethereum/link.xml.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions Assets/AnkrSDK/Scripts/Core/AoT.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions Assets/AnkrSDK/Scripts/Core/AoT/AoTSetup.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
using System.Numerics;
using AnkrSDK.Core.Data.ContractMessages.ERC721;
using AnkrSDK.Core.Data.ContractMessages.ERC721.RentableExtension;
using AnkrSDK.Examples.GameCharacterContract;
using Nethereum.Web3;

namespace AnkrSDK.Core.AoT
{
public static class AoTSetup
{
private static void SetupAoT()
{
var web3 = new Web3();
var contractHandler = web3.Eth.GetContractHandler("");
contractHandler.QueryAsync<Data.ContractMessages.ERC721.BalanceOfMessage, BigInteger>();
contractHandler.QueryAsync<Data.ContractMessages.ERC1155.BalanceOfMessage, BigInteger>();
contractHandler.QueryAsync<GetHatMessage, BigInteger>();
contractHandler.QueryAsync<GetShoesMessage, BigInteger>();
contractHandler.QueryAsync<TotalSupplyMessage, BigInteger>();
contractHandler.QueryAsync<TokenOfOwnerByIndexMessage, BigInteger>();
contractHandler.QueryAsync<TokenByIndexMessage, BigInteger>();
contractHandler.QueryAsync<TokenURIMessage, string>();
contractHandler.QueryAsync<OwnerOfMessage, string>();
contractHandler.QueryAsync<NameMessage, string>();
contractHandler.QueryAsync<SymbolMessage, string>();
contractHandler.QueryAsync<PrincipalOwnerMessage, string>();
contractHandler.QueryAsync<IsApprovedForAllMessage, bool>();
contractHandler.QueryAsync<GetApprovedMessage, bool>();
contractHandler.QueryAsync<IsRentedMessage, bool>();
}
}
}
3 changes: 3 additions & 0 deletions Assets/AnkrSDK/Scripts/Core/AoT/AoTSetup.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 0 additions & 4 deletions Assets/AnkrSDK/Scripts/Core/Data/EventDTOBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,5 @@ namespace AnkrSDK.Core.Data
{
public class EventDTOBase : IEventDTO
{
public EventDTOBase()
{

}
}
}
12 changes: 6 additions & 6 deletions Assets/AnkrSDK/Scripts/Core/Data/EventFilterData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ namespace AnkrSDK.Core.Data
{
public class EventFilterData
{
public object[] filterTopic1 { get; set; }
public object[] filterTopic2 { get; set; }
public object[] filterTopic3 { get; set; }
public BlockParameter fromBlock { get; set; }
public BlockParameter toBlock { get; set; }
public object[] FilterTopic1 { get; set; }
public object[] FilterTopic2 { get; set; }
public object[] FilterTopic3 { get; set; }
public BlockParameter FromBlock { get; set; }
public BlockParameter ToBlock { get; set; }

public bool AreTopicsFilled()
{
return filterTopic1 != null || filterTopic2 != null || filterTopic3 != null;
return FilterTopic1 != null || FilterTopic2 != null || FilterTopic3 != null;
}
}
}
4 changes: 2 additions & 2 deletions Assets/AnkrSDK/Scripts/Core/Utils/EventFilterHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public static NewFilterInput CreateEventFilters<TEvDto>(string contractAddress,
{
var eventABI = ABITypedRegistry.GetEvent<TEvDto>();

var ethFilterInput = FilterInputBuilder.GetDefaultFilterInput(contractAddress, evFilter?.fromBlock, evFilter?.toBlock);
var ethFilterInput = FilterInputBuilder.GetDefaultFilterInput(contractAddress, evFilter?.FromBlock, evFilter?.ToBlock);
if (evFilter != null && evFilter.AreTopicsFilled())
{
ethFilterInput.Topics = eventABI.GetTopicBuilder()
.GetTopics(evFilter.filterTopic1, evFilter.filterTopic2, evFilter.filterTopic3);
.GetTopics(evFilter.FilterTopic1, evFilter.FilterTopic2, evFilter.FilterTopic3);
}

return ethFilterInput;
Expand Down

0 comments on commit 06241a9

Please sign in to comment.