XRPLF / xrpl.js

A JavaScript/TypeScript API for interacting with the XRP Ledger in Node.js and the browser
https://xrpl.org/
1.2k stars 511 forks source link

'Account' does not exist in type 'SignerEntry' #1843

Closed mrosendin closed 2 years ago

mrosendin commented 2 years ago

I'm getting this TypeScript error on v2.0.2.

Screen Shot 2021-12-01 at 10 27 10 AM

SignerEntry interface

Reproducible code:

import xrpl, { SignerListSet, TxResponse } from "xrpl"

const client = new xrpl.Client('wss://s.altnet.rippletest.net:51233')

/**
 * @function createSignersList
 * Setup the signers list
 */
export async function createSignersList(): Promise<TxResponse> {
  console.log("Creating signers list.")
  const address = await getAddress()
  const { wallet } = await client.fundWallet()
  const tx: SignerListSet = {
    TransactionType: "SignerListSet",
    Account: address,
    SignerEntries: [
      {
        Account: address,
        SignerWeight: 1
      }
    ],
    SignerQuorum: 1
  }
  await client.connect()
  return await client.submitAndWait(tx, {
    wallet
  })
}
JST5000 commented 2 years ago

SignerEntry is a weird object because it has a single-field named SignerEntry, which then has the Account and SignerWeight data. So, your code should actually look like:

SignerEntries: [
   {
       SignerEntry: {
            Account: address,
            SignerWeight: 1
       }
   }
JST5000 commented 2 years ago

Here's the type definition for it: https://github.com/XRPLF/xrpl.js/blob/3e7a722a4cbdb53d1e219fa62fc778147a098390/packages/xrpl/src/models/common/index.ts#L62-L67

mrosendin commented 2 years ago

Thanks @JST5000! I'd be curious to know if the SignerEntry key is intentional. In any case, that solves it.

JST5000 commented 2 years ago

Thanks @JST5000! I'd be curious to know if the SignerEntry key is intentional. In any case, that solves it.

Yeah, unfortunately it's awkward either way (If you try to pull it out, then you end up with SignerEntries becoming Array<{ SignerEntry: SignerEntry }> which isn't great either.)