stellar / typescript-wallet-sdk

Typescript Wallet SDK to build Stellar wallets
Apache License 2.0
20 stars 6 forks source link

Error when trying to create account #103

Closed yanielbf closed 5 months ago

yanielbf commented 6 months ago

What version are you using?

1.3.1

What did you do?

I am using React Native with Expo. I am triying to create account in Stellar Ledger

function generateRandomKeypair() {
  let wallet = new Wallet({
    stellarConfiguration: StellarConfiguration.TestNet(),
  });
  const account = wallet.stellar().account();
  const randomBytes = Crypto.getRandomBytes(32);
  return account.createKeypairFromRandom(Buffer.from(randomBytes));
}

async function handlerCreateAccount() {
    const parentAccount = SigningKeypair.fromSecret(
      "SBW5TWYWFRGPPCSBMLN2K7HDMKWUGLFPF5FMMSZQX7CT65EIQ5V5L43N"
    );
    const childAccount = generateRandomKeypair();

    let wallet = new Wallet({
      stellarConfiguration: StellarConfiguration.TestNet(),
    });
    const txBuilder = await wallet.stellar().transaction({
      sourceAddress: parentAccount,
    });
    const tx = txBuilder.createAccount(childAccount).build();
    parentAccount.sign(tx);
    await wallet.stellar().submitTransaction(tx);
}

I tested in codesanbox for react project and it's throwing same error

https://codesandbox.io/p/sandbox/loving-dewdney-s9n2dq?file=%2Fsrc%2FApp.js%3A25%2C29

What did you expect to see?

Create new account in Stellar Ledger

What did you see instead?

node_modules\@stellar\typescript-wallet-sdk\src\walletSdk\Horizon\Transaction\TransactionBuilder.ts

image

Imagen de WhatsApp 2024-03-08 a las 01 18 09_4d14815a

image

acharb commented 5 months ago

hey @yanielbf thanks for pointing this out. This was fixed in our 1.4.0 release which was just published. If you upgrade to that version it should be fixed