Skip to content

Commit 3a32132

Browse files
0.1.37
1 parent 397ca11 commit 3a32132

File tree

1 file changed

+28
-14
lines changed

1 file changed

+28
-14
lines changed

src/wallet.rs

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ use chia_puzzles::SINGLETON_LAUNCHER_HASH;
2626
use chia_wallet_sdk::client::{ClientError, Peer};
2727
use chia_wallet_sdk::driver::{
2828
get_merkle_tree, DataStore, DataStoreMetadata, DelegatedPuzzle, Did, DidInfo, DriverError,
29-
IntermediateLauncher, Launcher, Layer, NftMint, OracleLayer,
30-
SpendContext, SpendWithConditions, StandardLayer, WriterLayer,
29+
IntermediateLauncher, Launcher, Layer, NftMint, OracleLayer, SpendContext, SpendWithConditions,
30+
StandardLayer, WriterLayer,
3131
};
3232
// Import proof types from our own crate's rust module
3333
use crate::rust::{EveProof, LineageProof, Proof};
@@ -1263,7 +1263,7 @@ pub async fn mint_nft(
12631263
did_string: &str,
12641264
recipient_puzzle_hash: Bytes32,
12651265
metadata: NftMetadata,
1266-
royalty_puzzle_hash: Option<Bytes32>,
1266+
_royalty_puzzle_hash: Option<Bytes32>,
12671267
royalty_basis_points: u16,
12681268
fee: u64,
12691269
network: TargetNetwork,
@@ -1287,19 +1287,21 @@ pub async fn mint_nft(
12871287
};
12881288

12891289
// Create the DID singleton info (simplified DID structure)
1290-
let did_info = DidInfo::new(did_coin.coin_id(), None, 1, vec![], synthetic_key.derive_synthetic().to_bytes().into());
1290+
// Use the first 32 bytes of the public key (truncate from 48 to 32 bytes)
1291+
let public_key_bytes = synthetic_key.derive_synthetic().to_bytes();
1292+
let mut public_key_hash = [0u8; 32];
1293+
public_key_hash.copy_from_slice(&public_key_bytes[..32]);
1294+
let did_info: DidInfo<Vec<u8>> =
1295+
DidInfo::new(did_coin.coin_id(), None, 1, vec![], public_key_hash.into());
12911296

12921297
let did = Did::new(did_coin, did_proof, did_info);
12931298

12941299
// Create StandardLayer for spending coins
12951300
let p2 = StandardLayer::new(synthetic_key);
12961301

1297-
// Allocate metadata
1298-
let metadata_ptr = ctx.alloc(&metadata)?;
1299-
1300-
// Create the NFT mint configuration
1302+
// Create the NFT mint configuration with metadata
13011303
let nft_mint = NftMint::new(
1302-
metadata_ptr,
1304+
metadata,
13031305
recipient_puzzle_hash,
13041306
royalty_basis_points,
13051307
None, // No DID owner for now - we'll set this up differently
@@ -1321,7 +1323,7 @@ pub async fn mint_nft(
13211323
return Err(WalletError::Parse); // Not enough coins
13221324
}
13231325

1324-
let change = total_input - total_needed;
1326+
let _change = total_input - total_needed;
13251327
let change_puzzle_hash = StandardArgs::curry_tree_hash(synthetic_key).into();
13261328

13271329
// Spend the selected coins
@@ -1589,8 +1591,14 @@ pub async fn resolve_did_string_and_generate_proof(
15891591
let launcher_puzzle = launcher_spend.puzzle.to_clvm(&mut allocator)?;
15901592
let launcher_solution = launcher_spend.solution.to_clvm(&mut allocator)?;
15911593

1592-
let output = clvmr::run_program(&mut allocator, &clvmr::ChiaDialect::new(0), launcher_puzzle, launcher_solution, u64::MAX)
1593-
.map_err(|_| WalletError::Clvm)?;
1594+
let output = clvmr::run_program(
1595+
&mut allocator,
1596+
&clvmr::ChiaDialect::new(0),
1597+
launcher_puzzle,
1598+
launcher_solution,
1599+
u64::MAX,
1600+
)
1601+
.map_err(|_| WalletError::Clvm)?;
15941602

15951603
let conditions =
15961604
Vec::<Condition>::from_clvm(&allocator, output.1).map_err(|_| WalletError::Parse)?;
@@ -1650,8 +1658,14 @@ pub async fn resolve_did_string_and_generate_proof(
16501658
let spend_puzzle = spend.puzzle.to_clvm(&mut allocator)?;
16511659
let spend_solution = spend.solution.to_clvm(&mut allocator)?;
16521660

1653-
let spend_output = clvmr::run_program(&mut allocator, &clvmr::ChiaDialect::new(0), spend_puzzle, spend_solution, u64::MAX)
1654-
.map_err(|_| WalletError::Clvm)?;
1661+
let spend_output = clvmr::run_program(
1662+
&mut allocator,
1663+
&clvmr::ChiaDialect::new(0),
1664+
spend_puzzle,
1665+
spend_solution,
1666+
u64::MAX,
1667+
)
1668+
.map_err(|_| WalletError::Clvm)?;
16551669

16561670
let spend_conditions = Vec::<Condition>::from_clvm(&allocator, spend_output.1)
16571671
.map_err(|_| WalletError::Parse)?;

0 commit comments

Comments
 (0)