-
Notifications
You must be signed in to change notification settings - Fork 29
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 Token” via freighter-api #1815
base: release/5.28.0
Are you sure you want to change the base?
Conversation
extension/src/background/messageListener/freighterApiMessageListener.ts
Outdated
Show resolved
Hide resolved
extension/src/background/messageListener/popupMessageListener.ts
Outdated
Show resolved
Hide resolved
5f251f9
to
1addc55
Compare
266000c
to
f6b4f54
Compare
try { | ||
let balance; | ||
if (fetchBalance && networkDetails.sorobanRpcUrl) { |
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.
is there any reason to not use the balance from the backend in this case? We only want to use the rpc locally in the case of a custom network in general.
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.
Second this. We should use the backend to fetch balances and token details (unless we're on a custom network).
Also, using buildSorobanServer
with networkDetails.sorobanRpcUrl
will not work on mainnet because our Soroban RPC url for Mainnet is on a private kube cluster that only our backend can reach. You'll see that if you hit this method on Mainnet that the call will fail
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.
@aristidesstaffieri @piyalbasu Thanks for raising this!
So I ended up adding this RPC fetch because the backend request was not returning the balance. It's currently returning an object like this:
{
name: string;
decimals: number;
symbol: string;
}
I'll take a look at the backend code to see what we could do there.
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.
PR opened here: stellar/freighter-backend#204
> | ||
+1000.00 GO | ||
{t("Simulated Balance Changes")} |
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.
Curious why this says "Simulated Balance Changes"?
Isn't adding a token only bringing into your Freighter balances? I don't think this changes a balance or simulates a balance change.
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.
Good point, I was simply following the Designs here. Looks like @sdfcharles tried using the same wording from other screens, but thinking about this now I think something like "Balance Info" would probably make more sense here.
What do you think?
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.
Yeah something like that seems more appropriate to me but maybe we could have @sdfcharles weigh in.
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'm still taking a look at this (sorry for the delay!). But could you please add documentation for this new method in |
@piyalbasu great catch, I'll add it |
@piyalbasu I've added the missing documentation for ![]() ![]() |
Related issue: #1646
This PR adds the
addToken
functionality via freighter-api, it uses the existingsignTransaction
andsignMessage
APIs as inspiration.The
addToken
API takes both acontractId
and anetworkPassphrase
as input which Freighter will use to load the token details (e.g.symbol, name, decimals and balance
) for the user.Freighter will then show these token details along with any applicable warnings. The user will need to approve it in order for the token to be added.
This PR extracts the
token lookup
andchange trustline
functionalities into theuseTokenLookup
anduseChangeTrustline
hooks respectively so we can reuse the "add token" logic in both our API and manual approaches.Adding a custom token with the
addToken
APIcustom-token.mov
Adding a SAC token with the
addToken
APIsac-token.mov
Asset lists and Blockaid warning messages
Documentation update