-
Notifications
You must be signed in to change notification settings - Fork 53
Description
As per title, I have encountered the following issue: Lumos internally uses a deprecated types validator that doesn't validate ImmutableJS types.
In the current version of Lumos Utils I have extensively used ImmutableJS's Records for defining types implementing the Interfaces defines by Lumos such a Scripts, OutPoint... but then when I try to use them, often I encounter deprecated types validators flagging them as not valid.
For example, let's say I implement the Script interface with:
export type I8Script = Record<Script> & Readonly<Script>;
export const I8ScriptFrom = Record<Script>({
codeHash: "0x0000000000000000000000000000000000000000000000000000000000000000",
hashType: "data",
args: "0x"
});
encodeToAddress(I8ScriptFrom())
Lumos errors out with:
/home/user/ickb/lumos-utils/node_modules/@ckb-lumos/toolkit/src/validators.js:31
throw new Error(errorMessage);
^
Error: script does not have correct keys! Required keys: [args, codeHash, hashType], optional keys: [], actual keys: [__ownerID, _values]
at assertObjectWithKeys (/home/user/ickb/lumos-utils/node_modules/@ckb-lumos/toolkit/src/validators.js:31:11)
at Object.ValidateScript (/home/user/ickb/lumos-utils/node_modules/@ckb-lumos/toolkit/src/validators.js:70:3)
at encodeToAddress (/home/user/ickb/lumos-utils/node_modules/@ckb-lumos/helpers/src/index.ts:239:14)
at I8Secp256k1AccountFrom (/home/user/ickb/lumos-utils/src/secp256k1.ts:69:36)
at main (/home/user/ickb/v1-core/src/deploy.ts:33:43)
at processTicksAndRejections (node:internal/process/task_queues:95:5)
This is due to Lumos Toolkit's ValidateScript that, while being marked as deprecate, it's still used to validate the Script parameter:
/**
* @deprecated please follow the {@link https://lumos-website.vercel.app/migrations/migrate-to-v0.19 migration-guide}
*/
export function ValidateScript(script: any, { nestedValidation, debugPath }?: {
nestedValidation?: boolean;
debugPath?: string;
}): script is api.Script;
So while I8Script correctly implements the Script interface (as it correctly exporse the fields codeHash, hashType and args), it's flagged as invalid by this deprecated validator.
Should I report all the errors of this kind that I encounter and ask them to be fixed?
As usual I'm asking here since GitHub issues are SEO friendly and very likely in the future there will be other L1 developers wondering the same 😉
Phroi
Metadata
Metadata
Assignees
Labels
Type
Projects
Status