@@ -58,6 +58,9 @@ pub(crate) struct Scope {
5858 /// This enables any Object GraphQL type to access fresh data without database queries.
5959 execution_objects : ExecutionObjectMap ,
6060
61+ /// Balance changes from the executed transaction, only available in execution context.
62+ balance_changes : Option < Vec < grpc:: BalanceChange > > ,
63+
6164 /// Access to packages for type resolution.
6265 package_store : Arc < dyn PackageStore > ,
6366
@@ -77,6 +80,7 @@ impl Scope {
7780 checkpoint_viewed_at : Some ( watermark. high_watermark ( ) . checkpoint ( ) ) ,
7881 root_version : None ,
7982 execution_objects : Arc :: new ( BTreeMap :: new ( ) ) ,
83+ balance_changes : None ,
8084 package_store : package_store. clone ( ) ,
8185 resolver_limits : limits. package_resolver ( ) ,
8286 } )
@@ -90,6 +94,7 @@ impl Scope {
9094 checkpoint_viewed_at : Some ( checkpoint_viewed_at) ,
9195 root_version : self . root_version ,
9296 execution_objects : Arc :: clone ( & self . execution_objects ) ,
97+ balance_changes : self . balance_changes . clone ( ) ,
9398 package_store : self . package_store . clone ( ) ,
9499 resolver_limits : self . resolver_limits . clone ( ) ,
95100 } )
@@ -101,6 +106,7 @@ impl Scope {
101106 checkpoint_viewed_at : self . checkpoint_viewed_at ,
102107 root_version : Some ( root_version) ,
103108 execution_objects : Arc :: clone ( & self . execution_objects ) ,
109+ balance_changes : self . balance_changes . clone ( ) ,
104110 package_store : self . package_store . clone ( ) ,
105111 resolver_limits : self . resolver_limits . clone ( ) ,
106112 }
@@ -112,6 +118,7 @@ impl Scope {
112118 checkpoint_viewed_at : self . checkpoint_viewed_at ,
113119 root_version : None ,
114120 execution_objects : Arc :: clone ( & self . execution_objects ) ,
121+ balance_changes : self . balance_changes . clone ( ) ,
115122 package_store : self . package_store . clone ( ) ,
116123 resolver_limits : self . resolver_limits . clone ( ) ,
117124 }
@@ -163,7 +170,12 @@ impl Scope {
163170 . and_then ( |( _, opt) | opt. as_ref ( ) )
164171 }
165172
166- /// Create a nested scope with execution objects extracted from an ExecutedTransaction.
173+ /// Get balance changes from execution context, if available.
174+ pub ( crate ) fn balance_changes ( & self ) -> Option < & [ grpc:: BalanceChange ] > {
175+ self . balance_changes . as_deref ( )
176+ }
177+
178+ /// Create a nested scope with execution objects and balance changes extracted from an ExecutedTransaction.
167179 pub ( crate ) fn with_executed_transaction (
168180 & self ,
169181 executed_transaction : & grpc:: ExecutedTransaction ,
@@ -174,6 +186,7 @@ impl Scope {
174186 checkpoint_viewed_at : None ,
175187 root_version : self . root_version ,
176188 execution_objects,
189+ balance_changes : Some ( executed_transaction. balance_changes . clone ( ) ) ,
177190 package_store : self . package_store . clone ( ) ,
178191 resolver_limits : self . resolver_limits . clone ( ) ,
179192 } )
0 commit comments