@campnetwork/origin 1.2.0-3 → 1.2.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.
@@ -51,6 +51,7 @@ type IpNFTSource = "spotify" | "twitter" | "tiktok" | "file";
51
51
  * @param to The address to mint the NFT to.
52
52
  * @param tokenId The ID of the token to mint.
53
53
  * @param parents The IDs of the parent NFTs, if applicable.
54
+ * @param isIp Whether the NFT is an IP NFT.
54
55
  * @param hash The hash of the data associated with the NFT.
55
56
  * @param uri The URI of the NFT metadata.
56
57
  * @param licenseTerms The terms of the license for the NFT.
@@ -63,7 +64,10 @@ declare function mintWithSignature(this: Origin, to: Address, tokenId: bigint, p
63
64
  * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
64
65
  * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
65
66
  * @param deadline The deadline for the registration operation.
66
- * @param fileKey Optional file key for file uploads.
67
+ * @param licenseTerms The terms of the license for the NFT.
68
+ * @param metadata The metadata associated with the NFT.
69
+ * @param fileKey The file key(s) if the source is "file".
70
+ * @param parents The IDs of the parent NFTs, if applicable.
67
71
  * @return A promise that resolves with the registration data.
68
72
  */
69
73
  declare function registerIpNFT(this: Origin, source: IpNFTSource, deadline: bigint, licenseTerms: LicenseTerms, metadata: Record<string, unknown>, fileKey?: string | string[], parents?: bigint[]): Promise<any>;
@@ -211,7 +215,8 @@ declare class Origin {
211
215
  private jwt;
212
216
  environment: Environment;
213
217
  private viemClient?;
214
- constructor(jwt: string, environment: Environment, viemClient?: WalletClient);
218
+ baseParentId?: bigint;
219
+ constructor(jwt: string, environment: Environment, viemClient?: WalletClient, baseParentId?: bigint);
215
220
  getJwt(): string;
216
221
  setViemClient(client: WalletClient): void;
217
222
  uploadFile(file: File, options?: {
@@ -326,6 +331,7 @@ declare class Auth {
326
331
  viem: any;
327
332
  origin: Origin | null;
328
333
  environment: Environment;
334
+ baseParentId?: bigint;
329
335
  /**
330
336
  * Constructor for the Auth class.
331
337
  * @param {object} options The options object.
@@ -335,10 +341,11 @@ declare class Auth {
335
341
  * @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
336
342
  * @throws {APIError} - Throws an error if the clientId is not provided.
337
343
  */
338
- constructor({ clientId, redirectUri, environment, storage, }: {
344
+ constructor({ clientId, redirectUri, environment, baseParentId, storage, }: {
339
345
  clientId: string;
340
346
  redirectUri: string | Record<string, string>;
341
347
  environment?: "DEVELOPMENT" | "PRODUCTION";
348
+ baseParentId?: bigint;
342
349
  storage?: StorageAdapter;
343
350
  });
344
351
  /**
@@ -539,15 +546,16 @@ declare const CampContext: React.Context<CampContextType>;
539
546
  * @param {string} props.clientId The Camp client ID
540
547
  * @param {string} props.redirectUri The redirect URI to use after social oauths
541
548
  * @param {React.ReactNode} props.children The children components
542
- * @param {boolean} props.allowAnalytics Whether to allow analytics to be sent
549
+ * @param {string | bigint} props.baseParentId The base parent ID to use for minted NFTs
550
+ * @param {string} props.environment The environment to use ("DEVELOPMENT" or "PRODUCTION")
543
551
  * @returns {JSX.Element} The CampProvider component
544
552
  */
545
- declare const CampProvider: ({ clientId, redirectUri, children, environment, }: {
553
+ declare const CampProvider: ({ clientId, redirectUri, children, environment, baseParentId, }: {
546
554
  clientId: string;
547
555
  redirectUri?: string;
548
556
  children: React.ReactNode;
549
- allowAnalytics?: boolean;
550
557
  environment?: "DEVELOPMENT" | "PRODUCTION";
558
+ baseParentId?: string | bigint;
551
559
  }) => React.JSX.Element;
552
560
 
553
561
  interface ModalContextProps {
@@ -3241,7 +3241,7 @@ const validateDuration = (duration, licenseDurationUnit) => {
3241
3241
  const validateRoyaltyBps = (royaltyBps) => {
3242
3242
  if (royaltyBps && royaltyBps.trim() !== "") {
3243
3243
  const bps = Math.floor(parseFloat(royaltyBps) * 100);
3244
- return (bps >= constants.MIN_ROYALTY_BPS && bps <= constants.MAX_ROYALTY_BPS);
3244
+ return bps >= constants.MIN_ROYALTY_BPS && bps <= constants.MAX_ROYALTY_BPS;
3245
3245
  }
3246
3246
  else {
3247
3247
  return false;
@@ -3253,6 +3253,7 @@ const validateRoyaltyBps = (royaltyBps) => {
3253
3253
  * @param to The address to mint the NFT to.
3254
3254
  * @param tokenId The ID of the token to mint.
3255
3255
  * @param parents The IDs of the parent NFTs, if applicable.
3256
+ * @param isIp Whether the NFT is an IP NFT.
3256
3257
  * @param hash The hash of the data associated with the NFT.
3257
3258
  * @param uri The URI of the NFT metadata.
3258
3259
  * @param licenseTerms The terms of the license for the NFT.
@@ -3269,7 +3270,10 @@ function mintWithSignature(to, tokenId, parents, isIp, hash, uri, licenseTerms,
3269
3270
  * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
3270
3271
  * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
3271
3272
  * @param deadline The deadline for the registration operation.
3272
- * @param fileKey Optional file key for file uploads.
3273
+ * @param licenseTerms The terms of the license for the NFT.
3274
+ * @param metadata The metadata associated with the NFT.
3275
+ * @param fileKey The file key(s) if the source is "file".
3276
+ * @param parents The IDs of the parent NFTs, if applicable.
3273
3277
  * @return A promise that resolves with the registration data.
3274
3278
  */
3275
3279
  function registerIpNFT(source, deadline, licenseTerms, metadata, fileKey, parents) {
@@ -3524,11 +3528,12 @@ var _Origin_instances, _Origin_generateURL, _Origin_setOriginStatus, _Origin_wai
3524
3528
  * Handles the upload of files to Origin, as well as querying the user's stats
3525
3529
  */
3526
3530
  class Origin {
3527
- constructor(jwt, environment, viemClient) {
3531
+ constructor(jwt, environment, viemClient, baseParentId) {
3528
3532
  _Origin_instances.add(this);
3529
3533
  this.jwt = jwt;
3530
3534
  this.viemClient = viemClient;
3531
3535
  this.environment = environment;
3536
+ this.baseParentId = baseParentId;
3532
3537
  // DataNFT methods
3533
3538
  this.mintWithSignature = mintWithSignature.bind(this);
3534
3539
  this.registerIpNFT = registerIpNFT.bind(this);
@@ -3614,6 +3619,12 @@ class Origin {
3614
3619
  metadata.mimetype = file.type;
3615
3620
  }
3616
3621
  const deadline = BigInt(Date.now() + 600000); // 10 minutes from now
3622
+ if (this.baseParentId) {
3623
+ if (!parents) {
3624
+ parents = [];
3625
+ }
3626
+ parents.unshift(this.baseParentId);
3627
+ }
3617
3628
  let registration;
3618
3629
  try {
3619
3630
  registration = yield this.registerIpNFT("file", deadline, license, metadata, info.key, parents);
@@ -3655,9 +3666,10 @@ class Origin {
3655
3666
  }
3656
3667
  metadata.mimetype = `social/${source}`;
3657
3668
  const deadline = BigInt(Math.floor(Date.now() / 1000) + 600); // 10 minutes from now
3669
+ let parents = this.baseParentId ? [this.baseParentId] : [];
3658
3670
  let registration;
3659
3671
  try {
3660
- registration = yield this.registerIpNFT(source, deadline, license, metadata);
3672
+ registration = yield this.registerIpNFT(source, deadline, license, metadata, undefined, parents);
3661
3673
  }
3662
3674
  catch (error) {
3663
3675
  throw new Error(`Failed to register Social IpNFT: ${error instanceof Error ? error.message : String(error)}`);
@@ -3671,7 +3683,7 @@ class Origin {
3671
3683
  throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");
3672
3684
  }
3673
3685
  try {
3674
- const mintResult = yield this.mintWithSignature(account, tokenId, [], true, creatorContentHash, uri, license, deadline, signature);
3686
+ const mintResult = yield this.mintWithSignature(account, tokenId, parents, true, creatorContentHash, uri, license, deadline, signature);
3675
3687
  if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
3676
3688
  throw new Error(`Minting Social IpNFT failed with status: ${mintResult.receipt.status}`);
3677
3689
  }
@@ -4436,7 +4448,7 @@ class Auth {
4436
4448
  * @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
4437
4449
  * @throws {APIError} - Throws an error if the clientId is not provided.
4438
4450
  */
4439
- constructor({ clientId, redirectUri, environment = "DEVELOPMENT", storage, }) {
4451
+ constructor({ clientId, redirectUri, environment = "DEVELOPMENT", baseParentId, storage, }) {
4440
4452
  _Auth_instances.add(this);
4441
4453
  _Auth_triggers.set(this, void 0);
4442
4454
  _Auth_isNodeEnvironment.set(this, void 0);
@@ -4453,6 +4465,7 @@ class Auth {
4453
4465
  (__classPrivateFieldGet(this, _Auth_isNodeEnvironment, "f") ? new MemoryStorage() : new BrowserStorage()), "f");
4454
4466
  this.viem = null;
4455
4467
  this.environment = ENVIRONMENTS[environment];
4468
+ this.baseParentId = baseParentId;
4456
4469
  this.redirectUri = createRedirectUriObject(redirectUri);
4457
4470
  this.clientId = clientId;
4458
4471
  this.isAuthenticated = false;
@@ -4683,7 +4696,7 @@ class Auth {
4683
4696
  this.isAuthenticated = true;
4684
4697
  this.userId = res.userId;
4685
4698
  this.jwt = res.token;
4686
- this.origin = new Origin(this.jwt, this.environment, this.viem);
4699
+ this.origin = new Origin(this.jwt, this.environment, this.viem, this.baseParentId);
4687
4700
  yield __classPrivateFieldGet(this, _Auth_storage, "f").setItem("camp-sdk:jwt", this.jwt);
4688
4701
  yield __classPrivateFieldGet(this, _Auth_storage, "f").setItem("camp-sdk:wallet-address", this.walletAddress);
4689
4702
  yield __classPrivateFieldGet(this, _Auth_storage, "f").setItem("camp-sdk:user-id", this.userId);
@@ -4745,7 +4758,7 @@ class Auth {
4745
4758
  this.isAuthenticated = true;
4746
4759
  this.userId = res.userId;
4747
4760
  this.jwt = res.token;
4748
- this.origin = new Origin(this.jwt, this.environment, this.viem);
4761
+ this.origin = new Origin(this.jwt, this.environment, this.viem, this.baseParentId);
4749
4762
  yield __classPrivateFieldGet(this, _Auth_storage, "f").setItem("camp-sdk:jwt", this.jwt);
4750
4763
  yield __classPrivateFieldGet(this, _Auth_storage, "f").setItem("camp-sdk:wallet-address", this.walletAddress);
4751
4764
  yield __classPrivateFieldGet(this, _Auth_storage, "f").setItem("camp-sdk:user-id", this.userId);
@@ -5134,7 +5147,7 @@ _Auth_triggers = new WeakMap(), _Auth_isNodeEnvironment = new WeakMap(), _Auth_s
5134
5147
  this.walletAddress = walletAddress;
5135
5148
  this.userId = userId;
5136
5149
  this.jwt = jwt;
5137
- this.origin = new Origin(this.jwt, this.environment);
5150
+ this.origin = new Origin(this.jwt, this.environment, this.viem, this.baseParentId);
5138
5151
  this.isAuthenticated = true;
5139
5152
  if (provider) {
5140
5153
  this.setProvider({
@@ -5656,11 +5669,13 @@ const CampContext = createContext({
5656
5669
  * @param {string} props.clientId The Camp client ID
5657
5670
  * @param {string} props.redirectUri The redirect URI to use after social oauths
5658
5671
  * @param {React.ReactNode} props.children The children components
5659
- * @param {boolean} props.allowAnalytics Whether to allow analytics to be sent
5672
+ * @param {string | bigint} props.baseParentId The base parent ID to use for minted NFTs
5673
+ * @param {string} props.environment The environment to use ("DEVELOPMENT" or "PRODUCTION")
5660
5674
  * @returns {JSX.Element} The CampProvider component
5661
5675
  */
5662
- const CampProvider = ({ clientId, redirectUri, children, environment = "DEVELOPMENT", }) => {
5676
+ const CampProvider = ({ clientId, redirectUri, children, environment = "DEVELOPMENT", baseParentId, }) => {
5663
5677
  const isServer = typeof window === "undefined";
5678
+ const normalizedBaseParentId = typeof baseParentId === "string" ? BigInt(baseParentId) : baseParentId;
5664
5679
  const [auth, setAuth] = useState(!isServer
5665
5680
  ? new Auth({
5666
5681
  clientId,
@@ -5670,6 +5685,7 @@ const CampProvider = ({ clientId, redirectUri, children, environment = "DEVELOPM
5670
5685
  ? window.location.href
5671
5686
  : "",
5672
5687
  environment: environment,
5688
+ baseParentId: normalizedBaseParentId,
5673
5689
  })
5674
5690
  : null);
5675
5691
  const wagmiContext = typeof window !== "undefined" ? useContext(WagmiContext) : undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campnetwork/origin",
3
- "version": "1.2.0-3",
3
+ "version": "1.2.0",
4
4
  "main": "dist/core.cjs",
5
5
  "exports": {
6
6
  ".": {