@totemsdk/omnia-factory 0.1.6 → 0.1.8

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.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.computeFactoryStateCommitment = computeFactoryStateCommitment;
4
- const sha3_js_1 = require("@noble/hashes/sha3.js");
4
+ const core_1 = require("@totemsdk/core");
5
5
  /**
6
6
  * Compute the canonical 32-byte state commitment for N-of-N factory signing.
7
7
  *
@@ -26,5 +26,5 @@ function computeFactoryStateCommitment(factoryId, sequence, pendingAllocations,
26
26
  .map(([k, v]) => [k, v.toString()])),
27
27
  virtualChannelIds: [...virtualChannelIds].sort(),
28
28
  };
29
- return (0, sha3_js_1.sha3_256)(new TextEncoder().encode(JSON.stringify(canonical)));
29
+ return (0, core_1.sha3_256)(new TextEncoder().encode(JSON.stringify(canonical)));
30
30
  }
package/dist/factory.js CHANGED
@@ -4,8 +4,8 @@ exports.enforceConservation = enforceConservation;
4
4
  exports.createFactory = createFactory;
5
5
  exports.acceptFactory = acceptFactory;
6
6
  exports.reallocate = reallocate;
7
- const sha3_js_1 = require("@noble/hashes/sha3.js");
8
7
  const core_1 = require("@totemsdk/core");
8
+ const core_2 = require("@totemsdk/core");
9
9
  const omnia_1 = require("@totemsdk/omnia");
10
10
  const txpow_1 = require("@totemsdk/txpow");
11
11
  const script_js_1 = require("./script.js");
@@ -50,7 +50,7 @@ async function leaseSign(factoryId, commitment, purpose, participant, bundle) {
50
50
  // Verify the signature against the REGISTERED participant public key digest —
51
51
  // not self-reported from the signer, ensuring the signer matches the factory record.
52
52
  const verifyFn = bundle.verify
53
- ?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.fromHex)(pkd)));
53
+ ?? ((s, c, pkd) => (0, core_2.wotsVerifyDigest)(s, c, (0, core_2.hexToBytes)(pkd)));
54
54
  if (!verifyFn(sig, commitment, participant.publicKeyDigest)) {
55
55
  await bundle.leaseProvider.burnReservation(reservation.reservationId, 'verification-failed').catch(() => { });
56
56
  throw new Error(`Signature verification failed for party '${participant.partyId}' — refusing to commit`);
@@ -81,7 +81,7 @@ function generateFactoryId(participants, tokenId) {
81
81
  tokenId,
82
82
  nonce,
83
83
  });
84
- return Buffer.from((0, sha3_js_1.sha3_256)(new TextEncoder().encode(input))).toString('hex');
84
+ return Buffer.from((0, core_1.sha3_256)(new TextEncoder().encode(input))).toString('hex');
85
85
  }
86
86
  // ─── createFactory ────────────────────────────────────────────────────────────
87
87
  /**
@@ -140,7 +140,7 @@ async function createFactory(participants, tokenId, bundle, chainProvider) {
140
140
  const draftBytes = (0, omnia_1.omniaDraftToMinimaBytes)(fundingDraft);
141
141
  const txBody = (0, txpow_1.serializeTxBody)(draftBytes, new Uint8Array(0));
142
142
  const mined = await (0, txpow_1.mineTxPoW)(txBody, txpow_1.TX_POW_MIN_DIFFICULTY);
143
- const fullTxPoW = (0, core_1.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01]), txBody);
143
+ const fullTxPoW = (0, core_2.concatBytes)((0, core_2.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01])), txBody);
144
144
  await chainProvider.broadcastTxPoW(Buffer.from(fullTxPoW).toString('hex'));
145
145
  fundingTxId = Buffer.from(mined.txpowId).toString('hex');
146
146
  fundingCoinId = `${fundingTxId}-0`;
@@ -91,7 +91,7 @@ async function closeFactory(factory, leaseProviders, chainProvider) {
91
91
  throw err;
92
92
  }
93
93
  const verifyFn = bundle.verify
94
- ?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.fromHex)(pkd)));
94
+ ?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.hexToBytes)(pkd)));
95
95
  if (!verifyFn(sig, txDigest, p.publicKeyDigest)) {
96
96
  await bundle.leaseProvider.burnReservation(reservation.reservationId, 'verification-failed').catch(() => { });
97
97
  throw new Error(`Settlement signature verification failed for party '${p.partyId}'`);
@@ -100,7 +100,7 @@ async function closeFactory(factory, leaseProviders, chainProvider) {
100
100
  witnessParts.push(sig);
101
101
  }
102
102
  // Concatenated WOTS signatures form the N-of-N MULTISIG witness.
103
- const witnessBytes = (0, core_1.concatBytes)(...witnessParts);
103
+ const witnessBytes = witnessParts.reduce((a, b) => (0, core_1.concatBytes)(a, b));
104
104
  const payload = {
105
105
  factoryId: factory.factoryId,
106
106
  sequence: factory.currentSequence,
@@ -112,7 +112,7 @@ async function closeFactory(factory, leaseProviders, chainProvider) {
112
112
  const draftBytes = (0, omnia_1.omniaDraftToMinimaBytes)(settlementDraft);
113
113
  const txBody = (0, txpow_1.serializeTxBody)(draftBytes, witnessBytes);
114
114
  const mined = await (0, txpow_1.mineTxPoW)(txBody, txpow_1.TX_POW_MIN_DIFFICULTY);
115
- const fullTxPoW = (0, core_1.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01]), txBody);
115
+ const fullTxPoW = (0, core_1.concatBytes)((0, core_1.concatBytes)(mined.minedHeaderBytes, new Uint8Array([0x01])), txBody);
116
116
  await chainProvider.broadcastTxPoW(Buffer.from(fullTxPoW).toString('hex'));
117
117
  payload.txpowId = Buffer.from(mined.txpowId).toString('hex');
118
118
  }
package/dist/virtual.js CHANGED
@@ -26,7 +26,7 @@ async function leaseSign(factoryId, commitment, purpose, partyId, publicKeyDiges
26
26
  throw err;
27
27
  }
28
28
  const verifyFn = bundle.verify
29
- ?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.fromHex)(pkd)));
29
+ ?? ((s, c, pkd) => (0, core_1.wotsVerifyDigest)(s, c, (0, core_1.hexToBytes)(pkd)));
30
30
  if (!verifyFn(sig, commitment, publicKeyDigest)) {
31
31
  await bundle.leaseProvider.burnReservation(reservation.reservationId, 'verification-failed').catch(() => { });
32
32
  throw new Error(`Signature verification failed for party '${partyId}' — aborting virtual channel operation`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@totemsdk/omnia-factory",
3
- "version": "0.1.6",
3
+ "version": "0.1.8",
4
4
  "description": "Channel factory layer for Omnia — N-of-N MULTISIG funding, virtual channel management, and factory settlement",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -11,34 +11,31 @@
11
11
  "import": "./dist/index.js"
12
12
  }
13
13
  },
14
+ "scripts": {
15
+ "build": "tsc",
16
+ "prepare": "tsc",
17
+ "clean": "rm -rf dist",
18
+ "test": "node ../../node_modules/jest/bin/jest.js --config jest.config.cjs --passWithNoTests"
19
+ },
14
20
  "files": [
15
21
  "dist",
16
22
  "README.md",
17
23
  "LICENSE"
18
24
  ],
19
25
  "dependencies": {
20
- "@totemsdk/core": "1.0.10",
21
- "@totemsdk/omnia": "0.1.5",
22
- "@totemsdk/wots-lease": "0.1.3",
23
- "@totemsdk/tx-builder": "0.1.5",
24
- "@totemsdk/chain-provider": "0.1.3",
25
- "@totemsdk/txpow": "0.1.5"
26
- },
27
- "peerDependencies": {
28
- "@noble/hashes": "^2.0.0"
29
- },
30
- "peerDependenciesMeta": {
31
- "@noble/hashes": {
32
- "optional": false
33
- }
26
+ "@totemsdk/core": "^1.1.0",
27
+ "@totemsdk/omnia": "^0.1.5",
28
+ "@totemsdk/wots-lease": "^0.1.3",
29
+ "@totemsdk/tx-builder": "^0.1.6",
30
+ "@totemsdk/txpow": "^0.1.5",
31
+ "@totemsdk/chain-provider": "^0.1.4"
34
32
  },
35
33
  "devDependencies": {
36
- "@noble/hashes": "^2.2.0",
37
- "@types/jest": "^29.0.0",
34
+ "@types/jest": "^30.0.0",
38
35
  "@types/node": "^20.0.0",
39
- "jest": "^29.0.0",
36
+ "jest": "^30.4.2",
40
37
  "ts-jest": "^29.0.0",
41
- "typescript": "^5.0.0"
38
+ "typescript": "^7.0.2"
42
39
  },
43
40
  "engines": {
44
41
  "node": ">=18.0.0"
@@ -48,13 +45,13 @@
48
45
  },
49
46
  "license": "MIT",
50
47
  "author": "Totem SDK",
51
- "homepage": "https://totemsdk.com",
48
+ "homepage": "https://totem.ing",
52
49
  "bugs": {
53
- "url": "https://github.com/MrGheek/axia-totem/issues"
50
+ "url": "https://github.com/totem-sdk/totem-sdk/issues"
54
51
  },
55
52
  "repository": {
56
53
  "type": "git",
57
- "url": "git+https://github.com/MrGheek/axia-totem.git",
54
+ "url": "git+https://github.com/totem-sdk/totem-sdk.git",
58
55
  "directory": "packages/totem-sdk/packages/omnia-factory"
59
56
  },
60
57
  "keywords": [
@@ -73,10 +70,5 @@
73
70
  "channel-factory",
74
71
  "virtual-channel",
75
72
  "multisig"
76
- ],
77
- "scripts": {
78
- "build": "tsc",
79
- "clean": "rm -rf dist",
80
- "test": "node ../../node_modules/jest/bin/jest.js --config jest.config.cjs --passWithNoTests"
81
- }
82
- }
73
+ ]
74
+ }