Skip to content

Commit

Permalink
Initial migration to e2e example
Browse files Browse the repository at this point in the history
  • Loading branch information
juanfranblanco committed Feb 19, 2022
1 parent 85de471 commit 482e422
Show file tree
Hide file tree
Showing 13 changed files with 667 additions and 811 deletions.
15 changes: 15 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"overrides": [
{
"files": "*.sol",
"options": {
"printWidth": 280,
"tabWidth": 20,
"useTabs": false,
"singleQuote": false,
"bracketSpacing": false,
"explicitTypes": "always"
}
}
]
}
12 changes: 12 additions & 0 deletions .solhint.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"rules": {


"func-name-mixedcase": "error",
"func-param-name-mixedcase": "error",
"modifier-name-mixedcase": "error",
"private-vars-leading-underscore": "error",
"var-name-mixedcase": "error",
"imports-on-top": "error"
}
}
4 changes: 3 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{
"solidity.compileUsingRemoteVersion": "v0.7.6+commit.7338295f"
"telemetry.enableCrashReporter": false,


}
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,14 @@ public ERC721PresetMinterPauserAutoIdTests(EthereumClientIntegrationFixture ethe
public async void ShouldDeployAndMintNFTToken()
{

var destinationAddress = "0x6C547791C3573c2093d81b919350DB1094707011";
//Using rinkeby to demo opensea, if we dont want to use the configured client
var web3 = _ethereumClientIntegrationFixture.GetInfuraWeb3(InfuraNetwork.Rinkeby);
//var web3 = _ethereumClientIntegrationFixture.GetWeb3();

//using https://my-json-server.typicode.com/ to host the metadata database, this creates and auto json server api based on data hosted in github
//see https://github.com/juanfranblanco/samplenftdb/blob/main/db.json
var erc721PresetMinter = new ERC721PresetMinterPauserAutoIdDeployment() {
BaseURI = "https://my-json-server.typicode.com/juanfranblanco/samplenftdb/tokens/",
Name = "NFTArt",
Symbol = "NFA"};
var erc721PresetMinter = new ERC721PresetMinterPauserAutoIdDeployment() {BaseURI = "https://my-json-server.typicode.com/juanfranblanco/samplenftdb/tokens/", Name = "NFTArt", Symbol = "NFA"};

//Deploy the erc721Minter
var deploymentReceipt = await ERC721PresetMinterPauserAutoIdService.DeployContractAndWaitForReceiptAsync(web3, erc721PresetMinter);
Expand Down

This file was deleted.

2 changes: 1 addition & 1 deletion ERC721ContractLibrary/ERC721ContractLibrary.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include = "Nethereum.Web3" Version="3.8.0" />
<PackageReference Include = "Nethereum.Web3" Version="4.2.0" />
</ItemGroup>

</Project>

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,33 @@
using Nethereum.Contracts.ContractHandlers;
using Nethereum.Contracts;
using System.Threading;
using ERC721ContractLibrary.Contracts.ERC721PresetMinterPauserAutoId.ContractDefinition;
using ERC721ContractLibrary.Contracts.ERC721EnumerableUriStorage.ContractDefinition;

namespace ERC721ContractLibrary.Contracts.ERC721PresetMinterPauserAutoId
namespace ERC721ContractLibrary.Contracts.ERC721EnumerableUriStorage
{
public partial class ERC721PresetMinterPauserAutoIdService
public partial class ERC721EnumerableUriStorageService
{
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, ERC721PresetMinterPauserAutoIdDeployment eRC721PresetMinterPauserAutoIdDeployment, CancellationTokenSource cancellationTokenSource = null)
public static Task<TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, ERC721EnumerableUriStorageDeployment eRC721EnumerableUriStorageDeployment, CancellationTokenSource cancellationTokenSource = null)
{
return web3.Eth.GetContractDeploymentHandler<ERC721PresetMinterPauserAutoIdDeployment>().SendRequestAndWaitForReceiptAsync(eRC721PresetMinterPauserAutoIdDeployment, cancellationTokenSource);
return web3.Eth.GetContractDeploymentHandler<ERC721EnumerableUriStorageDeployment>().SendRequestAndWaitForReceiptAsync(eRC721EnumerableUriStorageDeployment, cancellationTokenSource);
}

public static Task<string> DeployContractAsync(Nethereum.Web3.Web3 web3, ERC721PresetMinterPauserAutoIdDeployment eRC721PresetMinterPauserAutoIdDeployment)
public static Task<string> DeployContractAsync(Nethereum.Web3.Web3 web3, ERC721EnumerableUriStorageDeployment eRC721EnumerableUriStorageDeployment)
{
return web3.Eth.GetContractDeploymentHandler<ERC721PresetMinterPauserAutoIdDeployment>().SendRequestAsync(eRC721PresetMinterPauserAutoIdDeployment);
return web3.Eth.GetContractDeploymentHandler<ERC721EnumerableUriStorageDeployment>().SendRequestAsync(eRC721EnumerableUriStorageDeployment);
}

public static async Task<ERC721PresetMinterPauserAutoIdService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, ERC721PresetMinterPauserAutoIdDeployment eRC721PresetMinterPauserAutoIdDeployment, CancellationTokenSource cancellationTokenSource = null)
public static async Task<ERC721EnumerableUriStorageService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, ERC721EnumerableUriStorageDeployment eRC721EnumerableUriStorageDeployment, CancellationTokenSource cancellationTokenSource = null)
{
var receipt = await DeployContractAndWaitForReceiptAsync(web3, eRC721PresetMinterPauserAutoIdDeployment, cancellationTokenSource);
return new ERC721PresetMinterPauserAutoIdService(web3, receipt.ContractAddress);
var receipt = await DeployContractAndWaitForReceiptAsync(web3, eRC721EnumerableUriStorageDeployment, cancellationTokenSource);
return new ERC721EnumerableUriStorageService(web3, receipt.ContractAddress);
}

