{"_id":"@beriktassuly/txline","_rev":"2-2ebd451a3d7ac411f286c39002ef777a","name":"@beriktassuly/txline","dist-tags":{"latest":"0.4.0"},"versions":{"0.3.5":{"name":"@beriktassuly/txline","version":"0.3.5","keywords":["txline","txodds","solana","sdk"],"license":"MIT OR Apache-2.0","_id":"@beriktassuly/txline@0.3.5","maintainers":[{"name":"beriktassuly","email":"berektasulymuhammedali@gmail.com"}],"homepage":"https://github.com/Berektassuly/txline#readme","bugs":{"url":"https://github.com/Berektassuly/txline/issues"},"dist":{"shasum":"e0d26e15011e31ad083bd57c8a872ce80ae3e259","tarball":"https://registry.npmjs.org/@beriktassuly/txline/-/txline-0.3.5.tgz","fileCount":127,"integrity":"sha512-E32/AqONroiCGDWR7XhkTGJdWeBtYg1+MaKtBTW/gKu5cf7Gy6itwcC+eWN+I4X2pZhPye+CPB70cYNYfc4q6g==","signatures":[{"sig":"MEUCIQDzNZ5SyMY/Qin8q0k65lykoP3Z2P0QWjPRjsrHuWw3+QIgJuTDKqY0dScjfrQl0eDFnN4/864gMYFfN/T3YtRivLA=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":255531},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"gitHead":"e0b078f8cce51736b1a6a1404b108c74929e5fee","scripts":{"test":"vitest run","build":"tsc -p tsconfig.json","typecheck":"tsc --noEmit -p tsconfig.json"},"_npmUser":{"name":"beriktassuly","email":"berektasulymuhammedali@gmail.com"},"repository":{"url":"git+https://github.com/Berektassuly/txline.git","type":"git","directory":"typescript"},"_npmVersion":"11.12.1","description":"TypeScript/JavaScript SDK for TxLINE Devnet REST, SSE, validation, and Solana instruction builders","directories":{},"_nodeVersion":"24.14.1","dependencies":{"@solana/kit":"^7.0.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^4.1.10","typescript":"^6.0.3","@types/node":"^24.0.0"},"_npmOperationalInternal":{"tmp":"tmp/txline_0.3.5_1783374398455_0.6085203645197379","host":"s3://npm-registry-packages-npm-production"}},"0.4.0":{"name":"@beriktassuly/txline","version":"0.4.0","description":"TypeScript/JavaScript SDK for TxLINE Devnet REST, SSE, validation, and Solana instruction builders","type":"module","packageManager":"npm@11.18.0","main":"./dist/index.js","types":"./dist/index.d.ts","repository":{"type":"git","url":"git+https://github.com/Berektassuly/txline.git","directory":"typescript"},"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js"},"./package.json":"./package.json"},"scripts":{"build":"tsc -p tsconfig.json","format":"prettier --check package.json tsconfig.json tsconfig.eslint.json .prettierrc.json eslint.config.mjs vitest.config.ts \"scripts/**/*.mjs\" \"src/**/*.ts\" \"tests/**/*.ts\" README.md NOTES.md","lint":"eslint . --max-warnings=0","security:audit":"npm audit --audit-level=high","security:signatures":"npm audit signatures","test":"vitest run","test:coverage":"vitest run --coverage","typecheck":"tsc --noEmit -p tsconfig.json","verify:package":"node scripts/verify-package.mjs"},"keywords":["txline","txodds","solana","sdk"],"license":"MIT OR Apache-2.0","publishConfig":{"access":"public"},"dependencies":{"@solana/kit":"^7.0.0"},"devDependencies":{"@eslint/js":"^10.0.1","@types/node":"^24.0.0","@vitest/coverage-v8":"^4.1.10","eslint":"^10.6.0","globals":"^17.7.0","prettier":"^3.9.4","typescript":"^6.0.3","typescript-eslint":"^8.63.0","vitest":"^4.1.10"},"gitHead":"a4475bb4eb3d901325e45d8438d1205f927aad99","_id":"@beriktassuly/txline@0.4.0","bugs":{"url":"https://github.com/Berektassuly/txline/issues"},"homepage":"https://github.com/Berektassuly/txline#readme","_nodeVersion":"24.18.0","_npmVersion":"11.18.0","dist":{"integrity":"sha512-I2vYRkQqJDi/7awmbLkbaoX9UMmYjqehtlsrgJk6dE/ni8yKy51sPxbejTI4GpcdGGlW92ToC03nRLxV5HZYEw==","shasum":"c8887d9b615dcbcd16ce8ffe625884b7e4e7a18a","tarball":"https://registry.npmjs.org/@beriktassuly/txline/-/txline-0.4.0.tgz","fileCount":131,"unpackedSize":313935,"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@beriktassuly%2ftxline@0.4.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCZfhuFdYua1sgKSDcIJd4VtS5jgtMGGbW2C9ropP23pQIhAPzLvWv+4Qb+LreBLHX+3ZSO0cVtA7ptlinIJORpk9h6"}]},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:9f78bffe-f96b-4afe-bbf0-7f3b668fe820"}},"directories":{},"maintainers":[{"name":"beriktassuly","email":"berektasulymuhammedali@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/txline_0.4.0_1783439495747_0.02373315367330342"},"_hasShrinkwrap":false}},"time":{"created":"2026-07-06T21:46:38.302Z","modified":"2026-07-07T15:51:36.204Z","0.3.5":"2026-07-06T21:46:38.606Z","0.4.0":"2026-07-07T15:51:35.890Z"},"bugs":{"url":"https://github.com/Berektassuly/txline/issues"},"license":"MIT OR Apache-2.0","homepage":"https://github.com/Berektassuly/txline#readme","keywords":["txline","txodds","solana","sdk"],"repository":{"type":"git","url":"git+https://github.com/Berektassuly/txline.git","directory":"typescript"},"description":"TypeScript/JavaScript SDK for TxLINE Devnet REST, SSE, validation, and Solana instruction builders","maintainers":[{"name":"beriktassuly","email":"berektasulymuhammedali@gmail.com"}],"readme":"# TxLINE TypeScript SDK\n\nTypeScript-first SDK for TxLINE Devnet REST, SSE, validation payload helpers, and Solana instruction builders.\n\nThis package is Devnet-first. Mainnet addresses are exposed only as verified reference data; transaction flows are not presented as Mainnet-ready.\n\n## Install And Develop\n\nPublished package: <https://www.npmjs.com/package/@beriktassuly/txline>\n\nInstall from npm:\n\n```bash\nnpm install @beriktassuly/txline\n```\n\nDevelop from this repository:\n\n```bash\nnpm ci --ignore-scripts\nnpm run security:audit\nnpm run security:signatures\nnpm run format\nnpm run lint\nnpm run typecheck\nnpm test\nnpm run test:coverage\nnpm run build\nnpm run verify:package\n```\n\nThe package uses npm and a checked-in `package-lock.json` for deterministic\nNode-compatible installs. CI also checks registry signatures, high-severity\naudit findings, typed ESLint rules, Prettier formatting, coverage thresholds,\nand the packed npm artifact.\n\n## Quick Start\n\n```ts\nimport { TxlineClient, devnetConfig } from \"@beriktassuly/txline\";\n\nconst client = new TxlineClient({ config: devnetConfig() });\n\nconst guestJwt = await client.startGuestSession();\nclient.setGuestJwt(guestJwt);\n\nif (process.env.TXLINE_API_TOKEN) {\n  client.setApiToken(process.env.TXLINE_API_TOKEN);\n}\n\nconst fixtures = await client.fixtures().snapshot({ competitionId: 1 });\n```\n\nLive examples require caller-provided credentials, wallet signatures, and RPC/API access. Do not commit tokens, JWTs, signatures, seed phrases, private keys, generated live responses, or full auth headers.\n\n## REST\n\n```ts\nconst quote = await client.purchaseQuote(buyerAddress, 1_000n);\n\nconst validation = await client.scores().statValidationV2({\n  fixtureId: 17_952_170,\n  seq: 1,\n  statKeys: [1001, 1002],\n});\n```\n\nREST methods build the current OpenAPI query names, including V2 score stat validation via `statKeys=1001,1002`.\n\n## SSE\n\nStreams require both the guest JWT and activated API token to be set on the\nclient.\n\n```ts\nconst controller = new AbortController();\n\nfor await (const event of client.scoresStream().stream({\n  fixtureId: 17_952_170,\n  signal: controller.signal,\n})) {\n  console.log(event.id, event.data.seq);\n}\n```\n\nThe SSE client parses event blocks, filters `heartbeat`, preserves `Last-Event-ID`, respects server `retry:` hints, reconnects after interruptions, requires an activated API token, and refreshes guest JWTs on stream `401`/`403`.\n\n## World Cup Trading Lifecycle\n\nThe SDK includes Devnet-only helpers for World Cup hackathon projects that need to connect TxLINE scores to score-settled trading or prediction-market flows. The helpers compose published REST, SSE, validation, and public Devnet IDL builders. They do not add unpublished trading REST endpoints, derive unverified trading PDAs, sign transactions, submit transactions, or compute a production terms-hash preimage.\n\nUseful source links:\n\n- [World Cup hackathon](https://superteam.fun/earn/hackathon/world-cup/)\n- [On-chain validation guide](https://txline.txodds.com/documentation/examples/onchain-validation)\n- [Streaming data guide](https://txline.txodds.com/documentation/examples/streaming-data)\n- [Devnet IDL JSON](https://github.com/txodds/tx-on-chain/blob/main/examples/devnet/idl/txoracle.json)\n\nLifecycle outline:\n\n1. Subscribe on Devnet and activate API access using `startGuestSession`, `subscribeInstruction`, `activationPreimage`, and `activateSubscription`, or inject caller-provided guest JWT and API token with `setGuestJwt` and `setApiToken`.\n2. Define score-market terms with helpers such as `finalOutcomeMarketTerms`, `totalGoalsMarketTerms`, or `spreadMarketTerms`.\n3. Pass an explicit 32-byte caller-owned terms hash to `createIntentPlan`, `createTradePlan`, or `claimBatchLegacyPlan`. The public Devnet IDL requires `[u8; 32]`, but the canonical production preimage is not published.\n4. Observe live odds and scores through `oddsStream()` and `scoresStream()`, or fetch historical score records with `client.scores().historicalByFixture(fixtureId)`.\n5. Detect final soccer outcomes with `isFinalOutcomeRecord` and `extractFinalOutcome`. The documented final-outcome record shape is `action=game_finalised`, `statusId=100`, and `period=100`; soccer defaults use stat key `1` for participant 1 goals and stat key `2` for participant 2 goals.\n6. Fetch V2 proof payloads with `client.scores().statValidationV2({ fixtureId, seq, statKeys })`, then build validation inputs and strategies with `finalOutcomeProof`, `finalOutcomeStrategy`, `validationInputForMarket`, or `marketTermsStrategy`.\n7. Build the on-chain instruction you need with `finalOutcomeValidationPlan`, `settleTradePlan`, `settleMatchedTradePlan`, `claimViaResolutionPlan`, `claimBatchLegacyPlan`, `refundBatchPlan`, or `auditTradeResultPlan`.\n\n```ts\nimport {\n  TxlineClient,\n  defaultSoccerFinalOutcomeConfig,\n  devnetConfig,\n  extractFinalOutcome,\n  finalOutcomeProof,\n  finalOutcomeStatKeys,\n  isFinalOutcomeRecord,\n  validateStatV2Instruction,\n} from \"@beriktassuly/txline\";\n\nconst client = new TxlineClient({ config: devnetConfig() });\nclient.setGuestJwt(\"caller-provided-guest-jwt\");\nclient.setApiToken(\"caller-provided-api-token\");\n\nconst fixtureId = 17_952_170;\nconst scores = await client.scores().historicalByFixture(fixtureId);\nconst finalScore = scores.find(isFinalOutcomeRecord);\nif (!finalScore) throw new Error(\"final outcome not found\");\n\nconst outcome = extractFinalOutcome(finalScore, defaultSoccerFinalOutcomeConfig());\n\nconst validation = await client.scores().statValidationV2({\n  fixtureId: outcome.fixtureId,\n  seq: outcome.seq,\n  statKeys: finalOutcomeStatKeys(outcome.config),\n});\n\nconst proof = finalOutcomeProof(outcome, validation);\nconst dailyScoresRoot = \"caller-provided-daily-scores-root\";\nconst ix = validateStatV2Instruction(\n  devnetConfig().programId,\n  dailyScoresRoot,\n  proof.payload,\n  proof.strategy,\n);\n```\n\n`dailyScoresRoot` is the Devnet daily scores root account for the proof timestamp. Applications may derive it with `DevnetPdas` or use `devnetFinalOutcomeValidationPlan` to derive it inside the SDK. Trading plans still require caller-supplied intent, escrow, vault, token, winner, resolver, and signer accounts from the coordinating application or backend.\n\n## Validation\n\n```ts\nimport {\n  comparison,\n  strategyBuilder,\n  traderPredicate,\n  validateStatV2Instruction,\n} from \"@beriktassuly/txline\";\n\nconst strategy = strategyBuilder(validation.statsToProve().length)\n  .single(0, traderPredicate(1, comparison.greaterThan()))\n  .build();\n\nconst instruction = validateStatV2Instruction(\n  devnetConfig().programId,\n  dailyScoresRoot,\n  validation.toValidationInput(),\n  strategy,\n);\n```\n\nProof hashes may be base64, hex, or byte arrays and must decode to exactly 32 bytes. V2 helpers preserve requested stat-key order and reject mismatched `statsToProve`/`statProofs` lengths.\n\n## Solana Builders\n\n```ts\nimport {\n  DEVNET_PROGRAM_ID,\n  devnetSubscribeAccounts,\n  subscribeInstruction,\n} from \"@beriktassuly/txline\";\n\nconst accounts = await devnetSubscribeAccounts(userAddress);\nconst ix = subscribeInstruction(DEVNET_PROGRAM_ID, accounts, {\n  serviceLevelId: 1,\n  weeks: 4,\n});\n```\n\nTrading builders are low-level by design: pass explicit accounts for `createIntent`, `createTrade`, `executeMatch`, settlement, claim, refund, and audit instructions. The SDK does not derive or validate unverified trading PDAs.\n\n## Purchase Quote Safety\n\nBackend quote transaction bytes are not considered safe for signing by default.\n\n```ts\nconst checked = await client.purchaseQuoteChecked(buyerAddress, 1_000n, expectedBackendSigner);\n\nconst bytes = checked.transactionBytes;\n```\n\n`purchaseQuoteChecked` validates financial shape, decodes the transaction, rejects address table lookups, checks allowed programs, requires exactly one TxLINE `purchase_subscription_token_usdt` instruction, verifies the discriminator and requested amount, checks the Devnet account layout, and requires the expected backend signer.\n\nRaw helpers are intentionally named `Unchecked` for diagnostics only.\n\n## Source Notes\n\nSee [NOTES.md](./NOTES.md) for public-source conflicts around OpenAPI version, public program docs, pinned Rust Devnet IDL coverage, and `validate_stat_v2`.\n","readmeFilename":"README.md"}