|
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"; |
12 | 2 |
|
13 | 3 | import evm from "@wormhole-foundation/sdk/evm";
|
14 | 4 | import solana from "@wormhole-foundation/sdk/solana";
|
@@ -63,8 +53,6 @@ import { getSigner } from "./helpers/index.js";
|
63 | 53 | // creating a transfer request fetches token details
|
64 | 54 | // since all routes will need to know about the tokens
|
65 | 55 | const tr = await routes.RouteTransferRequest.create(wh, {
|
66 |
| - from: sender.address, |
67 |
| - to: receiver.address, |
68 | 56 | source: sendToken,
|
69 | 57 | destination: destinationToken,
|
70 | 58 | });
|
@@ -106,32 +94,14 @@ import { getSigner } from "./helpers/index.js";
|
106 | 94 | // EXAMPLE_REQUEST_INITIATE
|
107 | 95 | // Now the transfer may be initiated
|
108 | 96 | // 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); |
110 | 98 | console.log("Initiated transfer with receipt: ", receipt);
|
111 | 99 | // EXAMPLE_REQUEST_INITIATE
|
112 | 100 |
|
113 | 101 | // Kick off a wait log, if there is an opportunity to complete, this function will do it
|
114 | 102 | // see the implementation for how this works
|
115 | 103 | await routes.checkAndCompleteTransfer(bestRoute, receipt, receiver.signer);
|
| 104 | + } else { |
| 105 | + console.log("Not initiating transfer (set `imSure` to true to do so)"); |
116 | 106 | }
|
117 | 107 | })();
|
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