@campnetwork/origin 1.3.2 → 1.4.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.
@@ -10,17 +10,16 @@ interface Environment {
10
10
  MARKETPLACE_CONTRACT_ADDRESS: string;
11
11
  BATCH_OPERATIONS_CONTRACT_ADDRESS: string;
12
12
  DISPUTE_CONTRACT_ADDRESS?: string;
13
- FRACTIONALIZER_CONTRACT_ADDRESS?: string;
14
13
  APP_REGISTRY_CONTRACT_ADDRESS?: string;
15
- USDC_CONTRACT_ADDRESS: string;
14
+ IP_ROYALTY_VAULT_FACTORY_CONTRACT_ADDRESS?: string;
16
15
  CHAIN: any;
17
16
  IPNFT_ABI?: any;
18
17
  MARKETPLACE_ABI?: any;
19
18
  TBA_ABI?: any;
20
19
  BATCH_OPERATIONS_ABI?: any;
21
20
  DISPUTE_ABI?: any;
22
- FRACTIONALIZER_ABI?: any;
23
21
  APP_REGISTRY_ABI?: any;
22
+ IP_ROYALTY_VAULT_FACTORY_ABI?: any;
24
23
  }
25
24
 
26
25
  /**
@@ -161,14 +160,6 @@ declare function updateTerms(this: Origin, tokenId: bigint, newTerms: LicenseTer
161
160
  */
162
161
  declare function finalizeDelete(this: Origin, tokenId: bigint): Promise<any>;
163
162
 
164
- /**
165
- * Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
166
- * @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
167
- * @param simulateOnly If true, simulates the transaction without executing it.
168
- * @returns The address of the royalty vault associated with the specified token owner.
169
- */
170
- declare function getOrCreateRoyaltyVault(this: Origin, tokenOwner: Address, simulateOnly?: boolean): Promise<Address>;
171
-
172
163
  /**
173
164
  * Returns the license terms associated with a specific token ID.
174
165
  * @param tokenId The token ID to query.
@@ -557,182 +548,79 @@ interface DisputeRequirements {
557
548
  declare function getDisputeRequirements(this: Origin, userAddress: Address): Promise<DisputeRequirements>;
558
549
 
559
550
  /**
560
- * Fractionalizes an IP NFT into fungible ERC20 tokens.
561
- * The NFT is transferred to the fractionalizer contract and a new ERC20 token is created.
562
- * The caller receives the full supply of fractional tokens.
563
- *
564
- * @param tokenId The token ID of the IP NFT to fractionalize.
565
- * @returns A promise that resolves with the transaction result.
566
- *
567
- * @example
568
- * ```typescript
569
- * // First approve the fractionalizer contract to transfer your NFT
570
- * await origin.approve(fractionalizerAddress, tokenId);
551
+ * Gets the royalty vault address for a given token ID.
552
+ * Returns null if no vault has been deployed yet.
571
553
  *
572
- * // Then fractionalize
573
- * const result = await origin.fractionalize(1n);
574
- * ```
554
+ * @param tokenId The token ID to look up.
555
+ * @returns The vault address, or null if no vault exists.
575
556
  */
576
- declare function fractionalize(this: Origin, tokenId: bigint): Promise<any>;
557
+ declare function getRoyaltyVault(this: Origin, tokenId: bigint): Promise<Address | null>;
577
558
 
578
559
  /**
579
- * Redeems an IP NFT by burning all of its fractional tokens.
580
- * The caller must hold the entire supply of the NFT's fractional token.
581
- * After redemption, the NFT is transferred back to the caller.
582
- *
583
- * @param tokenId The token ID of the IP NFT to redeem.
584
- * @returns A promise that resolves with the transaction result.
560
+ * Gets the list of revenue token addresses that have accumulated in a token's vault.
585
561
  *
586
- * @example
587
- * ```typescript
588
- * // Requires holding 100% of the fractional token supply
589
- * await origin.redeem(1n);
590
- * ```
562
+ * @param tokenId The token ID to look up.
563
+ * @returns An array of ERC20 token addresses with revenue in the vault.
591
564
  */
592
- declare function redeem(this: Origin, tokenId: bigint): Promise<any>;
565
+ declare function getVaultRevenueTokens(this: Origin, tokenId: bigint): Promise<Address[]>;
593
566
 
