base-model.js 494 B

123456789101112131415161718192021222324
  1. const http = require("../utils/axios");
  2. module.exports = class BaseModel {
  3. static MODULES = {
  4. HISTORY: 'history',
  5. PENDING: 'pending',
  6. FACTORY: 'factory'
  7. }
  8. constructor(chainId, module) {
  9. if (!chainId || !module) throw "Must have [chainId, module]."
  10. this.chainId = chainId
  11. this.module = module
  12. }
  13. async find() {
  14. const url = `/${this.module}/findByChainId`
  15. const rst = await http.post(url, {
  16. chainId: this.chainId
  17. })
  18. return rst.data
  19. }
  20. }