@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 +31 -12
- package/dist/index.mjs +31 -12
- package/package.json +1 -1
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
|
|
1867
|
-
|
|
1868
|
-
|
|
1869
|
-
|
|
1870
|
-
|
|
1871
|
-
|
|
1872
|
-
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
|
|
1876
|
-
|
|
1877
|
-
|
|
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
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
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
|
|