-
Notifications
You must be signed in to change notification settings - Fork 208
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(a3p): update makeVStorage according to batchQuery.js
rel: #10574
- Loading branch information
1 parent
d8a109e
commit b8c0f7d
Showing
2 changed files
with
133 additions
and
111 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
a3p-integration/proposals/z:acceptance/test-lib/makeHttpClient.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import { assert } from '@endo/errors'; | ||
import { Far } from '@endo/far'; | ||
|
||
/** | ||
* 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 {string} apiAddress nodes default to port 1317 | ||
* @param {object} io | ||
* @param {typeof fetch} io.fetch | ||
*/ | ||
export const makeAPI = (apiAddress, { fetch }) => { | ||
assert.typeof(apiAddress, 'string'); | ||
|
||
/** | ||
* @param {string} href | ||
* @param {object} [options] | ||
* @param {Record<string, string>} [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 Far('LCD', { | ||
getJSON, | ||
latestBlock: () => getJSON(`/cosmos/base/tendermint/v1beta1/blocks/latest`), | ||
}); | ||
}; | ||
/** @typedef {ReturnType<typeof makeAPI>} LCD */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters