UNPKG

@saberhq/sail

Version:

Account caching and batched loading for React-based Solana applications.

29 lines 884 B
import { mapSome } from "@saberhq/solana-contrib"; import { PublicKey } from "@solana/web3.js"; import uniq from "lodash.uniq"; export * from "./falsy"; export * from "./fetchNullable"; export const accountsEqual = (a, b) => { if (a && b) { return a.accountInfo.data.equals(b.accountInfo.data); } return false; }; export const serializeKeys = (keys) => { return keys.map((k) => (k ? k.toString() : k)); }; /** * Generates a list of unique {@link PublicKey}s. * @param keys * @returns */ export const uniqKeys = (keys) => uniq(keys.map((key) => key.toString())).map((key) => new PublicKey(key)); /** * Makes a memo key for a list of strings. * @param list * @returns */ export const makeListMemoKey = (list) => { return mapSome(list, (ms) => JSON.stringify(ms.map((mint) => mapSome(mint, (m) => m.toString())))); }; //# sourceMappingURL=index.js.map