public async Task SupportForDefect2088SupplyKeyNotBeingRecordedDemonstrateProblem()
    {
        await using var fxTreasury = await TestAccount.CreateAsync(_network);

        var(adminPublicKey, adminPrivateKey)     = Generator.KeyPair();
        var(supplyPublicKey, supplyPrivateKey)   = Generator.KeyPair();
        var(royaltyPublicKey, royaltyPrivateKey) = Generator.KeyPair();
        var createParams = new CreateAssetParams
        {
            Name                 = "012345678912",
            Symbol               = "ABCD",
            Treasury             = fxTreasury,
            Administrator        = adminPublicKey,
            SupplyEndorsement    = supplyPublicKey,
            RoyaltiesEndorsement = royaltyPublicKey,
            Expiration           = DateTime.UtcNow.AddSeconds(7890000),
            Signatory            = new Signatory(fxTreasury, adminPrivateKey)
        };
        var receipt = await fxTreasury.Client.CreateTokenAsync(createParams);

        Assert.Equal(ResponseCode.Success, receipt.Status);

        var metadata = Enumerable.Range(1, 10).Select(_ => Generator.SHA384Hash()).ToArray();
        var record   = await fxTreasury.Client.MintAssetWithRecordAsync(receipt.Token, metadata, supplyPrivateKey);

        Assert.Equal(ResponseCode.Success, record.Status);

        var info = await fxTreasury.Client.GetTokenInfoAsync(receipt.Token);

        Assert.Equal(createParams.RoyaltiesEndorsement, info.RoyaltiesEndorsement);
    }
    public async Task SupportForDefect2088SupplyKeyNotBeingRecordedReproduceNonReproduce()
    {
        await using var fxTreasury = await TestAccount.CreateAsync(_network);

        var(adminPublicKey, adminPrivateKey)     = Generator.KeyPair();
        var(supplyPublicKey, supplyPrivateKey)   = Generator.KeyPair();
        var(royaltyPublicKey, royaltyPrivateKey) = Generator.KeyPair();
        var createParams = new CreateAssetParams
        {
            Name                 = "012345678912",
            Symbol               = "ABCD",
            Treasury             = fxTreasury,
            Administrator        = adminPublicKey,
            SupplyEndorsement    = supplyPublicKey,
            RoyaltiesEndorsement = royaltyPublicKey,
            Expiration           = DateTime.UtcNow.AddSeconds(7890000),
            Signatory            = new Signatory(fxTreasury, adminPrivateKey)
        };
        var receipt = await fxTreasury.Client.CreateTokenAsync(createParams);

        Assert.Equal(ResponseCode.Success, receipt.Status);

        var info = await fxTreasury.Client.GetTokenInfoAsync(receipt.Token);

        Assert.Equal(createParams.RoyaltiesEndorsement, info.RoyaltiesEndorsement);
    }
Esempio n. 3
0
 /// <summary>
 /// Creates a new Asset instance with the given create parameters.
 /// </summary>
 /// <param name="createParameters">
 /// Details regarding the Asset to instantiate.
 /// </param>
 /// <param name="configure">
 /// Optional callback method providing an opportunity to modify
 /// the execution configuration for just this method call.
 /// It is executed prior to submitting the request to the network.
 /// </param>
 /// <returns>
 /// A transaction record with a description of the newly created Asset.
 /// </returns>
 /// <exception cref="ArgumentOutOfRangeException">If required arguments are missing.</exception>
 /// <exception cref="InvalidOperationException">If required context configuration is missing.</exception>
 /// <exception cref="PrecheckException">If the gateway node create rejected the request upon submission.</exception>
 /// <exception cref="ConsensusException">If the network was unable to come to consensus before the duration of the transaction expired.</exception>
 /// <exception cref="TransactionException">If the network rejected the create request as invalid or had missing data.</exception>
 public async Task <CreateTokenRecord> CreateTokenWithRecordAsync(CreateAssetParams createParameters, Action <IContext>?configure = null)
 {
     return(new CreateTokenRecord(await ExecuteTransactionAsync(new TokenCreateTransactionBody(createParameters), configure, true, createParameters.Signatory).ConfigureAwait(false)));
 }
