-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
- Loading branch information
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Nethereum.JsonRpc.Client; | ||
|
||
namespace MoralisWeb3ApiSdk | ||
{ | ||
/// <summary> | ||
/// | ||
/// </summary> | ||
public class DeadRpcReadClient : IClient | ||
{ | ||
private Action<string> messageHandler; | ||
public DeadRpcReadClient(Action<string> msgHandler) | ||
{ | ||
messageHandler = msgHandler; | ||
} | ||
|
||
public RequestInterceptor OverridingRequestInterceptor { get => throw new NotImplementedException(); set => throw new NotImplementedException(); } | ||
|
||
public Task<T> SendRequestAsync<T>(RpcRequest request, string route = null) | ||
{ | ||
if (messageHandler != null) | ||
{ | ||
messageHandler($"Method {request.Method} is not supported by this RPC handler"); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public Task<T> SendRequestAsync<T>(string method, string route = null, params object[] paramList) | ||
{ | ||
if (messageHandler != null) | ||
{ | ||
messageHandler($"Method {method} is not supported by this RPC handler"); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public Task SendRequestAsync(RpcRequest request, string route = null) | ||
{ | ||
if (messageHandler != null) | ||
{ | ||
messageHandler($"Method {request.Method} is not supported by this RPC handler"); | ||
} | ||
|
||
return null; | ||
} | ||
|
||
public Task SendRequestAsync(string method, string route = null, params object[] paramList) | ||
{ | ||
if (messageHandler != null) | ||
{ | ||
messageHandler($"Method {method} is not supported by this RPC handler"); | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* Module: EvmContractInstance.cs | ||
* Descriptiontion: Class that wraps specifica copontract / chain instnace | ||
* Author: Moralis Web3 Technology AB, 559307-5988 - David B. Goodrich | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021 Moralis Web3 Technology AB, 559307-5988 | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
using Assets.Scripts.Moralis; | ||
using Nethereum.Contracts; | ||
|
||
namespace MoralisWeb3ApiSdk | ||
{ | ||
/// <summary> | ||
/// Defines specific copontract / chain instnace | ||
/// </summary> | ||
public class EvmContractInstance | ||
{ | ||
/// <summary> | ||
/// Contract address on this chain. | ||
/// </summary> | ||
public string ContractAddress { get; set; } | ||
/// <summary> | ||
/// Contract Instance derived from ABI | ||
/// </summary> | ||
public Contract ContractInstance { get; set; } | ||
/// <summary> | ||
/// Evm Chain information. | ||
/// </summary> | ||
public ChainEntry ChainInfo { get; set; } | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
/** | ||
* Module: EvmContractItem.cs | ||
* Descriptiontion: Class that wraps a list on Nethereum contract instances by chain | ||
* Author: Moralis Web3 Technology AB, 559307-5988 - David B. Goodrich | ||
* | ||
* MIT License | ||
* | ||
* Copyright (c) 2021 Moralis Web3 Technology AB, 559307-5988 | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in all | ||
* copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
* SOFTWARE. | ||
*/ | ||
using System.Collections.Generic; | ||
using Assets.Scripts.Moralis; | ||
using Nethereum.Contracts; | ||
using Nethereum.Web3; | ||
|
||
namespace MoralisWeb3ApiSdk | ||
{ | ||
/// <summary> | ||
/// Wraps a list on Nethereum contract instances by chain | ||
/// </summary> | ||
public class EvmContractItem | ||
{ | ||
/// <summary> | ||
/// the raw contract ABI | ||
/// </summary> | ||
public string Abi { get; set; } | ||
|
||
/// <summary> | ||
/// Contract instance by chain | ||
/// </summary> | ||
public Dictionary<string, EvmContractInstance> ChainContractMap { get; set; } | ||
|
||
public EvmContractItem() | ||
{ | ||
ChainContractMap = new Dictionary<string, EvmContractInstance>(); | ||
} | ||
|
||
public EvmContractItem(Web3 client, string abi, string chainId, string contractAddress) | ||
{ | ||
ChainContractMap = new Dictionary<string, EvmContractInstance>(); | ||
this.Abi = abi; | ||
|
||
AddChainInstance(client, chainId, contractAddress); | ||
} | ||
|
||
/// <summary> | ||
/// Add a contract instance for a specific chain. | ||
/// </summary> | ||
/// <param name="client"></param> | ||
/// <param name="chainId"></param> | ||
/// <param name="contractAddress"></param> | ||
public void AddChainInstance(Web3 client, string chainId, string contractAddress) | ||
{ | ||
if (!ChainContractMap.ContainsKey(chainId)) | ||
{ | ||
ChainEntry chainInfo = SupportedEvmChains.FromChainList(chainId); | ||
Contract contractInstance = client.Eth.GetContract(this.Abi, contractAddress); | ||
EvmContractInstance eci = new EvmContractInstance() | ||
{ | ||
ChainInfo = chainInfo, | ||
ContractAddress = contractAddress, | ||
ContractInstance = contractInstance | ||
}; | ||
|
||
ChainContractMap.Add(chainId, eci); | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.