public void ChangeTrustOperation() { // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF var source = KeyPair.FromSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); var assetCode = "EUR"; var asset = new Stellar.Generated.Asset { Discriminant = Stellar.Generated.AssetType.Create( Stellar.Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4), AlphaNum4 = new Stellar.Generated.Asset.AssetAlphaNum4 { AssetCode = Encoding.ASCII.GetBytes(assetCode), Issuer = source.AccountId } }; long limit = 100; ChangeTrustOperation operation = new ChangeTrustOperation.Builder(asset, limit) .SetSourceAccount(source) .Build(); Stellar.Generated.Operation xdr = operation.ToXdr(); ChangeTrustOperation parsedOperation = Stellar.ChangeTrustOperation.FromXdr(xdr); Assert.AreEqual(source.Address, parsedOperation.SourceAccount.Address); Assert.AreEqual("EUR", Encoding.ASCII.GetString(parsedOperation.Asset.AlphaNum4.AssetCode)); Assert.AreEqual(Stellar.Generated.AssetType.AssetTypeEnum.ASSET_TYPE_CREDIT_ALPHANUM4, parsedOperation.Asset.Discriminant.InnerValue); Assert.AreEqual(limit, parsedOperation.Limit); Assert.AreEqual("AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAYAAAABRVVSAAAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAAAAABk", operation.ToXdrBase64()); }
public void TestChangeTrustOperation() { // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF var source = KeyPair.FromSecretSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); Asset asset = new AssetTypeNative(); var limit = "922337203685.4775807"; var operation = new ChangeTrustOperation.Builder(asset, limit) .SetSourceAccount(source) .Build(); var xdr = operation.ToXdr(); var parsedOperation = (ChangeTrustOperation)Operation.FromXdr(xdr); Assert.AreEqual(9223372036854775807L, xdr.Body.ChangeTrustOp.Limit.InnerValue); Assert.AreEqual(source.AccountId, parsedOperation.SourceAccount.AccountId); Assert.IsTrue(parsedOperation.Asset is AssetTypeNative); Assert.AreEqual(limit, parsedOperation.Limit); Assert.AreEqual(OperationThreshold.Medium, parsedOperation.Threshold); Assert.AreEqual( "AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAYAAAAAf/////////8=", operation.ToXdrBase64()); }
public void ChangeTrustOperation() { // GC5SIC4E3V56VOHJ3OZAX5SJDTWY52JYI2AFK6PUGSXFVRJQYQXXZBZF KeyPair source = KeyPair.FromSeed("SC4CGETADVYTCR5HEAVZRB3DZQY5Y4J7RFNJTRA6ESMHIPEZUSTE2QDK"); var assetCode = "EUR"; var asset = new Asset(assetCode, source); long limit = 100; ChangeTrustOperation operation = new ChangeTrustOperation.Builder(asset, limit) .SetSourceAccount(source) .Build(); Assert.AreEqual(source.Address, operation.SourceAccount.Address); Assert.AreEqual(assetCode, operation.Asset.Code); Assert.AreEqual(asset.Issuer.Address, operation.Asset.Issuer.Address); Assert.AreEqual(asset.Type, operation.Asset.Type); Assert.AreEqual(limit, operation.Limit); Assert.AreEqual("AAAAAQAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAYAAAABRVVSAAAAAAC7JAuE3XvquOnbsgv2SRztjuk4RoBVefQ0rlrFMMQvfAAAAAAAAABk", operation.ToXdrBase64()); Stellar.Generated.Operation xdr = operation.ToXDR(); ChangeTrustOperation parsedOperation = Stellar.ChangeTrustOperation.FromXDR(xdr); Assert.AreEqual(source.Address, parsedOperation.SourceAccount.Address); Assert.AreEqual("EUR", parsedOperation.Asset.Code); Assert.AreEqual(source.Address, parsedOperation.Asset.Issuer.Address); Assert.AreEqual(limit, parsedOperation.Limit); }