コード例 #1
0
        public void Should_Convert_To_Namespace_Alias()
        {
            var namespaceId = new NamespaceId("foo");
            var byteArray   = namespaceId.AliasToRecipient();

            byteArray.Length.Should().Be(25);
        }
コード例 #2
0
        /// <summary>
        ///     Gets the namespace.
        /// </summary>
        /// <param name="namespaceId">The namespace Id</param>
        /// <returns>IObservable&lt;NamespaceInfo&gt;</returns>
        public IObservable <NamespaceInfo> GetNamespace(NamespaceId namespaceId)
        {
            var route = $"{BasePath}/namespace/{namespaceId.HexId}";

            if (namespaceId == null)
            {
                throw new ArgumentNullException(nameof(namespaceId));
            }

            var networkType = GetNetworkTypeObservable().Take(1);

            return(Observable.FromAsync(async ar => await route.GetJsonAsync <NamespaceInfoDTO>())
                   .Select(info => new NamespaceInfo(
                               info.Meta.Active,
                               info.Meta.Index,
                               info.Meta.Id,
                               NamespaceTypeExtension.GetRawValue((int)info.Namespace.Type),
                               info.Namespace.Depth,
                               ExtractLevels(info.Namespace.Level0, info.Namespace.Level1, info.Namespace.Level2),
                               info.Namespace.ParentId.ToUInt64() == 0
                        ? null
                        : new NamespaceId(info.Namespace.ParentId.ToUInt64()),
                               PublicAccount.CreateFromPublicKey(info.Namespace.Owner, networkType.Wait()),
                               info.Namespace.StartHeight.ToUInt64(),
                               info.Namespace.EndHeight.ToUInt64(),
                               new Alias(AliasTypeExtension.GetRawValue((int)info.Namespace.Alias.Type),
                                         info.Namespace.Alias.Address != null
                            ? Address.CreateFromHex(info.Namespace.Alias.Address)
                            : null,
                                         info.Namespace.Alias.MosaicId != null
                            ? new MosaicId(info.Namespace.Alias.MosaicId.ToUInt64())
                            : null
                                         )
                               )));
        }
コード例 #3
0
ファイル: MosaicHttp.cs プロジェクト: zwurv/nem2-sdk-csharp
        /// <summary>
        /// Gets the mosaics from namespace.
        /// </summary>
        /// <param name="namespaceId">The namespace identifier.</param>
        /// <returns>IObservable&lt;List&lt;MosaicInfoDTO&gt;&gt;.</returns>
        /// <exception cref="ArgumentNullException">namespaceId</exception>
        /// <exception cref="ArgumentException">invalid namespace id</exception>
        public IObservable <List <MosaicInfo> > GetMosaicsFromNamespace(NamespaceId namespaceId)
        {
            if (namespaceId == null)
            {
                throw new ArgumentNullException(nameof(namespaceId));
            }
            if (namespaceId.HexId.Length != 16 || !Regex.IsMatch(namespaceId.HexId, @"\A\b[0-9a-fA-F]+\b\Z"))
            {
                throw new ArgumentException("invalid namespace id");
            }

            IObservable <NetworkType.Types> networkTypeResolve = GetNetworkTypeObservable().Take(1);

            return(Observable.FromAsync(async ar => await MosaicRoutesApi.GetMosaicsFromNamespaceAsync(namespaceId.HexId))
                   .Select(e => e.Select(mosaic => new MosaicInfo(
                                             mosaic.Meta.Active,
                                             mosaic.Meta.Index,
                                             mosaic.Meta.Id,
                                             new NamespaceId(BitConverter.ToUInt64(mosaic.Mosaic.NamespaceId.FromHex(), 0)),
                                             new MosaicId(BitConverter.ToUInt64(mosaic.Mosaic.MosaicId.FromHex(), 0)),
                                             mosaic.Mosaic.Supply,
                                             mosaic.Mosaic.Height,
                                             new PublicAccount(mosaic.Mosaic.Owner, networkTypeResolve.Wait()),
                                             ExtractMosaicProperties(mosaic.Mosaic.Properties))).ToList()));
        }
