forked from airswap/airswap-web
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of github.com:airswap/airswap-web into develop
- Loading branch information
Showing
11 changed files
with
142 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
src/features/transactions/helpers/getOrdersFromWrappedEventLogs.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ADDRESS_ZERO, FullSwapERC20, OrderERC20 } from "@airswap/utils"; | ||
|
||
import { Event } from "ethers"; | ||
|
||
import { FullSwapErc20Log } from "./getOrdersFromLogs"; | ||
|
||
export const getOrdersFromWrappedEventLogs = ( | ||
logs: FullSwapErc20Log[], | ||
wrappedEvents: Event[] | ||
): FullSwapErc20Log[] => { | ||
const filteredLogs = logs.map((log) => { | ||
const wrappedEvent = wrappedEvents.find( | ||
(event) => event.transactionHash === log.hash | ||
); | ||
|
||
if (!wrappedEvent) return; | ||
|
||
const args = wrappedEvent.args || []; | ||
const senderWallet = args[0] as string | undefined; | ||
|
||
if (!senderWallet) return; | ||
|
||
const order: OrderERC20 = { | ||
...log.order, | ||
senderToken: ADDRESS_ZERO, | ||
}; | ||
|
||
const swap: FullSwapERC20 = { | ||
...log.swap, | ||
senderToken: ADDRESS_ZERO, | ||
senderWallet, | ||
}; | ||
|
||
return { | ||
...log, | ||
order, | ||
swap, | ||
}; | ||
}); | ||
|
||
return filteredLogs.filter(Boolean) as FullSwapErc20Log[]; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.