Skip to content

Commit

Permalink
Use it only if friendbot is actually failing
Browse files Browse the repository at this point in the history
  • Loading branch information
Shaptic committed Nov 14, 2024
1 parent 6dc5f91 commit 5cc207b
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/rpc/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -977,14 +977,18 @@ export class RpcServer {
`${friendbotUrl}?addr=${encodeURIComponent(account)}`
);

const txMeta = await this.getTransaction(response.data.hash)
if (txMeta.status !== Api.GetTransactionStatus.SUCCESS) {
throw new Error(`Funding account ${address} failed`);
let meta: xdr.TransactionMeta;
if (!response.data.result_meta_xdr) {
const txMeta = await this.getTransaction(response.data.hash)
if (txMeta.status !== Api.GetTransactionStatus.SUCCESS) {
throw new Error(`Funding account ${address} failed`);
}
meta = txMeta.resultMetaXdr;
} else {
meta = xdr.TransactionMeta.fromXDR(response.data.result_meta_xdr, 'base64');
}

const sequence = findCreatedAccountSequenceInTransactionMeta(
txMeta.resultMetaXdr
);
const sequence = findCreatedAccountSequenceInTransactionMeta(meta);
return new Account(account, sequence);
} catch (error: any) {
if (error.response?.status === 400) {
Expand Down

0 comments on commit 5cc207b

Please sign in to comment.