unrip/src/lib/http.mjs
philipp 41b9ec680b
Some checks failed
deploy / deploy (push) Failing after 1m35s
Implement funded NEAR Intents trade loop
Proof: first non-mocked tradeable loop for one pair using funded NEAR Intents inventory, Kafka, and PostgreSQL.

Assumptions: solver-side execution is performed by signed token_diff quote responses over the Solver Relay; EURe is treated as 1:1 with EUR; k3s runtime uses unrip-dev.near as the named signer account.

Still fake: signer key is not yet registered on intents.near, strategy and executor remain disarmed by default, and no live mainnet quote response has been submitted from this repo yet.
2026-04-02 10:01:15 +02:00

22 lines
543 B
JavaScript

export async function fetchJson(url, options = {}) {
const response = await fetch(url, options);
const text = await response.text();
if (!response.ok) {
throw new Error(`HTTP ${response.status}: ${text.slice(0, 200)}`);
}
return text ? JSON.parse(text) : null;
}
export async function postJson(url, body, { headers = {}, ...options } = {}) {
return fetchJson(url, {
...options,
method: 'POST',
headers: {
'content-type': 'application/json',
...headers,
},
body: JSON.stringify(body),
});
}