Skip to content
Merged

Ts6 #793

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions analytics/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"serverless-scaleway-functions": ">=0.4.16",
"tsdown": "^0.23.1",
"tsx": "^4.23.5",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
"typescript-eslint": "^8.60.0",
"vitest": "^4.1.11"
},
Expand Down
2 changes: 1 addition & 1 deletion analytics/test/stats.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { privateKeyToAccount } from "viem/accounts";
import { privateKeyToAccount } from "@fretchen/chain-utils";

// The handler's module-level storage is S3HitStorage; the range logic below is
// tested directly against MemoryHitStorage instead.
Expand Down
8 changes: 4 additions & 4 deletions bunny_js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bunny_js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"prettier": "^3.6.2",
"tsdown": "^0.23.1",
"tsx": "^4.23.15",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
"typescript-eslint": "^8.58.2",
"vitest": "^4.1.11"
},
Expand Down
2 changes: 1 addition & 1 deletion bunny_js/src/facilitator/chain_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* Uses @fretchen/chain-utils for chain/address data.
*/

import type { Chain } from "viem";
import {
getViemChain,
tryGetEIP3009SplitterAddress,
Expand All @@ -14,6 +13,7 @@ import {
getSettlementTokens,
type Network,
type SettlementTokenInfo,
type Chain,
} from "@fretchen/chain-utils";

export interface ChainConfig {
Expand Down
2 changes: 1 addition & 1 deletion bunny_js/src/facilitator/facilitator_instance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* schemes coexist on the same /verify and /settle endpoints.
*/

import { createPublicClient, createWalletClient, http, type Account } from "viem";
import { createPublicClient, createWalletClient, http, type Account } from "@fretchen/chain-utils";
import { x402Facilitator } from "@x402/core/facilitator";
import { toFacilitatorEvmSigner } from "@x402/evm";
import { ExactEvmScheme } from "@x402/evm/exact/facilitator";
Expand Down
6 changes: 3 additions & 3 deletions bunny_js/src/facilitator/x402_fee.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import {
http,
getContract,
nonceManager,
privateKeyToAccount,
loadPrivateKey,
WaitForTransactionReceiptTimeoutError,
type Address,
type Abi,
type Hex,
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
} from "@fretchen/chain-utils";
import { logger } from "../logger";
import { loadPrivateKey } from "@fretchen/chain-utils";
import { findFeeToken, getChainConfig, getRpcUrl } from "./chain_utils";

// ═══════════════════════════════════════════════════════════════
Expand Down
3 changes: 1 addition & 2 deletions bunny_js/src/x402_channel_sync.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { createPublicClient, http } from "viem";
import { getViemChain, getRpcUrl } from "@fretchen/chain-utils";
import { createPublicClient, getViemChain, getRpcUrl, http } from "@fretchen/chain-utils";
import type { Channel, ChannelStorage } from "@x402/evm/batch-settlement/server";
import { logger } from "./logger.js";

Expand Down
1 change: 0 additions & 1 deletion bunny_js/test/facilitator/facilitator_routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,6 @@ describe("facilitator routes (verify + settle)", () => {
throw new Error("the body must not be read when Content-Length already refuses");
},
} as unknown as Request;
// eslint-disable-next-line @typescript-eslint/no-unsafe-argument
await expect(readCappedBody(req)).resolves.toBe("too-large");
});

Expand Down
9 changes: 4 additions & 5 deletions bunny_js/test/x402_channel_sync.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,13 @@ import type { Channel, ChannelStorage } from "@x402/evm/batch-settlement/server"

const { mockReadContract } = vi.hoisted(() => ({ mockReadContract: vi.fn() }));

vi.mock("viem", async () => {
const actual = await vi.importActual("viem");
return { ...actual, createPublicClient: vi.fn(() => ({ readContract: mockReadContract })) };
});

// The module takes its viem surface through the chain-utils facade (see
// shared/VIEM_TS6_NOTES.md), so the client factory is mocked where it is imported from.
vi.mock("@fretchen/chain-utils", () => ({
getViemChain: vi.fn(() => ({ id: 10 })),
getRpcUrl: vi.fn(() => "https://rpc.example"),
createPublicClient: vi.fn(() => ({ readContract: mockReadContract })),
http: vi.fn(() => "transport"),
}));

import { resyncChannelState } from "../src/x402_channel_sync.js";
Expand Down
2 changes: 2 additions & 0 deletions bunny_js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
"verbatimModuleSyntax": true,
"resolveJsonModule": true,
"skipLibCheck": true,
"types": ["node"],
"rootDir": "..",
"outDir": "dist",
"declaration": false,
"noEmit": true
Expand Down
7 changes: 7 additions & 0 deletions bunny_js/vitest.config.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { defineConfig } from "vitest/config";

