@@ -64,58 +64,86 @@ func TestFetchReceiptTokenTransfers(t *testing.T) {
6464
6565 // Case 3: a trails intent call, with bunch of other actions inside of the txn, including erc20 transfers
6666 // https://arbiscan.io/tx/0xb88cc2fea7cd26c88e169f6244fea76f590fc0797ba4c424669d1b74643f1dc9
67- // .. lets get another one using zerox + cctp for example
6867 t .Run ("Case 3: .." , func (t * testing.T ) {
68+ provider , err := ethrpc .NewProvider ("https://nodes.sequence.app/arbitrum" )
69+ require .NoError (t , err )
70+
71+ txnHash := common .HexToHash ("0xb88cc2fea7cd26c88e169f6244fea76f590fc0797ba4c424669d1b74643f1dc9" )
72+ receipt , transfers , err := receipts .FetchReceiptTokenTransfers (context .Background (), provider , txnHash )
73+ require .NoError (t , err )
74+ require .NotNil (t , receipt )
75+ require .Greater (t , len (transfers ), 0 )
76+ require .Equal (t , 13 , len (receipt .Logs ))
77+
78+ // Trails intent
79+ usdc := common .HexToAddress ("0xaf88d065e77c8cC2239327C5EDb3A432268e5831" )
80+ owner := common .HexToAddress ("0x9DAB7A98C207f01A35DF00257949a27609b93ad7" )
81+ trailsRouter := common .HexToAddress ("0xF8A739B9F24E297a98b7aba7A9cdFDBD457F6fF8" )
82+ bridge := common .HexToAddress ("0xf70da97812CB96acDF810712Aa562db8dfA3dbEF" )
83+ collector := common .HexToAddress ("0x76008498f26789dd8b691Bebe24C889A3dd1A2fc" )
84+
85+ // spew.Dump(transfers)
86+ require .Equal (t , 3 , len (transfers ))
87+
88+ // Log 1, USDC owner to trailsRouter
89+ require .Equal (t , usdc , transfers [0 ].Token )
90+ require .Equal (t , owner , transfers [0 ].From )
91+ require .Equal (t , trailsRouter , transfers [0 ].To )
92+ require .Equal (t , big .NewInt (175353 ), transfers [0 ].Value )
93+
94+ // Log 2, USDC trailsRouter from bridge
95+ require .Equal (t , usdc , transfers [1 ].Token )
96+ require .Equal (t , trailsRouter , transfers [1 ].From )
97+ require .Equal (t , bridge , transfers [1 ].To )
98+ require .Equal (t , big .NewInt (175353 ), transfers [1 ].Value )
99+
100+ // Log 3, USDC owner to collector
101+ require .Equal (t , usdc , transfers [2 ].Token )
102+ require .Equal (t , owner , transfers [2 ].From )
103+ require .Equal (t , collector , transfers [2 ].To )
104+ require .Equal (t , big .NewInt (9979 ), transfers [2 ].Value )
105+
106+ // Get the delta / net effects
107+ balances := transfers .ComputeBalanceOutputs ()
108+ require .NotNil (t , balances )
109+ require .Equal (t , len (balances ), 3 )
110+ // spew.Dump(balances)
111+
112+ require .Equal (t , usdc , balances [0 ].Token )
113+ require .Equal (t , owner , balances [0 ].Account )
114+ require .Equal (t , big .NewInt (- 185332 ), balances [0 ].Balance )
115+
116+ require .Equal (t , usdc , balances [1 ].Token )
117+ require .Equal (t , collector , balances [1 ].Account )
118+ require .Equal (t , big .NewInt (9979 ), balances [1 ].Balance )
119+
120+ require .Equal (t , usdc , balances [2 ].Token )
121+ require .Equal (t , bridge , balances [2 ].Account )
122+ require .Equal (t , big .NewInt (175353 ), balances [2 ].Balance )
69123 })
70124
71- // Case 4: vault bridge USDC .. lets check the token transfer event, prob just erc20 too
72- // https://katanascan.com/tx/0x7bcd0068a5c3352cf4e1d75c7c4f78d99f02b8b2f5f96b2c407972f43e724f52
125+ // Case 4: a trails cross-chain swap where we use 0x + cctp to swap from MAGIC to USDC then bridge
126+ // over CCTP. This includes many calls with USDC and MAGIC.
127+ // https://arbiscan.io/tx/0xa5c17e51443c8a8ce60cdcbe84b89fd2570f073bbb3b9ec8cdc9361aa1ca984f
73128 t .Run ("Case 4: .." , func (t * testing.T ) {
74129 })
75130
76- // Case 5: polygon POL LogTransfer event
77- // https://polygonscan .com/tx/0x252419983224542bfb07dab75808fa57186a7a269d0d267ae655eb7ef037fdd5
131+ // Case 5: vault bridge USDC .. lets check the token transfer event, prob just erc20 too
132+ // https://katanascan .com/tx/0x7bcd0068a5c3352cf4e1d75c7c4f78d99f02b8b2f5f96b2c407972f43e724f52
78133 t .Run ("Case 5: .." , func (t * testing.T ) {
79134 })
80135
81- // Case 6: bunch of logs for the same erc20 token, and we need to sum it up, ie. a big uniswap call
82- // and we have to do a delta/diff, and return the "result" maybe "TokenTransferResult" ?
83- // https://etherscan.io/tx/0xb11ff491495e145b07a1d3cc304f7d04b235b80af51b50da9a54095a6882fca4
136+ // Case 6: polygon POL LogTransfer event
137+ // https://polygonscan.com/tx/0x252419983224542bfb07dab75808fa57186a7a269d0d267ae655eb7ef037fdd5
84138 t .Run ("Case 6: .." , func (t * testing.T ) {
85139 })
86140
87- //--
88-
89- // t.Run("Simple ERC20 Transfer", func(t *testing.T) {
90- // // https://arbiscan.io/tx/0xb88cc2fea7cd26c88e169f6244fea76f590fc0797ba4c424669d1b74643f1dc9
91- // provider, err := ethrpc.NewProvider("https://nodes.sequence.app/arbitrum")
92- // require.NoError(t, err)
93-
94- // txnHash := common.HexToHash("0xb88cc2fea7cd26c88e169f6244fea76f590fc0797ba4c424669d1b74643f1dc9")
95-
96- // receipt, transfers, err := receipts.FetchReceiptTokenTransfers(context.Background(), provider, txnHash)
97- // require.NoError(t, err)
98- // require.NotNil(t, receipt)
99- // require.Greater(t, len(transfers), 0)
100-
101- // spew.Dump(transfers)
102-
103- // })
104-
105- // t.Run("Polygon POL LogTransfer", func(t *testing.T) {
106- // t.Skip("POL")
107-
108- // // txnHash := https://polygonscan.com/tx/0x252419983224542bfb07dab75808fa57186a7a269d0d267ae655eb7ef037fdd5
109- // provider, err := ethrpc.NewProvider("https://nodes.sequence.app/polygon")
110- // require.NoError(t, err)
111-
112- // txnHash := common.HexToHash("0x252419983224542bfb07dab75808fa57186a7a269d0d267ae655eb7ef037fdd5")
113-
114- // receipt, transfers, err := receipts.FetchReceiptTokenTransfers(context.Background(), provider, txnHash)
115- // require.NoError(t, err)
116- // require.NotNil(t, receipt)
117- // require.Greater(t, len(transfers), 0)
118-
119- // spew.Dump(transfers)
120- // })
141+ // Case 7: bunch of logs for the same erc20 token, and we need to sum it up, ie. a big uniswap call
142+ // and we have to do a delta/diff, and return the "result" maybe "TokenTransferResult" ?
143+ // https://etherscan.io/tx/0xb11ff491495e145b07a1d3cc304f7d04b235b80af51b50da9a54095a6882fca4
144+ t .Run ("Case 7: .." , func (t * testing.T ) {
145+ })
121146}
147+
148+ // TODO: lets test the TokenTransfers directly with mock
149+ // data we write by hand to ensure aggregation works properly, etc.
0 commit comments