From 60fc0b942c2ec8126508912ee94887f46337a00a Mon Sep 17 00:00:00 2001 From: Dan Connolly Date: Tue, 21 Jan 2025 14:27:29 -0600 Subject: [PATCH] fixup! feat(client-utils): makeAPI --- packages/client-utils/src/grpc-rest-api.js | 44 ---------------------- 1 file changed, 44 deletions(-) delete mode 100644 packages/client-utils/src/grpc-rest-api.js diff --git a/packages/client-utils/src/grpc-rest-api.js b/packages/client-utils/src/grpc-rest-api.js deleted file mode 100644 index bccdf32c19b..00000000000 --- a/packages/client-utils/src/grpc-rest-api.js +++ /dev/null @@ -1,44 +0,0 @@ -const { freeze } = Object; - -// XXX makeVStorage could / should be layered on this - -/** - * gRPC-gateway REST API access - * - * @see {@link https://docs.cosmos.network/v0.45/core/grpc_rest.html#rest-server Cosmos SDK REST Server} - * - * Note: avoid Legacy REST routes, per - * {@link https://docs.cosmos.network/v0.45/migrations/rest.html Cosmos SDK REST Endpoints Migration}. - * - * @param {object} io - * @param {typeof fetch} io.fetch - * @param {string} apiAddress nodes default to port 1317 - */ -export const makeAPI = ({ fetch }, apiAddress = 'http://localhost:1317') => { - /** - * @param {string} href - * @param {object} [options] - * @param {Record} [options.headers] - */ - const getJSON = (href, options = {}) => { - const opts = { - keepalive: true, - headers: { - 'Content-Type': 'application/json', - ...options.headers, - }, - }; - const url = `${apiAddress}${href}`; - return fetch(url, opts).then(r => { - if (!r.ok) throw Error(r.statusText); - return r.json().then(data => { - return data; - }); - }); - }; - - return freeze({ - getJSON, - }); -}; -/** @typedef {ReturnType} CosmosAPI */