-
Notifications
You must be signed in to change notification settings - Fork 103
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
[Invoke contract] convert nativeToScVal and use prepareTransaction
to submit
#1281
[Invoke contract] convert nativeToScVal and use prepareTransaction
to submit
#1281
Conversation
Something went wrong with PR preview build please check |
Something went wrong with PR preview build please check |
Something went wrong with PR preview build please check |
Something went wrong with PR preview build please check |
Something went wrong with PR preview build please check |
Preview is available here: |
@jeesunikim This is super neat! |
Preview is available here: |
if (inputFieldType === xdr.ScSpecType.scSpecTypeU64().name) { | ||
return parsedIntValue.toU64(); | ||
} | ||
|
||
if (inputFieldType === xdr.ScSpecType.scSpecTypeI64().name) { | ||
return parsedIntValue.toI64(); | ||
} | ||
|
||
if (inputFieldType === xdr.ScSpecType.scSpecTypeI128().name) { | ||
return parsedIntValue.toI128(); | ||
} | ||
|
||
if (inputFieldType === xdr.ScSpecType.scSpecTypeU128().name) { | ||
return parsedIntValue.toU128(); | ||
} | ||
|
||
return nativeToScVal(parsedIntValue, { type: inputFieldType }); |
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 think you can use return parsedIntValue.toScVal()
here?
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.
parseIntValue.toScVal
returns u64
even for the required u128
type. I think it's because the saved value type is in string
type so it returns the smallest possible XDR integer type when I use parsedIntValue.toScVal()
, which is u64
in this case even though the contract requires u128
in the case of swap func in contract CA6PUJLBYKZKUEKLZJMKBZLEKP2OTHANDEOWSFF44FTSYLKQPIICCJBE
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.
Ahhh yes that makes sense - you can pass an optional { type: "" }
but that'd be the same amount of code to compare the input field type.
Preview is available here: |
-- stellar.expert link
success.mov
CA6PUJLBYKZKUEKLZJMKBZLEKP2OTHANDEOWSFF44FTSYLKQPIICCJBE
(link)-- this one doesn't provide
debuginfo
error.mov
I need to test further with contracts to get the scenario with
debuginfo