Error rather than degrade if inference fails
banool opened this issue · 3 comments
One thing I notice is if you don't have the right module ID the type inference still proceeds but it misses a lot of information.
For example, this gives me rich type information:
type ABITAble = DefaultABITable & {
"0x296102a3893d43e11de2aa142fbb126377120d7d71c246a2f95d5b4f3ba16b30::chess": typeof CHESS_ABI;
};
But this doesn't:
type ABITAble = DefaultABITable & {
"0x296102a3893d43e11de2aa142fbb126377120d7d71c246a2f95d5b4f3ba16b30::Chess": typeof CHESS_ABI;
};
I would rather the second case be an error rather than it just degrade silently.
@banool After some investigation, I think the best solution is change this ABITable
from a Record type to a list.
In this example:
type ABITAble = DefaultABITable & {
"0x296102a3893d43e11de2aa142fbb126377120d7d71c246a2f95d5b4f3ba16b30::chess": typeof CHESS_ABI;
};
The key "0x296102a3893d43e11de2aa142fbb126377120d7d71c246a2f95d5b4f3ba16b30::chess" is redundant because CHESS_ABI
already have those address and name information. So this is enough:
type ABITAble = [
typeof CHESS_ABI,
typeof ANOTHER_ABI,
]
wdyt?
Seems much better to me!
@banool We have release the change in 1.6.0. Now the ABITable should be a list:
import { DefaultABITable } from "@thalalabs/surf";
import { createSurfClient } from '@thalalabs/surf';
import { Aptos } from '@aptos-labs/ts-sdk';
type ABITAble = [
...DefaultABITable,
...[
typeof FIXED_POINT64_ABI
]
];
const client = createSurfClient<ABITAble>(new Aptos());
And btw, for enhanced security, we now publish all packages, including Surf, on Github Packages instead of npm registry. To install Surf, now you need to add a .npmrc
config. You can find more details in README.md. Feel free to share your feedback.