Update to use published packages. Update types. Update readme. Fix tests.
This commit is contained in:
@@ -2,7 +2,7 @@ import type {
|
||||
AcceptInvitationParameters,
|
||||
AppendInvitationParameters,
|
||||
Engine,
|
||||
FindSuitableResourcesParameters,
|
||||
GetSpendableResourcesParameters,
|
||||
} from "@xo-cash/engine";
|
||||
import { hasInvitationExpired, mergeInvitationCommits } from "@xo-cash/engine";
|
||||
import type {
|
||||
@@ -483,12 +483,27 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
||||
}
|
||||
|
||||
async findSuitableResources(
|
||||
options: Partial<FindSuitableResourcesParameters> = {},
|
||||
options: Partial<GetSpendableResourcesParameters> = {},
|
||||
): Promise<UnspentOutputData[]> {
|
||||
const templateIdentifier =
|
||||
options.templateIdentifier ?? this.data.templateIdentifier;
|
||||
const template = await this.engine.getTemplate(templateIdentifier);
|
||||
const fallbackOutputIdentifier = Object.keys(template?.outputs ?? {})[0];
|
||||
if (!fallbackOutputIdentifier && !options.outputIdentifier) {
|
||||
throw new Error(
|
||||
`No output identifiers found for template: ${templateIdentifier}`,
|
||||
);
|
||||
}
|
||||
|
||||
const resolvedOptions: GetSpendableResourcesParameters = {
|
||||
templateIdentifier,
|
||||
outputIdentifier: options.outputIdentifier ?? fallbackOutputIdentifier ?? "",
|
||||
};
|
||||
|
||||
// Find the suitable resources
|
||||
const { unspentOutputs } = await this.engine.findSuitableResources(
|
||||
const { unspentOutputs } = await this.engine.getSpendableResources(
|
||||
this.data,
|
||||
options,
|
||||
resolvedOptions,
|
||||
);
|
||||
|
||||
// Update the status of the invitation
|
||||
|
||||
Reference in New Issue
Block a user