a0178d28f7
* wasm: mix-fetch: remove harbour master client and use Nym API client * wasm: mix-fetch: fix up internal tester * Release Typescript SDK v1.4.1 * remove bump version tool from workspace * ts-sdk: contract clients: update and re-run autogen * ts: fix linting errors * update go * pin minimatch typings to fix lint errors * bump versions to rc * Update publish-sdk-npm.yml * Update publish-sdk-npm.yml * Update publish-sdk-npm.yml * Update publish-sdk-npm.yml * try disable typedoc because of minimatch errors * bump versions to rc0 * limit packages published to only wasm clients * TS SDK 1.4.1-rc1 * simplify version dependencies and add dist to dev mode * add back version complexity for CI * TS SDK 1.4.1-rc2 * ts-sdk: fix minimatch dependency and correct casing on `selfAddress` function call * wasm: rename `main` to `main_js` to avoid collision errors in exporting main from tests see https://github.com/wasm-bindgen/wasm-bindgen/issues/2206 * improve wasm js tests * TS SDK 1.4.1-rc3 * update example docs * TS SDK 1.4.1 release * update docs dependencies to SDK 1.4.1 * update yarn lock file after TS SDK 1.4.1 publish * Update ci-lint-typescript.yml * Update ci-lint-typescript.yml * Update ci-nym-wallet-storybook.yml * Bump node tester version and add additional yarn install step to fix linting --------- Co-authored-by: Mark Sinclair <mmsinclair@users.noreply.github.com>
87 lines
2.4 KiB
TypeScript
87 lines
2.4 KiB
TypeScript
import React, { useState } from "react";
|
|
import CircularProgress from "@mui/material/CircularProgress";
|
|
import Button from "@mui/material/Button";
|
|
import TextField from "@mui/material/TextField";
|
|
import Typography from "@mui/material/Typography";
|
|
import Box from "@mui/material/Box";
|
|
import { mixFetch } from "@nymproject/mix-fetch-full-fat";
|
|
import Stack from "@mui/material/Stack";
|
|
import Paper from "@mui/material/Paper";
|
|
import type { SetupMixFetchOps } from "@nymproject/mix-fetch-full-fat";
|
|
|
|
const defaultUrl = "https://nymtech.net/.wellknown/network-requester/exit-policy.txt";
|
|
const args = { mode: "unsafe-ignore-cors" };
|
|
|
|
const mixFetchOptions: SetupMixFetchOps = {
|
|
preferredGateway: "2xU4CBE6QiiYt6EyBXSALwxkNvM7gqJfjHXaMkjiFmYW", // with WSS
|
|
// preferredNetworkRequester:
|
|
// "CTDxrcXgrZHWyCWnuCgjpJPghQUcEVz1HkhUr5mGdFnT.3UAww1YWNyVNYNWFQL1LaHYouQtDiXBGK5GiDZgpXkTK@2RFtU5BwxvJJXagAWAEuaPgb5ZVPRoy2542TT93Edw6v",
|
|
mixFetchOverride: {
|
|
requestTimeoutMs: 60_000,
|
|
},
|
|
forceTls: true, // force WSS
|
|
};
|
|
|
|
export const MixFetch = () => {
|
|
const [url, setUrl] = useState<string>(defaultUrl);
|
|
const [html, setHtml] = useState<string>();
|
|
const [busy, setBusy] = useState<boolean>(false);
|
|
|
|
const handleFetch = async () => {
|
|
try {
|
|
setBusy(true);
|
|
setHtml(undefined);
|
|
const response = await mixFetch(url, args, mixFetchOptions);
|
|
console.log(response);
|
|
const resHtml = await response.text();
|
|
setHtml(resHtml);
|
|
} catch (err) {
|
|
console.log(err);
|
|
} finally {
|
|
setBusy(false);
|
|
}
|
|
};
|
|
|
|
return (
|
|
<div style={{ marginTop: "1rem" }}>
|
|
<Stack direction="row">
|
|
<TextField
|
|
disabled={busy}
|
|
fullWidth
|
|
label="URL"
|
|
type="text"
|
|
variant="outlined"
|
|
defaultValue={defaultUrl}
|
|
onChange={(e) => setUrl(e.target.value)}
|
|
/>
|
|
<Button
|
|
variant="outlined"
|
|
disabled={busy}
|
|
sx={{ marginLeft: "1rem" }}
|
|
onClick={handleFetch}
|
|
>
|
|
Fetch
|
|
</Button>
|
|
</Stack>
|
|
|
|
{busy && (
|
|
<Box mt={4}>
|
|
<CircularProgress />
|
|
</Box>
|
|
)}
|
|
{html && (
|
|
<>
|
|
<Box mt={4}>
|
|
<strong>Response</strong>
|
|
</Box>
|
|
<Paper sx={{ p: 2, mt: 1 }} elevation={4}>
|
|
<Typography fontFamily="monospace" fontSize="small">
|
|
{html}
|
|
</Typography>
|
|
</Paper>
|
|
</>
|
|
)}
|
|
</div>
|
|
);
|
|
};
|