Skip to content

Commit

Permalink
feat(schema-type): add isDynamicAbiType (#1096)
Browse files Browse the repository at this point in the history
  • Loading branch information
alvrs authored Jul 3, 2023
1 parent 469ca13 commit b9319d1
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/schema-type/src/typescript/dynamicAbiTypes.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Hex } from "viem";
import { DynamicAbiType } from "./schemaAbiTypes";
import { DynamicAbiType, SchemaAbiType } from "./schemaAbiTypes";
import { LiteralToBroad } from "./utils";
import { isArrayAbiType } from "./arrayAbiTypes";

// Variable-length ABI types, where their lengths are encoded by a PackedCounter within the record

Expand Down Expand Up @@ -122,3 +123,7 @@ export const dynamicAbiTypeToDefaultValue = {
export type DynamicAbiTypeToPrimitiveType<TDynamicAbiType extends DynamicAbiType = DynamicAbiType> = LiteralToBroad<
(typeof dynamicAbiTypeToDefaultValue)[TDynamicAbiType]
>;

export function isDynamicAbiType(abiType: SchemaAbiType): abiType is DynamicAbiType {
return isArrayAbiType(abiType) || abiType === "bytes" || abiType === "string";
}

0 comments on commit b9319d1

Please sign in to comment.