@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.
package/dist/core.d.ts CHANGED
@@ -716,20 +716,20 @@ declare function getVaultRevenueTokens(this: Origin, tokenId: bigint): Promise<A
716
716
 
717
717
  /**
718
718
  * Returns the amount of revenue claimable by a holder for a given token and revenue token.
719
- * If no holder is provided, the NFT's Token Bound Account (TBA) is used,
720
- * since RT tokens are held in the TBA by default.
719
+ * If no holder is provided, the connected wallet address is used,
720
+ * since RT tokens are sent directly to the wallet.
721
721
  *
722
722
  * @param tokenId The token ID whose vault to query.
723
723
  * @param revenueToken The ERC20 revenue token address.
724
- * @param holder Optional holder address. Defaults to the NFT's TBA.
724
+ * @param holder Optional holder address. Defaults to the connected wallet.
725
725
  * @returns The claimable amount in the revenue token's smallest unit.
726
726
  */
727
727
  declare function claimableRevenue(this: Origin, tokenId: bigint, revenueToken: Address, holder?: Address): Promise<bigint>;
728
728
 
729
729
  /**
730
730
  * Claims accumulated revenue for a token from a specific revenue token.
731
- * Executes the claim through the NFT's Token Bound Account (TBA),
732
- * since the TBA holds the Royalty Tokens.
731
+ * The connected wallet must hold Royalty Tokens for the given token.
732
+ * Revenue is sent directly to the connected wallet.
733
733
  *
734
734
  * @param tokenId The token ID whose vault to claim from.
735
735
  * @param revenueToken The ERC20 revenue token address to claim.
@@ -739,8 +739,8 @@ declare function claimRevenue(this: Origin, tokenId: bigint, revenueToken: Addre
739
739
 
740
740
  /**
741
741
  * Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
742
- * Executes the claim through the NFT's Token Bound Account (TBA),
743
- * since the TBA holds the Royalty Tokens.
742
+ * The connected wallet must hold Royalty Tokens for the given token.
743
+ * Revenue is sent directly to the connected wallet.
744
744
  *
745
745
  * @param tokenId The token ID whose vault to claim from.
746
746
  * @param revenueTokens Array of ERC20 revenue token addresses to claim.
@@ -766,11 +766,11 @@ interface RoyaltyTokenBalance {
766
766
  }
767
767
  /**
768
768
  * Gets the Royalty Token balance for a holder in a token's vault.
769
- * If no holder is provided, the NFT's Token Bound Account (TBA) is used,
770
- * since RT tokens are minted to the TBA by default.
769
+ * If no holder is provided, the connected wallet address is used,
770
+ * since RT tokens are sent directly to the wallet.
771
771
  *
772
772
  * @param tokenId The token ID whose vault to query.
773
- * @param holder Optional holder address. Defaults to the NFT's TBA.
773
+ * @param holder Optional holder address. Defaults to the connected wallet.
774
774
  * @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
775
775
  */
776
776
  declare function getRoyaltyTokenBalance(this: Origin, tokenId: bigint, holder?: Address): Promise<RoyaltyTokenBalance>;