594
567
  /**
595
- * Gets the fractional ERC20 token address for a specific IP NFT.
596
- * Returns zero address if the NFT has not been fractionalized.
597
- *
598
- * @param tokenId The token ID of the IP NFT.
599
- * @returns A promise that resolves with the fractional token address.
568
+ * Returns the amount of revenue claimable by a holder for a given token and revenue token.
569
+ * If no holder is provided, the connected wallet address is used.
600
570
  *
601
- * @example
602
- * ```typescript
603
- * const fractionalToken = await origin.getTokenForNFT(1n);
604
- * if (fractionalToken !== zeroAddress) {
605
- * console.log(`Fractional token: ${fractionalToken}`);
606
- * } else {
607
- * console.log("NFT has not been fractionalized");
608
- * }
609
- * ```
571
+ * @param tokenId The token ID whose vault to query.
572
+ * @param revenueToken The ERC20 revenue token address.
573
+ * @param holder Optional holder address. Defaults to connected wallet.
574
+ * @returns The claimable amount in the revenue token's smallest unit.
610
575
  */
611
- declare function getTokenForNFT(this: Origin, tokenId: bigint): Promise<Address>;
576
+ declare function claimableRevenue(this: Origin, tokenId: bigint, revenueToken: Address, holder?: Address): Promise<bigint>;
612
577
 
613
578
  /**
614
- * Fractionalizes an IP NFT with automatic approval.
615
- * This method first approves the fractionalizer contract to transfer your NFT,
616
- * then calls fractionalize. This is the recommended method for most use cases.
617
- *
618
- * @param tokenId The token ID of the IP NFT to fractionalize.
619
- * @returns A promise that resolves with the transaction result.
579
+ * Claims accumulated revenue for a token from a specific revenue token.
580
+ * The caller must hold Royalty Tokens to claim their proportional share.
620
581
  *
621
- * @example
622
- * ```typescript
623
- * // Single call handles approval and fractionalization
624
- * const result = await origin.fractionalizeWithApproval(1n);
625
- * ```
582
+ * @param tokenId The token ID whose vault to claim from.
583
+ * @param revenueToken The ERC20 revenue token address to claim.
584
+ * @returns The transaction result.
626
585
  */
627
- declare function fractionalizeWithApproval(this: Origin, tokenId: bigint): Promise<any>;
586
+ declare function claimRevenue(this: Origin, tokenId: bigint, revenueToken: Address): Promise<any>;
628
587
 
629
588
  /**
630
- * Redeems fractional tokens for the underlying NFT, but only if the caller owns 100% of the supply.
631
- * This method checks the caller's balance before attempting to redeem, providing a clear error
632
- * if they don't hold the full supply.
589
+ * Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
590
+ * The caller must hold Royalty Tokens to claim their proportional share.
633
591
  *
634
- * @param tokenId The token ID of the original NFT to redeem.
635
- * @returns A promise that resolves with the transaction result.
636
- * @throws Error if the caller doesn't own 100% of the fractional tokens.
637
- *
638
- * @example
639
- * ```typescript
640
- * try {
641
- * const result = await origin.redeemIfComplete(1n);
642
- * console.log("NFT redeemed successfully!");
643
- * } catch (error) {
644
- * console.log("You don't own all fractional tokens yet");
645
- * }
646
- * ```
592
+ * @param tokenId The token ID whose vault to claim from.
593
+ * @param revenueTokens Array of ERC20 revenue token addresses to claim.
594
+ * @returns The transaction result.
647
595
  */
648
- declare function redeemIfComplete(this: Origin, tokenId: bigint): Promise<any>;
596
+ declare function claimRevenueBatch(this: Origin, tokenId: bigint, revenueTokens: Address[]): Promise<any>;
649
597
 
650
598
  /**
651
- * Ownership information for fractional tokens.
599
+ * Deploys a new royalty vault for an existing NFT that was minted before the vault system.
600
+ * This is used to migrate old NFTs to the new royalty vault system.
601
+ *
602
+ * @param tokenId The token ID to deploy a vault for.
603
+ * @returns The transaction result including the new vault address.
652
604
  */