protected Nethereum.Web3.Web3 Web3{ get; }

public ContractHandler ContractHandler { get; }

public ERC721PresetMinterPauserAutoIdService(Nethereum.Web3.Web3 web3, string contractAddress)
public ERC721EnumerableUriStorageService(Nethereum.Web3.Web3 web3, string contractAddress)
{
Web3 = web3;
ContractHandler = web3.Eth.GetContractHandler(contractAddress);
Expand Down Expand Up @@ -64,17 +64,6 @@ public Task<byte[]> MINTER_ROLEQueryAsync(BlockParameter blockParameter = null)
return ContractHandler.QueryAsync<MINTER_ROLEFunction, byte[]>(null, blockParameter);
}

public Task<byte[]> PAUSER_ROLEQueryAsync(PAUSER_ROLEFunction pAUSER_ROLEFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<PAUSER_ROLEFunction, byte[]>(pAUSER_ROLEFunction, blockParameter);
}


public Task<byte[]> PAUSER_ROLEQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<PAUSER_ROLEFunction, byte[]>(null, blockParameter);
}

public Task<string> ApproveRequestAsync(ApproveFunction approveFunction)
{
return ContractHandler.SendRequestAsync(approveFunction);
Expand Down Expand Up @@ -117,43 +106,6 @@ public Task<BigInteger> BalanceOfQueryAsync(string owner, BlockParameter blockPa
return ContractHandler.QueryAsync<BalanceOfFunction, BigInteger>(balanceOfFunction, blockParameter);
}

public Task<string> BaseURIQueryAsync(BaseURIFunction baseURIFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<BaseURIFunction, string>(baseURIFunction, blockParameter);
}


public Task<string> BaseURIQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<BaseURIFunction, string>(null, blockParameter);
}

public Task<string> BurnRequestAsync(BurnFunction burnFunction)
{
return ContractHandler.SendRequestAsync(burnFunction);
}

public Task<TransactionReceipt> BurnRequestAndWaitForReceiptAsync(BurnFunction burnFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(burnFunction, cancellationToken);
}

public Task<string> BurnRequestAsync(BigInteger tokenId)
{
var burnFunction = new BurnFunction();
burnFunction.TokenId = tokenId;

return ContractHandler.SendRequestAsync(burnFunction);
}

public Task<TransactionReceipt> BurnRequestAndWaitForReceiptAsync(BigInteger tokenId, CancellationTokenSource cancellationToken = null)
{
var burnFunction = new BurnFunction();
burnFunction.TokenId = tokenId;

return ContractHandler.SendRequestAndWaitForReceiptAsync(burnFunction, cancellationToken);
}

