yours-org / yours-wallet

A non-custodial and open-source wallet for BSV and 1Sat Ordinals.
Other
64 stars 51 forks source link

SendBSV20 - no token amount showing in the wallet UI when requesting/prompting a user to transfer tokens. #249

Closed joeyjojojoe closed 1 month ago

joeyjojojoe commented 1 month ago
Screenshot
danwag06 commented 1 month ago

@joeyjojojoe I'm not seeing the same issue. Can you give an example of the request you are passing via the provider?

Screenshot 2024-10-04 at 7 43 21 PM

https://app.gitbook.com/o/k6HnSOibnJKs9gyXDEwI/s/8h5PbVdOLZTSAZHevtG0/bsv-20/send-bsv20

joeyjojojoe commented 1 month ago

Hi Dan,

Does this help?

let totalTokens; if (userChoice) { // Prompt the user to select a BSV20 ticker const ticker = window.prompt('Enter the BSV20 token ticker (1SAT, GM, PEPE, SHUA):'); if (!ticker) { console.error('No ticker provided. Aborting BSV20 payment.'); return; }

// Fetch the sat/token price using the ticker const satPerToken = await getMarketPrice(ticker); if (!satPerToken) { console.error('Failed to fetch sat/token price. Aborting BSV20 payment.'); return; }

// Calculate the number of tokens needed to pay for the item const itemPrice = parseInt(item.price); // Item price in satoshis totalTokens = Math.ceil(itemPrice / satPerToken); // Calculate total tokens needed console.log(Total tokens required to purchase: ${totalTokens});

// Set up transfer parameters for BSV20 payment const transferParams = { idOrTick: ticker, // Use the provided ticker address: '1sMrf4iWRPZ3qKYcHA7Pnz67Px4qFYzVd', // Address to receive the tokens amount: totalTokens, // Amount of tokens to transfer };

console.log('BSV20 transfer parameters:', transferParams);

try { const txid = await wallet.transferOrdinal(transferParams); console.log(BSV20 Transfer Transaction ID: ${txid}); } catch (transferError) { console.error('Error during BSV20 transfer:', transferError); }

On 5 Oct 2024, at 12:44 pm, Dan Wagner @.***> wrote:

@joeyjojojoehttps://github.com/joeyjojojoe I'm not seeing the same issue. Can you give an example of the request you are passing?

Screenshot.2024-10-04.at.7.43.21.PM.png (view on web)https://github.com/user-attachments/assets/32b9caf5-e474-4dbf-b6dd-470dcd302db3

— Reply to this email directly, view it on GitHubhttps://github.com/yours-org/yours-wallet/issues/249#issuecomment-2394872100, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AP372LGNNZHY5XNLQ6BJEC3ZZ5HCFAVCNFSM6AAAAABPM2KUXOVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGOJUHA3TEMJQGA. You are receiving this because you were mentioned.Message ID: @.***>

joeyjojojoe commented 1 month ago

most likely an issue on my end with the wallet. I don't think I had the token in the wallet.

danwag06 commented 1 month ago

Yeah if the wallet does not have the specified token it would likely display as you originally posted. You can call getBsv20s() to get a list of tokens available in the wallet.