import type { Idl } from "@project-serum/anchor" ; import { Program } from "@project-serum/anchor" ; import type { Provider as SaberProvider } from "@saberhq/solana-contrib" ; import type { PublicKey } from "@solana/web3.js" ; import mapValues from "lodash.mapvalues" ; import { makeAnchorProvider } from "./provider" ; param idl param address param provider returns export const newProgram = < P > ( idl , address , provider ) => { return new Program ( idl , address . toString ( ) , makeAnchorProvider ( provider ) ) as unknown as P ; } ; param provider param programs returns export const newProgramMap = < P > ( provider , idls , addresses ) : { [ K in keyof P ] : P [ K ] ; } => { return mapValues ( idls , ( idl , k ) => newProgram ( idl , addresses [ k ] , provider ) ) as unknown as { [ K in keyof P ] : P [ K ] ; } ; } ;