Skip to content

Commit

Permalink
2.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dkackman committed Dec 15, 2023
1 parent 61ea8e1 commit c5c1546
Show file tree
Hide file tree
Showing 6 changed files with 97 additions and 18 deletions.
10 changes: 10 additions & 0 deletions src/chia-dotnet/ChiaTypes/BlockSpendWithConditions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
using System.Collections.Generic;

namespace chia.dotnet
{
public record BlockSpendWithConditions
{
public CoinSpend CoinSpend { get; init; } = new();
public IEnumerable<ConditionWithArgs> Conditions { get; init; } = new List<ConditionWithArgs>();
}
}
2 changes: 1 addition & 1 deletion src/chia-dotnet/ChiaTypes/ConditionWithArgs.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ namespace chia.dotnet
/// </summary>
public record ConditionWithArgs
{
public string Opcode { get; init; } = string.Empty;
public ushort Opcode { get; init; }
public IEnumerable<string> Vars { get; init; } = new List<string>();
}
}
28 changes: 14 additions & 14 deletions src/chia-dotnet/DAOWallet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public override async Task Validate(CancellationToken cancellationToken = defaul
/// <param name="includeClosed"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(IEnumerable<ProposalInfo> proposals, ulong proposalTimelock, ulong softCloseLength)> DaoGetProposals(bool includeClosed = true, CancellationToken cancellationToken = default)
public async Task<(IEnumerable<ProposalInfo> proposals, ulong proposalTimelock, ulong softCloseLength)> GetProposals(bool includeClosed = true, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.include_closed = includeClosed;
Expand All @@ -52,7 +52,7 @@ public override async Task Validate(CancellationToken cancellationToken = defaul
/// <param name="proposalType"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(string proposalId, string txId, TransactionRecord tx)> DaoCreateProposal(string proposalType, CancellationToken cancellationToken = default)
public async Task<(string proposalId, string txId, TransactionRecord tx)> CreateProposal(string proposalType, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.proposal_type = proposalType;
Expand All @@ -71,7 +71,7 @@ public override async Task Validate(CancellationToken cancellationToken = defaul
/// <param name="proposalId"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns>Dictionary</returns>
public async Task<IDictionary<string, object>> DaoParseProposal(string proposalId, CancellationToken cancellationToken = default)
public async Task<IDictionary<string, object>> ParseProposal(string proposalId, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.proposal_id = proposalId;
Expand All @@ -87,7 +87,7 @@ public async Task<IDictionary<string, object>> DaoParseProposal(string proposalI
/// <param name="proposalId"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(string txId, TransactionRecord tx)> DaoVoteOnProposal(bool isYesVote, ulong voteAmount, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
public async Task<(string txId, TransactionRecord tx)> VoteOnProposal(bool isYesVote, ulong voteAmount, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.proposal_id = proposalId;
Expand All @@ -106,7 +106,7 @@ public async Task<IDictionary<string, object>> DaoParseProposal(string proposalI
/// </summary>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<IDictionary<string, ulong>> DaoGetTreasuryBalance(CancellationToken cancellationToken = default)
public async Task<IDictionary<string, ulong>> GetTreasuryBalance(CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
return await WalletProxy.SendMessage<IDictionary<string, ulong>>("dao_get_treasury_balance", data, cancellationToken).ConfigureAwait(false);
Expand All @@ -117,7 +117,7 @@ public async Task<IDictionary<string, ulong>> DaoGetTreasuryBalance(Cancellation
/// </summary>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns><see cref="string"/></returns>
public async Task<string> DaoGetTreasuryId(CancellationToken cancellationToken = default)
public async Task<string> GetTreasuryId(CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
return await WalletProxy.SendMessage<string>("dao_get_treasury_id", data, "treasury_id", cancellationToken).ConfigureAwait(false);
Expand All @@ -128,7 +128,7 @@ public async Task<string> DaoGetTreasuryId(CancellationToken cancellationToken =
/// </summary>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns><see cref="DAORules"/></returns>
public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = default)
public async Task<DAORules> GetRules(CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
return await WalletProxy.SendMessage<DAORules>("dao_get_rules", data, "rules", cancellationToken).ConfigureAwait(false);
Expand All @@ -143,7 +143,7 @@ public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = de
/// <param name="proposalId"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(string txId, TransactionRecord tx)> DaoCloseProposal(string selfDestruct, string genesisId, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
public async Task<(string txId, TransactionRecord tx)> CloseProposal(string selfDestruct, string genesisId, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.proposal_id = proposalId;
Expand All @@ -163,7 +163,7 @@ public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = de
/// <param name="coins"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(string txId, TransactionRecord tx)> DaoExitLockup(IEnumerable<object> coins, ulong fee = 0, CancellationToken cancellationToken = default)
public async Task<(string txId, TransactionRecord tx)> ExitLockup(IEnumerable<object> coins, ulong fee = 0, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.coins = coins;
Expand All @@ -181,7 +181,7 @@ public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = de
/// <param name="filterLevel"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns><see cref="DAOInfo"/></returns>
public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationToken cancellationToken = default)
public async Task<DAOInfo> AdjustFilterLevel(ulong filterLevel, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.filter_level = filterLevel;
Expand All @@ -196,7 +196,7 @@ public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationT
/// <param name="fundingWalletId"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(string txId, TransactionRecord tx)> DaoAddFundsToTreasury(ulong amount, uint fundingWalletId, ulong fee = 0, CancellationToken cancellationToken = default)
public async Task<(string txId, TransactionRecord tx)> AddFundsToTreasury(ulong amount, uint fundingWalletId, ulong fee = 0, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.funding_wallet_id = fundingWalletId;
Expand All @@ -216,7 +216,7 @@ public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationT
/// <param name="amount"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(string txId, TransactionRecord tx)> DaoSendToLockup(ulong amount, ulong fee = 0, CancellationToken cancellationToken = default)
public async Task<(string txId, TransactionRecord tx)> SendToLockup(ulong amount, ulong fee = 0, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.amount = amount;
Expand All @@ -241,7 +241,7 @@ public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationT
/// <param name="proposalId"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns><see cref="ProposalState"/></returns>
public async Task<ProposalState> DaoGetProposalState(string proposalId, CancellationToken cancellationToken = default)
public async Task<ProposalState> GetProposalState(string proposalId, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.proposal_id = proposalId;
Expand All @@ -254,7 +254,7 @@ public async Task<ProposalState> DaoGetProposalState(string proposalId, Cancella
/// <param name="fee"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns></returns>
public async Task<(string txId, TransactionRecord tx)> DaoFreeCoinsFromFinishedProposals(ulong fee = 0, CancellationToken cancellationToken = default)
public async Task<(string txId, TransactionRecord tx)> FreeCoinsFromFinishedProposals(ulong fee = 0, CancellationToken cancellationToken = default)
{
dynamic data = CreateWalletDataObject();
data.fee = fee;
Expand Down
13 changes: 13 additions & 0 deletions src/chia-dotnet/FullNodeProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -673,5 +673,18 @@ public async Task<TimeSpan> GetAverageBlockTime(CancellationToken cancellationTo
return SECONDS_PER_BLOCK;
}
}

/// <summary>
/// Retrieves the spends in the given block, including its conditions.
/// </summary>
/// <param name="headerHash"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns>A list of <see cref="BlockSpendWithConditions"/></returns>
public async Task<IEnumerable<BlockSpendWithConditions>> GetBlockSpendsWithConditions(string headerHash, CancellationToken cancellationToken = default)
{
dynamic data = new ExpandoObject();
data.header_hash = headerHash;
return await SendMessage<IEnumerable<BlockSpendWithConditions>>("get_block_spends_with_conditions", data, "block_spends_with_conditions", cancellationToken).ConfigureAwait(false);
}
}
}
56 changes: 56 additions & 0 deletions src/chia-dotnet/WalletProxy.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1110,5 +1110,61 @@ public async Task<IEnumerable<string>> SpendClawbackCoins(IEnumerable<string> co
data.batch_size = batchSize;
return await SendMessage<IEnumerable<string>>("spend_clawback_coins", data, "transaction_ids", cancellationToken).ConfigureAwait(false);
}

/// <summary>
/// Create a new CAT wallet
/// </summary>
/// <param name="daoRules"></param>
/// <param name="amountOfCats"></param>
/// <param name="filterAmount"></param>
/// <param name="feeForCat">Fee (in units of mojos)</param>
/// <param name="fee">Fee (in units of mojos)</param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns>Information about the wallet</returns>
public async Task<(WalletType Type, string TreasuryId, uint WalletId, uint CatWalletId, uint DaoCatWalletId)>
CreateNewDAOWallet(DAORules? daoRules = null, ulong? amountOfCats = null, ulong filterAmount = 1, ulong feeForCat = 0, ulong fee = 0, CancellationToken cancellationToken = default)
{
dynamic data = new ExpandoObject();
data.wallet_type = "dao_wallet";
data.mode = "new";
data.dao_rules = daoRules;
data.amount_of_cats = amountOfCats;
data.filter_amount = filterAmount;
data.fee_for_cat = feeForCat;
data.fee = fee;
var response = await SendMessage("create_new_wallet", data, cancellationToken).ConfigureAwait(false);
return (
(WalletType)response.type,
response.treasury_id,
(uint)response.wallet_id,
(uint)response.cat_wallet_id,
(uint)response.dao_cat_wallet_id
);
}

/// <summary>
/// Create a new CAT wallet
/// </summary>
/// <param name="treasuryId"></param>
/// <param name="filterAmount"></param>
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
/// <returns>Information about the wallet</returns>
public async Task<(WalletType Type, string TreasuryId, uint WalletId, uint CatWalletId, uint DaoCatWalletId)>
CreateExistingDAOWallet(string treasuryId, ulong filterAmount = 1, CancellationToken cancellationToken = default)
{
dynamic data = new ExpandoObject();
data.wallet_type = "dao_wallet";
data.mode = "existing";
data.treasury_id = treasuryId;
data.filter_amount = filterAmount;
var response = await SendMessage("create_new_wallet", data, cancellationToken).ConfigureAwait(false);
return (
(WalletType)response.type,
response.treasury_id,
(uint)response.wallet_id,
(uint)response.cat_wallet_id,
(uint)response.dao_cat_wallet_id
);
}
}
}
6 changes: 3 additions & 3 deletions src/chia-dotnet/chia-dotnet.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<NoWarn>$(NoWarn);CS1591</NoWarn>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>2.2.0</Version>
<Version>2.2.1</Version>
<Authors>dkackman</Authors>
<Company>dkackman</Company>
<Description>A .net client library for chia™ RPC interfaces that runs on linux and windows.</Description>
Expand All @@ -21,8 +21,8 @@
<PackageReleaseNotes>Add Dao Wallet</PackageReleaseNotes>
<PackageIcon>chia-leaf-logo-384x384.png</PackageIcon>
<PackageIconUrl />
<AssemblyVersion>2.2.0.0</AssemblyVersion>
<FileVersion>2.2.0.0</FileVersion>
<AssemblyVersion>2.2.1.0</AssemblyVersion>
<FileVersion>2.2.1.0</FileVersion>
<Nullable>enable</Nullable>
<Title>chia.dotnet</Title>
<PackageReadmeFile>README.md</PackageReadmeFile>
Expand Down

0 comments on commit c5c1546

Please sign in to comment.