@solana/connector 0.1.7 → 0.1.9

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 (50) hide show
  1. package/README.md +83 -5
  2. package/dist/{chunk-VA6LKXCQ.js → chunk-5HRJKCIL.js} +204 -268
  3. package/dist/chunk-5HRJKCIL.js.map +1 -0
  4. package/dist/chunk-DSUCH44G.js +678 -0
  5. package/dist/chunk-DSUCH44G.js.map +1 -0
  6. package/dist/{chunk-VZ5Y6DIM.js → chunk-I6TJLYNA.js} +80 -235
  7. package/dist/chunk-I6TJLYNA.js.map +1 -0
  8. package/dist/chunk-J7DHGLW6.mjs +638 -0
  9. package/dist/chunk-J7DHGLW6.mjs.map +1 -0
  10. package/dist/{chunk-TQRJYZNK.mjs → chunk-JOBLG62A.mjs} +71 -218
  11. package/dist/chunk-JOBLG62A.mjs.map +1 -0
  12. package/dist/{chunk-APQGEW7S.mjs → chunk-MAXA3HEP.mjs} +120 -170
  13. package/dist/chunk-MAXA3HEP.mjs.map +1 -0
  14. package/dist/{chunk-JK47EFJT.mjs → chunk-P5LXUDP6.mjs} +65 -14
  15. package/dist/chunk-P5LXUDP6.mjs.map +1 -0
  16. package/dist/{chunk-Z22V3D4E.js → chunk-WDXEP4AJ.js} +95 -37
  17. package/dist/chunk-WDXEP4AJ.js.map +1 -0
  18. package/dist/compat.d.mts +1 -1
  19. package/dist/compat.d.ts +1 -1
  20. package/dist/compat.js +40 -39
  21. package/dist/compat.js.map +1 -1
  22. package/dist/compat.mjs +39 -38
  23. package/dist/compat.mjs.map +1 -1
  24. package/dist/headless.d.mts +447 -151
  25. package/dist/headless.d.ts +447 -151
  26. package/dist/headless.js +214 -194
  27. package/dist/headless.mjs +3 -3
  28. package/dist/index.d.mts +7 -6
  29. package/dist/index.d.ts +7 -6
  30. package/dist/index.js +268 -224
  31. package/dist/index.mjs +4 -4
  32. package/dist/react.d.mts +108 -7
  33. package/dist/react.d.ts +108 -7
  34. package/dist/react.js +54 -30
  35. package/dist/react.mjs +2 -2
  36. package/dist/{wallet-standard-shim-DiMvGjOk.d.ts → standard-shim-CT49DM5l.d.mts} +38 -247
  37. package/dist/{wallet-standard-shim-D4CYG5sU.d.mts → standard-shim-D9guL5fz.d.ts} +38 -247
  38. package/dist/{transaction-signer-CpGEvp7S.d.mts → transaction-signer-T-KVQFi8.d.mts} +1 -1
  39. package/dist/{transaction-signer-CpGEvp7S.d.ts → transaction-signer-T-KVQFi8.d.ts} +1 -1
  40. package/package.json +3 -3
  41. package/dist/chunk-APQGEW7S.mjs.map +0 -1
  42. package/dist/chunk-I64FD2EH.js +0 -312
  43. package/dist/chunk-I64FD2EH.js.map +0 -1
  44. package/dist/chunk-JK47EFJT.mjs.map +0 -1
  45. package/dist/chunk-QL3IT3TS.mjs +0 -299
  46. package/dist/chunk-QL3IT3TS.mjs.map +0 -1
  47. package/dist/chunk-TQRJYZNK.mjs.map +0 -1
  48. package/dist/chunk-VA6LKXCQ.js.map +0 -1
  49. package/dist/chunk-VZ5Y6DIM.js.map +0 -1
  50. package/dist/chunk-Z22V3D4E.js.map +0 -1