コード例 #4
0
        public Metadata Apply(JObject input)
        {
            var      metadata     = input["metadata"].ToObject <JObject>();
            var      metadataType = MetadataTypeExtension.GetRawValue(metadata["metadataType"].ToObject <int>());
            var      fields       = metadata["fields"].ToObject <List <FieldDTO> >();
            var      fieldList    = fields.Select(f => new Field(f.Key, f.Value)).ToList();
            Metadata metadataInfo = null;

            switch (metadataType)
            {
            case MetadataType.ACCOUNT:
                var address = Address.CreateFromHex(metadata["metadataId"].ToObject <string>());
                metadataInfo = new AddressMetadata(fieldList, address);
                break;

            case MetadataType.NAMESPACE:
                var namespaceId = new NamespaceId(metadata["metadataId"].ToObject <UInt64DTO>().ToUInt64());
                metadataInfo = new NamespaceMetadata(fieldList, namespaceId);
                break;

            case MetadataType.MOSAIC:
                var mosaicId = new MosaicId(metadata["metadataId"].ToObject <UInt64DTO>().ToUInt64());
                metadataInfo = new MosaicMetadata(fieldList, mosaicId);
                break;

            case MetadataType.NONE:
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            return(metadataInfo);
        }
コード例 #5
0
        public void CreateANamespaceIdFromSubNamespaceNameViaConstructor()
        {
            NamespaceId namespaceId = new NamespaceId("nem.xem");

            Assert.AreEqual(namespaceId.Id, (ulong)6507831095446241869);
            Assert.AreEqual(namespaceId.Name, "nem.xem");
        }
コード例 #6
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RegisterNamespaceTransaction"/> class.
        /// </summary>
        /// <param name="type">The type.</param>
        /// <param name="version">The version.</param>
        /// <param name="deadline">The deadline.</param>
        /// <param name="fee">The fee.</param>
        /// <param name="namespaceType">Type of the namespace.</param>
        /// <param name="duration">The duration.</param>
        /// <param name="parentId">The parent identifier.</param>
        /// <param name="namespaceName">Name of the namespace.</param>
        /// <param name="signer">The signer.</param>
        /// <param name="signature">The signature.</param>
        /// <param name="transactionInfo">The transaction information.</param>
        /// <exception cref="ArgumentNullException">parentId</exception>
        /// <exception cref="InvalidEnumArgumentException">type</exception>
        /// <exception cref="ArgumentOutOfRangeException">namespaceType</exception>
        public RegisterNamespaceTransaction(NetworkType.Types type, int version, Deadline deadline, ulong fee, byte namespaceType, ulong duration, NamespaceId parentId, NamespaceId namespaceName, PublicAccount signer, string signature, TransactionInfo transactionInfo)
        {
            if (parentId == null && namespaceName == null)
            {
                throw new ArgumentNullException(nameof(parentId) + " and " + nameof(namespaceName) + " cannot both be null");
            }
            if (!Enum.IsDefined(typeof(NetworkType.Types), type))
            {
                throw new InvalidEnumArgumentException(nameof(type), (int)type, typeof(NetworkType.Types));
            }
            if (namespaceType != 0 && namespaceType != 1)
            {
                throw new ArgumentOutOfRangeException(nameof(namespaceType));
            }

            NetworkType     = type;
            Version         = version;
            Deadline        = deadline;
            Fee             = fee;
            NamespaceType   = NamespaceTypes.GetRawValue(namespaceType);
            TransactionType = TransactionTypes.Types.RegisterNamespace;
            Duration        = duration;
            ParentId        = parentId;
            NamespaceId     = namespaceName;
            Signer          = signer;
            Signature       = signature;
            TransactionInfo = transactionInfo;
        }
コード例 #7
0
        /// <summary>
        /// Initializes a new instance of the <see cref="MosaicId"/> class.
        /// </summary>
        /// <param name="identifier">The identifier.</param>
        /// <exception cref="System.ArgumentException">
        /// </exception>
        public MosaicId(string identifier)
        {
            if (string.IsNullOrEmpty(identifier))
            {
                throw new ArgumentException(identifier + " is not valid");
            }
            if (!identifier.Contains(":"))
            {
                throw new ArgumentException(identifier + " is not valid");
            }
            var parts = identifier.Split(':');

            if (parts.Length != 2)
            {
                throw new ArgumentException(identifier + " is not valid");
            }
            if (parts[0] == "")
            {
                throw new ArgumentException(identifier + " is not valid");
            }
            if (parts[1] == "")
            {
                throw new ArgumentException(identifier + " is not valid");
            }
            var namespaceName = parts[0];

            NamespaceId = new NamespaceId(namespaceName);
            Name        = parts[1];
            FullName    = identifier;
        }
コード例 #8
0
        public virtual string GetProperty(string strPropertyName, string strFormat, System.Globalization.CultureInfo formatProvider, DotNetNuke.Entities.Users.UserInfo accessingUser, DotNetNuke.Services.Tokens.Scope accessLevel, ref bool propertyNotFound)
        {
            switch (strPropertyName.ToLower())
            {
            case "namespaceid": // Int
                return(NamespaceId.ToString(strFormat, formatProvider));

            case "parentid": // Int
                return(ParentId.ToString(strFormat, formatProvider));

            case "moduleid": // Int
                return(ModuleId.ToString(strFormat, formatProvider));

            case "namespacename": // NVarChar
                return(PropertyAccess.FormatString(NamespaceName, strFormat));

            case "lastqualifier": // NVarChar
                return(PropertyAccess.FormatString(LastQualifier, strFormat));

            case "description": // NVarCharMax
                if (Description == null)
                {
                    return("");
                }
                ;
                return(PropertyAccess.FormatString(Description, strFormat));

            default:
                propertyNotFound = true;
                break;
            }

            return(Null.NullString);
        }
コード例 #9
0
        public void Should_Create_Namespace_From_Name()
        {
            const string namespaceName = "nspeeccbe.subnsaf3628";
            var          namespaceId   = new NamespaceId(namespaceName);

            namespaceId.HexId.Should().BeEquivalentTo("9E088FD2585C3518");
        }
コード例 #10
0
        /// <summary>
        /// Gets the namespace.
        /// </summary>
        /// <param name="namespaceId">The namespace identifier.</param>
        /// <returns>IObservable&lt;NamespaceInfoDTO&gt;.</returns>
        /// <exception cref="ArgumentException">Value cannot be null or empty. - namespaceId
        /// or
        /// Invalid namespace</exception>
        public IObservable <NamespaceInfo> GetNamespace(NamespaceId namespaceId)
        {
            if (string.IsNullOrEmpty(namespaceId.Name))
            {
                throw new ArgumentException("Value cannot be null or empty.", nameof(namespaceId));
            }
            if (namespaceId.HexId.Length != 16 || !Regex.IsMatch(namespaceId.HexId, @"\A\b[0-9a-fA-F]+\b\Z"))
            {
                throw new ArgumentException("Invalid namespace");
            }

            IObservable <NetworkType.Types> networkTypeResolve = GetNetworkTypeObservable().Take(1);

            return(Observable.FromAsync(async ar => await NamespaceRoutesApi.GetNamespaceAsync(namespaceId.HexId))
                   .Select(e =>
                           new NamespaceInfo(
                               e.Meta.Active,
                               e.Meta.Index,
                               e.Meta.Id,
                               NamespaceTypes.GetRawValue(e.Namespace.Type),
                               e.Namespace.Depth,
                               ExtractLevels(e.Namespace),
                               new NamespaceId(e.Namespace.ParentId),
                               e.Namespace.StartHeight,
                               e.Namespace.EndHeight,
                               new PublicAccount(e.Namespace.Owner, networkTypeResolve.Wait())
                               )));
        }
コード例 #11
0
        public void CreateANamespaceIdFromRootNamespaceNameViaConstructor()
        {
            NamespaceId namespaceId = new NamespaceId("nem");

            Assert.AreEqual(namespaceId.Id, 9562080086528621131);
            Assert.AreEqual(namespaceId.Name, "nem");
            Assert.AreEqual(namespaceId.HexId, "84B3552D375FFA4B");
        }
コード例 #12
0
        public async Task Should_Add_Metadata_To_Namespace()
        {
            var namespaceName = "nsp" + Guid.NewGuid().ToString().Replace("-", "").Substring(0, 6);
            var namespaceId   = new NamespaceId(namespaceName);
            var account       = Fixture.SeedAccount;

            await Fixture.SiriusWebSocketClient.Listener.Open();

            var tx = Fixture.SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(account.Address).Take(1).Timeout(TimeSpan.FromSeconds(1000));


            Log.WriteLine($"Going to generate namespace {namespaceId}");

            var registerRootTransaction = RegisterNamespaceTransaction.CreateRootNamespace(
                Deadline.Create(),
                namespaceName,
                100,
                Fixture.NetworkType
                );

            var signedTransaction = account.Sign(registerRootTransaction, Fixture.GenerationHash);

            await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction);


            var result = await tx;

            Log.WriteLine($"Request register namespace confirmed with transaction {result.TransactionInfo.Hash}");


            var modifications = new List <MetadataModification>
            {
                MetadataModification.Add("company", "ProximaX"),
                MetadataModification.Add("department", "IT")
            };

            var modifyMetadataTransaction = ModifyMetadataTransaction.CreateForNamespace(
                Deadline.Create(),
                namespaceId,
                modifications,
                Fixture.NetworkType);

            signedTransaction = account.Sign(modifyMetadataTransaction, Fixture.GenerationHash);

            await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction);

            result = await tx;
            Log.WriteLine($"Request add metadata to namespace confirmed with transaction {result.TransactionInfo.Hash}");


            var metaInfo = await Fixture.SiriusClient.MetadataHttp.GetMetadataFromNamespace(namespaceId);

            metaInfo.Fields.Should().HaveCount(2);
            metaInfo.Type.Should().BeEquivalentTo(MetadataType.NAMESPACE);
        }
コード例 #13
0
        public void TryGetDocumentation_returns_expected_documentation_item_for_an_documented_type()
        {
            // ARRANGE
            var cs1 = @"
                namespace Namespace1.Namespace2
                {
                    public class Class1
                    { }
                }
            ";
            var cs2 = @"
                namespace Namespace3
                {
                    public class Class2
                    { }
                }
            ";

            var assembly1 = Compile(cs1, "Assembly1");
            var assembly2 = Compile(cs2, "Assembly2");

            var typeId1      = assembly1.MainModule.Types.Single(x => x.Name == "Class1").ToTypeId();
            var typeId2      = assembly2.MainModule.Types.Single(x => x.Name == "Class2").ToTypeId();
            var namespaceId1 = new NamespaceId("Namespace1.Namespace2");
            var namespaceId2 = new NamespaceId("Namespace3");

            using var sut = AssemblySetDocumentation.FromAssemblyDefinitions(assembly1, assembly2);

            // ACT
            var documentation1 = sut.TryGetDocumentation(typeId1);
            var documentation2 = sut.TryGetDocumentation(typeId2);
            var documentation3 = sut.TryGetDocumentation(namespaceId1);
            var documentation4 = sut.TryGetDocumentation(namespaceId2);

            // ASSERT
            Assert.NotNull(documentation1);
            var typeDocumentation1 = Assert.IsType <TypeDocumentation>(documentation1);

            Assert.Equal(typeId1, typeDocumentation1.TypeId);

            Assert.NotNull(documentation2);
            var typeDocumentation2 = Assert.IsType <TypeDocumentation>(documentation2);

            Assert.Equal(typeId2, typeDocumentation2.TypeId);

            Assert.NotNull(documentation3);
            var namespaceDocumentation1 = Assert.IsType <NamespaceDocumentation>(documentation3);

            Assert.Equal(namespaceId1, namespaceDocumentation1.NamespaceId);

            Assert.NotNull(documentation4);
            var namespaceDocumentation2 = Assert.IsType <NamespaceDocumentation>(documentation4);

            Assert.Equal(namespaceId2, namespaceDocumentation2.NamespaceId);
        }
