GithubHelp home page GithubHelp logo

js-sdk's People

Contributors

0xmaayan avatar focusjosh avatar jbn avatar jessetherobot avatar jorahw3 avatar joshbenaron avatar jshaw-ar avatar kevger avatar lukecd avatar rabm2k7 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

js-sdk's Issues

cannot fund with wallet

All calls work except await bundlr.fund(price);

/Users/Documents/whitelights/bundlr-basics/node_modules/arweave/node/lib/api.js:43
        const headers = new Headers(init?.headers || {});

Can't fund uploads on Boba Rinkeby test network

When using this code:

const provider = new ethers.providers.Web3Provider(window.ethereum)
const bundlr = new WebBundlr(
      "https://devnet.bundlr.network",
      "boba",
      provider,
      { providerUrl: "https://rinkeby.boba.network" },
)
await bundlr.ready()
const price = await bundlr.getPrice(file.size)
await bundlr.fund(price)

MetaMask will request you to send testnet ETH to an address. This transaction will confirm and deplete ETH from your account, however, one of two errors will normally cause the code to fail at bundlr.fund.

One error is "Tx 0x2a994320700ca1597f8d838fac282017094832b900d214cc085c66ca2f2cd497 didn't finalize after 30 seconds".

The other error is "HTTP Error: Posting transaction 0x7b1d1f6bc857cae8d82563ff1749fa1dcb2bdf4e75befd78893164624c7bb2df information to the bundler: 400 Invalid tx"

If you check here or here you will see the transactions actually did go through.

Attempting to create a Bundlr transaction will always result in an error saying there are not enough funds, even though funds are being removed from the user's account. So this seems to be an issue with the devnet RPC. Perhaps it's checking transactions from the wrong RPC or block explorer?

bigint: Failed to load bindings

Hi I am trying to use WebBundlr but it gives me below error:

bigint: Failed to load bindings, pure JS will be used (try npm run rebuild?)
(node:50) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. 03:39:25
(Use node --trace-deprecation ... to show where the warning was created)

spec:

  • Operating System: Linux
  • Node Version: v16.15.1
  • Nuxt Version: 3.1.2
  • Nitro Version: 2.1.1
  • Package Manager: [email protected]
  • Builder: vite
  • User Config: app, components, modules, build, vite
  • Runtime Modules: @nuxtjs/[email protected]
  • Build Modules: -

How to check if the signed tx is already submitted?

The following code opens a Metamask window requesting to sign a transaction.

const bundlr = new WebBundlr(bundlrNode, currency, provider, {})
await bundlr.utils.getBundlerAddress(currency)
await bundlr.ready()

Is there a way to check if the signed transaction is already submitted to the bundler node?

For example:

const bundlr = new WebBundlr(bundlrNode, currency, provider, {})
await bundlr.utils.getBundlerAddress(currency)
if (alreadySubmitted) { // any way to do this?
  await bundlr.ready()
}

PS: The goal is to avoid showing the Metamask modal for every new upload.

Error: unsupported provider

import { providers } from "ethers";
import { WebBundlr } from "@bundlr-network/client";

const provider = new providers.Web3Provider(window.aptos)
const bundlr = new WebBundlr(
"https://node2.bundlr.network",
"aptos",
provider
);
await bundlr.ready();

This is my code. Ethers does not support aptos. Throws following errors:
image_2023-01-09_140851925

What to use instead of ethers?

Support for CF Workers

Due to the utilization of the Node.js Crypto module by the package, I am unable to use Bundlr JS SDK in combination with Cloudflare Workers. I would like to inquire whether there are any plans to support this integration in the future. Thank you for your attention to this matter :)

Algorand currency is currently now working anymore

The default indexer and api service provider is currently not providing the service anymore,
the best that i found for free and open is https://algonode.io/api/#documentation

but currently the code implemented in the AlgorandCurrency adds node. extension that doesn't work correctly with the different standard of algonode.

I think that a new standard should be adopted to make the old app based on algorand fully functional

