Skip to content
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

Merged

Conversation

jeesunikim
Copy link
Contributor

@jeesunikim jeesunikim commented Mar 18, 2025

success.mov
  • fail case on mainnet using the contract CA6PUJLBYKZKUEKLZJMKBZLEKP2OTHANDEOWSFF44FTSYLKQPIICCJBE (link)
    -- this one doesn't provide debuginfo
error.mov

I need to test further with contracts to get the scenario with debuginfo

@stellar-jenkins
Copy link

Something went wrong with PR preview build please check

@stellar-jenkins
Copy link

Something went wrong with PR preview build please check

@stellar-jenkins
Copy link

Something went wrong with PR preview build please check

@stellar-jenkins
Copy link

Something went wrong with PR preview build please check

@stellar-jenkins
Copy link

Something went wrong with PR preview build please check

@stellar-jenkins
Copy link

@jeesunikim jeesunikim marked this pull request as ready for review March 19, 2025 06:18
@jeesunikim jeesunikim requested a review from quietbits March 19, 2025 06:19
@janewang
Copy link
Contributor

@jeesunikim This is super neat!

@stellar-jenkins
Copy link

Comment on lines +34 to +50
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 });
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

@stellar-jenkins
Copy link

@jeesunikim jeesunikim merged commit 1ffa798 into feature-invoke-host-function Mar 19, 2025
5 checks passed
@jeesunikim jeesunikim deleted the invoke-contract-convert-to-scval branch March 19, 2025 21:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants