@allbridge/bridge-core-sdk 3.21.1-alpha.2 → 3.22.0-alpha.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"jupiter.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/jupiter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgD;AAChD,6CAAuF;AACvF,+CAA0C;AAC1C,oDAA6D;AAC7D,oDAAiF;AAEjF,MAAa,cAAc;IACzB,UAAU,CAAa;IACvB,UAAU,CAAS;IACnB,WAAW,CAAU;IAErB,YAAY,YAAoB,EAAE,UAAkB,EAAE,kBAA2B;QAC/E,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,yBAAyB;QAC1E,IAAI,CAAC,WAAW,GAAG,kBAAkB,CAAC;IACxC,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,WAAmB,EACnB,kBAA0B,EAC1B,MAAc,EACd,QAAiB;QAEjB,IAAI,aAAkB,CAAC;QACvB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,SAAS,CAAC;YACnD,IAAI,GAAG,GAAG,GAAG,IAAI,CAAC,UAAU,oBAAoB,kBAAkB,eAAe,uBAAW,CAAC,QAAQ,EAAE,WAAW,MAAM,aAAa,QAAQ,wCAAwC,CAAC;YAEtL,IAAI,IAAI,CAAC,WAAW,EAAE,CAAC;gBACrB,GAAG,IAAI,gBAAgB,IAAI,CAAC,WAAW,EAAE,CAAC;YAC5C,CAAC;YACD,aAAa,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACvC,CAAC;QAAC,OAAO,G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AAC,CAAC;YAE7E,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,qBAAqB,KAAK,CAAC,IAAI,WAAW,CAAC,UAAU,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAC5F,MAAM,SAAS,GAAG,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;gBACtC,IAAI,CAAC,SAAS,EAAE,CAAC;oBACf,MAAM,IAAI,qBAAQ,CAAC,wBAAwB,CAAC,CAAC;gBAC/C,CAAC;gBACD,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;YACzC,CAAC;YACD,OAAO,WAAW,CAAC;QACrB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,KAAK,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;gBACpC,MAAM,IAAI,yBAAY,CAAC,0EAA0E,CAAC,CAAC,OAAO,EAAE,CAAC,CAAC;YAChH,CAAC;YACD,MAAM,IAAI,yBAAY,CAAC,uEAAuE,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;CACF;AAvGD,wCAuGC","sourcesContent":["import { NATIVE_MINT } from \"@solana/spl-token\";\nimport { Connection, TransactionMessage, VersionedTransaction } from \"@solana/web3.js\";\nimport axios, { AxiosError } from \"axios\";\nimport { JupiterError, SdkError } from \"../../../exceptions\";\nimport { fetchAddressLookupTableAccountsFromTx } from \"../../../utils/sol/utils\";\n\nexport class JupiterService {\n connection: Connection;\n jupiterUrl: string;\n maxAccounts?: number;\n\n constructor(solanaRpcUrl: string, jupiterUrl: string, jupiterMaxAccounts?: number) {\n this.connection = new Connection(solanaRpcUrl);\n this.jupiterUrl = jupiterUrl.replace(/\\/$/, \"\"); // trim last \"/\" if exist\n this.maxAccounts = jupiterMaxAccounts;\n }\n\n async getJupiterSwapTx(\n userAddress: string,\n stableTokenAddress: string,\n amount: string,\n exactOut: boolean\n ): Promise<{ tx: VersionedTransaction; amountIn?: string }> {\n let quoteResponse: any;\n try {\n const swapMode = exactOut ? \"ExactOut\" : \"ExactIn\";\n let url = `${this.jupiterUrl}/quote?inputMint=${stableTokenAddress}&outputMint=${NATIVE_MINT.toString()}&amount=${amount}&swapMode=${swapMode}&slippageBps=100&onlyDirectRoutes=true`;\n\n if (this.maxAccounts) {\n url += `&maxAccounts=${this.maxAccounts}`;\n }\n quoteResponse = await axios.get(url);\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get route\");\n }\n\n let inAmount;\n if (exactOut && quoteResponse?.data?.inAmount) {\n inAmount = quoteResponse.data.inAmount;\n } else if (exactOut) {\n throw new JupiterError(\"Cannot get inAmount\");\n }\n\n let transactionResponse: any;\n try {\n transactionResponse = await axios.post(`${this.jupiterUrl}/swap`, {\n quoteResponse: quoteResponse.data,\n userPublicKey: userAddress,\n wrapAndUnwrapSol: true,\n });\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n let swapTransaction;\n if (transactionResponse?.data?.swapTransaction) {\n swapTransaction = transactionResponse.data.swapTransaction;\n } else {\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n const swapTransactionBuf = Buffer.from(swapTransaction, \"base64\");\n const tx = VersionedTransaction.deserialize(swapTransactionBuf);\n\n return exactOut ? { tx, amountIn: inAmount } : { tx };\n }\n\n async amendJupiterWithSdkTx(\n transaction: VersionedTransaction,\n sdkTx: VersionedTransaction\n ): Promise<VersionedTransaction> {\n try {\n const addressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(transaction, this.connection);\n const sdkAddressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(sdkTx, this.connection);\n\n const message = TransactionMessage.decompile(transaction.message, {\n addressLookupTableAccounts: addressLookupTableAccounts,\n });\n const sdkMessage = TransactionMessage.decompile(sdkTx.message, {\n addressLookupTableAccounts: sdkAddressLookupTableAccounts,\n });\n sdkMessage.instructions.shift();\n message.instructions.push(...sdkMessage.instructions);\n\n addressLookupTableAccounts.push(...sdkAddressLookupTableAccounts);\n\n transaction.message = message.compileToV0Message(addressLookupTableAccounts);\n\n if (sdkTx.message.header.numRequiredSignatures === 2 && transaction.signatures.length === 1) {\n const signature = sdkTx.signatures[0];\n if (!signature) {\n throw new SdkError(\"Signature is undefined\");\n }\n transaction.signatures.push(signature);\n }\n return transaction;\n } catch (e) {\n if (e instanceof Error && e.message) {\n throw new JupiterError(`Some error occurred during creation final swap and bridge transaction. ${e.message}`);\n }\n throw new JupiterError(\"Some error occurred during creation final swap and bridge transaction\");\n }\n }\n}\n"]}
1
+ {"version":3,"file":"jupiter.js","sourceRoot":"","sources":["../../../../../src/services/bridge/sol/jupiter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAgD;AAChD,6CAAuF;AACvF,+CAA0C;AAC1C,oDAA6D;AAC7D,oDAAiF;AAGjF,MAAa,cAAc;IACzB,UAAU,CAAa;IACvB,UAAU,CAAS;IACnB,YAAY,CAAU;IACtB,WAAW,CAAU;IAErB,YAAY,YAAoB,EAAE,aAA4B;QAC5D,IAAI,CAAC,UAAU,GAAG,IAAI,oBAAU,CAAC,YAAY,CAAC,CAAC;QAC/C,IAAI,CAAC,UAAU,GAAG,aAAa,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,CAAC,yBAAyB;QACxF,IAAI,CAAC,YAAY,GAAG,aAAa,CAAC,mBAAmB,CAAC;QACtD,IAAI,CAAC,WAAW,GAAG,aAAa,CAAC,kBAAkB,CAAC;IACtD,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,WAAmB,EACnB,kBAA0B,EAC1B,MAAc,EACd,QAAiB;QAEjB,IAAI,aAAkB,CAAC;QACvB,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,QAAQ,C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O,EAAE,CAAC,CAAC;YAChH,CAAC;YACD,MAAM,IAAI,yBAAY,CAAC,uEAAuE,CAAC,CAAC;QAClG,CAAC;IACH,CAAC;CACF;AAjHD,wCAiHC","sourcesContent":["import { NATIVE_MINT } from \"@solana/spl-token\";\nimport { Connection, TransactionMessage, VersionedTransaction } from \"@solana/web3.js\";\nimport axios, { AxiosError } from \"axios\";\nimport { JupiterError, SdkError } from \"../../../exceptions\";\nimport { fetchAddressLookupTableAccountsFromTx } from \"../../../utils/sol/utils\";\nimport { JupiterParams } from \"./index\";\n\nexport class JupiterService {\n connection: Connection;\n jupiterUrl: string;\n apiKeyHeader?: string;\n maxAccounts?: number;\n\n constructor(solanaRpcUrl: string, jupiterParams: JupiterParams) {\n this.connection = new Connection(solanaRpcUrl);\n this.jupiterUrl = jupiterParams.jupiterUrl.replace(/\\/$/, \"\"); // trim last \"/\" if exist\n this.apiKeyHeader = jupiterParams.jupiterApiKeyHeader;\n this.maxAccounts = jupiterParams.jupiterMaxAccounts;\n }\n\n async getJupiterSwapTx(\n userAddress: string,\n stableTokenAddress: string,\n amount: string,\n exactOut: boolean\n ): Promise<{ tx: VersionedTransaction; amountIn?: string }> {\n let quoteResponse: any;\n try {\n const swapMode = exactOut ? \"ExactOut\" : \"ExactIn\";\n let url = `${this.jupiterUrl}/quote?inputMint=${stableTokenAddress}&outputMint=${NATIVE_MINT.toString()}&amount=${amount}&swapMode=${swapMode}&slippageBps=100&onlyDirectRoutes=true`;\n\n if (this.maxAccounts) {\n url += `&maxAccounts=${this.maxAccounts}`;\n }\n quoteResponse = await axios.get(url, {\n headers: this.apiKeyHeader ? { \"x-api-key\": this.apiKeyHeader } : undefined,\n });\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get route\");\n }\n\n let inAmount;\n if (exactOut && quoteResponse?.data?.inAmount) {\n inAmount = quoteResponse.data.inAmount;\n } else if (exactOut) {\n throw new JupiterError(\"Cannot get inAmount\");\n }\n\n let transactionResponse: any;\n try {\n transactionResponse = await axios.post(\n `${this.jupiterUrl}/swap`,\n {\n quoteResponse: quoteResponse.data,\n userPublicKey: userAddress,\n wrapAndUnwrapSol: true,\n },\n {\n headers: this.apiKeyHeader ? { \"x-api-key\": this.apiKeyHeader } : undefined,\n }\n );\n } catch (err) {\n if (err instanceof AxiosError && err.response && err.response.data && err.response.data.error) {\n throw new JupiterError(err.response.data.error);\n }\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n let swapTransaction;\n if (transactionResponse?.data?.swapTransaction) {\n swapTransaction = transactionResponse.data.swapTransaction;\n } else {\n throw new JupiterError(\"Cannot get swap transaction\");\n }\n\n const swapTransactionBuf = Buffer.from(swapTransaction, \"base64\");\n const tx = VersionedTransaction.deserialize(swapTransactionBuf);\n\n return exactOut ? { tx, amountIn: inAmount } : { tx };\n }\n\n async amendJupiterWithSdkTx(\n transaction: VersionedTransaction,\n sdkTx: VersionedTransaction\n ): Promise<VersionedTransaction> {\n try {\n const addressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(transaction, this.connection);\n const sdkAddressLookupTableAccounts = await fetchAddressLookupTableAccountsFromTx(sdkTx, this.connection);\n\n const message = TransactionMessage.decompile(transaction.message, {\n addressLookupTableAccounts: addressLookupTableAccounts,\n });\n const sdkMessage = TransactionMessage.decompile(sdkTx.message, {\n addressLookupTableAccounts: sdkAddressLookupTableAccounts,\n });\n sdkMessage.instructions.shift();\n message.instructions.push(...sdkMessage.instructions);\n\n addressLookupTableAccounts.push(...sdkAddressLookupTableAccounts);\n\n transaction.message = message.compileToV0Message(addressLookupTableAccounts);\n\n if (sdkTx.message.header.numRequiredSignatures === 2 && transaction.signatures.length === 1) {\n const signature = sdkTx.signatures[0];\n if (!signature) {\n throw new SdkError(\"Signature is undefined\");\n }\n transaction.signatures.push(signature);\n }\n return transaction;\n } catch (e) {\n if (e instanceof Error && e.message) {\n throw new JupiterError(`Some error occurred during creation final swap and bridge transaction. ${e.message}`);\n }\n throw new JupiterError(\"Some error occurred during creation final swap and bridge transaction\");\n }\n }\n}\n"]}
@@ -1 +1 @@
1
- export declare const VERSION = "3.21.1-alpha.2";
1
+ export declare const VERSION = "3.22.0-alpha.1";
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "3.21.1-alpha.2";
4
+ exports.VERSION = "3.22.0-alpha.1";
5
5
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["export const VERSION = \"3.21.1-alpha.2\";\n"]}
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../../src/version.ts"],"names":[],"mappings":";;;AAAa,QAAA,OAAO,GAAG,gBAAgB,CAAC","sourcesContent":["export const VERSION = \"3.22.0-alpha.1\";\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@allbridge/bridge-core-sdk",
3
- "version": "3.21.1-alpha.2",
3
+ "version": "3.22.0-alpha.1",
4
4
  "main": "./dist/cjs/index.js",
5
5
  "module": "./dist/esm/index.js",
6
6
  "types": "./dist/src/index.d.ts",