Skip to content

Commit

Permalink
Consolidate errors for the findVectorBufferArgument function
Browse files Browse the repository at this point in the history
Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
  • Loading branch information
petertonysmith94 and maschad committed Apr 9, 2024
1 parent 7ea6d92 commit a26bff7
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions packages/abi-coder/src/utils/json-abi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,19 +62,11 @@ export const findVectorBufferArgument = (
components: readonly ResolvedAbiType[]
): JsonAbiArgument => {
const bufferComponent = components.find((c) => c.name === 'buf');
if (!bufferComponent) {
throw new FuelError(
if (!bufferComponent || !bufferComponent.originalTypeArguments?.[0]) {
throw new FuelError(
ErrorCode.INVALID_COMPONENT,
`The provided Vec type is missing the 'buf' component.`
);
}

const arg = bufferComponent.originalTypeArguments?.[0];
if (!arg) {
throw new FuelError(
ErrorCode.INVALID_COMPONENT,
`The provided Vec type is missing the 'type argument'.`
);
}
return arg;
};

0 comments on commit a26bff7

Please sign in to comment.