Skip to content

Commit 9a2ef36

Browse files
authored
fix router example, remove console errors (#554)
1 parent 09d8b8e commit 9a2ef36

File tree

2 files changed

+4
-36
lines changed

2 files changed

+4
-36
lines changed

connect/src/routes/resolver.ts

-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class RouteResolver<N extends Network> {
4949
try {
5050
return await rc.supportedDestinationTokens(inputTokenId, fromChain, toChain);
5151
} catch (e) {
52-
console.error(`Failed to get supported destination tokens for ${rc.meta.name}: `, e);
5352
return [];
5453
}
5554
}),
@@ -96,7 +95,6 @@ export class RouteResolver<N extends Network> {
9695

9796
return protocolSupported && sourceTokenSupported && destinationTokenSupported;
9897
} catch (e) {
99-
console.error(`failed to find routes for ${rc.meta.name}: `, e);
10098
return false;
10199
}
102100
}),

examples/src/router.ts

+4-34
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,4 @@
1-
import {
2-
Chain,
3-
Network,
4-
Signer,
5-
TransactionId,
6-
TransferState,
7-
Wormhole,
8-
canonicalAddress,
9-
routes,
10-
wormhole,
11-
} from "@wormhole-foundation/sdk";
1+
import { Wormhole, canonicalAddress, routes, wormhole } from "@wormhole-foundation/sdk";
122

133
import evm from "@wormhole-foundation/sdk/evm";
144
import solana from "@wormhole-foundation/sdk/solana";
@@ -63,8 +53,6 @@ import { getSigner } from "./helpers/index.js";
6353
// creating a transfer request fetches token details
6454
// since all routes will need to know about the tokens
6555
const tr = await routes.RouteTransferRequest.create(wh, {
66-
from: sender.address,
67-
to: receiver.address,
6856
source: sendToken,
6957
destination: destinationToken,
7058
});
@@ -106,32 +94,14 @@ import { getSigner } from "./helpers/index.js";
10694
// EXAMPLE_REQUEST_INITIATE
10795
// Now the transfer may be initiated
10896
// A receipt will be returned, guess what you gotta do with that?
109-
const receipt = await bestRoute.initiate(sender.signer, quote);
97+
const receipt = await bestRoute.initiate(sender.signer, quote, receiver.address);
11098
console.log("Initiated transfer with receipt: ", receipt);
11199
// EXAMPLE_REQUEST_INITIATE
112100

113101
// Kick off a wait log, if there is an opportunity to complete, this function will do it
114102
// see the implementation for how this works
115103
await routes.checkAndCompleteTransfer(bestRoute, receipt, receiver.signer);
104+
} else {
105+
console.log("Not initiating transfer (set `imSure` to true to do so)");
116106
}
117107
})();
118-
119-
// An incomplete transfer can be completed by calling this function
120-
async function completeTransfer<N extends Network>(
121-
route: routes.Route<N>,
122-
fromChain: Chain,
123-
toChain: Chain,
124-
tx: TransactionId,
125-
signer: Signer,
126-
) {
127-
const receipt: routes.Receipt = {
128-
from: fromChain,
129-
to: toChain,
130-
state: TransferState.SourceInitiated,
131-
originTxs: [tx],
132-
};
133-
134-
// Kick off a wait log, if there is an opportunity to complete, this function will do it
135-
// see the implementation for how this works
136-
await routes.checkAndCompleteTransfer(route, receipt, signer);
137-
}

0 commit comments

Comments
 (0)