public Task<string> GetApprovedQueryAsync(GetApprovedFunction getApprovedFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<GetApprovedFunction, string>(getApprovedFunction, blockParameter);
Expand Down Expand Up @@ -279,18 +231,20 @@ public Task<TransactionReceipt> MintRequestAndWaitForReceiptAsync(MintFunction m
return ContractHandler.SendRequestAndWaitForReceiptAsync(mintFunction, cancellationToken);
}

public Task<string> MintRequestAsync(string to)
public Task<string> MintRequestAsync(string to, string newTokenURI)
{
var mintFunction = new MintFunction();
mintFunction.To = to;
mintFunction.NewTokenURI = newTokenURI;

return ContractHandler.SendRequestAsync(mintFunction);
}

public Task<TransactionReceipt> MintRequestAndWaitForReceiptAsync(string to, CancellationTokenSource cancellationToken = null)
public Task<TransactionReceipt> MintRequestAndWaitForReceiptAsync(string to, string newTokenURI, CancellationTokenSource cancellationToken = null)
{
var mintFunction = new MintFunction();
mintFunction.To = to;
mintFunction.NewTokenURI = newTokenURI;

return ContractHandler.SendRequestAndWaitForReceiptAsync(mintFunction, cancellationToken);
}
Expand Down Expand Up @@ -320,37 +274,6 @@ public Task<string> OwnerOfQueryAsync(BigInteger tokenId, BlockParameter blockPa
return ContractHandler.QueryAsync<OwnerOfFunction, string>(ownerOfFunction, blockParameter);
}

public Task<string> PauseRequestAsync(PauseFunction pauseFunction)
{
return ContractHandler.SendRequestAsync(pauseFunction);
}

public Task<string> PauseRequestAsync()
{
return ContractHandler.SendRequestAsync<PauseFunction>();
}

public Task<TransactionReceipt> PauseRequestAndWaitForReceiptAsync(PauseFunction pauseFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(pauseFunction, cancellationToken);
}

public Task<TransactionReceipt> PauseRequestAndWaitForReceiptAsync(CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync<PauseFunction>(null, cancellationToken);
}

public Task<bool> PausedQueryAsync(PausedFunction pausedFunction, BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<PausedFunction, bool>(pausedFunction, blockParameter);
}


public Task<bool> PausedQueryAsync(BlockParameter blockParameter = null)
{
return ContractHandler.QueryAsync<PausedFunction, bool>(null, blockParameter);
}

public Task<string> RenounceRoleRequestAsync(RenounceRoleFunction renounceRoleFunction)
{
return ContractHandler.SendRequestAsync(renounceRoleFunction);
Expand Down Expand Up @@ -605,25 +528,5 @@ public Task<TransactionReceipt> TransferFromRequestAndWaitForReceiptAsync(string

return ContractHandler.SendRequestAndWaitForReceiptAsync(transferFromFunction, cancellationToken);
}

public Task<string> UnpauseRequestAsync(UnpauseFunction unpauseFunction)
{
return ContractHandler.SendRequestAsync(unpauseFunction);
}

public Task<string> UnpauseRequestAsync()
{
return ContractHandler.SendRequestAsync<UnpauseFunction>();
}

public Task<TransactionReceipt> UnpauseRequestAndWaitForReceiptAsync(UnpauseFunction unpauseFunction, CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync(unpauseFunction, cancellationToken);
}

public Task<TransactionReceipt> UnpauseRequestAndWaitForReceiptAsync(CancellationTokenSource cancellationToken = null)
{
return ContractHandler.SendRequestAndWaitForReceiptAsync<UnpauseFunction>(null, cancellationToken);
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<Authors>Juan Blanco</Authors>
<Authors>Juan Blanco</Authors>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Binder" Version="5.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="5.0.0" />
<PackageReference Include="Nethereum.Web3" Version="3.8.0" />
<PackageReference Include="Nethereum.Web3" Version="4.2.0" />
<PackageReference Include="xunit" Version="2.3.1" />
</ItemGroup>
</Project>
Loading

0 comments on commit 482e422

Please sign in to comment.