Skip to content

Commit b315827

Browse files
authored
Clear signing updates (#349)
* reserved fee, p2 puzzle hash, message hashes * Requested payments, and NFTs * Update declarations
1 parent c73bb81 commit b315827

File tree

10 files changed

+270
-75
lines changed

10 files changed

+270
-75
lines changed

bindings/clear_signing.json

Lines changed: 21 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"fields": {
66
"launcher_id": "Bytes32",
77
"custody_hash": "TreeHash",
8-
"delegated_spend": "Spend"
8+
"delegated_spend": "Spend",
9+
"coin_id": "Option<Bytes32>"
910
}
1011
},
1112
"VaultTransaction": {
@@ -18,7 +19,11 @@
1819
"nfts": "Vec<ParsedNftTransfer>",
1920
"drop_coins": "Vec<DropCoin>",
2021
"fee_paid": "u64",
21-
"total_fee": "u64"
22+
"total_fee": "u64",
23+
"reserved_fee": "u64",
24+
"p2_puzzle_hash": "Bytes32",
25+
"coin_message_hash": "Option<Bytes32>",
26+
"puzzle_message_hash": "Bytes32"
2227
}
2328
},
2429
"ParsedPayment": {
@@ -46,11 +51,23 @@
4651
"coin": "Coin",
4752
"clawback": "Option<ClawbackV2>",
4853
"memos": "Vec<String>",
49-
"new_uris": "Vec<MetadataUpdate>",
50-
"latest_owner": "Option<Bytes32>",
54+
"old_state": "NftState",
55+
"new_state": "NftState",
56+
"royalty_puzzle_hash": "Bytes32",
57+
"royalty_basis_points": "u16",
5158
"includes_unverifiable_updates": "bool"
5259
}
5360
},
61+
"NftState": {
62+
"type": "class",
63+
"new": true,
64+
"remote": true,
65+
"fields": {
66+
"parsed_metadata": "Option<NftMetadata>",
67+
"metadata_updater_puzzle_hash": "Bytes32",
68+
"owner": "Option<Bytes32>"
69+
}
70+
},
5471
"TransferType": {
5572
"type": "enum",
5673
"values": ["Sent", "Burned", "Offered", "Received", "Updated"]

crates/chia-sdk-bindings/src/clear_signing.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ pub struct VaultSpendReveal {
99
pub launcher_id: Bytes32,
1010
pub custody_hash: TreeHash,
1111
pub delegated_spend: Spend,
12+
pub coin_id: Option<Bytes32>,
1213
}
1314

1415
impl From<VaultSpendReveal> for sdk::VaultSpendReveal {
@@ -17,6 +18,7 @@ impl From<VaultSpendReveal> for sdk::VaultSpendReveal {
1718
launcher_id: value.launcher_id,
1819
custody_hash: value.custody_hash,
1920
delegated_spend: value.delegated_spend.into(),
21+
coin_id: value.coin_id,
2022
}
2123
}
2224
}

crates/chia-sdk-bindings/src/lib.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,11 @@ pub use chia_sdk_coinset::{
7676
};
7777
pub use chia_sdk_driver::{
7878
Bulletin, BulletinMessage, Cat, CatInfo, Clawback, ClawbackV2, Delta, DropCoin,
79-
MedievalVaultHint, MedievalVaultInfo, MetadataUpdate, OptionInfo, OptionMetadata, OptionType,
80-
OptionUnderlying, P2ParentCoin, ParsedNftTransfer, ParsedPayment, RewardDistributorConstants,
81-
RewardDistributorState, RewardDistributorType, RoundRewardInfo, RoundTimeInfo, StreamedAsset,
82-
StreamingPuzzleInfo, TransferType, UriKind, VaultInfo, VaultTransaction,
79+
MedievalVaultHint, MedievalVaultInfo, MetadataUpdate, NftState, OptionInfo, OptionMetadata,
80+
OptionType, OptionUnderlying, P2ParentCoin, ParsedNftTransfer, ParsedPayment,
81+
RewardDistributorConstants, RewardDistributorState, RewardDistributorType, RoundRewardInfo,
82+
RoundTimeInfo, StreamedAsset, StreamingPuzzleInfo, TransferType, UriKind, VaultInfo,
83+
VaultTransaction,
8384
};
8485
pub use chia_sdk_types::{
8586
conditions::TradePrice,

crates/chia-sdk-driver/src/action_system/spends.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ pub struct Outputs {
4343
pub nfts: IndexMap<Id, Nft>,
4444
pub options: IndexMap<Id, OptionContract>,
4545
pub fee: u64,
46+
pub reserved_fee: u64,
4647
}
4748

4849
#[derive(Debug, Default, Clone, Copy, PartialEq, Eq, Hash)]
@@ -240,8 +241,8 @@ impl Spends<Unfinished> {
240241

241242
conditions = conditions.extend(self.conditions.optional.clone());
242243

243-
if self.outputs.fee > 0 {
244-
conditions = conditions.reserve_fee(self.outputs.fee);
244+
if self.outputs.reserved_fee > 0 {
245+
conditions = conditions.reserve_fee(self.outputs.reserved_fee);
245246
}
246247

247248
for (_, spend) in self.iter_conditions_spends() {

crates/chia-sdk-driver/src/actions/fee.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@ use crate::{Deltas, DriverError, Id, SpendAction, SpendContext, Spends};
33
#[derive(Debug, Clone, Copy)]
44
pub struct FeeAction {
55
pub amount: u64,
6+
pub reserved: bool,
67
}
78

89
impl FeeAction {
910
pub fn new(amount: u64) -> Self {
10-
Self { amount }
11+
Self {
12+
amount,
13+
reserved: true,
14+
}
1115
}
1216
}
1317

@@ -24,6 +28,10 @@ impl SpendAction for FeeAction {
2428
) -> Result<(), DriverError> {
2529
spends.outputs.fee += self.amount;
2630

31+
if self.reserved {
32+
spends.outputs.reserved_fee += self.amount;
33+
}
34+
2735
Ok(())
2836
}
2937
}

0 commit comments

Comments
 (0)