@totemsdk/omnia-vtxo 0.2.0 → 0.3.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.
Files changed (84) hide show
  1. package/dist/anchor.d.ts +87 -0
  2. package/dist/anchor.js +107 -0
  3. package/dist/cjs/anchor.d.ts +87 -0
  4. package/dist/cjs/anchor.js +114 -0
  5. package/dist/cjs/commitment.d.ts +41 -0
  6. package/dist/cjs/commitment.js +173 -0
  7. package/dist/cjs/constants.d.ts +10 -0
  8. package/dist/cjs/constants.js +13 -0
  9. package/dist/cjs/durable-store.d.ts +33 -0
  10. package/dist/cjs/durable-store.js +93 -0
  11. package/dist/cjs/errors.d.ts +33 -0
  12. package/dist/cjs/errors.js +77 -0
  13. package/dist/cjs/exit-tx.d.ts +55 -0
  14. package/dist/cjs/exit-tx.js +81 -0
  15. package/dist/cjs/exit.d.ts +29 -0
  16. package/dist/cjs/exit.js +115 -0
  17. package/dist/cjs/index.d.ts +21 -0
  18. package/dist/cjs/index.js +37 -0
  19. package/dist/cjs/memory-store.d.ts +17 -0
  20. package/dist/cjs/memory-store.js +51 -0
  21. package/dist/cjs/merge.d.ts +8 -0
  22. package/dist/cjs/merge.js +106 -0
  23. package/dist/cjs/operator.d.ts +29 -0
  24. package/dist/cjs/operator.js +65 -0
  25. package/dist/cjs/package.json +1 -0
  26. package/dist/cjs/policy.d.ts +22 -0
  27. package/dist/cjs/policy.js +27 -0
  28. package/dist/cjs/pool-script.d.ts +19 -0
  29. package/dist/cjs/pool-script.js +41 -0
  30. package/dist/cjs/pool.d.ts +5 -0
  31. package/dist/cjs/pool.js +60 -0
  32. package/dist/cjs/receipt.d.ts +31 -0
  33. package/dist/cjs/receipt.js +52 -0
  34. package/dist/cjs/refresh.d.ts +8 -0
  35. package/dist/cjs/refresh.js +84 -0
  36. package/dist/cjs/serialization.d.ts +5 -0
  37. package/dist/cjs/serialization.js +31 -0
  38. package/dist/cjs/split.d.ts +8 -0
  39. package/dist/cjs/split.js +96 -0
  40. package/dist/cjs/transfer.d.ts +8 -0
  41. package/dist/cjs/transfer.js +152 -0
  42. package/dist/cjs/types.d.ts +166 -0
  43. package/dist/cjs/types.js +2 -0
  44. package/dist/cjs/verify.d.ts +23 -0
  45. package/dist/cjs/verify.js +121 -0
  46. package/dist/cjs/vtxo.d.ts +14 -0
  47. package/dist/cjs/vtxo.js +96 -0
  48. package/dist/commitment.d.ts +13 -0
  49. package/dist/commitment.js +39 -30
  50. package/dist/constants.d.ts +0 -2
  51. package/dist/constants.js +4 -9
  52. package/dist/durable-store.d.ts +33 -0
  53. package/dist/durable-store.js +90 -0
  54. package/dist/errors.js +10 -23
  55. package/dist/exit-tx.d.ts +55 -0
  56. package/dist/exit-tx.js +74 -0
  57. package/dist/exit.d.ts +12 -2
  58. package/dist/exit.js +39 -23
  59. package/dist/index.d.ts +6 -0
  60. package/dist/index.js +21 -31
  61. package/dist/memory-store.js +3 -7
  62. package/dist/merge.js +15 -19
  63. package/dist/operator.d.ts +29 -0
  64. package/dist/operator.js +61 -0
  65. package/dist/policy.d.ts +1 -1
  66. package/dist/policy.js +3 -7
  67. package/dist/pool-script.d.ts +19 -0
  68. package/dist/pool-script.js +36 -0
  69. package/dist/pool.js +21 -27
  70. package/dist/receipt.d.ts +31 -0
  71. package/dist/receipt.js +48 -0
  72. package/dist/refresh.js +10 -14
  73. package/dist/serialization.js +4 -10
  74. package/dist/split.js +13 -17
  75. package/dist/transfer.js +13 -17
  76. package/dist/types.d.ts +12 -1
  77. package/dist/types.js +1 -2
  78. package/dist/verify.js +7 -13
  79. package/dist/vtxo.js +14 -19
  80. package/package.json +19 -8
  81. package/rust/pkg/omnia_vtxo_wasm_bg.wasm +0 -0
  82. package/rust/pkg/package.json +1 -1
  83. package/rust/pkg-node/omnia_vtxo_wasm_bg.wasm +0 -0
  84. package/rust/pkg-node/package.json +1 -1
