@@ -3233,9 +3233,9 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
32333233 & mut self ,
32343234 outpoint : UtxoOutPoint ,
32353235 utxo : Utxo ,
3236- spent : bool ,
32373236 addresses : & [ & str ] ,
32383237 ) -> Result < ( ) , ApiServerStorageError > {
3238+ let spent = utxo. spent ( ) ;
32393239 self . tx
32403240 . execute (
32413241 "INSERT INTO ml.mempool_utxo (outpoint, utxo, spent)
@@ -3488,7 +3488,6 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
34883488 SELECT utxo, spent
34893489 FROM ml.mempool_utxo
34903490 WHERE outpoint = ua.outpoint
3491- ORDER BY block_height DESC
34923491 LIMIT 1
34933492 ) u
34943493 WHERE ua.address = $1 AND u.spent = false;"# ,
@@ -3581,7 +3580,7 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
35813580 let coin_or_token_id = CoinOrTokenId :: TokenId ( token_id) ;
35823581 self . tx
35833582 . execute (
3584- "INSERT INTO ml.mempool_coin_or_token_decimals (coin_or_token_id, number_of_decimals) VALUES ($1, $2, $3 );" ,
3583+ "INSERT INTO ml.mempool_coin_or_token_decimals (coin_or_token_id, number_of_decimals) VALUES ($1, $2);" ,
35853584 & [ & coin_or_token_id. encode ( ) , & ( issuance. number_of_decimals as i16 ) ] ,
35863585 )
35873586 . await
@@ -3617,7 +3616,7 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
36173616 let coin_or_token_id = CoinOrTokenId :: TokenId ( token_id) ;
36183617 self . tx
36193618 . execute (
3620- "INSERT INTO ml.mempool_coin_or_token_decimals (coin_or_token_id, number_of_decimals) VALUES ($1, $2, $3 );" ,
3619+ "INSERT INTO ml.mempool_coin_or_token_decimals (coin_or_token_id, number_of_decimals) VALUES ($1, $2);" ,
36213620 & [ & coin_or_token_id. encode ( ) , & 0_i16 ] ,
36223621 )
36233622 . await
@@ -3629,11 +3628,12 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
36293628 & self ,
36303629 token_id : TokenId ,
36313630 ) -> Result < Option < u8 > , ApiServerStorageError > {
3631+ let coin_or_token_id = CoinOrTokenId :: TokenId ( token_id) ;
36323632 let res = self
36333633 . tx
36343634 . query_opt (
36353635 "SELECT number_of_decimals FROM ml.mempool_coin_or_token_decimals WHERE coin_or_token_id = $1" ,
3636- & [ & token_id . encode ( ) ] ,
3636+ & [ & coin_or_token_id . encode ( ) ] ,
36373637 )
36383638 . await
36393639 . map_err ( |e| ApiServerStorageError :: LowLevelStorageError ( e. to_string ( ) ) ) ?;
@@ -3685,9 +3685,7 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
36853685 chain_config : & ChainConfig ,
36863686 ) -> Result < ( ) , ApiServerStorageError > {
36873687 let order_id_addr = Address :: new ( chain_config, order_id)
3688- . map_err ( |_| ApiServerStorageError :: AddressableError ) ?
3689- . as_str ( )
3690- . to_string ( ) ;
3688+ . map_err ( |_| ApiServerStorageError :: AddressableError ) ?;
36913689
36923690 self . tx
36933691 . execute (
@@ -3697,12 +3695,12 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
36973695 ON CONFLICT (order_id) DO UPDATE SET initially_asked = EXCLUDED.initially_asked, ask_balance = EXCLUDED.ask_balance, ask_currency = EXCLUDED.ask_currency, initially_given = EXCLUDED.initially_given, give_balance = EXCLUDED.give_balance, give_currency = EXCLUDED.give_currency, conclude_destination = EXCLUDED.conclude_destination, next_nonce = EXCLUDED.next_nonce, frozen = EXCLUDED.frozen;
36983696 "# ,
36993697 & [
3700- & order_id_addr,
3701- & order. initially_asked . encode ( ) ,
3702- & order. ask_balance . encode ( ) ,
3698+ & order_id_addr. as_str ( ) ,
3699+ & amount_to_str ( order. initially_asked ) ,
3700+ & amount_to_str ( order. ask_balance ) ,
37033701 & order. ask_currency . encode ( ) ,
3704- & order. initially_given . encode ( ) ,
3705- & order. give_balance . encode ( ) ,
3702+ & amount_to_str ( order. initially_given ) ,
3703+ & amount_to_str ( order. give_balance ) ,
37063704 & order. give_currency . encode ( ) ,
37073705 & order. conclude_destination . encode ( ) ,
37083706 & order. next_nonce . encode ( ) ,
@@ -3729,6 +3727,7 @@ impl<'a, 'b> QueryFromConnection<'a, 'b> {
37293727 ml.mempool_token_transactions,
37303728 ml.mempool_fungible_token,
37313729 ml.mempool_nft_issuance,
3730+ ml.mempool_orders,
37323731 ml.mempool_coin_or_token_decimals
37333732 RESTART IDENTITY CASCADE;" ,
37343733 )
@@ -3754,7 +3753,7 @@ fn decode_order_from_row(
37543753 let give_currency: Vec < u8 > = data. get ( "give_currency" ) ;
37553754 let conclude_destination: Vec < u8 > = data. get ( "conclude_destination" ) ;
37563755 let next_nonce: Vec < u8 > = data. get ( "next_nonce" ) ;
3757- let creation_block_height: Option < i64 > = data. get ( "creation_block_height" ) ;
3756+ let creation_block_height: Option < i64 > = data. try_get ( "creation_block_height" ) . ok ( ) . flatten ( ) ;
37583757 let is_frozen: bool = data. get ( "frozen" ) ;
37593758
37603759 let order_id = Address :: < OrderId > :: from_string ( chain_config, order_id)
0 commit comments