Using the javascript sdk, I'm sending a payment like so:
const operation = Operation.payment({
destination: toAddress,
asset: asset,
amount: amount.toString()
});
const account = await server.loadAccount(address);
const transactionBuilder = new StellarSdk.TransactionBuilder(account);
transactionBuilder.addOperation(operation);
const transaction = transactionBuilder.build();
transaction.sign(this.keys);
const payment = await this.server.submitTransaction(transaction);
This works well, but I also want to get the operation record for that transaction.
It seems that the type of payment
should be TransactionRecord:
interface TransactionRecord extends Record {
id: string;
paging_token: string;
hash: string;
ledger_attr: number;
created_at: string;
max_fee: number;
fee_paid: number;
operation_count: number;
result_code: number;
result_code_s: string;
source_account: string;
source_account_sequence: string;
envelope_xdr: string;
result_xdr: string;
result_meta_xdr: string;
memo: string;
account: CallFunction<AccountRecord>;
effects: CallCollectionFunction<EffectRecord>;
ledger: CallFunction<LedgerRecord>;
operations: CallCollectionFunction<OperationRecord>;
precedes: CallFunction<TransactionRecord>;
self: CallFunction<TransactionRecord>;
succeeds: CallFunction<TransactionRecord>;
}
But when I try to do this:
(await payment.operations())._embedded.records[0] as PaymentOperationRecord;
I get an error because payment.operations
is undefined
.
I logged the value of payment
and it was something like:
{
_links: {
transaction: {
href: '...'
}
},
hash: '...',
ledger: 0000000,
envelope_xdr: '...',
result_xdr: '...',
result_meta_xdr: '...'
}
Am I mistaken in thinking that the type of the result should be TransactionRecord
? And if so, what is this type? I couldn't find anything in the typescript definition files to match it, and the official documentation doesn't say much about it.
Thanks.