@campnetwork/origin 1.0.0-alpha.0 → 1.0.0-alpha.10

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.
@@ -1,5 +1,5 @@
1
1
  import React, { JSX } from 'react';
2
- import { Address, Hex, Abi } from 'viem';
2
+ import { Address, Hex, WalletClient, Abi } from 'viem';
3
3
  import { UseQueryResult } from '@tanstack/react-query';
4
4
 
5
5
  interface Environment {
@@ -12,6 +12,7 @@ interface Environment {
12
12
  CHAIN: any;
13
13
  IPNFT_ABI?: any;
14
14
  MARKETPLACE_ABI?: any;
15
+ ROYALTY_VAULT_ABI?: any;
15
16
  }
16
17
 
17
18
  /**
@@ -66,26 +67,70 @@ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, p
66
67
  */
67
68
  declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
68
69
 
69
- declare function updateTerms(this: Origin, tokenId: bigint, royaltyReceiver: Address, newTerms: LicenseTerms): Promise<any>;
70
+ /**
71
+ * Updates the license terms of a specified IPNFT.
72
+ * @param tokenId The ID of the IPNFT to update.
73
+ * @param newTerms The new license terms to set.
74
+ * @returns A promise that resolves when the transaction is complete.
75
+ */
76
+ declare function updateTerms(this: Origin, tokenId: bigint, newTerms: LicenseTerms): Promise<any>;
70
77
 
71
- declare function requestDelete(this: Origin, tokenId: bigint): Promise<any>;
78
+ /**
79
+ * Sets the IPNFT as deleted
80
+ * @param tokenId The token ID to set as deleted.
81
+ * @returns A promise that resolves when the transaction is complete.
82
+ */
83
+ declare function finalizeDelete(this: Origin, tokenId: bigint): Promise<any>;
72
84
 
85
+ /**
86
+ * Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
87
+ * @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
88
+ * @param simulateOnly If true, simulates the transaction without executing it.
89
+ * @returns The address of the royalty vault associated with the specified token owner.
90
+ */
91
+ declare function getOrCreateRoyaltyVault(this: Origin, tokenOwner: Address, simulateOnly?: boolean): Promise<Address>;
92
+
93
+ /**
94
+ * Returns the license terms associated with a specific token ID.
95
+ * @param tokenId The token ID to query.
96
+ * @returns The license terms of the token ID.
97
+ */
73
98
  declare function getTerms(this: Origin, tokenId: bigint): Promise<any>;
74
99
 
100
+ /**
101
+ * Returns the owner of the specified IPNFT.
102
+ * @param tokenId The ID of the IPNFT to query.
103
+ * @returns The address of the owner of the IPNFT.
104
+ */
75
105
  declare function ownerOf(this: Origin, tokenId: bigint): Promise<any>;
76
106
 
107
+ /**
108
+ * Returns the number of IPNFTs owned by the given address.
109
+ * @param owner The address to query.
110
+ * @returns The number of IPNFTs owned by the address.
111
+ */
77
112
  declare function balanceOf(this: Origin, owner: Address): Promise<any>;
78
113
 
79
- declare function contentHash(this: Origin, tokenId: bigint): Promise<any>;
80
-
114
+ /**
115
+ * Returns the metadata URI associated with a specific token ID.
116
+ * @param tokenId The token ID to query.
117
+ * @returns The metadata URI of the token ID.
118
+ */
81
119
  declare function tokenURI(this: Origin, tokenId: bigint): Promise<any>;
82
120
 
121
+ /**
122
+ * Returns the data status of the given token ID.
123
+ * @param tokenId The token ID to query.
124
+ * @returns The data status of the token ID.
125
+ */
83
126
  declare function dataStatus(this: Origin, tokenId: bigint): Promise<DataStatus>;
84
127
 
85
- declare function royaltyInfo(this: Origin, tokenId: bigint, salePrice: bigint): Promise<[Address, bigint]>;
86
-
87
- declare function getApproved(this: Origin, tokenId: bigint): Promise<Address>;
88
-
128
+ /**
129
+ * Checks if an operator is approved to manage all assets of a given owner.
130
+ * @param owner The address of the asset owner.
131
+ * @param operator The address of the operator to check.
132
+ * @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
133
+ */
89
134
  declare function isApprovedForAll(this: Origin, owner: Address, operator: Address): Promise<boolean>;
90
135
 
91
136
  declare function transferFrom(this: Origin, from: Address, to: Address, tokenId: bigint): Promise<any>;
@@ -96,10 +141,24 @@ declare function approve(this: Origin, to: Address, tokenId: bigint): Promise<an
96
141
 
97
142
  declare function setApprovalForAll(this: Origin, operator: Address, approved: boolean): Promise<any>;
98
143
 
99
- declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, periods: number, value?: bigint): Promise<any>;
100
-
101
- declare function renewAccess(this: Origin, tokenId: bigint, buyer: Address, periods: number, value?: bigint): Promise<any>;
144
+ /**
145
+ * Buys access to a data NFT for a specified duration.
146
+ * @param buyer The address of the buyer.
147
+ * @param tokenId The ID of the data NFT.
148
+ * @param expectedPrice The expected price for the access.
149
+ * @param expectedDuration The expected duration of the access in seconds.
150
+ * @param expectedPaymentToken The address of the payment token (use zero address for native token).
151
+ * @param value The amount of native token to send (only required if paying with native token).
152
+ * @returns A promise that resolves when the transaction is confirmed.
153
+ */
154
+ declare function buyAccess(this: Origin, buyer: Address, tokenId: bigint, expectedPrice: bigint, expectedDuration: bigint, expectedPaymentToken: Address, value?: bigint): Promise<any>;
102
155
 
