-
Notifications
You must be signed in to change notification settings - Fork 50
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
57 changed files
with
913 additions
and
859 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 was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { | ||
ChainContext, | ||
Signer, | ||
TransactionId, | ||
TxHash, | ||
UnsignedTransaction, | ||
} from "@wormhole-foundation/sdk-definitions"; | ||
import { PlatformName } from "@wormhole-foundation/sdk-base"; | ||
|
||
export async function signSendWait( | ||
chain: ChainContext<PlatformName>, | ||
xfer: AsyncGenerator<UnsignedTransaction>, | ||
signer: Signer, | ||
): Promise<TransactionId[]> { | ||
// buffer unsigned transactions as long as they are | ||
// marked as parallelizable | ||
let txbuff: UnsignedTransaction[] = []; | ||
|
||
const txHashes: TxHash[] = []; | ||
for await (const tx of xfer) { | ||
txbuff.push(tx); | ||
|
||
if (!tx.parallelizable) { | ||
// sign/send | ||
const signed = await signer.sign(txbuff); | ||
const txids = await chain.sendWait(signed); | ||
txHashes.push(...txids); | ||
// reset buffer | ||
txbuff = []; | ||
} | ||
} | ||
|
||
if (txbuff.length > 0) { | ||
const signed = await signer.sign(txbuff); | ||
const txids = await chain.sendWait(signed); | ||
txHashes.push(...txids); | ||
} | ||
|
||
return txHashes.map((txid) => ({ chain: chain.chain, txid })); | ||
} |
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.