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
5
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.0-beta-0 to 0.3.0-beta-1

dist/web3/network/cache/index.d.ts

6

dist/web3/network/account-requests.d.ts

@@ -6,6 +6,6 @@ /// <reference types="node" />

export declare function getParsedAccount<T>(connection: Connection, address: Address, parser: ParsableEntity<T>): Promise<T | null>;
export declare function getMultipleParsedAccounts<T>(connection: Connection, addresses: Address[], parser: ParsableEntity<T>): Promise<(T | null)[]>;
export declare function getMultipleParsedAccounts<T>(connection: Connection, addresses: Address[], parser: ParsableEntity<T>, chunkSize?: number): Promise<(T | null)[]>;
export type FetchedAccountEntry = [PublicKey, AccountInfo<Buffer> | null];
export type FetchedAccountMap = Map<string, AccountInfo<Buffer> | null>;
export declare function getMultipleAccountsInMap(connection: Connection, addresses: Address[], timeoutAfterSeconds?: number): Promise<Readonly<FetchedAccountMap>>;
export declare function getMultipleAccounts(connection: Connection, addresses: Address[], timeoutAfterSeconds?: number): Promise<Readonly<FetchedAccountEntry[]>>;
export declare function getMultipleAccountsInMap(connection: Connection, addresses: Address[], timeoutAfterSeconds?: number, chunkSize?: number): Promise<Readonly<FetchedAccountMap>>;
export declare function getMultipleAccounts(connection: Connection, addresses: Address[], timeoutAfterSeconds?: number, chunkSize?: number): Promise<Readonly<FetchedAccountEntry[]>>;

@@ -15,7 +15,7 @@ "use strict";

exports.getParsedAccount = getParsedAccount;
async function getMultipleParsedAccounts(connection, addresses, parser) {
async function getMultipleParsedAccounts(connection, addresses, parser, chunkSize = 100) {
if (addresses.length === 0) {
return [];
}
const values = await getMultipleAccounts(connection, address_util_1.AddressUtil.toPubKeys(addresses));
const values = await getMultipleAccounts(connection, address_util_1.AddressUtil.toPubKeys(addresses), 10, chunkSize);
const results = values.map((val) => {

@@ -31,4 +31,4 @@ if (val[1] === null) {

exports.getMultipleParsedAccounts = getMultipleParsedAccounts;
async function getMultipleAccountsInMap(connection, addresses, timeoutAfterSeconds = 10) {
const results = await getMultipleAccounts(connection, addresses, timeoutAfterSeconds);
async function getMultipleAccountsInMap(connection, addresses, timeoutAfterSeconds = 10, chunkSize = 100) {
const results = await getMultipleAccounts(connection, addresses, timeoutAfterSeconds, chunkSize);
return results.reduce((map, [key, value]) => {

@@ -40,3 +40,3 @@ map.set(key.toBase58(), value);

exports.getMultipleAccountsInMap = getMultipleAccountsInMap;
async function getMultipleAccounts(connection, addresses, timeoutAfterSeconds = 10) {
async function getMultipleAccounts(connection, addresses, timeoutAfterSeconds = 10, chunkSize = 100) {
if (addresses.length === 0) {

@@ -46,12 +46,13 @@ return [];

const promises = [];
const chunk = 100; // getMultipleAccounts has limitation of 100 accounts per request
const result = [];
for (let i = 0; i < addresses.length; i += chunk) {
const addressChunk = address_util_1.AddressUtil.toPubKeys(addresses.slice(i, i + chunk));
const chunks = Math.ceil(addresses.length / chunkSize);
const result = new Array(chunks);
for (let i = 0; i < result.length; i++) {
const slice = addresses.slice(i * chunkSize, (i + 1) * chunkSize);
const addressChunk = address_util_1.AddressUtil.toPubKeys(slice);
const promise = new Promise(async (resolve) => {
const res = await connection.getMultipleAccountsInfo(addressChunk);
const map = res.map((result, index) => {
const fetchedAccountChunk = res.map((result, index) => {
return [addressChunk[index], result];
});
result.push(...map);
result[i] = fetchedAccountChunk;
resolve();

@@ -65,4 +66,5 @@ });

]);
(0, tiny_invariant_1.default)(result.length === addresses.length, "getMultipleAccounts not enough results");
return result;
const flattenedResult = result.flat();
(0, tiny_invariant_1.default)(flattenedResult.length === addresses.length, "getMultipleAccounts not enough results");
return flattenedResult;
}

@@ -69,0 +71,0 @@ exports.getMultipleAccounts = getMultipleAccounts;

export * from "./account-requests";
export * from "./cache";
export * from "./parsing";

@@ -18,2 +18,3 @@ "use strict";

__exportStar(require("./account-requests"), exports);
__exportStar(require("./cache"), exports);
__exportStar(require("./parsing"), exports);
{
"name": "@orca-so/common-sdk",
"version": "0.3.0-beta-0",
"version": "0.3.0-beta-1",
"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