import { State } from '../../state' ; import { getContractMaterial , VtxContract } from '../VtxContract' ; import { address_checker } from '../../utils/address_checker' ; import { is_alias } from '../../utils/is_alias' ; import { Store } from 'redux' ; description param state export const getContractsSpecList = ( state ) : string [ ] => Object . keys ( state . contracts . specs ) . filter ( ( key ) => state . contracts . specs [ key ] !== undefined ) ; description param store param contract_name param address_or_alias export const getContract = ( store , contract_name , address_or_alias ) : VtxContract => { try { address_or_alias = address_checker ( address_or_alias ) ; } catch ( e ) { throw new Error ( `Invalid provided address or alias: ${ address_or_alias }` ) ; } const state = store . getState ( ) ; if ( is_alias ( address_or_alias ) ) { try { address_or_alias = state . contracts . alias [ contract_name ] [ address_or_alias ] . address ; } catch ( e ) { return undefined ; } } if ( ! state . contracts . specs [ contract_name ] ) return undefined ; if ( ! state . contracts . instances [ contract_name ] || ! state . contracts . instances [ contract_name ] [ address_or_alias ] ) return undefined ; const web3_instance = store . getState ( ) . contracts . instances [ contract_name ] [ address_or_alias ] . web3_instance ; return new VtxContract ( store . dispatch , getContractMaterial ( store . getState ( ) , contract_name , address_or_alias ) , web3_instance , contract_name , address_or_alias , state . contracts . specs [ contract_name ] . abi , state . contracts . specs [ contract_name ] . bin , state . contracts . specs [ contract_name ] . constructor_bin ) ; } ; interface ContractList { [ key ] : string [ ] ; } description param state export const getContractList = ( state ) : ContractList => { const ret = { } ; for ( const contract of Object . keys ( state . contracts . instances ) ) { ret [ contract ] = Object . keys ( state . contracts . instances [ contract ] ) ; } return ret ; } ;