import { LocalTerra , RawKey , Wallet } from "@terra-money/terra.js" ; import { ContractConfig , ContractRef , loadConfig , loadConnections , loadKeys , loadRefs , } from "../config" ; import { LCDClientExtra } from "./LCDClientExtra" ; import * as R from "ramda" ; export type Env = { config : ( contract : string ) => ContractConfig ; refs : { [ contractName ] : ContractRef ; } ; wallets : { [ key ] : Wallet ; } ; client : LCDClientExtra ; } ; export const getEnv = ( configPath , keysPath , refsPath , network ) : Env => { const connections = loadConnections ( configPath ) ; const config = loadConfig ( configPath ) ; const keys = loadKeys ( keysPath ) ; const refs = loadRefs ( refsPath ) [ network ] ; const lcd = new LCDClientExtra ( connections ( network ) , refs ) ; const userDefinedWallets = R . map < { [ k ] : RawKey ; } , { [ k ] : Wallet ; } > ( ( k ) => new Wallet ( lcd , k ) , keys ) ; return { config : ( contract ) => config ( network , contract ) , refs , wallets : { ... new LocalTerra ( ) . wallets , ... userDefinedWallets , } , client : lcd , } ; } ;