-
Notifications
You must be signed in to change notification settings - Fork 44
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
[Transaction Builder] Adding distinct interfaces for entry function and script transaction payloads #8
Conversation
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.
left some questions and comments but overall lgtm!
static U8(values: Array<number> | HexInput): MoveVector<U8> { | ||
let numbers: Array<number>; | ||
|
||
if (Array.isArray(values) && typeof values[0] === "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.
we assume all elements in the array are numbers and not just the first one? or we actually check it somewhere?
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.
each one is eventually validated when you map the numbers I believe, but will check it here if not
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.
it's validated when mapping the numbers, since new U8(v)
should validate it
Ah yes, I already have a test case for it in bcs-helper.test.ts
:
expect(() => MoveVector.U8(["01", "02", "03"] as any)).toThrow();
/** | ||
* Deserialize a Script Transaction Argument | ||
*/ | ||
export function deserializeFromScriptArgument(deserializer: Deserializer): TransactionArgument { |
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.
why place it in this file?
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 wasn't sure where to put it in order to avoid circular deps, but I figured it's only used for script payloads so just put it here
bb85c02
to
336d764
Compare
…endencies surrounding it
…types.ts for clearer type errors when using incorrect types
… use regular Move classes
336d764
to
3167861
Compare
Description
This is ideally the last significant change to anything BCS-related before alpha release. It looks like a lot but it's mostly just consolidating types, removing extraneous classes, and adding interfaces to avoid circular dependencies and make things more clear
1. Removed the ScriptTransactionArgument class
deserializeFromScriptArgument
function we use in theScript
class when deserializing the argument vectorOptions
and onlyMoveVector<U8>
2. Added
EntryFunctionBytes
classFixedBytes
, except without aserializeForScriptFunction
function.EntryFunctionBytes
asScriptFunctionArguments
3. Added
serializeForEntryFunction
andserializeForScriptFunction
for each classTransactionArgument
interface, which allows us to pass around Move values and serialize them according to the inferred transaction payload without having to have a class to represent those values4. Added support for Objects and Strings in script functions
5. Renamed all instances and references of
String
andOption
to haveMove
prepended to them6. Added
EntryFunctionArgumentTypes
andScriptFunctionArgumentTypes
Still need to test if script payload args have compile time and/or runtime errors with incorrect argument types, and make more extensive tests around script payloads, especially using strings and objects.
Example of new
ScriptPayload
:Now:
Before:
Test Plan
Added basic test cases for things