コード例 #14
0
 public AliasTransaction(NetworkType networkType, int version, Deadline deadline, ulong?maxFee,
                         EntityType transactionType, NamespaceId namespaceId, AliasActionType actionType,
                         MosaicId mosaicId = null, Address address = null, string signature = null, PublicAccount signer = null,
                         TransactionInfo transactionInfo = null)
     : base(networkType, version, transactionType, deadline, maxFee, signature, signer, transactionInfo)
 {
     NamespaceId     = namespaceId;
     MosaicId        = mosaicId;
     AliasActionType = actionType;
     Address         = address;
 }
        public RegisterNamespaceTransactionBuilder SetSubNamespace(NamespaceId parentId, string name)
        {
            NamespaceType = NamespaceType.SUB_NAMESPACE;
            SetNamespaceName(name);
            SetParentId(parentId);
            var subNamespace = IdGenerator.GenerateSubNamespaceIdFromParentId(parentId.Id, name);

            SetNamespaceId(new NamespaceId(subNamespace));

            return(Self());
        }
コード例 #16
0
        public void Should_Create_Namespace_From_UInt64DTO()
        {
            var id = new UInt64DTO
            {
                388731997, 2432469584
            };

            var namespaceId = new NamespaceId(id.ToUInt64());

            namespaceId.HexId.Should().BeEquivalentTo("90FC8A50172B945D");
        }
コード例 #17
0
        public int CompareTo(OpenXmlSchema other)
        {
            var nsCompare = NamespaceId.CompareTo(other.NamespaceId);

            if (nsCompare != 0)
            {
                return(nsCompare);
            }

            return(string.CompareOrdinal(Name, other.Name));
        }
 /// <summary>
 ///     Constructor
 /// </summary>
 /// <param name="networkType"></param>
 /// <param name="version"></param>
 /// <param name="transactionType"></param>
 /// <param name="deadline"></param>
 /// <param name="maxFee"></param>
 /// <param name="metadataType"></param>
 /// <param name="metadataId"></param>
 /// <param name="address"></param>
 /// <param name="modifications"></param>
 /// <param name="signature"></param>
 /// <param name="signer"></param>
 /// <param name="transactionInfo"></param>
 public NamespaceMetadataTransaction(NetworkType networkType, int version, EntityType transactionType, Deadline deadline, ulong?maxFee, ulong scopedKey, PublicAccount targetPublicKey, NamespaceId targetId, string newValue, short valueSizeDelta, ushort valueSize,
                                     string signature = null, PublicAccount signer = null, TransactionInfo transactionInfo = null)
     : base(networkType, version, transactionType, deadline, maxFee, signature, signer, transactionInfo)
 {
     ScopedKey       = scopedKey;
     TargetPublicKey = targetPublicKey;
     TargetId        = targetId;
     Value           = newValue;
     ValueSizeDelta  = valueSizeDelta;
     ValueSize       = valueSize;
     // oldValue = oldValue;
 }
コード例 #19
0
        /// <summary>
        ///     GetMetadataFromNamespace
        /// </summary>
        /// <param name="namespaceId">The namespace Id</param>
        /// <returns> IObservable&lt;MosaicMetadata&gt;</returns>
        public IObservable <NamespaceMetadata> GetMetadataFromNamespace(NamespaceId namespaceId)
        {
            Guard.NotNull(namespaceId, nameof(namespaceId), "Namespace id should not be null");

            var route = $"{BasePath}/namespace/{namespaceId.HexId}/metadata";

            return(Observable.FromAsync(async ar => await route.GetJsonAsync <NamespaceMetadataInfoDTO>())
                   .Select(info => new NamespaceMetadata(
                               info.Metadata.Fields.Select(f => new Field(f.Key, f.Value)).ToList(),
                               new NamespaceId(info.Metadata.MetadataId.ToUInt64())
                               )));
        }
