Irys-xyz / arweave-js-sdk

JS SDK for Irys on Arweave
110 stars 95 forks source link

How to check if the signed tx is already submitted? #39

Closed LiveDuo closed 2 years ago

LiveDuo commented 2 years ago

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.

JesseTheRobot commented 2 years ago

The signing prompt ('connection modal') is solely so that WebBundlr can get the user's public key/address - no data is actually submitted anywhere - but this means that this prompt effectively always has to occur. There is, however, work being put into removing this step of the process - but I cannot give you a definite timeframe for when/if this change will be released. As a side note; as long as you are re-using the same WebBundlr instance, a user should only have to interact with the connection modal once per site visit - it should be noted that a separate modal for each upload is, however, unavoidable.

LiveDuo commented 2 years ago

The signing prompt ('connection modal') is solely so that WebBundlr can get the user's public key/address - no data is actually submitted anywhere - but this means that this prompt effectively always has to occur.

If I understand upload calls getSigner that has a different implementation for each chain.

https://github.com/Bundlr-Network/js-client/blob/28e623312b2012e652a3931093b3c6b874b1790a/src/common/upload.ts#L40

https://github.com/Bundlr-Network/js-client/blob/28e623312b2012e652a3931093b3c6b874b1790a/src/web/currencies/ethereum.ts#L47

Then if this.signer is null, InjectedEthereumSigner creates a new signer:

https://github.com/Bundlr-Network/js-client/blob/28e623312b2012e652a3931093b3c6b874b1790a/src/web/currencies/ethereum.ts#L11

Are the function above the relevant ones for ethereum?

JesseTheRobot commented 2 years ago

Yup, InjectedEthereumSigner is the signer that creates the connection modal.