bloxroute
Version:
Package for connecting to Bloxroute's gateways
66 lines (65 loc) • 1.66 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Filter = void 0;
class Filter {
constructor() {
this._filter = '';
this._valid = false;
}
build() {
if (!this._valid)
throw new Error('Invalid filter');
return this._filter;
}
to(address) {
this._filter += `({to} =='${address}')`;
this._valid = true;
return this;
}
toIn(addresses) {
this._filter += `({to} IN ${JSON.stringify(addresses)})`;
this._valid = true;
return this;
}
from(address) {
this._filter += `({from} == '${address}')`;
this._valid = true;
return this;
}
fromIn(addresses) {
this._filter += `({from} in ${JSON.stringify(addresses)})`;
this._valid = true;
return this;
}
method(methodId) {
this._filter += `({method_id} == '${methodId}')`;
this._valid = true;
return this;
}
methodIn(methodIds) {
this._filter += `({method_id} in ${JSON.stringify(methodIds)})`;
this._valid = true;
return this;
}
gasPriceGt(gasPrice) {
this._filter += `({gas_price} > ${gasPrice})`;
this._valid = true;
return this;
}
gasPriceLt(gasPrice) {
this._filter += `({gas_price} < ${gasPrice})`;
this._valid = true;
return this;
}
get and() {
this._filter += ` AND `;
this._valid = false;
return this;
}
get or() {
this._filter += ` OR `;
this._valid = false;
return this;
}
}
exports.Filter = Filter;