@campnetwork/origin 1.4.0-alpha.3 → 1.4.0-alpha.5

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.
@@ -566,20 +566,20 @@ declare function getVaultRevenueTokens(this: Origin, tokenId: bigint): Promise<A
566
566
 
567
567
  /**
568
568
  * Returns the amount of revenue claimable by a holder for a given token and revenue token.
569
- * If no holder is provided, the NFT's Token Bound Account (TBA) is used,
570
- * since RT tokens are held in the TBA by default.
569
+ * If no holder is provided, the connected wallet address is used,
570
+ * since RT tokens are sent directly to the wallet.
571
571
  *
572
572
  * @param tokenId The token ID whose vault to query.
573
573
  * @param revenueToken The ERC20 revenue token address.
574
- * @param holder Optional holder address. Defaults to the NFT's TBA.
574
+ * @param holder Optional holder address. Defaults to the connected wallet.
575
575
  * @returns The claimable amount in the revenue token's smallest unit.
576
576
  */
577
577
  declare function claimableRevenue(this: Origin, tokenId: bigint, revenueToken: Address, holder?: Address): Promise<bigint>;
578
578
 
579
579
  /**
580
580
  * Claims accumulated revenue for a token from a specific revenue token.
581
- * Executes the claim through the NFT's Token Bound Account (TBA),
582
- * since the TBA holds the Royalty Tokens.
581
+ * The connected wallet must hold Royalty Tokens for the given token.
582
+ * Revenue is sent directly to the connected wallet.
583
583
  *
584
584
  * @param tokenId The token ID whose vault to claim from.
585
585
  * @param revenueToken The ERC20 revenue token address to claim.
@@ -589,8 +589,8 @@ declare function claimRevenue(this: Origin, tokenId: bigint, revenueToken: Addre
589
589
 
590
590
  /**
591
591
  * Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
592
- * Executes the claim through the NFT's Token Bound Account (TBA),
593
- * since the TBA holds the Royalty Tokens.
592
+ * The connected wallet must hold Royalty Tokens for the given token.
593
+ * Revenue is sent directly to the connected wallet.
594
594
  *
595
595
  * @param tokenId The token ID whose vault to claim from.
596
596
  * @param revenueTokens Array of ERC20 revenue token addresses to claim.
@@ -616,11 +616,11 @@ interface RoyaltyTokenBalance {
616
616
  }
617
617
  /**
618
618
  * Gets the Royalty Token balance for a holder in a token's vault.
619
- * If no holder is provided, the NFT's Token Bound Account (TBA) is used,
620
- * since RT tokens are minted to the TBA by default.
619
+ * If no holder is provided, the connected wallet address is used,
620
+ * since RT tokens are sent directly to the wallet.
621
621
  *
622
622
  * @param tokenId The token ID whose vault to query.
623
- * @param holder Optional holder address. Defaults to the NFT's TBA.
623
+ * @param holder Optional holder address. Defaults to the connected wallet.
624
624
  * @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
625
625
  */
626
626
  declare function getRoyaltyTokenBalance(this: Origin, tokenId: bigint, holder?: Address): Promise<RoyaltyTokenBalance>;
