import * as _ from "lodash" ; import { signEcdsa } from "../../utils" ; import { H256 } from "../classes" ; import { Transaction } from "../Transaction" ; import { NetworkId } from "../types" ; export interface RemoveActionJSON { hash : string ; signature : string ; } export class Remove extends Transaction { private readonly _hash : H256 ; private readonly signature : string ; public constructor ( params , networkId ) { super ( networkId ) ; if ( "secret" in params ) { const { hash , secret } = params ; this . _hash = hash ; this . signature = signEcdsa ( hash . value , secret . value ) ; } else { let signature = params . signature ; if ( signature . startsWith ( "0x" ) ) { signature = signature . substr ( 2 ) ; } this . _hash = params . hash ; this . signature = signature ; } } public type ( ) { return "remove" ; } protected actionToEncodeObject ( ) { const { _hash , signature } = this ; return [ 9 , _hash . toEncodeObject ( ) , `0x${ signature }` ] ; } protected actionToJSON ( ) { const { _hash , signature } = this ; return { hash : _hash . toEncodeObject ( ) , signature : `0x${ signature }` } ; } }