Skip to content
This repository was archived by the owner on Jun 16, 2025. It is now read-only.

Commit 73202fb

Browse files
committed
rename existing tx prep functions to not overlap with protocol definition
1 parent a544b5f commit 73202fb

File tree

6 files changed

+65
-23
lines changed

6 files changed

+65
-23
lines changed

evm/ts/src/TokenRouter/evm.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export class EvmTokenRouter implements TokenRouter<ethers.ContractTransaction> {
3535
return this.contract.address;
3636
}
3737

38-
placeMarketOrder(
38+
placeMarketOrderTx(
3939
amountIn: bigint,
4040
targetChain: number,
4141
redeemer: Buffer | Uint8Array,
@@ -62,7 +62,7 @@ export class EvmTokenRouter implements TokenRouter<ethers.ContractTransaction> {
6262
}
6363
}
6464

65-
placeFastMarketOrder(
65+
placeFastMarketOrderTx(
6666
amountIn: bigint,
6767
targetChain: number,
6868
redeemer: Buffer | Uint8Array,
@@ -97,19 +97,19 @@ export class EvmTokenRouter implements TokenRouter<ethers.ContractTransaction> {
9797
}
9898
}
9999

100-
redeemFill(response: OrderResponse) {
100+
redeemFillTx(response: OrderResponse) {
101101
return this.contract.redeemFill(response);
102102
}
103103

104-
addRouterEndpoint(chain: number, endpoint: Endpoint, domain: number) {
104+
addRouterEndpointTx(chain: number, endpoint: Endpoint, domain: number) {
105105
return this.contract.addRouterEndpoint(chain, endpoint, domain);
106106
}
107107

108-
updateFastTransferParameters(newParams: FastTransferParameters) {
108+
updateFastTransferParametersTx(newParams: FastTransferParameters) {
109109
return this.contract.updateFastTransferParameters(newParams);
110110
}
111111

112-
enableFastTransfer(enable: boolean) {
112+
enableFastTransferTx(enable: boolean) {
113113
return this.contract.enableFastTransfers(enable);
114114
}
115115

evm/ts/src/TokenRouter/index.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export type Endpoint = {
2323
export abstract class TokenRouter<PreparedTransactionType extends PreparedInstruction> {
2424
abstract get address(): string;
2525

26-
abstract placeMarketOrder(
26+
abstract placeMarketOrderTx(
2727
amountIn: bigint,
2828
targetChain: number,
2929
redeemer: Buffer | Uint8Array,
@@ -32,7 +32,7 @@ export abstract class TokenRouter<PreparedTransactionType extends PreparedInstru
3232
refundAddress?: string,
3333
): Promise<PreparedTransactionType>;
3434

35-
abstract placeFastMarketOrder(
35+
abstract placeFastMarketOrderTx(
3636
amountIn: bigint,
3737
targetChain: number,
3838
redeemer: Buffer | Uint8Array,
@@ -43,21 +43,20 @@ export abstract class TokenRouter<PreparedTransactionType extends PreparedInstru
4343
refundAddress?: string,
4444
): Promise<PreparedTransactionType>;
4545

46-
abstract redeemFill(response: OrderResponse): Promise<PreparedTransactionType>;
46+
abstract redeemFillTx(response: OrderResponse): Promise<PreparedTransactionType>;
4747

48-
abstract addRouterEndpoint(
48+
abstract addRouterEndpointTx(
4949
chain: number,
5050
endpoint: Endpoint,
5151
domain: number,
5252
): Promise<PreparedTransactionType>;
5353

54-
abstract updateFastTransferParameters(
54+
abstract updateFastTransferParametersTx(
5555
newParams: FastTransferParameters,
5656
): Promise<PreparedTransactionType>;
5757

58-
abstract enableFastTransfer(enable: boolean): Promise<PreparedTransactionType>;
58+
abstract enableFastTransferTx(enable: boolean): Promise<PreparedTransactionType>;
5959

6060
abstract getInitialAuctionFee(): Promise<ethers.BigNumber>;
61-
6261
abstract getTransactionResults(txHash: string): Promise<LiquidityLayerTransactionResult>;
6362
}

evm/ts/src/protocol/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./tokenRouter";

evm/ts/src/protocol/tokenRouter.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { TokenRouter } from "@wormhole-foundation/example-liquidity-layer-definitions";
2+
import { Chain, Network } from "@wormhole-foundation/sdk-base";
3+
import {
4+
AccountAddress,
5+
UnsignedTransaction,
6+
VAA,
7+
CircleBridge,
8+
Contracts,
9+
} from "@wormhole-foundation/sdk-definitions";
10+
import { EvmTokenRouter as _EvmTokenRouter } from "../TokenRouter";
11+
import { ethers } from "ethers";
12+
13+
export class EvmTokenRouter<N extends Network, C extends Chain>
14+
extends _EvmTokenRouter
15+
implements TokenRouter<N, C>
16+
{
17+
constructor(
18+
readonly network: N,
19+
readonly chain: C,
20+
readonly provider: ethers.providers.Provider,
21+
readonly contracts: Contracts & TokenRouter.Addresses,
22+
) {
23+
super(provider, contracts.tokenRouter, contracts.cctp.tokenMessenger);
24+
}
25+
26+
async *placeMarketOrder(
27+
sender: AccountAddress<C>,
28+
order: TokenRouter.OrderRequest | TokenRouter.PreparedOrder<C>,
29+
): AsyncGenerator<UnsignedTransaction<N, C>, any, unknown> {
30+
throw new Error("Method not implemented.");
31+
}
32+
async *redeemFill(
33+
sender: AccountAddress<C>,
34+
vaa:
35+
| VAA<"FastTransfer:CctpDeposit">
36+
| VAA<"FastTransfer:FastMarketOrder">
37+
| VAA<"FastTransfer:FastFill">,
38+
cctp: CircleBridge.Attestation,
39+
): AsyncGenerator<UnsignedTransaction<N, C>, any, unknown> {
40+
throw new Error("Method not implemented.");
41+
}
42+
}

evm/ts/tests/03__marketOrder.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ describe("Market Order Business Logic -- CCTP to CCTP", () => {
110110
const targetChain = toChainId(toChainName);
111111
const minAmountOut = BigInt(0);
112112
const receipt = await fromTokenRouter
113-
.placeMarketOrder(
113+
.placeMarketOrderTx(
114114
amountIn,
115115
targetChain,
116116
Buffer.from(tryNativeToUint8Array(toWallet.address, toChainName)),
@@ -159,7 +159,7 @@ describe("Market Order Business Logic -- CCTP to CCTP", () => {
159159
const balanceBefore = await usdc.balanceOf(toWallet.address);
160160

161161
const receipt = await toTokenRouter
162-
.redeemFill(orderResponse)
162+
.redeemFillTx(orderResponse)
163163
.then((tx) => mineWait(toProvider, tx))
164164
.catch((err) => {
165165
console.log(err);

evm/ts/tests/04__fastMarketOrder.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
159159
const minAmountOut = BigInt(0);
160160
const deadline = 0;
161161
const receipt = await fromTokenRouter
162-
.placeFastMarketOrder(
162+
.placeFastMarketOrderTx(
163163
amountIn,
164164
targetChain,
165165
Buffer.from(tryNativeToUint8Array(toWallet.address, toChainName)),
@@ -443,7 +443,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
443443
const balanceBefore = await usdc.balanceOf(toWallet.address);
444444

445445
const receipt = await toTokenRouter
446-
.redeemFill(orderResponse)
446+
.redeemFillTx(orderResponse)
447447
.then((tx) => mineWait(toProvider, tx))
448448
.catch((err) => {
449449
console.log(err);
@@ -540,7 +540,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
540540
const minAmountOut = BigInt(0);
541541
const deadline = 0;
542542
const receipt = await fromTokenRouter
543-
.placeFastMarketOrder(
543+
.placeFastMarketOrderTx(
544544
amountIn,
545545
targetChain,
546546
Buffer.from(tryNativeToUint8Array(toWallet.address, toChainName)),
@@ -840,7 +840,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
840840
const balanceBefore = await usdc.balanceOf(toWallet.address);
841841

842842
const receipt = await toTokenRouter
843-
.redeemFill(orderResponse)
843+
.redeemFillTx(orderResponse)
844844
.then((tx) => mineWait(toProvider, tx))
845845
.catch((err) => {
846846
console.log(err);
@@ -939,7 +939,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
939939
const minAmountOut = BigInt(0);
940940
const deadline = 0;
941941
const receipt = await fromTokenRouter
942-
.placeFastMarketOrder(
942+
.placeFastMarketOrderTx(
943943
amountIn,
944944
targetChain,
945945
Buffer.from(tryNativeToUint8Array(toWallet.address, toChainName)),
@@ -1089,7 +1089,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
10891089
const balanceBefore = await usdc.balanceOf(toWallet.address);
10901090

10911091
const receipt = await toTokenRouter
1092-
.redeemFill(orderResponse)
1092+
.redeemFillTx(orderResponse)
10931093
.then((tx) => mineWait(toProvider, tx))
10941094
.catch((err) => {
10951095
console.log(err);
@@ -1153,7 +1153,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
11531153
const deadline = (await engineProvider.getBlock(currentBlock)).timestamp;
11541154

11551155
const receipt = await fromTokenRouter
1156-
.placeFastMarketOrder(
1156+
.placeFastMarketOrderTx(
11571157
amountIn,
11581158
targetChain,
11591159
Buffer.from(tryNativeToUint8Array(toWallet.address, toChainName)),
@@ -1339,7 +1339,7 @@ describe("Fast Market Order Business Logic -- CCTP to CCTP", function (this: Moc
13391339
const balanceBefore = await usdc.balanceOf(toWallet.address);
13401340

13411341
const receipt = await toTokenRouter
1342-
.redeemFill(orderResponse)
1342+
.redeemFillTx(orderResponse)
13431343
.then((tx) => mineWait(toProvider, tx))
13441344
.catch((err) => {
13451345
console.log(err);

0 commit comments

Comments
 (0)