@@ -962,7 +962,7 @@ interface TolerantMintResult {
962
962
  * creatorContentHash: "0x...",
963
963
  * uri: "ipfs://...",
964
964
  * licenseTerms: { price: 1000n, duration: 86400, royaltyBps: 500, paymentToken: zeroAddress, licenseType: 0 },
965
- * deadline: BigInt(Date.now() + 600000),
965
+ * deadline: BigInt(Math.floor(Date.now() / 1000) + 600),
966
966
  * parents: [],
967
967
  * isIP: true,
968
968
  * appId: "myApp",
@@ -989,6 +989,103 @@ declare function bulkMint(this: Origin, mints: MintParams[]): Promise<any>;
989
989
  */
990
990
  declare function bulkMintTolerant(this: Origin, mints: MintParams[]): Promise<any>;
991
991
 
992
+ interface OriginContext {
993
+ environment: {
994
+ AUTH_HUB_BASE_API: string;
995
+ };
996
+ [key: string]: any;
997
+ }
998
+ type IpfsPinningProvider = "pinata" | "infura" | "web3storage";
999
+ interface IpfsCredentials {
1000
+ provider: IpfsPinningProvider;
1001
+ apiKey?: string;
1002
+ apiSecret?: string;
1003
+ jwt?: string;
1004
+ token?: string;
1005
+ projectId?: string;
1006
+ projectSecret?: string;
1007
+ }
1008
+ interface IpfsUploadConfig {
1009
+ provider: IpfsPinningProvider;
1010
+ pinata?: {
1011
+ jwt?: string;
1012
+ apiKey?: string;
1013
+ apiSecret?: string;
1014
+ };
1015
+ infura?: {
1016
+ projectId: string;
1017
+ projectSecret: string;
1018
+ endpoint: string;
1019
+ };
1020
+ web3storage?: {
1021
+ token: string;
1022
+ };
1023
+ }
1024
+ /**
1025
+ * Save IPFS credentials for large file uploads.
1026
+ * Users can configure their own IPFS pinning service (Pinata, Infura, or web3.storage).
1027
+ * @param credentials The IPFS credentials to save.
1028
+ * @throws {APIError} If saving credentials fails.
1029
+ * @example
1030
+ * ```typescript
1031
+ * // Save Pinata credentials
1032
+ * await origin.saveIpfsCredentials({
1033
+ * provider: 'pinata',
1034
+ * jwt: 'your-pinata-jwt-token'
1035
+ * });
1036
+ *
1037
+ * // Save Infura credentials
1038
+ * await origin.saveIpfsCredentials({
1039
+ * provider: 'infura',
1040
+ * projectId: 'your-project-id',
1041
+ * projectSecret: 'your-project-secret'
1042
+ * });
1043
+ * ```
1044
+ */
1045
+ declare function saveIpfsCredentials(this: OriginContext, credentials: IpfsCredentials): Promise<void>;
1046
+ /**
1047
+ * Verify that saved IPFS credentials are valid.
1048
+ * @returns Object with valid boolean and optional error message.
1049
+ * @throws {APIError} If verification request fails.
1050
+ */
1051
+ declare function verifyIpfsCredentials(this: OriginContext): Promise<{
1052
+ valid: boolean;
1053
+ error?: string;
1054
+ }>;
1055
+ /**
1056
+ * Delete saved IPFS credentials.
1057
+ * @throws {APIError} If deletion fails.
1058
+ */
1059
+ declare function deleteIpfsCredentials(this: OriginContext): Promise<void>;
1060
+ /**
1061
+ * Check if user has IPFS credentials configured.
1062
+ * @returns True if credentials are configured, false otherwise.
1063
+ */
1064
+ declare function hasIpfsCredentials(this: OriginContext): Promise<boolean>;
1065
+ /**
1066
+ * Get IPFS upload config for client-side uploads.
1067
+ * @returns IPFS config or null if not configured.
1068
+ */
1069
+ declare function getIpfsUploadConfig(this: OriginContext): Promise<IpfsUploadConfig | null>;
1070
+ /**
1071
+ * Upload a file to user's IPFS pinning service.
1072
+ * @param file The file to upload.
1073
+ * @param config The IPFS upload config.
1074
+ * @param progressCallback Optional progress callback with intermediate upload progress.
1075
+ * @returns The IPFS CID of the uploaded file.
1076
+ */
1077
+ declare function uploadToUserIPFS(this: OriginContext, file: File, config: IpfsUploadConfig, progressCallback?: (percent: number) => void): Promise<string>;
1078
+ /**
1079
+ * Register an IPFS file with the backend after client-side upload.
1080
+ * @param cid The IPFS CID of the uploaded file.
1081
+ * @param fileName The original file name.
1082
+ * @param fileType The file MIME type.
1083
+ * @returns The registered file key.
1084
+ */
1085
+ declare function registerIpfsFile(this: OriginContext, cid: string, fileName: string, fileType: string): Promise<{
1086
+ fileKey: string;
1087
+ }>;
1088
+
992
1089
  interface RoyaltyInfo {
993
1090
  tokenBoundAccount: Address;
994
1091
  balance: bigint;
@@ -1059,6 +1156,13 @@ declare class Origin {
1059
1156
  deployVaultForExistingNFT: typeof deployVaultForExistingNFT;
1060
1157
  getRoyaltyTokenBalance: typeof getRoyaltyTokenBalance;
1061
1158
  getAppInfo: typeof getAppInfo;
1159
+ saveIpfsCredentials: typeof saveIpfsCredentials;
1160
+ verifyIpfsCredentials: typeof verifyIpfsCredentials;
1161
+ deleteIpfsCredentials: typeof deleteIpfsCredentials;
1162
+ hasIpfsCredentials: typeof hasIpfsCredentials;
1163
+ getIpfsUploadConfig: typeof getIpfsUploadConfig;
1164
+ uploadToUserIPFS: typeof uploadToUserIPFS;
1165
+ registerIpfsFile: typeof registerIpfsFile;
1062
1166
  private jwt?;
1063
1167
  environment: Environment;
1064
1168
  private viemClient?;
@@ -1088,13 +1192,14 @@ declare class Origin {
1088
1192
  * @param metadata The metadata associated with the file.
1089
1193
  * @param license The license terms for the IpNFT.
1090
1194
  * @param parents Optional parent token IDs for lineage tracking.
1091
- * @param options Optional parameters including progress callback, preview image, and use asset as preview flag.
1195
+ * @param options Optional parameters including progress callback, preview image, use asset as preview flag, and forceIpfs.
1092
1196
  * @returns The token ID of the minted IpNFT as a string, or null if minting failed.
1093
1197
  */
1094
1198
  mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
1095
1199
  progressCallback?: (percent: number) => void;
1096
1200
  previewImage?: File | null;
1097
1201
  useAssetAsPreview?: boolean;
1202
+ forceIpfs?: boolean;
1098
1203
  }): Promise<string | null>;
1099
1204
  /**
1100
1205
  * Mints multiple file-based IpNFTs in a single transaction using the BatchOperations contract.
@@ -1118,6 +1223,7 @@ declare class Origin {
1118
1223
  */
1119
1224
  bulkMintFile(entries: BulkMintFileEntry[], options?: {
1120
1225
  tolerant?: boolean;
1226
+ forceIpfs?: boolean;
1121
1227
  progressCallback?: (progress: {
1122
1228
  fileIndex: number;
1123
1229
  fileCount: number;
@@ -1235,6 +1341,12 @@ declare class Origin {
1235
1341
  * ```
1236
1342
  */
1237
1343
  claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
1344
+ /**
1345
+ * Get the connected wallet address.
1346
+ * @returns {Promise<Address>} The connected wallet address.
1347
+ * @throws {WalletError} Throws if no wallet is connected.
1348
+ */
1349
+ getWalletAddress(): Promise<Address>;
1238
1350
  }
1239
1351
 
1240
1352
  declare global {
@@ -716,20 +716,20 @@ declare function getVaultRevenueTokens(this: Origin, tokenId: bigint): Promise<A
716
716
 
717
717
  /**
718
718
  * Returns the amount of revenue claimable by a holder for a given token and revenue token.
719
- * If no holder is provided, the NFT's Token Bound Account (TBA) is used,
720
- * since RT tokens are held in the TBA by default.
719
+ * If no holder is provided, the connected wallet address is used,
720
+ * since RT tokens are sent directly to the wallet.
721
721
  *
722
722
  * @param tokenId The token ID whose vault to query.
723
723
  * @param revenueToken The ERC20 revenue token address.
724
- * @param holder Optional holder address. Defaults to the NFT's TBA.
724
+ * @param holder Optional holder address. Defaults to the connected wallet.
725
725
  * @returns The claimable amount in the revenue token's smallest unit.
726
726
  */
727
727
  declare function claimableRevenue(this: Origin, tokenId: bigint, revenueToken: Address, holder?: Address): Promise<bigint>;
728
728
 
729
729
  /**
730
730
  * Claims accumulated revenue for a token from a specific revenue token.
731
- * Executes the claim through the NFT's Token Bound Account (TBA),
732
- * since the TBA holds the Royalty Tokens.
731
+ * The connected wallet must hold Royalty Tokens for the given token.
732
+ * Revenue is sent directly to the connected wallet.
733
733
  *
734
734
  * @param tokenId The token ID whose vault to claim from.
735
735
  * @param revenueToken The ERC20 revenue token address to claim.
@@ -739,8 +739,8 @@ declare function claimRevenue(this: Origin, tokenId: bigint, revenueToken: Addre
739
739
 
740
740
  /**
741
741
  * Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
742
- * Executes the claim through the NFT's Token Bound Account (TBA),
743
- * since the TBA holds the Royalty Tokens.
742
+ * The connected wallet must hold Royalty Tokens for the given token.
743
+ * Revenue is sent directly to the connected wallet.
744
744
  *
745
745
  * @param tokenId The token ID whose vault to claim from.
746
746
  * @param revenueTokens Array of ERC20 revenue token addresses to claim.
@@ -766,11 +766,11 @@ interface RoyaltyTokenBalance {
766
766
  }
767
767
  /**
768
768
  * Gets the Royalty Token balance for a holder in a token's vault.
769
- * If no holder is provided, the NFT's Token Bound Account (TBA) is used,
770
- * since RT tokens are minted to the TBA by default.
769
+ * If no holder is provided, the connected wallet address is used,
770
+ * since RT tokens are sent directly to the wallet.
771
771
  *
772
772
  * @param tokenId The token ID whose vault to query.
773
- * @param holder Optional holder address. Defaults to the NFT's TBA.
773
+ * @param holder Optional holder address. Defaults to the connected wallet.
774
774
  * @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
775
775
  */
776
776
  declare function getRoyaltyTokenBalance(this: Origin, tokenId: bigint, holder?: Address): Promise<RoyaltyTokenBalance>;
@@ -962,7 +962,7 @@ interface TolerantMintResult {
962
962
  * creatorContentHash: "0x...",
963
963
  * uri: "ipfs://...",
964
964
  * licenseTerms: { price: 1000n, duration: 86400, royaltyBps: 500, paymentToken: zeroAddress, licenseType: 0 },
965
- * deadline: BigInt(Date.now() + 600000),
965
+ * deadline: BigInt(Math.floor(Date.now() / 1000) + 600),
966
966
  * parents: [],
967
967
  * isIP: true,
968
968
  * appId: "myApp",
@@ -989,6 +989,103 @@ declare function bulkMint(this: Origin, mints: MintParams[]): Promise<any>;
989
989
  */
990
990
  declare function bulkMintTolerant(this: Origin, mints: MintParams[]): Promise<any>;
991
991
 
992
+ interface OriginContext {
993
+ environment: {
994
+ AUTH_HUB_BASE_API: string;
995
+ };
996
+ [key: string]: any;
997
+ }
998
+ type IpfsPinningProvider = "pinata" | "infura" | "web3storage";
999
+ interface IpfsCredentials {
1000
+ provider: IpfsPinningProvider;
1001
+ apiKey?: string;
1002
+ apiSecret?: string;
1003
+ jwt?: string;
1004
+ token?: string;
1005
+ projectId?: string;
1006
+ projectSecret?: string;
1007
+ }
1008
+ interface IpfsUploadConfig {
1009
+ provider: IpfsPinningProvider;
1010
+ pinata?: {
1011
+ jwt?: string;
1012
+ apiKey?: string;
1013
+ apiSecret?: string;
1014
+ };
1015
+ infura?: {
1016
+ projectId: string;
1017
+ projectSecret: string;
1018
+ endpoint: string;
1019
+ };
1020
+ web3storage?: {
1021
+ token: string;
1022
+ };
1023
+ }
1024
+ /**
1025
+ * Save IPFS credentials for large file uploads.
1026
+ * Users can configure their own IPFS pinning service (Pinata, Infura, or web3.storage).
1027
+ * @param credentials The IPFS credentials to save.
1028
+ * @throws {APIError} If saving credentials fails.
1029
+ * @example
1030
+ * ```typescript
1031
+ * // Save Pinata credentials
1032
+ * await origin.saveIpfsCredentials({
1033
+ * provider: 'pinata',
1034
+ * jwt: 'your-pinata-jwt-token'
1035
+ * });
1036
+ *
1037
+ * // Save Infura credentials
1038
+ * await origin.saveIpfsCredentials({
1039
+ * provider: 'infura',
1040
+ * projectId: 'your-project-id',
1041
+ * projectSecret: 'your-project-secret'
1042
+ * });
1043
+ * ```
1044
+ */
1045
+ declare function saveIpfsCredentials(this: OriginContext, credentials: IpfsCredentials): Promise<void>;
1046
+ /**
1047
+ * Verify that saved IPFS credentials are valid.
1048
+ * @returns Object with valid boolean and optional error message.
1049
+ * @throws {APIError} If verification request fails.
1050
+ */
1051
+ declare function verifyIpfsCredentials(this: OriginContext): Promise<{
1052
+ valid: boolean;
1053
+ error?: string;
1054
+ }>;
1055
+ /**
1056
+ * Delete saved IPFS credentials.
1057
+ * @throws {APIError} If deletion fails.
1058
+ */
1059
+ declare function deleteIpfsCredentials(this: OriginContext): Promise<void>;
1060
+ /**
1061
+ * Check if user has IPFS credentials configured.
1062
+ * @returns True if credentials are configured, false otherwise.
1063
+ */
1064
+ declare function hasIpfsCredentials(this: OriginContext): Promise<boolean>;
1065
+ /**
1066
+ * Get IPFS upload config for client-side uploads.
1067
+ * @returns IPFS config or null if not configured.
1068
+ */
1069
+ declare function getIpfsUploadConfig(this: OriginContext): Promise<IpfsUploadConfig | null>;
1070
+ /**
1071
+ * Upload a file to user's IPFS pinning service.
1072
+ * @param file The file to upload.
1073
+ * @param config The IPFS upload config.
1074
+ * @param progressCallback Optional progress callback with intermediate upload progress.
1075
+ * @returns The IPFS CID of the uploaded file.
1076
+ */
1077
+ declare function uploadToUserIPFS(this: OriginContext, file: File, config: IpfsUploadConfig, progressCallback?: (percent: number) => void): Promise<string>;
1078
+ /**
1079
+ * Register an IPFS file with the backend after client-side upload.
1080
+ * @param cid The IPFS CID of the uploaded file.
1081
+ * @param fileName The original file name.
1082
+ * @param fileType The file MIME type.
1083
+ * @returns The registered file key.
1084
+ */
1085
+ declare function registerIpfsFile(this: OriginContext, cid: string, fileName: string, fileType: string): Promise<{
1086
+ fileKey: string;
1087
+ }>;
1088
+
992
1089
  interface RoyaltyInfo {
993
1090
  tokenBoundAccount: Address;
994
1091
  balance: bigint;
@@ -1059,6 +1156,13 @@ declare class Origin {
1059
1156
  deployVaultForExistingNFT: typeof deployVaultForExistingNFT;
1060
1157
  getRoyaltyTokenBalance: typeof getRoyaltyTokenBalance;
1061
1158
  getAppInfo: typeof getAppInfo;
1159
+ saveIpfsCredentials: typeof saveIpfsCredentials;
1160
+ verifyIpfsCredentials: typeof verifyIpfsCredentials;
1161
+ deleteIpfsCredentials: typeof deleteIpfsCredentials;
1162
+ hasIpfsCredentials: typeof hasIpfsCredentials;
1163
+ getIpfsUploadConfig: typeof getIpfsUploadConfig;
1164
+ uploadToUserIPFS: typeof uploadToUserIPFS;
1165
+ registerIpfsFile: typeof registerIpfsFile;
1062
1166
  private jwt?;
1063
1167
  environment: Environment;
1064
1168
  private viemClient?;
@@ -1088,13 +1192,14 @@ declare class Origin {
1088
1192
  * @param metadata The metadata associated with the file.
1089
1193
  * @param license The license terms for the IpNFT.
1090
1194
  * @param parents Optional parent token IDs for lineage tracking.
1091
- * @param options Optional parameters including progress callback, preview image, and use asset as preview flag.
1195
+ * @param options Optional parameters including progress callback, preview image, use asset as preview flag, and forceIpfs.
1092
1196
  * @returns The token ID of the minted IpNFT as a string, or null if minting failed.
1093
1197
  */
1094
1198
  mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
1095
1199
  progressCallback?: (percent: number) => void;
1096
1200
  previewImage?: File | null;
1097
1201
  useAssetAsPreview?: boolean;
1202
+ forceIpfs?: boolean;
1098
1203
  }): Promise<string | null>;
1099
1204
  /**
1100
1205
  * Mints multiple file-based IpNFTs in a single transaction using the BatchOperations contract.
@@ -1118,6 +1223,7 @@ declare class Origin {
1118
1223
  */
1119
1224
  bulkMintFile(entries: BulkMintFileEntry[], options?: {
1120
1225
  tolerant?: boolean;
1226
+ forceIpfs?: boolean;
1121
1227
  progressCallback?: (progress: {
1122
1228
  fileIndex: number;
1123
1229
  fileCount: number;
@@ -1235,6 +1341,12 @@ declare class Origin {
1235
1341
  * ```
1236
1342
  */
1237
1343
  claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
1344
+ /**
1345
+ * Get the connected wallet address.
1346
+ * @returns {Promise<Address>} The connected wallet address.
1347
+ * @throws {WalletError} Throws if no wallet is connected.
1348
+ */
1349
+ getWalletAddress(): Promise<Address>;
1238
1350
  }
1239
1351
 
1240
1352
  declare global {