Arbundles causing `window is not defined`

When trying to deploy to a Cloudflare worker, I get the error:

Uncaught ReferenceError: window is not defined
    at index.js:16761:5 in ../../node_modules/arweave/web/index.js
    at index.js:18:51 in __require2
    at index.js:16809:38 in ../../node_modules/arbundles/src/deepHash.js
    at index.js:18:51 in __require2
    at index.js:16909:22 in ../../node_modules/arbundles/src/ar-data-base.js
    at index.js:18:51 in __require2
    at index.js:87941:26 in ../../node_modules/arbundles/src/ar-data-bundle.js
    at index.js:18:51 in __require2
    at index.js:88456:28 in ../../node_modules/arbundles/src/index.js
    at index.js:18:51 in __require2
   [code: 10021]

This is using the Bundlr (default) client, but looks like the arbundles dependency is still using some web-based build and causing an issue.

Funding mismatch

Is there any guidance on how much buffer we should allow when applying funding before sending transactions? In particular, the following does not seem sufficient:

const bytes = bundlrTransactions.reduce((c, d) => c + d.data.length, 0);
const cost = await bundlr.utils.getPrice('solana', bytes);
await bundlr.fund(cost.toNumber());
for (const tx of bundlrTransactions) {
  await tx.upload();
}

The upload will fail with Not enough funds to send data in @bundlr-network/client/build/src/upload.js:221:23 and no other diagnostics

In my particular test, the number of bytes was small (<50kb) and multiplying the cost (<1e-5 SOL) by 2 was sufficient but it would be great to have specifics. Thanks!

WebBundlr issues with latest viem and wagmi version

Description

  • @bundlr-network/client: 0.11.2
  • wagmi: 1.0.8
  • viem: 0.3.37

The WebBundlr docs recommend using the useProvider and useSigner hooks from the wagmi library. These hooks have been deprecated for usePublicClient and useWalletClient.

When initializing with viem as recommended here:

const client: any = createWalletClient({
  chain,
  transport: custom((window as any).ethereum),
});
client.getSigner = () => client;
client.getAddress = async () => client.getAddresses();

// initialize bundlr instance
const bundlr = new WebBundlr('https://node1.bundlr.network', 'matic', client);
await bundlr.ready();

The bundlr.ready() no longer opens the injected signer (my MetaMask extension, for instance) to sign for bundlr, and when I call to create the transaction with my bundlr instance:

const fileData = await fileToDataUrl(uploadData.file);
const tx = ctx.bundlr.createTransaction(fileData);
 // sign and upload the tx
await tx.sign();
const result = await tx.uploadWithReceipt();

It throws an error:

Error: Owner must be 42 bytes, but was incorrectly 1 at Module.createData

Example Stackblitz

Searching by tag doesn't work in Arweave GraphQL

Example of creating transaction

const transaction = await bundlr.createTransaction(JSON.stringify({
    id: 'test',
  }, {
    tags: [
      { name: 'App-Name', value: 'TestAnton' },
    ],
  }));
  await transaction.sign();
  await transaction.upload();
  console.log(transaction.id);

Query GraphQL

query {
    transactions(first: 50,
      tags: [
        {
          name: "App-Name",
          values: ["TestAnton"]
        }
      ]
    ) {
        edges {
            node {
                id
            }
        }
    }
}

Example txid: 8igzR2DFLyveeZ-8aps5srfE4jAXtUvf2en5Z-xlSiM

bundlr.fund doesn't work on devnet with Windows

I'm using 0.7.15 and WebBundlr.
We can bundlr.fund on Mac environment with devnet and mainnet.
But we can't bundlr.fund on Windows environment with devnet. (Windows with mainnet works.)

It returns 400 error for our POST without creating any data on chain so the hash doesn't exist on Solana Explorer.

The error causes after 30 seconds for approve and message is below.

