Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add explicit enums implementation #529

Merged
merged 3 commits into from
Nov 12, 2024
Merged

Conversation

danielailie
Copy link
Contributor


const typedValues = NativeSerializer.nativeToTypedValues([p1], endpoint);

console.log(typedValues[0].valueOf());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logging artifact.


// Simple enum by name
const p1 = "completed";
// Enum with a single field
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment / code alignment.

Comment on lines +67 to +70
} else if (typeDefinition.type == "enum") {
customTypes.push(EnumType.fromJSON({ name: customTypeName, variants: typeDefinition.variants }));
} else if (typeDefinition.type == "explicit-enum") {
customTypes.push(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import { StringBinaryCodec } from "./string";

export class ExplicitEnumBinaryCodec {
private readonly stringCodec: StringBinaryCodec;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@@ -107,6 +112,12 @@ export class AbiRegistry {
return <EnumType>result!;
}

getExplicitEnum(name: string): ExplicitEnumType {
const result = this.customTypes.find((e) => e.getName() == name && e.hasExactClass(ExplicitEnumType.ClassName));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it does not help in this case, but I think it would be a good practice to use === wherever possible.

@danielailie danielailie merged commit 9de1d6a into main Nov 12, 2024
4 checks passed
@danielailie danielailie deleted the TOOL-328-fix-explicit-enums branch November 12, 2024 12:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants