public async Task ShouldAddNewNftTemplate() { // Arrange Function <AddNewTemplateFunctionInput> aAddNewTemplateFunction = NftCreator.Instance.GetFunction <AddNewTemplateFunctionInput>(); Nethereum.Contracts.ContractHandlers.IContractTransactionHandler <AddNewTemplateFunctionInput> addNewTemplateFunctionHandler = NethWeb3.Instance.Eth.GetContractTransactionHandler <AddNewTemplateFunctionInput>(); var getNftRequest = new GetNftTypesServiceRequest(); GetNftTypesServiceResponse totalTypesBeforeTest = await Mediator.Send(getNftRequest); var aAddNewTemplateFunctionMessage = new AddNewTemplateFunctionInput { NewTemplateName = "Purchase Order", NewTemplateSymbol = "POR", NewTemplateAttachedTokens = 0, NewTemplateMintLimit = 10 }; Nethereum.Hex.HexTypes.HexBigInteger gasEstimate = await addNewTemplateFunctionHandler.EstimateGasAsync(NftCreatorAddresses.NftCreatorRinkebyAddress, aAddNewTemplateFunctionMessage); aAddNewTemplateFunctionMessage.Gas = gasEstimate.Value; gasEstimate.Value.ShouldBeGreaterThan(0); // Leaving this commented out as this is the action that makes a new template // it's been tested and works //Nethereum.RPC.Eth.DTOs.TransactionReceipt addingTemplateTransactionReceipt = await addNewTemplateFunctionHandler.SendRequestAndWaitForReceiptAsync(NftCreatorAddresses.NftCreatorRinkebyAddress, aAddNewTemplateFunctionMessage); //addingTemplateTransactionReceipt.ShouldNotBe(null); //GetNftTypesServiceResponse totalTypesAfterTest = await Mediator.Send(getNftRequest); //totalTypesAfterTest.TotalNftTypes.ShouldBeGreaterThan(totalTypesBeforeTest.TotalNftTypes); }
public async Task ShouldMintNftOfType() { // Arrange Function <MintNftOfTypeFunctionInput> aMintNftOfTypeFunction = NftCreator.Instance.GetFunction <MintNftOfTypeFunctionInput>(); Nethereum.Contracts.ContractHandlers.IContractTransactionHandler <MintNftOfTypeFunctionInput> MintNftOfTypeFunctionHandler = NethWeb3.Instance.Eth.GetContractTransactionHandler <MintNftOfTypeFunctionInput>(); //byte[] serializedImmutable = Serializer.Serialize(new ImmutableData()); //byte[] serializedMutable = Serializer.Serialize(new MutableData()); //string base64StringifiedSerializedImmutable = Convert.ToBase64String(serializedImmutable); //string base64StringifiedSerializedMutable = Convert.ToBase64String(serializedMutable); var aMintNftOfTypeFunctionMessage = new MintNftOfTypeFunctionInput { Type = 4, MutableDataString = "The Third Minted NFT!Take 3", ImmutableDataString = "This Is MintingTest 3" }; Nethereum.Hex.HexTypes.HexBigInteger gasEstimate = await MintNftOfTypeFunctionHandler.EstimateGasAsync(NftCreatorAddresses.NftCreatorRinkebyAddress, aMintNftOfTypeFunctionMessage); aMintNftOfTypeFunctionMessage.Gas = gasEstimate.Value; gasEstimate.Value.ShouldBeGreaterThan(0); //Nethereum.RPC.Eth.DTOs.TransactionReceipt MintNftOfTypeTransactionReceipt = await MintNftOfTypeFunctionHandler.SendRequestAndWaitForReceiptAsync(NftCreatorAddresses.NftCreatorRinkebyAddress, aMintNftOfTypeFunctionMessage); //System.Collections.Generic.List<EventLog<MintNftOutputEventDto>> MintNftOutput = MintNftOfTypeTransactionReceipt.DecodeAllEvents<MintNftOutputEventDto>(); //MintNftOfTypeTransactionReceipt.ShouldNotBe(null); //MintNftOutput.Count.ShouldBeGreaterThan(0); }
public async Task ShouldMintNftOfType() { // Arrange Function <MintNftOfTypeFunctionInput> aMintNftOfTypeFunction = NftCreator.Instance.GetFunction <MintNftOfTypeFunctionInput>(); Nethereum.Contracts.ContractHandlers.IContractTransactionHandler <MintNftOfTypeFunctionInput> mintNftOfTypeFunctionHandler = NethWeb3.Instance.Eth.GetContractTransactionHandler <MintNftOfTypeFunctionInput>(); var aMintNftOfTypeFunctionMessage = new MintNftOfTypeFunctionInput { NftId = 4, MutableDataString = "The Third Minted NFT!Take 3", ImmutableDataString = "This Is MintingTest 3" }; Nethereum.Hex.HexTypes.HexBigInteger gasEstimate = await mintNftOfTypeFunctionHandler.EstimateGasAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aMintNftOfTypeFunctionMessage); aMintNftOfTypeFunctionMessage.Gas = gasEstimate.Value; gasEstimate.Value.ShouldBeGreaterThan(0); }
public async Task <AddNewTemplateServiceResponse> Handle(AddNewTemplateServiceRequest aAddNewTemplateServiceRequest, CancellationToken aCancellationToken) { Function <AddNewTemplateFunctionInput> aAddNewTemplateFunction = NftCreatorInstance.Instance.GetFunction <AddNewTemplateFunctionInput>(); Nethereum.Contracts.ContractHandlers.IContractTransactionHandler <AddNewTemplateFunctionInput> addNewTemplateFunctionHandler = NethWeb3.Instance.Eth.GetContractTransactionHandler <AddNewTemplateFunctionInput>(); var aAddNewTemplateFunctionMessage = new AddNewTemplateFunctionInput { NewTemplateName = aAddNewTemplateServiceRequest.NewTemplateName, NewTemplateSymbol = aAddNewTemplateServiceRequest.NewTemplateSymbol, NewTemplateAttachedTokens = aAddNewTemplateServiceRequest.NewTemplateAttachedTokens, NewTemplateMintLimit = aAddNewTemplateServiceRequest.NewTemplateMintLimit }; // Gas Estimates, needs to be tested Nethereum.Hex.HexTypes.HexBigInteger gasEstimate = await addNewTemplateFunctionHandler.EstimateGasAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aAddNewTemplateFunctionMessage); aAddNewTemplateFunctionMessage.Gas = gasEstimate.Value; Nethereum.RPC.Eth.DTOs.TransactionReceipt mintingTransactionReceipt = await addNewTemplateFunctionHandler.SendRequestAndWaitForReceiptAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aAddNewTemplateFunctionMessage); return(new AddNewTemplateServiceResponse { NewTemplateTransactionReceipt = mintingTransactionReceipt }); }
public async Task <MintNftOfTypeServiceResponse> Handle(MintNftOfTypeServiceRequest aMintNftOfTypeServiceRequest, CancellationToken aCancellationToken) { Function <MintNftOfTypeFunctionInput> aMintNftOfTypeFunction = NftCreatorInstance.Instance.GetFunction <MintNftOfTypeFunctionInput>(); Nethereum.Contracts.ContractHandlers.IContractTransactionHandler <MintNftOfTypeFunctionInput> mintingHandler = NethWeb3.Instance.Eth.GetContractTransactionHandler <MintNftOfTypeFunctionInput>(); // serialization needed var aMintNftOfTypeFunctionMessage = new MintNftOfTypeFunctionInput { NftId = aMintNftOfTypeServiceRequest.MintNftId, ImmutableDataString = aMintNftOfTypeServiceRequest.ImmutableDataString, MutableDataString = aMintNftOfTypeServiceRequest.MutableDataString == null ? "" : aMintNftOfTypeServiceRequest.MutableDataString }; Nethereum.Hex.HexTypes.HexBigInteger gasEstimate = await mintingHandler.EstimateGasAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aMintNftOfTypeFunctionMessage); aMintNftOfTypeFunctionMessage.Gas = gasEstimate.Value; Nethereum.RPC.Eth.DTOs.TransactionReceipt mintingTransactionReceipt = await mintingHandler.SendRequestAndWaitForReceiptAsync(NftCreatorAddresses.NewNftCreatorRopstenAddress, aMintNftOfTypeFunctionMessage); System.Collections.Generic.List <EventLog <MintNftOutputEventDto> > MintNftOutput = mintingTransactionReceipt.DecodeAllEvents <MintNftOutputEventDto>(); int id = (int)MintNftOutput[0].Event.Id; return(new MintNftOfTypeServiceResponse { TransactionHash = mintingTransactionReceipt.TransactionHash, TokenId = id, GasUsed = new HexBigInteger(mintingTransactionReceipt.GasUsed.Value) }); }