@@ -28,7 +28,7 @@ use ckb_types::{bytes::Bytes, packed, prelude::*, H160, H256};
28
28
use num_bigint:: { BigInt , BigUint } ;
29
29
use num_traits:: Zero ;
30
30
31
- use std:: collections:: { HashMap , HashSet } ;
31
+ use std:: collections:: { HashMap , HashSet , VecDeque } ;
32
32
use std:: convert:: TryInto ;
33
33
use std:: str:: FromStr ;
34
34
@@ -656,19 +656,21 @@ impl<C: CkbRpc> MercuryRpcImpl<C> {
656
656
AssetScriptType :: ChequeSender ( ref s) => {
657
657
script_set. insert ( CHEQUE . to_string ( ) ) ;
658
658
s. clone ( )
659
- } // AssetScriptType::Dao => {
660
- // script_set.insert(DAO.to_string());
661
- // script_set.insert(SECP256K1.to_string());
662
- // Address::new(
663
- // self.network_type,
664
- // AddressPayload::from_pubkey_hash(
665
- // self.network_type,
666
- // H160::from_slice(&cell.cell_output.lock().args().raw_data()[0..20])
667
- // .unwrap(),
668
- // ),
669
- // )
670
- // .to_string()
671
- // }
659
+ }
660
+ AssetScriptType :: Dao ( _) => {
661
+ // script_set.insert(DAO.to_string());
662
+ // script_set.insert(SECP256K1.to_string());
663
+ // Address::new(
664
+ // self.network_type,
665
+ // AddressPayload::from_pubkey_hash(
666
+ // self.network_type,
667
+ // H160::from_slice(&cell.cell_output.lock().args().raw_data()[0..20])
668
+ // .unwrap(),
669
+ // ),
670
+ // )
671
+ // .to_string()
672
+ unreachable ! ( )
673
+ }
672
674
} ;
673
675
674
676
pool_cells. push ( cell. clone ( ) ) ;
@@ -1767,15 +1769,6 @@ pub fn build_cheque_args(receiver_address: Address, sender_address: Address) ->
1767
1769
ret. pack ( )
1768
1770
}
1769
1771
1770
- #[ allow( clippy:: upper_case_acronyms) ]
1771
- pub enum AssetScriptType {
1772
- Secp256k1 ,
1773
- ACP ,
1774
- ChequeSender ( String ) ,
1775
- ChequeReceiver ( String ) ,
1776
- // Dao,
1777
- }
1778
-
1779
1772
pub fn address_to_identity ( address : & str ) -> InnerResult < Identity > {
1780
1773
let address = Address :: from_str ( address) . map_err ( CoreError :: CommonError ) ?;
1781
1774
let script = address_to_script ( address. payload ( ) ) ;
@@ -1817,3 +1810,138 @@ pub(crate) fn dedup_json_items(items: Vec<JsonItem>) -> Vec<JsonItem> {
1817
1810
items. dedup ( ) ;
1818
1811
items
1819
1812
}
1813
+
1814
+ #[ allow( clippy:: upper_case_acronyms) ]
1815
+ pub enum AssetScriptType {
1816
+ Secp256k1 ,
1817
+ ACP ,
1818
+ ChequeSender ( String ) ,
1819
+ ChequeReceiver ( String ) ,
1820
+ Dao ( Item ) ,
1821
+ }
1822
+
1823
+ #[ derive( Debug , Default ) ]
1824
+ pub struct TransferComponents {
1825
+ pub inputs : Vec < DetailedCell > ,
1826
+ pub outputs : Vec < packed:: CellOutput > ,
1827
+ pub outputs_data : Vec < packed:: Bytes > ,
1828
+ pub header_deps : Vec < packed:: Byte32 > ,
1829
+ pub script_deps : HashSet < String > ,
1830
+ pub signature_actions : HashMap < String , SignatureAction > ,
1831
+ pub type_witness_args : HashMap < usize , ( packed:: BytesOpt , packed:: BytesOpt ) > ,
1832
+ pub fee_change_cell_index : Option < usize > ,
1833
+ pub dao_reward_capacity : u64 ,
1834
+ pub dao_since_map : HashMap < usize , u64 > ,
1835
+ pub header_dep_map : HashMap < packed:: Byte32 , usize > ,
1836
+ }
1837
+
1838
+ impl TransferComponents {
1839
+ pub fn new ( ) -> Self {
1840
+ TransferComponents :: default ( )
1841
+ }
1842
+ }
1843
+
1844
+ #[ derive( Debug , Copy , Clone ) ]
1845
+ pub enum PoolCkbCategory {
1846
+ DaoClaim ,
1847
+ CellBase ,
1848
+ Acp ,
1849
+ NormalSecp ,
1850
+ }
1851
+
1852
+ #[ derive( Debug , Copy , Clone ) ]
1853
+ pub enum PoolUdtCategory {
1854
+ ChequeInTime ,
1855
+ ChequeOutTime ,
1856
+ SecpUdt ,
1857
+ Acp ,
1858
+ }
1859
+
1860
+ pub struct CkbCellsCache {
1861
+ pub items : Vec < Item > ,
1862
+ pub item_category_array : Vec < ( usize , PoolCkbCategory ) > ,
1863
+ pub array_index : usize ,
1864
+ pub cell_deque : VecDeque < ( DetailedCell , AssetScriptType ) > ,
1865
+ }
1866
+
1867
+ impl CkbCellsCache {
1868
+ pub fn new ( items : Vec < Item > ) -> Self {
1869
+ let mut item_category_array = vec ! [ ] ;
1870
+ for ( item_index, _) in items. iter ( ) . enumerate ( ) {
1871
+ for category_index in & [
1872
+ PoolCkbCategory :: DaoClaim ,
1873
+ PoolCkbCategory :: CellBase ,
1874
+ PoolCkbCategory :: Acp ,
1875
+ PoolCkbCategory :: NormalSecp ,
1876
+ ] {
1877
+ item_category_array. push ( ( item_index, category_index. to_owned ( ) ) )
1878
+ }
1879
+ }
1880
+ CkbCellsCache {
1881
+ items,
1882
+ item_category_array,
1883
+ array_index : 0 ,
1884
+ cell_deque : VecDeque :: new ( ) ,
1885
+ }
1886
+ }
1887
+ }
1888
+
1889
+ pub struct UdtCellsCache {
1890
+ pub items : Vec < Item > ,
1891
+ pub asset_info : AssetInfo ,
1892
+ pub item_category_array : Vec < ( usize , PoolUdtCategory ) > ,
1893
+ pub array_index : usize ,
1894
+ pub cell_deque : VecDeque < ( DetailedCell , AssetScriptType ) > ,
1895
+ }
1896
+
1897
+ impl UdtCellsCache {
1898
+ pub fn new ( items : Vec < Item > , asset_info : AssetInfo , source : Source ) -> Self {
1899
+ let mut item_category_array = vec ! [ ] ;
1900
+ match source {
1901
+ Source :: Claimable => {
1902
+ for ( item_index, _) in items. iter ( ) . enumerate ( ) {
1903
+ for category_index in & [ PoolUdtCategory :: ChequeInTime ] {
1904
+ item_category_array. push ( ( item_index, category_index. to_owned ( ) ) )
1905
+ }
1906
+ }
1907
+ }
1908
+ Source :: Free => {
1909
+ for ( item_index, _) in items. iter ( ) . enumerate ( ) {
1910
+ for category_index in & [
1911
+ PoolUdtCategory :: ChequeOutTime ,
1912
+ PoolUdtCategory :: SecpUdt ,
1913
+ PoolUdtCategory :: Acp ,
1914
+ ] {
1915
+ item_category_array. push ( ( item_index, category_index. to_owned ( ) ) )
1916
+ }
1917
+ }
1918
+ }
1919
+ }
1920
+
1921
+ UdtCellsCache {
1922
+ items,
1923
+ asset_info,
1924
+ item_category_array,
1925
+ array_index : 0 ,
1926
+ cell_deque : VecDeque :: new ( ) ,
1927
+ }
1928
+ }
1929
+ }
1930
+
1931
+ pub struct AcpCellsCache {
1932
+ pub items : Vec < Item > ,
1933
+ pub asset_info : Option < AssetInfo > ,
1934
+ pub current_index : usize ,
1935
+ pub cell_deque : VecDeque < DetailedCell > ,
1936
+ }
1937
+
1938
+ impl AcpCellsCache {
1939
+ pub fn new ( items : Vec < Item > , asset_info : Option < AssetInfo > ) -> Self {
1940
+ AcpCellsCache {
1941
+ items,
1942
+ asset_info,
1943
+ current_index : 0 ,
1944
+ cell_deque : VecDeque :: new ( ) ,
1945
+ }
1946
+ }
1947
+ }
0 commit comments