Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@orca-so/common-sdk

Package Overview
Dependencies
Maintainers
4
Versions
75
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orca-so/common-sdk - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

22

dist/helpers/token-instructions.js

@@ -1,15 +0,18 @@

import { AccountLayout, NATIVE_MINT, Token, TOKEN_PROGRAM_ID } from "@solana/spl-token";
import { Keypair, SystemProgram } from "@solana/web3.js";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.createWSOLAccountInstructions = void 0;
const spl_token_1 = require("@solana/spl-token");
const web3_js_1 = require("@solana/web3.js");
// TODO use native-mint instead
export function createWSOLAccountInstructions(walletAddress, amountIn, rentExemptLamports) {
const tempAccount = new Keypair();
const createAccountInstruction = SystemProgram.createAccount({
function createWSOLAccountInstructions(walletAddress, amountIn, rentExemptLamports) {
const tempAccount = new web3_js_1.Keypair();
const createAccountInstruction = web3_js_1.SystemProgram.createAccount({
fromPubkey: walletAddress,
newAccountPubkey: tempAccount.publicKey,
lamports: amountIn.toNumber() + rentExemptLamports,
space: AccountLayout.span,
programId: TOKEN_PROGRAM_ID,
space: spl_token_1.AccountLayout.span,
programId: spl_token_1.TOKEN_PROGRAM_ID,
});
const initAccountInstruction = Token.createInitAccountInstruction(TOKEN_PROGRAM_ID, NATIVE_MINT, tempAccount.publicKey, walletAddress);
const closeWSOLAccountInstruction = Token.createCloseAccountInstruction(TOKEN_PROGRAM_ID, tempAccount.publicKey, walletAddress, walletAddress, []);
const initAccountInstruction = spl_token_1.Token.createInitAccountInstruction(spl_token_1.TOKEN_PROGRAM_ID, spl_token_1.NATIVE_MINT, tempAccount.publicKey, walletAddress);
const closeWSOLAccountInstruction = spl_token_1.Token.createCloseAccountInstruction(spl_token_1.TOKEN_PROGRAM_ID, tempAccount.publicKey, walletAddress, walletAddress, []);
return {

@@ -22,1 +25,2 @@ address: tempAccount.publicKey,

}
exports.createWSOLAccountInstructions = createWSOLAccountInstructions;

@@ -1,2 +0,18 @@

export * from "./math";
export * from "./web3";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./math"), exports);
__exportStar(require("./web3"), exports);

@@ -1,12 +0,18 @@

import { u64 } from "@solana/spl-token";
import Decimal from "decimal.js";
export class DecimalUtil {
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.DecimalUtil = void 0;
const spl_token_1 = require("@solana/spl-token");
const decimal_js_1 = __importDefault(require("decimal.js"));
class DecimalUtil {
static adjustDecimals(input, shift = 0) {
return input.div(Decimal.pow(10, shift));
return input.div(decimal_js_1.default.pow(10, shift));
}
static fromU64(input, shift = 0) {
return new Decimal(input.toString()).div(new Decimal(10).pow(shift));
return new decimal_js_1.default(input.toString()).div(new decimal_js_1.default(10).pow(shift));
}
static fromNumber(input, shift = 0) {
return new Decimal(input).div(new Decimal(10).pow(shift));
return new decimal_js_1.default(input).div(new decimal_js_1.default(10).pow(shift));
}

@@ -17,6 +23,7 @@ static toU64(input, shift = 0) {

}
const shiftedValue = input.mul(new Decimal(10).pow(shift));
const shiftedValue = input.mul(new decimal_js_1.default(10).pow(shift));
const zeroDecimalValue = shiftedValue.trunc();
return new u64(zeroDecimalValue.toString());
return new spl_token_1.u64(zeroDecimalValue.toString());
}
}
exports.DecimalUtil = DecimalUtil;

@@ -1,3 +0,19 @@

export * from "./decimal-util";
export * from "./math-util";
export * from "./percentage";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./decimal-util"), exports);
__exportStar(require("./math-util"), exports);
__exportStar(require("./percentage"), exports);

@@ -1,49 +0,55 @@

import { BN } from "@project-serum/anchor";
import Decimal from "decimal.js";
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.MathUtil = exports.U64_MAX = exports.U128 = exports.TWO = exports.ONE = exports.ZERO = void 0;
const anchor_1 = require("@project-serum/anchor");
const decimal_js_1 = __importDefault(require("decimal.js"));
/**
* @category Math
*/
export const ZERO = new BN(0);
exports.ZERO = new anchor_1.BN(0);
/**
* @category Math
*/
export const ONE = new BN(1);
exports.ONE = new anchor_1.BN(1);
/**
* @category Math
*/
export const TWO = new BN(2);
exports.TWO = new anchor_1.BN(2);
/**
* @category Math
*/
export const U128 = TWO.pow(new BN(128));
exports.U128 = exports.TWO.pow(new anchor_1.BN(128));
/**
* @category Math
*/
export const U64_MAX = TWO.pow(new BN(64)).sub(ONE);
exports.U64_MAX = exports.TWO.pow(new anchor_1.BN(64)).sub(exports.ONE);
/**
* @category Math
*/
export class MathUtil {
class MathUtil {
static toX64_BN(num) {
return num.mul(new BN(2).pow(new BN(64)));
return num.mul(new anchor_1.BN(2).pow(new anchor_1.BN(64)));
}
static toX64_Decimal(num) {
return num.mul(Decimal.pow(2, 64));
return num.mul(decimal_js_1.default.pow(2, 64));
}
static toX64(num) {
return new BN(num.mul(Decimal.pow(2, 64)).floor().toFixed());
return new anchor_1.BN(num.mul(decimal_js_1.default.pow(2, 64)).floor().toFixed());
}
static fromX64(num) {
return new Decimal(num.toString()).mul(Decimal.pow(2, -64));
return new decimal_js_1.default(num.toString()).mul(decimal_js_1.default.pow(2, -64));
}
static fromX64_Decimal(num) {
return num.mul(Decimal.pow(2, -64));
return num.mul(decimal_js_1.default.pow(2, -64));
}
static fromX64_BN(num) {
return num.div(new BN(2).pow(new BN(64)));
return num.div(new anchor_1.BN(2).pow(new anchor_1.BN(64)));
}
static shiftRightRoundUp(n) {
let result = n.shrn(64);
if (n.mod(U64_MAX).gt(ZERO)) {
result = result.add(ONE);
if (n.mod(exports.U64_MAX).gt(exports.ZERO)) {
result = result.add(exports.ONE);
}

@@ -53,5 +59,5 @@ return result;

static divRoundUp(n0, n1) {
const hasRemainder = !n0.mod(n1).eq(ZERO);
const hasRemainder = !n0.mod(n1).eq(exports.ZERO);
if (hasRemainder) {
return n0.div(n1).add(new BN(1));
return n0.div(n1).add(new anchor_1.BN(1));
}

@@ -63,4 +69,5 @@ else {

static subUnderflowU128(n0, n1) {
return n0.add(U128).sub(n1).mod(U128);
return n0.add(exports.U128).sub(n1).mod(exports.U128);
}
}
exports.MathUtil = MathUtil;

@@ -1,7 +0,13 @@

import { u64 } from "@solana/spl-token";
import Decimal from "decimal.js";
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Percentage = void 0;
const spl_token_1 = require("@solana/spl-token");
const decimal_js_1 = __importDefault(require("decimal.js"));
/**
* @category Math
*/
export class Percentage {
class Percentage {
constructor(numerator, denominator) {

@@ -18,11 +24,11 @@ this.toString = () => {

static fromFraction(numerator, denominator) {
const num = typeof numerator === "number" ? new u64(numerator.toString()) : numerator;
const denom = typeof denominator === "number" ? new u64(denominator.toString()) : denominator;
const num = typeof numerator === "number" ? new spl_token_1.u64(numerator.toString()) : numerator;
const denom = typeof denominator === "number" ? new spl_token_1.u64(denominator.toString()) : denominator;
return new Percentage(num, denom);
}
toDecimal() {
if (this.denominator.eq(new u64(0))) {
return new Decimal(0);
if (this.denominator.eq(new spl_token_1.u64(0))) {
return new decimal_js_1.default(0);
}
return new Decimal(this.numerator.toString()).div(new Decimal(this.denominator.toString()));
return new decimal_js_1.default(this.numerator.toString()).div(new decimal_js_1.default(this.denominator.toString()));
}

@@ -37,4 +43,5 @@ add(p2) {

const newNumerator = p1NumeratorAdjusted.add(p2NumeratorAdjusted);
return new Percentage(new u64(newNumerator.toString()), new u64(denomLcm.toString()));
return new Percentage(new spl_token_1.u64(newNumerator.toString()), new spl_token_1.u64(denomLcm.toString()));
}
}
exports.Percentage = Percentage;

@@ -1,8 +0,11 @@

import { translateAddress, utils } from "@project-serum/anchor";
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.AddressUtil = void 0;
const anchor_1 = require("@project-serum/anchor");
/**
* @category Util
*/
export class AddressUtil {
class AddressUtil {
static toPubKey(address) {
return translateAddress(address);
return (0, anchor_1.translateAddress)(address);
}

@@ -13,5 +16,6 @@ static toPubKeys(addresses) {

static findProgramAddress(seeds, programId) {
const [publicKey, bump] = utils.publicKey.findProgramAddressSync(seeds, programId);
const [publicKey, bump] = anchor_1.utils.publicKey.findProgramAddressSync(seeds, programId);
return { publicKey, bump };
}
}
exports.AddressUtil = AddressUtil;

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,6 +11,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { ASSOCIATED_TOKEN_PROGRAM_ID, NATIVE_MINT, Token, TOKEN_PROGRAM_ID, u64, } from "@solana/spl-token";
import { createWSOLAccountInstructions, } from "../helpers/token-instructions";
import { TokenUtil } from "./token-util";
import { EMPTY_INSTRUCTION } from "./transactions/types";
Object.defineProperty(exports, "__esModule", { value: true });
exports.deriveATA = exports.resolveOrCreateATAs = exports.resolveOrCreateATA = void 0;
const spl_token_1 = require("@solana/spl-token");
const token_instructions_1 = require("../helpers/token-instructions");
const token_util_1 = require("./token-util");
const types_1 = require("./transactions/types");
/**

@@ -27,3 +30,3 @@ * IMPORTANT: wrappedSolAmountIn should only be used for input/source token that

*/
export function resolveOrCreateATA(connection, ownerAddress, tokenMint, getAccountRentExempt, wrappedSolAmountIn = new u64(0), payer = ownerAddress) {
function resolveOrCreateATA(connection, ownerAddress, tokenMint, getAccountRentExempt, wrappedSolAmountIn = new spl_token_1.u64(0), payer = ownerAddress) {
return __awaiter(this, void 0, void 0, function* () {

@@ -34,2 +37,3 @@ const instructions = yield resolveOrCreateATAs(connection, ownerAddress, [{ tokenMint, wrappedSolAmountIn }], getAccountRentExempt, payer);

}
exports.resolveOrCreateATA = resolveOrCreateATA;
/**

@@ -47,7 +51,7 @@ * IMPORTANT: wrappedSolAmountIn should only be used for input/source token that

*/
export function resolveOrCreateATAs(connection, ownerAddress, requests, getAccountRentExempt, payer = ownerAddress) {
function resolveOrCreateATAs(connection, ownerAddress, requests, getAccountRentExempt, payer = ownerAddress) {
var _a;
return __awaiter(this, void 0, void 0, function* () {
const nonNativeMints = requests.filter(({ tokenMint }) => !tokenMint.equals(NATIVE_MINT));
const nativeMints = requests.filter(({ tokenMint }) => tokenMint.equals(NATIVE_MINT));
const nonNativeMints = requests.filter(({ tokenMint }) => !tokenMint.equals(spl_token_1.NATIVE_MINT));
const nativeMints = requests.filter(({ tokenMint }) => tokenMint.equals(spl_token_1.NATIVE_MINT));
if (nativeMints.length > 1) {

@@ -60,3 +64,3 @@ throw new Error("Cannot resolve multiple WSolAccounts");

const tokenAccountInfos = yield connection.getMultipleAccountsInfo(nonNativeAddresses);
const tokenAccounts = tokenAccountInfos.map((tai) => TokenUtil.deserializeTokenAccount(tai === null || tai === void 0 ? void 0 : tai.data));
const tokenAccounts = tokenAccountInfos.map((tai) => token_util_1.TokenUtil.deserializeTokenAccount(tai === null || tai === void 0 ? void 0 : tai.data));
tokenAccounts.forEach((tokenAccount, index) => {

@@ -66,6 +70,6 @@ const ataAddress = nonNativeAddresses[index];

if (tokenAccount) {
resolvedInstruction = Object.assign({ address: ataAddress }, EMPTY_INSTRUCTION);
resolvedInstruction = Object.assign({ address: ataAddress }, types_1.EMPTY_INSTRUCTION);
}
else {
const createAtaInstruction = Token.createAssociatedTokenAccountInstruction(ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, nonNativeMints[index].tokenMint, ataAddress, ownerAddress, payer);
const createAtaInstruction = spl_token_1.Token.createAssociatedTokenAccountInstruction(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, nonNativeMints[index].tokenMint, ataAddress, ownerAddress, payer);
resolvedInstruction = {

@@ -83,4 +87,4 @@ address: ataAddress,

const accountRentExempt = yield getAccountRentExempt();
const wrappedSolAmountIn = ((_a = nativeMints[0]) === null || _a === void 0 ? void 0 : _a.wrappedSolAmountIn) || new u64(0);
instructionMap[NATIVE_MINT.toBase58()] = createWSOLAccountInstructions(ownerAddress, wrappedSolAmountIn, accountRentExempt);
const wrappedSolAmountIn = ((_a = nativeMints[0]) === null || _a === void 0 ? void 0 : _a.wrappedSolAmountIn) || new spl_token_1.u64(0);
instructionMap[spl_token_1.NATIVE_MINT.toBase58()] = (0, token_instructions_1.createWSOLAccountInstructions)(ownerAddress, wrappedSolAmountIn, accountRentExempt);
}

@@ -91,6 +95,8 @@ // Preserve order of resolution

}
export function deriveATA(ownerAddress, tokenMint) {
exports.resolveOrCreateATAs = resolveOrCreateATAs;
function deriveATA(ownerAddress, tokenMint) {
return __awaiter(this, void 0, void 0, function* () {
return yield Token.getAssociatedTokenAddress(ASSOCIATED_TOKEN_PROGRAM_ID, TOKEN_PROGRAM_ID, tokenMint, ownerAddress);
return yield spl_token_1.Token.getAssociatedTokenAddress(spl_token_1.ASSOCIATED_TOKEN_PROGRAM_ID, spl_token_1.TOKEN_PROGRAM_ID, tokenMint, ownerAddress);
});
}
exports.deriveATA = deriveATA;

@@ -1,4 +0,20 @@

export * from "./ata-util";
export * from "./address-util";
export * from "./token-util";
export * from "./transactions";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./ata-util"), exports);
__exportStar(require("./address-util"), exports);
__exportStar(require("./token-util"), exports);
__exportStar(require("./transactions"), exports);

@@ -1,2 +0,1 @@

/// <reference types="node" />
import { AccountInfo, u64 } from "@solana/spl-token";

@@ -3,0 +2,0 @@ import { Connection, PublicKey } from "@solana/web3.js";

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -21,13 +22,18 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { AccountLayout, NATIVE_MINT, Token, TOKEN_PROGRAM_ID, u64 } from "@solana/spl-token";
import { PublicKey, SystemProgram } from "@solana/web3.js";
import invariant from "tiny-invariant";
import { ZERO } from "../math";
import { deriveATA, resolveOrCreateATA } from "../web3";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TokenUtil = void 0;
const spl_token_1 = require("@solana/spl-token");
const web3_js_1 = require("@solana/web3.js");
const tiny_invariant_1 = __importDefault(require("tiny-invariant"));
const math_1 = require("../math");
const web3_1 = require("../web3");
/**
* @category Util
*/
export class TokenUtil {
class TokenUtil {
static isNativeMint(mint) {
return mint.equals(NATIVE_MINT);
return mint.equals(spl_token_1.NATIVE_MINT);
}

@@ -51,6 +57,6 @@ /**

return __awaiter(this, void 0, void 0, function* () {
invariant(!amount.eq(ZERO), "SendToken transaction must send more than 0 tokens.");
(0, tiny_invariant_1.default)(!amount.eq(math_1.ZERO), "SendToken transaction must send more than 0 tokens.");
// Specifically handle SOL, which is not a spl-token.
if (tokenMint.equals(NATIVE_MINT)) {
const sendSolTxn = SystemProgram.transfer({
if (tokenMint.equals(spl_token_1.NATIVE_MINT)) {
const sendSolTxn = web3_js_1.SystemProgram.transfer({
fromPubkey: sourceWallet,

@@ -66,5 +72,5 @@ toPubkey: destinationWallet,

}
const sourceTokenAccount = yield deriveATA(sourceWallet, tokenMint);
const _a = yield resolveOrCreateATA(connection, destinationWallet, tokenMint, getAccountRentExempt, amount, payer), { address: destinationTokenAccount } = _a, destinationAtaIx = __rest(_a, ["address"]);
const transferIx = Token.createTransferCheckedInstruction(TOKEN_PROGRAM_ID, sourceTokenAccount, tokenMint, destinationTokenAccount, sourceWallet, [], new u64(amount.toString()), tokenDecimals);
const sourceTokenAccount = yield (0, web3_1.deriveATA)(sourceWallet, tokenMint);
const _a = yield (0, web3_1.resolveOrCreateATA)(connection, destinationWallet, tokenMint, getAccountRentExempt, amount, payer), { address: destinationTokenAccount } = _a, destinationAtaIx = __rest(_a, ["address"]);
const transferIx = spl_token_1.Token.createTransferCheckedInstruction(spl_token_1.TOKEN_PROGRAM_ID, sourceTokenAccount, tokenMint, destinationTokenAccount, sourceWallet, [], new spl_token_1.u64(amount.toString()), tokenDecimals);
return {

@@ -78,2 +84,3 @@ instructions: destinationAtaIx.instructions.concat(transferIx),

}
exports.TokenUtil = TokenUtil;
TokenUtil.deserializeTokenAccount = (data) => {

@@ -83,13 +90,13 @@ if (!data) {

}
const accountInfo = AccountLayout.decode(data);
accountInfo.mint = new PublicKey(accountInfo.mint);
accountInfo.owner = new PublicKey(accountInfo.owner);
accountInfo.amount = u64.fromBuffer(accountInfo.amount);
const accountInfo = spl_token_1.AccountLayout.decode(data);
accountInfo.mint = new web3_js_1.PublicKey(accountInfo.mint);
accountInfo.owner = new web3_js_1.PublicKey(accountInfo.owner);
accountInfo.amount = spl_token_1.u64.fromBuffer(accountInfo.amount);
if (accountInfo.delegateOption === 0) {
accountInfo.delegate = null;
accountInfo.delegatedAmount = new u64(0);
accountInfo.delegatedAmount = new spl_token_1.u64(0);
}
else {
accountInfo.delegate = new PublicKey(accountInfo.delegate);
accountInfo.delegatedAmount = u64.fromBuffer(accountInfo.delegatedAmount);
accountInfo.delegate = new web3_js_1.PublicKey(accountInfo.delegate);
accountInfo.delegatedAmount = spl_token_1.u64.fromBuffer(accountInfo.delegatedAmount);
}

@@ -99,3 +106,3 @@ accountInfo.isInitialized = accountInfo.state !== 0;

if (accountInfo.isNativeOption === 1) {
accountInfo.rentExemptReserve = u64.fromBuffer(accountInfo.isNative);
accountInfo.rentExemptReserve = spl_token_1.u64.fromBuffer(accountInfo.isNative);
accountInfo.isNative = true;

@@ -111,5 +118,5 @@ }

else {
accountInfo.closeAuthority = new PublicKey(accountInfo.closeAuthority);
accountInfo.closeAuthority = new web3_js_1.PublicKey(accountInfo.closeAuthority);
}
return accountInfo;
};

@@ -1,3 +0,19 @@

export * from "./transactions-builder";
export * from "./transactions-processor";
export * from "./types";
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
__exportStar(require("./transactions-builder"), exports);
__exportStar(require("./transactions-processor"), exports);
__exportStar(require("./types"), exports);

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,8 +11,10 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
import { Transaction } from "@solana/web3.js";
import { TransactionProcessor } from "./transactions-processor";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionBuilder = void 0;
const web3_js_1 = require("@solana/web3.js");
const transactions_processor_1 = require("./transactions-processor");
/**
* @category Transactions Util
*/
export class TransactionBuilder {
class TransactionBuilder {
constructor(connection, wallet) {

@@ -116,3 +119,3 @@ this.connection = connection;

: latestBlockhash;
const transaction = new Transaction(Object.assign(Object.assign({}, recentBlockhash), { feePayer: this.wallet.publicKey }));
const transaction = new web3_js_1.Transaction(Object.assign(Object.assign({}, recentBlockhash), { feePayer: this.wallet.publicKey }));
const ix = this.compressIx(true);

@@ -134,3 +137,3 @@ transaction.add(...ix.instructions);

const tx = yield this.build();
const tp = new TransactionProcessor(this.connection, this.wallet);
const tp = new transactions_processor_1.TransactionProcessor(this.connection, this.wallet);
const { execute } = yield tp.signAndConstructTransaction(tx);

@@ -154,1 +157,2 @@ return execute();

}
exports.TransactionBuilder = TransactionBuilder;

@@ -0,1 +1,2 @@

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -10,2 +11,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

};
Object.defineProperty(exports, "__esModule", { value: true });
exports.TransactionProcessor = void 0;
// Only used internally

@@ -17,3 +20,3 @@ var TransactionStatus;

})(TransactionStatus || (TransactionStatus = {}));
export class TransactionProcessor {
class TransactionProcessor {
constructor(connection, wallet, commitment = "confirmed") {

@@ -99,2 +102,3 @@ this.connection = connection;

}
exports.TransactionProcessor = TransactionProcessor;
function promiseToSettled(promise) {

@@ -101,0 +105,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -0,5 +1,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.EMPTY_INSTRUCTION = void 0;
/**
* @category Transactions Util
*/
export const EMPTY_INSTRUCTION = {
exports.EMPTY_INSTRUCTION = {
instructions: [],

@@ -6,0 +9,0 @@ cleanupInstructions: [],

{
"name": "@orca-so/common-sdk",
"version": "0.1.2",
"version": "0.1.3",
"description": "Common Typescript components across Orca",

@@ -13,3 +13,3 @@ "repository": "https://github.com/orca-so/orca-sdks",

"@solana/spl-token": "0.1.8",
"decimal.js": "~10.3.1",
"decimal.js": "^10.3.1",
"tiny-invariant": "^1.2.0"

@@ -16,0 +16,0 @@ },

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc