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

Multicall V2.5 implementation #624

Merged
merged 36 commits into from
Nov 2, 2023
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dbe0daa
Cherry picked
RyRy79261 Sep 18, 2023
44090fc
Added refrerences
RyRy79261 Sep 18, 2023
2ce589d
Cherry picked DTO files
RyRy79261 Sep 18, 2023
37c556c
Added config
RyRy79261 Sep 18, 2023
f638de6
Auto-duplicate Package Samples
RyRy79261 Sep 18, 2023
50f6dc1
Connecting to unity buttons
RyRy79261 Sep 19, 2023
a4bd33d
Merge remote-tracking branch 'origin/ryan/multicall-484' into ryan/mu…
RyRy79261 Sep 19, 2023
7f02774
Auto-duplicate Package Samples
RyRy79261 Sep 19, 2023
03f04bb
Function triggering
RyRy79261 Sep 20, 2023
de21a49
Merge remote-tracking branch 'origin/ryan/multicall-484' into ryan/mu…
RyRy79261 Sep 20, 2023
574f443
Trying to get call data to be accepted
RyRy79261 Sep 22, 2023
9e0d860
Refactored to contract style
RyRy79261 Sep 29, 2023
dcfdbf7
No idea how to get logic in to unity
RyRy79261 Oct 4, 2023
30bb556
Saved unity files
RyRy79261 Oct 4, 2023
547da9a
Finally referenced in the game
RyRy79261 Oct 5, 2023
878661c
Attempting to init packages
RyRy79261 Oct 6, 2023
664fb75
Pushing for support
RyRy79261 Oct 9, 2023
87d6c10
ambiguous method compile error and MultiCall already bound runtime er…
robGG1997 Oct 9, 2023
a2a6df3
ProjectConfig returning bool
RyRy79261 Oct 9, 2023
b2f5cb5
Works without multicall again
RyRy79261 Oct 9, 2023
50d8717
Calls are successful, return decode, not so much
RyRy79261 Oct 10, 2023
213498c
Results returned as expected
RyRy79261 Oct 11, 2023
4830c61
Merge branch 'main' into ryan/multicall-484
RyRy79261 Oct 11, 2023
723a6e0
Fixed merge, scripts still broken
RyRy79261 Oct 11, 2023
0222d91
Auto-duplicate Package Samples
RyRy79261 Oct 11, 2023
277d880
retrigger checks
kalambet Oct 16, 2023
75d2f66
Merge branch 'main' into ryan/multicall-484
RyRy79261 Oct 24, 2023
b50d502
Updated comments
RyRy79261 Oct 25, 2023
d23a2e3
Merge branch 'main' into ryan/multicall-484
RyRy79261 Oct 30, 2023
5499c98
rebuilt & removed file again
RyRy79261 Oct 30, 2023
624207e
Auto-duplicate Package Samples
RyRy79261 Oct 30, 2023
942e5fb
Rebuilt
RyRy79261 Oct 31, 2023
a083be8
Lint fix
RyRy79261 Oct 31, 2023
2b004dd
Merge branch 'main' into ryan/multicall-484
RyRy79261 Oct 31, 2023
d296204
Merge branch 'main' into ryan/multicall-484
RyRy79261 Nov 1, 2023
576f91f
Rebuilt
RyRy79261 Nov 1, 2023
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
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using ChainSafe.GamingSdk.Gelato.Dto;
using UnityEngine;


public class GelatoSample
{
private readonly Web3 _web3;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
using System.Threading.Tasks;
using System.Collections.Generic;
using System.Numerics;
using ChainSafe.Gaming.MultiCall;
using ChainSafe.Gaming.UnityPackage;
using ChainSafe.Gaming.Web3;
using Nethereum.ABI.FunctionEncoding;
using Nethereum.Contracts.QueryHandlers.MultiCall;
using Nethereum.Hex.HexConvertors.Extensions;
using UnityEngine;

public class MultiCallSample
{
private const string Erc20ContractAddress = "0x3E0C0447e47d49195fbE329265E330643eB42e6f";
private const string Erc20Account = "0xd25b827D92b0fd656A1c829933e9b0b836d5C3e2";

private readonly Web3 web3;

public MultiCallSample(Web3 web3)
{
this.web3 = web3;
}

public async Task ErcSamples()
{
var erc20Contract = web3.ContractBuilder.Build(ABI.ERC_20, Erc20ContractAddress);
var erc20BalanceOfCalldata = erc20Contract.Calldata(CommonMethod.BalanceOf, new object[]
{
Erc20Account
});

var erc20TotalSupplyCalldata = erc20Contract.Calldata(CommonMethod.TotalSupply, new object[]
{
});

var calls = new[]
{
new Call3Value()
{
Target = Erc20ContractAddress,
AllowFailure = true,
CallData = erc20BalanceOfCalldata.HexToByteArray(),
},
new Call3Value()
{
Target = Erc20ContractAddress,
AllowFailure = true,
CallData = erc20TotalSupplyCalldata.HexToByteArray(),
}
};

var multicallResultResponse = await web3.MultiCall().MultiCallAsync(calls);

Debug.Log(multicallResultResponse);

if (multicallResultResponse[0] != null && multicallResultResponse[0].Success)
{
var decodedBalanceOf = erc20Contract.Decode(CommonMethod.BalanceOf, multicallResultResponse[0].ReturnData.ToHex());
Debug.Log($"decodedBalanceOf {((BigInteger)decodedBalanceOf[0]).ToString()}");
}

if (multicallResultResponse[1] != null && multicallResultResponse[1].Success)
{
var decodedTotalSupply = erc20Contract.Decode(CommonMethod.TotalSupply, multicallResultResponse[1].ReturnData.ToHex());
Debug.Log($"decodedTotalSupply {((BigInteger)decodedTotalSupply[0]).ToString()}");
}

}

private static class CommonMethod
{
public const string BalanceOf = "balanceOf";
robGG1997 marked this conversation as resolved.
Show resolved Hide resolved
public const string Name = "name";
public const string Symbol = "symbol";
public const string Decimals = "decimals";
public const string TotalSupply = "totalSupply";
public const string OwnerOf = "ownerOf";
public const string TokenUri = "tokenURI";
public const string Uri = "uri";
public const string BalanceOfBatch = "balanceOfBatch";
public const string Transfer = "transfer";
public const string SafeTransferFrom = "safeTransferFrom";
}
}

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

Loading