-
Notifications
You must be signed in to change notification settings - Fork 27
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 improved local options with preflight #185
Conversation
import type { ICommand, SignatureWithHash } from '@kadena/types'; | ||
|
||
import type { IUnsignedCommand, SignCommand } from '@kadena/types'; | ||
import { createSendRequest } from 'kadena.js'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this import not be something along the lines of @kadena/client
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kadena/client
's send uses the send
in chainweb-node-client, and has it's own send function from the command builder.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Its a preliminary, but I wanted to get you started
export interface ILocalCommandResultWithPreflight { | ||
reqKey: IBase64Url; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
txId: number | null; | ||
result: IPactResultSuccess | IPactResultError; | ||
gas: number; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
logs: string | null; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
continuation: IPactExec | null; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
metaData: IChainwebResponseMetaData | null; | ||
events?: Array<IPactEvent>; | ||
preflightWarnings?: Array<string>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to have a intersection type between ILocalCommandResult
and the separate Preflight
part, instead of duplicating across two interfaces?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
per our discussion, because the preflight result only includes another field, preflightWarnings
, this type will be used as the LocalResultWithPreflight
, and LocalResultWithoutPreflight
will be
Omit<
LocalResultWithPreflight,
'preflightWarnings'
>;```
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments
…chainweb-node-client
@all-contributors please add @ggobugi27 for code |
I've put up a pull request to add @ggobugi27! 🎉 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments
export type LocalResultWithoutPreflight = Omit< | ||
LocalResultWithPreflight, | ||
'preflightWarnings' | ||
>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the default for a local call, with or without preflight? I'd rather have one that doesn't have a specifier on preflight
. So LocalResult
and either LocalPreflightResult
or LocalResultWithoutPreflight
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default will be with preflight. I'll change the naming.
export interface ILocalCommandResultWithPreflight { | ||
reqKey: IBase64Url; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
txId: number | null; | ||
result: IPactResultSuccess | IPactResultError; | ||
gas: number; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
logs: string | null; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
continuation: IPactExec | null; | ||
/* eslint-disable-next-line @rushstack/no-new-null*/ | ||
metaData: IChainwebResponseMetaData | null; | ||
events?: Array<IPactEvent>; | ||
preflightWarnings?: Array<string>; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see on line 228 the following interface:
export interface IPreflightResult {
preflightResult: ICommandResult;
preflightWarnings: [];
}
Should ILocalCommandResultWithPreflight
also have preflightResult
? Or is this what the API returns and not what is used in downstream code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one is interface for the parsed commandResult, where preflightResult is spread into the object.
test('/spv returns SPV proof', async () => { | ||
const actual: string | Response = await spv(testSPVRequest, ''); | ||
const actual: string | Response = await spv(testSPVRequest, testURL); | ||
const expected: SPVResponse = testSPVProof; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you make an issue to convert all test
s to describe
+it
?
Reason:
kadena-io/chainweb-node#1585
/local
with preflight and signatureVerificationChanges made (preferably with images/screenshots):
chainweb-node-client
local
defaults topreflight=true
,signatureVerification=true
-
local
andsend
only accepts fully signed commands.createSendRequest
,createPollRequest
,createListenRequest
from kadena.jskadena.js
prepareExecCommand
,prepareContCommand
,createCommand
results changed fromICommand
toIUnsignedCommand
types
{sig: undefined}
option inICommand
IUnsignedCommand
pactjs
isSignedCommand
function which checks if signature is presentensureSignedCommand
function which checks if signature is present and return the command in ICommand type, throws error if signature is not present.Check off the following:
rush change
to add the appropriate change logs.