Skip to content

Commit

Permalink
stellar#76: use better approach to iterate list of auths from pr feed…
Browse files Browse the repository at this point in the history
…back
  • Loading branch information
sreuland committed May 11, 2023
1 parent 4384b3f commit ec786ab
Showing 1 changed file with 9 additions and 15 deletions.
24 changes: 9 additions & 15 deletions src/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ export function assembleTransaction(
}

const source = new Account(raw.source, `${parseInt(raw.sequence, 10) - 1}`);
const authDecoratedHostFunctions: xdr.HostFunction[] = [];

const txnBuilder = new TransactionBuilder(source, {
// automatically update the tx fee based on suggested fees from simulation response
fee: Math.max(
Expand All @@ -64,19 +62,15 @@ export function assembleTransaction(
extraSigners: raw.extraSigners,
});

// apply the pre-built Auth from simulation onto each Tx/Op/HostFunction invocation
for (
let hostFnIndex = 0;
hostFnIndex < simulation.results.length;
hostFnIndex++
) {
const rawHostFunction: xdr.HostFunction =
rawInvokeHostFunctionOp.functions[hostFnIndex];
const simHostFunctionResult: SorobanRpc.SimulateHostFunctionResult =
simulation.results[hostFnIndex];
rawHostFunction.auth(buildContractAuth(simHostFunctionResult.auth));
authDecoratedHostFunctions.push(rawHostFunction);
}
// apply the pre-built Auth from simulation onto each Tx/Op/HostFunction
// invocation
const authDecoratedHostFunctions = simulation.results.map(
(functionSimulationResult, i) => {
const hostFn: xdr.HostFunction = rawInvokeHostFunctionOp.functions[i];
hostFn.auth(buildContractAuth(functionSimulationResult.auth));
return hostFn;
},
);

txnBuilder.addOperation(
Operation.invokeHostFunctions({
Expand Down

0 comments on commit ec786ab

Please sign in to comment.