public void VecU8EncodingTest() { var tc = new GenericTypeConverter <Vec <U8> >(); var actual = (Vec <U8>)tc.Create("0x200101020304050607"); Assert.AreEqual(actual.Bytes, actual.Encode()); var t1 = new U8(); t1.Create(actual.Value[0].Value); var t2 = new U8(); t2.Create(actual.Value[1].Value); var t3 = new U8(); t3.Create(actual.Value[2].Value); var t4 = new U8(); t4.Create(actual.Value[3].Value); var t5 = new U8(); t5.Create(actual.Value[4].Value); var t6 = new U8(); t6.Create(actual.Value[5].Value); var t7 = new U8(); t7.Create(actual.Value[6].Value); var t8 = new U8(); t8.Create(actual.Value[7].Value); List <U8> list = new List <U8>() { t1, t2, t3, t4, t5, t6, t7, t8 }; var vecU8 = new Vec <U8>(); vecU8.Create(list); Assert.AreEqual("0x200101020304050607", Utils.Bytes2HexString(vecU8.Bytes)); }
public void MogwaiBiosTest() { var mogwaiBiosStr = "0x0b1b9f0f79a9e3971baf6188ed98623284f1c3bb275883602164b7097789523f000000000881f7a106cc0f747e85deedaf2946297ebacbe008a7a4887c334448fcc4c4888c00000000000000000000000000000000010426df010000"; var mogwaiBiosA = new MogwaiBios(); mogwaiBiosA.Create(mogwaiBiosStr); var mogwaiBiosB = new MogwaiBios(); var id = new Hash(); id.Create(mogwaiBiosA.Id.Value); Assert.AreEqual("0x0B1B9F0F79A9E3971BAF6188ED98623284F1C3BB275883602164B7097789523F", mogwaiBiosA.Id.Value); var state = new U32(); state.Create(mogwaiBiosA.State.Value); Assert.AreEqual(0, mogwaiBiosA.State.Value); var metaXy = new Vec <U8Arr16>(); metaXy.Create(mogwaiBiosA.MetaXy.Bytes); Assert.AreEqual(2, mogwaiBiosA.MetaXy.Value.Count); Assert.AreEqual("0x0881F7A106CC0F747E85DEEDAF2946297EBACBE008A7A4887C334448FCC4C4888C", Utils.Bytes2HexString(mogwaiBiosA.MetaXy.Bytes)); Assert.AreEqual("0x81F7A106CC0F747E85DEEDAF2946297E", Utils.Bytes2HexString(metaXy.Value[0].Bytes)); var intrinsic = new Balance(); intrinsic.Create(mogwaiBiosA.Intrinsic.Value); var level = new U8(); level.Create(mogwaiBiosA.Level.Value); var phases = new Vec <BlockNumber>(); phases.Create(mogwaiBiosA.Phases.Bytes); var adaptations = new Vec <Hash>(); adaptations.Create(mogwaiBiosA.Adaptations.Bytes); mogwaiBiosB.Create(id, state, metaXy, intrinsic, level, phases, adaptations); Assert.AreEqual(mogwaiBiosB.Id.Value, mogwaiBiosA.Id.Value); Assert.AreEqual(mogwaiBiosB.State.Value, mogwaiBiosA.State.Value); Assert.AreEqual(mogwaiBiosB.MetaXy.Value[0].Bytes, mogwaiBiosA.MetaXy.Value[0].Bytes); Assert.AreEqual(mogwaiBiosB.Intrinsic.Value, mogwaiBiosA.Intrinsic.Value); Assert.AreEqual(mogwaiBiosB.Level.Value, mogwaiBiosA.Level.Value); Assert.AreEqual(mogwaiBiosB.Phases.Value[0].Bytes, mogwaiBiosA.Phases.Value[0].Bytes); Assert.AreEqual(mogwaiBiosB.Adaptations.Value, mogwaiBiosA.Adaptations.Value); }
public static GenericExtrinsicCall RemoveClaim(string mogwaicoinAddress, string account) { var address = new Vec <U8>(); address.Create( Encoding.ASCII.GetBytes(mogwaicoinAddress).ToList().Select(p => { var u = new U8(); u.Create(p); return(u); }).ToList() ); var accountId = new RawAccountId(); accountId.Create(Utils.GetPublicKeyFrom(account)); return(RemoveClaim(address, accountId)); }
public static GenericExtrinsicCall UpdateClaim(string mogwaicoinAddress, string account, ClaimState claimState, RawBalance balanceAmount) { var address = new Vec <U8>(); address.Create( Encoding.ASCII.GetBytes(mogwaicoinAddress).ToList().Select(p => { var u = new U8(); u.Create(p); return(u); }).ToList() ); var accountId = new RawAccountId(); accountId.Create(Utils.GetPublicKeyFrom(account)); var state = new EnumType <ClaimState>(); state.Create(claimState); return(UpdateClaim(address, accountId, state, balanceAmount)); }