openttt 0.2.0 → 0.2.2

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.
@@ -3,7 +3,7 @@
3
3
  // Turbo (50ms) vs Full (127ms)
4
4
  Object.defineProperty(exports, "__esModule", { value: true });
5
5
  exports.AdaptiveSwitch = exports.TIER_TOLERANCE_MS = exports.AdaptiveMode = void 0;
6
- const helm_crypto_1 = require("../vendor/helm-crypto");
6
+ const grg_inverse_1 = require("./grg_inverse");
7
7
  const logger_1 = require("./logger");
8
8
  var AdaptiveMode;
9
9
  (function (AdaptiveMode) {
@@ -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.GrgInverse.verify(block.data, tttRecord.grgPayload, chainId, poolAddress);
46
+ const integrityOk = grg_inverse_1.GrgInverse.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
@@ -7,7 +7,7 @@ const dynamic_fee_1 = require("./dynamic_fee");
7
7
  const evm_connector_1 = require("./evm_connector");
8
8
  const protocol_fee_1 = require("./protocol_fee");
9
9
  const pot_signer_1 = require("./pot_signer");
10
- const helm_crypto_1 = require("../vendor/helm-crypto");
10
+ const grg_forward_1 = require("./grg_forward");
11
11
  const types_1 = require("./types");
12
12
  const logger_1 = require("./logger");
13
13
  const errors_1 = require("./errors");
@@ -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.GrgForward.encode(ethers_1.ethers.getBytes(grgPayload), this.config.chainId, this.config.poolAddress);
226
+ const grgShards = grg_forward_1.GrgForward.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
@@ -1,4 +1,6 @@
1
- export * from "../vendor/helm-crypto";
1
+ export * from "./grg_forward";
2
+ export * from "./grg_inverse";
3
+ export * from "./grg_pipeline";
2
4
  export * from "./adaptive_switch";
3
5
  export * from "./evm_connector";
4
6
  export * from "./x402_enforcer";
@@ -20,3 +22,4 @@ export * from "./pot_signer";
20
22
  export * from "./ct_log";
21
23
  export * from "./trust_store";
22
24
  export * from "./revenue_tiers";
25
+ export * from "./integrity_client";
package/dist/index.js CHANGED
@@ -15,7 +15,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  // sdk/src/index.ts
18
- __exportStar(require("../vendor/helm-crypto"), exports);
18
+ __exportStar(require("./grg_forward"), exports);
19
+ __exportStar(require("./grg_inverse"), exports);
20
+ __exportStar(require("./grg_pipeline"), exports);
19
21
  __exportStar(require("./adaptive_switch"), exports);
20
22
  __exportStar(require("./evm_connector"), exports);
21
23
  __exportStar(require("./x402_enforcer"), exports);
@@ -37,3 +39,4 @@ __exportStar(require("./pot_signer"), exports);
37
39
  __exportStar(require("./ct_log"), exports);
38
40
  __exportStar(require("./trust_store"), exports);
39
41
  __exportStar(require("./revenue_tiers"), exports);
42
+ __exportStar(require("./integrity_client"), exports);
@@ -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
- * GRG API Client — replaces local GRG computation with server-side API call.
4
- * GRG source code stays in Helm private repo. Only API calls go through npm SDK.
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 GrgForward.encode() and GrgInverse.verify().
6
+ * Drop-in replacement interface for local encode() and verify() operations.
7
7
  */
8
8
  Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.GrgApiClient = void 0;
10
- exports.getDefaultGrgApiClient = getDefaultGrgApiClient;
11
- exports.setDefaultGrgApiClient = setDefaultGrgApiClient;
12
- class GrgApiClient {
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://grg.helmprotocol.com/api/v1", options) {
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 GRG pipeline (server-side).
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 (same shape as GrgForward.encode())
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(`GRG API error: ${resp.status} ${resp.statusText}`);
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 GRG integrity (server-side).
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(`GRG API error: ${resp.status} ${resp.statusText}`);
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 GRG API server.
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.GrgApiClient = GrgApiClient;
100
+ exports.IntegrityClient = IntegrityClient;
103
101
  /**
104
- * Singleton default client — uses production GRG API endpoint.
105
- * Can be overridden via setDefaultGrgApiClient() for testing/staging.
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 getDefaultGrgApiClient() {
106
+ function getDefaultIntegrityClient() {
109
107
  if (!_defaultClient) {
110
- _defaultClient = new GrgApiClient();
108
+ _defaultClient = new IntegrityClient();
111
109
  }
112
110
  return _defaultClient;
113
111
  }
114
- function setDefaultGrgApiClient(client) {
112
+ function setDefaultIntegrityClient(client) {
115
113
  _defaultClient = client;
116
114
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "openttt",
3
- "version": "0.2.0",
3
+ "version": "0.2.2",
4
4
  "description": "OpenTTT — TLS-grade transaction ordering for DeFi. Time + Logic + Sync.",
5
5
  "license": "BSL-1.1",
6
6
  "repository": {
@@ -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;