@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.
- package/README.md +43 -64
- package/dist/core.cjs +174 -266
- package/dist/core.d.ts +55 -168
- package/dist/core.esm.d.ts +55 -168
- package/dist/core.esm.js +190 -282
- package/dist/react/index.esm.d.ts +54 -167
- package/dist/react/index.esm.js +3120 -2804
- package/package.json +1 -1
|
@@ -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
|
-
|
|
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
|
-
*
|
|
561
|
-
*
|
|
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
|
-
*
|
|
573
|
-
*
|
|
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
|
|
557
|
+
declare function getRoyaltyVault(this: Origin, tokenId: bigint): Promise<Address | null>;
|
|
577
558
|
|
|
578
559
|
/**
|
|
579
|
-
*
|
|
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
|
-
* @
|
|
587
|
-
*
|
|
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
|
|
565
|
+
declare function getVaultRevenueTokens(this: Origin, tokenId: bigint): Promise<Address[]>;
|
|
593
566
|
|
|
594
567
|
/**
|
|
595
|
-
*
|
|
596
|
-
*
|
|
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
|
-
* @
|
|
602
|
-
*
|
|
603
|
-
*
|
|
604
|
-
*
|
|
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
|
|
576
|
+
declare function claimableRevenue(this: Origin, tokenId: bigint, revenueToken: Address, holder?: Address): Promise<bigint>;
|
|
612
577
|
|
|
613
578
|
/**
|
|
614
|
-
*
|
|
615
|
-
*
|
|
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
|
-
* @
|
|
622
|
-
*
|
|
623
|
-
*
|
|
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
|
|
586
|
+
declare function claimRevenue(this: Origin, tokenId: bigint, revenueToken: Address): Promise<any>;
|
|
628
587
|
|
|
629
588
|
/**
|
|
630
|
-
*
|
|
631
|
-
*
|
|
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
|
|
635
|
-
* @
|
|
636
|
-
* @
|
|
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
|
|
596
|
+
declare function claimRevenueBatch(this: Origin, tokenId: bigint, revenueTokens: Address[]): Promise<any>;
|
|
649
597
|
|
|
650
598
|
/**
|
|
651
|
-
*
|
|
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
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
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
|
-
|
|
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
|
|
670
|
-
*
|
|
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
|
|
716
|
-
* @param
|
|
717
|
-
* @returns
|
|
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
|
|
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
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
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;
|