コード例 #20
0
        private static AliasTransaction ToAliasTransaction(JObject tx, TransactionInfo txInfo)
        {
            var transaction = tx["transaction"].ToObject <JObject>();
            var version     = transaction["version"];


            //Bug - It seems the dotnetcore does not
            //understand the Integer.
            //The workaround it to double cast the version
            int versionValue;

            try
            {
                versionValue = (int)((uint)version);
            }
            catch (Exception)
            {
                versionValue = (int)version;
            }

            var network   = TransactionMappingUtils.ExtractNetworkType(versionValue);
            var txVersion = TransactionMappingUtils.ExtractTransactionVersion(versionValue);

            var deadline  = new Deadline(transaction["deadline"].ToObject <UInt64DTO>().ToUInt64());
            var maxFee    = transaction["maxFee"]?.ToObject <UInt64DTO>().ToUInt64();
            var signature = transaction["signature"].ToObject <string>();
            var signer    = new PublicAccount(transaction["signer"].ToObject <string>(), network);

            var namespaceId = new NamespaceId(transaction["namespaceId"].ToObject <UInt64DTO>().ToUInt64());
            var type        = EntityTypeExtension.GetRawValue(transaction["type"].ToObject <int>());
            var actionType  = TransactionMappingHelper.ExtractActionType(tx);

            AliasTransaction aliasTransaction = null;

            switch (type)
            {
            case EntityType.ADDRESS_ALIAS:
                var addressHex = transaction["address"].ToObject <string>();
                var address    = Address.CreateFromHex(addressHex);
                aliasTransaction = new AliasTransaction(network, txVersion, deadline, maxFee, type,
                                                        namespaceId, actionType, null, address, signature, signer, txInfo);
                break;

            case EntityType.MOSAIC_ALIAS:
                var mosaic = new MosaicId(transaction["mosaicId"].ToObject <UInt64DTO>().ToUInt64());
                aliasTransaction = new AliasTransaction(network, txVersion, deadline, maxFee, type,
                                                        namespaceId, actionType, mosaic, null, signature, signer, txInfo);
                break;
            }

            return(aliasTransaction);
        }
コード例 #21
0
 /// <summary>
 /// The mosaic info structure contains its properties, the owner and the namespace to which it belongs to.
 /// </summary>
 /// <param name="active">The mosaic activity.</param>
 /// <param name="index">The mosaic index.</param>
 /// <param name="metaId">The meta data id.</param>
 /// <param name="namespaceId">The namespace id.</param>
 /// <param name="mosaicId">The mosaic id.</param>
 /// <param name="supply">The mosaic supply.</param>
 /// <param name="height">The mosaic height.</param>
 /// <param name="owner">The mosaic owner.</param>
 /// <param name="properties">The properties.</param>
 /// <exception cref="ArgumentOutOfRangeException">index</exception>
 /// <exception cref="ArgumentNullException">
 /// owner
 /// or
 /// properties
 /// </exception>
 public MosaicInfo(bool active, int index, string metaId, NamespaceId namespaceId, MosaicId mosaicId, ulong supply, ulong height, PublicAccount owner, MosaicProperties properties)
 {
     Console.WriteLine(namespaceId.HexId);
     IsActive    = active;
     Index       = index;
     MetaId      = metaId;
     NamespaceId = namespaceId;
     MosaicId    = mosaicId;
     Supply      = supply;
     Height      = height;
     Owner       = owner;
     Properties  = properties;
 }
コード例 #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NamespaceInfo" /> class.
 /// </summary>
 /// <param name="active">if set to <c>true</c> [active].</param>
 /// <param name="index">The index.</param>
 /// <param name="metaId">The meta identifier.</param>
 /// <param name="namespaceId">The namespace identifier.</param>
 /// <param name="depth">The depth.</param>
 /// <param name="levels">The levels.</param>
 /// <param name="parentId">The parent identifier.</param>
 /// <param name="startHeight">The start height.</param>
 /// <param name="endHeight">The end height.</param>
 /// <param name="owner">The owner.</param>
 public NamespaceInfo(bool active, int index, string metaId, NamespaceTypes.Types namespaceId, int depth, List <NamespaceId> levels, NamespaceId parentId, ulong startHeight, ulong endHeight, PublicAccount owner)
 {
     IsActive      = active;
     Owner         = owner;
     Index         = index;
     MetaId        = metaId;
     NamespaceType = namespaceId;
     ParentId      = parentId;
     StartHeight   = startHeight;
     EndHeight     = endHeight;
     Depth         = depth;
     Levels        = levels;
 }
コード例 #23
0
        public byte[] GetBytes()
        {
            if (Address != null)
            {
                return(Address.Plain.FromBase32String());
            }
            else if (NamespaceId != null)
            {
                return(NamespaceId.AliasToRecipient());
            }

            throw new IllegalStateException("Recipient is not specific");
        }
