base-model.js 703 B

12345678910111213141516171819202122232425262728293031323334
  1. const http = require("../utils/axios");
  2. module.exports = class BaseModel {
  3. static MODULES = {
  4. HISTORY: 'history',
  5. PENDING: 'pending',
  6. FACTORY: 'factory',
  7. TOKEN: 'token',
  8. V2_LP: 'v2-lp',
  9. V3_LP: 'v3-lp'
  10. }
  11. constructor(chainId, module) {
  12. if (!chainId || !module) throw "Must have [chainId, module]."
  13. this.chainId = chainId
  14. this.module = module
  15. }
  16. async find() {
  17. const url = `/${this.module}/findByChainId`
  18. const rst = await http.post(url, {
  19. chainId: this.chainId
  20. })
  21. return rst.data
  22. }
  23. async appendOrUpdate(data) {
  24. const url = `/${this.module}/appendOrUpdate`
  25. const rst = await http.post(url, data)
  26. return rst.data
  27. }
  28. }