@shelby-protocol/react 0.0.4 → 1.0.0

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 (78) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/README.md +31 -0
  3. package/dist/chunk-ESCNOV4I.js +2 -0
  4. package/dist/chunk-ESCNOV4I.js.map +1 -0
  5. package/dist/chunk-EYENPTAB.cjs +2 -0
  6. package/dist/chunk-EYENPTAB.cjs.map +1 -0
  7. package/dist/components/ShelbyClientProvider.d.ts +8 -0
  8. package/dist/components/ShelbyClientProvider.d.ts.map +1 -0
  9. package/dist/components/index.d.ts +2 -0
  10. package/dist/components/index.d.ts.map +1 -0
  11. package/dist/core/index.cjs +2 -0
  12. package/dist/core/index.cjs.map +1 -0
  13. package/dist/core/index.d.ts +3 -0
  14. package/dist/core/index.d.ts.map +1 -0
  15. package/dist/core/index.js +2 -0
  16. package/dist/core/index.js.map +1 -0
  17. package/dist/core/queries/accountBlobs.d.ts +8 -0
  18. package/dist/core/queries/accountBlobs.d.ts.map +1 -0
  19. package/dist/core/queries/blobMetadata.d.ts +8 -0
  20. package/dist/core/queries/blobMetadata.d.ts.map +1 -0
  21. package/dist/core/queries/index.d.ts +3 -0
  22. package/dist/core/queries/index.d.ts.map +1 -0
  23. package/dist/core/types.d.ts +6 -0
  24. package/dist/core/types.d.ts.map +1 -0
  25. package/dist/index.cjs +1 -1
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.d.ts +2 -0
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +1 -1
  30. package/dist/index.js.map +1 -1
  31. package/dist/mutations/index.d.ts +2 -0
  32. package/dist/mutations/index.d.ts.map +1 -1
  33. package/dist/mutations/useCommitBlobs.d.ts +1 -1
  34. package/dist/mutations/useCommitBlobs.d.ts.map +1 -1
  35. package/dist/mutations/useDeleteBlob.d.ts +60 -0
  36. package/dist/mutations/useDeleteBlob.d.ts.map +1 -0
  37. package/dist/mutations/useDeleteBlobs.d.ts +77 -0
  38. package/dist/mutations/useDeleteBlobs.d.ts.map +1 -0
  39. package/dist/mutations/useEncodeBlobs.d.ts +11 -8
  40. package/dist/mutations/useEncodeBlobs.d.ts.map +1 -1
  41. package/dist/mutations/useRegisterCommitments.d.ts +1 -1
  42. package/dist/mutations/useRegisterCommitments.d.ts.map +1 -1
  43. package/dist/mutations/useUploadBlobs.d.ts +1 -1
  44. package/dist/mutations/useUploadBlobs.d.ts.map +1 -1
  45. package/dist/queries/useAccountBlobs.d.ts +4 -8
  46. package/dist/queries/useAccountBlobs.d.ts.map +1 -1
  47. package/dist/queries/useBlobMetadata.d.ts +4 -8
  48. package/dist/queries/useBlobMetadata.d.ts.map +1 -1
  49. package/dist/types/index.d.ts +2 -0
  50. package/dist/types/index.d.ts.map +1 -0
  51. package/dist/types/mutations.d.ts +4 -3
  52. package/dist/types/mutations.d.ts.map +1 -1
  53. package/dist/types/queries.d.ts +1 -5
  54. package/dist/types/queries.d.ts.map +1 -1
  55. package/dist/types/signers.d.ts +21 -1
  56. package/dist/types/signers.d.ts.map +1 -1
  57. package/package.json +14 -5
  58. package/src/components/ShelbyClientProvider.tsx +26 -0
  59. package/src/components/index.ts +1 -0
  60. package/src/core/index.ts +2 -0
  61. package/src/core/queries/accountBlobs.ts +23 -0
  62. package/src/core/queries/blobMetadata.ts +16 -0
  63. package/src/core/queries/index.ts +8 -0
  64. package/src/core/types.ts +16 -0
  65. package/src/index.ts +2 -0
  66. package/src/mutations/index.ts +2 -0
  67. package/src/mutations/useCommitBlobs.tsx +3 -4
  68. package/src/mutations/useDeleteBlob.tsx +93 -0
  69. package/src/mutations/useDeleteBlobs.tsx +139 -0
  70. package/src/mutations/useEncodeBlobs.tsx +11 -11
  71. package/src/mutations/useRegisterCommitments.tsx +17 -3
  72. package/src/mutations/useUploadBlobs.tsx +25 -9
  73. package/src/queries/useAccountBlobs.tsx +12 -23
  74. package/src/queries/useBlobMetadata.tsx +12 -16
  75. package/src/types/index.ts +1 -0
  76. package/src/types/mutations.ts +13 -4
  77. package/src/types/queries.ts +1 -16
  78. package/src/types/signers.ts +19 -1
@@ -1,20 +1,15 @@
1
- import type { Network } from "@aptos-labs/ts-sdk";
2
- import type {
3
- BlobMetadata,
4
- ShelbyBlobClient,
5
- } from "@shelby-protocol/sdk/browser";
1
+ import type { BlobMetadata } from "@shelby-protocol/sdk/browser";
6
2
  import { useQuery } from "@tanstack/react-query";
