@m0-foundation/ntt-sdk-route 0.0.14 → 0.0.15

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
@@ -71,7 +71,7 @@ declare class SolanaRoutes<N extends Network, C extends SolanaChains> {
71
71
  mLikeTokens: string[];
72
72
  };
73
73
  getTransferExtensionBurnIx(amount: bigint, recipient: ChainAddress, payer: PublicKey, outboxItem: PublicKey, extMint: PublicKey, destinationToken: Uint8Array, shouldQueue?: boolean): TransactionInstruction;
74
- getExecutorRelayIx(sender: PublicKey, quote: NttWithExecutor.Quote, destinationChain: Chain, outboxItem: PublicKey): TransactionInstruction;
74
+ getExecutorRelayIx(sender: PublicKey, quote: NttWithExecutor.Quote, destinationChain: Chain): Promise<TransactionInstruction>;
75
75
  getReleaseInboundMintExtensionIx(nttMessage: Ntt.Message, emitterChain: Chain, payer: PublicKey, extMint: PublicKey, extAta: PublicKey): TransactionInstruction;
76
76
  getAddressLookupTableAccounts(connection: Connection): Promise<AddressLookupTableAccount>;
77
77
  static createReleaseInboundMintInstruction<N extends Network, C extends SolanaChains>(ntt: SolanaNtt<N, C>, args: {
package/dist/index.d.ts CHANGED
@@ -71,7 +71,7 @@ declare class SolanaRoutes<N extends Network, C extends SolanaChains> {
71
71
  mLikeTokens: string[];
72
72
  };
73
73
  getTransferExtensionBurnIx(amount: bigint, recipient: ChainAddress, payer: PublicKey, outboxItem: PublicKey, extMint: PublicKey, destinationToken: Uint8Array, shouldQueue?: boolean): TransactionInstruction;
74
- getExecutorRelayIx(sender: PublicKey, quote: NttWithExecutor.Quote, destinationChain: Chain, outboxItem: PublicKey): TransactionInstruction;
74
+ getExecutorRelayIx(sender: PublicKey, quote: NttWithExecutor.Quote, destinationChain: Chain): Promise<TransactionInstruction>;
75
75
  getReleaseInboundMintExtensionIx(nttMessage: Ntt.Message, emitterChain: Chain, payer: PublicKey, extMint: PublicKey, extAta: PublicKey): TransactionInstruction;
76
76
  getAddressLookupTableAccounts(connection: Connection): Promise<AddressLookupTableAccount>;
77
77
  static createReleaseInboundMintInstruction<N extends Network, C extends SolanaChains>(ntt: SolanaNtt<N, C>, args: {
package/dist/index.js CHANGED
@@ -87,6 +87,10 @@ var SolanaRoutes = class _SolanaRoutes {
87
87
  usdkyPPxgV7sfNyKb8eDz66ogPrkRXG3wS2FVb6LLUf: {
88
88
  program: pk("3PskKTHgboCbUSQPMcCAZdZNFHbNvSoZ8zEFYANCdob7"),
89
89
  tokenProgram: splToken.TOKEN_2022_PROGRAM_ID
90
+ },
91
+ fUSDqquEMUU8UmU2YWYGZy2Lda1oMzBc88Mkzc1PRDw: {
92
+ program: pk("extUkDFf3HLekkxbcZ3XRUizMjbxMJgKBay3p9xGVmg"),
93
+ tokenProgram: splToken.TOKEN_PROGRAM_ID
90
94
  }
91
95
  }
92
96
  }[network];
@@ -335,14 +339,27 @@ var SolanaRoutes = class _SolanaRoutes {
335
339
  ])
336
340
  });
337
341
  }
