@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.
- package/CHANGELOG.md +21 -0
- package/README.md +31 -0
- package/dist/chunk-ESCNOV4I.js +2 -0
- package/dist/chunk-ESCNOV4I.js.map +1 -0
- package/dist/chunk-EYENPTAB.cjs +2 -0
- package/dist/chunk-EYENPTAB.cjs.map +1 -0
- package/dist/components/ShelbyClientProvider.d.ts +8 -0
- package/dist/components/ShelbyClientProvider.d.ts.map +1 -0
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/core/index.cjs +2 -0
- package/dist/core/index.cjs.map +1 -0
- package/dist/core/index.d.ts +3 -0
- package/dist/core/index.d.ts.map +1 -0
- package/dist/core/index.js +2 -0
- package/dist/core/index.js.map +1 -0
- package/dist/core/queries/accountBlobs.d.ts +8 -0
- package/dist/core/queries/accountBlobs.d.ts.map +1 -0
- package/dist/core/queries/blobMetadata.d.ts +8 -0
- package/dist/core/queries/blobMetadata.d.ts.map +1 -0
- package/dist/core/queries/index.d.ts +3 -0
- package/dist/core/queries/index.d.ts.map +1 -0
- package/dist/core/types.d.ts +6 -0
- package/dist/core/types.d.ts.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/mutations/index.d.ts +2 -0
- package/dist/mutations/index.d.ts.map +1 -1
- package/dist/mutations/useCommitBlobs.d.ts +1 -1
- package/dist/mutations/useCommitBlobs.d.ts.map +1 -1
- package/dist/mutations/useDeleteBlob.d.ts +60 -0
- package/dist/mutations/useDeleteBlob.d.ts.map +1 -0
- package/dist/mutations/useDeleteBlobs.d.ts +77 -0
- package/dist/mutations/useDeleteBlobs.d.ts.map +1 -0
- package/dist/mutations/useEncodeBlobs.d.ts +11 -8
- package/dist/mutations/useEncodeBlobs.d.ts.map +1 -1
- package/dist/mutations/useRegisterCommitments.d.ts +1 -1
- package/dist/mutations/useRegisterCommitments.d.ts.map +1 -1
- package/dist/mutations/useUploadBlobs.d.ts +1 -1
- package/dist/mutations/useUploadBlobs.d.ts.map +1 -1
- package/dist/queries/useAccountBlobs.d.ts +4 -8
- package/dist/queries/useAccountBlobs.d.ts.map +1 -1
- package/dist/queries/useBlobMetadata.d.ts +4 -8
- package/dist/queries/useBlobMetadata.d.ts.map +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/mutations.d.ts +4 -3
- package/dist/types/mutations.d.ts.map +1 -1
- package/dist/types/queries.d.ts +1 -5
- package/dist/types/queries.d.ts.map +1 -1
- package/dist/types/signers.d.ts +21 -1
- package/dist/types/signers.d.ts.map +1 -1
- package/package.json +14 -5
- package/src/components/ShelbyClientProvider.tsx +26 -0
- package/src/components/index.ts +1 -0
- package/src/core/index.ts +2 -0
- package/src/core/queries/accountBlobs.ts +23 -0
- package/src/core/queries/blobMetadata.ts +16 -0
- package/src/core/queries/index.ts +8 -0
- package/src/core/types.ts +16 -0
- package/src/index.ts +2 -0
- package/src/mutations/index.ts +2 -0
- package/src/mutations/useCommitBlobs.tsx +3 -4
- package/src/mutations/useDeleteBlob.tsx +93 -0
- package/src/mutations/useDeleteBlobs.tsx +139 -0
- package/src/mutations/useEncodeBlobs.tsx +11 -11
- package/src/mutations/useRegisterCommitments.tsx +17 -3
- package/src/mutations/useUploadBlobs.tsx +25 -9
- package/src/queries/useAccountBlobs.tsx +12 -23
- package/src/queries/useBlobMetadata.tsx +12 -16
- package/src/types/index.ts +1 -0
- package/src/types/mutations.ts +13 -4
- package/src/types/queries.ts +1 -16
- package/src/types/signers.ts +19 -1
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
import type {
|
|
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
|
|
3
|
+
import { useShelbyClient } from "../components/ShelbyClientProvider";
|
|
4
|
+
import {
|
|
5
|
+
getUseBlobMetadataQueryKey,
|
|
6
|
+
type UseBlobMetadataOptions,
|
|
7
|
+
} from "../core/queries/blobMetadata";
|
|
8
8
|
|
|
9
|
-
export
|
|
10
|
-
|
|
11
|
-
|
|
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
|
|
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";
|
package/src/types/mutations.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
14
|
+
UseMutationOptionsTanstack<TMutationFnData, TError, TData, TMutationKey>,
|
|
15
15
|
"mutationFn"
|
|
16
|
-
|
|
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
|
+
};
|
package/src/types/queries.ts
CHANGED
|
@@ -1,16 +1 @@
|
|
|
1
|
-
|
|
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";
|
package/src/types/signers.ts
CHANGED
|
@@ -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;
|