@koralabs/kora-labs-common 6.9.0 → 6.9.1
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/mpt/index.d.ts +9 -0
- package/mpt/index.js +14 -3
- package/package.json +1 -1
package/mpt/index.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
|
+
import { Trie } from '@aiken-lang/merkle-patricia-forestry';
|
|
1
2
|
import * as labelSet from './labelSet';
|
|
2
3
|
import * as registryValue from './registryValue';
|
|
3
4
|
export { labelSet, registryValue };
|
|
5
|
+
export { Trie };
|
|
6
|
+
/**
|
|
7
|
+
* THE canonical minting-data MPT (a real {@link Trie}, for proof generation during mint/burn).
|
|
8
|
+
* Consumers that only need the root hash should use {@link computeMintingDataRoot}; consumers that
|
|
9
|
+
* generate proofs (the minting engine's verifyRootHash) keep the returned Trie. Value = "" per the
|
|
10
|
+
* validator's `update_root` — see {@link computeMintingDataRoot} for the full rationale.
|
|
11
|
+
*/
|
|
12
|
+
export declare const buildMintingDataTrie: (handleNames: string[]) => Promise<Trie>;
|
|
4
13
|
/**
|
|
5
14
|
* THE canonical minting-data MPT root. Every Node service (api.handle.me, the minting engine,
|
|
6
15
|
* handle.me/bff) and the on-chain mirror (@koralabs/handles-decentralized-minting) MUST compute
|
package/mpt/index.js
CHANGED
|
@@ -23,17 +23,29 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.computeMintingDataRoot = exports.registryValue = exports.labelSet = void 0;
|
|
26
|
+
exports.computeMintingDataRoot = exports.buildMintingDataTrie = exports.Trie = exports.registryValue = exports.labelSet = void 0;
|
|
27
27
|
// Server-only (Node) MPT module. Pulls @aiken-lang/merkle-patricia-forestry (native `level`/`blake2b`)
|
|
28
28
|
// so it is NOT re-exported from the package root — import it from the subpath:
|
|
29
29
|
// import { computeMintingDataRoot } from '@koralabs/kora-labs-common/mpt';
|
|
30
30
|
// Mirrors the './aws' server-only convention; keeps the package root isomorphic/browser-safe.
|
|
31
31
|
const merkle_patricia_forestry_1 = require("@aiken-lang/merkle-patricia-forestry");
|
|
32
|
+
Object.defineProperty(exports, "Trie", { enumerable: true, get: function () { return merkle_patricia_forestry_1.Trie; } });
|
|
32
33
|
const labelSet = __importStar(require("./labelSet"));
|
|
33
34
|
exports.labelSet = labelSet;
|
|
34
35
|
const registryValue = __importStar(require("./registryValue"));
|
|
35
36
|
exports.registryValue = registryValue;
|
|
36
37
|
const EMPTY_ROOT_HEX = Buffer.alloc(32).toString('hex');
|
|
38
|
+
/**
|
|
39
|
+
* THE canonical minting-data MPT (a real {@link Trie}, for proof generation during mint/burn).
|
|
40
|
+
* Consumers that only need the root hash should use {@link computeMintingDataRoot}; consumers that
|
|
41
|
+
* generate proofs (the minting engine's verifyRootHash) keep the returned Trie. Value = "" per the
|
|
42
|
+
* validator's `update_root` — see {@link computeMintingDataRoot} for the full rationale.
|
|
43
|
+
*/
|
|
44
|
+
const buildMintingDataTrie = async (handleNames) => {
|
|
45
|
+
const uniqueKeys = Array.from(new Set(handleNames));
|
|
46
|
+
return merkle_patricia_forestry_1.Trie.fromList(uniqueKeys.map((key) => ({ key, value: '' })));
|
|
47
|
+
};
|
|
48
|
+
exports.buildMintingDataTrie = buildMintingDataTrie;
|
|
37
49
|
/**
|
|
38
50
|
* THE canonical minting-data MPT root. Every Node service (api.handle.me, the minting engine,
|
|
39
51
|
* handle.me/bff) and the on-chain mirror (@koralabs/handles-decentralized-minting) MUST compute
|
|
@@ -52,8 +64,7 @@ const EMPTY_ROOT_HEX = Buffer.alloc(32).toString('hex');
|
|
|
52
64
|
*/
|
|
53
65
|
const computeMintingDataRoot = async (handleNames) => {
|
|
54
66
|
var _a, _b;
|
|
55
|
-
const
|
|
56
|
-
const trie = await merkle_patricia_forestry_1.Trie.fromList(uniqueKeys.map((key) => ({ key, value: '' })));
|
|
67
|
+
const trie = await (0, exports.buildMintingDataTrie)(handleNames);
|
|
57
68
|
return (_b = (_a = trie.hash) === null || _a === void 0 ? void 0 : _a.toString('hex')) !== null && _b !== void 0 ? _b : EMPTY_ROOT_HEX;
|
|
58
69
|
};
|
|
59
70
|
exports.computeMintingDataRoot = computeMintingDataRoot;
|