11use crate :: codec;
2+ use crate :: trigger:: TransactionWithBlockPtr ;
23use graph:: runtime:: gas:: GasCounter ;
34use graph:: runtime:: { asc_new, AscHeap , AscPtr , DeterministicHostError , ToAscObj } ;
4- use graph_runtime_wasm:: asc_abi:: class:: Array ;
5+ use graph_runtime_wasm:: asc_abi:: class:: { Array , Uint8Array } ;
56
67pub ( crate ) use super :: generated:: * ;
78
@@ -18,16 +19,16 @@ impl ToAscObj<AscTag> for codec::Tag {
1819 }
1920}
2021
21- impl ToAscObj < AscTransactionArray > for Vec < codec :: Transaction > {
22+ impl ToAscObj < AscTransactionArray > for Vec < Vec < u8 > > {
2223 fn to_asc_obj < H : AscHeap + ?Sized > (
2324 & self ,
2425 heap : & mut H ,
2526 gas : & GasCounter ,
2627 ) -> Result < AscTransactionArray , DeterministicHostError > {
2728 let content = self
28- . iter ( )
29- . map ( |x| asc_new ( heap, x, gas) )
30- . collect :: < Result < Vec < _ > , _ > > ( ) ?;
29+ . into_iter ( )
30+ . map ( |x| asc_new ( heap, x. as_slice ( ) , gas) )
31+ . collect :: < Result < Vec < AscPtr < Uint8Array > > , _ > > ( ) ?;
3132 Ok ( AscTransactionArray ( Array :: new ( & * content, heap, gas) ?) )
3233 }
3334}
@@ -109,7 +110,6 @@ impl ToAscObj<AscBlock> for codec::Block {
109110 gas : & GasCounter ,
110111 ) -> Result < AscBlock , DeterministicHostError > {
111112 Ok ( AscBlock {
112- // ver: self.ver,
113113 indep_hash : asc_new ( heap, self . indep_hash . as_slice ( ) , gas) ?,
114114 nonce : asc_new ( heap, self . nonce . as_slice ( ) , gas) ?,
115115 previous_block : asc_new ( heap, self . previous_block . as_slice ( ) , gas) ?,
@@ -123,7 +123,15 @@ impl ToAscObj<AscBlock> for codec::Block {
123123 height : self . height ,
124124 hash : asc_new ( heap, self . hash . as_slice ( ) , gas) ?,
125125 tx_root : asc_new ( heap, self . tx_root . as_slice ( ) , gas) ?,
126- txs : asc_new ( heap, & self . txs , gas) ?,
126+ txs : asc_new (
127+ heap,
128+ & self
129+ . txs
130+ . iter ( )
131+ . map ( |tx| tx. id . clone ( ) . into ( ) )
132+ . collect :: < Vec < Vec < u8 > > > ( ) ,
133+ gas,
134+ ) ?,
127135 wallet_list : asc_new ( heap, self . wallet_list . as_slice ( ) , gas) ?,
128136 reward_addr : asc_new ( heap, self . reward_addr . as_slice ( ) , gas) ?,
129137 tags : asc_new ( heap, & self . tags , gas) ?,
@@ -168,3 +176,16 @@ impl ToAscObj<AscBlock> for codec::Block {
168176 } )
169177 }
170178}
179+
180+ impl ToAscObj < AscTransactionWithBlockPtr > for TransactionWithBlockPtr {
181+ fn to_asc_obj < H : AscHeap + ?Sized > (
182+ & self ,
183+ heap : & mut H ,
184+ gas : & GasCounter ,
185+ ) -> Result < AscTransactionWithBlockPtr , DeterministicHostError > {
186+ Ok ( AscTransactionWithBlockPtr {
187+ tx : asc_new ( heap, & self . tx . as_ref ( ) , gas) ?,
188+ block : asc_new ( heap, self . block . as_ref ( ) , gas) ?,
189+ } )
190+ }
191+ }
0 commit comments