Skip to content

Commit

Permalink
chore: remove Max transcript size and refactor to use constants (#106)
Browse files Browse the repository at this point in the history
* chore: refactor to use constants

* chore: remove stale max_transcript_size

closes #105
  • Loading branch information
heeckhau authored Oct 8, 2024
1 parent d47cf0d commit 3d5e3ce
Show file tree
Hide file tree
Showing 8 changed files with 6 additions and 25 deletions.
10 changes: 0 additions & 10 deletions src/entries/Background/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,6 @@ export type RequestHistory = {
method: string;
headers: { [key: string]: string };
body?: string;
maxTranscriptSize: number;
maxSentData: number;
maxRecvData: number;
notaryUrl: string;
Expand Down Expand Up @@ -328,7 +327,6 @@ async function handleProveRequestStart(
method,
headers,
body,
maxTranscriptSize,
maxSentData,
maxRecvData,
notaryUrl,
Expand All @@ -344,7 +342,6 @@ async function handleProveRequestStart(
body,
maxSentData,
maxRecvData,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,
secretHeaders,
Expand All @@ -369,7 +366,6 @@ async function handleProveRequestStart(
method,
headers,
body,
maxTranscriptSize,
maxSentData,
maxRecvData,
notaryUrl,
Expand Down Expand Up @@ -399,14 +395,12 @@ async function runPluginProver(request: BackgroundAction, now = Date.now()) {
const websocketProxyUrl = _websocketProxyUrl || (await getProxyApi());
const maxSentData = _maxSentData || (await getMaxSent());
const maxRecvData = _maxRecvData || (await getMaxRecv());
const maxTranscriptSize = 16384;

const { id } = await addNotaryRequest(now, {
url,
method,
headers,
body,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,
maxRecvData,
Expand All @@ -433,7 +427,6 @@ async function runPluginProver(request: BackgroundAction, now = Date.now()) {
method,
headers,
body,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,
maxRecvData,
Expand Down Expand Up @@ -808,7 +801,6 @@ async function handleNotarizeRequest(request: BackgroundAction) {
body,
maxSentData = await getMaxSent(),
maxRecvData = await getMaxRecv(),
maxTranscriptSize,
notaryUrl = await getNotaryApi(),
websocketProxyUrl = await getProxyApi(),
origin,
Expand All @@ -823,7 +815,6 @@ async function handleNotarizeRequest(request: BackgroundAction) {
body,
maxSentData,
maxRecvData,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,
metadata,
Expand Down Expand Up @@ -866,7 +857,6 @@ async function handleNotarizeRequest(request: BackgroundAction) {
method,
headers,
body,
maxTranscriptSize,
maxSentData,
maxRecvData,
notaryUrl,
Expand Down
2 changes: 0 additions & 2 deletions src/entries/Content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ class TLSN {
websocketProxyUrl?: string;
maxSentData?: number;
maxRecvData?: number;
maxTranscriptSize?: number;
metadata?: {
[k: string]: string;
};
Expand All @@ -60,7 +59,6 @@ class TLSN {
body: requestOptions?.body,
maxSentData: proofOptions?.maxSentData,
maxRecvData: proofOptions?.maxRecvData,
maxTranscriptSize: proofOptions?.maxTranscriptSize,
notaryUrl: proofOptions?.notaryUrl,
websocketProxyUrl: proofOptions?.websocketProxyUrl,
metadata: proofOptions?.metadata,
Expand Down
3 changes: 0 additions & 3 deletions src/entries/Content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ import { urlify } from '../../utils/misc';
websocketProxyUrl?: string;
maxSentData?: number;
maxRecvData?: number;
maxTranscriptSize?: number;
}>,
) => {
const {
Expand All @@ -94,7 +93,6 @@ import { urlify } from '../../utils/misc';
body,
maxSentData,
maxRecvData,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,
metadata,
Expand All @@ -112,7 +110,6 @@ import { urlify } from '../../utils/misc';
body,
maxSentData,
maxRecvData,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,
metadata,
Expand Down
3 changes: 0 additions & 3 deletions src/pages/Notarize/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@ import {
} from '../../utils/storage';
import { useDispatch } from 'react-redux';

const maxTranscriptSize = 16384;

export default function Notarize(): ReactElement {
const params = useParams<{ requestId: string }>();
const req = useRequest(params.requestId);
Expand Down Expand Up @@ -58,7 +56,6 @@ export default function Notarize(): ReactElement {
body: req.requestBody,
maxSentData,
maxRecvData,
maxTranscriptSize,
notaryUrl,
websocketProxyUrl,
secretHeaders,
Expand Down
1 change: 0 additions & 1 deletion src/pages/RequestBuilder/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,6 @@ export default function RequestBuilder(props?: {
maxRecvData,
secretHeaders: [],
secretResps: [],
maxTranscriptSize: 0,
notaryUrl,
websocketProxyUrl,
},
Expand Down
1 change: 0 additions & 1 deletion src/reducers/requests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ export const notarizeRequest = (options: RequestHistory) => async () => {
method: options.method,
headers: options.headers,
body: options.body,
maxTranscriptSize: options.maxTranscriptSize,
maxSentData,
maxRecvData,
secretHeaders: options.secretHeaders,
Expand Down
2 changes: 1 addition & 1 deletion src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const EXPLORER_API = 'https://explorer.tlsnotary.org';
export const NOTARY_API = 'https://notary.pse.dev/v0.1.0-alpha.5';
export const NOTARY_API = 'https://notary.pse.dev/v0.1.0-alpha.7';
export const NOTARY_PROXY = 'wss://notary.pse.dev/proxy';
export const MAX_RECV = 16384;
export const MAX_SENT = 4096;
9 changes: 5 additions & 4 deletions src/utils/storage.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { LoggingLevel } from 'tlsn-js';
import { MAX_RECV, MAX_SENT, NOTARY_API, NOTARY_PROXY } from './constants';

export const NOTARY_API_LS_KEY = 'notary-api';
export const PROXY_API_LS_KEY = 'proxy-api';
Expand All @@ -18,19 +19,19 @@ export async function get(key: string, defaultValue?: string) {
}

export async function getMaxSent() {
return parseInt(await get(MAX_SENT_LS_KEY, '4096'));
return parseInt(await get(MAX_SENT_LS_KEY, MAX_SENT.toString()));
}

export async function getMaxRecv() {
return parseInt(await get(MAX_RECEIVED_LS_KEY, '16384'));
return parseInt(await get(MAX_RECEIVED_LS_KEY, MAX_RECV.toString()));
}

export async function getNotaryApi() {
return await get(NOTARY_API_LS_KEY, 'https://notary.pse.dev/v0.1.0-alpha.7');
return await get(NOTARY_API_LS_KEY, NOTARY_API);
}

export async function getProxyApi() {
return await get(PROXY_API_LS_KEY, 'wss://notary.pse.dev/proxy');
return await get(PROXY_API_LS_KEY, NOTARY_PROXY);
}

export async function getLoggingFilter(): Promise<LoggingLevel> {
Expand Down

0 comments on commit 3d5e3ce

Please sign in to comment.