openttt 0.2.0 → 0.2.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/dist/adaptive_switch.js
CHANGED
|
@@ -43,7 +43,7 @@ class AdaptiveSwitch {
|
|
|
43
43
|
let sequenceOk = orderMatch && timeMatch;
|
|
44
44
|
// B1-1: Do not skip GrgInverse.verify() in TURBO mode
|
|
45
45
|
// We check integrity regardless of mode
|
|
46
|
-
const integrityOk = helm_crypto_1.
|
|
46
|
+
const integrityOk = helm_crypto_1.IntegrityDecoder.verify(block.data, tttRecord.grgPayload, chainId, poolAddress);
|
|
47
47
|
if (!integrityOk) {
|
|
48
48
|
logger_1.logger.error(`[AdaptiveSwitch] GRG integrity check FAILED`);
|
|
49
49
|
sequenceOk = false; // Mark as false if integrity fails
|
package/dist/auto_mint.js
CHANGED
|
@@ -223,7 +223,7 @@ class AutoMintEngine {
|
|
|
223
223
|
// 4. EVM mint call — run GRG integrity pipeline
|
|
224
224
|
const grgPayload = ethers_1.ethers.AbiCoder.defaultAbiCoder().encode(["bytes32", "bytes32", "uint64", "uint8"], [tokenId, potHash, synthesized.timestamp, pot.sources]);
|
|
225
225
|
const grgStart = Date.now();
|
|
226
|
-
const grgShards = helm_crypto_1.
|
|
226
|
+
const grgShards = helm_crypto_1.IntegrityEncoder.encode(ethers_1.ethers.getBytes(grgPayload), this.config.chainId, this.config.poolAddress);
|
|
227
227
|
const grgElapsed = Date.now() - grgStart;
|
|
228
228
|
logger_1.logger.info(`[AutoMint] GRG pipeline completed in ${grgElapsed}ms`);
|
|
229
229
|
if (grgElapsed > 50 && !this.warnedGrgSlow) {
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integrity Client — replaces local integrity computation with server-side API call.
|
|
3
|
+
* Core pipeline source code stays in Helm private repo. Only API calls go through npm SDK.
|
|
4
|
+
*
|
|
5
|
+
* Drop-in replacement interface for local encode() and verify() operations.
|
|
6
|
+
*/
|
|
7
|
+
export interface IntegrityEncodeResult {
|
|
8
|
+
/** Hex-encoded serialized shards (joined as JSON array of hex strings) */
|
|
9
|
+
shards: string[];
|
|
10
|
+
}
|
|
11
|
+
export interface IntegrityVerifyResult {
|
|
12
|
+
valid: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare class IntegrityClient {
|
|
15
|
+
private baseUrl;
|
|
16
|
+
private timeoutMs;
|
|
17
|
+
constructor(baseUrl?: string, options?: {
|
|
18
|
+
timeoutMs?: number;
|
|
19
|
+
});
|
|
20
|
+
/**
|
|
21
|
+
* Forward pass: encode data through integrity pipeline (server-side).
|
|
22
|
+
*
|
|
23
|
+
* @returns Array of Uint8Array shards
|
|
24
|
+
*/
|
|
25
|
+
encode(data: Uint8Array, chainId: number, poolAddress: string): Promise<Uint8Array[]>;
|
|
26
|
+
/**
|
|
27
|
+
* Verify: check data integrity (server-side).
|
|
28
|
+
*
|
|
29
|
+
* @returns boolean — true if data matches the original shards
|
|
30
|
+
*/
|
|
31
|
+
verify(data: Uint8Array, originalShards: Uint8Array[], chainId: number, poolAddress: string): Promise<boolean>;
|
|
32
|
+
/**
|
|
33
|
+
* Health check — ping the integrity API server.
|
|
34
|
+
* Returns true if reachable within timeoutMs.
|
|
35
|
+
*/
|
|
36
|
+
isReachable(): Promise<boolean>;
|
|
37
|
+
}
|
|
38
|
+
export declare function getDefaultIntegrityClient(): IntegrityClient;
|
|
39
|
+
export declare function setDefaultIntegrityClient(client: IntegrityClient): void;
|
|
@@ -1,26 +1,25 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Integrity Client — replaces local integrity computation with server-side API call.
|
|
4
|
+
* Core pipeline source code stays in Helm private repo. Only API calls go through npm SDK.
|
|
5
5
|
*
|
|
6
|
-
* Drop-in replacement interface for local
|
|
6
|
+
* Drop-in replacement interface for local encode() and verify() operations.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
-
class
|
|
9
|
+
exports.IntegrityClient = void 0;
|
|
10
|
+
exports.getDefaultIntegrityClient = getDefaultIntegrityClient;
|
|
11
|
+
exports.setDefaultIntegrityClient = setDefaultIntegrityClient;
|
|
12
|
+
class IntegrityClient {
|
|
13
13
|
baseUrl;
|
|
14
14
|
timeoutMs;
|
|
15
|
-
constructor(baseUrl = "https://
|
|
15
|
+
constructor(baseUrl = "https://integrity.helmprotocol.com/api/v1", options) {
|
|
16
16
|
this.baseUrl = baseUrl.replace(/\/$/, "");
|
|
17
17
|
this.timeoutMs = options?.timeoutMs ?? 5000;
|
|
18
18
|
}
|
|
19
19
|
/**
|
|
20
|
-
* Forward pass: encode data through
|
|
21
|
-
* Same interface contract as local GrgForward.encode().
|
|
20
|
+
* Forward pass: encode data through integrity pipeline (server-side).
|
|
22
21
|
*
|
|
23
|
-
* @returns Array of Uint8Array shards
|
|
22
|
+
* @returns Array of Uint8Array shards
|
|
24
23
|
*/
|
|
25
24
|
async encode(data, chainId, poolAddress) {
|
|
26
25
|
const controller = new AbortController();
|
|
@@ -37,7 +36,7 @@ class GrgApiClient {
|
|
|
37
36
|
signal: controller.signal,
|
|
38
37
|
});
|
|
39
38
|
if (!resp.ok) {
|
|
40
|
-
throw new Error(`
|
|
39
|
+
throw new Error(`Integrity API error: ${resp.status} ${resp.statusText}`);
|
|
41
40
|
}
|
|
42
41
|
const result = await resp.json();
|
|
43
42
|
return result.shards.map((hex) => Buffer.from(hex, "hex"));
|
|
@@ -47,8 +46,7 @@ class GrgApiClient {
|
|
|
47
46
|
}
|
|
48
47
|
}
|
|
49
48
|
/**
|
|
50
|
-
* Verify: check
|
|
51
|
-
* Same interface contract as local GrgInverse.verify().
|
|
49
|
+
* Verify: check data integrity (server-side).
|
|
52
50
|
*
|
|
53
51
|
* @returns boolean — true if data matches the original shards
|
|
54
52
|
*/
|
|
@@ -68,7 +66,7 @@ class GrgApiClient {
|
|
|
68
66
|
signal: controller.signal,
|
|
69
67
|
});
|
|
70
68
|
if (!resp.ok) {
|
|
71
|
-
throw new Error(`
|
|
69
|
+
throw new Error(`Integrity API error: ${resp.status} ${resp.statusText}`);
|
|
72
70
|
}
|
|
73
71
|
const result = await resp.json();
|
|
74
72
|
return result.valid;
|
|
@@ -78,7 +76,7 @@ class GrgApiClient {
|
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
78
|
/**
|
|
81
|
-
* Health check — ping the
|
|
79
|
+
* Health check — ping the integrity API server.
|
|
82
80
|
* Returns true if reachable within timeoutMs.
|
|
83
81
|
*/
|
|
84
82
|
async isReachable() {
|
|
@@ -99,18 +97,18 @@ class GrgApiClient {
|
|
|
99
97
|
}
|
|
100
98
|
}
|
|
101
99
|
}
|
|
102
|
-
exports.
|
|
100
|
+
exports.IntegrityClient = IntegrityClient;
|
|
103
101
|
/**
|
|
104
|
-
* Singleton default client — uses production
|
|
105
|
-
* Can be overridden via
|
|
102
|
+
* Singleton default client — uses production integrity API endpoint.
|
|
103
|
+
* Can be overridden via setDefaultIntegrityClient() for testing/staging.
|
|
106
104
|
*/
|
|
107
105
|
let _defaultClient = null;
|
|
108
|
-
function
|
|
106
|
+
function getDefaultIntegrityClient() {
|
|
109
107
|
if (!_defaultClient) {
|
|
110
|
-
_defaultClient = new
|
|
108
|
+
_defaultClient = new IntegrityClient();
|
|
111
109
|
}
|
|
112
110
|
return _defaultClient;
|
|
113
111
|
}
|
|
114
|
-
function
|
|
112
|
+
function setDefaultIntegrityClient(client) {
|
|
115
113
|
_defaultClient = client;
|
|
116
114
|
}
|
package/package.json
CHANGED
package/dist/grg_api_client.d.ts
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* GRG API Client — replaces local GRG computation with server-side API call.
|
|
3
|
-
* GRG source code stays in Helm private repo. Only API calls go through npm SDK.
|
|
4
|
-
*
|
|
5
|
-
* Drop-in replacement interface for local GrgForward.encode() and GrgInverse.verify().
|
|
6
|
-
*/
|
|
7
|
-
export interface GrgEncodeResult {
|
|
8
|
-
/** Hex-encoded serialized shards (joined as JSON array of hex strings) */
|
|
9
|
-
shards: string[];
|
|
10
|
-
}
|
|
11
|
-
export interface GrgVerifyResult {
|
|
12
|
-
valid: boolean;
|
|
13
|
-
}
|
|
14
|
-
export declare class GrgApiClient {
|
|
15
|
-
private baseUrl;
|
|
16
|
-
private timeoutMs;
|
|
17
|
-
constructor(baseUrl?: string, options?: {
|
|
18
|
-
timeoutMs?: number;
|
|
19
|
-
});
|
|
20
|
-
/**
|
|
21
|
-
* Forward pass: encode data through GRG pipeline (server-side).
|
|
22
|
-
* Same interface contract as local GrgForward.encode().
|
|
23
|
-
*
|
|
24
|
-
* @returns Array of Uint8Array shards (same shape as GrgForward.encode())
|
|
25
|
-
*/
|
|
26
|
-
encode(data: Uint8Array, chainId: number, poolAddress: string): Promise<Uint8Array[]>;
|
|
27
|
-
/**
|
|
28
|
-
* Verify: check GRG integrity (server-side).
|
|
29
|
-
* Same interface contract as local GrgInverse.verify().
|
|
30
|
-
*
|
|
31
|
-
* @returns boolean — true if data matches the original shards
|
|
32
|
-
*/
|
|
33
|
-
verify(data: Uint8Array, originalShards: Uint8Array[], chainId: number, poolAddress: string): Promise<boolean>;
|
|
34
|
-
/**
|
|
35
|
-
* Health check — ping the GRG API server.
|
|
36
|
-
* Returns true if reachable within timeoutMs.
|
|
37
|
-
*/
|
|
38
|
-
isReachable(): Promise<boolean>;
|
|
39
|
-
}
|
|
40
|
-
export declare function getDefaultGrgApiClient(): GrgApiClient;
|
|
41
|
-
export declare function setDefaultGrgApiClient(client: GrgApiClient): void;
|