From d5d807b82c4e94ce3ff2b372e5db6d70179c0e3d Mon Sep 17 00:00:00 2001 From: Markeljan Sokoli Date: Mon, 24 Aug 2026 11:24:23 -0400 Subject: [PATCH] Add Polygon deployment support to SDK --- .changeset/polygon-mainnet-sdk.md | 7 ++ .github/workflows/ci.yml | 10 +++ .github/workflows/release.yml | 4 +- README.md | 3 +- apps/docs/app/page.tsx | 25 ++++--- bun.lock | 7 +- lefthook.yaml | 2 +- package.json | 1 + packages/w3gpt/README.md | 101 ++++++++++++++++++++------ packages/w3gpt/index.test.ts | 117 ++++++++++++++++++++++++++++++ packages/w3gpt/index.ts | 73 +++++++++++++++++-- packages/w3gpt/package.json | 27 ++++++- turbo.json | 1 + 13 files changed, 334 insertions(+), 44 deletions(-) create mode 100644 .changeset/polygon-mainnet-sdk.md create mode 100644 packages/w3gpt/index.test.ts diff --git a/.changeset/polygon-mainnet-sdk.md b/.changeset/polygon-mainnet-sdk.md new file mode 100644 index 0000000..87ab093 --- /dev/null +++ b/.changeset/polygon-mainnet-sdk.md @@ -0,0 +1,7 @@ +--- +"w3gpt": patch +--- + +Add typed Polygon mainnet and Amoy contract deployment support, package export +metadata, tests, and a prepack build so published releases include executable +artifacts. diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 26b15ae..54cbeba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -31,3 +31,13 @@ jobs: - name: Install dependencies run: bun install --frozen-lockfile + + - name: Build + run: bun run build + + - name: Test + run: bun run test + + - name: Verify package contents + working-directory: packages/w3gpt + run: npm pack --dry-run diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 01e763d..d801299 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -41,8 +41,8 @@ jobs: id: changesets uses: changesets/action@v1 with: - version: bun ci:version - publish: bun ci:release + version: bun changeset version + publish: bun changeset publish env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} NPM_TOKEN: ${{ secrets.NPM_TOKEN }} diff --git a/README.md b/README.md index 0f2ac61..de0efb1 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ Useful commands: The SDK mirrors the public Web3GPT skill flow: -1. Start a chat with no params +1. Call `deployContract` with an explicit Polygon mainnet (137) or Amoy + (80002) chain ID, or start a lower-level chat with no params 2. Save the returned `chatId` 3. Send follow-up messages with the same `chatId` 4. Add `history=true` or `full=true` when you want the full simplified history diff --git a/apps/docs/app/page.tsx b/apps/docs/app/page.tsx index 9611dc3..aee2674 100644 --- a/apps/docs/app/page.tsx +++ b/apps/docs/app/page.tsx @@ -2,21 +2,26 @@ import styles from "./page.module.css"; const installSnippet = `npm install w3gpt`; -const quickstartSnippet = `import { w3gpt } from "w3gpt"; +const quickstartSnippet = `import { PolygonChainId, w3gpt } from "w3gpt"; const client = w3gpt(); -const started = await client.startChat(); +const prepared = await client.deployContract({ + chainId: PolygonChainId.Mainnet, + prompt: "An ERC20 named GrantProof with symbol GRANT and fixed supply.", +}); + +console.log(prepared.response); -const reply = await client.chat({ - chatId: started.chatId, - message: "Deploy an ERC20 on Polygon mainnet with 1,000,000 supply", +const deployed = await client.chat({ + chatId: prepared.chatId, + message: "Yes. I confirm deployment to Polygon mainnet, chain ID 137.", }); -console.log(reply.response);`; +console.log(deployed.response);`; const historySnippet = `const history = await client.chat({ - chatId: started.chatId, + chatId: deployed.chatId, history: true, }); @@ -62,7 +67,9 @@ export default function Home() {

Model