package/dist/refresh.js CHANGED
@@ -1,22 +1,18 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.refreshVtxo = refreshVtxo;
4
- const errors_js_1 = require("./errors.js");
5
- const commitment_js_1 = require("./commitment.js");
6
- const constants_js_1 = require("./constants.js");
1
+ import { VtxoStatusError, VtxoPolicyError } from './errors.js';
2
+ import { computeVtxoId, buildVtxoProofSet, computeReceiptId } from './commitment.js';
7
3
  /**
8
4
  * Refreshes a VTXO to a new epoch.
9
5
  * @param now - Timestamp in ms. Defaults to Date.now() if omitted — pass explicitly for determinism.
10
6
  */
11
- function refreshVtxo(vtxo, params, now) {
7
+ export function refreshVtxo(vtxo, params, now) {
12
8
  const ts = now !== undefined ? now : Date.now();
13
9
  if (vtxo.status !== 'active') {
14
- throw new errors_js_1.VtxoStatusError(`Cannot refresh VTXO ${vtxo.vtxoId}: status is '${vtxo.status}'`, vtxo.status);
10
+ throw new VtxoStatusError(`Cannot refresh VTXO ${vtxo.vtxoId}: status is '${vtxo.status}'`, vtxo.status);
15
11
  }
16
12
  if (params.newEpoch <= vtxo.epoch) {
17
- throw new errors_js_1.VtxoPolicyError(`Refresh epoch ${params.newEpoch} must be strictly greater than current epoch ${vtxo.epoch}`);
13
+ throw new VtxoPolicyError(`Refresh epoch ${params.newEpoch} must be strictly greater than current epoch ${vtxo.epoch}`);
18
14
  }
19
- const refreshedId = (0, commitment_js_1.computeVtxoId)({
15
+ const refreshedId = computeVtxoId({
20
16
  poolId: vtxo.poolId,
21
17
  owner: vtxo.owner,
22
18
  amount: vtxo.amount,
@@ -51,7 +47,7 @@ function refreshVtxo(vtxo, params, now) {
51
47
  siblings: [],
52
48
  positions: [],
53
49
  epoch: params.newEpoch,
54
- batchId: constants_js_1.MOCK_BATCH_ID,
50
+ batchId: '',
55
51
  },
56
52
  history: [
57
53
  {
@@ -65,9 +61,9 @@ function refreshVtxo(vtxo, params, now) {
65
61
  updatedAt: ts,
66
62
  expiresAt: vtxo.expiresAt,
67
63
  };
68
- const { proofs } = (0, commitment_js_1.buildVtxoProofSet)([rawRefreshed]);
64
+ const { proofs } = buildVtxoProofSet([rawRefreshed]);
69
65
  const refreshedVtxo = { ...rawRefreshed, proof: proofs[refreshedId] };
70
- const receiptId = (0, commitment_js_1.computeReceiptId)(vtxo.poolId, 'refresh', [vtxo.vtxoId], [refreshedId], ts);
66
+ const receiptId = computeReceiptId(vtxo.poolId, 'refresh', [vtxo.vtxoId], [refreshedId], ts);
71
67
  return {
72
68
  old: oldVtxo,
73
69
  refreshed: refreshedVtxo,
@@ -79,7 +75,7 @@ function refreshVtxo(vtxo, params, now) {
79
75
  outputIds: [refreshedId],
80
76
  epoch: params.newEpoch,
81
77
  at: ts,
82
- signature: constants_js_1.MOCK_OPERATOR_SIGNATURE,
78
+ signature: '',
83
79
  },
84
80
  };
85
81
  }
@@ -1,9 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.serializeVtxo = serializeVtxo;
4
- exports.deserializeVtxo = deserializeVtxo;
5
- exports.serializePool = serializePool;
6
- exports.deserializePool = deserializePool;
7
1
  const BIGINT_PREFIX = '__bigint__:';
8
2
  function replacer(_key, value) {
9
3
  if (typeof value === 'bigint') {
@@ -17,15 +11,15 @@ function reviver(_key, value) {
17
11
  }
18
12
  return value;
19
13
  }
20
- function serializeVtxo(vtxo) {
14
+ export function serializeVtxo(vtxo) {
21
15
  return JSON.stringify(vtxo, replacer);
22
16
  }
23
- function deserializeVtxo(json) {
17
+ export function deserializeVtxo(json) {
24
18
  return JSON.parse(json, reviver);
25
19
  }
26
- function serializePool(pool) {
20
+ export function serializePool(pool) {
27
21
  return JSON.stringify(pool, replacer);
28
22
  }
29
- function deserializePool(json) {
23
+ export function deserializePool(json) {
30
24
  return JSON.parse(json, reviver);
31
25
  }
package/dist/split.js CHANGED
@@ -1,34 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.splitVtxo = splitVtxo;
4
- const errors_js_1 = require("./errors.js");
5
- const commitment_js_1 = require("./commitment.js");
6
- const constants_js_1 = require("./constants.js");
1
+ import { VtxoStatusError, VtxoAmountError, VtxoSplitError } from './errors.js';
2
+ import { computeVtxoId, buildVtxoProofSet, computeReceiptId } from './commitment.js';
7
3
  /**
8
4
  * Splits a VTXO into multiple outputs.
9
5
  * @param now - Timestamp in ms. Defaults to Date.now() if omitted — pass explicitly for determinism.
10
6
  */
11
- function splitVtxo(vtxo, params, now) {
7
+ export function splitVtxo(vtxo, params, now) {
12
8
  const ts = now !== undefined ? now : Date.now();
13
9
  if (vtxo.status !== 'active') {
14
- throw new errors_js_1.VtxoStatusError(`Cannot split VTXO ${vtxo.vtxoId}: status is '${vtxo.status}'`, vtxo.status);
10
+ throw new VtxoStatusError(`Cannot split VTXO ${vtxo.vtxoId}: status is '${vtxo.status}'`, vtxo.status);
15
11
  }
16
12
  if (params.amounts.length < 2) {
17
- throw new errors_js_1.VtxoSplitError('Split requires at least 2 output amounts');
13
+ throw new VtxoSplitError('Split requires at least 2 output amounts');
18
14
  }
19
15
  if (params.amounts.length !== params.nonces.length) {
20
- throw new errors_js_1.VtxoSplitError('amounts and nonces arrays must have the same length');
16
+ throw new VtxoSplitError('amounts and nonces arrays must have the same length');
21
17
  }
22
18
  for (const amt of params.amounts) {
23
19
  if (amt <= BigInt(0)) {
24
- throw new errors_js_1.VtxoAmountError(`All split amounts must be > 0, got ${amt}`);
20
+ throw new VtxoAmountError(`All split amounts must be > 0, got ${amt}`);
25
21
  }
26
22
  }
27
23
  const sum = params.amounts.reduce((a, b) => a + b, BigInt(0));
28
24
  if (sum !== vtxo.amount) {
29
- throw new errors_js_1.VtxoAmountError(`Split amounts sum ${sum} does not equal VTXO amount ${vtxo.amount}`);
25
+ throw new VtxoAmountError(`Split amounts sum ${sum} does not equal VTXO amount ${vtxo.amount}`);
30
26
  }
31
- const outputIds = params.amounts.map((amount, i) => (0, commitment_js_1.computeVtxoId)({
27
+ const outputIds = params.amounts.map((amount, i) => computeVtxoId({
32
28
  poolId: vtxo.poolId,
33
29
  owner: vtxo.owner,
34
30
  amount,
@@ -63,7 +59,7 @@ function splitVtxo(vtxo, params, now) {
63
59
  siblings: [],
64
60
  positions: [],
65
61
  epoch: vtxo.epoch,
66
- batchId: constants_js_1.MOCK_BATCH_ID,
62
+ batchId: '',
67
63
  },
68
64
  history: [
69
65
  {
@@ -77,9 +73,9 @@ function splitVtxo(vtxo, params, now) {
77
73
  createdAt: ts,
78
74
  updatedAt: ts,
79
75
  }));
80
- const { proofs } = (0, commitment_js_1.buildVtxoProofSet)(rawOutputs);
76
+ const { proofs } = buildVtxoProofSet(rawOutputs);
81
77
  const outputs = rawOutputs.map(o => ({ ...o, proof: proofs[o.vtxoId] }));
82
- const receiptId = (0, commitment_js_1.computeReceiptId)(vtxo.poolId, 'split', [vtxo.vtxoId], outputIds, ts);
78
+ const receiptId = computeReceiptId(vtxo.poolId, 'split', [vtxo.vtxoId], outputIds, ts);
83
79
  return {
84
80
  input: inputVtxo,
85
81
  outputs,
@@ -91,7 +87,7 @@ function splitVtxo(vtxo, params, now) {
91
87
  outputIds,
92
88
  epoch: vtxo.epoch,
93
89
  at: ts,
94
- signature: constants_js_1.MOCK_OPERATOR_SIGNATURE,
90
+ signature: '',
95
91
  },
96
92
  };
97
93
  }
package/dist/transfer.js CHANGED
@@ -1,27 +1,23 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.transferVtxo = transferVtxo;
4
- const errors_js_1 = require("./errors.js");
5
- const commitment_js_1 = require("./commitment.js");
6
- const constants_js_1 = require("./constants.js");
1
+ import { VtxoStatusError, VtxoAmountError } from './errors.js';
2
+ import { computeVtxoId, buildVtxoProofSet, computeReceiptId } from './commitment.js';
7
3
  /**
8
4
  * Transfers a VTXO (fully or partially) to a recipient.
9
5
  * @param now - Timestamp in ms. Defaults to Date.now() if omitted — pass explicitly for determinism.
10
6
  */
11
- function transferVtxo(vtxo, params, now) {
7
+ export function transferVtxo(vtxo, params, now) {
12
8
  const ts = now !== undefined ? now : Date.now();
13
9
  if (vtxo.status !== 'active') {
14
- throw new errors_js_1.VtxoStatusError(`Cannot transfer VTXO ${vtxo.vtxoId}: status is '${vtxo.status}'`, vtxo.status);
10
+ throw new VtxoStatusError(`Cannot transfer VTXO ${vtxo.vtxoId}: status is '${vtxo.status}'`, vtxo.status);
15
11
  }
16
12
  if (params.amount <= BigInt(0)) {
17
- throw new errors_js_1.VtxoAmountError(`Transfer amount must be > 0, got ${params.amount}`);
13
+ throw new VtxoAmountError(`Transfer amount must be > 0, got ${params.amount}`);
18
14
  }
19
15
  if (params.amount > vtxo.amount) {
20
- throw new errors_js_1.VtxoAmountError(`Transfer amount ${params.amount} exceeds VTXO amount ${vtxo.amount}`);
16
+ throw new VtxoAmountError(`Transfer amount ${params.amount} exceeds VTXO amount ${vtxo.amount}`);
21
17
  }
22
18
  const isPartial = params.amount < vtxo.amount;
23
19
  const changeAmount = vtxo.amount - params.amount;
24
- const outputId = (0, commitment_js_1.computeVtxoId)({
20
+ const outputId = computeVtxoId({
25
21
  poolId: vtxo.poolId,
26
22
  owner: params.recipient,
27
23
  amount: params.amount,
@@ -32,7 +28,7 @@ function transferVtxo(vtxo, params, now) {
32
28
  let changeId;
33
29
  if (isPartial) {
34
30
  const changeNonce = params.changeNonce ?? params.nonce + ':change';
35
- changeId = (0, commitment_js_1.computeVtxoId)({
31
+ changeId = computeVtxoId({
36
32
  poolId: vtxo.poolId,
37
33
  owner: vtxo.owner,
38
34
  amount: changeAmount,
@@ -69,7 +65,7 @@ function transferVtxo(vtxo, params, now) {
69
65
  siblings: [],
70
66
  positions: [],
71
67
  epoch: vtxo.epoch,
72
- batchId: constants_js_1.MOCK_BATCH_ID,
68
+ batchId: '',
73
69
  },
74
70
  history: [
75
71
  {
@@ -99,7 +95,7 @@ function transferVtxo(vtxo, params, now) {
99
95
  siblings: [],
100
96
  positions: [],
101
97
  epoch: vtxo.epoch,
102
- batchId: constants_js_1.MOCK_BATCH_ID,
98
+ batchId: '',
103
99
  },
104
100
  history: [
105
101
  {
@@ -116,7 +112,7 @@ function transferVtxo(vtxo, params, now) {
116
112
  outputIds.push(changeId);
117
113
  }
118
114
  const activeOutputs = changeVtxo ? [outputVtxo, changeVtxo] : [outputVtxo];
119
- const { proofs } = (0, commitment_js_1.buildVtxoProofSet)(activeOutputs);
115
+ const { proofs } = buildVtxoProofSet(activeOutputs);
120
116
  const patchedOutput = { ...outputVtxo, proof: proofs[outputId] };
121
117
  const patchedChange = changeVtxo
122
118
  ? { ...changeVtxo, proof: proofs[changeId] }
@@ -133,7 +129,7 @@ function transferVtxo(vtxo, params, now) {
133
129
  tokenId: vtxo.tokenId,
134
130
  at: ts,
135
131
  };
136
- const receiptId = (0, commitment_js_1.computeReceiptId)(vtxo.poolId, 'transfer', [vtxo.vtxoId], outputIds, ts);
132
+ const receiptId = computeReceiptId(vtxo.poolId, 'transfer', [vtxo.vtxoId], outputIds, ts);
137
133
  return {
138
134
  input: inputVtxo,
139
135
  output: patchedOutput,
@@ -147,7 +143,7 @@ function transferVtxo(vtxo, params, now) {
147
143
  outputIds,
148
144
  epoch: vtxo.epoch,
149
145
  at: ts,
150
- signature: constants_js_1.MOCK_OPERATOR_SIGNATURE,
146
+ signature: '',
151
147
  },
152
148
  };
153
149
  }
package/dist/types.d.ts CHANGED
@@ -48,6 +48,13 @@ export interface OmniaVtxo {
48
48
  createdAt: number;
49
49
  updatedAt: number;
50
50
  expiresAt?: number;
51
+ /** The on-chain funding proof recorded at mint (deep proof, #28). */
52
+ fundingProof?: unknown;
53
+ /** Set when an exit draft consumed this VTXO — prevents double-exit. */
54
+ exitConsumedAt?: number;
55
+ exitReceiptId?: string;
56
+ /** The confirming exit transaction's txpowId (set on `markExited`). */
57
+ exitTxpowId?: string;
51
58
  }
52
59
  export interface VtxoTransfer {
53
60
  inputId: VtxoId;
@@ -84,6 +91,8 @@ export interface MintVtxoParams {
84
91
  amount: bigint;
85
92
  nonce: string;
86
93
  expiresAt?: number;
94
+ /** The on-chain funding proof (deep proof) recorded at mint. */
95
+ fundingProof?: unknown;
87
96
  }
88
97
  export interface TransferVtxoParams {
89
98
  recipient: string;
@@ -132,9 +141,11 @@ export interface ExitDraft {
132
141
  owner: string;
133
142
  amount: bigint;
134
143
  tokenId: string;
135
- draftType: 'mock-exit';
144
+ draftType: 'vtxo-exit';
136
145
  timelockSeconds: number;
137
146
  createdAt: number;
147
+ /** The verified share this exit is capped at (the VTXO's amount). */
148
+ verifiedShare: bigint;
138
149
  }
139
150
  export interface VerifyVtxoResult {
140
151
  valid: boolean;
package/dist/types.js CHANGED
@@ -1,2 +1 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
1
+ export {};
package/dist/verify.js CHANGED
@@ -1,11 +1,5 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyVtxo = verifyVtxo;
4
- exports.verifyVtxoProof = verifyVtxoProof;
5
- exports.verifyVtxoTransfer = verifyVtxoTransfer;
6
- exports.verifyConservation = verifyConservation;
7
- const commitment_js_1 = require("./commitment.js");
8
- function verifyVtxo(vtxo) {
1
+ import { computeVtxoLeaf, verifyMerkleProof } from './commitment.js';
2
+ export function verifyVtxo(vtxo) {
9
3
  const errors = [];
10
4
  if (!vtxo.vtxoId)
11
5
  errors.push('Missing vtxoId');
@@ -27,9 +21,9 @@ function verifyVtxo(vtxo) {
27
21
  }
28
22
  return { valid: errors.length === 0, errors };
29
23
  }
30
- function verifyVtxoProof(vtxo, proof) {
24
+ export function verifyVtxoProof(vtxo, proof) {
31
25
  const errors = [];
32
- const expectedLeaf = (0, commitment_js_1.computeVtxoLeaf)(vtxo);
26
+ const expectedLeaf = computeVtxoLeaf(vtxo);
33
27
  if (proof.leaf !== expectedLeaf) {
34
28
  errors.push(`Proof leaf mismatch: expected ${expectedLeaf}, got ${proof.leaf}`);
35
29
  }
@@ -38,7 +32,7 @@ function verifyVtxoProof(vtxo, proof) {
38
32
  sibling,
39
33
  position: proof.positions[i],
40
34
  }));
41
- const valid = (0, commitment_js_1.verifyMerkleProof)(proof.leaf, proofNodes, proof.root);
35
+ const valid = verifyMerkleProof(proof.leaf, proofNodes, proof.root);
42
36
  if (!valid) {
43
37
  errors.push('Merkle proof verification failed');
44
38
  }
@@ -50,7 +44,7 @@ function verifyVtxoProof(vtxo, proof) {
50
44
  }
51
45
  return { valid: errors.length === 0, errors };
52
46
  }
53
- function verifyVtxoTransfer(input, output, transfer) {
47
+ export function verifyVtxoTransfer(input, output, transfer) {
54
48
  const errors = [];
55
49
  if (transfer.inputId !== input.vtxoId) {
56
50
  errors.push(`Transfer inputId ${transfer.inputId} does not match input VTXO ${input.vtxoId}`);
@@ -77,7 +71,7 @@ function verifyVtxoTransfer(input, output, transfer) {
77
71
  *
78
72
  * Always requires: same `poolId` and `tokenId` across all inputs and outputs.
79
73
  */
80
- function verifyConservation(params) {
74
+ export function verifyConservation(params) {
81
75
  const errors = [];
82
76
  const { inputs, outputs, mode = 'lte' } = params;
83
77
  if (inputs.length === 0 || outputs.length === 0) {
package/dist/vtxo.js CHANGED
@@ -1,13 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.isVtxoActive = isVtxoActive;
4
- exports.mintVtxo = mintVtxo;
5
- exports.markVtxoSpent = markVtxoSpent;
6
- const errors_js_1 = require("./errors.js");
7
- const constants_js_1 = require("./constants.js");
8
- const commitment_js_1 = require("./commitment.js");
9
- const pool_js_1 = require("./pool.js");
10
- function isVtxoActive(vtxo) {
1
+ import { VtxoStatusError } from './errors.js';
2
+ import { computeVtxoId, buildVtxoProofSet, computeReceiptId } from './commitment.js';
3
+ import { assertPoolCanMint } from './pool.js';
4
+ export function isVtxoActive(vtxo) {
11
5
  return vtxo.status === 'active';
12
6
  }
13
7
  /**
@@ -16,10 +10,10 @@ function isVtxoActive(vtxo) {
16
10
  * @param params - Mint parameters (owner, amount, nonce).
17
11
  * @param now - Timestamp in ms. Defaults to Date.now() if omitted — pass explicitly for determinism.
18
12
  */
19
- function mintVtxo(pool, params, now) {
13
+ export function mintVtxo(pool, params, now) {
20
14
  const ts = now !== undefined ? now : Date.now();
21
- (0, pool_js_1.assertPoolCanMint)(pool, params.amount);
22
- const vtxoId = (0, commitment_js_1.computeVtxoId)({
15
+ assertPoolCanMint(pool, params.amount);
16
+ const vtxoId = computeVtxoId({
23
17
  poolId: pool.poolId,
24
18
  owner: params.owner,
25
19
  amount: params.amount,
@@ -40,8 +34,9 @@ function mintVtxo(pool, params, now) {
40
34
  siblings: [],
41
35
  positions: [],
42
36
  epoch: pool.epoch,
43
- batchId: constants_js_1.MOCK_BATCH_ID,
37
+ batchId: '',
44
38
  },
39
+ fundingProof: params.fundingProof,
45
40
  history: [
46
41
  {
47
42
  op: 'mint',
@@ -54,7 +49,7 @@ function mintVtxo(pool, params, now) {
54
49
  updatedAt: ts,
55
50
  expiresAt: params.expiresAt,
56
51
  };
57
- const { root, proofs } = (0, commitment_js_1.buildVtxoProofSet)([vtxo]);
52
+ const { root, proofs } = buildVtxoProofSet([vtxo]);
58
53
  const proof = proofs[vtxoId];
59
54
  const mintedVtxo = { ...vtxo, proof };
60
55
  const updatedPool = {
@@ -62,7 +57,7 @@ function mintVtxo(pool, params, now) {
62
57
  availableCapacity: pool.availableCapacity - params.amount,
63
58
  commitmentRoot: root,
64
59
  };
65
- const receiptId = (0, commitment_js_1.computeReceiptId)(pool.poolId, 'mint', [], [vtxoId], ts);
60
+ const receiptId = computeReceiptId(pool.poolId, 'mint', [], [vtxoId], ts);
66
61
  const receipt = {
67
62
  receiptId,
68
63
  poolId: pool.poolId,
@@ -71,7 +66,7 @@ function mintVtxo(pool, params, now) {
71
66
  outputIds: [vtxoId],
72
67
  epoch: pool.epoch,
73
68
  at: ts,
74
- signature: constants_js_1.MOCK_OPERATOR_SIGNATURE,
69
+ signature: '',
75
70
  };
76
71
  return { pool: updatedPool, vtxo: mintedVtxo, receipt };
77
72
  }
@@ -79,10 +74,10 @@ function mintVtxo(pool, params, now) {
79
74
  * Marks an active VTXO as spent.
80
75
  * @param now - Timestamp in ms. Defaults to Date.now() if omitted — pass explicitly for determinism.
81
76
  */
82
- function markVtxoSpent(vtxo, now) {
77
+ export function markVtxoSpent(vtxo, now) {
83
78
  const ts = now !== undefined ? now : Date.now();
84
79
  if (!isVtxoActive(vtxo)) {
85
- throw new errors_js_1.VtxoStatusError(`Cannot mark VTXO ${vtxo.vtxoId} as spent: status is '${vtxo.status}'`, vtxo.status);
80
+ throw new VtxoStatusError(`Cannot mark VTXO ${vtxo.vtxoId} as spent: status is '${vtxo.status}'`, vtxo.status);
86
81
  }
87
82
  return {
88
83
  ...vtxo,
package/package.json CHANGED
@@ -1,14 +1,19 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-vtxo",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Virtual UTXO / payment-pool claim layer for Omnia — cash-like off-chain balance primitive for Totem Edge",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "main": "dist/cjs/index.js",
6
+ "types": "dist/cjs/index.d.ts",
7
7
  "exports": {
8
8
  ".": {
9
- "types": "./dist/index.d.ts",
10
- "require": "./dist/index.js",
11
- "import": "./dist/index.js"
9
+ "import": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "require": {
14
+ "types": "./dist/cjs/index.d.ts",
15
+ "default": "./dist/cjs/index.js"
16
+ }
12
17
  }
13
18
  },
14
19
  "files": [
@@ -19,7 +24,12 @@
19
24
  "LICENSE"
20
25
  ],
21
26
  "dependencies": {
22
- "@totemsdk/core": "^1.2.9"
27
+ "@totemsdk/chain-provider": "^0.2.1",
28
+ "@totemsdk/omnia": "^1.0.3",
29
+ "@totemsdk/core": "^1.2.11",
30
+ "@totemsdk/storage": "^0.1.0",
31
+ "@totemsdk/wots-lease": "^1.0.1",
32
+ "@totemsdk/txpow": "^1.0.2"
23
33
  },
24
34
  "devDependencies": {
25
35
  "@types/jest": "^30.0.0",
@@ -61,8 +71,9 @@
61
71
  "off-chain",
62
72
  "ark"
63
73
  ],
74
+ "type": "module",
64
75
  "scripts": {
65
- "build": "npm run build:wasm && tsc && node ../../scripts/clean-wasm-output-ignores.mjs",
76
+ "build": "tsc && tsc -p tsconfig.cjs.json && node -e \"require('fs').writeFileSync('dist/cjs/package.json', JSON.stringify({type:'commonjs'})+'\\n')\"",
66
77
  "clean": "rm -rf dist rust/pkg rust/pkg-node rust/target",
67
78
  "test": "jest",
68
79
  "build:wasm": "cd rust && wasm-pack build --target bundler --out-dir pkg && wasm-pack build --target nodejs --out-dir pkg-node"
Binary file
@@ -24,4 +24,4 @@
24
24
  "./omnia_vtxo_wasm.js",
25
25
  "./snippets/*"
26
26
  ]
27
- }
27
+ }
@@ -18,4 +18,4 @@
18
18
  "main": "omnia_vtxo_wasm.js",
19
19
  "homepage": "https://totem.ing",
20
20
  "types": "omnia_vtxo_wasm.d.ts"
21
- }
21
+ }