Skip to content

Commit c10f5fa

Browse files
committed
refactor
1 parent eb099b2 commit c10f5fa

File tree

2 files changed

+33
-4
lines changed

2 files changed

+33
-4
lines changed

evm/ts/src/multiTokenNttWithExecutor.ts

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ import {
1616
EvmPlatform,
1717
EvmPlatformType,
1818
EvmAddress,
19+
EvmUnsignedTransaction,
20+
addChainId,
1921
} from "@wormhole-foundation/sdk-evm";
2022
import {
2123
Ntt,
@@ -39,6 +41,7 @@ export class EvmMultiTokenNttWithExecutor<
3941
> implements MultiTokenNttWithExecutor<N, C>
4042
{
4143
readonly chainId: bigint;
44+
readonly managerAddress: string;
4245
readonly multiTokenNttWithExecutorAddress: string;
4346

4447
constructor(
@@ -52,6 +55,14 @@ export class EvmMultiTokenNttWithExecutor<
5255
chain
5356
) as bigint;
5457

58+
const managerAddress = contracts.multiTokenNtt?.manager;
59+
if (!managerAddress) {
60+
throw new Error(
61+
`MultiTokenNtt manager address not found for chain ${chain} on network ${network}`
62+
);
63+
}
64+
this.managerAddress = managerAddress;
65+
5566
const multiTokenNttWithExecutorAddress =
5667
multiTokenNttWithExecutorAddresses[this.network]?.[this.chain];
5768
if (!multiTokenNttWithExecutorAddress) {
@@ -143,7 +154,7 @@ export class EvmMultiTokenNttWithExecutor<
143154

144155
if (isNativeToken) {
145156
data = iface.encodeFunctionData("transferETH", [
146-
multiTokenNtt.managerAddress,
157+
this.managerAddress,
147158
amount,
148159
recipientChain,
149160
recipient,
@@ -172,14 +183,14 @@ export class EvmMultiTokenNttWithExecutor<
172183
amount
173184
);
174185

175-
yield multiTokenNtt.createUnsignedTx(
186+
yield this.createUnsignedTx(
176187
approveTx,
177188
"MultiTokenNttWithExecutor.Approve"
178189
);
179190
}
180191

181192
data = iface.encodeFunctionData("transfer", [
182-
multiTokenNtt.managerAddress,
193+
this.managerAddress,
183194
tokenAddress,
184195
amount,
185196
recipientChain,
@@ -199,7 +210,7 @@ export class EvmMultiTokenNttWithExecutor<
199210
from: senderAddress,
200211
};
201212

202-
yield multiTokenNtt.createUnsignedTx(
213+
yield this.createUnsignedTx(
203214
txReq,
204215
isNativeToken
205216
? "MultiTokenNttWithExecutor.transferETH"
@@ -227,4 +238,18 @@ export class EvmMultiTokenNttWithExecutor<
227238
gasLimit,
228239
};
229240
}
241+
242+
createUnsignedTx(
243+
txReq: TransactionRequest,
244+
description: string,
245+
parallelizable: boolean = false
246+
): EvmUnsignedTransaction<N, C> {
247+
return new EvmUnsignedTransaction(
248+
addChainId(txReq, this.chainId),
249+
this.network,
250+
this.chain,
251+
description,
252+
parallelizable
253+
);
254+
}
230255
}

sdk/route/src/executor/multiToken.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,8 @@ export class MultiTokenNttExecutorRoute<N extends Network>
237237
try {
238238
const executorQuote = await this.fetchExecutorQuote(request, params);
239239

240+
// TODO: fetch the delivery price, add it to the relayFee.amount (estimatedCost + deliveryPrice)
241+
240242
const { remainingAmount, estimatedCost, gasDropOff, expires } =
241243
executorQuote;
242244

@@ -335,6 +337,8 @@ export class MultiTokenNttExecutorRoute<N extends Network>
335337
return referrerFeeDbps;
336338
}
337339

340+
// TODO: we can probably make a bunch of these functions free in a utils file
341+
338342
getReferrerAddress(fromChain: ChainContext<N>): ChainAddress {
339343
let referrer = getDefaultReferrerAddress(fromChain.chain);
340344
const referrerFeeConfig = this.staticConfig.referrerFee;

0 commit comments

Comments
 (0)