-
Notifications
You must be signed in to change notification settings - Fork 11.3k
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
[TypeScript SDK] Allow people to pass Pure args directly #7765
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Ignored Deployment
|
sdk/typescript/src/types/common.ts
Outdated
@@ -57,7 +57,7 @@ export type ObjectOwner = Infer<typeof ObjectOwner>; | |||
|
|||
// TODO: Figure out if we actually should have validaton on this: | |||
export const SuiJsonValue = unknown(); | |||
export type SuiJsonValue = boolean | number | string | Array<SuiJsonValue>; | |||
export type SuiJsonValue = boolean | number | string | PureArg | Array<SuiJsonValue>; |
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.
MoveCallTransaction interface has this property arguments: SuiJsonValue[]
so I added PureArg as SuiJsonValue but I am not sure if this is an acceptable way to do it
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.
PureArg
should not be part of SuiJsonValue
as it does not work with the RpcTxnBuilder. I see two ways of fixing this:
-
change
arguments: SuiJsonValue[]
toarguments: (SuiJsonValue | PureArg)[]
. To make this compatible with the RpcTxnDataSerializer, we either throw an error ifPureArg
is passed as an argument in RpcTxnDataSerializer.ts -
Or we can update the rust code
rpc_arguments: Vec<SuiJsonValue>,
cc @oxade
sdk/typescript/src/types/sui-bcs.ts
Outdated
/** | ||
* A pure argument. | ||
*/ | ||
export type PureArg = { Pure: ArrayLike<number> }; |
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.
nit: reuse in line 167
.changeset/sour-ligers-deny.md
Outdated
"@mysten/sui.js": minor | ||
--- | ||
|
||
Pure args can be passed directly |
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.
"@mysten/sui.js": minor | |
--- | |
Pure args can be passed directly | |
"@mysten/sui.js": patch | |
--- | |
Allow passing Pure args directly in Move call |
We are following the semver semantics for Alpha and beta (0.x.y) : https://github.com/dbrock/semver-howto#alpha-and-beta-0xy, incrementing y for every backward-compatible change, and x for every incompatible change. So this should be a patch change since it's backward compatible
sdk/typescript/src/types/common.ts
Outdated
@@ -57,7 +57,7 @@ export type ObjectOwner = Infer<typeof ObjectOwner>; | |||
|
|||
// TODO: Figure out if we actually should have validaton on this: | |||
export const SuiJsonValue = unknown(); | |||
export type SuiJsonValue = boolean | number | string | Array<SuiJsonValue>; | |||
export type SuiJsonValue = boolean | number | string | PureArg | Array<SuiJsonValue>; |
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.
PureArg
should not be part of SuiJsonValue
as it does not work with the RpcTxnBuilder. I see two ways of fixing this:
-
change
arguments: SuiJsonValue[]
toarguments: (SuiJsonValue | PureArg)[]
. To make this compatible with the RpcTxnDataSerializer, we either throw an error ifPureArg
is passed as an argument in RpcTxnDataSerializer.ts -
Or we can update the rust code
rpc_arguments: Vec<SuiJsonValue>,
cc @oxade
…pcTxnDataSerializer
sdk/typescript/src/signers/txn-data-serializers/rpc-txn-data-serializer.ts
Outdated
Show resolved
Hide resolved
Added PureArg type in sui-bcs.ts If Move Call argument is of type PureArg, it is returned without further serialization in call-arg-serializer.ts closes #7569 closes #7539 --------- Co-authored-by: Chris Li <[email protected]>
How do I construct a devInspect transaction using a UID? Right now this is giving the error:
How do I make the first argument to be of type UID inside of the object, rather than the object itself? |
Is this part of production? I'm using Typescript SDK v0.29 and I'm still getting a Tyepscript error about how Uint8Array's aren't part of SuiJSON or SuiJSON[ ] types and I can't use it as a function argument. When I do a @ts-ignore and do it anyway, I get a weird error like this:
Not sure why it turns my Uint8Array into this weird object... What's really weird about this too is that bcs.ser (the official BCS serializer) returns Unit8Arrays, so you need to turn bcs's output into a number[ ][ ] instead to get the Sui Typescript SDK to accept it as input. |
Added PureArg type in sui-bcs.ts
If Move Call argument is of type PureArg, it is returned without further serialization in call-arg-serializer.ts
closes #7569
closes #7539