1- import { AccountStatus , Address , Cell , Transaction } from "@ton/core" ;
1+ import { AccountStatus , Address , Cell , CurrencyCollection , Transaction } from "@ton/core" ;
22import { inspect } from "node-inspect-extracted" ;
33import { CompareResult } from "./interface" ;
44
@@ -7,6 +7,7 @@ export type FlatTransaction = {
77 to ?: Address
88 on ?: Address
99 value ?: bigint
10+ ec ?: [ number , bigint ] [ ]
1011 body ?: Cell
1112 inMessageBounced ?: boolean
1213 inMessageBounceable ?: boolean
@@ -42,6 +43,15 @@ function extractOp(body: Cell): number | undefined {
4243 }
4344}
4445
46+ function extractEc ( cc : CurrencyCollection ) : [ number , bigint ] [ ] {
47+ const r : [ number , bigint ] [ ] = [ ] ;
48+ for ( const [ k , v ] of cc . other ?? [ ] ) {
49+ r . push ( [ k , v ] ) ;
50+ }
51+ r . sort ( ( a , b ) => a [ 0 ] - b [ 0 ] ) ;
52+ return r ;
53+ }
54+
4555export function flattenTransaction ( tx : Transaction ) : FlatTransaction {
4656 return {
4757 lt : tx . lt ,
@@ -55,6 +65,7 @@ export function flattenTransaction(tx: Transaction): FlatTransaction {
5565 to : tx . inMessage . info . dest as Address ,
5666 on : tx . inMessage . info . dest as Address ,
5767 value : tx . inMessage . info . type === 'internal' ? tx . inMessage . info . value . coins : undefined ,
68+ ec : tx . inMessage . info . type === 'internal' ? extractEc ( tx . inMessage . info . value ) : undefined ,
5869 body : tx . inMessage . body ,
5970 inMessageBounced : tx . inMessage . info . type === 'internal' ? tx . inMessage . info . bounced : undefined ,
6071 inMessageBounceable : tx . inMessage . info . type === 'internal' ? tx . inMessage . info . bounce : undefined ,
@@ -67,6 +78,7 @@ export function flattenTransaction(tx: Transaction): FlatTransaction {
6778 to : undefined ,
6879 on : undefined ,
6980 value : undefined ,
81+ ec : undefined ,
7082 body : undefined ,
7183 inMessageBounced : undefined ,
7284 inMessageBounceable : undefined ,
@@ -108,6 +120,15 @@ function compareValue(a: any, b: any) {
108120 return a . equals ( b )
109121 }
110122
123+ if ( a instanceof Array ) {
124+ if ( ! ( b instanceof Array ) ) return false
125+ if ( a . length !== b . length ) return false
126+ for ( let i = 0 ; i < a . length ; i ++ ) {
127+ if ( ! compareValue ( a [ i ] , b [ i ] ) ) return false
128+ }
129+ return true
130+ }
131+
111132 return a === b
112133}
113134
0 commit comments