Skip to content

Chore/Better Types#246

Merged
SamuelQZQ merged 3 commits intoThalaLabs:mainfrom
21Chani:chore/type-refactor
Apr 21, 2025
Merged

Chore/Better Types#246
SamuelQZQ merged 3 commits intoThalaLabs:mainfrom
21Chani:chore/type-refactor

Conversation

@21Chani
Copy link
Copy Markdown
Contributor

@21Chani 21Chani commented Apr 15, 2025

This PR will:

Refactor types aiming a new cleaner approach to make life easier when messing with abi type conversion.

Motivation

At #237 I found myself dealing with a lot troubles having to manage a refactor in files that shouldn't be touched in the pr, because of that I am splitting those small tasks to it's own pr's like this one.

Approaches explanation

I wanted to remove type conversions like this one that was being "recreated" in 3 files:
image

So I have created a map type for it that will provide type reusability and also easier type reading.
image
But I had to make it generic with HighValue because I found that sometimes the api needs to use string instead of AnyNumber, so, instead of creating two separated types, you just need to provide the type in generics of the type of Number return you want to manage.

Example:

type Uint64 = MovePrimitiveMap<string>["u64"] 
// string

or

type Uint64 = MovePrimitiveMap<AnyNumber>["u64"] 
// AnyNumber

@21Chani 21Chani changed the title Chore/type refactor Chore/Better Types Apr 15, 2025
@21Chani 21Chani mentioned this pull request Apr 15, 2025
@21Chani
Copy link
Copy Markdown
Contributor Author

21Chani commented Apr 15, 2025

@SamuelQZQ I believe all type issues are now fixed. Right after confirmed that everything is good I will proceed to struct types

Comment thread src/core/__tests__/createEntryPayload.test.ts
@SamuelQZQ
Copy link
Copy Markdown
Contributor

@21Chani seems like you remove two @ts-expect-error, which means now it doesn't through type error, even if it's passing the wrong vector type😂

@21Chani
Copy link
Copy Markdown
Contributor Author

21Chani commented Apr 18, 2025

@21Chani seems like you remove two @ts-expect-error, which means now it doesn't through type error, even if it's passing the wrong vector type😂

Lol I have posted giga comments about it and then realized that yeah, was checking for invalid types, lol, it took me a while to understand that the file was doing verification only for errors, since the ts-expect error was saying was not necessary anymore, I thought the right was remove it lmao.

Types has been fixed and the expect line has been returned 🫡

@SamuelQZQ SamuelQZQ merged commit 7be743f into ThalaLabs:main Apr 21, 2025
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.

2 participants