@@ -794,7 +794,7 @@ interface MintParams {
794
794
  * creatorContentHash: "0x...",
795
795
  * uri: "ipfs://...",
796
796
  * licenseTerms: { price: 1000n, duration: 86400, royaltyBps: 500, paymentToken: zeroAddress, licenseType: 0 },
797
- * deadline: BigInt(Date.now() + 600000),
797
+ * deadline: BigInt(Math.floor(Date.now() / 1000) + 600),
798
798
  * parents: [],
799
799
  * isIP: true,
800
800
  * appId: "myApp",
@@ -821,6 +821,103 @@ declare function bulkMint(this: Origin, mints: MintParams[]): Promise<any>;
821
821
  */
822
822
  declare function bulkMintTolerant(this: Origin, mints: MintParams[]): Promise<any>;
823
823
 
824
+ interface OriginContext {
825
+ environment: {
826
+ AUTH_HUB_BASE_API: string;
827
+ };
828
+ [key: string]: any;
829
+ }
830
+ type IpfsPinningProvider = "pinata" | "infura" | "web3storage";
831
+ interface IpfsCredentials {
832
+ provider: IpfsPinningProvider;
833
+ apiKey?: string;
834
+ apiSecret?: string;
835
+ jwt?: string;
836
+ token?: string;
837
+ projectId?: string;
838
+ projectSecret?: string;
839
+ }
840
+ interface IpfsUploadConfig {
841
+ provider: IpfsPinningProvider;
842
+ pinata?: {
843
+ jwt?: string;
844
+ apiKey?: string;
845
+ apiSecret?: string;
846
+ };
847
+ infura?: {
848
+ projectId: string;
849
+ projectSecret: string;
850
+ endpoint: string;
851
+ };
852
+ web3storage?: {
853
+ token: string;
854
+ };
855
+ }
856
+ /**
857
+ * Save IPFS credentials for large file uploads.
858
+ * Users can configure their own IPFS pinning service (Pinata, Infura, or web3.storage).
859
+ * @param credentials The IPFS credentials to save.
860
+ * @throws {APIError} If saving credentials fails.
861
+ * @example
862
+ * ```typescript
863
+ * // Save Pinata credentials
864
+ * await origin.saveIpfsCredentials({
865
+ * provider: 'pinata',
866
+ * jwt: 'your-pinata-jwt-token'
867
+ * });
868
+ *
869
+ * // Save Infura credentials
870
+ * await origin.saveIpfsCredentials({
871
+ * provider: 'infura',
872
+ * projectId: 'your-project-id',
873
+ * projectSecret: 'your-project-secret'
874
+ * });
875
+ * ```
876
+ */
877
+ declare function saveIpfsCredentials(this: OriginContext, credentials: IpfsCredentials): Promise<void>;
878
+ /**
879
+ * Verify that saved IPFS credentials are valid.
880
+ * @returns Object with valid boolean and optional error message.
881
+ * @throws {APIError} If verification request fails.
882
+ */
883
+ declare function verifyIpfsCredentials(this: OriginContext): Promise<{
884
+ valid: boolean;
885
+ error?: string;
886
+ }>;
887
+ /**
888
+ * Delete saved IPFS credentials.
889
+ * @throws {APIError} If deletion fails.
890
+ */
891
+ declare function deleteIpfsCredentials(this: OriginContext): Promise<void>;
892
+ /**
893
+ * Check if user has IPFS credentials configured.
894
+ * @returns True if credentials are configured, false otherwise.
895
+ */
896
+ declare function hasIpfsCredentials(this: OriginContext): Promise<boolean>;
897
+ /**
898
+ * Get IPFS upload config for client-side uploads.
899
+ * @returns IPFS config or null if not configured.
900
+ */
901
+ declare function getIpfsUploadConfig(this: OriginContext): Promise<IpfsUploadConfig | null>;
902
+ /**
903
+ * Upload a file to user's IPFS pinning service.
904
+ * @param file The file to upload.
905
+ * @param config The IPFS upload config.
906
+ * @param progressCallback Optional progress callback with intermediate upload progress.
907
+ * @returns The IPFS CID of the uploaded file.
908
+ */
909
+ declare function uploadToUserIPFS(this: OriginContext, file: File, config: IpfsUploadConfig, progressCallback?: (percent: number) => void): Promise<string>;
910
+ /**
911
+ * Register an IPFS file with the backend after client-side upload.
912
+ * @param cid The IPFS CID of the uploaded file.
913
+ * @param fileName The original file name.
914
+ * @param fileType The file MIME type.
915
+ * @returns The registered file key.
916
+ */
917
+ declare function registerIpfsFile(this: OriginContext, cid: string, fileName: string, fileType: string): Promise<{
918
+ fileKey: string;
919
+ }>;
920
+
824
921
  interface RoyaltyInfo {
825
922
  tokenBoundAccount: Address;
826
923
  balance: bigint;
@@ -891,6 +988,13 @@ declare class Origin {
891
988
  deployVaultForExistingNFT: typeof deployVaultForExistingNFT;
892
989
  getRoyaltyTokenBalance: typeof getRoyaltyTokenBalance;
893
990
  getAppInfo: typeof getAppInfo;
991
+ saveIpfsCredentials: typeof saveIpfsCredentials;
992
+ verifyIpfsCredentials: typeof verifyIpfsCredentials;
993
+ deleteIpfsCredentials: typeof deleteIpfsCredentials;
994
+ hasIpfsCredentials: typeof hasIpfsCredentials;
995
+ getIpfsUploadConfig: typeof getIpfsUploadConfig;
996
+ uploadToUserIPFS: typeof uploadToUserIPFS;
997
+ registerIpfsFile: typeof registerIpfsFile;
894
998
  private jwt?;
895
999
  environment: Environment;
896
1000
  private viemClient?;
@@ -920,13 +1024,14 @@ declare class Origin {
920
1024
  * @param metadata The metadata associated with the file.
921
1025
  * @param license The license terms for the IpNFT.
922
1026
  * @param parents Optional parent token IDs for lineage tracking.
923
- * @param options Optional parameters including progress callback, preview image, and use asset as preview flag.
1027
+ * @param options Optional parameters including progress callback, preview image, use asset as preview flag, and forceIpfs.
924
1028
  * @returns The token ID of the minted IpNFT as a string, or null if minting failed.
925
1029
  */
926
1030
  mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
927
1031
  progressCallback?: (percent: number) => void;
928
1032
  previewImage?: File | null;
929
1033
  useAssetAsPreview?: boolean;
1034
+ forceIpfs?: boolean;
930
1035
  }): Promise<string | null>;
931
1036
  /**
932
1037
  * Mints multiple file-based IpNFTs in a single transaction using the BatchOperations contract.
@@ -950,6 +1055,7 @@ declare class Origin {
950
1055
  */
951
1056
  bulkMintFile(entries: BulkMintFileEntry[], options?: {
952
1057
  tolerant?: boolean;
1058
+ forceIpfs?: boolean;
953
1059
  progressCallback?: (progress: {
954
1060
  fileIndex: number;
955
1061
  fileCount: number;
@@ -1067,6 +1173,12 @@ declare class Origin {
1067
1173
  * ```
1068
1174
  */
1069
1175
  claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
1176
+ /**
1177
+ * Get the connected wallet address.
1178
+ * @returns {Promise<Address>} The connected wallet address.
1179
+ * @throws {WalletError} Throws if no wallet is connected.
1180
+ */
1181
+ getWalletAddress(): Promise<Address>;
1070
1182
  }
1071
1183
 
1072
1184
  interface StorageAdapter {