@thru/thru-sdk 0.1.16 → 0.1.20

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.
Files changed (72) hide show
  1. package/README.md +96 -0
  2. package/dist/{chunk-FDZQR6ZZ.js → chunk-4JWHIX3Q.js} +168 -65
  3. package/dist/chunk-4JWHIX3Q.js.map +1 -0
  4. package/dist/client.d.ts +16 -3
  5. package/dist/client.js +19 -3
  6. package/dist/client.js.map +1 -1
  7. package/dist/metafile-esm.json +1 -1
  8. package/dist/sdk.d.ts +5 -4
  9. package/dist/sdk.js +1 -1
  10. package/dist/{transactions-X2KKrGw6.d.ts → transactions-CJsRFL_T.d.ts} +562 -98
  11. package/package.json +15 -4
  12. package/buf.gen.yaml +0 -12
  13. package/buf.lock +0 -9
  14. package/buf.yaml +0 -15
  15. package/dist/chunk-FDZQR6ZZ.js.map +0 -1
  16. package/proto/thru/common/v1/consensus.proto +0 -73
  17. package/proto/thru/common/v1/errors.proto +0 -65
  18. package/proto/thru/common/v1/filters.proto +0 -60
  19. package/proto/thru/common/v1/pagination.proto +0 -45
  20. package/proto/thru/core/v1/account.proto +0 -137
  21. package/proto/thru/core/v1/block.proto +0 -80
  22. package/proto/thru/core/v1/state.proto +0 -35
  23. package/proto/thru/core/v1/transaction.proto +0 -136
  24. package/proto/thru/core/v1/types.proto +0 -50
  25. package/proto/thru/services/v1/command_service.proto +0 -70
  26. package/proto/thru/services/v1/query_service.proto +0 -344
  27. package/proto/thru/services/v1/streaming_service.proto +0 -126
  28. package/thru-ts-client-sdk/client.ts +0 -10
  29. package/thru-ts-client-sdk/core/bound-client.ts +0 -135
  30. package/thru-ts-client-sdk/core/client.ts +0 -38
  31. package/thru-ts-client-sdk/defaults.ts +0 -17
  32. package/thru-ts-client-sdk/modules/accounts.ts +0 -145
  33. package/thru-ts-client-sdk/modules/blocks.ts +0 -75
  34. package/thru-ts-client-sdk/modules/events.ts +0 -20
  35. package/thru-ts-client-sdk/modules/height.ts +0 -9
  36. package/thru-ts-client-sdk/modules/helpers.ts +0 -131
  37. package/thru-ts-client-sdk/modules/keys.ts +0 -29
  38. package/thru-ts-client-sdk/modules/proofs.ts +0 -20
  39. package/thru-ts-client-sdk/modules/streaming.ts +0 -34
  40. package/thru-ts-client-sdk/modules/transactions.ts +0 -274
  41. package/thru-ts-client-sdk/proto/buf/validate/validate_pb.ts +0 -4761
  42. package/thru-ts-client-sdk/proto/google/api/annotations_pb.ts +0 -39
  43. package/thru-ts-client-sdk/proto/google/api/client_pb.ts +0 -953
  44. package/thru-ts-client-sdk/proto/google/api/field_behavior_pb.ts +0 -157
  45. package/thru-ts-client-sdk/proto/google/api/http_pb.ts +0 -474
  46. package/thru-ts-client-sdk/proto/google/api/launch_stage_pb.ts +0 -118
  47. package/thru-ts-client-sdk/proto/thru/common/v1/consensus_pb.ts +0 -163
  48. package/thru-ts-client-sdk/proto/thru/common/v1/errors_pb.ts +0 -130
  49. package/thru-ts-client-sdk/proto/thru/common/v1/filters_pb.ts +0 -81
  50. package/thru-ts-client-sdk/proto/thru/common/v1/pagination_pb.ts +0 -80
  51. package/thru-ts-client-sdk/proto/thru/core/v1/account_pb.ts +0 -358
  52. package/thru-ts-client-sdk/proto/thru/core/v1/block_pb.ts +0 -260
  53. package/thru-ts-client-sdk/proto/thru/core/v1/state_pb.ts +0 -104
  54. package/thru-ts-client-sdk/proto/thru/core/v1/transaction_pb.ts +0 -327
  55. package/thru-ts-client-sdk/proto/thru/core/v1/types_pb.ts +0 -101
  56. package/thru-ts-client-sdk/proto/thru/services/v1/command_service_pb.ts +0 -81
  57. package/thru-ts-client-sdk/proto/thru/services/v1/query_service_pb.ts +0 -813
  58. package/thru-ts-client-sdk/proto/thru/services/v1/streaming_service_pb.ts +0 -391
  59. package/thru-ts-client-sdk/sdk.ts +0 -40
  60. package/thru-ts-client-sdk/test-scripts/counter.ts +0 -216
  61. package/thru-ts-client-sdk/test-scripts/create-account.ts +0 -74
  62. package/thru-ts-client-sdk/test-scripts/get-height.ts +0 -52
  63. package/thru-ts-client-sdk/transactions/Transaction.ts +0 -240
  64. package/thru-ts-client-sdk/transactions/TransactionBuilder.ts +0 -48
  65. package/thru-ts-client-sdk/transactions/__tests__/transaction.test.ts +0 -95
  66. package/thru-ts-client-sdk/transactions/index.ts +0 -3
  67. package/thru-ts-client-sdk/transactions/types.ts +0 -64
  68. package/thru-ts-client-sdk/transactions/utils.ts +0 -132
  69. package/thru-ts-client-sdk/types/types.ts +0 -8
  70. package/thru-ts-client-sdk/utils/utils.ts +0 -27
  71. package/tsconfig.json +0 -9
  72. package/tsup.config.ts +0 -14
