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.0.7 to 0.1.0

dist/web3/wallet.d.ts

1

dist/web3/token-util.d.ts

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

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

@@ -3,0 +2,0 @@ /**

@@ -1,3 +0,4 @@

import { Provider } from "@project-serum/anchor";
import { Signer, ConfirmOptions } from "@solana/web3.js";
import { AnchorProvider } from "@project-serum/anchor";
import { Wallet } from "@project-serum/anchor/dist/cjs/provider";
import { ConfirmOptions, Connection, Signer } from "@solana/web3.js";
import { Instruction, TransactionPayload } from "./types";

@@ -7,13 +8,7 @@ /**

*/
export declare type TransformableInstruction = Instruction & {
toTx: () => TransactionBuilder;
};
/**
* @category Transactions Util
*/
export declare type BuildOptions = {
latestBlockhash: boolean | {
latestBlockhash: {
blockhash: string;
lastValidBlockHeight: number;
};
} | undefined;
};

@@ -24,6 +19,7 @@ /**

export declare class TransactionBuilder {
private provider;
readonly connection: Connection;
readonly wallet: Wallet;
private instructions;
private signers;
constructor(provider: Provider);
constructor(connection: Connection, wallet: Wallet);
addInstruction(instruction: Instruction): TransactionBuilder;

@@ -53,3 +49,3 @@ addSigner(signer: Signer): TransactionBuilder;

*/
static sendAll(provider: Provider, txns: TransactionBuilder[], opts?: ConfirmOptions): Promise<string[]>;
static sendAll(provider: AnchorProvider, txns: TransactionBuilder[], opts?: ConfirmOptions): Promise<string[]>;
}

@@ -19,4 +19,5 @@ "use strict";

class TransactionBuilder {
constructor(provider) {
this.provider = provider;
constructor(connection, wallet) {
this.connection = connection;
this.wallet = wallet;
this.instructions = [];

@@ -66,21 +67,12 @@ this.signers = [];

*/
// TODO: Anchor 0.24+ removes .wallet from Provider
build(options = { latestBlockhash: false }) {
build(options = { latestBlockhash: undefined }) {
return __awaiter(this, void 0, void 0, function* () {
const { latestBlockhash } = options;
let recentBlockhash;
if (latestBlockhash === true) {
recentBlockhash = (yield this.provider.connection.getLatestBlockhash("singleGossip"))
.blockhash;
}
else if (latestBlockhash !== false && latestBlockhash.blockhash) {
recentBlockhash = latestBlockhash.blockhash;
}
const transaction = new web3_js_1.Transaction({
recentBlockhash,
feePayer: this.provider.wallet.publicKey,
});
let recentBlockhash = !latestBlockhash
? yield this.connection.getLatestBlockhash("singleGossip")
: latestBlockhash;
const transaction = new web3_js_1.Transaction(Object.assign(Object.assign({}, recentBlockhash), { feePayer: this.wallet.publicKey }));
const ix = this.compressIx(true);
transaction.add(...ix.instructions);
transaction.feePayer = this.provider.wallet.publicKey;
transaction.feePayer = this.wallet.publicKey;
return {

@@ -99,3 +91,3 @@ transaction: transaction,

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

@@ -102,0 +94,0 @@ return execute();

@@ -1,8 +0,9 @@

import { Provider } from "@project-serum/anchor";
import { Commitment, Transaction } from "@solana/web3.js";
import { Wallet } from "@project-serum/anchor/dist/cjs/provider";
import { Commitment, Transaction, Connection } from "@solana/web3.js";
import { SendTxRequest } from "./types";
export declare class TransactionProcessor {
readonly provider: Provider;
readonly connection: Connection;
readonly wallet: Wallet;
readonly commitment: Commitment;
constructor(provider: Provider, commitment?: Commitment);
constructor(connection: Connection, wallet: Wallet, commitment?: Commitment);
signTransaction(txRequest: SendTxRequest): Promise<{

@@ -9,0 +10,0 @@ transaction: Transaction;

@@ -20,4 +20,5 @@ "use strict";

class TransactionProcessor {
constructor(provider, commitment = "confirmed") {
this.provider = provider;
constructor(connection, wallet, commitment = "confirmed") {
this.connection = connection;
this.wallet = wallet;
this.commitment = commitment;

@@ -34,8 +35,8 @@ }

// TODO: Neither Solana nor Anchor currently correctly handle latest block height confirmation
const { blockhash, lastValidBlockHeight } = yield this.provider.connection.getLatestBlockhash(this.commitment);
const feePayer = this.provider.wallet.publicKey;
const { blockhash, lastValidBlockHeight } = yield this.connection.getLatestBlockhash(this.commitment);
const feePayer = this.wallet.publicKey;
const pSignedTxs = txRequests.map((txRequest) => {
return rewriteTransaction(txRequest, feePayer, blockhash);
});
const transactions = yield this.provider.wallet.signAllTransactions(pSignedTxs);
const transactions = yield this.wallet.signAllTransactions(pSignedTxs);
return {

@@ -65,5 +66,5 @@ transactions,

// We separate the block expiry promise so that it can be shared for all the transactions
const expiry = checkBlockHeightExpiry(this.provider, lastValidBlockHeight, this.commitment, isDone);
const expiry = checkBlockHeightExpiry(this.connection, lastValidBlockHeight, this.commitment, isDone);
const txs = transactions.map((tx) => tx.serialize());
const txPromises = txs.map((tx) => __awaiter(this, void 0, void 0, function* () { return confirmOrExpire(this.provider, tx, this.commitment, expiry); }));
const txPromises = txs.map((tx) => __awaiter(this, void 0, void 0, function* () { return confirmOrExpire(this.connection, tx, this.commitment, expiry); }));
let results = [];

@@ -123,5 +124,5 @@ if (parallel) {

*/
function confirmOrExpire(provider, tx, commitment, expiry) {
function confirmOrExpire(connection, tx, commitment, expiry) {
return __awaiter(this, void 0, void 0, function* () {
const txId = yield provider.connection.sendRawTransaction(tx, {
const txId = yield connection.sendRawTransaction(tx, {
preflightCommitment: commitment,

@@ -135,3 +136,3 @@ });

try {
subscriptionId = provider.connection.onSignature(txId, () => {
subscriptionId = connection.onSignature(txId, () => {
subscriptionId = undefined;

@@ -157,3 +158,3 @@ resolve(TransactionStatus.CONFIRMED);

if (subscriptionId) {
provider.connection.removeSignatureListener(subscriptionId);
connection.removeSignatureListener(subscriptionId);
}

@@ -163,6 +164,6 @@ }

}
function checkBlockHeightExpiry(provider, lastValidBlockHeight, commitment, isDone) {
function checkBlockHeightExpiry(connection, lastValidBlockHeight, commitment, isDone) {
return __awaiter(this, void 0, void 0, function* () {
while (!isDone()) {
let blockHeight = yield provider.connection.getBlockHeight(commitment);
let blockHeight = yield connection.getBlockHeight(commitment);
if (blockHeight > lastValidBlockHeight) {

@@ -169,0 +170,0 @@ break;

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

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

"dependencies": {
"@project-serum/anchor": "0.20.1",
"@project-serum/anchor": "~0.25.0",
"@solana/spl-token": "0.1.8",

@@ -14,0 +14,0 @@ "decimal.js": "^10.3.1"

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