@chironbuilder/ootle-sdk 0.1.29 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bucketStealthTransfer.d.ts +12 -0
- package/dist/bucketStealthTransfer.d.ts.map +1 -0
- package/dist/bucketStealthTransfer.js +57 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/indexerDecode.d.ts +23 -0
- package/dist/indexerDecode.d.ts.map +1 -0
- package/dist/indexerDecode.js +68 -0
- package/dist/storage.d.ts +11 -0
- package/dist/storage.d.ts.map +1 -1
- package/dist/utxoScan.d.ts +24 -39
- package/dist/utxoScan.d.ts.map +1 -1
- package/dist/utxoScan.js +136 -133
- package/dist/wallet.d.ts +28 -8
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.js +166 -82
- package/package.json +8 -8
- package/vendor/ootle-wasm-patched/chiron-0.49.2.patch +199 -0
- package/vendor/ootle-wasm-patched/ootle_wasm.d.ts +53 -35
- package/vendor/ootle-wasm-patched/ootle_wasm.js +1 -1
- package/vendor/ootle-wasm-patched/ootle_wasm_bg.js +158 -45
- package/vendor/ootle-wasm-patched/ootle_wasm_bg.wasm +0 -0
- package/vendor/ootle-wasm-patched/ootle_wasm_bg.wasm.d.ts +15 -12
- package/vendor/ootle-wasm-patched/package.json +3 -3
- package/vendor/ootle-patched/README.md +0 -67
- package/vendor/ootle-patched/dist/index.d.ts +0 -2158
- package/vendor/ootle-patched/dist/index.js +0 -1389
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/README.md +0 -128
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm.d.ts +0 -436
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm.js +0 -9
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm_bg.js +0 -1450
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/ootle_wasm_bg.wasm +0 -0
- package/vendor/ootle-patched/node_modules/@tari-project/ootle-wasm/package.json +0 -30
- package/vendor/ootle-patched/package.json +0 -23
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StealthTransfer } from "@tari-project/ootle";
|
|
2
|
+
import type { Instruction } from "@tari-project/ootle-ts-bindings";
|
|
3
|
+
export declare class BucketStealthTransfer extends StealthTransfer {
|
|
4
|
+
private bucketVar;
|
|
5
|
+
private followUps;
|
|
6
|
+
/** Reveal `amount` to `receiver` and keep it on the workspace as `workspaceVarName`. */
|
|
7
|
+
toRevealedOutputAsBucket(amount: bigint, workspaceVarName: string, receiver: Uint8Array): this;
|
|
8
|
+
/** Instructions appended after the stealth transfer (they may reference the bucket). */
|
|
9
|
+
andThen(instructions: Instruction[]): this;
|
|
10
|
+
constructor(...args: ConstructorParameters<typeof StealthTransfer>);
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=bucketStealthTransfer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bucketStealthTransfer.d.ts","sourceRoot":"","sources":["../src/bucketStealthTransfer.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AAanE,qBAAa,qBAAsB,SAAQ,eAAe;IACxD,OAAO,CAAC,SAAS,CAAuB;IACxC,OAAO,CAAC,SAAS,CAAqB;IAEtC,wFAAwF;IACxF,wBAAwB,CAAC,MAAM,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,EAAE,QAAQ,EAAE,UAAU,GAAG,IAAI;IAQ9F,wFAAwF;IACxF,OAAO,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,IAAI;gBAK9B,GAAG,IAAI,EAAE,qBAAqB,CAAC,OAAO,eAAe,CAAC;CAuBnE"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// A `StealthTransfer` whose revealed output is left on the workspace as a named bucket (instead of
|
|
2
|
+
// being deposited back into the source account), followed by caller-supplied instructions that
|
|
3
|
+
// consume it in the same transaction. This is what `withdrawStealthAndExecute` needs; upstream
|
|
4
|
+
// `@tari-project/ootle` only offers `toRevealedOutput`, which always deposits the revealed amount.
|
|
5
|
+
//
|
|
6
|
+
// Replaces the vendored ootle.ts 0.3 fork (`@chironbuilder/ootle-legacy`): everything except the
|
|
7
|
+
// final "what happens to the revealed bucket" step is the upstream builder's own code, so the
|
|
8
|
+
// statement / input / signer handling tracks upstream releases automatically.
|
|
9
|
+
import { StealthTransfer } from "@tari-project/ootle";
|
|
10
|
+
// `emitInstructions` is a (TS-)private method of the upstream class; reach it via the prototype.
|
|
11
|
+
const baseEmit = StealthTransfer.prototype.emitInstructions;
|
|
12
|
+
if (typeof baseEmit !== "function") {
|
|
13
|
+
throw new Error("@tari-project/ootle StealthTransfer no longer has emitInstructions(); BucketStealthTransfer needs updating");
|
|
14
|
+
}
|
|
15
|
+
export class BucketStealthTransfer extends StealthTransfer {
|
|
16
|
+
bucketVar = null;
|
|
17
|
+
followUps = [];
|
|
18
|
+
/** Reveal `amount` to `receiver` and keep it on the workspace as `workspaceVarName`. */
|
|
19
|
+
toRevealedOutputAsBucket(amount, workspaceVarName, receiver) {
|
|
20
|
+
if (this.bucketVar !== null && this.bucketVar !== workspaceVarName) {
|
|
21
|
+
throw new Error(`toRevealedOutputAsBucket: already saving to "${this.bucketVar}"`);
|
|
22
|
+
}
|
|
23
|
+
this.bucketVar = workspaceVarName;
|
|
24
|
+
return this.toRevealedOutput(amount, receiver);
|
|
25
|
+
}
|
|
26
|
+
/** Instructions appended after the stealth transfer (they may reference the bucket). */
|
|
27
|
+
andThen(instructions) {
|
|
28
|
+
this.followUps.push(...instructions);
|
|
29
|
+
return this;
|
|
30
|
+
}
|
|
31
|
+
constructor(...args) {
|
|
32
|
+
super(...args);
|
|
33
|
+
// Shadow the upstream (TS-private) emitInstructions on this instance: emit withdraw +
|
|
34
|
+
// StealthTransfer exactly as upstream, minus its trailing deposit, then save the bucket.
|
|
35
|
+
Object.defineProperty(this, "emitInstructions", {
|
|
36
|
+
value: (statement) => {
|
|
37
|
+
const self = this;
|
|
38
|
+
if (this.bucketVar === null) {
|
|
39
|
+
baseEmit.call(this, statement);
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
const saved = self.state.revealedOutput;
|
|
43
|
+
self.state.revealedOutput = null;
|
|
44
|
+
try {
|
|
45
|
+
baseEmit.call(this, statement);
|
|
46
|
+
}
|
|
47
|
+
finally {
|
|
48
|
+
self.state.revealedOutput = saved;
|
|
49
|
+
}
|
|
50
|
+
self.builder.saveVar(this.bucketVar);
|
|
51
|
+
}
|
|
52
|
+
if (this.followUps.length > 0)
|
|
53
|
+
self.builder.withInstructions(this.followUps);
|
|
54
|
+
},
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -23,5 +23,5 @@ export type { UtxosDeltaResult, UtxosPageResult, UtxoScanWatermark } from "./utx
|
|
|
23
23
|
export { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
|
|
24
24
|
export { chromeStorageAdapter, inMemoryAdapter, localStorageAdapter } from "./adapters.js";
|
|
25
25
|
export type { FeeType, HtlcClaimOptions, HtlcFundOptions, HtlcFundResult, HtlcSpendResult, PrivateBalance, TokenBalance } from "./wallet.js";
|
|
26
|
-
export { OotleAccount, assertValidMinimumValuePromise, buildHtlcSpendStatement, extractMissingSubstateAddress, extractStaleLockVersion, forgetKnownVersions, pollTransactionResult, recoverPendingShields, resetKnownVersions, resolveInputsWithRetry, resolveSendPrivatelyPlan, resolveUnshieldPlan, selectPrivateFeeUtxo, selectShieldedUtxosForAmount, selectUnspentShieldedOutputs, substateExists, summarizePrivateHoldings, synthesizeShieldedOnlyBalances, } from "./wallet.js";
|
|
26
|
+
export { OotleAccount, assertValidMinimumValuePromise, buildHtlcSpendStatement, extractMissingSubstateAddress, extractStaleLockVersion, forgetKnownVersions, pollTransactionResult, recoverPendingShields, FeeCommittedError, FeeBookkeepingError, resetKnownVersions, resolveInputsWithRetry, resolveSendPrivatelyPlan, resolveUnshieldPlan, selectPrivateFeeUtxo, selectShieldedUtxosForAmount, selectUnspentShieldedOutputs, substateExists, summarizePrivateHoldings, synthesizeShieldedOnlyBalances, } from "./wallet.js";
|
|
27
27
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEhF,OAAO,EACL,wBAAwB,EACxB,iCAAiC,EACjC,6BAA6B,EAC7B,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,YAAY,EAAE,sBAAsB,EAAE,eAAe,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AACrH,OAAO,EAAE,sBAAsB,EAAE,gBAAgB,EAAE,wBAAwB,EAAE,2BAA2B,EAAE,MAAM,gBAAgB,CAAC;AAEjI,YAAY,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACrF,OAAO,EAAE,+BAA+B,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAEhG,YAAY,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEpD,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,0BAA0B,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAEhI,YAAY,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACtD,OAAO,EAAE,4BAA4B,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAEzE,YAA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B,cAAc,EACd,uBAAuB,EACvB,kBAAkB,EAClB,eAAe,GAChB,MAAM,cAAc,CAAC;AAEtB,YAAY,EAAE,gBAAgB,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAC1F,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAE9D,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAE3F,YAAY,EAAE,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC7I,OAAO,EACL,YAAY,EACZ,8BAA8B,EAC9B,uBAAuB,EACvB,6BAA6B,EAC7B,uBAAuB,EACvB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,sBAAsB,EACtB,wBAAwB,EACxB,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,4BAA4B,EAC5B,cAAc,EACd,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,aAAa,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -14,4 +14,4 @@ export { withTimeout } from "./timeout.js";
|
|
|
14
14
|
export { addPendingShield, addShieldedOutput, clearUtxoScanPageCursor, configureOotleStorage, getKnownVersions, getPrivatePaymentScanCursor, getPrivatePaymentScanResume, getUtxoScanPageCursor, getUtxoScanWatermarks, listPendingShields, listShieldedOutputs, localAccountId, markShieldedOutputSpent, reviveShieldedOutput, removePendingShield, serialized, setKnownVersions, setPrivatePaymentScanCursor, setPrivatePaymentScanResume, setUtxoScanPageCursor, setUtxoScanWatermarks, wipeOotleState, CommitmentReservedError, RESERVATION_TTL_MS, listHtlcJournal, } from "./storage.js";
|
|
15
15
|
export { scanUtxosDelta, scanUtxosPage } from "./utxoScan.js";
|
|
16
16
|
export { chromeStorageAdapter, inMemoryAdapter, localStorageAdapter } from "./adapters.js";
|
|
17
|
-
export { OotleAccount, assertValidMinimumValuePromise, buildHtlcSpendStatement, extractMissingSubstateAddress, extractStaleLockVersion, forgetKnownVersions, pollTransactionResult, recoverPendingShields, resetKnownVersions, resolveInputsWithRetry, resolveSendPrivatelyPlan, resolveUnshieldPlan, selectPrivateFeeUtxo, selectShieldedUtxosForAmount, selectUnspentShieldedOutputs, substateExists, summarizePrivateHoldings, synthesizeShieldedOnlyBalances, } from "./wallet.js";
|
|
17
|
+
export { OotleAccount, assertValidMinimumValuePromise, buildHtlcSpendStatement, extractMissingSubstateAddress, extractStaleLockVersion, forgetKnownVersions, pollTransactionResult, recoverPendingShields, FeeCommittedError, FeeBookkeepingError, resetKnownVersions, resolveInputsWithRetry, resolveSendPrivatelyPlan, resolveUnshieldPlan, selectPrivateFeeUtxo, selectShieldedUtxosForAmount, selectUnspentShieldedOutputs, substateExists, summarizePrivateHoldings, synthesizeShieldedOnlyBalances, } from "./wallet.js";
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { IndexerProvider } from "@tari-project/ootle-indexer";
|
|
2
|
+
/** Decodes a substate value if it is a base64 CBOR string; returns objects unchanged. */
|
|
3
|
+
export declare function substateValueOf<T = any>(value: unknown): T;
|
|
4
|
+
/** Decodes an `ExecuteResult` if it is a base64 CBOR string; returns objects/null unchanged. */
|
|
5
|
+
export declare function executeResultOf<T = any>(value: unknown): T;
|
|
6
|
+
export declare function eventOf<T = any>(value: unknown): T;
|
|
7
|
+
export declare function utxoValueOf<T = any>(value: unknown): T;
|
|
8
|
+
/** `getSubstate` response with `state.up.substate` decoded. */
|
|
9
|
+
export declare function decodeSubstateResponse<T = any>(response: any): T;
|
|
10
|
+
export declare function getSubstateDecoded(provider: IndexerProvider, substateId: string, version?: number | null): Promise<any>;
|
|
11
|
+
/** `fetchSubstates` with each entry given the pre-0.48 `{ version, substate }` shape. */
|
|
12
|
+
export declare function fetchSubstatesDecoded(provider: IndexerProvider, ids: string[]): Promise<{
|
|
13
|
+
substates: Record<string, {
|
|
14
|
+
version: number;
|
|
15
|
+
substate: any;
|
|
16
|
+
} | undefined>;
|
|
17
|
+
}>;
|
|
18
|
+
/** Decodes `Finalized.execution_result` (and nested event blobs) in a transaction-result response. */
|
|
19
|
+
export declare function decodeTransactionResultResponse<T = any>(response: any): T;
|
|
20
|
+
/** An `ExecuteResult` with any CBOR-string events also decoded. */
|
|
21
|
+
export declare function decodeExecuteResultDeep<T = any>(value: unknown): T;
|
|
22
|
+
export declare function getTransactionResultDecoded(provider: IndexerProvider, transactionId: string): Promise<any>;
|
|
23
|
+
//# sourceMappingURL=indexerDecode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexerDecode.d.ts","sourceRoot":"","sources":["../src/indexerDecode.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAEnE,yFAAyF;AACzF,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAE1D;AAED,gGAAgG;AAChG,wBAAgB,eAAe,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAE1D;AAED,wBAAgB,OAAO,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAElD;AAED,wBAAgB,WAAW,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAEtD;AAED,+DAA+D;AAC/D,wBAAgB,sBAAsB,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,CAKhE;AAED,wBAAsB,kBAAkB,CAAC,QAAQ,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,GAAG,CAAC,CAE7H;AAED,yFAAyF;AACzF,wBAAsB,qBAAqB,CAAC,QAAQ,EAAE,eAAe,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC;IAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,GAAG,CAAA;KAAE,GAAG,SAAS,CAAC,CAAA;CAAE,CAAC,CAQ5K;AAED,sGAAsG;AACtG,wBAAgB,+BAA+B,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,GAAG,GAAG,CAAC,CAUzE;AAED,mEAAmE;AACnE,wBAAgB,uBAAuB,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,EAAE,OAAO,GAAG,CAAC,CAOlE;AAED,wBAAsB,2BAA2B,CAAC,QAAQ,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAEhH"}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// Ootle 0.48+ indexers serve substate values, execution results, events and UTXOs as base64 CBOR
|
|
2
|
+
// blobs (tari-ootle #3100/#3101/#3110). The SDK's own readers were written against the decoded
|
|
3
|
+
// JSON shapes, so every internal read goes through these helpers, which decode once and hand back
|
|
4
|
+
// the pre-0.48 shape. Values that are already objects (an older JSON indexer) pass through, so the
|
|
5
|
+
// helpers are safe against either server.
|
|
6
|
+
//
|
|
7
|
+
// Upstream `@tari-project/ootle` code (StealthTransfer, resolveTransaction, ...) is still handed
|
|
8
|
+
// the raw provider: it expects the encoded shapes itself.
|
|
9
|
+
import { decodeEvent, decodeExecuteResult, decodeSubstateValue, decodeUtxo } from "@tari-project/ootle";
|
|
10
|
+
/** Decodes a substate value if it is a base64 CBOR string; returns objects unchanged. */
|
|
11
|
+
export function substateValueOf(value) {
|
|
12
|
+
return (typeof value === "string" ? decodeSubstateValue(value) : value);
|
|
13
|
+
}
|
|
14
|
+
/** Decodes an `ExecuteResult` if it is a base64 CBOR string; returns objects/null unchanged. */
|
|
15
|
+
export function executeResultOf(value) {
|
|
16
|
+
return (typeof value === "string" ? decodeExecuteResult(value) : value);
|
|
17
|
+
}
|
|
18
|
+
export function eventOf(value) {
|
|
19
|
+
return (typeof value === "string" ? decodeEvent(value) : value);
|
|
20
|
+
}
|
|
21
|
+
export function utxoValueOf(value) {
|
|
22
|
+
return (typeof value === "string" ? decodeUtxo(value) : value);
|
|
23
|
+
}
|
|
24
|
+
/** `getSubstate` response with `state.up.substate` decoded. */
|
|
25
|
+
export function decodeSubstateResponse(response) {
|
|
26
|
+
if (response && response.state && typeof response.state === "object" && "up" in response.state) {
|
|
27
|
+
return { ...response, state: { up: { ...response.state.up, substate: substateValueOf(response.state.up.substate) } } };
|
|
28
|
+
}
|
|
29
|
+
return response;
|
|
30
|
+
}
|
|
31
|
+
export async function getSubstateDecoded(provider, substateId, version) {
|
|
32
|
+
return decodeSubstateResponse(await provider.getSubstate(substateId, version));
|
|
33
|
+
}
|
|
34
|
+
/** `fetchSubstates` with each entry given the pre-0.48 `{ version, substate }` shape. */
|
|
35
|
+
export async function fetchSubstatesDecoded(provider, ids) {
|
|
36
|
+
const response = (await provider.fetchSubstates(ids));
|
|
37
|
+
const substates = {};
|
|
38
|
+
for (const [id, entry] of Object.entries(response.substates ?? {})) {
|
|
39
|
+
if (!entry)
|
|
40
|
+
continue;
|
|
41
|
+
substates[id] = { ...entry, substate: substateValueOf(entry.value ?? entry.substate) };
|
|
42
|
+
}
|
|
43
|
+
return { ...response, substates };
|
|
44
|
+
}
|
|
45
|
+
/** Decodes `Finalized.execution_result` (and nested event blobs) in a transaction-result response. */
|
|
46
|
+
export function decodeTransactionResultResponse(response) {
|
|
47
|
+
const result = response?.result;
|
|
48
|
+
if (result && typeof result === "object" && "Finalized" in result) {
|
|
49
|
+
const finalized = result.Finalized;
|
|
50
|
+
return {
|
|
51
|
+
...response,
|
|
52
|
+
result: { Finalized: { ...finalized, execution_result: decodeExecuteResultDeep(finalized.execution_result) } },
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
/** An `ExecuteResult` with any CBOR-string events also decoded. */
|
|
58
|
+
export function decodeExecuteResultDeep(value) {
|
|
59
|
+
const decoded = executeResultOf(value);
|
|
60
|
+
const events = decoded?.finalize?.events;
|
|
61
|
+
if (Array.isArray(events) && events.some((e) => typeof e === "string")) {
|
|
62
|
+
return { ...decoded, finalize: { ...decoded.finalize, events: events.map(eventOf) } };
|
|
63
|
+
}
|
|
64
|
+
return decoded;
|
|
65
|
+
}
|
|
66
|
+
export async function getTransactionResultDecoded(provider, transactionId) {
|
|
67
|
+
return decodeTransactionResultResponse(await provider.getTransactionResult(transactionId));
|
|
68
|
+
}
|
package/dist/storage.d.ts
CHANGED
|
@@ -39,6 +39,17 @@ export interface PendingShield {
|
|
|
39
39
|
ownCommitment?: string;
|
|
40
40
|
/** This account's own memo for the operation, if any. */
|
|
41
41
|
memo?: string;
|
|
42
|
+
/**
|
|
43
|
+
* The private fee this transaction pays, if any. Stored with the pending entry because the fee phase
|
|
44
|
+
* commits on its own: an `AcceptFeeRejectRest` result still spends the fee UTXO and creates its
|
|
45
|
+
* change, so recovery must record that even when the operation itself did nothing.
|
|
46
|
+
*/
|
|
47
|
+
privateFee?: {
|
|
48
|
+
feeResourceAddress: string;
|
|
49
|
+
spentCommitment: string;
|
|
50
|
+
changeCommitment: string;
|
|
51
|
+
changeAmount: string;
|
|
52
|
+
};
|
|
42
53
|
}
|
|
43
54
|
/**
|
|
44
55
|
* Lifecycle of one HTLC operation, persisted *before* anything is submitted so a crash, a killed
|
package/dist/storage.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"storage.d.ts","sourceRoot":"","sources":["../src/storage.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;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,EACd,KAAK,SAAqB,GACzB,OAAO,CAAC,IAAI,CAAC,CAaf;AAED,6FAA6F;AAC7F,wBAAsB,mBAAmB,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvE;AAED,qBAAa,uBAAwB,SAAQ,KAAK;aACpB,WAAW,EAAE,MAAM,EAAE;gBAArB,WAAW,EAAE,MAAM,EAAE;CAQlD;AAQD;4FAC4F;AAC5F,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,CAAC,CAE1I;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,CAAC,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAK5J;AAED;oDACoD;AACpD,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAE9G;AAED,wBAAsB,qBAAqB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAKrH;AAED,wBAAsB,uBAAuB,CAAC,SAAS,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAMvG;AAED;;mFAEmF;AACnF,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAIpD"}
|
package/dist/utxoScan.d.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { type StealthCryptoProvider } from "@tari-project/ootle";
|
|
2
|
-
import type { Shard, StateVersion } from "@tari-project/ootle-ts-bindings";
|
|
2
|
+
import type { Shard, StateVersion, UtxoTag } from "@tari-project/ootle-ts-bindings";
|
|
3
3
|
import type { ScannedStealthOutput } from "./confidential.js";
|
|
4
|
+
/** Shards 1..=NUM_PRESHARDS (shard 0 is the global shard, which holds no UTXOs). */
|
|
5
|
+
export declare const NUM_PRESHARDS = 256;
|
|
4
6
|
/** Checkpoint for one resource's delta scan: a `[Shard, StateVersion]` pair per shard read so far.
|
|
5
|
-
* Serialize as JSON; pass back verbatim
|
|
7
|
+
* Serialize as JSON; pass back verbatim on the next call. Empty = scan every shard from genesis. */
|
|
6
8
|
export type UtxoScanWatermark = Array<[Shard, StateVersion]>;
|
|
7
9
|
/** Result of a delta scan (`scanUtxosDelta`). */
|
|
8
10
|
export interface UtxosDeltaResult {
|
|
@@ -17,52 +19,35 @@ export interface UtxosDeltaResult {
|
|
|
17
19
|
* Call `scanUtxosDelta` again (with the returned `watermarks`) until this is false. */
|
|
18
20
|
hasMore: boolean;
|
|
19
21
|
}
|
|
20
|
-
/** Result of one
|
|
22
|
+
/** Result of one pass of a full scan (`scanUtxosPage`). */
|
|
21
23
|
export interface UtxosPageResult {
|
|
22
24
|
/** Outputs we decrypted as ours. Pass each to `addShieldedOutput`. */
|
|
23
25
|
owned: ScannedStealthOutput[];
|
|
24
|
-
/**
|
|
25
|
-
*
|
|
26
|
+
/** Opaque cursor for the next pass (save with `setUtxoScanPageCursor`, pass as `fromId`).
|
|
27
|
+
* `null` means the sweep reached the end of every shard. */
|
|
26
28
|
nextCursor: string | null;
|
|
27
29
|
}
|
|
30
|
+
interface StreamRead {
|
|
31
|
+
unspent: Array<[UtxoTag, string]>;
|
|
32
|
+
spent: string[];
|
|
33
|
+
reached: Map<number, StateVersion>;
|
|
34
|
+
hasMore: boolean;
|
|
35
|
+
}
|
|
36
|
+
/** Every shard at version 0 — the request a first scan sends. */
|
|
37
|
+
export declare function genesisWatermarks(): UtxoScanWatermark;
|
|
38
|
+
/** Parses an ndjson UTXO stream body into updates and per-shard resume points. */
|
|
39
|
+
export declare function parseUtxoStream(body: string): StreamRead;
|
|
28
40
|
/**
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* Pass `watermarks: []` (or the saved value from storage) on every call. The very first call
|
|
33
|
-
* with an empty watermarks array replays everything the indexer has retained, so it doubles as the
|
|
34
|
-
* initial full scan. Subsequent calls with the returned watermarks fetch only the delta.
|
|
35
|
-
*
|
|
36
|
-
* Call in a loop until `result.hasMore` is false:
|
|
37
|
-
* ```ts
|
|
38
|
-
* let wm = await getUtxoScanWatermarks(accountId, resourceAddress);
|
|
39
|
-
* do {
|
|
40
|
-
* const r = await scanUtxosDelta(indexerUrl, resourceAddress, crypto, viewSecret, wm, 200);
|
|
41
|
-
* for (const o of r.owned) await addShieldedOutput({ ...o, accountId, ... });
|
|
42
|
-
* for (const c of r.spentCommitments) await markShieldedOutputSpent(accountId, c);
|
|
43
|
-
* wm = r.watermarks;
|
|
44
|
-
* await setUtxoScanWatermarks(accountId, resourceAddress, wm);
|
|
45
|
-
* } while (r.hasMore);
|
|
46
|
-
* ```
|
|
41
|
+
* Reads UTXO updates (new outputs + spends) since `watermarks` and decrypts the new outputs with
|
|
42
|
+
* the account's view key. Pass `[]` (or the saved value) on every call; call again with the
|
|
43
|
+
* returned watermarks until `hasMore` is false.
|
|
47
44
|
*/
|
|
48
45
|
export declare function scanUtxosDelta(indexerBaseUrl: string, resourceAddress: string, crypto: StealthCryptoProvider, viewSecret: Uint8Array, watermarks: UtxoScanWatermark, perShardLimit?: number): Promise<UtxosDeltaResult>;
|
|
49
46
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
* `UtxoId` (32-byte commitment hex) of the last output seen on the previous page.
|
|
54
|
-
*
|
|
55
|
-
* Call in a loop until `result.nextCursor` is null:
|
|
56
|
-
* ```ts
|
|
57
|
-
* let cursor = await getUtxoScanPageCursor(accountId, resourceAddress);
|
|
58
|
-
* do {
|
|
59
|
-
* const r = await scanUtxosPage(indexerUrl, resourceAddress, crypto, viewSecret, cursor);
|
|
60
|
-
* for (const o of r.owned) await addShieldedOutput({ ...o, accountId, ... });
|
|
61
|
-
* cursor = r.nextCursor;
|
|
62
|
-
* if (cursor) await setUtxoScanPageCursor(accountId, resourceAddress, cursor);
|
|
63
|
-
* } while (cursor !== null);
|
|
64
|
-
* await clearUtxoScanPageCursor(accountId, resourceAddress);
|
|
65
|
-
* ```
|
|
47
|
+
* One pass of a sweep over every live UTXO of `resourceAddress`. `fromId` is the cursor a previous
|
|
48
|
+
* pass returned (`null` starts a new sweep); a cursor from the pre-0.48 `GET /utxos` API (a bare
|
|
49
|
+
* UtxoId) is ignored and the sweep restarts.
|
|
66
50
|
*/
|
|
67
51
|
export declare function scanUtxosPage(indexerBaseUrl: string, resourceAddress: string, crypto: StealthCryptoProvider, viewSecret: Uint8Array, fromId?: string | null, pageSize?: number): Promise<UtxosPageResult>;
|
|
52
|
+
export {};
|
|
68
53
|
//# sourceMappingURL=utxoScan.d.ts.map
|
package/dist/utxoScan.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utxoScan.d.ts","sourceRoot":"","sources":["../src/utxoScan.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utxoScan.d.ts","sourceRoot":"","sources":["../src/utxoScan.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAgC,KAAK,qBAAqB,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,KAAK,EAAE,KAAK,EAAE,YAAY,EAAU,OAAO,EAAQ,MAAM,iCAAiC,CAAC;AAElG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,oFAAoF;AACpF,eAAO,MAAM,aAAa,MAAM,CAAC;AAGjC;oGACoG;AACpG,MAAM,MAAM,iBAAiB,GAAG,KAAK,CAAC,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC;AAE7D,iDA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