import { getConnection , getMongoManager } from 'typeorm' ; import { injectable } from 'inversify' ; import { RegisteredToken } from '../../entities/registered.token' ; export enum RegisteredTokenScope { Local = '' , Global = 'global' } /**
 *
 */ export interface RegisteredTokenRepositoryInterface { save ( tx ) : Promise < RegisteredToken > ; getAllByScope ( scope ? ) : Promise < RegisteredToken [ ] > ; getByContractAddress ( address ) : Promise < RegisteredToken > ; } /**
 *
 */ @ injectable ( ) export class RegisteredTokenRepository implements RegisteredTokenRepositoryInterface { param tx save ( tx ) { return getConnection ( ) . getMongoRepository ( RegisteredToken ) . save ( tx ) ; } getAllByScope ( scope ? ) { return getConnection ( ) . getMongoRepository ( RegisteredToken ) . createCursor ( { scope : scope || RegisteredTokenScope . Local } ) . sort ( 'symbol' , 1 ) . toArray ( ) ; } getByContractAddress ( contractAddress ) { return getConnection ( ) . getMongoRepository ( RegisteredToken ) . findOne ( { contractAddress } ) ; } } const RegisteredTokenRepositoryType = Symbol ( 'RegisteredTokenRepositoryInterface' ) ; export { RegisteredTokenRepositoryType } ;