@campnetwork/origin 0.0.17 → 1.0.0-alpha.1
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/dist/core.cjs +84 -105
- package/dist/core.d.ts +28 -9
- package/dist/core.esm.d.ts +28 -9
- package/dist/core.esm.js +88 -109
- package/dist/react/components/toasts.d.ts +10 -0
- package/dist/react/index.esm.d.ts +33 -10
- package/dist/react/index.esm.js +1455 -750
- package/package.json +1 -1
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { ReactNode } from "react";
|
|
2
|
+
interface ToastContextProps {
|
|
3
|
+
addToast: (message: string, type?: "info" | "success" | "error" | "warning", duration?: number) => void;
|
|
4
|
+
}
|
|
5
|
+
interface ToastProviderProps {
|
|
6
|
+
children: ReactNode;
|
|
7
|
+
}
|
|
8
|
+
export declare const ToastProvider: ({ children }: ToastProviderProps) => React.JSX.Element;
|
|
9
|
+
export declare const useToast: () => ToastContextProps;
|
|
10
|
+
export {};
|
|
@@ -2,6 +2,18 @@ import React, { JSX } from 'react';
|
|
|
2
2
|
import { Address, Hex, Abi } from 'viem';
|
|
3
3
|
import { UseQueryResult } from '@tanstack/react-query';
|
|
4
4
|
|
|
5
|
+
interface Environment {
|
|
6
|
+
NAME: string;
|
|
7
|
+
AUTH_HUB_BASE_API: string;
|
|
8
|
+
AUTH_ENDPOINT: string;
|
|
9
|
+
ORIGIN_DASHBOARD: string;
|
|
10
|
+
DATANFT_CONTRACT_ADDRESS: string;
|
|
11
|
+
MARKETPLACE_CONTRACT_ADDRESS: string;
|
|
12
|
+
CHAIN: any;
|
|
13
|
+
IPNFT_ABI?: any;
|
|
14
|
+
MARKETPLACE_ABI?: any;
|
|
15
|
+
}
|
|
16
|
+
|
|
5
17
|
/**
|
|
6
18
|
* Represents the terms of a license for a digital asset.
|
|
7
19
|
* @property price - The price of the asset in wei.
|
|
@@ -36,7 +48,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
|
|
|
36
48
|
* Mints a Data NFT with a signature.
|
|
37
49
|
* @param to The address to mint the NFT to.
|
|
38
50
|
* @param tokenId The ID of the token to mint.
|
|
39
|
-
* @param
|
|
51
|
+
* @param parents The IDs of the parent NFTs, if applicable.
|
|
40
52
|
* @param hash The hash of the data associated with the NFT.
|
|
41
53
|
* @param uri The URI of the NFT metadata.
|
|
42
54
|
* @param licenseTerms The terms of the license for the NFT.
|
|
@@ -44,7 +56,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
|
|
|
44
56
|
* @param signature The signature for the minting operation.
|
|
45
57
|
* @returns A promise that resolves when the minting is complete.
|
|
46
58
|
*/
|
|
47
|
-
declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint,
|
|
59
|
+
declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, parents: bigint[], hash: Hex, uri: string, licenseTerms: LicenseTerms, deadline: bigint, signature: Hex): Promise<any>;
|
|
48
60
|
/**
|
|
49
61
|
* Registers a Data NFT with the Origin service in order to obtain a signature for minting.
|
|
50
62
|
* @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
|
|
@@ -52,7 +64,7 @@ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, p
|
|
|
52
64
|
* @param fileKey Optional file key for file uploads.
|
|
53
65
|
* @return A promise that resolves with the registration data.
|
|
54
66
|
*/
|
|
55
|
-
declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[],
|
|
67
|
+
declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
|
|
56
68
|
|
|
57
69
|
declare function updateTerms(this: Origin, tokenId: bigint, royaltyReceiver: Address, newTerms: LicenseTerms): Promise<any>;
|
|
58
70
|
|
|
@@ -84,7 +96,7 @@ declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<an
|
|
|
84
96
|
|
|
85
97
|
declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
|
|
86
98
|
|
|
87
|
-
declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint,
|
|
99
|
+
declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
|
|
88
100
|
|
|
89
101
|
declare function renewAccess(this: Origin, tokenId: bigint, buyer: Address, periods: number, value?: bigint): Promise<any>;
|
|
90
102
|
|
|
@@ -134,14 +146,15 @@ declare class Origin {
|
|
|
134
146
|
hasAccess: typeof hasAccess;
|
|
135
147
|
subscriptionExpiry: typeof subscriptionExpiry;
|
|
136
148
|
private jwt;
|
|
149
|
+
environment: Environment;
|
|
137
150
|
private viemClient?;
|
|
138
|
-
constructor(jwt: string, viemClient?: any);
|
|
151
|
+
constructor(jwt: string, environment: Environment, viemClient?: any);
|
|
139
152
|
getJwt(): string;
|
|
140
153
|
setViemClient(client: any): void;
|
|
141
154
|
uploadFile: (file: File, options?: {
|
|
142
155
|
progressCallback?: (percent: number) => void;
|
|
143
156
|
}) => Promise<any>;
|
|
144
|
-
mintFile: (file: File, metadata: Record<string, unknown>, license: LicenseTerms,
|
|
157
|
+
mintFile: (file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
|
|
145
158
|
progressCallback?: (percent: number) => void;
|
|
146
159
|
}) => Promise<string | null>;
|
|
147
160
|
mintSocial: (source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms) => Promise<string | null>;
|
|
@@ -179,10 +192,9 @@ declare class Origin {
|
|
|
179
192
|
/**
|
|
180
193
|
* Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
|
|
181
194
|
* @param {bigint} tokenId The token ID of the asset.
|
|
182
|
-
* @param {number} periods The number of periods to buy access for.
|
|
183
195
|
* @returns {Promise<any>} The result of the buyAccess call.
|
|
184
196
|
*/
|
|
185
|
-
buyAccessSmart(tokenId: bigint
|
|
197
|
+
buyAccessSmart(tokenId: bigint): Promise<any>;
|
|
186
198
|
getData(tokenId: bigint): Promise<any>;
|
|
187
199
|
}
|
|
188
200
|
|
|
@@ -206,6 +218,7 @@ declare class Auth {
|
|
|
206
218
|
userId: string | null;
|
|
207
219
|
viem: any;
|
|
208
220
|
origin: Origin | null;
|
|
221
|
+
environment: Environment;
|
|
209
222
|
/**
|
|
210
223
|
* Constructor for the Auth class.
|
|
211
224
|
* @param {object} options The options object.
|
|
@@ -213,13 +226,15 @@ declare class Auth {
|
|
|
213
226
|
* @param {string|object} options.redirectUri The redirect URI used for oauth. Leave empty if you want to use the current URL. If you want different redirect URIs for different socials, pass an object with the socials as keys and the redirect URIs as values.
|
|
214
227
|
* @param {boolean} [options.allowAnalytics=true] Whether to allow analytics to be sent.
|
|
215
228
|
* @param {object} [options.ackeeInstance] The Ackee instance.
|
|
229
|
+
* @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
|
|
216
230
|
* @throws {APIError} - Throws an error if the clientId is not provided.
|
|
217
231
|
*/
|
|
218
|
-
constructor({ clientId, redirectUri, allowAnalytics, ackeeInstance, }: {
|
|
232
|
+
constructor({ clientId, redirectUri, allowAnalytics, ackeeInstance, environment, }: {
|
|
219
233
|
clientId: string;
|
|
220
234
|
redirectUri: string | Record<string, string>;
|
|
221
235
|
allowAnalytics?: boolean;
|
|
222
236
|
ackeeInstance?: any;
|
|
237
|
+
environment?: "DEVELOPMENT" | "PRODUCTION";
|
|
223
238
|
});
|
|
224
239
|
/**
|
|
225
240
|
* Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
|
|
@@ -255,6 +270,10 @@ declare class Auth {
|
|
|
255
270
|
* @returns {void}
|
|
256
271
|
*/
|
|
257
272
|
setWalletAddress(walletAddress: string): void;
|
|
273
|
+
/**
|
|
274
|
+
* Recover the provider from local storage.
|
|
275
|
+
* @returns {Promise<void>}
|
|
276
|
+
*/
|
|
258
277
|
recoverProvider(): Promise<void>;
|
|
259
278
|
/**
|
|
260
279
|
* Disconnect the user.
|
|
@@ -374,6 +393,7 @@ interface CampContextType {
|
|
|
374
393
|
wagmiAvailable: boolean;
|
|
375
394
|
ackee: any;
|
|
376
395
|
setAckee: any;
|
|
396
|
+
environment: Environment;
|
|
377
397
|
}
|
|
378
398
|
declare const CampContext: React.Context<CampContextType>;
|
|
379
399
|
/**
|
|
@@ -385,11 +405,12 @@ declare const CampContext: React.Context<CampContextType>;
|
|
|
385
405
|
* @param {boolean} props.allowAnalytics Whether to allow analytics to be sent
|
|
386
406
|
* @returns {JSX.Element} The CampProvider component
|
|
387
407
|
*/
|
|
388
|
-
declare const CampProvider: ({ clientId, redirectUri, children,
|
|
408
|
+
declare const CampProvider: ({ clientId, redirectUri, children, environment, }: {
|
|
389
409
|
clientId: string;
|
|
390
410
|
redirectUri?: string;
|
|
391
411
|
children: React.ReactNode;
|
|
392
412
|
allowAnalytics?: boolean;
|
|
413
|
+
environment?: "DEVELOPMENT" | "PRODUCTION";
|
|
393
414
|
}) => React.JSX.Element;
|
|
394
415
|
|
|
395
416
|
interface ModalContextProps {
|
|
@@ -407,6 +428,8 @@ declare const ModalContext: React.Context<ModalContextProps>;
|
|
|
407
428
|
interface Provider {
|
|
408
429
|
info: {
|
|
409
430
|
uuid: string;
|
|
431
|
+
name?: string;
|
|
432
|
+
icon?: string;
|
|
410
433
|
};
|
|
411
434
|
provider: any;
|
|
412
435
|
}
|