Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AuthAccounts with AMMBid should be unique and !=sfAccount [Version: rippled-2.2.2] #5184

Open
tequdev opened this issue Nov 7, 2024 · 1 comment · May be fixed by #5203
Open

AuthAccounts with AMMBid should be unique and !=sfAccount [Version: rippled-2.2.2] #5184

tequdev opened this issue Nov 7, 2024 · 1 comment · May be fixed by #5203

Comments

@tequdev
Copy link
Contributor

tequdev commented Nov 7, 2024

Issue Description

Steps to Reproduce

import { encode, encodeForSigning } from 'ripple-binary-codec'
import { sign } from 'ripple-keypairs'
import { type AMMBid, AccountSetAsfFlags, Client, Wallet, xrpToDrops } from 'xrpl'

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

const main = async () => {
  await client.connect()

  const account = (await client.fundWallet()).wallet

  console.log(account.address)

  await client.submitAndWait(
    {
      TransactionType: 'AccountSet',
      Account: account.address,
      SetFlag: AccountSetAsfFlags.asfDefaultRipple,
    },
    { wallet: account },
  )

  await client.submitAndWait(
    {
      TransactionType: 'AMMCreate',
      Account: account.address,
      Amount: xrpToDrops('10'),
      Amount2: {
        issuer: account.address,
        currency: 'TST',
        value: '1000000000',
      },
      TradingFee: 0.001,
    },
    { wallet: account },
  )

  const response = await client.request({
    command: 'amm_info',
    asset: {
      currency: 'XRP',
    },
    asset2: {
      issuer: account.address,
      currency: 'TST',
    },
  })
  const lpToken = response.result.amm.lp_token

  const acountInfo = await client.request({ command: 'account_info', account: account.address })
  const Sequence = acountInfo.result.account_data.Sequence
  const ledgerIndex = await client.getLedgerIndex()

  const tx = {
    TransactionType: 'AMMBid',
    Account: account.address,
    Fee: '100',
    Asset: {
      currency: 'XRP',
    },
    Asset2: {
      issuer: account.address,
      currency: 'TST',
    },
    BidMax: {
      ...lpToken,
      value: '10000',
    },
    AuthAccounts: [
      { AuthAccount: { Account: account.address } },
      { AuthAccount: { Account: account.address } },
      { AuthAccount: { Account: account.address } },
      { AuthAccount: { Account: account.address } },
    ],
    Sequence: Sequence,
    SigningPubKey: account.publicKey,
    LastLedgerSequence: ledgerIndex + 4,
  } as AMMBid

  tx.TxnSignature = sign(encodeForSigning(tx), account.privateKey)

  const tx_blob = encode(tx)

  await client.submitAndWait(tx_blob)

  await client.disconnect()
}

main()

Expected Result

Transaction should be failed.

Actual Result

https://testnet.xrpl.org/transactions/D458FC31A063FAD895E122343A9FB6003918043781041CA6508EE814B2DC05C8/simple

Environment

rippled-2.2.2 (testnet)

Supporting Files

スクリーンショット 2024-11-07 14 50 28
@tequdev
Copy link
Contributor Author

tequdev commented Dec 5, 2024

#5203

@mvadari mvadari linked a pull request Dec 5, 2024 that will close this issue
9 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant