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
6
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.3.5 to 0.3.6-beta.0

2

dist/web3/ata-util.js

@@ -44,3 +44,3 @@ "use strict";

*/
async function resolveOrCreateATAs(connection, ownerAddress, requests, getAccountRentExempt, payer = ownerAddress, modeIdempotent = false, allowPDAOwnerAddress = false, wrappedSolAccountCreateMethod = "keypair") {
async function resolveOrCreateATAs(connection, ownerAddress, requests, getAccountRentExempt, payer = ownerAddress, modeIdempotent = false, allowPDAOwnerAddress = false, wrappedSolAccountCreateMethod = "ata") {
const nonNativeMints = requests.filter(({ tokenMint }) => !tokenMint.equals(spl_token_1.NATIVE_MINT));

@@ -47,0 +47,0 @@ const nativeMints = requests.filter(({ tokenMint }) => tokenMint.equals(spl_token_1.NATIVE_MINT));

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

*/
export type WrappedSolAccountCreateMethod = "keypair" | "withSeed";
export type WrappedSolAccountCreateMethod = "keypair" | "withSeed" | "ata";
/**

@@ -16,0 +16,0 @@ * @category Util

@@ -30,8 +30,15 @@ "use strict";

*/
static createWrappedNativeAccountInstruction(owner, amountIn, rentExemptLamports, payer, unwrapDestination, createAccountMethod = "keypair") {
static createWrappedNativeAccountInstruction(owner, amountIn, rentExemptLamports, payer, unwrapDestination, createAccountMethod = "ata") {
const payerKey = payer ?? owner;
const unwrapDestinationKey = unwrapDestination ?? payer ?? owner;
return createAccountMethod === "keypair"
? createWrappedNativeAccountInstructionWithKeypair(owner, amountIn, rentExemptLamports, payerKey, unwrapDestinationKey)
: createWrappedNativeAccountInstructionWithSeed(owner, amountIn, rentExemptLamports, payerKey, unwrapDestinationKey);
switch (createAccountMethod) {
case "ata":
return createWrappedNativeAccountInstructionWithATA(owner, amountIn, rentExemptLamports, payerKey, unwrapDestinationKey);
case "keypair":
return createWrappedNativeAccountInstructionWithKeypair(owner, amountIn, rentExemptLamports, payerKey, unwrapDestinationKey);
case "withSeed":
return createWrappedNativeAccountInstructionWithSeed(owner, amountIn, rentExemptLamports, payerKey, unwrapDestinationKey);
default:
throw new Error(`Invalid createAccountMethod: ${createAccountMethod}`);
}
}

@@ -80,2 +87,25 @@ /**

exports.TokenUtil = TokenUtil;
function createWrappedNativeAccountInstructionWithATA(owner, amountIn, _rentExemptLamports, payerKey, unwrapDestinationKey) {
const tempAccount = (0, spl_token_1.getAssociatedTokenAddressSync)(spl_token_1.NATIVE_MINT, owner);
const instructions = [];
const createAccountInstruction = (0, spl_token_1.createAssociatedTokenAccountIdempotentInstruction)(payerKey, tempAccount, owner, spl_token_1.NATIVE_MINT);
instructions.push(createAccountInstruction);
if (amountIn.gt(math_1.ZERO)) {
const transferInstruction = web3_js_1.SystemProgram.transfer({
fromPubkey: payerKey,
toPubkey: tempAccount,
lamports: amountIn.toNumber(),
});
instructions.push(transferInstruction);
const syncNativeInstruction = (0, spl_token_1.createSyncNativeInstruction)(tempAccount);
instructions.push(syncNativeInstruction);
}
const closeWSOLAccountInstruction = (0, spl_token_1.createCloseAccountInstruction)(tempAccount, unwrapDestinationKey, owner);
return {
address: tempAccount,
instructions,
cleanupInstructions: [closeWSOLAccountInstruction],
signers: [],
};
}
function createWrappedNativeAccountInstructionWithKeypair(owner, amountIn, rentExemptLamports, payerKey, unwrapDestinationKey) {

@@ -82,0 +112,0 @@ const tempAccount = new web3_js_1.Keypair();

{
"name": "@orca-so/common-sdk",
"version": "0.3.5",
"version": "0.3.6-beta.0",
"description": "Common Typescript components across Orca",

@@ -5,0 +5,0 @@ "repository": "https://github.com/orca-so/orca-sdks",

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