Esempio n. 4
0
 public TokenCreateTransactionBody(CreateAssetParams createParameters) : this()
 {
     if (createParameters is null)
     {
         throw new ArgumentNullException(nameof(createParameters), "The create parameters are missing. Please check that the argument is not null.");
     }
     if (string.IsNullOrWhiteSpace(createParameters.Name))
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Name), "The name cannot be null or empty.");
     }
     if (string.IsNullOrWhiteSpace(createParameters.Symbol))
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Symbol), "The token symbol must be specified.");
     }
     if (createParameters.Symbol.Trim().Length != createParameters.Symbol.Length)
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Symbol), "The token symbol cannot contain leading or trailing white space.");
     }
     if (createParameters.Symbol.Length > 32)
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Symbol), "The token symbol cannot exceed 32 characters in length.");
     }
     if (!createParameters.Symbol.Equals(createParameters.Symbol.ToUpperInvariant()))
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Symbol), "The token symbol must contain upper case characters.");
     }
     if (createParameters.Treasury is null || createParameters.Treasury == Hashgraph.Address.None)
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Treasury), "The treasury must be specified.");
     }
     if (createParameters.Expiration < DateTime.UtcNow)
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.Expiration), "The expiration time must be in the future.");
     }
     if (createParameters.RenewAccount.IsNullOrNone() == createParameters.RenewPeriod.HasValue)
     {
         throw new ArgumentOutOfRangeException(nameof(createParameters.RenewPeriod), "Both the renew account and period must be specified, or not at all.");
     }
     if (!string.IsNullOrEmpty(createParameters.Memo))
     {
         if (createParameters.Memo.Trim().Length != createParameters.Memo.Length)
         {
             throw new ArgumentOutOfRangeException(nameof(createParameters.Memo), "The token memo cannot contain leading or trailing white space.");
         }
     }
     Name      = createParameters.Name;
     Symbol    = createParameters.Symbol;
     Treasury  = new AccountID(createParameters.Treasury);
     TokenType = TokenType.NonFungibleUnique;
     if (createParameters.Ceiling > 0 && createParameters.Ceiling < long.MaxValue)
     {
         MaxSupply  = createParameters.Ceiling;
         SupplyType = TokenSupplyType.Finite;
     }
     else
     {
         SupplyType = TokenSupplyType.Infinite;
     }
     if (!createParameters.Administrator.IsNullOrNone())
     {
         AdminKey = new Key(createParameters.Administrator);
     }
     if (!createParameters.GrantKycEndorsement.IsNullOrNone())
     {
         KycKey = new Key(createParameters.GrantKycEndorsement);
     }
     if (!createParameters.SuspendEndorsement.IsNullOrNone())
     {
         FreezeKey = new Key(createParameters.SuspendEndorsement);
     }
     if (!createParameters.PauseEndorsement.IsNullOrNone())
     {
         PauseKey = new Key(createParameters.PauseEndorsement);
     }
     if (!createParameters.PauseEndorsement.IsNullOrNone())
     {
         PauseKey = new Key(createParameters.PauseEndorsement);
     }
     if (!createParameters.ConfiscateEndorsement.IsNullOrNone())
     {
         WipeKey = new Key(createParameters.ConfiscateEndorsement);
     }
     if (!createParameters.SupplyEndorsement.IsNullOrNone())
     {
         SupplyKey = new Key(createParameters.SupplyEndorsement);
     }
     if (!createParameters.RoyaltiesEndorsement.IsNullOrNone())
     {
         FeeScheduleKey = new Key(createParameters.RoyaltiesEndorsement);
     }
     if (createParameters.Royalties is not null)
     {
         CustomFees.AddRange(createParameters.Royalties.Select(royalty => new CustomFee(royalty)));
     }
     FreezeDefault = createParameters.InitializeSuspended;
     Expiry        = new Timestamp(createParameters.Expiration);
     if (!createParameters.RenewAccount.IsNullOrNone())
     {
         AutoRenewAccount = new AccountID(createParameters.RenewAccount);
     }
     if (createParameters.RenewPeriod.HasValue)
     {
         AutoRenewPeriod = new Duration(createParameters.RenewPeriod.Value);
     }
     Memo = createParameters.Memo ?? string.Empty;
 }