@mycelium-ip/react 0.1.0-alpha.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/README.md +952 -0
- package/dist/hooks/derivative/useCreateDerivativeLink.d.ts +30 -0
- package/dist/hooks/derivative/useCreateDerivativeLink.d.ts.map +1 -0
- package/dist/hooks/derivative/useCreateDerivativeLink.js +45 -0
- package/dist/hooks/derivative/useUpdateDerivativeLicense.d.ts +30 -0
- package/dist/hooks/derivative/useUpdateDerivativeLicense.d.ts.map +1 -0
- package/dist/hooks/derivative/useUpdateDerivativeLicense.js +44 -0
- package/dist/hooks/entity/useCreateEntity.d.ts +28 -0
- package/dist/hooks/entity/useCreateEntity.d.ts.map +1 -0
- package/dist/hooks/entity/useCreateEntity.js +42 -0
- package/dist/hooks/entity/useUpdateEntityControllers.d.ts +28 -0
- package/dist/hooks/entity/useUpdateEntityControllers.d.ts.map +1 -0
- package/dist/hooks/entity/useUpdateEntityControllers.js +42 -0
- package/dist/hooks/grant/useCreateLicenseGrant.d.ts +29 -0
- package/dist/hooks/grant/useCreateLicenseGrant.d.ts.map +1 -0
- package/dist/hooks/grant/useCreateLicenseGrant.js +43 -0
- package/dist/hooks/grant/useRevokeLicenseGrant.d.ts +28 -0
- package/dist/hooks/grant/useRevokeLicenseGrant.d.ts.map +1 -0
- package/dist/hooks/grant/useRevokeLicenseGrant.js +42 -0
- package/dist/hooks/internal/useMyceliumClient.d.ts +15 -0
- package/dist/hooks/internal/useMyceliumClient.d.ts.map +1 -0
- package/dist/hooks/internal/useMyceliumClient.js +18 -0
- package/dist/hooks/internal/useMyceliumConnection.d.ts +14 -0
- package/dist/hooks/internal/useMyceliumConnection.d.ts.map +1 -0
- package/dist/hooks/internal/useMyceliumConnection.js +17 -0
- package/dist/hooks/internal/useMyceliumContext.d.ts +14 -0
- package/dist/hooks/internal/useMyceliumContext.d.ts.map +1 -0
- package/dist/hooks/internal/useMyceliumContext.js +22 -0
- package/dist/hooks/internal/useMyceliumWallet.d.ts +14 -0
- package/dist/hooks/internal/useMyceliumWallet.d.ts.map +1 -0
- package/dist/hooks/internal/useMyceliumWallet.js +17 -0
- package/dist/hooks/ip/useCreateIp.d.ts +29 -0
- package/dist/hooks/ip/useCreateIp.d.ts.map +1 -0
- package/dist/hooks/ip/useCreateIp.js +43 -0
- package/dist/hooks/ip/useTransferIp.d.ts +28 -0
- package/dist/hooks/ip/useTransferIp.d.ts.map +1 -0
- package/dist/hooks/ip/useTransferIp.js +42 -0
- package/dist/hooks/license/useCreateLicense.d.ts +28 -0
- package/dist/hooks/license/useCreateLicense.d.ts.map +1 -0
- package/dist/hooks/license/useCreateLicense.js +42 -0
- package/dist/hooks/license/useRevokeLicense.d.ts +27 -0
- package/dist/hooks/license/useRevokeLicense.d.ts.map +1 -0
- package/dist/hooks/license/useRevokeLicense.js +41 -0
- package/dist/hooks/license/useUpdateLicense.d.ts +28 -0
- package/dist/hooks/license/useUpdateLicense.d.ts.map +1 -0
- package/dist/hooks/license/useUpdateLicense.js +42 -0
- package/dist/hooks/metadata/useCreateEntityMetadata.d.ts +30 -0
- package/dist/hooks/metadata/useCreateEntityMetadata.d.ts.map +1 -0
- package/dist/hooks/metadata/useCreateEntityMetadata.js +45 -0
- package/dist/hooks/metadata/useCreateIpMetadata.d.ts +31 -0
- package/dist/hooks/metadata/useCreateIpMetadata.d.ts.map +1 -0
- package/dist/hooks/metadata/useCreateIpMetadata.js +46 -0
- package/dist/hooks/metadata/useCreateMetadataSchema.d.ts +29 -0
- package/dist/hooks/metadata/useCreateMetadataSchema.d.ts.map +1 -0
- package/dist/hooks/metadata/useCreateMetadataSchema.js +43 -0
- package/dist/hooks/queries/queryKeys.d.ts +45 -0
- package/dist/hooks/queries/queryKeys.d.ts.map +1 -0
- package/dist/hooks/queries/queryKeys.js +44 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +33 -0
- package/dist/provider/MyceliumIpProvider.d.ts +56 -0
- package/dist/provider/MyceliumIpProvider.d.ts.map +1 -0
- package/dist/provider/MyceliumIpProvider.js +76 -0
- package/dist/provider/context.d.ts +22 -0
- package/dist/provider/context.d.ts.map +1 -0
- package/dist/provider/context.js +6 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/wallet.d.ts +54 -0
- package/dist/types/wallet.d.ts.map +1 -0
- package/dist/types/wallet.js +1 -0
- package/dist/utils/transaction.d.ts +40 -0
- package/dist/utils/transaction.d.ts.map +1 -0
- package/dist/utils/transaction.js +82 -0
- package/package.json +59 -0
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to create a new IP (Intellectual Property) asset.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function CreateIpButton({ entityPubkey }: { entityPubkey: PublicKey }) {
|
|
12
|
+
* const { mutate, isPending } = useCreateIp();
|
|
13
|
+
*
|
|
14
|
+
* const handleCreate = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* registrantEntity: entityPubkey,
|
|
17
|
+
* content: new TextEncoder().encode("ip-content-hash"),
|
|
18
|
+
* treasuryTokenAccount: treasuryAccount,
|
|
19
|
+
* payerTokenAccount: payerAccount,
|
|
20
|
+
* });
|
|
21
|
+
* };
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
25
|
+
* Create IP
|
|
26
|
+
* </button>
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function useCreateIp() {
|
|
32
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
return useMutation({
|
|
35
|
+
mutationFn: async (params) => {
|
|
36
|
+
const instruction = await client.ipCore.ip.createIx(params);
|
|
37
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
38
|
+
},
|
|
39
|
+
onSuccess: () => {
|
|
40
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.ips() });
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { TransferIpParams } from "@mycelium-ip/core-sdk";
|
|
2
|
+
import { type TransactionResult } from "../../utils/transaction";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to transfer IP ownership to another entity.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function TransferIpButton({ ipPubkey, currentOwner, newOwner }: Props) {
|
|
9
|
+
* const { mutate, isPending } = useTransferIp();
|
|
10
|
+
*
|
|
11
|
+
* const handleTransfer = () => {
|
|
12
|
+
* mutate({
|
|
13
|
+
* ip: ipPubkey,
|
|
14
|
+
* currentOwnerEntity: currentOwner,
|
|
15
|
+
* newOwnerEntity: newOwner,
|
|
16
|
+
* });
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <button onClick={handleTransfer} disabled={isPending}>
|
|
21
|
+
* Transfer IP
|
|
22
|
+
* </button>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useTransferIp(): import("@tanstack/react-query").UseMutationResult<TransactionResult, Error, TransferIpParams, unknown>;
|
|
28
|
+
//# sourceMappingURL=useTransferIp.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTransferIp.d.ts","sourceRoot":"","sources":["../../../src/hooks/ip/useTransferIp.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAE9D,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,aAAa,2GAa5B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to transfer IP ownership to another entity.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function TransferIpButton({ ipPubkey, currentOwner, newOwner }: Props) {
|
|
12
|
+
* const { mutate, isPending } = useTransferIp();
|
|
13
|
+
*
|
|
14
|
+
* const handleTransfer = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* ip: ipPubkey,
|
|
17
|
+
* currentOwnerEntity: currentOwner,
|
|
18
|
+
* newOwnerEntity: newOwner,
|
|
19
|
+
* });
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <button onClick={handleTransfer} disabled={isPending}>
|
|
24
|
+
* Transfer IP
|
|
25
|
+
* </button>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function useTransferIp() {
|
|
31
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
32
|
+
const queryClient = useQueryClient();
|
|
33
|
+
return useMutation({
|
|
34
|
+
mutationFn: async (params) => {
|
|
35
|
+
const instruction = await client.ipCore.ip.transferIx(params);
|
|
36
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
37
|
+
},
|
|
38
|
+
onSuccess: () => {
|
|
39
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.ips() });
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { CreateLicenseParams } from "@mycelium-ip/core-sdk";
|
|
2
|
+
import { type TransactionResult } from "../../utils/transaction";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to create a new license for an IP.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function CreateLicenseButton({ originIp, ownerEntity }: Props) {
|
|
9
|
+
* const { mutate, isPending } = useCreateLicense();
|
|
10
|
+
*
|
|
11
|
+
* const handleCreate = () => {
|
|
12
|
+
* mutate({
|
|
13
|
+
* originIp,
|
|
14
|
+
* ownerEntity,
|
|
15
|
+
* derivativesAllowed: true,
|
|
16
|
+
* });
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
21
|
+
* Create License
|
|
22
|
+
* </button>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useCreateLicense(): import("@tanstack/react-query").UseMutationResult<TransactionResult, Error, CreateLicenseParams, unknown>;
|
|
28
|
+
//# sourceMappingURL=useCreateLicense.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateLicense.d.ts","sourceRoot":"","sources":["../../../src/hooks/license/useCreateLicense.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,8GAa/B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to create a new license for an IP.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function CreateLicenseButton({ originIp, ownerEntity }: Props) {
|
|
12
|
+
* const { mutate, isPending } = useCreateLicense();
|
|
13
|
+
*
|
|
14
|
+
* const handleCreate = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* originIp,
|
|
17
|
+
* ownerEntity,
|
|
18
|
+
* derivativesAllowed: true,
|
|
19
|
+
* });
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
24
|
+
* Create License
|
|
25
|
+
* </button>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function useCreateLicense() {
|
|
31
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
32
|
+
const queryClient = useQueryClient();
|
|
33
|
+
return useMutation({
|
|
34
|
+
mutationFn: async (params) => {
|
|
35
|
+
const instruction = await client.license.license.createIx(params);
|
|
36
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
37
|
+
},
|
|
38
|
+
onSuccess: () => {
|
|
39
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.licenses() });
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { RevokeLicenseParams } from "@mycelium-ip/core-sdk";
|
|
2
|
+
import { type TransactionResult } from "../../utils/transaction";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to revoke a license.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function RevokeLicenseButton({ originIp, authorityEntity }: Props) {
|
|
9
|
+
* const { mutate, isPending } = useRevokeLicense();
|
|
10
|
+
*
|
|
11
|
+
* const handleRevoke = () => {
|
|
12
|
+
* mutate({
|
|
13
|
+
* originIp,
|
|
14
|
+
* authorityEntity,
|
|
15
|
+
* });
|
|
16
|
+
* };
|
|
17
|
+
*
|
|
18
|
+
* return (
|
|
19
|
+
* <button onClick={handleRevoke} disabled={isPending}>
|
|
20
|
+
* Revoke License
|
|
21
|
+
* </button>
|
|
22
|
+
* );
|
|
23
|
+
* }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export declare function useRevokeLicense(): import("@tanstack/react-query").UseMutationResult<TransactionResult, Error, RevokeLicenseParams, unknown>;
|
|
27
|
+
//# sourceMappingURL=useRevokeLicense.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRevokeLicense.d.ts","sourceRoot":"","sources":["../../../src/hooks/license/useRevokeLicense.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;GAsBG;AACH,wBAAgB,gBAAgB,8GAa/B"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to revoke a license.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function RevokeLicenseButton({ originIp, authorityEntity }: Props) {
|
|
12
|
+
* const { mutate, isPending } = useRevokeLicense();
|
|
13
|
+
*
|
|
14
|
+
* const handleRevoke = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* originIp,
|
|
17
|
+
* authorityEntity,
|
|
18
|
+
* });
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <button onClick={handleRevoke} disabled={isPending}>
|
|
23
|
+
* Revoke License
|
|
24
|
+
* </button>
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export function useRevokeLicense() {
|
|
30
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
31
|
+
const queryClient = useQueryClient();
|
|
32
|
+
return useMutation({
|
|
33
|
+
mutationFn: async (params) => {
|
|
34
|
+
const instruction = await client.license.license.revokeIx(params);
|
|
35
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
36
|
+
},
|
|
37
|
+
onSuccess: () => {
|
|
38
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.licenses() });
|
|
39
|
+
},
|
|
40
|
+
});
|
|
41
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { UpdateLicenseParams } from "@mycelium-ip/core-sdk";
|
|
2
|
+
import { type TransactionResult } from "../../utils/transaction";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to update an existing license.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function UpdateLicenseButton({ originIp, authorityEntity }: Props) {
|
|
9
|
+
* const { mutate, isPending } = useUpdateLicense();
|
|
10
|
+
*
|
|
11
|
+
* const handleUpdate = () => {
|
|
12
|
+
* mutate({
|
|
13
|
+
* originIp,
|
|
14
|
+
* authorityEntity,
|
|
15
|
+
* derivativesAllowed: false,
|
|
16
|
+
* });
|
|
17
|
+
* };
|
|
18
|
+
*
|
|
19
|
+
* return (
|
|
20
|
+
* <button onClick={handleUpdate} disabled={isPending}>
|
|
21
|
+
* Update License
|
|
22
|
+
* </button>
|
|
23
|
+
* );
|
|
24
|
+
* }
|
|
25
|
+
* ```
|
|
26
|
+
*/
|
|
27
|
+
export declare function useUpdateLicense(): import("@tanstack/react-query").UseMutationResult<TransactionResult, Error, UpdateLicenseParams, unknown>;
|
|
28
|
+
//# sourceMappingURL=useUpdateLicense.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useUpdateLicense.d.ts","sourceRoot":"","sources":["../../../src/hooks/license/useUpdateLicense.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,gBAAgB,8GAa/B"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to update an existing license.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function UpdateLicenseButton({ originIp, authorityEntity }: Props) {
|
|
12
|
+
* const { mutate, isPending } = useUpdateLicense();
|
|
13
|
+
*
|
|
14
|
+
* const handleUpdate = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* originIp,
|
|
17
|
+
* authorityEntity,
|
|
18
|
+
* derivativesAllowed: false,
|
|
19
|
+
* });
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <button onClick={handleUpdate} disabled={isPending}>
|
|
24
|
+
* Update License
|
|
25
|
+
* </button>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export function useUpdateLicense() {
|
|
31
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
32
|
+
const queryClient = useQueryClient();
|
|
33
|
+
return useMutation({
|
|
34
|
+
mutationFn: async (params) => {
|
|
35
|
+
const instruction = await client.license.license.updateIx(params);
|
|
36
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
37
|
+
},
|
|
38
|
+
onSuccess: () => {
|
|
39
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.licenses() });
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { CreateEntityMetadataParams } from "@mycelium-ip/core-sdk";
|
|
2
|
+
import { type TransactionResult } from "../../utils/transaction";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to create metadata for an entity.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function AddEntityMetadata({ entityPubkey, schemaPubkey }: Props) {
|
|
9
|
+
* const { mutate, isPending } = useCreateEntityMetadata();
|
|
10
|
+
*
|
|
11
|
+
* const handleCreate = () => {
|
|
12
|
+
* mutate({
|
|
13
|
+
* entity: entityPubkey,
|
|
14
|
+
* schema: schemaPubkey,
|
|
15
|
+
* revision: 1n,
|
|
16
|
+
* data: new TextEncoder().encode(JSON.stringify(metadata)),
|
|
17
|
+
* cid: "Qm...",
|
|
18
|
+
* });
|
|
19
|
+
* };
|
|
20
|
+
*
|
|
21
|
+
* return (
|
|
22
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
23
|
+
* Add Metadata
|
|
24
|
+
* </button>
|
|
25
|
+
* );
|
|
26
|
+
* }
|
|
27
|
+
* ```
|
|
28
|
+
*/
|
|
29
|
+
export declare function useCreateEntityMetadata(): import("@tanstack/react-query").UseMutationResult<TransactionResult, Error, CreateEntityMetadataParams, unknown>;
|
|
30
|
+
//# sourceMappingURL=useCreateEntityMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateEntityMetadata.d.ts","sourceRoot":"","sources":["../../../src/hooks/metadata/useCreateEntityMetadata.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,uBAAuB,qHAetC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to create metadata for an entity.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function AddEntityMetadata({ entityPubkey, schemaPubkey }: Props) {
|
|
12
|
+
* const { mutate, isPending } = useCreateEntityMetadata();
|
|
13
|
+
*
|
|
14
|
+
* const handleCreate = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* entity: entityPubkey,
|
|
17
|
+
* schema: schemaPubkey,
|
|
18
|
+
* revision: 1n,
|
|
19
|
+
* data: new TextEncoder().encode(JSON.stringify(metadata)),
|
|
20
|
+
* cid: "Qm...",
|
|
21
|
+
* });
|
|
22
|
+
* };
|
|
23
|
+
*
|
|
24
|
+
* return (
|
|
25
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
26
|
+
* Add Metadata
|
|
27
|
+
* </button>
|
|
28
|
+
* );
|
|
29
|
+
* }
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export function useCreateEntityMetadata() {
|
|
33
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
34
|
+
const queryClient = useQueryClient();
|
|
35
|
+
return useMutation({
|
|
36
|
+
mutationFn: async (params) => {
|
|
37
|
+
const instruction = await client.ipCore.metadata.createEntityMetadataIx(params);
|
|
38
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
39
|
+
},
|
|
40
|
+
onSuccess: () => {
|
|
41
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.entities() });
|
|
42
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.metadata() });
|
|
43
|
+
},
|
|
44
|
+
});
|
|
45
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { CreateIpMetadataParams } from "@mycelium-ip/core-sdk";
|
|
2
|
+
import { type TransactionResult } from "../../utils/transaction";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to create metadata for an IP.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function AddIpMetadata({ ipPubkey, ownerEntity, schemaPubkey }: Props) {
|
|
9
|
+
* const { mutate, isPending } = useCreateIpMetadata();
|
|
10
|
+
*
|
|
11
|
+
* const handleCreate = () => {
|
|
12
|
+
* mutate({
|
|
13
|
+
* ip: ipPubkey,
|
|
14
|
+
* ownerEntity: ownerEntity,
|
|
15
|
+
* schema: schemaPubkey,
|
|
16
|
+
* revision: 1n,
|
|
17
|
+
* data: new TextEncoder().encode(JSON.stringify(metadata)),
|
|
18
|
+
* cid: "Qm...",
|
|
19
|
+
* });
|
|
20
|
+
* };
|
|
21
|
+
*
|
|
22
|
+
* return (
|
|
23
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
24
|
+
* Add IP Metadata
|
|
25
|
+
* </button>
|
|
26
|
+
* );
|
|
27
|
+
* }
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
30
|
+
export declare function useCreateIpMetadata(): import("@tanstack/react-query").UseMutationResult<TransactionResult, Error, CreateIpMetadataParams, unknown>;
|
|
31
|
+
//# sourceMappingURL=useCreateIpMetadata.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateIpMetadata.d.ts","sourceRoot":"","sources":["../../../src/hooks/metadata/useCreateIpMetadata.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,mBAAmB,iHAelC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to create metadata for an IP.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function AddIpMetadata({ ipPubkey, ownerEntity, schemaPubkey }: Props) {
|
|
12
|
+
* const { mutate, isPending } = useCreateIpMetadata();
|
|
13
|
+
*
|
|
14
|
+
* const handleCreate = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* ip: ipPubkey,
|
|
17
|
+
* ownerEntity: ownerEntity,
|
|
18
|
+
* schema: schemaPubkey,
|
|
19
|
+
* revision: 1n,
|
|
20
|
+
* data: new TextEncoder().encode(JSON.stringify(metadata)),
|
|
21
|
+
* cid: "Qm...",
|
|
22
|
+
* });
|
|
23
|
+
* };
|
|
24
|
+
*
|
|
25
|
+
* return (
|
|
26
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
27
|
+
* Add IP Metadata
|
|
28
|
+
* </button>
|
|
29
|
+
* );
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*/
|
|
33
|
+
export function useCreateIpMetadata() {
|
|
34
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
35
|
+
const queryClient = useQueryClient();
|
|
36
|
+
return useMutation({
|
|
37
|
+
mutationFn: async (params) => {
|
|
38
|
+
const instruction = await client.ipCore.metadata.createIpMetadataIx(params);
|
|
39
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
40
|
+
},
|
|
41
|
+
onSuccess: () => {
|
|
42
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.ips() });
|
|
43
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.metadata() });
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { CreateMetadataSchemaParams } from "@mycelium-ip/core-sdk";
|
|
2
|
+
import { type TransactionResult } from "../../utils/transaction";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to create a new metadata schema.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* ```tsx
|
|
8
|
+
* function CreateSchemaButton() {
|
|
9
|
+
* const { mutate, isPending } = useCreateMetadataSchema();
|
|
10
|
+
*
|
|
11
|
+
* const handleCreate = () => {
|
|
12
|
+
* mutate({
|
|
13
|
+
* id: "my-schema",
|
|
14
|
+
* version: "1.0.0",
|
|
15
|
+
* data: new TextEncoder().encode(JSON.stringify(schemaDefinition)),
|
|
16
|
+
* cid: "Qm...",
|
|
17
|
+
* });
|
|
18
|
+
* };
|
|
19
|
+
*
|
|
20
|
+
* return (
|
|
21
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
22
|
+
* Create Schema
|
|
23
|
+
* </button>
|
|
24
|
+
* );
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare function useCreateMetadataSchema(): import("@tanstack/react-query").UseMutationResult<TransactionResult, Error, CreateMetadataSchemaParams, unknown>;
|
|
29
|
+
//# sourceMappingURL=useCreateMetadataSchema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useCreateMetadataSchema.d.ts","sourceRoot":"","sources":["../../../src/hooks/metadata/useCreateMetadataSchema.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,uBAAuB,CAAC;AAExE,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAIjC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,uBAAuB,qHAatC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
|
3
|
+
import { executeTransaction, } from "../../utils/transaction";
|
|
4
|
+
import { useMyceliumContext } from "../internal/useMyceliumContext";
|
|
5
|
+
import { queryKeys } from "../queries/queryKeys";
|
|
6
|
+
/**
|
|
7
|
+
* Hook to create a new metadata schema.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```tsx
|
|
11
|
+
* function CreateSchemaButton() {
|
|
12
|
+
* const { mutate, isPending } = useCreateMetadataSchema();
|
|
13
|
+
*
|
|
14
|
+
* const handleCreate = () => {
|
|
15
|
+
* mutate({
|
|
16
|
+
* id: "my-schema",
|
|
17
|
+
* version: "1.0.0",
|
|
18
|
+
* data: new TextEncoder().encode(JSON.stringify(schemaDefinition)),
|
|
19
|
+
* cid: "Qm...",
|
|
20
|
+
* });
|
|
21
|
+
* };
|
|
22
|
+
*
|
|
23
|
+
* return (
|
|
24
|
+
* <button onClick={handleCreate} disabled={isPending}>
|
|
25
|
+
* Create Schema
|
|
26
|
+
* </button>
|
|
27
|
+
* );
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export function useCreateMetadataSchema() {
|
|
32
|
+
const { client, connection, wallet, confirmation } = useMyceliumContext();
|
|
33
|
+
const queryClient = useQueryClient();
|
|
34
|
+
return useMutation({
|
|
35
|
+
mutationFn: async (params) => {
|
|
36
|
+
const instruction = await client.ipCore.metadata.createSchemaIx(params);
|
|
37
|
+
return executeTransaction(connection, wallet, instruction, confirmation);
|
|
38
|
+
},
|
|
39
|
+
onSuccess: () => {
|
|
40
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.metadata() });
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Query key factory for TanStack Query.
|
|
3
|
+
*
|
|
4
|
+
* Provides a structured, type-safe way to define query keys
|
|
5
|
+
* for granular cache invalidation.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* // Invalidate all mycelium queries
|
|
10
|
+
* queryClient.invalidateQueries({ queryKey: queryKeys.all });
|
|
11
|
+
*
|
|
12
|
+
* // Invalidate specific entity
|
|
13
|
+
* queryClient.invalidateQueries({ queryKey: queryKeys.entity("123") });
|
|
14
|
+
*
|
|
15
|
+
* // Invalidate all IPs
|
|
16
|
+
* queryClient.invalidateQueries({ queryKey: queryKeys.ips() });
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export declare const queryKeys: {
|
|
20
|
+
/** Root key for all mycelium queries */
|
|
21
|
+
all: readonly ["mycelium"];
|
|
22
|
+
/** Key for all entity queries */
|
|
23
|
+
entities: () => readonly ["mycelium", "entities"];
|
|
24
|
+
/** Key for a specific entity */
|
|
25
|
+
entity: (id: string) => readonly ["mycelium", "entities", string];
|
|
26
|
+
/** Key for all IP queries */
|
|
27
|
+
ips: () => readonly ["mycelium", "ips"];
|
|
28
|
+
/** Key for a specific IP */
|
|
29
|
+
ip: (id: string) => readonly ["mycelium", "ips", string];
|
|
30
|
+
/** Key for all license queries */
|
|
31
|
+
licenses: () => readonly ["mycelium", "licenses"];
|
|
32
|
+
/** Key for a specific license */
|
|
33
|
+
license: (id: string) => readonly ["mycelium", "licenses", string];
|
|
34
|
+
/** Key for all grant queries */
|
|
35
|
+
grants: () => readonly ["mycelium", "grants"];
|
|
36
|
+
/** Key for a specific grant */
|
|
37
|
+
grant: (id: string) => readonly ["mycelium", "grants", string];
|
|
38
|
+
/** Key for all metadata queries */
|
|
39
|
+
metadata: () => readonly ["mycelium", "metadata"];
|
|
40
|
+
/** Key for all derivative queries */
|
|
41
|
+
derivatives: () => readonly ["mycelium", "derivatives"];
|
|
42
|
+
/** Key for a specific derivative */
|
|
43
|
+
derivative: (id: string) => readonly ["mycelium", "derivatives", string];
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=queryKeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queryKeys.d.ts","sourceRoot":"","sources":["../../../src/hooks/queries/queryKeys.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,eAAO,MAAM,SAAS;IACpB,wCAAwC;;IAGxC,iCAAiC;;IAGjC,gCAAgC;iBACnB,MAAM;IAEnB,6BAA6B;;IAG7B,4BAA4B;aACnB,MAAM;IAEf,kCAAkC;;IAGlC,iCAAiC;kBACnB,MAAM;IAEpB,gCAAgC;;IAGhC,+BAA+B;gBACnB,MAAM;IAElB,mCAAmC;;IAGnC,qCAAqC;;IAGrC,oCAAoC;qBACnB,MAAM;CACxB,CAAC"}
|