@thru/thru-sdk 0.1.19 → 0.1.21

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 (88) hide show
  1. package/README.md +19 -0
  2. package/dist/{chunk-PH7P5EEU.js → chunk-SHMREHP5.js} +13 -9
  3. package/dist/chunk-SHMREHP5.js.map +1 -0
  4. package/dist/client.d.ts +2 -1
  5. package/dist/client.js +3 -2
  6. package/dist/client.js.map +1 -1
  7. package/dist/metafile-esm.json +1 -1
  8. package/dist/sdk.d.ts +3 -3
  9. package/dist/sdk.js +1 -1
  10. package/dist/{transactions-BzD9hYlc.d.ts → transactions-CLezIeXO.d.ts} +20 -18
  11. package/package.json +7 -3
  12. package/buf.gen.yaml +0 -12
  13. package/buf.lock +0 -9
  14. package/buf.yaml +0 -15
  15. package/dist/chunk-PH7P5EEU.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/__tests__/helpers/test-utils.ts +0 -228
  29. package/thru-ts-client-sdk/client.ts +0 -10
  30. package/thru-ts-client-sdk/core/__tests__/bound-client.test.ts +0 -354
  31. package/thru-ts-client-sdk/core/__tests__/client.test.ts +0 -53
  32. package/thru-ts-client-sdk/core/bound-client.ts +0 -156
  33. package/thru-ts-client-sdk/core/client.ts +0 -38
  34. package/thru-ts-client-sdk/defaults.ts +0 -26
  35. package/thru-ts-client-sdk/modules/__tests__/accounts.test.ts +0 -406
  36. package/thru-ts-client-sdk/modules/__tests__/blocks.test.ts +0 -199
  37. package/thru-ts-client-sdk/modules/__tests__/events.test.ts +0 -74
  38. package/thru-ts-client-sdk/modules/__tests__/height.test.ts +0 -39
  39. package/thru-ts-client-sdk/modules/__tests__/helpers.test.ts +0 -288
  40. package/thru-ts-client-sdk/modules/__tests__/keys.test.ts +0 -55
  41. package/thru-ts-client-sdk/modules/__tests__/proofs.test.ts +0 -119
  42. package/thru-ts-client-sdk/modules/__tests__/streaming.test.ts +0 -152
  43. package/thru-ts-client-sdk/modules/__tests__/transactions.test.ts +0 -730
  44. package/thru-ts-client-sdk/modules/__tests__/version.test.ts +0 -40
  45. package/thru-ts-client-sdk/modules/accounts.ts +0 -141
  46. package/thru-ts-client-sdk/modules/blocks.ts +0 -75
  47. package/thru-ts-client-sdk/modules/events.ts +0 -20
  48. package/thru-ts-client-sdk/modules/height.ts +0 -9
  49. package/thru-ts-client-sdk/modules/helpers.ts +0 -131
  50. package/thru-ts-client-sdk/modules/keys.ts +0 -29
  51. package/thru-ts-client-sdk/modules/proofs.ts +0 -20
  52. package/thru-ts-client-sdk/modules/streaming.ts +0 -133
  53. package/thru-ts-client-sdk/modules/transactions.ts +0 -374
  54. package/thru-ts-client-sdk/modules/version.ts +0 -10
  55. package/thru-ts-client-sdk/proto/buf/validate/validate_pb.ts +0 -4761
  56. package/thru-ts-client-sdk/proto/google/api/annotations_pb.ts +0 -39
  57. package/thru-ts-client-sdk/proto/google/api/client_pb.ts +0 -953
  58. package/thru-ts-client-sdk/proto/google/api/field_behavior_pb.ts +0 -157
  59. package/thru-ts-client-sdk/proto/google/api/http_pb.ts +0 -474
  60. package/thru-ts-client-sdk/proto/google/api/launch_stage_pb.ts +0 -118
  61. package/thru-ts-client-sdk/proto/thru/common/v1/consensus_pb.ts +0 -162
  62. package/thru-ts-client-sdk/proto/thru/common/v1/errors_pb.ts +0 -129
  63. package/thru-ts-client-sdk/proto/thru/common/v1/filters_pb.ts +0 -129
  64. package/thru-ts-client-sdk/proto/thru/common/v1/pagination_pb.ts +0 -79
  65. package/thru-ts-client-sdk/proto/thru/core/v1/account_pb.ts +0 -359
  66. package/thru-ts-client-sdk/proto/thru/core/v1/block_pb.ts +0 -259
  67. package/thru-ts-client-sdk/proto/thru/core/v1/state_pb.ts +0 -103
  68. package/thru-ts-client-sdk/proto/thru/core/v1/transaction_pb.ts +0 -528
  69. package/thru-ts-client-sdk/proto/thru/core/v1/types_pb.ts +0 -100
  70. package/thru-ts-client-sdk/proto/thru/services/v1/command_service_pb.ts +0 -146
  71. package/thru-ts-client-sdk/proto/thru/services/v1/query_service_pb.ts +0 -819
  72. package/thru-ts-client-sdk/proto/thru/services/v1/streaming_service_pb.ts +0 -390
  73. package/thru-ts-client-sdk/sdk.ts +0 -42
  74. package/thru-ts-client-sdk/test-scripts/counter.ts +0 -469
  75. package/thru-ts-client-sdk/test-scripts/create-account.ts +0 -74
  76. package/thru-ts-client-sdk/test-scripts/get-height.ts +0 -52
  77. package/thru-ts-client-sdk/transactions/Transaction.ts +0 -240
  78. package/thru-ts-client-sdk/transactions/TransactionBuilder.ts +0 -53
  79. package/thru-ts-client-sdk/transactions/__tests__/TransactionBuilder.test.ts +0 -411
  80. package/thru-ts-client-sdk/transactions/__tests__/utils.test.ts +0 -214
  81. package/thru-ts-client-sdk/transactions/index.ts +0 -3
  82. package/thru-ts-client-sdk/transactions/types.ts +0 -74
  83. package/thru-ts-client-sdk/transactions/utils.ts +0 -132
  84. package/thru-ts-client-sdk/types/types.ts +0 -8
  85. package/thru-ts-client-sdk/utils/utils.ts +0 -27
  86. package/tsconfig.json +0 -9
  87. package/tsup.config.ts +0 -14
  88. package/vitest.config.ts +0 -31
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
@@ -1,4 +1,4 @@
1
- import { signAsync } from '@noble/ed25519';
1
+ import { signAsync, getPublicKeyAsync } from '@noble/ed25519';
2
2
  import { decodeSignature, decodeBase64, decodeAddress, ensureBytes, encodeAddress, isHexString, hexToBytes, encodeSignature } from '@thru/helpers';
