-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🗞️ Sign transactions on different chains in parallel (#461)
- Loading branch information
1 parent
54cf16e
commit 2b9ae6a
Showing
8 changed files
with
224 additions
and
54 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@layerzerolabs/ua-devtools-evm-hardhat-test": patch | ||
"@layerzerolabs/devtools": patch | ||
--- | ||
|
||
Sign transactions for different chains in parallel |
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,5 @@ | ||
--- | ||
"@layerzerolabs/devtools": patch | ||
--- | ||
|
||
Add groupTransactionsByEid utility |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,24 @@ | ||
import { OmniTransaction } from './types' | ||
import type { EndpointId } from '@layerzerolabs/lz-definitions' | ||
import type { OmniTransaction } from './types' | ||
|
||
const isNonNullable = <T>(value: T | null | undefined): value is T => value != null | ||
|
||
export const flattenTransactions = ( | ||
transations: (OmniTransaction | OmniTransaction[] | null | undefined)[] | ||
): OmniTransaction[] => transations.filter(isNonNullable).flat() | ||
|
||
/** | ||
* Groups transactions by their `eid`, preserving the order per group | ||
* | ||
* @param {OmniTransaction[]} transactions | ||
* @returns {Map<EndpointId, OmniTransaction[]>} | ||
*/ | ||
export const groupTransactionsByEid = (transactions: OmniTransaction[]): Map<EndpointId, OmniTransaction[]> => | ||
transactions.reduce( | ||
(transactionsByEid, transaction) => | ||
transactionsByEid.set(transaction.point.eid, [ | ||
...(transactionsByEid.get(transaction.point.eid) ?? []), | ||
transaction, | ||
]), | ||
new Map<EndpointId, OmniTransaction[]>() | ||
) |
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.