1
0
Fork 0

Use the database cache for mining and contracting automations

This commit is contained in:
Julien Dessaux 2023-06-12 23:40:07 +02:00
parent e18c5b1fdf
commit 28b3a695dc
Signed by: adyxax
GPG key ID: F92E51B86E07177E
3 changed files with 25 additions and 13 deletions

View file

@ -1,4 +1,5 @@
import * as api from './api.js';
import * as dbShips from '../database/ships.js';
export async function accept(ctx) {
return await api.send({endpoint: `/my/contracts/${ctx.contract}/accept`, method: 'POST'});
@ -9,11 +10,15 @@ export async function contracts() {
}
export async function deliver(ctx) {
return await api.send({ endpoint: `/my/contracts/${ctx.contract}/deliver`, method: 'POST', payload: {
const response = await api.send({ endpoint: `/my/contracts/${ctx.contract}/deliver`, method: 'POST', payload: {
shipSymbol: ctx.symbol,
tradeSymbol: ctx.good,
units: ctx.units,
}});
if (response.error !== undefined) {
throw response;
}
dbShips.setShipCargo(ctx.symbol, response.data.cargo);
}
export async function fulfill(ctx) {