Add import template into tui. Fix tests that fail on macos. Fix some updates.
This commit is contained in:
@@ -625,34 +625,26 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
||||
);
|
||||
}
|
||||
|
||||
console.dir(this.data, { depth: null });
|
||||
|
||||
// Create a list of all the variables from the commits
|
||||
const variables = this.data.commits.flatMap(
|
||||
(c) => c.data?.variables ?? [],
|
||||
);
|
||||
console.dir(variables, { depth: null });
|
||||
|
||||
// Create a dictionary of the variables
|
||||
const formattedVariables = variables.reduce(
|
||||
(acc, v) => {
|
||||
const { variableIdentifier, value } = v;
|
||||
console.log(typeof value);
|
||||
acc[variableIdentifier ?? ""] = value;
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, XOInvitationVariableValue>,
|
||||
);
|
||||
|
||||
console.dir(formattedVariables, { depth: null });
|
||||
|
||||
// Compile the CashAssembly expression to get the value satoshis (It handles the variable replacement for us)
|
||||
const valueSatoshis = compileCashAssemblyString(
|
||||
{ cashAssemblyText: String(valueSatoshisExpression), variables: formattedVariables, evaluationDecodeMode: 'bigint' },
|
||||
);
|
||||
|
||||
console.dir(valueSatoshis, { depth: null });
|
||||
|
||||
// Return the value satoshis as a bigint
|
||||
// TODO: Check this of a vulnerability or crash - I assume there might be one if someone made the `valueSatoshis` a malicious expression
|
||||
return BigInt(valueSatoshis);
|
||||
@@ -707,11 +699,9 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
||||
for (const output of outputs) {
|
||||
if (typeof output === "string") {
|
||||
const sats = await this.getSatsOut(output);
|
||||
console.log(`Sats for output: ${output} is ${sats}`);
|
||||
totalSats += sats
|
||||
} else {
|
||||
const sats = await this.getSatsOut(output.output);
|
||||
console.log(`Sats for output: ${output.output} is ${sats}`);
|
||||
totalSats += sats;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user