3
3
  import { messageDesc, fileDesc, serviceDesc } from '@bufbuild/protobuf/codegenv2';
4
4
  import { file_google_protobuf_timestamp, file_google_protobuf_descriptor, file_google_protobuf_duration } from '@bufbuild/protobuf/wkt';
@@ -661,6 +661,7 @@ function getEvent(ctx, eventId, options = {}) {
661
661
  // thru-ts-client-sdk/modules/keys.ts
662
662
  var keys_exports = {};
663
663
  __export(keys_exports, {
664
+ fromPrivateKey: () => fromPrivateKey,
664
665
  generateKeyPair: () => generateKeyPair
665
666
  });
666
667
  async function generateKeyPair() {
@@ -673,6 +674,9 @@ async function generateKeyPair() {
673
674
  privateKey: account.privateKey
674
675
  };
675
676
  }
677
+ async function fromPrivateKey(privateKey) {
678
+ return new Uint8Array(await getPublicKeyAsync(privateKey));
679
+ }
676
680
  function generateSeed() {
677
681
  const cryptoObj = getWebCrypto();
678
682
  const bytes = new Uint8Array(64);
@@ -840,8 +844,8 @@ async function createBuildParams(ctx, options) {
840
844
  const program = resolveProgramIdentifier(options.program);
841
845
  const header = await createTransactionHeader(ctx, options.header ?? {}, feePayerPublicKey);
842
846
  const accounts = parseAccounts(options.accounts);
843
- const context = createBuilderContext(feePayerPublicKey, program, accounts);
844
- const instructionData = resolveInstructionData(options.instructionData, context);
847
+ const context = createInstructionContext(feePayerPublicKey, program, accounts);
848
+ const instructionData = await resolveInstructionData(options.instructionData, context);
845
849
  const proofs = createProofs(options);
846
850
  return {
847
851
  feePayer: {
@@ -891,7 +895,7 @@ function parseAccounts(accounts) {
891
895
  }
892
896
  return result;
893
897
  }
894
- function createBuilderContext(feePayer, program, accounts) {
898
+ function createInstructionContext(feePayer, program, accounts) {
895
899
  const allAccounts = [
896
900
  feePayer,
897
901
  program,
@@ -919,12 +923,12 @@ function createBuilderContext(feePayer, program, accounts) {
919
923
  };
920
924
  return { accounts: allAccounts, getAccountIndex };
921
925
  }
922
- function resolveInstructionData(value, context) {
926
+ async function resolveInstructionData(value, context) {
923
927
  if (value === void 0) {
924
928
  return void 0;
925
929
  }
926
930
  if (typeof value === "function") {
927
- return value(context);
931
+ return await value(context);
928
932
  }
929
933
  if (value instanceof Uint8Array) {
930
934
  return value;
@@ -955,6 +959,6 @@ async function fetchFinalizedSlot(ctx) {
955
959
  return height.finalized;
956
960
  }
957
961
 
958
- export { CommandService, ConsensusStatus, DEFAULT_HOST, FilterParamValueSchema, FilterSchema, GetVersionRequestSchema, QueryService, StreamingService, Transaction, TransactionBuilder, accounts_exports, batchSendTransactions, blocks_exports, buildAndSignTransaction, buildTransaction, createAccount, deriveProgramAddress, events_exports, generateKeyPair, generateStateProof, getAccount, getBlock, getBlockHeight, getEvent, getRawAccount, getRawBlock, getRawTransaction, getTransaction, getTransactionStatus, height_exports, keys_exports, listAccounts, listBlocks, listTransactionsForAccount, proofs_exports, sendTransaction, streamAccountUpdates, streamBlocks, streamEvents, streamTransactions, streaming_exports, toBlockHash, toPubkey, toSignature, trackTransaction, transactions_exports };
959
- //# sourceMappingURL=chunk-PH7P5EEU.js.map
960
- //# sourceMappingURL=chunk-PH7P5EEU.js.map
962
+ export { CommandService, ConsensusStatus, DEFAULT_HOST, FilterParamValueSchema, FilterSchema, GetVersionRequestSchema, QueryService, StreamingService, Transaction, TransactionBuilder, accounts_exports, batchSendTransactions, blocks_exports, buildAndSignTransaction, buildTransaction, createAccount, deriveProgramAddress, events_exports, fromPrivateKey, generateKeyPair, generateStateProof, getAccount, getBlock, getBlockHeight, getEvent, getRawAccount, getRawBlock, getRawTransaction, getTransaction, getTransactionStatus, height_exports, keys_exports, listAccounts, listBlocks, listTransactionsForAccount, proofs_exports, sendTransaction, streamAccountUpdates, streamBlocks, streamEvents, streamTransactions, streaming_exports, toBlockHash, toPubkey, toSignature, trackTransaction, transactions_exports };
963
+ //# sourceMappingURL=chunk-SHMREHP5.js.map
964
+ //# sourceMappingURL=chunk-SHMREHP5.js.map