653
- interface FractionOwnership {
654
- tokenId: bigint;
655
- /** The ERC20 token address (zero if not fractionalized) */
656
- erc20Address: Address;
657
- isFractionalized: boolean;
658
- /** User's balance of fractional tokens */
605
+ declare function deployVaultForExistingNFT(this: Origin, tokenId: bigint): Promise<any>;
606
+
607
+ interface RoyaltyTokenBalance {
608
+ vaultAddress: Address;
659
609
  balance: bigint;
660
- /** Total supply of fractional tokens */
661
610
  totalSupply: bigint;
662
- /** User's ownership percentage (0-100) */
663
- ownershipPercentage: number;
664
- /** Whether user owns 100% and can redeem */
665
- canRedeem: boolean;
611
+ percentage: number;
666
612
  decimals: number;
667
613
  }
668
614
  /**
669
- * Gets a user's ownership percentage of a fractionalized NFT.
670
- * Returns detailed information about the user's fractional token holdings.
671
- *
672
- * @param tokenId The token ID of the original NFT.
673
- * @param owner Optional address to check. If not provided, uses connected wallet.
674
- * @returns A promise that resolves with the ownership details.
675
- *
676
- * @example
677
- * ```typescript
678
- * const ownership = await origin.getFractionOwnership(1n);
679
- *
680
- * if (!ownership.isFractionalized) {
681
- * console.log("This NFT has not been fractionalized");
682
- * } else {
683
- * console.log(`You own ${ownership.ownershipPercentage}% of this NFT`);
684
- * console.log(`Balance: ${ownership.balance} / ${ownership.totalSupply}`);
685
- *
686
- * if (ownership.canRedeem) {
687
- * console.log("You can redeem the original NFT!");
688
- * await origin.redeem(1n);
689
- * }
690
- * }
691
- * ```
692
- */
693
- declare function getFractionOwnership(this: Origin, tokenId: bigint, owner?: Address): Promise<FractionOwnership>;
694
-
695
- /**
696
- * Result of checking if a user can fractionalize an NFT.
697
- */
698
- interface FractionalizeEligibility {
699
- canFractionalize: boolean;
700
- /** Reason why user cannot fractionalize (if canFractionalize is false) */
701
- reason?: string;
702
- isOwner: boolean;
703
- currentOwner: Address;
704
- isAlreadyFractionalized: boolean;
705
- /** ERC20 address if already fractionalized */
706
- existingErc20Address?: Address;
707
- dataStatus: DataStatus;
708
- isApproved: boolean;
709
- needsApproval: boolean;
710
- }
711
- /**
712
- * Checks if a user can fractionalize an NFT and why not if they can't.
713
- * Returns detailed information about eligibility requirements.
615
+ * Gets the Royalty Token balance for a holder in a token's vault.
616
+ * If no holder is provided, the NFT's Token Bound Account (TBA) is used,
617
+ * since RT tokens are minted to the TBA by default.
714
618
  *
715
- * @param tokenId The token ID of the NFT to check.
716
- * @param owner Optional address to check. If not provided, uses connected wallet.
717
- * @returns A promise that resolves with the fractionalize eligibility details.
718
- *
719
- * @example
720
- * ```typescript
721
- * const eligibility = await origin.canFractionalize(1n);
722
- *
723
- * if (eligibility.canFractionalize) {
724
- * if (eligibility.needsApproval) {
725
- * // Use fractionalizeWithApproval for convenience
726
- * await origin.fractionalizeWithApproval(1n);
727
- * } else {
728
- * await origin.fractionalize(1n);
729
- * }
730
- * } else {
731
- * console.log(`Cannot fractionalize: ${eligibility.reason}`);
732
- * }
733
- * ```
619
+ * @param tokenId The token ID whose vault to query.
620
+ * @param holder Optional holder address. Defaults to the NFT's TBA.
621
+ * @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
734
622
  */
735
- declare function canFractionalize(this: Origin, tokenId: bigint, owner?: Address): Promise<FractionalizeEligibility>;
623
+ declare function getRoyaltyTokenBalance(this: Origin, tokenId: bigint, holder?: Address): Promise<RoyaltyTokenBalance>;
736
624
 
737
625
  /**
738
626
  * Gets information about a registered app from the AppRegistry.
@@ -959,7 +847,6 @@ declare class Origin {
959
847
  registerIpNFT: typeof registerIpNFT;
960
848
  updateTerms: typeof updateTerms;
961
849
  finalizeDelete: typeof finalizeDelete;
962
- getOrCreateRoyaltyVault: typeof getOrCreateRoyaltyVault;
963
850
  getTerms: typeof getTerms;
964
851
  ownerOf: typeof ownerOf;
965
852
  balanceOf: typeof balanceOf;
@@ -993,13 +880,13 @@ declare class Origin {
993
880
  canVoteOnDispute: typeof canVoteOnDispute;
994
881
  getDisputeProgress: typeof getDisputeProgress;
995
882
  getDisputeRequirements: typeof getDisputeRequirements;
996
- fractionalize: typeof fractionalize;
997
- redeem: typeof redeem;
998
- getTokenForNFT: typeof getTokenForNFT;
999
- fractionalizeWithApproval: typeof fractionalizeWithApproval;
1000
- redeemIfComplete: typeof redeemIfComplete;
1001
- getFractionOwnership: typeof getFractionOwnership;
1002
- canFractionalize: typeof canFractionalize;
883
+ getRoyaltyVault: typeof getRoyaltyVault;
884
+ getVaultRevenueTokens: typeof getVaultRevenueTokens;
885
+ claimableRevenue: typeof claimableRevenue;
886
+ claimRevenue: typeof claimRevenue;
887
+ claimRevenueBatch: typeof claimRevenueBatch;
888
+ deployVaultForExistingNFT: typeof deployVaultForExistingNFT;
889
+ getRoyaltyTokenBalance: typeof getRoyaltyTokenBalance;
1003
890
  getAppInfo: typeof getAppInfo;
1004
891
  private jwt?;
1005
892
  environment: Environment;