From eb34ca967e3ab5609dd24090f208868ca0a236e0 Mon Sep 17 00:00:00 2001 From: MicBun Date: Mon, 25 Nov 2024 15:49:01 +0700 Subject: [PATCH 1/2] chore: update old references to the new organization --- .github/ISSUE_TEMPLATE/bug-report.yml | 10 ++++----- .github/ISSUE_TEMPLATE/config.yml | 2 +- .github/ISSUE_TEMPLATE/feature-request.yml | 4 ++-- README.md | 24 ++++++++++----------- docs/api-reference.md | 8 +++---- docs/core-concepts.md | 10 ++++----- docs/getting-started.md | 20 ++++++++--------- package.json | 25 +++++++++++----------- src/client/browserClient.ts | 8 +++---- src/client/client.test.ts | 6 +++--- src/client/client.ts | 12 +++++------ src/client/listAllStreams.ts | 2 +- src/client/nodeClient.ts | 8 +++---- src/contracts-api/deployStream.ts | 4 ++-- src/contracts-api/destroyStream.ts | 2 +- src/contracts-api/stream.ts | 2 +- src/index.browser.ts | 2 +- src/index.common.ts | 2 +- src/index.node.ts | 2 +- src/index.ts | 4 ++-- tests/integration/composedStream.test.ts | 4 ++-- tests/integration/getAllStreams.test.ts | 4 ++-- tests/integration/permissions.test.ts | 8 +++---- tests/integration/utils.ts | 12 +++++------ 24 files changed, 93 insertions(+), 92 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index 82982e2..bc52cfb 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,19 +1,19 @@ name: Bug Report -description: Something with tsn-sdk-js is not working as expected. +description: Something with truf-node-sdk-js is not working as expected. title: "Bug: " labels: ["bug"] body: - type: markdown attributes: value: | - Thank you for taking the time to report an issue. This form is for reporting **bugs in tsn-sdk-js**. + Thank you for taking the time to report an issue. This form is for reporting **bugs in truf-node-sdk-js**. When submitting logs, please submit them as text and not as a screenshot. - type: input id: version attributes: label: Version / Commit - description: Please include the release version or commit hash of tsn-sdk-js you are using. Write `unknown` if you are unsure. + description: Please include the release version or commit hash of truf-node-sdk-js you are using. Write `unknown` if you are unsure. placeholder: e.g. v0.1.0 or 1234567890abcdef validations: required: true @@ -38,7 +38,7 @@ body: attributes: label: Expected Behavior description: Please describe what you expected to happen. - placeholder: e.g. I expected tsn-sdk-js to do X when I did Y + placeholder: e.g. I expected truf-node-sdk-js to do X when I did Y validations: required: true - type: textarea @@ -46,7 +46,7 @@ body: attributes: label: Actual Behavior description: Please describe what actually happened. - placeholder: e.g. tsn-sdk-js did Z instead of X when I did Y + placeholder: e.g. truf-node-sdk-js did Z instead of X when I did Y validations: required: true - type: textarea diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index 13dafd9..c654407 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: true contact_links: - name: Ask a question - url: https://github.com/truflation/tsn-sdk-js/discussions + url: https://github.com/trufnetwork/truf-node-sdk-js/discussions about: Please ask and answer questions here diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index c4e224e..61cff8d 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,12 +1,12 @@ name: Feature Request -description: Suggest a new feature or change for tsn-sdk-js. +description: Suggest a new feature or change for truf-node-sdk-js. title: "Feature Request: " labels: ["enhancement"] body: - type: markdown attributes: value: | - Thank you for taking the time to suggest a feature or change. This form is for suggesting **features or changes to tsn-sdk-js**. + Thank you for taking the time to suggest a feature or change. This form is for suggesting **features or changes to truf-node-sdk-js**. Feel free to discuss or mull over potential features. - type: textarea diff --git a/README.md b/README.md index d0e5858..3fa03ef 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# TSN SDK JS +# TN SDK JS -The TSN SDK provides developers with tools to interact with the Truflation Stream Network, a decentralized platform for publishing, composing, and consuming economic data streams. +The TN SDK provides developers with tools to interact with the Truf Network, a decentralized platform for publishing, composing, and consuming economic data streams. ## Quick Start @@ -9,7 +9,7 @@ The TSN SDK provides developers with tools to interact with the Truflation Strea ### Installation ```bash -npm install @truflation/tsn-sdk-js +npm install @trufnetwork/truf-node-sdk-js # or your preferred package manager ``` @@ -17,25 +17,25 @@ npm install @truflation/tsn-sdk-js ```ts // For Node.js applications -import { NodeTSNClient } from "@truflation/tsn-sdk-js"; +import { NodeTNClient } from "@trufnetwork/truf-node-sdk-js"; // For browser applications -import { BrowserTSNClient } from "@truflation/tsn-sdk-js"; +import { BrowserTNClient } from "@trufnetwork/truf-node-sdk-js"; ``` ### Example Usage ```ts -import { NodeTSNClient, StreamId } from "@truflation/tsn-sdk-js"; +import { NodeTNClient, StreamId } from "@trufnetwork/truf-node-sdk-js"; // Initialize client -const client = new NodeTSNClient({ +const client = new NodeTNClient({ endpoint: "https://staging.tsn.truflation.com", signerInfo: { address: wallet.address, signer: wallet, // Any object that implements signMessage }, - chainId: "tsn-1", // or use NodeTSNClient.getDefaultChainId() + chainId: "tsn-1", // or use NodeTNClient.getDefaultChainId() }); // Deploy and initialize a stream @@ -63,18 +63,18 @@ const data = await stream.getRecord({ ``` For a complete working example: -- Check our [TSN SDK Demo Repository](https://github.com/truflation/tsn-sdk-demo) +- Check our [TN SDK Demo Repository](https://github.com/truflation/tsn-sdk-demo) - Try the [Live Demo on CodeSandbox](https://codesandbox.io/p/devbox/m2r3tt?file=%2Fsrc%2Froutes%2F%2Bpage.svelte) - Try reading from [a Truflation Stream on CodeSandbox with NodeJS](https://codesandbox.io/p/devbox/rtm7mn?file=%2Findex.ts%3A22%2C11) ## Stream Types -TSN supports two main types of streams: +TN supports two main types of streams: - **Primitive Streams**: Direct data sources from providers - **Composed Streams**: Aggregate data from multiple streams using weights -More information about TSN components can be found in the [Go TSN-SDK Documentation](https://github.com/truflation/tsn-sdk/blob/main/docs/readme.md). +More information about TN components can be found in the [Js TN-SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/docs/api-reference.md). ## Documentation @@ -88,7 +88,7 @@ A staging network is available at https://staging.tsn.truflation.com for testing ## Support -For support, please [open an issue](https://github.com/truflation/tsn-sdk-js/issues). +For support, please [open an issue](https://github.com/trufnetwork/truf-node-sdk-js/issues). ## License diff --git a/docs/api-reference.md b/docs/api-reference.md index c6f7a16..7628b38 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -1,13 +1,13 @@ # API Reference -For detailed information about TSN concepts and operations, please refer to the [Go SDK Documentation](https://github.com/truflation/tsn-sdk/blob/main/docs/readme.md). +For detailed information about TN concepts and operations, please refer to the [Js SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/docs/api-reference.md). ## Client Initialization ```typescript -import { NodeTSNClient, BrowserTSNClient } from "@truflation/tsn-sdk-js"; +import { NodeTNClient, BrowserTNClient } from "@trufnetwork/truf-node-sdk-js"; -const client = new NodeTSNClient({ +const client = new NodeTNClient({ endpoint: "https://staging.tsn.truflation.com", signerInfo: { address: wallet.address, @@ -17,7 +17,7 @@ const client = new NodeTSNClient({ }); // Get chain ID automatically -const chainId = await NodeTSNClient.getDefaultChainId(endpoint); +const chainId = await NodeTNClient.getDefaultChainId(endpoint); ``` ## Stream Operations diff --git a/docs/core-concepts.md b/docs/core-concepts.md index 2c5f511..7af31c9 100644 --- a/docs/core-concepts.md +++ b/docs/core-concepts.md @@ -2,20 +2,20 @@ ## Stream Types -TSN supports two types of streams: +TN supports two types of streams: - **Primitive Streams**: Single data source streams that store raw values - **Composed Streams**: Aggregate multiple streams with configurable weights ```typescript -import { StreamType } from "@truflation/tsn-sdk-js"; +import { StreamType } from "@trufnetwork/truf-node-sdk-js"; // Available stream types StreamType.Primitive // Single data source StreamType.Composed // Aggregates multiple streams with weights ``` -For detailed information about stream types and their use cases, see the [Go SDK Documentation](https://github.com/truflation/tsn-sdk/blob/main/docs/readme.md). +For detailed information about stream types and their use cases, see the [Js SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/README.md). ## Error Handling @@ -52,7 +52,7 @@ const streamId = await StreamId.generate("my-unique-name"); Streams support granular permissions for both reading and composing: ```typescript -import { visibility } from "@truflation/tsn-sdk-js"; +import { visibility } from "@trufnetwork/truf-node-sdk-js"; // Set visibility await stream.setReadVisibility(visibility.private); @@ -81,5 +81,5 @@ if (tx.data?.tx_hash) { ## Further Reading - [Integration Tests](../tests/integration) - Usage examples -- [Go SDK Documentation](https://github.com/truflation/tsn-sdk/blob/main/docs/readme.md) - Detailed TSN concepts +- [Js SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/README.md) - Detailed TN concepts - [monads-io Documentation](https://github.com/AlexXanderGrib/monads-io) - Error handling patterns diff --git a/docs/getting-started.md b/docs/getting-started.md index e239de8..084f8d9 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -1,4 +1,4 @@ -# Getting Started with TSN SDK JS +# Getting Started with TN SDK JS ## Prerequisites - Node.js 18 or later @@ -6,24 +6,24 @@ ## Installation ```bash -npm install @truflation/tsn-sdk-js +npm install @trufnetwork/truf-node-sdk-js # or -pnpm install @truflation/tsn-sdk-js +pnpm install @trufnetwork/truf-node-sdk-js # or -yarn add @truflation/tsn-sdk-js +yarn add @trufnetwork/truf-node-sdk-js ``` ## Quick Start ```typescript -import { NodeTSNClient, StreamId } from "@truflation/tsn-sdk-js"; +import { NodeTNClient, StreamId } from "@trufnetwork/truf-node-sdk-js"; import { Wallet } from "ethers"; // Initialize client const wallet = new Wallet(privateKey); -const chainId = await NodeTSNClient.getDefaultChainId("https://staging.tsn.truflation.com"); +const chainId = await NodeTNClient.getDefaultChainId("https://staging.tsn.truflation.com"); -const client = new NodeTSNClient({ +const client = new NodeTNClient({ endpoint: "https://staging.tsn.truflation.com", signerInfo: { address: wallet.address, @@ -61,10 +61,10 @@ The SDK provides optimized clients for different environments: ```typescript // For Node.js -import { NodeTSNClient } from "@truflation/tsn-sdk-js"; +import { NodeTNClient } from "@trufnetwork/truf-node-sdk-js"; // For browsers -import { BrowserTSNClient } from "@truflation/tsn-sdk-js"; +import { BrowserTNClient } from "@trufnetwork/truf-node-sdk-js"; ``` ## Next Steps @@ -75,4 +75,4 @@ import { BrowserTSNClient } from "@truflation/tsn-sdk-js"; ## Support -For support and issues, please visit our [GitHub repository](https://github.com/truflation/tsn-sdk-js/issues). +For support and issues, please visit our [GitHub repository](https://github.com/trufnetwork/truf-node-sdk-js/issues). diff --git a/package.json b/package.json index 3a4a98e..dd483c5 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,10 @@ { - "name": "@truflation/tsn-sdk-js", + "name": "@trufnetwork/truf-node-sdk-js", "version": "0.1.0", - "description": "Truflation Stream Network SDK for JavaScript", + "description": "Truf Network SDK for JavaScript", "type": "module", "keywords": [ - "tsn", + "truf", "truflation", "sdk", "javascript", @@ -43,29 +43,30 @@ "prepublishOnly": "npm run build" }, "dependencies": { - "monads-io": "^4.0.2", + "@kwilteam/kwil-js": "^0.7.3", + "@truflation/tsn-sdk-js": "github:trufnetwork/truf-node-sdk-js", "crypto-hash": "^3.1.0", "lodash": "^4.17.21", - "@kwilteam/kwil-js": "^0.7.3" + "monads-io": "^4.0.2" }, "devDependencies": { + "@types/lodash": "4.17.12", "@types/node": "18.18.1", - "glob": "11.0.0", "@typescript-eslint/eslint-plugin": "8.11.0", "@typescript-eslint/parser": "8.11.0", - "@types/lodash": "4.17.12", + "disposablestack": "1.1.6", + "esbuild": "0.24.0", + "eslint": "9.13.0", "eslint-config-prettier": "9.1.0", + "eslint-import-resolver-alias": "1.1.2", "eslint-import-resolver-typescript": "3.6.3", "eslint-plugin-import": "2.31.0", "eslint-plugin-jest": "28.8.3", + "eslint-plugin-prettier": "5.2.1", "eslint-plugin-simple-import-sort": "12.1.1", "eslint-plugin-unused-imports": "4.1.4", - "disposablestack": "1.1.6", - "esbuild": "0.24.0", - "eslint-import-resolver-alias": "1.1.2", - "eslint-plugin-prettier": "5.2.1", - "eslint": "9.13.0", "ethers": "6.13.4", + "glob": "11.0.0", "prettier": "3.3.3", "tsx": "^4.19.1", "typescript": "^5.6.3", diff --git a/src/client/browserClient.ts b/src/client/browserClient.ts index f703212..0767bbf 100644 --- a/src/client/browserClient.ts +++ b/src/client/browserClient.ts @@ -1,9 +1,9 @@ import { EnvironmentType } from "@kwilteam/kwil-js/dist/core/enums"; import { WebKwil } from "@kwilteam/kwil-js"; -import { BaseTSNClient, TSNClientOptions } from "./client"; +import { BaseTNClient, TNClientOptions } from "./client"; -export class BrowserTSNClient extends BaseTSNClient { - constructor(options: TSNClientOptions) { +export class BrowserTNClient extends BaseTNClient { + constructor(options: TNClientOptions) { super(options); this.kwilClient = new WebKwil({ ...options, @@ -12,4 +12,4 @@ export class BrowserTSNClient extends BaseTSNClient { } } -export default BrowserTSNClient; +export default BrowserTNClient; diff --git a/src/client/client.test.ts b/src/client/client.test.ts index d7d9b25..26c58b1 100644 --- a/src/client/client.test.ts +++ b/src/client/client.test.ts @@ -1,6 +1,6 @@ import { describe, expect, it } from "vitest"; import { ethers } from "ethers"; -import { NodeTSNClient } from "./nodeClient"; +import { NodeTNClient } from "./nodeClient"; describe.sequential("Client", { timeout: 30000 }, () => { // Skip in CI, because it needs a local node @@ -10,13 +10,13 @@ describe.sequential("Client", { timeout: 30000 }, () => { "0x0000000000000000000000000000000000000000000000000000000000000001", ); it("should create a client", async () => { - const chainId = await NodeTSNClient.getDefaultChainId( + const chainId = await NodeTNClient.getDefaultChainId( "http://localhost:8484", ); if (!chainId) { throw new Error("Chain id not found"); } - const client = new NodeTSNClient({ + const client = new NodeTNClient({ endpoint: "http://localhost:8484", signerInfo: { address: wallet.address, diff --git a/src/client/client.ts b/src/client/client.ts index 4642887..8b9982d 100644 --- a/src/client/client.ts +++ b/src/client/client.ts @@ -23,21 +23,21 @@ export interface SignerInfo { signer: EthSigner; } -export type TSNClientOptions = { +export type TNClientOptions = { endpoint: string; signerInfo: SignerInfo; } & Omit; -export abstract class BaseTSNClient { +export abstract class BaseTNClient { protected kwilClient: Kwil | undefined; protected signerInfo: SignerInfo; - protected constructor(options: TSNClientOptions) { + protected constructor(options: TNClientOptions) { this.signerInfo = options.signerInfo; } /** - * Waits for a transaction to be mined by TSN. + * Waits for a transaction to be mined by TN. * @param txHash - The transaction hash to wait for. * @param timeout - The timeout in milliseconds. * @returns A promise that resolves to the transaction info receipt. @@ -195,7 +195,7 @@ export abstract class BaseTSNClient { } /** - * Returns all streams from the TSN network. + * Returns all streams from the TN network. * @param owner - The owner of the streams. If not provided, all streams will be returned. * @returns A promise that resolves to a list of stream locators. */ @@ -204,7 +204,7 @@ export abstract class BaseTSNClient { } /** - * Get the default chain id for a provider. Use with caution, as this decreases the security of the TSN. + * Get the default chain id for a provider. Use with caution, as this decreases the security of the TN. * @param provider - The provider URL. * @returns A promise that resolves to the chain ID. */ diff --git a/src/client/listAllStreams.ts b/src/client/listAllStreams.ts index 9b5f5b5..86adb13 100644 --- a/src/client/listAllStreams.ts +++ b/src/client/listAllStreams.ts @@ -6,7 +6,7 @@ import { StreamId } from "../util/StreamId"; import { Database } from "@kwilteam/kwil-js/dist/core/database"; /** - * List all streams from the TSN network. + * List all streams from the TN network. * @param kwilClient - The Kwil client. * @param owner - The owner of the streams. If not provided, all streams will be returned. * @returns A list of stream locators. diff --git a/src/client/nodeClient.ts b/src/client/nodeClient.ts index 502b896..e78801e 100644 --- a/src/client/nodeClient.ts +++ b/src/client/nodeClient.ts @@ -1,9 +1,9 @@ import { EnvironmentType } from "@kwilteam/kwil-js/dist/core/enums"; import { NodeKwil } from "@kwilteam/kwil-js"; -import { BaseTSNClient, TSNClientOptions } from "./client"; +import { BaseTNClient, TNClientOptions } from "./client"; -export class NodeTSNClient extends BaseTSNClient { - constructor(options: TSNClientOptions) { +export class NodeTNClient extends BaseTNClient { + constructor(options: TNClientOptions) { super(options); this.kwilClient = new NodeKwil({ ...options, @@ -12,4 +12,4 @@ export class NodeTSNClient extends BaseTSNClient { } } -export default NodeTSNClient; +export default NodeTNClient; diff --git a/src/contracts-api/deployStream.ts b/src/contracts-api/deployStream.ts index b91d292..4a26521 100644 --- a/src/contracts-api/deployStream.ts +++ b/src/contracts-api/deployStream.ts @@ -23,7 +23,7 @@ export interface DeployStreamOutput { } /** - * Deploys a stream to TSN. + * Deploys a stream to TN. * @param input - The input parameters for deploying the stream. * @returns The transaction hash of the deployment. */ @@ -38,7 +38,7 @@ export async function deployStream( const txHash = await input.kwilClient.deploy( { schema, - description: `TSN SDK - Deploying ${input.streamType} stream: ${input.streamId.getId()}`, + description: `TN SDK - Deploying ${input.streamType} stream: ${input.streamId.getId()}`, }, input.kwilSigner, input.synchronous, diff --git a/src/contracts-api/destroyStream.ts b/src/contracts-api/destroyStream.ts index 101ccf8..84a9c38 100644 --- a/src/contracts-api/destroyStream.ts +++ b/src/contracts-api/destroyStream.ts @@ -23,7 +23,7 @@ export interface DestroyStreamOutput { } /** - * Destroys a stream from TSN. + * Destroys a stream from TN. * @param input - The input parameters for destroying the stream. * @returns The transaction receipt of the destruction. */ diff --git a/src/contracts-api/stream.ts b/src/contracts-api/stream.ts index a2f19e7..a3bebbc 100644 --- a/src/contracts-api/stream.ts +++ b/src/contracts-api/stream.ts @@ -88,7 +88,7 @@ export class Stream { dbid: this.dbid, name: method, inputs, - description: `TSN SDK - Executing method on stream: ${method}`, + description: `TN SDK - Executing method on stream: ${method}`, }, this.kwilSigner, ); diff --git a/src/index.browser.ts b/src/index.browser.ts index 09449f0..6e6f55f 100644 --- a/src/index.browser.ts +++ b/src/index.browser.ts @@ -1,3 +1,3 @@ // Browser/Web exports -export { BrowserTSNClient } from "./client/browserClient"; +export { BrowserTNClient } from "./client/browserClient"; export * from "./index.common"; diff --git a/src/index.common.ts b/src/index.common.ts index 3bcabc7..7e855b2 100644 --- a/src/index.common.ts +++ b/src/index.common.ts @@ -1,5 +1,5 @@ // Core client types -export type { TSNClientOptions } from "./client/client"; +export type { TNClientOptions } from "./client/client"; export type { SignerInfo as EthProvider } from "./client/client"; // Stream types and interfaces diff --git a/src/index.node.ts b/src/index.node.ts index 1a6eaea..a2f9d42 100644 --- a/src/index.node.ts +++ b/src/index.node.ts @@ -1,3 +1,3 @@ // Node.js exports -export { NodeTSNClient } from "./client/nodeClient"; +export { NodeTNClient } from "./client/nodeClient"; export * from "./index.common"; diff --git a/src/index.ts b/src/index.ts index 000d4f7..8c2f2fe 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,4 +1,4 @@ // All exports, to provide types for both browser and node -export { BrowserTSNClient } from "./client/browserClient"; -export { NodeTSNClient } from "./client/nodeClient"; +export { BrowserTNClient } from "./client/browserClient"; +export { NodeTNClient } from "./client/nodeClient"; export * from "./index.common"; diff --git a/tests/integration/composedStream.test.ts b/tests/integration/composedStream.test.ts index c69140b..ad29ebd 100644 --- a/tests/integration/composedStream.test.ts +++ b/tests/integration/composedStream.test.ts @@ -1,5 +1,5 @@ import { describe, expect } from "vitest"; -import NodeTSNClient from "../../src/client/nodeClient"; +import NodeTNClient from "../../src/client/nodeClient"; import { StreamId } from "../../src/util/StreamId"; import { testWithDefaultWallet } from "./utils"; @@ -145,7 +145,7 @@ describe.sequential( // Helper function to deploy and initialize a primitive stream with data async function deployPrimitiveStreamWithData( - client: NodeTSNClient, + client: NodeTNClient, streamId: StreamId, data: { dateValue: string; value: string }[], ) { diff --git a/tests/integration/getAllStreams.test.ts b/tests/integration/getAllStreams.test.ts index 9eabf92..64f8fe2 100644 --- a/tests/integration/getAllStreams.test.ts +++ b/tests/integration/getAllStreams.test.ts @@ -2,7 +2,7 @@ import { describe, expect } from "vitest"; import { StreamId } from "../../src/util/StreamId"; import { StreamType } from "../../src/contracts-api/contractValues"; import { testWithDefaultWallet, waitForTxSuccess } from "./utils"; -import NodeTSNClient from "../../src/client/nodeClient"; +import NodeTNClient from "../../src/client/nodeClient"; describe.sequential("Get All Streams", { timeout: 90000 }, () => { testWithDefaultWallet.skipIf(process.env.CI)( @@ -104,7 +104,7 @@ describe.sequential("Get All Streams", { timeout: 90000 }, () => { // Helper function to create and initialize a stream async function createAndInitStream( - client: NodeTSNClient, + client: NodeTNClient, streamId: StreamId, type: StreamType, ) { diff --git a/tests/integration/permissions.test.ts b/tests/integration/permissions.test.ts index 01f6bb8..6ae407c 100644 --- a/tests/integration/permissions.test.ts +++ b/tests/integration/permissions.test.ts @@ -13,13 +13,13 @@ const PERMISSION_ROLES = { } as const; // Create permission-specific test context -const tsnTest = createTestContexts(PERMISSION_ROLES); +const tnTest = createTestContexts(PERMISSION_ROLES); describe.sequential("Permissions", { timeout: 90000 }, () => { // Skip in CI, because it needs a local node - tsnTest.skipIf(process.env.CI); + tnTest.skipIf(process.env.CI); - tsnTest( + tnTest( "should manage primitive stream permissions", async ({ ownerClient, readerClient, readerWallet }) => { // Generate a unique stream ID @@ -104,7 +104,7 @@ describe.sequential("Permissions", { timeout: 90000 }, () => { }, ); - tsnTest( + tnTest( "should manage composed stream permissions", async ({ ownerClient, readerClient, readerWallet }) => { // Generate stream IDs for both primitive and composed streams diff --git a/tests/integration/utils.ts b/tests/integration/utils.ts index 7d508f5..5430f6e 100644 --- a/tests/integration/utils.ts +++ b/tests/integration/utils.ts @@ -1,5 +1,5 @@ import { ethers } from "ethers"; -import { NodeTSNClient } from "../../src/client/nodeClient"; +import { NodeTNClient } from "../../src/client/nodeClient"; import { test } from "vitest"; import { GenericResponse } from "@kwilteam/kwil-js/dist/core/resreq"; import { TxReceipt } from "@kwilteam/kwil-js/dist/core/tx"; @@ -12,7 +12,7 @@ export const testWithDefaultWallet = createTestContexts({ export interface WalletContext { wallet: ethers.Wallet; - client: NodeTSNClient; + client: NodeTNClient; } type Fixtures> = Parameters< @@ -28,11 +28,11 @@ export async function createWalletContext( privateKey: string, ): Promise { const wallet = new ethers.Wallet(privateKey); - const chainId = await NodeTSNClient.getDefaultChainId(TEST_ENDPOINT); + const chainId = await NodeTNClient.getDefaultChainId(TEST_ENDPOINT); if (!chainId) throw new Error("Chain id not found"); - const client = new NodeTSNClient({ + const client = new NodeTNClient({ endpoint: TEST_ENDPOINT, signerInfo: { address: wallet.address, @@ -53,7 +53,7 @@ export function createTestContexts(roles: Record) { type ContextType = { [K in T as `${K}Wallet`]: ethers.Wallet; } & { - [K in T as `${K}Client`]: NodeTSNClient; + [K in T as `${K}Client`]: NodeTNClient; }; const testExtension = {} as Fixtures; @@ -84,7 +84,7 @@ export function createTestContexts(roles: Record) { export async function waitForTxSuccess( tx: GenericResponse, - client: NodeTSNClient, + client: NodeTNClient, ) { if (!tx.data?.tx_hash) { throw new Error("Tx hash not found"); From 07104f273021b1f031bfc10851c13bf05ccbf4aa Mon Sep 17 00:00:00 2001 From: MicBun Date: Tue, 26 Nov 2024 11:50:44 +0700 Subject: [PATCH 2/2] chore: rename truf-node-sdk-js into sdk-js --- .github/ISSUE_TEMPLATE/bug-report.yml | 10 +++++----- .github/ISSUE_TEMPLATE/config.yml | 2 +- .github/ISSUE_TEMPLATE/feature-request.yml | 4 ++-- README.md | 12 ++++++------ docs/api-reference.md | 4 ++-- docs/core-concepts.md | 8 ++++---- docs/getting-started.md | 14 +++++++------- package.json | 4 ++-- 8 files changed, 29 insertions(+), 29 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug-report.yml b/.github/ISSUE_TEMPLATE/bug-report.yml index bc52cfb..262fd8e 100644 --- a/.github/ISSUE_TEMPLATE/bug-report.yml +++ b/.github/ISSUE_TEMPLATE/bug-report.yml @@ -1,19 +1,19 @@ name: Bug Report -description: Something with truf-node-sdk-js is not working as expected. +description: Something with sdk-js is not working as expected. title: "Bug: " labels: ["bug"] body: - type: markdown attributes: value: | - Thank you for taking the time to report an issue. This form is for reporting **bugs in truf-node-sdk-js**. + Thank you for taking the time to report an issue. This form is for reporting **bugs in sdk-js**. When submitting logs, please submit them as text and not as a screenshot. - type: input id: version attributes: label: Version / Commit - description: Please include the release version or commit hash of truf-node-sdk-js you are using. Write `unknown` if you are unsure. + description: Please include the release version or commit hash of sdk-js you are using. Write `unknown` if you are unsure. placeholder: e.g. v0.1.0 or 1234567890abcdef validations: required: true @@ -38,7 +38,7 @@ body: attributes: label: Expected Behavior description: Please describe what you expected to happen. - placeholder: e.g. I expected truf-node-sdk-js to do X when I did Y + placeholder: e.g. I expected sdk-js to do X when I did Y validations: required: true - type: textarea @@ -46,7 +46,7 @@ body: attributes: label: Actual Behavior description: Please describe what actually happened. - placeholder: e.g. truf-node-sdk-js did Z instead of X when I did Y + placeholder: e.g. sdk-js did Z instead of X when I did Y validations: required: true - type: textarea diff --git a/.github/ISSUE_TEMPLATE/config.yml b/.github/ISSUE_TEMPLATE/config.yml index c654407..a05386d 100644 --- a/.github/ISSUE_TEMPLATE/config.yml +++ b/.github/ISSUE_TEMPLATE/config.yml @@ -1,5 +1,5 @@ blank_issues_enabled: true contact_links: - name: Ask a question - url: https://github.com/trufnetwork/truf-node-sdk-js/discussions + url: https://github.com/trufnetwork/sdk-js/discussions about: Please ask and answer questions here diff --git a/.github/ISSUE_TEMPLATE/feature-request.yml b/.github/ISSUE_TEMPLATE/feature-request.yml index 61cff8d..74dac0f 100644 --- a/.github/ISSUE_TEMPLATE/feature-request.yml +++ b/.github/ISSUE_TEMPLATE/feature-request.yml @@ -1,12 +1,12 @@ name: Feature Request -description: Suggest a new feature or change for truf-node-sdk-js. +description: Suggest a new feature or change for sdk-js. title: "Feature Request: " labels: ["enhancement"] body: - type: markdown attributes: value: | - Thank you for taking the time to suggest a feature or change. This form is for suggesting **features or changes to truf-node-sdk-js**. + Thank you for taking the time to suggest a feature or change. This form is for suggesting **features or changes to sdk-js**. Feel free to discuss or mull over potential features. - type: textarea diff --git a/README.md b/README.md index 3fa03ef..b35f30e 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ The TN SDK provides developers with tools to interact with the Truf Network, a d ### Installation ```bash -npm install @trufnetwork/truf-node-sdk-js +npm install @trufnetwork/sdk-js # or your preferred package manager ``` @@ -17,16 +17,16 @@ npm install @trufnetwork/truf-node-sdk-js ```ts // For Node.js applications -import { NodeTNClient } from "@trufnetwork/truf-node-sdk-js"; +import { NodeTNClient } from "@trufnetwork/sdk-js"; // For browser applications -import { BrowserTNClient } from "@trufnetwork/truf-node-sdk-js"; +import { BrowserTNClient } from "@trufnetwork/sdk-js"; ``` ### Example Usage ```ts -import { NodeTNClient, StreamId } from "@trufnetwork/truf-node-sdk-js"; +import { NodeTNClient, StreamId } from "@trufnetwork/sdk-js"; // Initialize client const client = new NodeTNClient({ @@ -74,7 +74,7 @@ TN supports two main types of streams: - **Primitive Streams**: Direct data sources from providers - **Composed Streams**: Aggregate data from multiple streams using weights -More information about TN components can be found in the [Js TN-SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/docs/api-reference.md). +More information about TN components can be found in the [Js TN-SDK Documentation](https://github.com/trufnetwork/sdk-js/blob/main/docs/api-reference.md). ## Documentation @@ -88,7 +88,7 @@ A staging network is available at https://staging.tsn.truflation.com for testing ## Support -For support, please [open an issue](https://github.com/trufnetwork/truf-node-sdk-js/issues). +For support, please [open an issue](https://github.com/trufnetwork/sdk-js/issues). ## License diff --git a/docs/api-reference.md b/docs/api-reference.md index 7628b38..7f1d282 100644 --- a/docs/api-reference.md +++ b/docs/api-reference.md @@ -1,11 +1,11 @@ # API Reference -For detailed information about TN concepts and operations, please refer to the [Js SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/docs/api-reference.md). +For detailed information about TN concepts and operations, please refer to the [Js SDK Documentation](https://github.com/trufnetwork/sdk-js/blob/main/docs/api-reference.md). ## Client Initialization ```typescript -import { NodeTNClient, BrowserTNClient } from "@trufnetwork/truf-node-sdk-js"; +import { NodeTNClient, BrowserTNClient } from "@trufnetwork/sdk-js"; const client = new NodeTNClient({ endpoint: "https://staging.tsn.truflation.com", diff --git a/docs/core-concepts.md b/docs/core-concepts.md index 7af31c9..92dfc98 100644 --- a/docs/core-concepts.md +++ b/docs/core-concepts.md @@ -8,14 +8,14 @@ TN supports two types of streams: - **Composed Streams**: Aggregate multiple streams with configurable weights ```typescript -import { StreamType } from "@trufnetwork/truf-node-sdk-js"; +import { StreamType } from "@trufnetwork/sdk-js"; // Available stream types StreamType.Primitive // Single data source StreamType.Composed // Aggregates multiple streams with weights ``` -For detailed information about stream types and their use cases, see the [Js SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/README.md). +For detailed information about stream types and their use cases, see the [Js SDK Documentation](https://github.com/trufnetwork/sdk-js/blob/main/README.md). ## Error Handling @@ -52,7 +52,7 @@ const streamId = await StreamId.generate("my-unique-name"); Streams support granular permissions for both reading and composing: ```typescript -import { visibility } from "@trufnetwork/truf-node-sdk-js"; +import { visibility } from "@trufnetwork/sdk-js"; // Set visibility await stream.setReadVisibility(visibility.private); @@ -81,5 +81,5 @@ if (tx.data?.tx_hash) { ## Further Reading - [Integration Tests](../tests/integration) - Usage examples -- [Js SDK Documentation](https://github.com/trufnetwork/truf-node-sdk-js/blob/main/README.md) - Detailed TN concepts +- [Js SDK Documentation](https://github.com/trufnetwork/sdk-js/blob/main/README.md) - Detailed TN concepts - [monads-io Documentation](https://github.com/AlexXanderGrib/monads-io) - Error handling patterns diff --git a/docs/getting-started.md b/docs/getting-started.md index 084f8d9..828d121 100644 --- a/docs/getting-started.md +++ b/docs/getting-started.md @@ -6,17 +6,17 @@ ## Installation ```bash -npm install @trufnetwork/truf-node-sdk-js +npm install @trufnetwork/sdk-js # or -pnpm install @trufnetwork/truf-node-sdk-js +pnpm install @trufnetwork/sdk-js # or -yarn add @trufnetwork/truf-node-sdk-js +yarn add @trufnetwork/sdk-js ``` ## Quick Start ```typescript -import { NodeTNClient, StreamId } from "@trufnetwork/truf-node-sdk-js"; +import { NodeTNClient, StreamId } from "@trufnetwork/sdk-js"; import { Wallet } from "ethers"; // Initialize client @@ -61,10 +61,10 @@ The SDK provides optimized clients for different environments: ```typescript // For Node.js -import { NodeTNClient } from "@trufnetwork/truf-node-sdk-js"; +import { NodeTNClient } from "@trufnetwork/sdk-js"; // For browsers -import { BrowserTNClient } from "@trufnetwork/truf-node-sdk-js"; +import { BrowserTNClient } from "@trufnetwork/sdk-js"; ``` ## Next Steps @@ -75,4 +75,4 @@ import { BrowserTNClient } from "@trufnetwork/truf-node-sdk-js"; ## Support -For support and issues, please visit our [GitHub repository](https://github.com/trufnetwork/truf-node-sdk-js/issues). +For support and issues, please visit our [GitHub repository](https://github.com/trufnetwork/sdk-js/issues). diff --git a/package.json b/package.json index dd483c5..3193e7c 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "@trufnetwork/truf-node-sdk-js", + "name": "@trufnetwork/sdk-js", "version": "0.1.0", "description": "Truf Network SDK for JavaScript", "type": "module", @@ -44,7 +44,7 @@ }, "dependencies": { "@kwilteam/kwil-js": "^0.7.3", - "@truflation/tsn-sdk-js": "github:trufnetwork/truf-node-sdk-js", + "@truflation/tsn-sdk-js": "github:trufnetwork/sdk-js", "crypto-hash": "^3.1.0", "lodash": "^4.17.21", "monads-io": "^4.0.2"