@meteora-ag/zap-sdk 1.2.0-rc.2 → 1.2.0-rc.3

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.js CHANGED
@@ -1863,18 +1863,37 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1863
1863
  quoteResponse,
1864
1864
  config
1865
1865
  );
1866
- const instruction = new import_web32.TransactionInstruction({
1867
- keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1868
- return {
1869
- pubkey: new import_web32.PublicKey(item.pubkey),
1870
- isSigner: item.isSigner,
1871
- isWritable: item.isWritable
1872
- };
1873
- }),
1874
- programId: new import_web32.PublicKey(swapInstructionResponse.swapInstruction.programId),
1875
- data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1876
- });
1877
- return { transaction: new import_web32.Transaction().add(instruction), quoteResponse };
1866
+ const toTxInstruction = (instruction) => {
1867
+ if (!instruction) return null;
1868
+ return new import_web32.TransactionInstruction({
1869
+ keys: instruction.accounts.map((item) => {
1870
+ return {
1871
+ pubkey: new import_web32.PublicKey(item.pubkey),
1872
+ isSigner: item.isSigner,
1873
+ isWritable: item.isWritable
1874
+ };
1875
+ }),
1876
+ programId: new import_web32.PublicKey(instruction.programId),
1877
+ data: Buffer.from(instruction.data, "base64")
1878
+ });
1879
+ };
1880
+ const transaction = new import_web32.Transaction();
1881
+ const tokenLedgerInstruction = toTxInstruction(
1882
+ swapInstructionResponse.tokenLedgerInstruction
1883
+ );
1884
+ if (tokenLedgerInstruction) {
1885
+ transaction.add(tokenLedgerInstruction);
1886
+ }
1887
+ for (const setupInstruction of swapInstructionResponse.setupInstructions) {
1888
+ const txInstruction = toTxInstruction(setupInstruction);
1889
+ if (txInstruction) transaction.add(txInstruction);
1890
+ }
1891
+ const swapInstruction = toTxInstruction(swapInstructionResponse.swapInstruction);
1892
+ if (!swapInstruction) {
1893
+ throw new Error("Missing Jupiter swap instruction");
1894
+ }
1895
+ transaction.add(swapInstruction);
1896
+ return { transaction, quoteResponse };
1878
1897
  });
1879
1898
  }
1880
1899
 
package/dist/index.mjs CHANGED
@@ -1793,18 +1793,37 @@ function buildJupiterSwapTransaction(_0, _1, _2, _3, _4, _5, _6) {
1793
1793
  quoteResponse,
1794
1794
  config
1795
1795
  );
1796
- const instruction = new TransactionInstruction({
1797
- keys: swapInstructionResponse.swapInstruction.accounts.map((item) => {
1798
- return {
1799
- pubkey: new PublicKey2(item.pubkey),
1800
- isSigner: item.isSigner,
1801
- isWritable: item.isWritable
1802
- };
1803
- }),
1804
- programId: new PublicKey2(swapInstructionResponse.swapInstruction.programId),
1805
- data: Buffer.from(swapInstructionResponse.swapInstruction.data, "base64")
1806
- });
1807
- return { transaction: new Transaction().add(instruction), quoteResponse };
1796
+ const toTxInstruction = (instruction) => {
1797
+ if (!instruction) return null;
1798
+ return new TransactionInstruction({
1799
+ keys: instruction.accounts.map((item) => {
1800
+ return {
1801
+ pubkey: new PublicKey2(item.pubkey),
1802
+ isSigner: item.isSigner,
1803
+ isWritable: item.isWritable
1804
+ };
1805
+ }),
1806
+ programId: new PublicKey2(instruction.programId),
1807
+ data: Buffer.from(instruction.data, "base64")
1808
+ });
1809
+ };
1810
+ const transaction = new Transaction();
1811
+ const tokenLedgerInstruction = toTxInstruction(
1812
+ swapInstructionResponse.tokenLedgerInstruction
1813
+ );
1814
+ if (tokenLedgerInstruction) {
1815
+ transaction.add(tokenLedgerInstruction);
1816
+ }
1817
+ for (const setupInstruction of swapInstructionResponse.setupInstructions) {
1818
+ const txInstruction = toTxInstruction(setupInstruction);
1819
+ if (txInstruction) transaction.add(txInstruction);
1820
+ }
1821
+ const swapInstruction = toTxInstruction(swapInstructionResponse.swapInstruction);
1822
+ if (!swapInstruction) {
1823
+ throw new Error("Missing Jupiter swap instruction");
1824
+ }
1825
+ transaction.add(swapInstruction);
1826
+ return { transaction, quoteResponse };
1808
1827
  });
1809
1828
  }
1810
1829
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meteora-ag/zap-sdk",
3
- "version": "1.2.0-rc.2",
3
+ "version": "1.2.0-rc.3",
4
4
  "description": "A Typescript SDK for interacting with the Zap program on Meteora.",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",