Skip to content

Commit 56af932

Browse files
Update intrpretion for AA txs (#244)
1 parent e4c4943 commit 56af932

File tree

2 files changed

+12
-22
lines changed

2 files changed

+12
-22
lines changed

.changeset/thick-fans-travel.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@3loop/transaction-interpreter': patch
3+
---
4+
5+
Add generic interpreations to AA transactions with single OP events

packages/transaction-interpreter/interpreters/aa.ts

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { assetsReceived, assetsSent, genericInterpreter, displayAddress, displayAsset, toAssetTransfer } from './std.js'
1+
import { genericInterpreter } from './std.js'
22
import type { InterpretedTransaction } from '@/types.js'
33
import type { DecodedTransaction } from '@3loop/transaction-decoder'
44

@@ -17,27 +17,12 @@ export function transformEvent(event: DecodedTransaction): InterpretedTransactio
1717
sender: string
1818
}
1919

20-
//detect single transfer
21-
const transfers = event.transfers
22-
.filter((t) => (t.from === sender || t.to === sender) && t.type !== 'native')
23-
.map(toAssetTransfer)
24-
if (transfers.length === 1) {
25-
return {
26-
...newEvent,
27-
type: 'transfer-token',
28-
action: `Sent ${displayAsset(transfers[0])}`,
29-
assetsSent: assetsSent(event.transfers, sender),
30-
assetsReceived: assetsReceived(event.transfers, sender),
31-
}
32-
}
33-
34-
return {
35-
...newEvent,
36-
type: 'account-abstraction',
37-
action: `Account Abstraction transaction by ${displayAddress(sender)}`,
38-
assetsSent: assetsSent(event.transfers, sender),
39-
assetsReceived: assetsReceived(event.transfers, sender),
40-
}
20+
// if there is only one userOpEvent, we can use the sender as the fromAddress
21+
// to try to use the generic interpreter to interpret the transaction
22+
return genericInterpreter({
23+
...event,
24+
fromAddress: sender,
25+
})
4126
}
4227

4328
if (userOpEvents.length > 1) {

0 commit comments

Comments
 (0)