@m0-foundation/ntt-sdk-route 0.0.5 → 0.0.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -13,18 +13,23 @@ type QR = routes.QuoteResult<Op, Vp>;
13
13
  type Q = routes.Quote<Op, Vp>;
14
14
  type R = NttRoute.AutomaticTransferReceipt;
15
15
  type Contracts = Ntt.Contracts & {
16
- wrappedMToken: string;
16
+ mLikeTokens: string[];
17
17
  };
18
18
  declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<N, Op, Vp, R> implements routes.StaticRouteMethods<typeof M0AutomaticRoute> {
19
19
  static NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
20
+ static EVM_WRAPPED_M_TOKEN: string;
21
+ static SOLANA_MAINNET_M_TOKEN: string;
22
+ static SOLANA_TESTNET_M_TOKEN: string;
20
23
  static EVM_CONTRACTS: Contracts;
21
24
  static meta: {
22
25
  name: string;
23
26
  provider: string;
24
27
  };
28
+ static solanaContracts(network: Network): Contracts;
25
29
  static supportedNetworks(): Network[];
30
+ static isPlatformSupported(platform: string): boolean;
26
31
  static supportedChains(network: Network): Chain[];
27
- static getContracts(chain: Chain): Contracts;
32
+ static getContracts(chainContext: ChainContext<Network>): Contracts;
28
33
  static supportedSourceTokens(fromChain: ChainContext<Network>): Promise<TokenId[]>;
29
34
  static supportedDestinationTokens<N extends Network>(token: TokenId, fromChain: ChainContext<N>, toChain: ChainContext<N>): Promise<TokenId[]>;
30
35
  static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean;
package/dist/index.d.ts CHANGED
@@ -13,18 +13,23 @@ type QR = routes.QuoteResult<Op, Vp>;
13
13
  type Q = routes.Quote<Op, Vp>;
14
14
  type R = NttRoute.AutomaticTransferReceipt;
15
15
  type Contracts = Ntt.Contracts & {
16
- wrappedMToken: string;
16
+ mLikeTokens: string[];
17
17
  };
18
18
  declare class M0AutomaticRoute<N extends Network> extends routes.AutomaticRoute<N, Op, Vp, R> implements routes.StaticRouteMethods<typeof M0AutomaticRoute> {
19
19
  static NATIVE_GAS_DROPOFF_SUPPORTED: boolean;
20
+ static EVM_WRAPPED_M_TOKEN: string;
21
+ static SOLANA_MAINNET_M_TOKEN: string;
22
+ static SOLANA_TESTNET_M_TOKEN: string;
20
23
  static EVM_CONTRACTS: Contracts;
21
24
  static meta: {
22
25
  name: string;
23
26
  provider: string;
24
27
  };
28
+ static solanaContracts(network: Network): Contracts;
25
29
  static supportedNetworks(): Network[];
30
+ static isPlatformSupported(platform: string): boolean;
26
31
  static supportedChains(network: Network): Chain[];
27
- static getContracts(chain: Chain): Contracts;
32
+ static getContracts(chainContext: ChainContext<Network>): Contracts;
28
33
  static supportedSourceTokens(fromChain: ChainContext<Network>): Promise<TokenId[]>;
29
34
  static supportedDestinationTokens<N extends Network>(token: TokenId, fromChain: ChainContext<N>, toChain: ChainContext<N>): Promise<TokenId[]>;
30
35
  static isProtocolSupported<N extends Network>(chain: ChainContext<N>): boolean;
package/dist/index.js CHANGED
@@ -2,27 +2,42 @@
2
2
 
3
3
  var sdkConnect = require('@wormhole-foundation/sdk-connect');
4
4
  var sdkDefinitionsNtt = require('@wormhole-foundation/sdk-definitions-ntt');
5
+ require('@wormhole-foundation/sdk-solana-ntt');
5
6
  var sdkEvm = require('@wormhole-foundation/sdk-evm');
7
+ require('@wormhole-foundation/sdk-solana');
6
8
  var sdkRouteNtt = require('@wormhole-foundation/sdk-route-ntt');
7
9
  var ethers = require('ethers');
8
10
 
9
11
  // src/m0AutomaticRoute.ts
10
12
  var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.AutomaticRoute {
13
+ static solanaContracts(network) {
14
+ return {
15
+ token: network == "Mainnet" ? this.SOLANA_MAINNET_M_TOKEN : this.SOLANA_TESTNET_M_TOKEN,
16
+ // Only M token can be bridged from Solana
17
+ mLikeTokens: [],
18
+ manager: "mzp1q2j5Hr1QuLC3KFBCAUz5aUckT6qyuZKZ3WJnMmY",
19
+ transceiver: { wormhole: "mzp1q2j5Hr1QuLC3KFBCAUz5aUckT6qyuZKZ3WJnMmY" },
20
+ quoter: "Nqd6XqA8LbsCuG8MLWWuP865NV6jR1MbXeKxD4HLKDJ"
21
+ };
22
+ }
11
23
  static supportedNetworks() {
12
24
  return ["Mainnet", "Testnet"];
13
25
  }
26
+ static isPlatformSupported(platform) {
27
+ return platform == "Evm" || platform == "Solana";
28
+ }
14
29
  static supportedChains(network) {
15
30
  switch (network) {
16
31
  case "Mainnet":
17
- return ["Ethereum", "Arbitrum", "Optimism"];
32
+ return ["Ethereum", "Arbitrum", "Optimism", "Solana"];
18
33
  case "Testnet":
19
- return ["Sepolia", "ArbitrumSepolia", "OptimismSepolia"];
34
+ return ["Sepolia", "ArbitrumSepolia", "OptimismSepolia", "Solana"];
20
35
  default:
21
36
  throw new Error(`Unsupported network: ${network}`);
22
37
  }
23
38
  }
24
- static getContracts(chain) {
25
- switch (chain) {
39
+ static getContracts(chainContext) {
40
+ switch (chainContext.chain) {
26
41
  case "Ethereum":
27
42
  return this.EVM_CONTRACTS;
28
43
  case "Optimism":
@@ -35,15 +50,17 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
35
50
  return this.EVM_CONTRACTS;
36
51
  case "ArbitrumSepolia":
37
52
  return this.EVM_CONTRACTS;
53
+ case "Solana":
54
+ return this.solanaContracts(chainContext.network);
38
55
  default:
39
- throw new Error(`Unsupported chain: ${chain}`);
56
+ throw new Error(`Unsupported chain: ${chainContext.chain}`);
40
57
  }
41
58
  }
42
59
  static async supportedSourceTokens(fromChain) {
43
- const { token, wrappedMToken } = this.getContracts(fromChain.chain);
60
+ const { token, mLikeTokens } = this.getContracts(fromChain);
44
61
  return [
45
62
  sdkConnect.Wormhole.tokenId(fromChain.chain, token),
46
- sdkConnect.Wormhole.tokenId(fromChain.chain, wrappedMToken)
63
+ ...mLikeTokens.map((x) => sdkConnect.Wormhole.tokenId(fromChain.chain, x))
47
64
  ];
48
65
  }
49
66
  static async supportedDestinationTokens(token, fromChain, toChain) {
@@ -51,10 +68,10 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
51
68
  if (!sourceTokens.some((t) => sdkConnect.isSameToken(t, token))) {
52
69
  return [];
53
70
  }
54
- const { token: mToken, wrappedMToken } = this.getContracts(toChain.chain);
71
+ const { token: mToken, mLikeTokens } = this.getContracts(toChain);
55
72
  return [
56
73
  sdkConnect.Wormhole.tokenId(toChain.chain, mToken),
57
- sdkConnect.Wormhole.tokenId(toChain.chain, wrappedMToken)
74
+ ...mLikeTokens.map((x) => sdkConnect.Wormhole.tokenId(toChain.chain, x))
58
75
  ];
59
76
  }
60
77
  static isProtocolSupported(chain) {
@@ -65,7 +82,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
65
82
  }
66
83
  async isAvailable(request) {
67
84
  const ntt = await request.fromChain.getProtocol("Ntt", {
68
- ntt: _M0AutomaticRoute.getContracts(request.fromChain.chain)
85
+ ntt: _M0AutomaticRoute.getContracts(request.fromChain)
69
86
  });
70
87
  return ntt.isRelayingAvailable(request.toChain.chain);
71
88
  }
@@ -80,10 +97,8 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
80
97
  parsedAmount,
81
98
  request.destination.decimals
82
99
  );
83
- const fromContracts = _M0AutomaticRoute.getContracts(
84
- request.fromChain.chain
85
- );
86
- const toContracts = _M0AutomaticRoute.getContracts(request.toChain.chain);
100
+ const fromContracts = _M0AutomaticRoute.getContracts(request.fromChain);
101
+ const toContracts = _M0AutomaticRoute.getContracts(request.toChain);
87
102
  const validatedParams = {
88
103
  amount: params.amount,
89
104
  normalizedParams: {
@@ -103,7 +118,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
103
118
  async quote(request, params) {
104
119
  const { fromChain, toChain } = request;
105
120
  const ntt = await fromChain.getProtocol("Ntt", {
106
- ntt: _M0AutomaticRoute.getContracts(fromChain.chain)
121
+ ntt: _M0AutomaticRoute.getContracts(fromChain)
107
122
  });
108
123
  if (!await ntt.isRelayingAvailable(toChain.chain)) {
109
124
  return {
@@ -149,22 +164,17 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
149
164
  const { params } = quote;
150
165
  const { fromChain } = request;
151
166
  const sender = sdkConnect.Wormhole.parseAddress(signer.chain(), signer.address());
152
- if (sdkConnect.chainToPlatform(fromChain.chain) !== "Evm")
153
- throw new Error("The route supports only EVM");
167
+ const platform = sdkConnect.chainToPlatform(fromChain.chain);
168
+ const transferAmount = sdkConnect.amount.units(params.normalizedParams.amount);
169
+ const options = params.normalizedParams.options;
170
+ if (platform !== "Evm" && platform !== "Solana")
171
+ throw new Error(`Unsupported platform ${platform}`);
154
172
  const ntt = await fromChain.getProtocol("Ntt", {
155
- ntt: _M0AutomaticRoute.getContracts(fromChain.chain)
173
+ ntt: _M0AutomaticRoute.getContracts(fromChain)
156
174
  });
157
- const sourceTokenAddress = sdkConnect.canonicalAddress(request.source.id);
158
- const destinationTokenAddress = sdkConnect.canonicalAddress(request.destination.id);
159
- const initXfer = this.transferMLike(
160
- ntt,
161
- sender,
162
- sdkConnect.amount.units(params.normalizedParams.amount),
163
- to,
164
- sourceTokenAddress,
165
- destinationTokenAddress,
166
- params.normalizedParams.options
167
- );
175
+ const sourceToken = sdkConnect.canonicalAddress(request.source.id);
176
+ const destinationToken = sdkConnect.canonicalAddress(request.destination.id);
177
+ const initXfer = platform === "Evm" ? this.transferMLike(ntt, sender, transferAmount, to, sourceToken, destinationToken, options) : ntt.transfer(sender, transferAmount, to, options);
168
178
  const txids = await sdkConnect.signSendWait(fromChain, initXfer, signer);
169
179
  return {
170
180
  from: fromChain.chain,
@@ -225,13 +235,10 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
225
235
  );
226
236
  }
227
237
  async *track(receipt, timeout) {
238
+ const isEvmPlatform = (chain) => sdkConnect.chainToPlatform(chain) === "Evm";
228
239
  if (sdkConnect.isSourceInitiated(receipt) || sdkConnect.isSourceFinalized(receipt)) {
229
240
  const { txid } = receipt.originTxs[receipt.originTxs.length - 1];
230
- const isEvmPlatform = (chain) => sdkConnect.chainToPlatform(chain) === "Evm";
231
- const vaaType = isEvmPlatform(receipt.from) && isEvmPlatform(receipt.to) ? (
232
- // Automatic NTT transfers between EVM chains use standard relayers
233
- "Ntt:WormholeTransferStandardRelayer"
234
- ) : "Ntt:WormholeTransfer";
241
+ const vaaType = isEvmPlatform(receipt.from) && isEvmPlatform(receipt.to) ? "Ntt:WormholeTransferStandardRelayer" : "Ntt:WormholeTransfer";
235
242
  const vaa = await this.wh.getVaa(txid, vaaType, timeout);
236
243
  if (!vaa) {
237
244
  throw new Error(`No VAA found for transaction: ${txid}`);
@@ -253,7 +260,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
253
260
  }
254
261
  const toChain = this.wh.getChain(receipt.to);
255
262
  const ntt = await toChain.getProtocol("Ntt", {
256
- ntt: _M0AutomaticRoute.getContracts(toChain.chain)
263
+ ntt: _M0AutomaticRoute.getContracts(toChain)
257
264
  });
258
265
  if (sdkConnect.isAttested(receipt)) {
259
266
  const {
@@ -269,13 +276,11 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
269
276
  }
270
277
  }
271
278
  if (sdkConnect.isRedeemed(receipt)) {
272
- const {
273
- attestation: { attestation: vaa }
274
- } = receipt;
279
+ const { attestation: { attestation: vaa } } = receipt;
275
280
  const payload = vaa.payloadName === "WormholeTransfer" ? vaa.payload : vaa.payload["payload"];
276
- const isExecuted = await ntt.manager.isMessageExecuted(
281
+ const isExecuted = isEvmPlatform(receipt.to) ? await ntt.manager.isMessageExecuted(
277
282
  sdkDefinitionsNtt.Ntt.messageDigest(vaa.emitterChain, payload["nttManagerPayload"])
278
- );
283
+ ) : await ntt.getIsExecuted(vaa);
279
284
  if (isExecuted) {
280
285
  receipt = {
281
286
  ...receipt,
@@ -289,18 +294,22 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
289
294
  };
290
295
  // ntt does not support gas drop-off currently
291
296
  _M0AutomaticRoute.NATIVE_GAS_DROPOFF_SUPPORTED = false;
297
+ // Wrapped M token address is the same on EVM chains
298
+ _M0AutomaticRoute.EVM_WRAPPED_M_TOKEN = "0x437cc33344a0B27A429f795ff6B469C72698B291";
299
+ _M0AutomaticRoute.SOLANA_MAINNET_M_TOKEN = "mzerokyEX9TNDoK4o2YZQBDmMzjokAeN6M2g2S3pLJo";
300
+ _M0AutomaticRoute.SOLANA_TESTNET_M_TOKEN = "mzeroZRGCah3j5xEWp2Nih3GDejSBbH1rbHoxDg8By6";
292
301
  // Contract addresses are the same on all EVM chains
293
302
  _M0AutomaticRoute.EVM_CONTRACTS = {
294
303
  // M token address is the same on EVM chains
295
304
  token: "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b",
296
- // Wrapped M token address is the same on EVM chains
297
- wrappedMToken: "0x437cc33344a0B27A429f795ff6B469C72698B291",
305
+ // Wrapped $M and Extension Tokens that can bridged by unwrapping to $M
306
+ mLikeTokens: [_M0AutomaticRoute.EVM_WRAPPED_M_TOKEN],
298
307
  // M0 Portal address is the same on EVM chains
299
308
  manager: "0xD925C84b55E4e44a53749fF5F2a5A13F63D128fd",
300
309
  // Wormhole transceiver address is the same on EVM chains
301
310
  transceiver: { wormhole: "0x0763196A091575adF99e2306E5e90E0Be5154841" }
302
311
  };
303
- _M0AutomaticRoute.meta = { name: "M0AutomaticRoute", provider: "M^0" };
312
+ _M0AutomaticRoute.meta = { name: "M0AutomaticRoute", provider: "M0" };
304
313
  var M0AutomaticRoute = _M0AutomaticRoute;
305
314
 
306
315
  exports.M0AutomaticRoute = M0AutomaticRoute;
package/dist/index.mjs CHANGED
@@ -1,26 +1,41 @@
1
1
  import { routes, Wormhole, isSameToken, amount, finality, chainToPlatform, canonicalAddress, signSendWait, TransferState, universalAddress, toChainId, toUniversal, isSourceInitiated, isSourceFinalized, isAttested, isRedeemed } from '@wormhole-foundation/sdk-connect';
2
2
  import { Ntt } from '@wormhole-foundation/sdk-definitions-ntt';
3
+ import '@wormhole-foundation/sdk-solana-ntt';
3
4
  import { EvmAddress, EvmPlatform, addFrom, EvmUnsignedTransaction, addChainId } from '@wormhole-foundation/sdk-evm';
5
+ import '@wormhole-foundation/sdk-solana';
4
6
  import { NttRoute } from '@wormhole-foundation/sdk-route-ntt';
5
7
  import { Contract } from 'ethers';
6
8
 
7
9
  // src/m0AutomaticRoute.ts
8
10
  var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
11
+ static solanaContracts(network) {
12
+ return {
13
+ token: network == "Mainnet" ? this.SOLANA_MAINNET_M_TOKEN : this.SOLANA_TESTNET_M_TOKEN,
14
+ // Only M token can be bridged from Solana
15
+ mLikeTokens: [],
16
+ manager: "mzp1q2j5Hr1QuLC3KFBCAUz5aUckT6qyuZKZ3WJnMmY",
17
+ transceiver: { wormhole: "mzp1q2j5Hr1QuLC3KFBCAUz5aUckT6qyuZKZ3WJnMmY" },
18
+ quoter: "Nqd6XqA8LbsCuG8MLWWuP865NV6jR1MbXeKxD4HLKDJ"
19
+ };
20
+ }
9
21
  static supportedNetworks() {
10
22
  return ["Mainnet", "Testnet"];
11
23
  }
24
+ static isPlatformSupported(platform) {
25
+ return platform == "Evm" || platform == "Solana";
26
+ }
12
27
  static supportedChains(network) {
13
28
  switch (network) {
14
29
  case "Mainnet":
15
- return ["Ethereum", "Arbitrum", "Optimism"];
30
+ return ["Ethereum", "Arbitrum", "Optimism", "Solana"];
16
31
  case "Testnet":
17
- return ["Sepolia", "ArbitrumSepolia", "OptimismSepolia"];
32
+ return ["Sepolia", "ArbitrumSepolia", "OptimismSepolia", "Solana"];
18
33
  default:
19
34
  throw new Error(`Unsupported network: ${network}`);
20
35
  }
21
36
  }
22
- static getContracts(chain) {
23
- switch (chain) {
37
+ static getContracts(chainContext) {
38
+ switch (chainContext.chain) {
24
39
  case "Ethereum":
25
40
  return this.EVM_CONTRACTS;
26
41
  case "Optimism":
@@ -33,15 +48,17 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
33
48
  return this.EVM_CONTRACTS;
34
49
  case "ArbitrumSepolia":
35
50
  return this.EVM_CONTRACTS;
51
+ case "Solana":
52
+ return this.solanaContracts(chainContext.network);
36
53
  default:
37
- throw new Error(`Unsupported chain: ${chain}`);
54
+ throw new Error(`Unsupported chain: ${chainContext.chain}`);
38
55
  }
39
56
  }
40
57
  static async supportedSourceTokens(fromChain) {
41
- const { token, wrappedMToken } = this.getContracts(fromChain.chain);
58
+ const { token, mLikeTokens } = this.getContracts(fromChain);
42
59
  return [
43
60
  Wormhole.tokenId(fromChain.chain, token),
44
- Wormhole.tokenId(fromChain.chain, wrappedMToken)
61
+ ...mLikeTokens.map((x) => Wormhole.tokenId(fromChain.chain, x))
45
62
  ];
46
63
  }
47
64
  static async supportedDestinationTokens(token, fromChain, toChain) {
@@ -49,10 +66,10 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
49
66
  if (!sourceTokens.some((t) => isSameToken(t, token))) {
50
67
  return [];
51
68
  }
52
- const { token: mToken, wrappedMToken } = this.getContracts(toChain.chain);
69
+ const { token: mToken, mLikeTokens } = this.getContracts(toChain);
53
70
  return [
54
71
  Wormhole.tokenId(toChain.chain, mToken),
55
- Wormhole.tokenId(toChain.chain, wrappedMToken)
72
+ ...mLikeTokens.map((x) => Wormhole.tokenId(toChain.chain, x))
56
73
  ];
57
74
  }
58
75
  static isProtocolSupported(chain) {
@@ -63,7 +80,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
63
80
  }
64
81
  async isAvailable(request) {
65
82
  const ntt = await request.fromChain.getProtocol("Ntt", {
66
- ntt: _M0AutomaticRoute.getContracts(request.fromChain.chain)
83
+ ntt: _M0AutomaticRoute.getContracts(request.fromChain)
67
84
  });
68
85
  return ntt.isRelayingAvailable(request.toChain.chain);
69
86
  }
@@ -78,10 +95,8 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
78
95
  parsedAmount,
79
96
  request.destination.decimals
80
97
  );
81
- const fromContracts = _M0AutomaticRoute.getContracts(
82
- request.fromChain.chain
83
- );
84
- const toContracts = _M0AutomaticRoute.getContracts(request.toChain.chain);
98
+ const fromContracts = _M0AutomaticRoute.getContracts(request.fromChain);
99
+ const toContracts = _M0AutomaticRoute.getContracts(request.toChain);
85
100
  const validatedParams = {
86
101
  amount: params.amount,
87
102
  normalizedParams: {
@@ -101,7 +116,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
101
116
  async quote(request, params) {
102
117
  const { fromChain, toChain } = request;
103
118
  const ntt = await fromChain.getProtocol("Ntt", {
104
- ntt: _M0AutomaticRoute.getContracts(fromChain.chain)
119
+ ntt: _M0AutomaticRoute.getContracts(fromChain)
105
120
  });
106
121
  if (!await ntt.isRelayingAvailable(toChain.chain)) {
107
122
  return {
@@ -147,22 +162,17 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
147
162
  const { params } = quote;
148
163
  const { fromChain } = request;
149
164
  const sender = Wormhole.parseAddress(signer.chain(), signer.address());
150
- if (chainToPlatform(fromChain.chain) !== "Evm")
151
- throw new Error("The route supports only EVM");
165
+ const platform = chainToPlatform(fromChain.chain);
166
+ const transferAmount = amount.units(params.normalizedParams.amount);
167
+ const options = params.normalizedParams.options;
168
+ if (platform !== "Evm" && platform !== "Solana")
169
+ throw new Error(`Unsupported platform ${platform}`);
152
170
  const ntt = await fromChain.getProtocol("Ntt", {
153
- ntt: _M0AutomaticRoute.getContracts(fromChain.chain)
171
+ ntt: _M0AutomaticRoute.getContracts(fromChain)
154
172
  });
155
- const sourceTokenAddress = canonicalAddress(request.source.id);
156
- const destinationTokenAddress = canonicalAddress(request.destination.id);
157
- const initXfer = this.transferMLike(
158
- ntt,
159
- sender,
160
- amount.units(params.normalizedParams.amount),
161
- to,
162
- sourceTokenAddress,
163
- destinationTokenAddress,
164
- params.normalizedParams.options
165
- );
173
+ const sourceToken = canonicalAddress(request.source.id);
174
+ const destinationToken = canonicalAddress(request.destination.id);
175
+ const initXfer = platform === "Evm" ? this.transferMLike(ntt, sender, transferAmount, to, sourceToken, destinationToken, options) : ntt.transfer(sender, transferAmount, to, options);
166
176
  const txids = await signSendWait(fromChain, initXfer, signer);
167
177
  return {
168
178
  from: fromChain.chain,
@@ -223,13 +233,10 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
223
233
  );
224
234
  }
225
235
  async *track(receipt, timeout) {
236
+ const isEvmPlatform = (chain) => chainToPlatform(chain) === "Evm";
226
237
  if (isSourceInitiated(receipt) || isSourceFinalized(receipt)) {
227
238
  const { txid } = receipt.originTxs[receipt.originTxs.length - 1];
228
- const isEvmPlatform = (chain) => chainToPlatform(chain) === "Evm";
229
- const vaaType = isEvmPlatform(receipt.from) && isEvmPlatform(receipt.to) ? (
230
- // Automatic NTT transfers between EVM chains use standard relayers
231
- "Ntt:WormholeTransferStandardRelayer"
232
- ) : "Ntt:WormholeTransfer";
239
+ const vaaType = isEvmPlatform(receipt.from) && isEvmPlatform(receipt.to) ? "Ntt:WormholeTransferStandardRelayer" : "Ntt:WormholeTransfer";
233
240
  const vaa = await this.wh.getVaa(txid, vaaType, timeout);
234
241
  if (!vaa) {
235
242
  throw new Error(`No VAA found for transaction: ${txid}`);
@@ -251,7 +258,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
251
258
  }
252
259
  const toChain = this.wh.getChain(receipt.to);
253
260
  const ntt = await toChain.getProtocol("Ntt", {
254
- ntt: _M0AutomaticRoute.getContracts(toChain.chain)
261
+ ntt: _M0AutomaticRoute.getContracts(toChain)
255
262
  });
256
263
  if (isAttested(receipt)) {
257
264
  const {
@@ -267,13 +274,11 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
267
274
  }
268
275
  }
269
276
  if (isRedeemed(receipt)) {
270
- const {
271
- attestation: { attestation: vaa }
272
- } = receipt;
277
+ const { attestation: { attestation: vaa } } = receipt;
273
278
  const payload = vaa.payloadName === "WormholeTransfer" ? vaa.payload : vaa.payload["payload"];
274
- const isExecuted = await ntt.manager.isMessageExecuted(
279
+ const isExecuted = isEvmPlatform(receipt.to) ? await ntt.manager.isMessageExecuted(
275
280
  Ntt.messageDigest(vaa.emitterChain, payload["nttManagerPayload"])
276
- );
281
+ ) : await ntt.getIsExecuted(vaa);
277
282
  if (isExecuted) {
278
283
  receipt = {
279
284
  ...receipt,
@@ -287,18 +292,22 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
287
292
  };
288
293
  // ntt does not support gas drop-off currently
289
294
  _M0AutomaticRoute.NATIVE_GAS_DROPOFF_SUPPORTED = false;
295
+ // Wrapped M token address is the same on EVM chains
296
+ _M0AutomaticRoute.EVM_WRAPPED_M_TOKEN = "0x437cc33344a0B27A429f795ff6B469C72698B291";
297
+ _M0AutomaticRoute.SOLANA_MAINNET_M_TOKEN = "mzerokyEX9TNDoK4o2YZQBDmMzjokAeN6M2g2S3pLJo";
298
+ _M0AutomaticRoute.SOLANA_TESTNET_M_TOKEN = "mzeroZRGCah3j5xEWp2Nih3GDejSBbH1rbHoxDg8By6";
290
299
  // Contract addresses are the same on all EVM chains
291
300
  _M0AutomaticRoute.EVM_CONTRACTS = {
292
301
  // M token address is the same on EVM chains
293
302
  token: "0x866A2BF4E572CbcF37D5071A7a58503Bfb36be1b",
294
- // Wrapped M token address is the same on EVM chains
295
- wrappedMToken: "0x437cc33344a0B27A429f795ff6B469C72698B291",
303
+ // Wrapped $M and Extension Tokens that can bridged by unwrapping to $M
304
+ mLikeTokens: [_M0AutomaticRoute.EVM_WRAPPED_M_TOKEN],
296
305
  // M0 Portal address is the same on EVM chains
297
306
  manager: "0xD925C84b55E4e44a53749fF5F2a5A13F63D128fd",
298
307
  // Wormhole transceiver address is the same on EVM chains
299
308
  transceiver: { wormhole: "0x0763196A091575adF99e2306E5e90E0Be5154841" }
300
309
  };
301
- _M0AutomaticRoute.meta = { name: "M0AutomaticRoute", provider: "M^0" };
310
+ _M0AutomaticRoute.meta = { name: "M0AutomaticRoute", provider: "M0" };
302
311
  var M0AutomaticRoute = _M0AutomaticRoute;
303
312
 
304
313
  export { M0AutomaticRoute };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m0-foundation/ntt-sdk-route",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",
@@ -35,6 +35,8 @@
35
35
  "@wormhole-foundation/sdk-definitions-ntt": "^0.7.1",
36
36
  "@wormhole-foundation/sdk-evm": "^1.7.0",
37
37
  "@wormhole-foundation/sdk-evm-ntt": "^0.7.1",
38
+ "@wormhole-foundation/sdk-solana": "^1.7.0",
39
+ "@wormhole-foundation/sdk-solana-ntt": "^0.7.1",
38
40
  "@wormhole-foundation/sdk-route-ntt": "^0.7.1",
39
41
  "ethers": "^6.5.1"
40
42
  },