338
- getExecutorRelayIx(sender, quote, destinationChain, outboxItem) {
339
- const nttPeer = web3_js.PublicKey.findProgramAddressSync(
340
- [
341
- Buffer.from("peer"),
342
- new BN__default.default(sdkConnect.chainToChainId(destinationChain)).toArrayLike(Buffer, "le", 2)
343
- ],
344
- this.programs.portal
342
+ async getExecutorRelayIx(sender, quote, destinationChain) {
343
+ const emitter = web3_js.PublicKey.findProgramAddressSync(
344
+ [Buffer.from("emitter")],
345
+ this.ntt.program.programId
345
346
  )[0];
347
+ const bridgeSequence = web3_js.PublicKey.findProgramAddressSync(
348
+ [Buffer.from("Sequence"), emitter.toBytes()],
349
+ new web3_js.PublicKey(this.ntt.contracts.coreBridge)
350
+ )[0];
351
+ const info = await this.ntt.connection.getAccountInfo(bridgeSequence);
352
+ const sequence = new BN__default.default(info.data, "le");
353
+ const vaaReqBytes = Buffer.concat([
354
+ Buffer.from("ERV1"),
355
+ // type
356
+ new BN__default.default(sdkConnect.chainToChainId(this.ntt.chain)).toArrayLike(Buffer, "be", 2),
357
+ // emitter chain
358
+ emitter.toBuffer(),
359
+ // emitter address
360
+ sequence.toArrayLike(Buffer, "be", 8)
361
+ // sequence
362
+ ]);
346
363
  const signedQuoteBytes = Buffer.from(quote.signedQuote);
347
364
  const relayInstructions = Buffer.from(quote.relayInstructions);
348
365
  return new web3_js.TransactionInstruction({
@@ -358,47 +375,35 @@ var SolanaRoutes = class _SolanaRoutes {
358
375
  isSigner: false,
359
376
  isWritable: true
360
377
  },
361
- {
362
- // ntt_program_id
363
- pubkey: this.programs.portal,
364
- isSigner: false,
365
- isWritable: false
366
- },
367
- {
368
- pubkey: nttPeer,
369
- isSigner: false,
370
- isWritable: false
371
- },
372
- {
373
- // ntt_message
374
- pubkey: outboxItem,
375
- isSigner: false,
376
- isWritable: false
377
- },
378
- {
379
- // executor_program
380
- pubkey: new web3_js.PublicKey("execXUrAsMnqMmTHj5m7N1YQgsDz3cwGLYCYyuDRciV"),
381
- isSigner: false,
382
- isWritable: false
383
- },
384
378
  {
385
379
  pubkey: web3_js.SystemProgram.programId,
386
380
  isSigner: false,
387
381
  isWritable: false
388
382
  }
389
383
  ],
390
- programId: new web3_js.PublicKey("nex1gkSWtRBheEJuQZMqHhbMG5A45qPU76KqnCZNVHR"),
384
+ programId: new web3_js.PublicKey("execXUrAsMnqMmTHj5m7N1YQgsDz3cwGLYCYyuDRciV"),
391
385
  data: Buffer.concat([
392
- Buffer.from(sha2.sha256("global:relay_ntt_mesage").subarray(0, 8)),
386
+ Buffer.from(sha2.sha256("global:request_for_execution").subarray(0, 8)),
387
+ // [109, 107, 87, 37, 151, 192, 119, 115]
388
+ new BN__default.default(quote.estimatedCost.toString()).toArrayLike(Buffer, "le", 8),
389
+ // amount
393
390
  new BN__default.default(sdkConnect.chainToChainId(destinationChain)).toArrayLike(Buffer, "le", 2),
394
- // recipient_chain
391
+ // dst_chain
392
+ this.ntt.program.programId.toBuffer(),
393
+ // peer portal address
394
+ sender.toBuffer(),
395
+ // refund_addr
395
396
  new BN__default.default(signedQuoteBytes.length).toArrayLike(Buffer, "le", 4),
396
397
  // vec length
397
- Buffer.from(signedQuoteBytes),
398
+ signedQuoteBytes,
398
399
  // signed_quote_bytes
400
+ new BN__default.default(vaaReqBytes.length).toArrayLike(Buffer, "le", 4),
401
+ // vec length
402
+ vaaReqBytes,
403
+ // request_bytes
399
404
  new BN__default.default(relayInstructions.length).toArrayLike(Buffer, "le", 4),
400
405
  // vec length
401
- Buffer.from(relayInstructions)
406
+ relayInstructions
402
407
  // relay_instructions
403
408
  ])
404
409
  });
@@ -1036,12 +1041,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends sdkConnect.routes.Automa
1036
1041
  amount2
1037
1042
  );
1038
1043
  tx.add(
1039
- router.getExecutorRelayIx(
1040
- payerAddress,
1041
- quote,
1042
- recipient.chain,
1043
- outboxItem.publicKey
1044
- )
1044
+ await router.getExecutorRelayIx(payerAddress, quote, recipient.chain)
1045
1045
  );
1046
1046
  } else if (options.automatic) {
1047
1047
  if (!ntt.quoter) {
package/dist/index.mjs CHANGED
@@ -79,6 +79,10 @@ var SolanaRoutes = class _SolanaRoutes {
79
79
  usdkyPPxgV7sfNyKb8eDz66ogPrkRXG3wS2FVb6LLUf: {
80
80
  program: pk("3PskKTHgboCbUSQPMcCAZdZNFHbNvSoZ8zEFYANCdob7"),
81
81
  tokenProgram: TOKEN_2022_PROGRAM_ID
82
+ },
83
+ fUSDqquEMUU8UmU2YWYGZy2Lda1oMzBc88Mkzc1PRDw: {
84
+ program: pk("extUkDFf3HLekkxbcZ3XRUizMjbxMJgKBay3p9xGVmg"),
85
+ tokenProgram: TOKEN_PROGRAM_ID
82
86
  }
83
87
  }
84
88
  }[network];
@@ -327,14 +331,27 @@ var SolanaRoutes = class _SolanaRoutes {
327
331
  ])
328
332
  });
329
333
  }