Unhandled Runtime Error
Error: HTTP Error: Posting transaction 535yVew4TKykmX2nfE7vYTx1PLrEjdvC3CoNPhXWCNkuLqRagUob65Kk8awotTKKemuMGMsrBF6piVRJoDQoVzLM information to the bundler: 400 Invalid tx

Call Stack
Utils.checkAndThrow
node_modules/@bundlr-network/client/build/common/utils.js (25:0)
Fund.fund
node_modules/@bundlr-network/client/build/common/fund.js (49:0)

Something is different in between the mac environment and windows one?

We use this in here.
solana-labs/governance-ui#866

The test deploy is here
https://governance-mnv1z1cl1-blockworks-foundation.vercel.app/dao/7y21NhHr64F2VLiLnZakna7B6vmWTEp5CK2GH6ArmVGP/params?cluster=devnet

We use WebBundlr on Create metadata on that page.
You can also test it after making your own DAO on devnet there.

Error when funding account in $MATIC

npx bundlr fund -h https://node1.bundlr.network -c matic -w $PRIVATE_KEY  500000000000000000

produces

assuming raw key instead of keyfile path
Loaded address: 0x....
? Confirmation: send 500000000000000000 wei (0.5 matic) to node1.bundlr.network (0x....)?
 Y / N y
0xed66902deab4....
(node:74180) UnhandledPromiseRejectionWarning: Error: HTTP Error: Posting transaction information to the bundler: 400 "Invalid tx"
    at Function.checkAndThrow (.../contracts/node_modules/@bundlr-network/client/build/src/utils.js:20:19)
    at Fund.<anonymous> (.../contracts/node_modules/@bundlr-network/client/build/src/fund.js:29:29)
    at Generator.next (<anonymous>)
    at fulfilled (.../contracts/node_modules/@bundlr-network/client/node_modules/tslib/tslib.js:114:62)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:74180) UnhandledPromiseRejectionWarning: Unhandled promise rejection...

using "version": "0.3.0"

js-sha256 causes warnings, and can be safely removed (code attached)

The js-sha256 module isn't necessary in current (last 10 years) browsers and causes warnings:

Use of eval in "node_modules/js-sha256/src/sha256.js" is strongly discouraged as it poses security risks and may cause issues with minification.

All current browsers provide SHA256 natively. See https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypto/digest

const getSHA256Hash = async (input) => {
  const textAsBuffer = new TextEncoder().encode(input);
  const hashBuffer = await window.crypto.subtle.digest("SHA-256", textAsBuffer);
  const hashArray = Array.from(new Uint8Array(hashBuffer));
  const hash = hashArray
    .map((item) => item.toString(16).padStart(2, "0"))
    .join("");
  return hash;
};

Large file / video uploads not working (>100mb)

I'm working on a YouTube type of application and having an issue uploading larger videos.

Smaller videos work great, but I am having issues with videos in the range of 100MB or more.

Here is the error message I'm getting:

Screen Shot 2022-05-09 at 5 05 52 PM

Here is the code (next.js app):

// initializing bundlr in pages/_app.js
  async function initialiseBundlr() {
    await window.ethereum.enable()
  
    const provider = new providers.Web3Provider(window.ethereum);
    await provider._ready()
  
    const bundlr = new WebBundlr("https://node1.bundlr.network", "matic", provider)
    await bundlr.ready()
    
    setBundlrInstance(bundlr)
    bundlrRef.current = bundlr
    fetchBalance()
  }
// main code in pages/index.js
import BigNumber from 'bignumber.js'
import { useContext, useState } from 'react'
import { MainContext } from '../context'

