@xcapit/shelter-sdk
Version:
SDK for Shelter smart contracts on Stellar
24 lines (23 loc) • 718 B
JavaScript
import { rpc } from "@stellar/stellar-sdk";
export class SimulatedTransaction {
_rawTx;
_signer;
_rpc;
constructor(_rawTx, _signer, _rpc) {
this._rawTx = _rawTx;
this._signer = _signer;
this._rpc = _rpc;
}
async result() {
const tx = this._rawTx.built;
const simTx = await this._rpc.server().simulateTransaction(tx);
const completeTx = this._rpc.assembleTransaction(tx, simTx).build();
completeTx.sign(this._signer);
return await this._txData(completeTx);
}
async _txData(tx) {
return await this._rpc
.server()
.pollTransaction((await this._rpc.server().sendTransaction(tx)).hash);
}
}