Update to use published packages. Update types. Update readme. Fix tests.

This commit is contained in:
2026-05-04 04:45:31 +00:00
parent 531e53d2ae
commit ccfaf3fd70
7 changed files with 1352 additions and 1381 deletions

165
package-lock.json generated
View File

@@ -12,11 +12,11 @@
"@bitauth/libauth": "^3.0.0",
"@electrum-cash/protocol": "^2.3.1",
"@generalprotocols/oracle-client": "^0.0.1-development.11945476152",
"@xo-cash/crypto": "file:../crypto",
"@xo-cash/crypto": "^0.0.1",
"@xo-cash/engine": "file:../engine",
"@xo-cash/state": "file:../state",
"@xo-cash/templates": "file:../templates",
"@xo-cash/types": "file:../types",
"@xo-cash/templates": "^0.0.1",
"@xo-cash/types": "^0.0.1",
"better-sqlite3": "^12.6.2",
"clipboardy": "^5.1.0",
"ink": "^6.6.0",
@@ -41,38 +41,6 @@
"vitest": "^4.1.2"
}
},
"../crypto": {
"name": "@xo-cash/crypto",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"@bitauth/libauth": "^3.1.0-next.8",
"@xo-cash/primitives": "0.0.1",
"@xo-cash/types": "0.0.1"
},
"devDependencies": {
"@chalp/eslint-airbnb": "^1.3.0",
"@generalprotocols/cspell-dictionary": "^1.0.1",
"@stylistic/eslint-plugin": "^5.7.0",
"@typescript-eslint/eslint-plugin": "^8.53.1",
"@typescript-eslint/parser": "^8.53.1",
"@vitest/coverage-v8": "^4.0.17",
"@viz-kit/esbuild-analyzer": "^1.0.0",
"@xo-cash/eslint-config": "1.0.1",
"cspell": "^9.6.0",
"eslint": "^9.39.2",
"prettier": "^3.6.2",
"tsdown": "^0.20.0-beta.4",
"typedoc": "^0.28.16",
"typedoc-plugin-coverage": "^4.0.2",
"typescript": "^5.3.2",
"typescript-eslint": "^8.53.1",
"vitest": "^4.0.17"
},
"engines": {
"node": ">=18.0.0"
}
},
"../engine": {
"name": "@xo-cash/engine",
"version": "0.0.1",
@@ -85,7 +53,8 @@
"@electrum-cash/servers": "^3.1.0",
"@xo-cash/crypto": "0.0.1",
"@xo-cash/primitives": "0.0.1",
"@xo-cash/state": "0.0.1",
"@xo-cash/state": "0.0.2",
"@xo-cash/templates": "0.0.1",
"@xo-cash/types": "0.0.1",
"@xo-cash/utils": "0.0.1",
"eventemitter3": "^5.0.1"
@@ -108,14 +77,11 @@
"typescript": "^5.3.2",
"typescript-eslint": "^8.53.1",
"vitest": "^4.0.17"
},
"engines": {
"node": ">=18.0.0"
}
},
"../state": {
"name": "@xo-cash/state",
"version": "0.0.1",
"version": "0.0.2",
"license": "MIT",
"dependencies": {
"@bitauth/libauth": "^3.1.0-next.8",
@@ -147,60 +113,6 @@
"vitest": "^4.0.17"
}
},
"../templates": {
"name": "@xo-cash/templates",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"@xo-cash/types": "0.0.1-development.13504604083"
},
"devDependencies": {
"@chalp/eslint-airbnb": "^1.3.0",
"@generalprotocols/cspell-dictionary": "^1.0.1",
"@stylistic/eslint-plugin": "^5.7.0",
"@typescript-eslint/eslint-plugin": "^8.53.1",
"@typescript-eslint/parser": "^8.53.1",
"@vitest/coverage-v8": "^4.0.17",
"@viz-kit/esbuild-analyzer": "^1.0.0",
"@xo-cash/eslint-config": "1.0.1",
"cspell": "^9.6.0",
"eslint": "^9.39.2",
"prettier": "^3.6.2",
"tsdown": "^0.20.0-beta.4",
"typedoc": "^0.28.16",
"typedoc-plugin-coverage": "^4.0.2",
"typescript": "^5.3.2",
"typescript-eslint": "^8.53.1",
"vitest": "^4.0.17"
}
},
"../types": {
"name": "@xo-cash/types",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"@bitauth/libauth": "^3.1.0-next.8"
},
"devDependencies": {
"@chalp/eslint-airbnb": "^1.3.0",
"@generalprotocols/cspell-dictionary": "^1.0.1",
"@stylistic/eslint-plugin": "^5.7.0",
"@typescript-eslint/eslint-plugin": "^8.53.1",
"@typescript-eslint/parser": "^8.53.1",
"@vitest/coverage-v8": "^4.0.17",
"@viz-kit/esbuild-analyzer": "^1.0.0",
"@xo-cash/eslint-config": "1.0.1",
"cspell": "^9.6.0",
"eslint": "^9.39.2",
"prettier": "^3.6.2",
"tsdown": "^0.20.0-beta.4",
"typedoc": "^0.28.16",
"typedoc-plugin-coverage": "^4.0.2",
"typescript": "^5.3.2",
"typescript-eslint": "^8.53.1",
"vitest": "^4.0.17"
}
},
"node_modules/@alcalzone/ansi-tokenize": {
"version": "0.2.4",
"resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.2.4.tgz",
@@ -971,24 +883,77 @@
}
},
"node_modules/@xo-cash/crypto": {
"resolved": "../crypto",
"link": true
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@xo-cash/crypto/-/crypto-0.0.1.tgz",
"integrity": "sha512-ZIa9MHAVCBJqo5uxyx/Tx/jTSyyJw1cfYfI48gEHqBIl5wyyxiZDx4eZvVWSr8uKgS5Tm3FXUkKQybvk5QGRIQ==",
"license": "MIT",
"dependencies": {
"@bitauth/libauth": "^3.1.0-next.8",
"@xo-cash/primitives": "0.0.1",
"@xo-cash/types": "0.0.1"
}
},
"node_modules/@xo-cash/crypto/node_modules/@bitauth/libauth": {
"version": "3.1.0-next.8",
"resolved": "https://registry.npmjs.org/@bitauth/libauth/-/libauth-3.1.0-next.8.tgz",
"integrity": "sha512-Pm+Ju+YP3JeBLLTiVrBnia2wwE4G17r4XqpvPRMcklElJTe8J6x3JgKRg1by0Xm3ZY6UFxACkEAoSA+x419/zA==",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/@xo-cash/engine": {
"resolved": "../engine",
"link": true
},
"node_modules/@xo-cash/primitives": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@xo-cash/primitives/-/primitives-0.0.1.tgz",
"integrity": "sha512-medxVK9Sawj7oIDhWvTjTgzwf6BjGao6CXtQYJOUFi6NOO1eclb1PDjEmkG/4NeK3v7LQIN8QS60mTAGyS9FXg==",
"license": "MIT",
"dependencies": {
"@bitauth/libauth": "^3.1.0-next.8"
}
},
"node_modules/@xo-cash/primitives/node_modules/@bitauth/libauth": {
"version": "3.1.0-next.8",
"resolved": "https://registry.npmjs.org/@bitauth/libauth/-/libauth-3.1.0-next.8.tgz",
"integrity": "sha512-Pm+Ju+YP3JeBLLTiVrBnia2wwE4G17r4XqpvPRMcklElJTe8J6x3JgKRg1by0Xm3ZY6UFxACkEAoSA+x419/zA==",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/@xo-cash/state": {
"resolved": "../state",
"link": true
},
"node_modules/@xo-cash/templates": {
"resolved": "../templates",
"link": true
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@xo-cash/templates/-/templates-0.0.1.tgz",
"integrity": "sha512-v5f0YeH9Bw6lNThdE0fI878T4L2jbM8RI1quxdKxnvqHn9hu2jzebqvveEB2TfJWG3sP1GpE1go0Yn87R4sXfw==",
"license": "MIT",
"dependencies": {
"@xo-cash/types": "0.0.1"
}
},
"node_modules/@xo-cash/types": {
"resolved": "../types",
"link": true
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/@xo-cash/types/-/types-0.0.1.tgz",
"integrity": "sha512-BMwh2Y9+LqnTXYmdA7Nxi1NuK+AcsNWFoFGJVAvuY5TBfsbNIzWppjmrI2fAyj/RlSE3tATMxam+6CJb3RnDIA==",
"license": "MIT",
"dependencies": {
"@bitauth/libauth": "^3.1.0-next.8"
}
},
"node_modules/@xo-cash/types/node_modules/@bitauth/libauth": {
"version": "3.1.0-next.8",
"resolved": "https://registry.npmjs.org/@bitauth/libauth/-/libauth-3.1.0-next.8.tgz",
"integrity": "sha512-Pm+Ju+YP3JeBLLTiVrBnia2wwE4G17r4XqpvPRMcklElJTe8J6x3JgKRg1by0Xm3ZY6UFxACkEAoSA+x419/zA==",
"license": "MIT",
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
}
},
"node_modules/ansi-escapes": {
"version": "7.2.0",

View File

@@ -34,11 +34,11 @@
"@bitauth/libauth": "^3.0.0",
"@electrum-cash/protocol": "^2.3.1",
"@generalprotocols/oracle-client": "^0.0.1-development.11945476152",
"@xo-cash/crypto": "file:../crypto",
"@xo-cash/crypto": "^0.0.1",
"@xo-cash/engine": "file:../engine",
"@xo-cash/state": "file:../state",
"@xo-cash/templates": "file:../templates",
"@xo-cash/types": "file:../types",
"@xo-cash/templates": "^0.0.1",
"@xo-cash/types": "^0.0.1",
"better-sqlite3": "^12.6.2",
"clipboardy": "^5.1.0",
"ink": "^6.6.0",

View File

@@ -13,6 +13,9 @@ git clone git@gitlab.com:GeneralProtocols/xo/engine.git
# Move into teh engine directory
cd engine
# Checkout the cli-test branch
git checkout cli-test
# Install the dependencies
npm ci

View File

@@ -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

View File

@@ -132,13 +132,12 @@ export const resolveProvidedLockingBytecodeHex = (
variableValues: Record<string, string>,
): string | undefined => {
const outputDefinition = template.outputs?.[outputIdentifier];
if (!outputDefinition || typeof outputDefinition.lockscript !== "string")
if (!outputDefinition || typeof outputDefinition.lockingScript !== "string") {
return undefined;
}
const lockingScriptDefinition = (
template.lockingScripts as Record<string, unknown> | undefined
)?.[outputDefinition.lockscript] as { lockingScript?: string } | undefined;
const scriptIdentifier = lockingScriptDefinition?.lockingScript;
const lockingScriptDefinition = template.lockingScripts?.[outputDefinition.lockingScript];
const scriptIdentifier = lockingScriptDefinition?.lockingBytecode;
if (!scriptIdentifier) return undefined;
const scriptExpression = (

View File

@@ -73,7 +73,7 @@ export const addFakeResource = async (
outpointTransactionHash: options.outpointTransactionHash ?? randomTxHash(),
minedAtHeight: options.minedAtHeight ?? 800000,
valueSatoshis: options.valueSatoshis ?? 10000,
lockingBytecode:
scriptHash:
options.lockingBytecode ??
"76a914000000000000000000000000000000000000000088ac",
reservedBy: options.reservedBy,
@@ -131,7 +131,7 @@ export const unreserveResource = async (
export const createMockEngine = async (seed: string) => {
// Create the in-memory storage adapter.
const storage = await createStorageAdapter({
storageType: StorageType.INMEMORY,
storageType: "inmemory",
accountHash: binToHex(sha256.hash(convertMnemonicToSeedBytes(seed))),
});

File diff suppressed because it is too large Load Diff