7
- import type { UseQueryOptionsWithClient } from "../types/queries";
3
+ import { useShelbyClient } from "../components/ShelbyClientProvider";
4
+ import {
5
+ getUseBlobMetadataQueryKey,
6
+ type UseBlobMetadataOptions,
7
+ } from "../core/queries/blobMetadata";
8
8
 
9
- export const getUseBlobMetadataQueryKey = (
10
- params: Parameters<ShelbyBlobClient["getBlobMetadata"]>[0] & {
11
- network: Network;
12
- },
13
- ) => ["blob-metadata", params.network, params.account.toString(), params.name];
14
-
15
- export type UseBlobMetadataOptions =
16
- UseQueryOptionsWithClient<BlobMetadata | null> &
17
- Parameters<ShelbyBlobClient["getBlobMetadata"]>[0];
9
+ export {
10
+ getUseBlobMetadataQueryKey,
11
+ type UseBlobMetadataOptions,
12
+ } from "../core/queries/blobMetadata";
18
13
 
19
14
  /**
20
15
  * Queries the metadata for a specific blob.
@@ -39,9 +34,10 @@ export type UseBlobMetadataOptions =
39
34
  export function useBlobMetadata({
40
35
  account,
41
36
  name,
42
- client: shelbyClient,
37
+ client,
43
38
  ...options
44
39
  }: UseBlobMetadataOptions) {
40
+ const shelbyClient = useShelbyClient(client);
45
41
  return useQuery<BlobMetadata | null>({
46
42
  queryKey: getUseBlobMetadataQueryKey({
47
43
  network: shelbyClient.config.network,
@@ -0,0 +1 @@
1
+ export * from "./signers";
@@ -2,15 +2,24 @@ import type { ShelbyClient } from "@shelby-protocol/sdk/browser";
2
2
  import type {
3
3
  DefaultError,
4
4
  MutationKey,
5
- UseMutationOptions,
5
+ UseMutationOptions as UseMutationOptionsTanstack,
6
6
  } from "@tanstack/react-query";
7
7
 
8
- export type UseMutationOptionsWithClient<
8
+ export type UseMutationOptions<
9
9
  TMutationFnData = unknown,
10
10
  TError = DefaultError,
11
11
  TData = TMutationFnData,
12
12
  TMutationKey extends MutationKey = MutationKey,
13
13
  > = Omit<
14
- UseMutationOptions<TMutationFnData, TError, TData, TMutationKey>,
14
+ UseMutationOptionsTanstack<TMutationFnData, TError, TData, TMutationKey>,
15
15
  "mutationFn"
16
- > & { client: ShelbyClient };
16
+ >;
17
+
18
+ export type UseMutationOptionsWithClient<
19
+ TMutationFnData = unknown,
20
+ TError = DefaultError,
21
+ TData = TMutationFnData,
22
+ TMutationKey extends MutationKey = MutationKey,
23
+ > = UseMutationOptions<TMutationFnData, TError, TData, TMutationKey> & {
24
+ client?: ShelbyClient | null;
25
+ };
@@ -1,16 +1 @@
1
- import type { ShelbyClient } from "@shelby-protocol/sdk/browser";
2
- import type {
3
- DefaultError,
4
- QueryKey,
5
- UseQueryOptions,
6
- } from "@tanstack/react-query";
7
-
8
- export type UseQueryOptionsWithClient<
9
- TQueryFnData = unknown,
10
- TError = DefaultError,
11
- TData = TQueryFnData,
12
- TQueryKey extends QueryKey = QueryKey,
13
- > = Omit<
14
- UseQueryOptions<TQueryFnData, TError, TData, TQueryKey>,
15
- "queryFn" | "queryKey"
16
- > & { client: ShelbyClient };
1
+ export type { UseQueryOptionsWithClient } from "../core/types";
@@ -4,8 +4,26 @@ import type { SignAndSubmitTransactionFn } from "./walletAdapter";
4
4
  export type AccountSigner = Account;
5
5
 
6
6
  export type WalletAdapterSigner = {
7
- account: AccountAddressInput;
7
+ account?: AccountAddressInput | { address: AccountAddressInput } | null;
8
8
  signAndSubmitTransaction: SignAndSubmitTransactionFn;
9
9
  };
10
10
 
11
+ /**
12
+ * A signer is a user who can sign transactions on the Shelby network.
13
+ * It can be an account signer or a wallet adapter signer.
14
+ *
15
+ * @example AccountSigner
16
+ * ```tsx
17
+ * const signer = new Account.generate();
18
+ * ```
19
+ *
20
+ * @example WalletAdapterSigner
21
+ * ```tsx
22
+ * const walletAdapterSigner = useWallet();
23
+ *
24
+ * if (!walletAdapterSigner.account) throw new Error("A wallet must be connected to sign transactions");
25
+ *
26
+ * const signer = walletAdapterSigner;
27
+ * ```
28
+ */
11
29
  export type Signer = AccountSigner | WalletAdapterSigner;