Irys-xyz / arweave-js-sdk

JS SDK for Irys on Arweave
111 stars 96 forks source link

Solana: Balance not displaying correctly? or doing it wrong? #56

Closed c4b4d4 closed 1 year ago

c4b4d4 commented 2 years ago

I'm creating a transaction on my own, because I'm implementing a minting process within the same transaction of sendings the funds for the upload, so I guarantee that the funds are sent at the same time the NFT gets minted.

I'm following everything that happens on the funding function for Solana:

https://github.com/Bundlr-Network/js-sdk/blob/55cd881dba49dc45e6e40fb46fde8b05a7d596b0/src/node/currencies/solana.ts#L126

And I'm adding an extra SOL transfer from the user that is minting the NFT, so I get the funds from them.

const price = await bundlr.getPrice(totalBytes);
const bundlrAddress = await bundlr.utils.getBundlerAddress("solana");

const minterPayment = SystemProgram.transfer({
    fromPubkey: toPublicKey(minterAddress),
    toPubkey: toPublicKey(arweaveWallet),
    lamports: price.toNumber(),
})

const fundingBundlr = SystemProgram.transfer({
    fromPubkey: toPublicKey(arweaveWallet),
    toPubkey: toPublicKey(bundlrAddress),
    lamports: price.toNumber(),
})

So, minterAddress is sending price amount to arweaveWallet, and then arweaveWallet (which is the my main wallet for funding the Bundlr node) is sending the same price amount to bundlrAddress.

You can see full transaction here: https://solscan.io/tx/5DCmfoPmTsbWg6vULD4mrPrZgVekjxQDH1y5WzJTP3dE9rH6um4GDv1uqDwSbLpxH5Tz67DhgZsq9dWKbvFJW54w?cluster=devnet

Here is the part where arweaveWallet is sending price amount to bundlrAddress. All happening in devnet

Screen Shot 2022-08-30 at 14 10 42

But when I query my balance, I'm getting 0 balance.

You can query it here: https://devnet.bundlr.network/account/balance/solana?address=EZgy1WTF1Do4QqpuUvj2NWvHuT5tyLiKqHv7PAvKB8os

Is there something wrong with the devnet? or am I missing something for funding it correctly.

c4b4d4 commented 2 years ago

By doing several tests I found that it only works when there are no other instructions on the Transaction. Not even by putting the Transfer Instruction as the first instruction of the Transaction.

This is so wrong, and I'd say it's a major bug/issue.

Bundlr only detects balance income when transactions are done with 1 instruction only 🤯, if Transaction is built with several instructions is not adding the balance to the account.

JesseTheRobot commented 2 years ago

Bundlr only detects balance income when transactions are done with 1 instruction only 🤯, if Transaction is built with several instructions is not adding the balance to the account.

Correct - we are working on resolving this issue and will update you once it's been resolved!