330
- getExecutorRelayIx(sender, quote, destinationChain, outboxItem) {
331
- const nttPeer = PublicKey.findProgramAddressSync(
332
- [
333
- Buffer.from("peer"),
334
- new BN(chainToChainId(destinationChain)).toArrayLike(Buffer, "le", 2)
335
- ],
336
- this.programs.portal
334
+ async getExecutorRelayIx(sender, quote, destinationChain) {
335
+ const emitter = PublicKey.findProgramAddressSync(
336
+ [Buffer.from("emitter")],
337
+ this.ntt.program.programId
337
338
  )[0];
339
+ const bridgeSequence = PublicKey.findProgramAddressSync(
340
+ [Buffer.from("Sequence"), emitter.toBytes()],
341
+ new PublicKey(this.ntt.contracts.coreBridge)
342
+ )[0];
343
+ const info = await this.ntt.connection.getAccountInfo(bridgeSequence);
344
+ const sequence = new BN(info.data, "le");
345
+ const vaaReqBytes = Buffer.concat([
346
+ Buffer.from("ERV1"),
347
+ // type
348
+ new BN(chainToChainId(this.ntt.chain)).toArrayLike(Buffer, "be", 2),
349
+ // emitter chain
350
+ emitter.toBuffer(),
351
+ // emitter address
352
+ sequence.toArrayLike(Buffer, "be", 8)
353
+ // sequence
354
+ ]);
338
355
  const signedQuoteBytes = Buffer.from(quote.signedQuote);
339
356
  const relayInstructions = Buffer.from(quote.relayInstructions);
340
357
  return new TransactionInstruction({
@@ -350,47 +367,35 @@ var SolanaRoutes = class _SolanaRoutes {
350
367
  isSigner: false,
351
368
  isWritable: true
352
369
  },
353
- {
354
- // ntt_program_id
355
- pubkey: this.programs.portal,
356
- isSigner: false,
357
- isWritable: false
358
- },
359
- {
360
- pubkey: nttPeer,
361
- isSigner: false,
362
- isWritable: false
363
- },
364
- {
365
- // ntt_message
366
- pubkey: outboxItem,
367
- isSigner: false,
368
- isWritable: false
369
- },
370
- {
371
- // executor_program
372
- pubkey: new PublicKey("execXUrAsMnqMmTHj5m7N1YQgsDz3cwGLYCYyuDRciV"),
373
- isSigner: false,
374
- isWritable: false
375
- },
376
370
  {
377
371
  pubkey: SystemProgram.programId,
378
372
  isSigner: false,
379
373
  isWritable: false
380
374
  }
381
375
  ],
382
- programId: new PublicKey("nex1gkSWtRBheEJuQZMqHhbMG5A45qPU76KqnCZNVHR"),
376
+ programId: new PublicKey("execXUrAsMnqMmTHj5m7N1YQgsDz3cwGLYCYyuDRciV"),
383
377
  data: Buffer.concat([
384
- Buffer.from(sha256("global:relay_ntt_mesage").subarray(0, 8)),
378
+ Buffer.from(sha256("global:request_for_execution").subarray(0, 8)),
379
+ // [109, 107, 87, 37, 151, 192, 119, 115]
380
+ new BN(quote.estimatedCost.toString()).toArrayLike(Buffer, "le", 8),
381
+ // amount
385
382
  new BN(chainToChainId(destinationChain)).toArrayLike(Buffer, "le", 2),
386
- // recipient_chain
383
+ // dst_chain
384
+ this.ntt.program.programId.toBuffer(),
385
+ // peer portal address
386
+ sender.toBuffer(),
387
+ // refund_addr
387
388
  new BN(signedQuoteBytes.length).toArrayLike(Buffer, "le", 4),
388
389
  // vec length
389
- Buffer.from(signedQuoteBytes),
390
+ signedQuoteBytes,
390
391
  // signed_quote_bytes
392
+ new BN(vaaReqBytes.length).toArrayLike(Buffer, "le", 4),
393
+ // vec length
394
+ vaaReqBytes,
395
+ // request_bytes
391
396
  new BN(relayInstructions.length).toArrayLike(Buffer, "le", 4),
392
397
  // vec length
393
- Buffer.from(relayInstructions)
398
+ relayInstructions
394
399
  // relay_instructions
395
400
  ])
396
401
  });
@@ -1028,12 +1033,7 @@ var _M0AutomaticRoute = class _M0AutomaticRoute extends routes.AutomaticRoute {
1028
1033
  amount2
1029
1034
  );
1030
1035
  tx.add(
1031
- router.getExecutorRelayIx(
1032
- payerAddress,
1033
- quote,
1034
- recipient.chain,
1035
- outboxItem.publicKey
1036
- )
1036
+ await router.getExecutorRelayIx(payerAddress, quote, recipient.chain)
1037
1037
  );
1038
1038
  } else if (options.automatic) {
1039
1039
  if (!ntt.quoter) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m0-foundation/ntt-sdk-route",
3
- "version": "0.0.14",
3
+ "version": "0.0.15",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./dist/index.d.ts",