sendResponse(id, result) {
    let originId = this.idMapping.tryPopId(id) || id;
    let callback = this.callbacks.get(id);
    let wrapResult = this.wrapResults.get(id);
    let data = { jsonrpc: "2.0", id: originId };
    if (typeof result === "object" && result.jsonrpc && result.result) {
      data.result = result.result;
    } else {
      data.result = result;
    }
    if (this.isDebug) {
      console.log(
        `<== sendResponse id: ${id}, result: ${JSON.stringify(
          result
        )}, data: ${JSON.stringify(data)}`
      );
    }
    if (callback) {
      wrapResult ? callback(null, data) : callback(null, result);
      this.callbacks.delete(id);
    } else {
      console.log(`callback id: ${id} not found`);
      // check if it's iframe callback
      for (var i = 0; i < window.frames.length; i++) {
        const frame = window.frames[i];
        try {
          if (frame.ethereum.callbacks.has(id)) {
            frame.ethereum.sendResponse(id, result);
          }
        } catch (error) {
          console.log(`send response to frame error: ${error}`);
        }
      }
    }
  }
/**
   * @private Internal native result -> js
   */
@private Internal native result -> js
@private Internal native result - > js
sendResponse(id, result) {
    let originId = this.idMapping.tryPopId(id) || id;
    let callback = this.callbacks.get(id);
    let wrapResult = this.wrapResults.get(id);
    let data = { jsonrpc: "2.0", id: originId };
    if (typeof result === "object" && result.jsonrpc && result.result) {
      data.result = result.result;
    } else {
      data.result = result;
    }
    if (this.isDebug) {
      console.log(
        `<== sendResponse id: ${id}, result: ${JSON.stringify(
          result
        )}, data: ${JSON.stringify(data)}`
      );
    }
    if (callback) {
      wrapResult ? callback(null, data) : callback(null, result);
      this.callbacks.delete(id);
    } else {
      console.log(`callback id: ${id} not found`);
      for (var i = 0; i < window.frames.length; i++) {
        const frame = window.frames[i];
        try {
          if (frame.ethereum.callbacks.has(id)) {
            frame.ethereum.sendResponse(id, result);
          }
        } catch (error) {
          console.log(`send response to frame error: ${error}`);
        }
      }
    }
  }
sendResponse ( id , result ) { let originId = this . idMapping . tryPopId ( id ) || id ; let callback = this . callbacks . get ( id ) ; let wrapResult = this . wrapResults . get ( id ) ; let data = { jsonrpc : "2.0" , id : originId } ; if ( typeof result === "object" && result . jsonrpc && result . result ) { data . result = result . result ; } else { data . result = result ; } if ( this . isDebug ) { console . log ( ` ${ id } ${ JSON . stringify ( result ) } ${ JSON . stringify ( data ) } ` ) ; } if ( callback ) { wrapResult ? callback ( null , data ) : callback ( null , result ) ; this . callbacks . delete ( id ) ; } else { console . log ( ` ${ id } ` ) ; for ( var i = 0 ; i < window . frames . length ; i ++ ) { const frame = window . frames [ i ] ; try { if ( frame . ethereum . callbacks . has ( id ) ) { frame . ethereum . sendResponse ( id , result ) ; } } catch ( error ) { console . log ( ` ${ error } ` ) ; } } } }
@private Internal native result -> js
@private Internal native result - > js
// check if it's iframe callback