コード例 #24
0
 public static MosaicDefinitionTransaction Create(NetworkType.Types networkType, Deadline deadline, string namespaceId, string mosaicName, MosaicProperties properties)
 {
     return(new MosaicDefinitionTransaction(
                networkType,
                3,
                deadline,
                0,
                mosaicName,
                NamespaceId.Create(namespaceId),
                MosaicId.CreateFromMosaicIdentifier(namespaceId + ":" + mosaicName),
                properties
                ));
 }
コード例 #25
0
 /// <summary>
 /// Constructor.
 /// </summary>
 public MosaicDefinitionTransaction(NetworkType.Types networkType, int version, Deadline deadline, ulong fee, string mosaicName, NamespaceId namespaceId, MosaicId mosaicId, MosaicProperties properties, string signature, PublicAccount signer, TransactionInfo transactionInfo)
 {
     Deadline        = deadline;
     NetworkType     = networkType;
     Version         = version;
     Properties      = properties;
     MosaicId        = mosaicId;
     NamespaceId     = namespaceId;
     MosaicName      = mosaicName;
     Fee             = fee;
     TransactionType = TransactionTypes.Types.MosaicDefinition;
     Signature       = signature;
     Signer          = signer;
     TransactionInfo = transactionInfo;
 }
コード例 #26
0
        private async Task <NamespaceInfo> GenerateNamespace(Account account, string namespaceName, NamespaceId parentId)
        {
            RegisterNamespaceTransaction registerNamespaceTransaction;

            if (parentId == null)
            {
                registerNamespaceTransaction = RegisterNamespaceTransaction.CreateRootNamespace(
                    Deadline.Create(),
                    namespaceName,
                    100,
                    Fixture.NetworkType
                    );
            }
            else
            {
                registerNamespaceTransaction = RegisterNamespaceTransaction.CreateSubNamespace(
                    Deadline.Create(),
                    namespaceName,
                    parentId,
                    Fixture.NetworkType
                    );
            }


            var signedTransaction = account.Sign(registerNamespaceTransaction, Fixture.GenerationHash);

            var tx = Fixture.SiriusWebSocketClient.Listener.ConfirmedTransactionsGiven(account.Address).Take(1)
                     .Timeout(TimeSpan.FromSeconds(3000));

            await Fixture.SiriusClient.TransactionHttp.Announce(signedTransaction);

            Log.WriteLine(
                $"Registered namespace {namespaceName} for account {account.Address.Plain} with transaction {signedTransaction.Hash}");

            var result = await tx;

            Log.WriteLine($"Request confirmed with transaction {result.TransactionInfo.Hash}");

            var expectedId = parentId != null?NamespaceId.CreateFromParent(namespaceName, parentId) : new NamespaceId(namespaceName);

            var namespaceInfo = await Fixture.SiriusClient.NamespaceHttp.GetNamespace(expectedId);

            Log.WriteLine(
                $"Retrieved namespace {namespaceName} successfully. The namespace HexId {namespaceInfo.Id.HexId}");

            return(namespaceInfo);
        }
コード例 #27
0
        public static AliasTransaction CreateForAddress(Address address, NamespaceId namespaceId,
                                                        AliasActionType actionType,
                                                        Deadline deadline, NetworkType networkType)
        {
            if (namespaceId == null)
            {
                throw new ArgumentNullException(nameof(namespaceId));
            }

            if (address == null)
            {
                throw new ArgumentNullException(nameof(address));
            }

            return(new AliasTransaction(networkType, EntityVersion.ADDRESS_ALIAS.GetValue(),
                                        deadline, 0, EntityType.ADDRESS_ALIAS, namespaceId, actionType, null, address));
        }
コード例 #28
0
        public static AliasTransaction CreateForMosaic(MosaicId mosaicId, NamespaceId namespaceId,
                                                       AliasActionType actionType,
                                                       Deadline deadline, NetworkType networkType)
        {
            if (namespaceId == null)
            {
                throw new ArgumentNullException(nameof(namespaceId));
            }

            if (mosaicId == null)
            {
                throw new ArgumentNullException(nameof(mosaicId));
            }

            return(new AliasTransaction(networkType, EntityVersion.MOSAIC_ALIAS.GetValue(),
                                        deadline, 0, EntityType.MOSAIC_ALIAS, namespaceId, actionType, mosaicId));
        }