export default function Home() {
  const [file, setFile] = useState()
  const [image, setImage] = useState()
  const [URI, setURI] = useState()
  const [amount, setAmount] = useState()
  const { bundlrInstance, initialiseBundlr, balance, fetchBalance } = useContext(MainContext)
  async function initialize() {
    initialiseBundlr()
  }
  function onFileChange(e) {
    const file = e.target.files[0]
    if (file) {
      const image = URL.createObjectURL(file)
      setImage(image)
      let reader = new FileReader()
      reader.onload = function () {
        if (reader.result) {
          setFile(Buffer.from(reader.result))
          console.log('file set...')
        }
      }
      reader.readAsArrayBuffer(file)
    }
  }

  async function uploadFile() {
    const tags = [{ name: 'Content-Type', value: 'video/mp4' }];
    bundlrInstance.useChunking = true
    let tx = await bundlrInstance.uploader.upload(file, tags)
    console.log('tx: ', tx)
    setURI(`http://arweave.net/${tx.data.id}`)

  }

  async function fundWallet() {
    if (!amount) return
    const amountParsed = parseInput(amount)
    let response = await bundlrInstance.fund(amountParsed)
    console.log('Wallet funded: ', response)
    fetchBalance()
  }

  function parseInput (input) {
    const conv = new BigNumber(input).multipliedBy(bundlrInstance.currencyConfig.base[1])
    if (conv.isLessThan(1)) {
      console.log('error: value too small')
      return
    } else {
      return conv
    }
  }

  return (
    <div style={containerStyle}>
      {
        !balance && <button onClick={initialize}>Initialize</button>
      }
      {
        balance && (
          <div>
            <h3>Balance: {balance}</h3>
            <div style={{ padding: '20px 0px'}}>
              <input onChange={e => setAmount(e.target.value)} />
              <button onClick={fundWallet}>Fund Wallet</button>
            </div>
            <input
              type="file"
              onChange={onFileChange}
            />
            <button onClick={uploadFile}>Upload File</button>
            {
              image && (
                <video width="320" height="240" controls>
                  <source src={image} type="video/mp4"/>
                </video>
              )

            }
            {
              URI && <a href={URI}>{URI}</a>
            }
          </div>
        )
      }
    </div>
  )
}

const containerStyle = {
  padding: '100px 20px'
}

[demo app] Can not fund my test account in local

I want to try Bundlr in testnet, but the balance is always equal to 0, even though I have added some test eth from faucets

const bundlerHttpAddress = 'https://devnet.bundlr.network'

const currency = 'ethereum'
const privateKey =
  'my-private-key'
const bundlr = new Bundlr(bundlerHttpAddress, currency, privateKey, {
  providerUrl: 'https://rinkeby.infura.io/v3/',
  contractAddress: '0x11D634457F99595aBE7B582739fd52b7ed48995A',   // https://rinkeby.etherscan.io/address/0x11D634457F99595aBE7B582739fd52b7ed48995A
})

const address = await bundlr.address
const converted = bundlr.utils.unitConverter(balance)

converted === 0

image

image

Error: HTTP Error: Posting transaction (Testnet)

Trying to fund the wallet with GoerliETH gives these errors:

I use this to initialize bundlr

const initialiseBundlr = async () => {
        const provider = new providers.Web3Provider(window.ethereum as any);
        await provider._ready();
        const bundlr = new WebBundlr(
            "https://devnet.bundlr.network",
            "ethereum",
            provider,
            {
                providerUrl:
                    process.env.ALCHEMY_RPC_URL,
            }
        );
        await bundlr.ready();
        setBundlrInstance(bundlr);
    }

It also gives the warning
"Tx 0xecd7dd59d82f5b591c54cd859fd8847c80cabea38ae3222fcaa8fb952b472224 didn't finalize after 30 seconds"

The same procedure worked for matic but somehow not for ethereum.

Incorrect Solana Wallet Balance

Hi

I have a really strange issue whereby the getLoadedBalance method returns a completely wrong amount compared to what I actually have in my wallet and what is shown in the error message when attempting to fund the transfer.

I've checked the providerUrl and wallet address values are the same so not sure what else it could be.

$ solana balance
0.006704023 SOL
const bundlr = new Bundlr(
          'https://devnet.bundlr.network',
          'solana',
          key,
          {
            timeout: 60000,
            providerUrl: 'https://api.devnet.solana.com',
          },
        );

const balance = await bundlr.getLoadedBalance();
console.log(balance.toNumber() / LAMPORTS);
// returns 4.477788768

