@campnetwork/origin 1.0.0-alpha.3 → 1.0.0-alpha.4
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.cjs +4 -4
- package/dist/core.esm.js +2 -2
- package/dist/react/index.esm.js +2 -1
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -73,7 +73,7 @@ let y=null,c=null;const h=()=>(c||(c=t.createPublicClient({chain:l,transport:t.h
|
|
|
73
73
|
* Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
|
|
74
74
|
* @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
|
|
75
75
|
* @returns The address of the royalty vault associated with the specified token owner.
|
|
76
|
-
*/function S(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getOrCreateRoyaltyVault",[e])}
|
|
76
|
+
*/function S(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getOrCreateRoyaltyVault",[e],{waitForReceipt:!0})}
|
|
77
77
|
/**
|
|
78
78
|
* Returns the license terms associated with a specific token ID.
|
|
79
79
|
* @param tokenId The token ID to query.
|
|
@@ -104,7 +104,7 @@ let y=null,c=null;const h=()=>(c||(c=t.createPublicClient({chain:l,transport:t.h
|
|
|
104
104
|
* @param owner The address of the asset owner.
|
|
105
105
|
* @param operator The address of the operator to check.
|
|
106
106
|
* @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
|
|
107
|
-
*/function U(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"isApprovedForAll",[e,t])}function M(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"transferFrom",[e,t,n])}function B(e,t,n,i){const a=i?[e,t,n,i]:[e,t,n];return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"safeTransferFrom",a)}function
|
|
107
|
+
*/function U(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"isApprovedForAll",[e,t])}function M(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"transferFrom",[e,t,n])}function B(e,t,n,i){const a=i?[e,t,n,i]:[e,t,n];return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"safeTransferFrom",a)}function R(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"approve",[e,t])}function F(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"setApprovalForAll",[e,t])}
|
|
108
108
|
/**
|
|
109
109
|
* Buys access to a data NFT for a specified duration.
|
|
110
110
|
* @param buyer The address of the buyer.
|
|
@@ -131,7 +131,7 @@ let y=null,c=null;const h=()=>(c||(c=t.createPublicClient({chain:l,transport:t.h
|
|
|
131
131
|
* Handles the upload of files to Origin, as well as querying the user's stats
|
|
132
132
|
*/class ae{constructor(e,t,n){L.add(this),this.jwt=e,this.viemClient=n,this.environment=t,
|
|
133
133
|
// DataNFT methods
|
|
134
|
-
this.mintWithSignature=E.bind(this),this.registerIpNFT=_.bind(this),this.updateTerms=C.bind(this),this.finalizeDelete=k.bind(this),this.getOrCreateRoyaltyVault=S.bind(this),this.getTerms=D.bind(this),this.ownerOf=N.bind(this),this.balanceOf=P.bind(this),this.tokenURI=x.bind(this),this.dataStatus=O.bind(this),this.isApprovedForAll=U.bind(this),this.transferFrom=M.bind(this),this.safeTransferFrom=B.bind(this),this.approve=
|
|
134
|
+
this.mintWithSignature=E.bind(this),this.registerIpNFT=_.bind(this),this.updateTerms=C.bind(this),this.finalizeDelete=k.bind(this),this.getOrCreateRoyaltyVault=S.bind(this),this.getTerms=D.bind(this),this.ownerOf=N.bind(this),this.balanceOf=P.bind(this),this.tokenURI=x.bind(this),this.dataStatus=O.bind(this),this.isApprovedForAll=U.bind(this),this.transferFrom=M.bind(this),this.safeTransferFrom=B.bind(this),this.approve=R.bind(this),this.setApprovalForAll=F.bind(this),
|
|
135
135
|
// Marketplace methods
|
|
136
136
|
this.buyAccess=$.bind(this),this.hasAccess=H.bind(this),this.subscriptionExpiry=j.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return a(this,void 0,void 0,(function*(){let i;try{i=yield r(this,L,"m",q).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield r(this,L,"m",W).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield r(this,L,"m",W).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,r){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const a=yield this.uploadFile(e,r);if(!a||!a.key)throw new Error("Failed to upload file or get upload info.");const s=BigInt(Date.now()+6e5),o=yield this.registerIpNFT("file",s,n,t,a.key,i),{tokenId:d,signerAddress:u,creatorContentHash:p,signature:l,uri:y}=o;// 10 minutes from now
|
|
137
137
|
if(!(d&&u&&p&&void 0!==l&&y))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");const[c]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if("0x1"!==h.status)throw console.error("Minting failed:",h),new Error(`Minting failed with status: ${h.status}`);return d.toString()}))}mintSocial(e,t,n){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=BigInt(Math.floor(Date.now()/1e3)+600),a=yield this.registerIpNFT(e,i,n,t),{tokenId:r,signerAddress:s,creatorContentHash:o,signature:d,uri:u}=a;// 10 minutes from now
|
|
@@ -174,7 +174,7 @@ if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: M
|
|
|
174
174
|
* // Get royalties for specific address
|
|
175
175
|
* const royalties = await origin.getRoyalties("0x1234...");
|
|
176
176
|
* ```
|
|
177
|
-
*/getRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,L,"m",J).call(this,n);try{const n=yield this.getOrCreateRoyaltyVault(i),a=h();let r,s;if(e&&e!==t.zeroAddress){
|
|
177
|
+
*/getRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,L,"m",J).call(this,n);try{const n=yield this.getOrCreateRoyaltyVault(i);console.log("Royalty Vault Address:",n);const a=h();let r,s;if(e&&e!==t.zeroAddress){
|
|
178
178
|
// erc20 (wrapped camp)
|
|
179
179
|
const i=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],stateMutability:"view",type:"function"}];r=yield this.callContractMethod(e,i,"balanceOf",[n]);const a=yield this.callContractMethod(e,i,"decimals",[]);s=t.formatUnits(r,a)}else r=yield a.getBalance({address:n}),s=t.formatEther(r);return{royaltyVault:n,balance:r,balanceFormatted:s}}catch(e){throw new Error(`Failed to retrieve royalties for address ${i}: ${e instanceof Error?e.message:String(e)}`)}}))}
|
|
180
180
|
/**
|
package/dist/core.esm.js
CHANGED
|
@@ -236,7 +236,7 @@ let E=null,_=null;const C=()=>(_||(_=i({chain:g,transport:a()})),_);var k=[{inpu
|
|
|
236
236
|
* Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
|
|
237
237
|
* @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
|
|
238
238
|
* @returns The address of the royalty vault associated with the specified token owner.
|
|
239
|
-
*/function H(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getOrCreateRoyaltyVault",[e])}
|
|
239
|
+
*/function H(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getOrCreateRoyaltyVault",[e],{waitForReceipt:!0})}
|
|
240
240
|
/**
|
|
241
241
|
* Returns the license terms associated with a specific token ID.
|
|
242
242
|
* @param tokenId The token ID to query.
|
|
@@ -337,7 +337,7 @@ if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: M
|
|
|
337
337
|
* // Get royalties for specific address
|
|
338
338
|
* const royalties = await origin.getRoyalties("0x1234...");
|
|
339
339
|
* ```
|
|
340
|
-
*/getRoyalties(e,t){return h(this,void 0,void 0,(function*(){const n=yield m(this,ee,"m",re).call(this,t);try{const t=yield this.getOrCreateRoyaltyVault(n),i=C();let a,r;if(e&&e!==d){
|
|
340
|
+
*/getRoyalties(e,t){return h(this,void 0,void 0,(function*(){const n=yield m(this,ee,"m",re).call(this,t);try{const t=yield this.getOrCreateRoyaltyVault(n);console.log("Royalty Vault Address:",t);const i=C();let a,r;if(e&&e!==d){
|
|
341
341
|
// erc20 (wrapped camp)
|
|
342
342
|
const n=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],stateMutability:"view",type:"function"}];a=yield this.callContractMethod(e,n,"balanceOf",[t]);const i=yield this.callContractMethod(e,n,"decimals",[]);r=p(a,i)}else a=yield i.getBalance({address:t}),r=u(a);return{royaltyVault:t,balance:a,balanceFormatted:r}}catch(e){throw new Error(`Failed to retrieve royalties for address ${n}: ${e instanceof Error?e.message:String(e)}`)}}))}
|
|
343
343
|
/**
|
package/dist/react/index.esm.js
CHANGED
|
@@ -2729,7 +2729,7 @@ function finalizeDelete(tokenId) {
|
|
|
2729
2729
|
* @returns The address of the royalty vault associated with the specified token owner.
|
|
2730
2730
|
*/
|
|
2731
2731
|
function getOrCreateRoyaltyVault(tokenOwner) {
|
|
2732
|
-
return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS, this.environment.IPNFT_ABI, "getOrCreateRoyaltyVault", [tokenOwner]);
|
|
2732
|
+
return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS, this.environment.IPNFT_ABI, "getOrCreateRoyaltyVault", [tokenOwner], { waitForReceipt: true });
|
|
2733
2733
|
}
|
|
2734
2734
|
|
|
2735
2735
|
/**
|
|
@@ -3203,6 +3203,7 @@ class Origin {
|
|
|
3203
3203
|
const walletAddress = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_resolveWalletAddress).call(this, owner);
|
|
3204
3204
|
try {
|
|
3205
3205
|
const royaltyVaultAddress = yield this.getOrCreateRoyaltyVault(walletAddress);
|
|
3206
|
+
console.log("Royalty Vault Address:", royaltyVaultAddress);
|
|
3206
3207
|
const publicClient = getPublicClient();
|
|
3207
3208
|
let balance;
|
|
3208
3209
|
let balanceFormatted;
|