static void Main(string[] args)
    {
        var X = new ImmutableData(100, "Jane");

        X.SetName("Anne");
        Debug.WriteLine(X);
        // "Data=100, Name=Anne"
    }
        public async Task ShouldDeserializeToken3()
        {
            var request = new ViewTokenDataServiceRequest {
                ViewTokenId = 3
            };

            ViewTokenDataServiceResponse response = await Mediator.Send(request);

            byte[] SerializedObject = Convert.FromBase64String(response.TokenDataString);

            ImmutableData deSerObj = Serializer.Deserialize <ImmutableData>(SerializedObject, 0);

            deSerObj.ShouldBeOfType <ImmutableData>();
            deSerObj.Title.ShouldBe("The First Minted NFT!");
        }
예제 #3
0
            private void DeserializeAndAddData(uint aToken, TokenBase aOwnedToken, string aDataString)
            {
                if (aToken == 3)
                {
                    byte[] serializedImmutableData = Convert.FromBase64String(aDataString);

                    ImmutableData aDeserializedObject = Serializer.Deserialize <ImmutableData>(serializedImmutableData, options); // options == 0

                    aOwnedToken.ImmDataObj = aDeserializedObject;

                    // Add to StateList
                    TokenDataList.Add(aOwnedToken);
                }
                else
                {
                    aOwnedToken.Data = aDataString;

                    TokenDataList.Add(aOwnedToken);
                }
            }
예제 #4
0
        public async Task ShouldGetTokenData()
        { //
          // Arrange
          //var getNftRequest = new ViewTokenDataServiceRequest { ViewTokenId = 3 };"0x12833d6fADd206dEd2fcE84936d8D78326AB8EfA"
            SerializerOptions options = 0;
            Function          viewTokenDataFunction = Herc1155.Instance.GetFunction("viewTokenData");

            CallInput CallInput = viewTokenDataFunction.CreateCallInput(from: TestEthAccounts.TestEthAccountAddress, gas: new Nethereum.Hex.HexTypes.HexBigInteger(900000), value: new Nethereum.Hex.HexTypes.HexBigInteger(0), functionInput: 4);

            // Act
            string base64SerializedString = await viewTokenDataFunction.CallAsync <string>(from : TestEthAccounts.TestEthAccountAddress, gas : new Nethereum.Hex.HexTypes.HexBigInteger(900000), value : new Nethereum.Hex.HexTypes.HexBigInteger(0), functionInput : 3);

            //ViewTokenDataServiceResponse response = await Mediator.Send(getNftRequest);

            byte[] serializedImmutableData = Convert.FromBase64String(base64SerializedString);

            ImmutableData deserializedObject = Serializer.Deserialize <ImmutableData>(serializedImmutableData, options);

            //Assert

            deserializedObject.ShouldNotBe(null);
            deserializedObject.MintedFrom.ShouldMatch(immutable.MintedFrom);
        }
 public ImmutableData Add(ImmutableData other)
 {
     AddCallsCount++;
     return(new ImmutableData(Value + other.Value));
 }
        //List<NftTemplate> TemplateDataList => WebThreeState.TemplateDataList;

        public async Task ShouldBuildTokenList()
        {
            WebThreeState webThree = await Mediator.Send(new GetNftTypesClientFeaturesAction());

            GetAllOwnedTokensSharedResponse aTokenList = await HttpClient.GetJsonAsync <GetAllOwnedTokensSharedResponse>(GetAllOwnedTokensSharedRequest.Route);

            aTokenList.TokenIdList.Count.ShouldBeGreaterThan(3);
            aTokenList.TokenIdList.Contains(3).ShouldBe(true);
            aTokenList.TokenIdList.Contains(4).ShouldBe(true);
            aTokenList.TokenIdList.Contains(5).ShouldBe(true);

            foreach (uint token in aTokenList.TokenIdList)
            {
                // TokenId
                var ownedToken = new TokenBase()
                {
                    TokenId = token
                };

                // TokenNFtTypeId
                string getNftTypeUri = GetTokenNftTypeSharedRequest.RouteFactory((int)token);

                WebThreeState NftTypeContainer = await Mediator.Send(new FetchTokenNftTypeAction()
                {
                    TokenId = (int)ownedToken.TokenId
                });

                // TokenNftTypeData Should already have the data in state so no need to make a service call
                NftTemplate nftType = webThree.TemplateDataList.Find(nft => nft.NftId == NftTypeContainer.CurrentTokenNftType);

                ownedToken.TemplateData = nftType;

                // Token Balance

                BalanceOfSharedResponse BalanceContainer = await HttpClient.GetJsonAsync <BalanceOfSharedResponse>(BalanceOfSharedRequest.RouteFactory((int)token));

                ownedToken.Balance = BalanceContainer.Balance;

                // Token ImmutableData (Data)

                ownedToken.TemplateData.ShouldBeOfType <NftTemplate>();

                ViewTokenDataSharedResponse DataString = await HttpClient.GetJsonAsync <ViewTokenDataSharedResponse>(ViewTokenDataSharedRequest.RouteFactory((int)token));

                DataString.TokenDataString.ShouldNotBe(null);
                if (token == 3)
                {
                    byte[] serializedImmutableData = Convert.FromBase64String(DataString.TokenDataString);
                    // need to figure out a way to get the type occording to the nftId
                    ImmutableData DeserializedObject = Serializer.Deserialize <ImmutableData>(serializedImmutableData, options); // options == 0

                    ownedToken.ImmDataObj = DeserializedObject;

                    // Add to StateList
                    TokenDataList.Add(ownedToken);
                }
                else
                {
                    ownedToken.Data = DataString.TokenDataString;

                    TokenDataList.Add(ownedToken);
                }
            }

            TokenDataList.Count.ShouldBe(3);
        }