@ -88,6 +88,42 @@ class ActivitiesViewController: UIViewController {
}
return container
}
private func createPseudoActivity ( fromTransaction transaction : Transaction ) -> Activity {
let activityName : String
// T O D O p a s s i n i n s t e a d
if EtherKeystore . current ! . address . sameContract ( as : transaction . from ) {
activityName = " sent "
} else {
activityName = " received "
}
var cardAttributes = [ AttributeId : AssetInternalValue ] ( )
cardAttributes [ " symbol " ] = . string ( transaction . server . symbol )
if let value = BigUInt ( transaction . value ) {
cardAttributes [ " amount " ] = . uint ( value )
}
if let value = AlphaWallet . Address ( string : transaction . to ) {
cardAttributes [ " to " ] = . address ( value )
}
if let value = AlphaWallet . Address ( string : transaction . from ) {
cardAttributes [ " from " ] = . address ( value )
}
return . init (
// W e o n l y u s e t h i s I D f o r r e f r e s h i n g t h e d i s p l a y o f s p e c i f i c a c t i v i t y , s i n c e t h e d i s p l a y f o r E T H s e n d / r e c e i v e s d o n ' t e v e r n e e d t o b e r e f r e s h e d , j u s t n e e d a n u m b e r t h a t d o n ' t c l a s h w i t h o t h e r a c t i v i t i e s
id : transaction . blockNumber + 10000000 ,
tokenObject : TokensDataStore . etherToken ( forServer : transaction . server ) ,
server : transaction . server ,
name : activityName ,
eventName : activityName ,
blockNumber : transaction . blockNumber ,
transactionId : transaction . id ,
date : transaction . date ,
values : ( token : . init ( ) , card : cardAttributes ) ,
view : ( html : " " , style : " " ) ,
itemView : ( html : " " , style : " " ) ,
isBaseCard : true
)
}
}
extension ActivitiesViewController : StatefulViewController {
@ -104,7 +140,13 @@ extension ActivitiesViewController: UITableViewDelegate {
case . activity ( let activity ) :
delegate ? . didPressActivity ( activity : activity , in : self )
case . transaction ( let transaction ) :
delegate ? . didPressTransaction ( transaction : transaction , in : self )
// E T H
if transaction . operation = = nil {
let activity = createPseudoActivity ( fromTransaction : transaction )
delegate ? . didPressActivity ( activity : activity , in : self )
} else {
delegate ? . didPressTransaction ( transaction : transaction , in : self )
}
}
}
}
@ -131,42 +173,8 @@ extension ActivitiesViewController: UITableViewDataSource {
case . transaction ( let transaction ) :
// E T H
if transaction . operation = = nil {
let activityName : String
// T O D O p a s s i n i n s t e a d
if EtherKeystore . current ! . address . sameContract ( as : transaction . from ) {
activityName = " sent "
} else {
activityName = " received "
}
var cardAttributes = [ AttributeId : AssetInternalValue ] ( )
cardAttributes [ " symbol " ] = . string ( transaction . server . symbol )
if let value = BigUInt ( transaction . value ) {
cardAttributes [ " amount " ] = . uint ( value )
}
if let value = AlphaWallet . Address ( string : transaction . to ) {
cardAttributes [ " to " ] = . address ( value )
}
if let value = AlphaWallet . Address ( string : transaction . from ) {
cardAttributes [ " from " ] = . address ( value )
}
let activity = createPseudoActivity ( fromTransaction : transaction )
let cell : DefaultActivityItemViewCell = tableView . dequeueReusableCell ( for : indexPath )
let activity = Activity (
// W e o n l y u s e t h i s I D f o r r e f r e s h i n g t h e d i s p l a y o f s p e c i f i c a c t i v i t y , s i n c e t h e d i s p l a y f o r E T H s e n d / r e c e i v e s d o n ' t e v e r n e e d t o b e r e f r e s h e d , j u s t n e e d a n u m b e r t h a t d o n ' t c l a s h w i t h o t h e r a c t i v i t i e s
id : transaction . blockNumber + 10000000 ,
tokenObject : TokensDataStore . etherToken ( forServer : transaction . server ) ,
server : transaction . server ,
name : activityName ,
eventName : activityName ,
blockNumber : transaction . blockNumber ,
transactionId : " " ,
date : transaction . date ,
values : ( token : . init ( ) , card : cardAttributes ) ,
view : ( html : " " , style : " " ) ,
itemView : ( html : " " , style : " " ) ,
isBaseCard : true
)
cell . configure ( viewModel : . init ( activity : activity ) )
return cell
} else {