package/README.md CHANGED
@@ -911,6 +911,85 @@ Token prices are cached for 60 seconds to minimize API calls. The retry logic on
911
911
 
912
912
  ## Advanced Usage
913
913
 
914
+ ### Error Handling with `tryCatch`
915
+
916
+ ConnectorKit exports a `tryCatch` utility for consistent async error handling:
917
+
918
+ ```typescript
919
+ import { tryCatch } from '@solana/connector/headless';
920
+
921
+ // Instead of try/catch blocks
922
+ async function sendTransaction() {
923
+ const { data: signature, error } = await tryCatch(signer.signAndSendTransaction(transaction));
924
+
925
+ if (error) {
926
+ console.error('Transaction failed:', error.message);
927
+ return;
928
+ }
929
+
930
+ console.log('Transaction sent:', signature);
931
+ }
932
+ ```
933
+
934
+ The `tryCatch` utility returns a `Result<T, E>` type that's either a success with `data` or a failure with `error`:
935
+
936
+ ```typescript
937
+ interface Success<T> {
938
+ data: T;
939
+ error: null;
940
+ }
941
+
942
+ interface Failure<E> {
943
+ data: null;
944
+ error: E;
945
+ }
946
+ ```
947
+
948
+ Also available: `tryCatchSync` for synchronous operations, and `isSuccess`/`isFailure` type guards.
949
+
950
+ ### Cache Invalidation with Query Keys
951
+
952
+ For advanced cache management, ConnectorKit exports query key generators:
953
+
954
+ ```typescript
955
+ import {
956
+ getBalanceQueryKey,
957
+ getTokensQueryKey,
958
+ getTransactionsQueryKey,
959
+ invalidateSharedQuery,
960
+ } from '@solana/connector/react';
961
+
962
+ // After sending a transaction, invalidate relevant caches
963
+ async function sendAndRefresh() {
964
+ await sendTransaction();
965
+
966
+ // Invalidate balance and tokens (they share the same cache)
967
+ const balanceKey = getBalanceQueryKey(rpcUrl, address);
968
+ if (balanceKey) invalidateSharedQuery(balanceKey);
969
+
970
+ // Invalidate transactions
971
+ const txKey = getTransactionsQueryKey({ rpcUrl, address, clusterId });
972
+ if (txKey) invalidateSharedQuery(txKey);
973
+ }
974
+ ```
975
+
976
+ ### Configuration Validation
977
+
978
+ Configuration is validated at runtime using Zod schemas. For manual validation:
979
+
980
+ ```typescript
981
+ import { validateConfigOptions } from '@solana/connector/headless';
982
+
983
+ const result = validateConfigOptions({
984
+ appName: 'My App',
985
+ network: 'mainnet',
986
+ });
987
+
988
+ if (!result.success) {
989
+ console.error('Validation errors:', result.error.issues);
990
+ }
991
+ ```
992
+
914
993
  ### Headless Client (Vue, Svelte, Vanilla JS)
915
994
 
916
995
  Use `ConnectorClient` for non-React frameworks:
@@ -1021,11 +1100,10 @@ import { useConnector, useAccount } from '@solana/connector/react';
1021
1100
 
1022
1101
  ### Configuration Functions
1023
1102
 
1024
- | Function | Description |
1025
- | --------------------------------- | ------------------------------------------------- |
1026
- | `getDefaultConfig(options)` | Create default connector configuration |
1027
- | `getDefaultMobileConfig(options)` | Create mobile wallet adapter configuration |
1028
- | `createConfig(options)` | Create unified config for ConnectorKit + Armadura |
1103
+ | Function | Description |
1104
+ | --------------------------------- | ------------------------------------------ |
1105
+ | `getDefaultConfig(options)` | Create default connector configuration |
1106
+ | `getDefaultMobileConfig(options)` | Create mobile wallet adapter configuration |
1029
1107
 
1030
1108
  ### Utility Functions
1031
1109