mirror of
https://github.com/tlsnotary/tlsn-plugin-demo.git
synced 2026-01-08 04:54:07 -05:00
52 lines
944 B
TypeScript
52 lines
944 B
TypeScript
import { Attestation, AttestedData } from '../utils/types';
|
|
|
|
enum ActionType {
|
|
SET_ATTESTATION = 'attestation/SET_ATTESTATION',
|
|
}
|
|
|
|
export type Action<payload = any> = {
|
|
type: ActionType;
|
|
payload: payload;
|
|
error?: boolean;
|
|
meta?: any;
|
|
};
|
|
|
|
type AttestationData = {
|
|
raw: Attestation;
|
|
};
|
|
|
|
export type State = {
|
|
raw: Attestation;
|
|
};
|
|
|
|
export const initState: State = {
|
|
raw: {
|
|
version: '0.1.0-alpha.12',
|
|
data: '',
|
|
meta: {
|
|
notaryUrl: '',
|
|
websocketProxyUrl: '',
|
|
pluginUrl: '',
|
|
},
|
|
},
|
|
};
|
|
|
|
export const setAttestation = (
|
|
attestation: AttestationData,
|
|
): Action<AttestationData> => ({
|
|
type: ActionType.SET_ATTESTATION,
|
|
payload: attestation,
|
|
});
|
|
|
|
export default function attestation(state = initState, action: Action): State {
|
|
switch (action.type) {
|
|
case ActionType.SET_ATTESTATION:
|
|
return {
|
|
...state,
|
|
raw: action.payload,
|
|
};
|
|
default:
|
|
return state;
|
|
}
|
|
}
|