WietseWind / xrpl-accountlib

XRPL Account helper: generation, derivation and signing (family seed, mnemonic, passphrase)
MIT License
27 stars 12 forks source link

Aufofill with `signAndSubmit` #314

Closed tequdev closed 7 months ago

tequdev commented 11 months ago

Fixed to do autofill in the signAndSubmit method as in xrpl.js.

WietseWind commented 11 months ago

Thank you!

I don't think this should be executed by default, always. This is a decision:

sign and submit means exactly this: Sign and Submit what has been passed. By adding auto network & account property filling to the method, the method doesn't do what it the name suggests, it does more.

Another problem is that this is a breaking change (this lib is all over the place).

The way I feel this should be implemented is a separate (new) method, that wraps around signAndSubmit, adding the network values first so the developer passed colliding properties prevail.

E.g.:

prefilledSignAndSubmit(...)

Where this would basically do this (pseudocode):

const prefilledSignAndSubmit = async (
  transaction: Object,
  client: XrplClient | string,
  account: Account | Account[]
) => {
  rerturn signAndSubmit({
     // First the vals, so these are always defined
    ...(await utils.txNetworkAndAccountValues(client, transaction?.Account)).txValues,
    // Then the passed tx, so duplicate props overrule as tx comes last
    ...transaction,
  })
}
tequdev commented 11 months ago

I created this PR because Fee was eligible for autofill.

Of course I respect your decision.

I'll create another PR for prefilledSignAndSubmit👍