package/README.md CHANGED
@@ -8,6 +8,25 @@ Typed TypeScript/JavaScript client for talking to the Thru blockchain. It wraps
8
8
  npm install @thru/thru-sdk
9
9
  ```
10
10
 
11
+ ### TypeScript Configuration
12
+
13
+ For optimal import resolution, we recommend using modern TypeScript module resolution in your `tsconfig.json`:
14
+
15
+ ```json
16
+ {
17
+ "compilerOptions": {
18
+ "moduleResolution": "bundler",
19
+ "module": "ESNext",
20
+ "target": "ES2020",
21
+ "isolatedModules": true
22
+ }
23
+ }
24
+ ```
25
+
26
+ **Why?** The SDK uses modern `exports` fields in `package.json` for better tree-shaking and bundler compatibility. The `bundler` resolution strategy fully supports these modern package exports, while the older `node` resolution may require importing from `dist` paths directly.
27
+
28
+ If you're using a bundler (Vite, Webpack, esbuild, etc.) or modern build tools, `moduleResolution: "bundler"` is the recommended setting. For Node.js projects, you can also use `"node16"` or `"nodenext"`.
29
+
11
30
  ## Basic Usage
12
31
 
13
32
  ```ts
@@ -36,6 +55,83 @@ const { rawTransaction, signature } = await thru.transactions.buildAndSign({
36
55
  await thru.transactions.send(rawTransaction);
37
56
  ```
38
57
 
58
+ ### Using Filters
59
+
60
+ Many SDK functions support CEL (Common Expression Language) filters to query or stream data based on custom expressions evaluated server-side. Filters are constructed using the `create` function from `@bufbuild/protobuf` (already a dependency of `@thru/thru-sdk`).
61
+
62
+ #### Constructing Filters
63
+
64
+ ```ts
65
+ import { create } from "@bufbuild/protobuf";
66
+ import {
67
+ FilterSchema,
68
+ FilterParamValueSchema,
69
+ type Filter,
70
+ type FilterParamValue
71
+ } from "@thru/thru-sdk";
72
+
73
+ // Create a filter parameter value
74
+ const paramValue = create(FilterParamValueSchema, {
75
+ kind: {
76
+ case: "bytesValue", // or "stringValue", "boolValue", "intValue", "doubleValue"
77
+ value: new Uint8Array(32), // the actual value
78
+ },
79
+ });
80
+
81
+ // Create the filter with a CEL expression
82
+ const filter = create(FilterSchema, {
83
+ expression: "meta.owner.value == params.owner_bytes",
84
+ params: {
85
+ owner_bytes: paramValue,
86
+ },
87
+ });
88
+ ```
89
+
90
+ #### Filter Parameter Value Types
91
+
92
+ Filter parameters support these types:
93
+ - `{ case: "stringValue", value: string }` - for string parameters
94
+ - `{ case: "bytesValue", value: Uint8Array }` - for byte array parameters
95
+ - `{ case: "boolValue", value: boolean }` - for boolean parameters
96
+ - `{ case: "intValue", value: bigint }` - for integer parameters
97
+ - `{ case: "doubleValue", value: number }` - for floating-point parameters
98
+
99
+ #### Functions That Accept Filters
100
+
101
+ **Query Functions:**
102
+ - `thru.accounts.list({ filter })` - List accounts with filtering
103
+ - `thru.blocks.list({ filter })` - List blocks with filtering
104
+ - `thru.transactions.listForAccount(account, { filter })` - List transactions for an account with filtering
105
+
106
+ **Streaming Functions:**
107
+ - `thru.streaming.streamBlocks({ filter })` - Stream blocks with filtering
108
+ - `thru.streaming.streamAccountUpdates(address, { filter })` - Stream account updates with filtering
109
+ - `thru.streaming.streamTransactions({ filter })` - Stream transactions with filtering
110
+ - `thru.streaming.streamEvents({ filter })` - Stream events with filtering
111
+
112
+ #### Example: Filtering Accounts by Owner
113
+
114
+ ```ts
115
+ // List accounts owned by a specific public key
116
+ const ownerBytes = new Uint8Array(32); // your owner pubkey bytes
117
+
118
+ const ownerParam = create(FilterParamValueSchema, {
119
+ kind: {
120
+ case: "bytesValue",
121
+ value: ownerBytes,
122
+ },
123
+ });
124
+
125
+ const filter = create(FilterSchema, {
126
+ expression: "meta.owner.value == params.owner_bytes",
127
+ params: {
128
+ owner_bytes: ownerParam,
129
+ },
130
+ });
131
+
132
+ const response = await thru.accounts.list({ filter });
133
+ ```
134
+
39
135
  ### Modules at a Glance
40
136
 
41
137
  - `thru.blocks` — query finalized or raw blocks and stream height information