Skip to content
This repository has been archived by the owner on Feb 26, 2024. It is now read-only.

Add missing codec component for new error type #6097

Merged
merged 1 commit into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@ import type { Format } from "@truffle/codec";
import { createCodecComponent } from "../../utils/create-codec-component";
import { OverlongArrayOrStringStrictModeError } from "./format.errors.overlong-array-or-string-strict-mode-error";
import { InternalFunctionInABIError } from "./format.errors.internal-function-in-abi-error";
import { isOverlongArrayOrStringStrictModeError } from "../../../utils";
import { ReEncodingMismatchError } from "./format.errors.re-encoding-mismatch-error";
import {
isOverlongArrayOrStringStrictModeError,
isInternalFunctionInABIError
} from "../../../utils";

export const { InternalUseError } = createCodecComponent(
"InternalUseError",
(data: Format.Errors.InternalUseError) =>
isOverlongArrayOrStringStrictModeError(data) ? (
<OverlongArrayOrStringStrictModeError data={data} />
) : (
) : isInternalFunctionInABIError(data) ? (
<InternalFunctionInABIError data={data} />
) : (
<ReEncodingMismatchError data={data} />
)
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import React from "react";
import type { Format } from "@truffle/codec";
import { createCodecComponent } from "../../utils/create-codec-component";
import { CodecError } from "../common/codec-error";

export const { ReEncodingMismatchError } = createCodecComponent(
"ReEncodingMismatchError",
({ kind }: Format.Errors.ReEncodingMismatchError) => (
<CodecError kind={kind} />
)
);
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export interface CustomComponentsContextValue {
OverlargePointersNotImplementedError: Codec.Format.Errors.OverlargePointersNotImplementedError;
OverlongArrayOrStringStrictModeError: Codec.Format.Errors.OverlongArrayOrStringStrictModeError;
OverlongArraysAndStringsNotImplementedError: Codec.Format.Errors.OverlongArraysAndStringsNotImplementedError;
ReEncodingMismatchError: Codec.Format.Errors.ReEncodingMismatchError;
ReadErrorBytes: Codec.Format.Errors.ReadErrorBytes;
ReadErrorStack: Codec.Format.Errors.ReadErrorStack;
ReadErrorStorage: Codec.Format.Errors.ReadErrorStorage;
Expand Down
1 change: 1 addition & 0 deletions packages/codec-components/src/react/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ export * from "./components/codec/format.errors.options-error";
export * from "./components/codec/format.errors.overlarge-pointers-not-implemented-error";
export * from "./components/codec/format.errors.overlong-array-or-string-strict-mode-error";
export * from "./components/codec/format.errors.overlong-arrays-and-strings-not-implemented-error";
export * from "./components/codec/format.errors.re-encoding-mismatch-error";
export * from "./components/codec/format.errors.read-error-bytes";
export * from "./components/codec/format.errors.read-error-stack";
export * from "./components/codec/format.errors.read-error-storage";
Expand Down
1 change: 1 addition & 0 deletions packages/codec-components/src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export * from "./type-guards/decoder-error/options-error";
export * from "./type-guards/decoder-error/overlarge-pointers-not-implemented-error";
export * from "./type-guards/decoder-error/overlong-array-or-string-strict-mode-error";
export * from "./type-guards/decoder-error/overlong-arrays-and-strings-not-implemented-error";
export * from "./type-guards/decoder-error/re-encoding-mismatch-error";
export * from "./type-guards/decoder-error/read-error";
export * from "./type-guards/decoder-error/read-error-bytes";
export * from "./type-guards/decoder-error/read-error-stack";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@ import type { Format } from "@truffle/codec";
import { decoderErrorTypeGuardHelper } from "./helper";
import { overlongArrayOrStringStrictModeErrorKinds } from "./overlong-array-or-string-strict-mode-error";
import { internalFunctionInABIErrorKinds } from "./internal-function-in-abi-error";
import { reEncodingMismatchErrorKinds } from "./re-encoding-mismatch-error";

export const [isInternalUseError, internalUseErrorKinds] =
decoderErrorTypeGuardHelper<Format.Errors.InternalUseError>(
...overlongArrayOrStringStrictModeErrorKinds,
...internalFunctionInABIErrorKinds
...internalFunctionInABIErrorKinds,
...reEncodingMismatchErrorKinds
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Format } from "@truffle/codec";
import { decoderErrorTypeGuardHelper } from "./helper";

export const [isReEncodingMismatchError, reEncodingMismatchErrorKinds] =
decoderErrorTypeGuardHelper<Format.Errors.ReEncodingMismatchError>(
"ReEncodingMismatchError"
);