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-3 to 0.3.0

1

dist/web3/network/fetcher/simple-fetcher-impl.d.ts

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

getAccount<U extends T>(address: Address, parser: ParsableEntity<U>, opts?: FetchOptions | undefined, now?: number): Promise<U | null>;
private getMaxAge;
getAccounts<U extends T>(addresses: Address[], parser: ParsableEntity<U>, opts?: SimpleAccountFetchOptions | undefined, now?: number): Promise<ReadonlyMap<string, U | null>>;

@@ -25,0 +26,0 @@ getAccountsAsArray<U extends T>(addresses: Address[], parser: ParsableEntity<U>, opts?: FetchOptions | undefined, now?: number): Promise<ReadonlyArray<U | null>>;

18

dist/web3/network/fetcher/simple-fetcher-impl.js

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

const account_requests_1 = require("../account-requests");
// SimpleAccountCache is a simple implementation of AccountCache that stores the fetched
// SimpleAccountFetcher is a simple implementation of AccountCache that stores the fetched
// accounts in memory. If TTL is not provided, it will use TTL defined in the the retention policy

@@ -21,3 +21,3 @@ // for the parser. If that is also not provided, the request will always prefer the cache value.

const cached = this.cache.get(addressStr);
const maxAge = opts?.maxAge ?? this.retentionPolicy.get(parser) ?? Number.POSITIVE_INFINITY;
const maxAge = this.getMaxAge(this.retentionPolicy.get(parser), opts);
const elapsed = !!cached ? now - (cached?.fetchedAt ?? 0) : Number.NEGATIVE_INFINITY;

@@ -39,2 +39,8 @@ const expired = elapsed > maxAge;

}
getMaxAge(parserMaxAge, opts) {
if (opts?.maxAge !== undefined) {
return opts.maxAge;
}
return parserMaxAge === undefined ? Number.POSITIVE_INFINITY : parserMaxAge;
}
async getAccounts(addresses, parser, opts, now = Date.now()) {

@@ -50,3 +56,2 @@ const addressStrs = address_util_1.AddressUtil.toStrings(addresses);

});
// invariant(result.size === addresses.length, "not enough results fetched");
return result;

@@ -78,7 +83,7 @@ }

const addressStrs = address_util_1.AddressUtil.toStrings(addresses);
const maxAge = opts?.maxAge ?? this.retentionPolicy.get(parser) ?? Number.POSITIVE_INFINITY;
const maxAge = this.getMaxAge(this.retentionPolicy.get(parser), opts);
// Filter out all unexpired accounts to get the accounts to fetch
const undefinedAccounts = addressStrs.filter((addressStr) => {
const cached = this.cache.get(addressStr);
const elapsed = cached ? now - (cached?.fetchedAt ?? 0) : Number.NEGATIVE_INFINITY;
const elapsed = !!cached ? now - (cached?.fetchedAt ?? 0) : Number.NEGATIVE_INFINITY;
const expired = elapsed > maxAge;

@@ -88,2 +93,5 @@ return !cached || expired;

// Fetch all undefined accounts and place in cache
// TODO: We currently do not support contextSlot consistency across the batched getMultipleAccounts call
// If the addresses list contain accounts in the 1st gMA call as subsequent calls and the gMA returns on different contextSlots,
// the returned results can be inconsistent and unexpected by the user.
if (undefinedAccounts.length > 0) {

@@ -90,0 +98,0 @@ const fetchedAccountsMap = await (0, account_requests_1.getMultipleAccountsInMap)(this.connection, undefinedAccounts);

{
"name": "@orca-so/common-sdk",
"version": "0.3.0-beta-3",
"version": "0.3.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