Update to use published packages. Update types. Update readme. Fix tests.
This commit is contained in:
165
package-lock.json
generated
165
package-lock.json
generated
@@ -12,11 +12,11 @@
|
|||||||
"@bitauth/libauth": "^3.0.0",
|
"@bitauth/libauth": "^3.0.0",
|
||||||
"@electrum-cash/protocol": "^2.3.1",
|
"@electrum-cash/protocol": "^2.3.1",
|
||||||
"@generalprotocols/oracle-client": "^0.0.1-development.11945476152",
|
"@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/engine": "file:../engine",
|
||||||
"@xo-cash/state": "file:../state",
|
"@xo-cash/state": "file:../state",
|
||||||
"@xo-cash/templates": "file:../templates",
|
"@xo-cash/templates": "^0.0.1",
|
||||||
"@xo-cash/types": "file:../types",
|
"@xo-cash/types": "^0.0.1",
|
||||||
"better-sqlite3": "^12.6.2",
|
"better-sqlite3": "^12.6.2",
|
||||||
"clipboardy": "^5.1.0",
|
"clipboardy": "^5.1.0",
|
||||||
"ink": "^6.6.0",
|
"ink": "^6.6.0",
|
||||||
@@ -41,38 +41,6 @@
|
|||||||
"vitest": "^4.1.2"
|
"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": {
|
"../engine": {
|
||||||
"name": "@xo-cash/engine",
|
"name": "@xo-cash/engine",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
@@ -85,7 +53,8 @@
|
|||||||
"@electrum-cash/servers": "^3.1.0",
|
"@electrum-cash/servers": "^3.1.0",
|
||||||
"@xo-cash/crypto": "0.0.1",
|
"@xo-cash/crypto": "0.0.1",
|
||||||
"@xo-cash/primitives": "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/types": "0.0.1",
|
||||||
"@xo-cash/utils": "0.0.1",
|
"@xo-cash/utils": "0.0.1",
|
||||||
"eventemitter3": "^5.0.1"
|
"eventemitter3": "^5.0.1"
|
||||||
@@ -108,14 +77,11 @@
|
|||||||
"typescript": "^5.3.2",
|
"typescript": "^5.3.2",
|
||||||
"typescript-eslint": "^8.53.1",
|
"typescript-eslint": "^8.53.1",
|
||||||
"vitest": "^4.0.17"
|
"vitest": "^4.0.17"
|
||||||
},
|
|
||||||
"engines": {
|
|
||||||
"node": ">=18.0.0"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"../state": {
|
"../state": {
|
||||||
"name": "@xo-cash/state",
|
"name": "@xo-cash/state",
|
||||||
"version": "0.0.1",
|
"version": "0.0.2",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@bitauth/libauth": "^3.1.0-next.8",
|
"@bitauth/libauth": "^3.1.0-next.8",
|
||||||
@@ -147,60 +113,6 @@
|
|||||||
"vitest": "^4.0.17"
|
"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": {
|
"node_modules/@alcalzone/ansi-tokenize": {
|
||||||
"version": "0.2.4",
|
"version": "0.2.4",
|
||||||
"resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.2.4.tgz",
|
"resolved": "https://registry.npmjs.org/@alcalzone/ansi-tokenize/-/ansi-tokenize-0.2.4.tgz",
|
||||||
@@ -971,24 +883,77 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/@xo-cash/crypto": {
|
"node_modules/@xo-cash/crypto": {
|
||||||
"resolved": "../crypto",
|
"version": "0.0.1",
|
||||||
"link": true
|
"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": {
|
"node_modules/@xo-cash/engine": {
|
||||||
"resolved": "../engine",
|
"resolved": "../engine",
|
||||||
"link": true
|
"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": {
|
"node_modules/@xo-cash/state": {
|
||||||
"resolved": "../state",
|
"resolved": "../state",
|
||||||
"link": true
|
"link": true
|
||||||
},
|
},
|
||||||
"node_modules/@xo-cash/templates": {
|
"node_modules/@xo-cash/templates": {
|
||||||
"resolved": "../templates",
|
"version": "0.0.1",
|
||||||
"link": true
|
"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": {
|
"node_modules/@xo-cash/types": {
|
||||||
"resolved": "../types",
|
"version": "0.0.1",
|
||||||
"link": true
|
"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": {
|
"node_modules/ansi-escapes": {
|
||||||
"version": "7.2.0",
|
"version": "7.2.0",
|
||||||
|
|||||||
@@ -34,11 +34,11 @@
|
|||||||
"@bitauth/libauth": "^3.0.0",
|
"@bitauth/libauth": "^3.0.0",
|
||||||
"@electrum-cash/protocol": "^2.3.1",
|
"@electrum-cash/protocol": "^2.3.1",
|
||||||
"@generalprotocols/oracle-client": "^0.0.1-development.11945476152",
|
"@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/engine": "file:../engine",
|
||||||
"@xo-cash/state": "file:../state",
|
"@xo-cash/state": "file:../state",
|
||||||
"@xo-cash/templates": "file:../templates",
|
"@xo-cash/templates": "^0.0.1",
|
||||||
"@xo-cash/types": "file:../types",
|
"@xo-cash/types": "^0.0.1",
|
||||||
"better-sqlite3": "^12.6.2",
|
"better-sqlite3": "^12.6.2",
|
||||||
"clipboardy": "^5.1.0",
|
"clipboardy": "^5.1.0",
|
||||||
"ink": "^6.6.0",
|
"ink": "^6.6.0",
|
||||||
|
|||||||
@@ -13,6 +13,9 @@ git clone git@gitlab.com:GeneralProtocols/xo/engine.git
|
|||||||
# Move into teh engine directory
|
# Move into teh engine directory
|
||||||
cd engine
|
cd engine
|
||||||
|
|
||||||
|
# Checkout the cli-test branch
|
||||||
|
git checkout cli-test
|
||||||
|
|
||||||
# Install the dependencies
|
# Install the dependencies
|
||||||
npm ci
|
npm ci
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import type {
|
|||||||
AcceptInvitationParameters,
|
AcceptInvitationParameters,
|
||||||
AppendInvitationParameters,
|
AppendInvitationParameters,
|
||||||
Engine,
|
Engine,
|
||||||
FindSuitableResourcesParameters,
|
GetSpendableResourcesParameters,
|
||||||
} from "@xo-cash/engine";
|
} from "@xo-cash/engine";
|
||||||
import { hasInvitationExpired, mergeInvitationCommits } from "@xo-cash/engine";
|
import { hasInvitationExpired, mergeInvitationCommits } from "@xo-cash/engine";
|
||||||
import type {
|
import type {
|
||||||
@@ -483,12 +483,27 @@ export class Invitation extends EventEmitter<InvitationEventMap> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findSuitableResources(
|
async findSuitableResources(
|
||||||
options: Partial<FindSuitableResourcesParameters> = {},
|
options: Partial<GetSpendableResourcesParameters> = {},
|
||||||
): Promise<UnspentOutputData[]> {
|
): 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
|
// Find the suitable resources
|
||||||
const { unspentOutputs } = await this.engine.findSuitableResources(
|
const { unspentOutputs } = await this.engine.getSpendableResources(
|
||||||
this.data,
|
this.data,
|
||||||
options,
|
resolvedOptions,
|
||||||
);
|
);
|
||||||
|
|
||||||
// Update the status of the invitation
|
// Update the status of the invitation
|
||||||
|
|||||||
@@ -132,13 +132,12 @@ export const resolveProvidedLockingBytecodeHex = (
|
|||||||
variableValues: Record<string, string>,
|
variableValues: Record<string, string>,
|
||||||
): string | undefined => {
|
): string | undefined => {
|
||||||
const outputDefinition = template.outputs?.[outputIdentifier];
|
const outputDefinition = template.outputs?.[outputIdentifier];
|
||||||
if (!outputDefinition || typeof outputDefinition.lockscript !== "string")
|
if (!outputDefinition || typeof outputDefinition.lockingScript !== "string") {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
const lockingScriptDefinition = (
|
const lockingScriptDefinition = template.lockingScripts?.[outputDefinition.lockingScript];
|
||||||
template.lockingScripts as Record<string, unknown> | undefined
|
const scriptIdentifier = lockingScriptDefinition?.lockingBytecode;
|
||||||
)?.[outputDefinition.lockscript] as { lockingScript?: string } | undefined;
|
|
||||||
const scriptIdentifier = lockingScriptDefinition?.lockingScript;
|
|
||||||
if (!scriptIdentifier) return undefined;
|
if (!scriptIdentifier) return undefined;
|
||||||
|
|
||||||
const scriptExpression = (
|
const scriptExpression = (
|
||||||
|
|||||||
@@ -73,7 +73,7 @@ export const addFakeResource = async (
|
|||||||
outpointTransactionHash: options.outpointTransactionHash ?? randomTxHash(),
|
outpointTransactionHash: options.outpointTransactionHash ?? randomTxHash(),
|
||||||
minedAtHeight: options.minedAtHeight ?? 800000,
|
minedAtHeight: options.minedAtHeight ?? 800000,
|
||||||
valueSatoshis: options.valueSatoshis ?? 10000,
|
valueSatoshis: options.valueSatoshis ?? 10000,
|
||||||
lockingBytecode:
|
scriptHash:
|
||||||
options.lockingBytecode ??
|
options.lockingBytecode ??
|
||||||
"76a914000000000000000000000000000000000000000088ac",
|
"76a914000000000000000000000000000000000000000088ac",
|
||||||
reservedBy: options.reservedBy,
|
reservedBy: options.reservedBy,
|
||||||
@@ -131,7 +131,7 @@ export const unreserveResource = async (
|
|||||||
export const createMockEngine = async (seed: string) => {
|
export const createMockEngine = async (seed: string) => {
|
||||||
// Create the in-memory storage adapter.
|
// Create the in-memory storage adapter.
|
||||||
const storage = await createStorageAdapter({
|
const storage = await createStorageAdapter({
|
||||||
storageType: StorageType.INMEMORY,
|
storageType: "inmemory",
|
||||||
accountHash: binToHex(sha256.hash(convertMnemonicToSeedBytes(seed))),
|
accountHash: binToHex(sha256.hash(convertMnemonicToSeedBytes(seed))),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user