@hawksightco/hawk-sdk
Advanced tools
Comparing version 1.1.28 to 1.1.29
@@ -5,3 +5,3 @@ /// <reference types="node" /> | ||
import * as web3 from "@solana/web3.js"; | ||
import { MeteoraPoolInfo, ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse, TokenAccountData, CreateAtaIdempotentParams, GetMintsFromInstructionParams } from "./types"; | ||
import { MeteoraPoolInfo, ResponseWithStatus, TransactionMetadata, TransactionMetadataResponse, TokenAccountData, CreateAtaIdempotentParams, GetMintsFromInstructionParams, Instruction } from "./types"; | ||
import { GeneralUtility } from "./classes/GeneralUtility"; | ||
@@ -257,3 +257,19 @@ import BN from "bn.js"; | ||
export declare function getJupiterRouteIxParams(data: Buffer): JupiterRouteIxParams; | ||
/** | ||
* Converts tx metadata to versioned transaction | ||
* | ||
* @param txMessage | ||
*/ | ||
export declare function toVersionedTransaction(connection: web3.Connection, txMessage: TransactionMetadataResponse): Promise<web3.VersionedTransaction>; | ||
export declare function ixStrToWeb3Ix(ix: Instruction): { | ||
keys: { | ||
isSigner: boolean; | ||
isWritable: boolean; | ||
pubkey: web3.PublicKey; | ||
}[]; | ||
data: Buffer; | ||
programId: web3.PublicKey; | ||
}; | ||
export declare function stringToAlt(connection: web3.Connection, alts: string[]): Promise<web3.AddressLookupTableAccount[]>; | ||
export {}; | ||
//# sourceMappingURL=functions.d.ts.map |
@@ -38,3 +38,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata = exports.METEORA_API_URL = void 0; | ||
exports.stringToAlt = exports.ixStrToWeb3Ix = exports.toVersionedTransaction = exports.getJupiterRouteIxParams = exports.inputTokenExists = exports.unwrapWsolToSol = exports.unwrapSolIfMintIsWsol = exports.wrapSolToWsol = exports.wrapSolIfMintIsWsol = exports.getMintsFromInstruction = exports.createAtaIdempotentIxs = exports.parseTokenAccountData = exports.tokenAccountExists = exports.sighash = exports.sighashMatch = exports.getIxs = exports.generateUserPdaStorageAccount = exports.generateOrcaPositionPDA = exports.generateAta = exports.generateUserPda = exports.createTransactionMeta = exports.getMeteoraPool = exports.getFeeEstimate = exports.resultOrError = exports.createTxMetadata = exports.METEORA_API_URL = void 0; | ||
const client = __importStar(require("@hawksightco/swagger-client")); | ||
@@ -582,1 +582,47 @@ const web3 = __importStar(require("@solana/web3.js")); | ||
exports.getJupiterRouteIxParams = getJupiterRouteIxParams; | ||
/** | ||
* Converts tx metadata to versioned transaction | ||
* | ||
* @param txMessage | ||
*/ | ||
function toVersionedTransaction(connection, txMessage) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const alts = yield stringToAlt(connection, txMessage.addressLookupTableAddresses); | ||
const result = new web3.VersionedTransaction(new web3.TransactionMessage({ | ||
instructions: txMessage.mainInstructions.map((ix) => ixStrToWeb3Ix(ix)), | ||
payerKey: new web3.PublicKey(txMessage.payer), | ||
recentBlockhash: web3.PublicKey.default.toString(), | ||
}).compileToV0Message(alts)); | ||
return result; | ||
}); | ||
} | ||
exports.toVersionedTransaction = toVersionedTransaction; | ||
function ixStrToWeb3Ix(ix) { | ||
return { | ||
keys: ix.accounts.map((account) => { | ||
return { | ||
isSigner: account.isSigner, | ||
isWritable: account.isWritable, | ||
pubkey: new web3.PublicKey(account.pubkey), | ||
}; | ||
}), | ||
data: Buffer.from(ix.data, "base64"), | ||
programId: new web3.PublicKey(ix.programId), | ||
}; | ||
} | ||
exports.ixStrToWeb3Ix = ixStrToWeb3Ix; | ||
function stringToAlt(connection, alts) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const _alts = []; | ||
const pubkeys = alts.map(alt => new web3.PublicKey(alt)); | ||
const accountInfos = yield connection.getMultipleAccountsInfo(pubkeys); | ||
for (let i = 0; i < accountInfos.length; i++) { | ||
_alts.push(new web3.AddressLookupTableAccount({ | ||
key: pubkeys[i], | ||
state: web3.AddressLookupTableAccount.deserialize(accountInfos[i].data) | ||
})); | ||
} | ||
return _alts; | ||
}); | ||
} | ||
exports.stringToAlt = stringToAlt; |
export * from "./types"; | ||
export * from "./functions"; | ||
export { HawkAPI } from "./classes/HawkAPI"; | ||
@@ -3,0 +4,0 @@ export { TxGenerator } from "./classes/TxGenerator"; |
@@ -19,2 +19,3 @@ "use strict"; | ||
__exportStar(require("./types"), exports); | ||
__exportStar(require("./functions"), exports); | ||
var HawkAPI_1 = require("./classes/HawkAPI"); | ||
@@ -21,0 +22,0 @@ Object.defineProperty(exports, "HawkAPI", { enumerable: true, get: function () { return HawkAPI_1.HawkAPI; } }); |
{ | ||
"name": "@hawksightco/hawk-sdk", | ||
"version": "1.1.28", | ||
"version": "1.1.29", | ||
"description": "Hawksight v2 SDK", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
2101611
46717