const tx = bundlr.createTransaction(data, opts)
const size = tx.size
const cost = await bundlr.getPrice(size);
console.log(cost.toNumber() / LAMPORTS);
// returns 0.00000136

await bundlr.fund(cost.minus(balance));
// returns {"error":{"logs":["Program 11111111111111111111111111111111 invoke [1]","Transfer: insufficient lamports 6699023, need 4477787408","Program 11111111111111111111111111111111 failed: custom program error: 0x1"]}

Typo in the docs

In the example of lazy funding, balance check is wrong

// If you don't have enough balance for the upload
if (balance.isGreaterThan(price)) {
...
}

it should be balance.isLessThan

// If you don't have enough balance for the upload
if (balance.isLessThan(price)) {
...
}

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

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.

Add Optimism

In the docs here Optimism is listed as supported, but from what I can tell here Optimism support has not yet been added to the JS library.

"^0.10.5" When uploading, garbage values are included at the end.

Hi there

There is an issue when using bundlr.upload to upload metadata

let response = await bundlr.upload(JSON.stringify(metadata, null, 2)); let tokenURI = "https://arweave.net/" + response.id; console.log(Metadata uploaded ==> ${tokenURI});

cat file
{ "name": "name #1", "description": "Description metadata", "image": "https://arweave.net/t0i_Cg4lFTz7_AsIRAiqOEQJJe80KwW26J3-07dsSKE" }%

When viewing the file with cat, there are garbage values at the end. However, it is fine when uploading the file.

Error: SubtleCrypto not available! when initializing WebBundlr

  • NextJS v12.1.5
  • React v17.0.2
  • Bundlr v0.11.9

Running into the error Error: SubtleCrypto not available! when trying to load Bundlr in the browser via:

const bundlr = new WebBundlr(
   "https://devnet.bundlr.network",
   "matic",
   provider
);

Stack trace:

Uncaught     at new WebCryptoDriver (file:///Users/user/projects/project/node_modules/arweave/web/lib/crypto/webcrypto-driver.js:10:19)
    at Object.<anonymous> (file:///Users/user/projects/project/node_modules/arweave/web/common.js:120:18)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1209:10)
    at Module.load (node:internal/modules/cjs/loader:1033:32)
    at Function.Module._load (node:internal/modules/cjs/loader:868:12)
    at Module.require (node:internal/modules/cjs/loader:1057:19)
    at require (node:internal/modules/cjs/helpers:103:18)
    at Object.<anonymous> (file:///Users/user/projects/project/node_modules/arweave/web/index.js:17:18)
    at Module._compile (node:internal/modules/cjs/loader:1155:14)

Maybe looks like there's an underlying dependency issue with arweave, but I'm not sure how to resolve this. I took a look at this issue but it's unclear what my next step should be other than to mess around with different versions.

Any suggestions on how to proceed?

"Uncaught ReferenceError: process is not defined" when using Vite with WebBundlr

Using WebBundlr with Vite creates error.

import { WebBundlr } from "@bundlr-network/client";

In util.js:109 file that uses process:

if (process.env.NODE_DEBUG) {

Dependencies:

"@bundlr-network/client": "^0.10.5",
"vite": "^4.2.0",

You can surpass some errors like this with vite.config.ts

export default defineConfig({
  plugins: [preact(), tsconfigPaths()],
  define: {
    'process.env': {}
  }
})

But still new errors arises like Buffer object etc.

Cannot get final name for export 'concatBuffers'

I've just upgraded from Bundlr -> Irys and I'm getting the following error:

frontend:build: ../../node_modules/@irys/sdk/build/esm/web/irys.js + 52 modules
frontend:build: Cannot get final name for export 'concatBuffers' of ../../node_modules/@irys/sdk/node_modules/arbundles/build/web/esm/src/webUtils.js

error TS1005: '?' expected.

Error: node_modules/@irys/query/build/cjs/types.d.ts:50:58 - error TS1005: '?' expected.
[K in keyof T]?: T[K] extends (infer U extends object)[] ? Field : T[K] extends object ? Field<T[K]> : boolean;

"typescript": "~4.6.4"

Devnet bundlr node doesn't recognize devnet solana account balance

How do you fund the account on devnet? We are trying using the CLI and a SOL devnet keypair and are getting the below error

Transaction simulation failed: Attempt to debit an account but found no record of a prior credit. 
    
Error whilst funding: failed to send transaction: Transaction simulation failed: Attempt to debit an account but found no record of a prior credit. 

How to merge transactions: Fund Bundlr + Upload file + Call some solana program

I have been playing around with the source code of your JS demo. But having to fill so many inputs and click on so many buttons makes for a terrible user experience on real websites. I have seen that transactions are supported so I was wondering if it would be possible to join all the steps on a single Solana transaction?

For instance, if I try to:

  • Fund Bundlr account with some Solana.
  • Upload a PNG image to arweave.
  • Send the arweave's URL hash of the uploaded file to some other Solana program.
# Example of what I am trying to achieve (this code doesn't work)
const walletAdapter = new PhantomWalletAdapter();
await walletAdapter.connect();
const webBundlr = new WebBundlr("https://devnet.bundlr.network", "solana", walletAdapter, {providerUrl: "https://api.devnet.solana.com"});

const tags = [{name: "Content-Type", value: "image/png"}];
const transaction = bundlr.createTransaction(SOME_FILE_DATA, { tags: tags })
transaction.add(bundler.fund(SOME_AMOUNT))
transaction.add(INTRUCTION_TO_OTHER_SOLANA_PROGRAM_USING_THE_IMAGE_HASH)
await transaction.sign()
const id = (await transaction.upload()).data.id

These are my doubts:

  • Would it be possible to run all these operations on a single transaction (if not maybe just some of them)?
  • How can I pass SOME_FILE_DATA using WebBundlr? because your example doesn't work on web browsers:
    const data = fs.readFileSync("data.txt");
    
  • Is there a way to know the hash of the uploaded file in advance so it can be used by the last instruction?(INTRUCTION_TO_OTHER_SOLANA_PROGRAM_USING_THE_IMAGE_HASH)

Docs

Hi guys,

Not sure where to put this as the docs repo link is broken.

  1. Github link to docs is broken. Where's the docs repo?
  2. Did this page mean price.minus(balance)?

image

GraphQL query not returning proper values based on tags after being posted then mined with Bundlr + Arweave

Hi, so I've been trying out the bundlr JS client, specifically the WebBundlr client, and I'm experiencing issues having the data mined to the network.

I've also noticed that there are a couple of different ways you all have referenced sending a transaction. For example, in the demo application you use this syntax:

await bundler?.uploader.upload(img, [{ name: "Content-Type", value: "image/png" }])

But in the documentation I see this:

const transaction = bundlr.createTransaction(data, { tags });

await transaction.sign();
await transaction.upload();

As for me, I've tried both, and am not sure if there is also maybe something I'm doing wrong in my code. Here's a look at essentially what I'm doing:

async function connect() {
    await window.ethereum.request({ method: 'eth_requestAccounts' })
    const provider = new providers.Web3Provider(window.ethereum);
    await provider._ready()
  
    const bundlr = new WebBundlr("https://node1.bundlr.network", "matic", provider)
    await bundlr.ready()
  
    setBundlrInstance(bundlr)
  }

/* create a transaction (plain text, JSON, file, image, video, etc..) */
async function createTransaction() {
  const data = "hello world"
  const tags = [
    { name: 'App-Name', value: 'PublicSquare' },
    { name: 'Content-Type', value: 'text/plain' },
    { name: 'Version', value: '1.0.1' },
    { name: 'Type', value: 'post' }
  ]

  const transaction = bundlrInstance.createTransaction(data, { tags })

  await transaction.sign()
  await transaction.upload()

  console.log('transaction id: ', transaction.id)
}

The data seems to be saving to the network, but after a while it is dropped.

I have had one or two transactions mined, but I've been doing so much experimentation I'm not sure why those worked but my others did not.

Is there anything that I should know that might help me understand better how this works?

Thanks for your time.

Cannot upload a file paying with solana token

This command

irys upload metadata.json -h https://node1.irys.xyz -t solana -w <my private key>

gives an error

Loaded address: <my address>
Error whilst uploading file: Not enough balance for transaction

even though my address has ~10 usd on balance

solana balance
0.09908193 SOL

Axios Cross-Site Request Forgery Vulnerability

Steps to Reproduce:

  1. npm install @irys/sdk
  2. npm audit
# npm audit report

axios  0.8.1 - 1.5.1
Severity: moderate
Axios Cross-Site Request Forgery Vulnerability - https://github.com/advisories/GHSA-wf5p-g6vw-rhxx
No fix available
node_modules/aptos/node_modules/axios
  aptos  <=1.13.3
  Depends on vulnerable versions of axios
  node_modules/aptos
    @irys/sdk  *
    Depends on vulnerable versions of aptos
    node_modules/@irys/sdk

Error initialising Bundlr client when using the CLI

I am trying to get the estimated price for uploading 1000 bytes to bundlr, using -c currency "solana", on -h host https://node1.bundlr.network:

bundlr price 1000 -c solana -h https://node1.bundlr.network

I get this error when I run this command:
Error whilst getting price: Error initialising Bundlr client - The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined

Why am I not able to get the price with this tool? It is mentioned here and here in the docs:
https://docs.bundlr.network/docs/client/cli#check-the-price-of-a-bundlr-node
https://docs.bundlr.network/docs/hidden/client/upload-with-solana#fund-a-bundler-with-sol

New Aptos TS SDK Integration

Aptos released a new TS SDK and it is recommended to migrate over to it for its benefits and support and also because the legacy one is not currently developed and/or maintained anymore.

I can clone and look at the irys Aptos implementation and start the migration but wondering if there is anything we should keep in mind while doing it? are there any side effects for a complete migration? should we keep both implementation for a grace period?

Appreciate your help!

Utils return wrong price ?

Hi runned into issue with uploading imgs im using solana + WebBundlr and randomly getting not enough funds error when trying to upload img. i also tried different functions to get img byte size and getting same results for example Buffer.byteLength(buff). when i add something like 500 bytes "margin" for all imgs it works all the time.

is this some problem with price fcn or im missing something in my code? thanks

code:

export const uploadImage = async (
  imageFile: Buffer,
  cluster: string,
  rpcEndpoint: string,
  wallet: SignerWalletAdapter
) => {
  const bundlr = await initBundlr(cluster, rpcEndpoint, wallet);
  if (!bundlr) return;
  if (imageFile == null) return;

  const loadedBalance = await bundlr.getLoadedBalance();
  const balance = bundlr.utils.unitConverter(loadedBalance.toNumber());
  const balanceNum = balance.toNumber();

  const price = await bundlr.utils.getPrice("solana", imageFile.length);
  const amount = bundlr.utils.unitConverter(price);
  const amountNum = amount.toNumber();

  if (balanceNum < amountNum) {
    await bundlr.fund(Math.ceil((amountNum - balanceNum) * LAMPORTS_PER_SOL));
  }

  const imageResult = await bundlr.uploader.upload(imageFile, {
    tags: [{ name: "Content-Type", value: "image/png" }],
  });

  const arweaveImageUrl = `https://arweave.net/${imageResult.data.id}?ext=png`;

  return arweaveImageUrl;
};

Priority Fees for Solana

The Solana network is quite congested at the moment. Transaction priority fees don't seem to be wired in for payments in SOL.
There seems to be a to-do in

async createTx(amount: BigNumber.Value, to: string, _fee?: string): Promise<{ txId: string | undefined; tx: any }> {
to use the currently unused _fee parameter in createTx. This is almost essential these days.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.