156
+ /**
157
+ * Checks if a user has access to a specific token based on subscription expiry.
158
+ * @param user - The address of the user.
159
+ * @param tokenId - The ID of the token.
160
+ * @returns A promise that resolves to a boolean indicating if the user has access.
161
+ */
103
162
  declare function hasAccess(this: Origin, user: Address, tokenId: bigint): Promise<boolean>;
104
163
 
105
164
  declare function subscriptionExpiry(this: Origin, tokenId: bigint, user: Address): Promise<bigint>;
@@ -113,10 +172,16 @@ interface OriginUsageReturnType {
113
172
  teams: Array<any>;
114
173
  dataSources: Array<any>;
115
174
  }
175
+ interface RoyaltyInfo {
176
+ royaltyVault: Address;
177
+ balance: bigint;
178
+ balanceFormatted: string;
179
+ }
116
180
  type CallOptions = {
117
181
  value?: bigint;
118
182
  gas?: bigint;
119
183
  waitForReceipt?: boolean;
184
+ simulate?: boolean;
120
185
  };
121
186
  /**
122
187
  * The Origin class
@@ -127,38 +192,35 @@ declare class Origin {
127
192
  mintWithSignature: typeof mintWithSignature;
128
193
  registerIpNFT: typeof registerIpNFT;
129
194
  updateTerms: typeof updateTerms;
130
- requestDelete: typeof requestDelete;
195
+ finalizeDelete: typeof finalizeDelete;
196
+ getOrCreateRoyaltyVault: typeof getOrCreateRoyaltyVault;
131
197
  getTerms: typeof getTerms;
132
198
  ownerOf: typeof ownerOf;
133
199
  balanceOf: typeof balanceOf;
134
- contentHash: typeof contentHash;
135
200
  tokenURI: typeof tokenURI;
136
201
  dataStatus: typeof dataStatus;
137
- royaltyInfo: typeof royaltyInfo;
138
- getApproved: typeof getApproved;
139
202
  isApprovedForAll: typeof isApprovedForAll;
140
203
  transferFrom: typeof transferFrom;
141
204
  safeTransferFrom: typeof safeTransferFrom;
142
205
  approve: typeof approve;
143
206
  setApprovalForAll: typeof setApprovalForAll;
144
207
  buyAccess: typeof buyAccess;
145
- renewAccess: typeof renewAccess;
146
208
  hasAccess: typeof hasAccess;
147
209
  subscriptionExpiry: typeof subscriptionExpiry;
148
210
  private jwt;
149
211
  environment: Environment;
150
212
  private viemClient?;
151
- constructor(jwt: string, environment: Environment, viemClient?: any);
213
+ constructor(jwt: string, environment: Environment, viemClient?: WalletClient);
152
214
  getJwt(): string;
153
- setViemClient(client: any): void;
154
- uploadFile: (file: File, options?: {
215
+ setViemClient(client: WalletClient): void;
216
+ uploadFile(file: File, options?: {
155
217
  progressCallback?: (percent: number) => void;
156
- }) => Promise<any>;
157
- mintFile: (file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
218
+ }): Promise<any>;
219
+ mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
158
220
  progressCallback?: (percent: number) => void;
159
- }) => Promise<string | null>;
160
- mintSocial: (source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms) => Promise<string | null>;
161
- getOriginUploads: () => Promise<any>;
221
+ }): Promise<string | null>;
222
+ mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
223
+ getOriginUploads(): Promise<any[] | null>;
162
224
  /**
163
225
  * Get the user's Origin stats (multiplier, consent, usage, etc.).
164
226
  * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
@@ -171,13 +233,6 @@ declare class Origin {
171
233
  * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
172
234
  */
