import { keyStores , ConnectConfig , KeyPair } from 'near-api-js' ; import { InMemoryKeyStore } from 'near-api-js/lib/key_stores' ; export const configFromNetwork = ( network ) : ConnectConfig => { const nodeUrl = network === 'Datahub' ? `${ process . env . NEAR_DATAHUB_URL }/apikey/${ process . env . DATAHUB_NEAR_API_KEY }` : 'https://rpc.testnet.near.org' ; const keyStore = new keyStores . InMemoryKeyStore ( ) ; const config = { keyStore , nodeUrl , networkId : 'testnet' , walletUrl : 'https://wallet.testnet.near.org' , helperUrl : 'https://helper.testnet.near.org' , explorerUrl : 'https://explorer.testnet.near.org' , } ; return config ; } ; export const transactionUrl = ( hash ) => `https://explorer.testnet.near.org/transactions/${ hash }` ; export const accountExplorer = ( network ) => ( address ) => `https://explorer.testnet.near.org/accounts/${ address }` ; export const getPrettyPublicKey = ( secretKey ) => KeyPair . fromString ( secretKey ) . getPublicKey ( ) . toString ( ) . slice ( 8 ) ; export const getPublicKey = ( secretKey ) => KeyPair . fromString ( secretKey ) . getPublicKey ( ) . toString ( ) ;