コード例 #29
0
        public async Task Get_SubNamespace_Should_Return_SubNamespaceInfo()
        {
            using (var httpTest = new HttpTest())
            {
                var fakeJson = TestHelper.LoadJsonFileToObject(@"Testdata\\Namespace\\GetSubNamespaceInfo.json");
                httpTest.RespondWithJson(fakeJson);

                const string expectedNamespaceIdHex       = "9C86E3F37F6EC854";
                const string expectedParentNamespaceIdHex = "9777BFC68948B892";
                var          namespaceId = new NamespaceId("nspcef49a.subns1a99d1");

                var namespaceInfo = await _namespaceHttp.GetNamespace(namespaceId);

                namespaceInfo.Id.HexId.Should().BeEquivalentTo(expectedNamespaceIdHex);
                namespaceInfo.ParentId.HexId.Should().BeEquivalentTo(expectedParentNamespaceIdHex);
            }
        }
コード例 #30
0
        public async Task Get_Namespace_Should_Return_NamespaceInfo()
        {
            using (var httpTest = new HttpTest())
            {
                var fakeJson =
                    TestHelper.LoadJsonFileToObject(@"Testdata\\Namespace\\GetNamespaceInfo.json");

                httpTest.RespondWithJson(fakeJson);

                var namespaceId = new NamespaceId("nsp714402");

                const string expectedNamespaceIdHex = "FD57051688018889";
                namespaceId.HexId.Should().BeEquivalentTo(expectedNamespaceIdHex);
                var namespaceInfo = await _namespaceHttp.GetNamespace(namespaceId);

                namespaceInfo.Id.HexId.Should().BeEquivalentTo(expectedNamespaceIdHex);
            }
        }
コード例 #31
0
 private static TriggeringNodeDefinition ConstructCorePropTND(NamespaceId namespaceId, string nodeName)
 {
     string propName = nodeName.Substring(0, 1).ToUpperInvariant() + nodeName.Substring(1);
     return ConstructCorePropTND(namespaceId, nodeName, propName);
 }
コード例 #32
0
        internal bool IsInNamespace(NamespaceId namespaceId)
        {
            if (namespaceId >= 0 && m_commonNamespaces.GetAtomicName(namespaceId) != this.NamespaceURI)
                return false;

            return true;

        }
コード例 #33
0
 public string GetAtomicName(NamespaceId id)
 {
     return m_atomicStrings[(int)id];
 }
コード例 #34
0
        internal bool Is(NamespaceId namespaceId, string nodeName)
        {
            if (!object.Equals(NodeName, nodeName))
            {
                return false;
            }

            if (namespaceId >= 0 && m_commonNamespaces.GetAtomicName(namespaceId) != this.NamespaceURI)
                return false;

            return true;
        }
コード例 #35
0
 public string GetAttributeValue(NamespaceId ns, string attrName)
 {
     foreach (AttribDetails ad in listOfAttribDetails)
     {
         if (string.Compare(ad.localName,attrName, true) == 0 && m_commonNamespaces.GetAtomicName(ns) == ad.namespaceURI)
             return ad.value;
     }
     return "";
 }
コード例 #36
0
        private static TriggeringNodeDefinition ConstructCorePropTND(NamespaceId nsid, string nodename, string propName, ContentType contentType)
        {
            EffectDescriptor td = new EffectDescriptor();
            td.ContentType = contentType;
            td.AddAdditionalInfoDescriptor(new AdditionalInfoDescriptor("Name", propName, AdditionalInfoDescriptor.MappingType.FixedValue));
            td.BlockType = Effect.BlockType.Structure;
            td.NameForContentProperty = "Value";

            return new TriggeringNodeDefinition(nsid, nodename, null, null, td);
        }
コード例 #37
0
 private static TriggeringNodeDefinition ConstructCorePropTND(NamespaceId nsid, string nodename, string propName)
 {
     return ConstructCorePropTND(nsid, nodename, propName, ContentType.BuiltInProperty);
 }