public async Task CanScheduleMintAssetCoins() { await using var fxPayer = await TestAccount.CreateAsync(_network, fx => fx.CreateParams.InitialBalance = 20_00_000_000); await using var fxAsset = await TestAsset.CreateAsync(_network); var metadata = Enumerable.Range(1, Generator.Integer(2, 10)).Select(_ => Generator.SHA384Hash()).ToArray(); var pendingReceipt = await fxAsset.Client.MintAssetAsync( fxAsset.Record.Token, metadata, new Signatory( fxAsset.SupplyPrivateKey, new PendingParams { PendingPayer = fxPayer })); await AssertHg.AssetBalanceAsync(fxAsset, fxAsset.TreasuryAccount, (ulong)fxAsset.Metadata.Length); var schedulingReceipt = await fxAsset.Client.SignPendingTransactionAsync(pendingReceipt.Pending.Id, fxPayer.PrivateKey); Assert.Equal(ResponseCode.Success, schedulingReceipt.Status); // Can get receipt for original scheduled tx. var executedReceipt = await fxAsset.Client.GetReceiptAsync(pendingReceipt.Pending.TxId) as AssetMintReceipt; Assert.Equal(ResponseCode.Success, executedReceipt.Status); Assert.Equal(metadata.Length, executedReceipt.SerialNumbers.Count); foreach (var serialNumber in executedReceipt.SerialNumbers) { Assert.True(serialNumber > 0); } Assert.Equal((ulong)(fxAsset.Metadata.Length + metadata.Length), executedReceipt.Circulation); // Can get record for original scheduled tx. var record = await fxAsset.Client.GetTransactionRecordAsync(pendingReceipt.Pending.TxId) as AssetMintRecord; Assert.Equal(metadata.Length, record.SerialNumbers.Count); foreach (var serialNumber in record.SerialNumbers) { Assert.True(serialNumber > 0); } Assert.Equal((ulong)(fxAsset.Metadata.Length + metadata.Length), record.Circulation); await AssertHg.AssetBalanceAsync(fxAsset, fxAsset.TreasuryAccount, (ulong)(metadata.Length + fxAsset.Metadata.Length)); var info = await fxAsset.Client.GetTokenInfoAsync(fxAsset.Record.Token); Assert.Equal(fxAsset.Record.Token, info.Token); Assert.Equal(fxAsset.Params.Symbol, info.Symbol); Assert.Equal(TokenType.Asset, info.Type); Assert.Equal(fxAsset.TreasuryAccount.Record.Address, info.Treasury); Assert.Equal((ulong)(metadata.Length + fxAsset.Metadata.Length), info.Circulation); Assert.Equal(fxAsset.Params.Ceiling, info.Ceiling); Assert.Equal(fxAsset.Params.Administrator, info.Administrator); Assert.Equal(fxAsset.Params.GrantKycEndorsement, info.GrantKycEndorsement); Assert.Equal(fxAsset.Params.SuspendEndorsement, info.SuspendEndorsement); Assert.Equal(fxAsset.Params.PauseEndorsement, info.PauseEndorsement); Assert.Equal(fxAsset.Params.ConfiscateEndorsement, info.ConfiscateEndorsement); Assert.Equal(fxAsset.Params.SupplyEndorsement, info.SupplyEndorsement); Assert.Equal(fxAsset.Params.RoyaltiesEndorsement, info.RoyaltiesEndorsement); Assert.Equal(TokenTradableStatus.Tradable, info.TradableStatus); Assert.Equal(TokenTradableStatus.Tradable, info.PauseStatus); Assert.Equal(TokenKycStatus.Revoked, info.KycStatus); Assert.Empty(info.Royalties); Assert.False(info.Deleted); Assert.Equal(fxAsset.Params.Memo, info.Memo); // NETWORK V0.21.0 UNSUPPORTED vvvv // NOT IMPLEMENTED YET Assert.Empty(info.Ledger.ToArray()); // NETWORK V0.21.0 UNSUPPORTED ^^^^ }
async Task TransferringAssetAppliesSingleValueCommision() { await using var fxBuyer = await TestAccount.CreateAsync(_network); await using var fxSeller = await TestAccount.CreateAsync(_network); await using var fxBenefactor = await TestAccount.CreateAsync(_network); await using var fxPaymentToken = await TestToken.CreateAsync(_network, fx => fx.Params.GrantKycEndorsement = null, fxBenefactor, fxBuyer, fxSeller); await using var fxAsset = await TestAsset.CreateAsync(_network, fx => { fx.Params.Royalties = new AssetRoyalty[] { new AssetRoyalty(fxBenefactor, 1, 2, 0, Address.None) }; fx.Params.GrantKycEndorsement = null; }, fxBuyer, fxSeller); Assert.Equal(ResponseCode.Success, fxAsset.Record.Status); var movedAsset = new Asset(fxAsset, 1); await fxPaymentToken.Client.TransferTokensAsync(fxPaymentToken, fxPaymentToken.TreasuryAccount, fxBuyer, 100, fxPaymentToken.TreasuryAccount); await fxPaymentToken.Client.TransferAssetAsync(movedAsset, fxAsset.TreasuryAccount, fxSeller, fxAsset.TreasuryAccount); await AssertHg.AssetBalanceAsync(fxAsset, fxBuyer, 0); await AssertHg.AssetBalanceAsync(fxAsset, fxSeller, 1); await AssertHg.AssetBalanceAsync(fxAsset, fxBenefactor, 0); await AssertHg.AssetBalanceAsync(fxAsset, fxAsset.TreasuryAccount, fxAsset.Metadata.Length - 1); await AssertHg.AssetBalanceAsync(fxAsset, fxPaymentToken.TreasuryAccount, 0); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxBuyer, 100); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxSeller, 0); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxBenefactor, 0); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxAsset.TreasuryAccount, 0); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxPaymentToken.TreasuryAccount, fxPaymentToken.Params.Circulation - 100); var record = await fxAsset.Client.TransferWithRecordAsync(new TransferParams { AssetTransfers = new[] { new AssetTransfer(movedAsset, fxSeller, fxBuyer) }, TokenTransfers = new[] { new TokenTransfer(fxPaymentToken, fxBuyer, -100), new TokenTransfer(fxPaymentToken, fxSeller, 100), }, Signatory = new Signatory(fxBuyer, fxSeller) }); Assert.Equal(ResponseCode.Success, record.Status); Assert.False(record.Hash.IsEmpty); Assert.NotNull(record.Concensus); Assert.NotNull(record.CurrentExchangeRate); Assert.NotNull(record.NextExchangeRate); Assert.Empty(record.Memo); Assert.InRange(record.Fee, 0UL, ulong.MaxValue); Assert.Equal(_network.Payer, record.Id.Address); Assert.Equal(3, record.TokenTransfers.Count); Assert.Contains(new TokenTransfer(fxPaymentToken, fxBuyer, -100), record.TokenTransfers); Assert.Contains(new TokenTransfer(fxPaymentToken, fxSeller, 50), record.TokenTransfers); Assert.Contains(new TokenTransfer(fxPaymentToken, fxBenefactor, 50), record.TokenTransfers); Assert.Single(record.AssetTransfers); Assert.Contains(new AssetTransfer(movedAsset, fxSeller, fxBuyer), record.AssetTransfers); Assert.Empty(record.Associations); Assert.Single(record.Royalties); AssertHg.ContainsRoyalty(fxPaymentToken, fxSeller, fxBenefactor, 50, record.Royalties); await AssertHg.AssetBalanceAsync(fxAsset, fxBuyer, 1); await AssertHg.AssetBalanceAsync(fxAsset, fxSeller, 0); await AssertHg.AssetBalanceAsync(fxAsset, fxBenefactor, 0); await AssertHg.AssetBalanceAsync(fxAsset, fxAsset.TreasuryAccount, fxAsset.Metadata.Length - 1); await AssertHg.AssetBalanceAsync(fxAsset, fxPaymentToken.TreasuryAccount, 0); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxBuyer, 0); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxSeller, 50); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxBenefactor, 50); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxAsset.TreasuryAccount, 0); await AssertHg.TokenBalanceAsync(fxPaymentToken, fxPaymentToken.TreasuryAccount, fxPaymentToken.Params.Circulation - 100); }