Skip to content

Commit c5c1546

Browse files
committed
2.2.1
1 parent 61ea8e1 commit c5c1546

File tree

6 files changed

+97
-18
lines changed

6 files changed

+97
-18
lines changed
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
using System.Collections.Generic;
2+
3+
namespace chia.dotnet
4+
{
5+
public record BlockSpendWithConditions
6+
{
7+
public CoinSpend CoinSpend { get; init; } = new();
8+
public IEnumerable<ConditionWithArgs> Conditions { get; init; } = new List<ConditionWithArgs>();
9+
}
10+
}

src/chia-dotnet/ChiaTypes/ConditionWithArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace chia.dotnet
88
/// </summary>
99
public record ConditionWithArgs
1010
{
11-
public string Opcode { get; init; } = string.Empty;
11+
public ushort Opcode { get; init; }
1212
public IEnumerable<string> Vars { get; init; } = new List<string>();
1313
}
1414
}

src/chia-dotnet/DAOWallet.cs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public override async Task Validate(CancellationToken cancellationToken = defaul
3434
/// <param name="includeClosed"></param>
3535
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
3636
/// <returns></returns>
37-
public async Task<(IEnumerable<ProposalInfo> proposals, ulong proposalTimelock, ulong softCloseLength)> DaoGetProposals(bool includeClosed = true, CancellationToken cancellationToken = default)
37+
public async Task<(IEnumerable<ProposalInfo> proposals, ulong proposalTimelock, ulong softCloseLength)> GetProposals(bool includeClosed = true, CancellationToken cancellationToken = default)
3838
{
3939
dynamic data = CreateWalletDataObject();
4040
data.include_closed = includeClosed;
@@ -52,7 +52,7 @@ public override async Task Validate(CancellationToken cancellationToken = defaul
5252
/// <param name="proposalType"></param>
5353
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
5454
/// <returns></returns>
55-
public async Task<(string proposalId, string txId, TransactionRecord tx)> DaoCreateProposal(string proposalType, CancellationToken cancellationToken = default)
55+
public async Task<(string proposalId, string txId, TransactionRecord tx)> CreateProposal(string proposalType, CancellationToken cancellationToken = default)
5656
{
5757
dynamic data = CreateWalletDataObject();
5858
data.proposal_type = proposalType;
@@ -71,7 +71,7 @@ public override async Task Validate(CancellationToken cancellationToken = defaul
7171
/// <param name="proposalId"></param>
7272
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
7373
/// <returns>Dictionary</returns>
74-
public async Task<IDictionary<string, object>> DaoParseProposal(string proposalId, CancellationToken cancellationToken = default)
74+
public async Task<IDictionary<string, object>> ParseProposal(string proposalId, CancellationToken cancellationToken = default)
7575
{
7676
dynamic data = CreateWalletDataObject();
7777
data.proposal_id = proposalId;
@@ -87,7 +87,7 @@ public async Task<IDictionary<string, object>> DaoParseProposal(string proposalI
8787
/// <param name="proposalId"></param>
8888
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
8989
/// <returns></returns>
90-
public async Task<(string txId, TransactionRecord tx)> DaoVoteOnProposal(bool isYesVote, ulong voteAmount, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
90+
public async Task<(string txId, TransactionRecord tx)> VoteOnProposal(bool isYesVote, ulong voteAmount, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
9191
{
9292
dynamic data = CreateWalletDataObject();
9393
data.proposal_id = proposalId;
@@ -106,7 +106,7 @@ public async Task<IDictionary<string, object>> DaoParseProposal(string proposalI
106106
/// </summary>
107107
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
108108
/// <returns></returns>
109-
public async Task<IDictionary<string, ulong>> DaoGetTreasuryBalance(CancellationToken cancellationToken = default)
109+
public async Task<IDictionary<string, ulong>> GetTreasuryBalance(CancellationToken cancellationToken = default)
110110
{
111111
dynamic data = CreateWalletDataObject();
112112
return await WalletProxy.SendMessage<IDictionary<string, ulong>>("dao_get_treasury_balance", data, cancellationToken).ConfigureAwait(false);
@@ -117,7 +117,7 @@ public async Task<IDictionary<string, ulong>> DaoGetTreasuryBalance(Cancellation
117117
/// </summary>
118118
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
119119
/// <returns><see cref="string"/></returns>
120-
public async Task<string> DaoGetTreasuryId(CancellationToken cancellationToken = default)
120+
public async Task<string> GetTreasuryId(CancellationToken cancellationToken = default)
121121
{
122122
dynamic data = CreateWalletDataObject();
123123
return await WalletProxy.SendMessage<string>("dao_get_treasury_id", data, "treasury_id", cancellationToken).ConfigureAwait(false);
@@ -128,7 +128,7 @@ public async Task<string> DaoGetTreasuryId(CancellationToken cancellationToken =
128128
/// </summary>
129129
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
130130
/// <returns><see cref="DAORules"/></returns>
131-
public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = default)
131+
public async Task<DAORules> GetRules(CancellationToken cancellationToken = default)
132132
{
133133
dynamic data = CreateWalletDataObject();
134134
return await WalletProxy.SendMessage<DAORules>("dao_get_rules", data, "rules", cancellationToken).ConfigureAwait(false);
@@ -143,7 +143,7 @@ public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = de
143143
/// <param name="proposalId"></param>
144144
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
145145
/// <returns></returns>
146-
public async Task<(string txId, TransactionRecord tx)> DaoCloseProposal(string selfDestruct, string genesisId, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
146+
public async Task<(string txId, TransactionRecord tx)> CloseProposal(string selfDestruct, string genesisId, string proposalId, ulong fee = 0, CancellationToken cancellationToken = default)
147147
{
148148
dynamic data = CreateWalletDataObject();
149149
data.proposal_id = proposalId;
@@ -163,7 +163,7 @@ public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = de
163163
/// <param name="coins"></param>
164164
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
165165
/// <returns></returns>
166-
public async Task<(string txId, TransactionRecord tx)> DaoExitLockup(IEnumerable<object> coins, ulong fee = 0, CancellationToken cancellationToken = default)
166+
public async Task<(string txId, TransactionRecord tx)> ExitLockup(IEnumerable<object> coins, ulong fee = 0, CancellationToken cancellationToken = default)
167167
{
168168
dynamic data = CreateWalletDataObject();
169169
data.coins = coins;
@@ -181,7 +181,7 @@ public async Task<DAORules> DaoGetRules(CancellationToken cancellationToken = de
181181
/// <param name="filterLevel"></param>
182182
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
183183
/// <returns><see cref="DAOInfo"/></returns>
184-
public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationToken cancellationToken = default)
184+
public async Task<DAOInfo> AdjustFilterLevel(ulong filterLevel, CancellationToken cancellationToken = default)
185185
{
186186
dynamic data = CreateWalletDataObject();
187187
data.filter_level = filterLevel;
@@ -196,7 +196,7 @@ public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationT
196196
/// <param name="fundingWalletId"></param>
197197
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
198198
/// <returns></returns>
199-
public async Task<(string txId, TransactionRecord tx)> DaoAddFundsToTreasury(ulong amount, uint fundingWalletId, ulong fee = 0, CancellationToken cancellationToken = default)
199+
public async Task<(string txId, TransactionRecord tx)> AddFundsToTreasury(ulong amount, uint fundingWalletId, ulong fee = 0, CancellationToken cancellationToken = default)
200200
{
201201
dynamic data = CreateWalletDataObject();
202202
data.funding_wallet_id = fundingWalletId;
@@ -216,7 +216,7 @@ public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationT
216216
/// <param name="amount"></param>
217217
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
218218
/// <returns></returns>
219-
public async Task<(string txId, TransactionRecord tx)> DaoSendToLockup(ulong amount, ulong fee = 0, CancellationToken cancellationToken = default)
219+
public async Task<(string txId, TransactionRecord tx)> SendToLockup(ulong amount, ulong fee = 0, CancellationToken cancellationToken = default)
220220
{
221221
dynamic data = CreateWalletDataObject();
222222
data.amount = amount;
@@ -241,7 +241,7 @@ public async Task<DAOInfo> DaoAdjustFilterLevel(ulong filterLevel, CancellationT
241241
/// <param name="proposalId"></param>
242242
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
243243
/// <returns><see cref="ProposalState"/></returns>
244-
public async Task<ProposalState> DaoGetProposalState(string proposalId, CancellationToken cancellationToken = default)
244+
public async Task<ProposalState> GetProposalState(string proposalId, CancellationToken cancellationToken = default)
245245
{
246246
dynamic data = CreateWalletDataObject();
247247
data.proposal_id = proposalId;
@@ -254,7 +254,7 @@ public async Task<ProposalState> DaoGetProposalState(string proposalId, Cancella
254254
/// <param name="fee"></param>
255255
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
256256
/// <returns></returns>
257-
public async Task<(string txId, TransactionRecord tx)> DaoFreeCoinsFromFinishedProposals(ulong fee = 0, CancellationToken cancellationToken = default)
257+
public async Task<(string txId, TransactionRecord tx)> FreeCoinsFromFinishedProposals(ulong fee = 0, CancellationToken cancellationToken = default)
258258
{
259259
dynamic data = CreateWalletDataObject();
260260
data.fee = fee;

src/chia-dotnet/FullNodeProxy.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -673,5 +673,18 @@ public async Task<TimeSpan> GetAverageBlockTime(CancellationToken cancellationTo
673673
return SECONDS_PER_BLOCK;
674674
}
675675
}
676+
677+
/// <summary>
678+
/// Retrieves the spends in the given block, including its conditions.
679+
/// </summary>
680+
/// <param name="headerHash"></param>
681+
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
682+
/// <returns>A list of <see cref="BlockSpendWithConditions"/></returns>
683+
public async Task<IEnumerable<BlockSpendWithConditions>> GetBlockSpendsWithConditions(string headerHash, CancellationToken cancellationToken = default)
684+
{
685+
dynamic data = new ExpandoObject();
686+
data.header_hash = headerHash;
687+
return await SendMessage<IEnumerable<BlockSpendWithConditions>>("get_block_spends_with_conditions", data, "block_spends_with_conditions", cancellationToken).ConfigureAwait(false);
688+
}
676689
}
677690
}

src/chia-dotnet/WalletProxy.cs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1110,5 +1110,61 @@ public async Task<IEnumerable<string>> SpendClawbackCoins(IEnumerable<string> co
11101110
data.batch_size = batchSize;
11111111
return await SendMessage<IEnumerable<string>>("spend_clawback_coins", data, "transaction_ids", cancellationToken).ConfigureAwait(false);
11121112
}
1113+
1114+
/// <summary>
1115+
/// Create a new CAT wallet
1116+
/// </summary>
1117+
/// <param name="daoRules"></param>
1118+
/// <param name="amountOfCats"></param>
1119+
/// <param name="filterAmount"></param>
1120+
/// <param name="feeForCat">Fee (in units of mojos)</param>
1121+
/// <param name="fee">Fee (in units of mojos)</param>
1122+
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
1123+
/// <returns>Information about the wallet</returns>
1124+
public async Task<(WalletType Type, string TreasuryId, uint WalletId, uint CatWalletId, uint DaoCatWalletId)>
1125+
CreateNewDAOWallet(DAORules? daoRules = null, ulong? amountOfCats = null, ulong filterAmount = 1, ulong feeForCat = 0, ulong fee = 0, CancellationToken cancellationToken = default)
1126+
{
1127+
dynamic data = new ExpandoObject();
1128+
data.wallet_type = "dao_wallet";
1129+
data.mode = "new";
1130+
data.dao_rules = daoRules;
1131+
data.amount_of_cats = amountOfCats;
1132+
data.filter_amount = filterAmount;
1133+
data.fee_for_cat = feeForCat;
1134+
data.fee = fee;
1135+
var response = await SendMessage("create_new_wallet", data, cancellationToken).ConfigureAwait(false);
1136+
return (
1137+
(WalletType)response.type,
1138+
response.treasury_id,
1139+
(uint)response.wallet_id,
1140+
(uint)response.cat_wallet_id,
1141+
(uint)response.dao_cat_wallet_id
1142+
);
1143+
}
1144+
1145+
/// <summary>
1146+
/// Create a new CAT wallet
1147+
/// </summary>
1148+
/// <param name="treasuryId"></param>
1149+
/// <param name="filterAmount"></param>
1150+
/// <param name="cancellationToken">A token to allow the call to be cancelled</param>
1151+
/// <returns>Information about the wallet</returns>
1152+
public async Task<(WalletType Type, string TreasuryId, uint WalletId, uint CatWalletId, uint DaoCatWalletId)>
1153+
CreateExistingDAOWallet(string treasuryId, ulong filterAmount = 1, CancellationToken cancellationToken = default)
1154+
{
1155+
dynamic data = new ExpandoObject();
1156+
data.wallet_type = "dao_wallet";
1157+
data.mode = "existing";
1158+
data.treasury_id = treasuryId;
1159+
data.filter_amount = filterAmount;
1160+
var response = await SendMessage("create_new_wallet", data, cancellationToken).ConfigureAwait(false);
1161+
return (
1162+
(WalletType)response.type,
1163+
response.treasury_id,
1164+
(uint)response.wallet_id,
1165+
(uint)response.cat_wallet_id,
1166+
(uint)response.dao_cat_wallet_id
1167+
);
1168+
}
11131169
}
11141170
}

src/chia-dotnet/chia-dotnet.csproj

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
<GenerateDocumentationFile>true</GenerateDocumentationFile>
88
<NoWarn>$(NoWarn);CS1591</NoWarn>
99
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
10-
<Version>2.2.0</Version>
10+
<Version>2.2.1</Version>
1111
<Authors>dkackman</Authors>
1212
<Company>dkackman</Company>
1313
<Description>A .net client library for chia™ RPC interfaces that runs on linux and windows.</Description>
@@ -21,8 +21,8 @@
2121
<PackageReleaseNotes>Add Dao Wallet</PackageReleaseNotes>
2222
<PackageIcon>chia-leaf-logo-384x384.png</PackageIcon>
2323
<PackageIconUrl />
24-
<AssemblyVersion>2.2.0.0</AssemblyVersion>
25-
<FileVersion>2.2.0.0</FileVersion>
24+
<AssemblyVersion>2.2.1.0</AssemblyVersion>
25+
<FileVersion>2.2.1.0</FileVersion>
2626
<Nullable>enable</Nullable>
2727
<Title>chia.dotnet</Title>
2828
<PackageReadmeFile>README.md</PackageReadmeFile>

0 commit comments

Comments
 (0)