export default defineConfig({
// One viem copy for the whole test graph: the src takes its viem surface through
// @fretchen/chain-utils (see shared/VIEM_TS6_NOTES.md), which resolves its own
// node_modules copy — without dedupe the vi.mock("viem") in the tests would only
// intercept this package's copy, and the chain-utils re-export would run real.
resolve: {
dedupe: ["viem"],
},
test: {
environment: "node",
globals: true,
Expand Down
8 changes: 4 additions & 4 deletions comment_service/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion comment_service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"prettier": "^3.0.0",
"serverless-scaleway-functions": ">=0.4.16",
"tsdown": "^0.23.1",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
"typescript-eslint": "^8.60.0",
"vitest": "^4.1.11"
},
Expand Down
1 change: 1 addition & 0 deletions comment_service/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"resolveJsonModule": true,
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"types": ["node"],
"noEmit": true
},
"include": ["*.ts", "test/**/*.ts"],
Expand Down
8 changes: 4 additions & 4 deletions observability/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion observability/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"eslint": "^10.0.0",
"prettier": "^3.6.2",
"tsx": "^4.23.12",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
"typescript-eslint": "^8.58.2",
"vitest": "^5.0.3"
}
Expand Down
22 changes: 10 additions & 12 deletions scw_js/genimg_x402_token.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,28 @@ import {
isTestnet,
loadPrivateKey,
getRpcUrl,
} from "@fretchen/chain-utils";
import { parseJsonBody, CORS_HEADERS, errorResponse, openAiError } from "./utils.js";
import {
ImageGenerationRequestSchema,
ADVERTISED_MODELS,
MODEL_TO_PROVIDER,
type ImageGenerationResponse,
} from "./genimg_schemas.js";
import type { z } from "zod";
import {
getContract,
createWalletClient,
createPublicClient,
http,
parseEther,
privateKeyToAccount,
type PublicClient,
type WalletClient,
type Chain,
type Account,
type Transport,
type GetContractReturnType,
} from "viem";
} from "@fretchen/chain-utils";
import { parseJsonBody, CORS_HEADERS, errorResponse, openAiError } from "./utils.js";
import {
ImageGenerationRequestSchema,
ADVERTISED_MODELS,
MODEL_TO_PROVIDER,
type ImageGenerationResponse,
} from "./genimg_schemas.js";
import type { z } from "zod";
import { generateAndUploadImage, JSON_BASE_PATH, type Provider } from "./image_service.js";
import { privateKeyToAccount } from "viem/accounts";
import {
createResourceServer,
createPaymentRequirements,
Expand Down
3 changes: 2 additions & 1 deletion scw_js/llm_x402_cron.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import { logger } from "./logger.js";
import { createPublicClient, http } from "viem";
import {
createPublicClient,
getSettlementTokens,
getViemChain,
getRpcUrl,
http,
type SettlementTokenInfo,
} from "@fretchen/chain-utils";
import {
Expand Down
8 changes: 4 additions & 4 deletions scw_js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion scw_js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"prettier": "^3.6.2",
"serverless-scaleway-functions": ">=0.5.1",
"tsdown": "^0.23.1",
"typescript": "^5.9.3",
"typescript": "^6.0.3",
"typescript-eslint": "^8.58.2",
"vitest": "^4.1.11"
},
Expand Down
11 changes: 6 additions & 5 deletions scw_js/scripts/fee_allowances.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,11 @@ import {
erc20Abi,
formatUnits,
http,
type Address,
} from "viem";
import { privateKeyToAccount } from "viem/accounts";
import {
privateKeyToAccount,
getRpcUrl,
getViemChain,
loadPrivateKey,
type Address,
type SettlementTokenInfo,
} from "@fretchen/chain-utils";
import { facilitatorFeeFor } from "../fee_config.js";
Expand Down Expand Up @@ -108,7 +106,10 @@ function units(atomic: bigint, decimals: number): string {
}

function publicClientFor(network: string) {
return createPublicClient({ chain: getViemChain(network), transport: http(getRpcUrl(network)) });
return createPublicClient({
chain: getViemChain(network),
transport: http(getRpcUrl(network)),
});
}

async function readAllowance(
Expand Down
3 changes: 1 addition & 2 deletions scw_js/scripts/sign_ownership_proof.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@
* Usage (from scw_js/): npx tsx scripts/sign_ownership_proof.ts <origin-url>
*/
import dotenv from "dotenv";
import { privateKeyToAccount } from "viem/accounts";
import { loadPrivateKey } from "@fretchen/chain-utils";
import { loadPrivateKey, privateKeyToAccount } from "@fretchen/chain-utils";

// Resolves relative to cwd (scw_js/), matching how npm run dev:* scripts are invoked.
dotenv.config();
Expand Down
17 changes: 10 additions & 7 deletions scw_js/test/getChain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,25 @@
* - Mismatch causes settlement to fail AFTER expensive operations complete
*/
import { describe, test, expect } from "vitest";
import { createPublicClient, http, type Chain } from "viem";
import { optimism, optimismSepolia, base, baseSepolia } from "viem/chains";

// Import functions under test
import { getExpectedNetworks, validatePaymentNetwork } from "../getChain.js";

// Import from chain-utils
import {
createPublicClient,
http,
optimism,
optimismSepolia,
base,
baseSepolia,
getGenAiNFTMainnetNetworks,
getGenAiNFTTestnetNetworks,
getViemChain,
getUSDCConfig,
getRpcUrl,
toCAIP2,
type Chain,
} from "@fretchen/chain-utils";

// Import functions under test
import { getExpectedNetworks, validatePaymentNetwork } from "../getChain.js";

// USDC contracts expose name() and version() functions for EIP-712 domain
// Note: They do NOT implement EIP-5267 eip712Domain(), so we read individual functions
const USDC_ABI = [
Expand Down
Loading