173
235
  setOriginConsent(consent: boolean): Promise<void>;
174
- /**
175
- * Set the user's Origin multiplier.
176
- * @param {number} multiplier The user's Origin multiplier.
177
- * @returns {Promise<void>}
178
- * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the multiplier is not provided.
179
- */
180
- setOriginMultiplier(multiplier: number): Promise<void>;
181
236
  /**
182
237
  * Call a contract method.
183
238
  * @param {string} contractAddress The contract address.
@@ -192,11 +247,33 @@ declare class Origin {
192
247
  /**
193
248
  * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
194
249
  * @param {bigint} tokenId The token ID of the asset.
195
- * @param {number} periods The number of periods to buy access for.
196
250
  * @returns {Promise<any>} The result of the buyAccess call.
197
251
  */
198
- buyAccessSmart(tokenId: bigint, periods: number): Promise<any>;
252
+ buyAccessSmart(tokenId: bigint): Promise<any>;
199
253
  getData(tokenId: bigint): Promise<any>;
254
+ /**
255
+ * Get royalty information for a wallet address, including the royalty vault address and its balance.
256
+ * @param {Address} [owner] - Optional wallet address to check royalties for. If not provided, uses the connected wallet.
257
+ * @returns {Promise<RoyaltyInfo>} A promise that resolves with the royalty vault address and balance information.
258
+ * @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
259
+ * @example
260
+ * ```typescript
261
+ * // Get royalties for connected wallet
262
+ * const royalties = await origin.getRoyalties();
263
+ *
264
+ * // Get royalties for specific address
265
+ * const royalties = await origin.getRoyalties("0x1234...");
266
+ * ```
267
+ */
268
+ getRoyalties(token?: Address, owner?: Address): Promise<RoyaltyInfo>;
269
+ /**
270
+ * Claim royalties from the royalty vault.
271
+ * @param {Address} [token] - Optional token address to claim royalties in. If not provided, claims in native token.
272
+ * @param {Address} [owner] - Optional wallet address to claim royalties for. If not provided, uses the connected wallet.
273
+ * @returns {Promise<any>} A promise that resolves when the claim transaction is confirmed.
274
+ * @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
275
+ */
276
+ claimRoyalties(token?: Address, owner?: Address): Promise<any>;
200
277
  }
201
278
 
202
279
  declare global {