@campnetwork/origin 1.0.0-alpha.12 → 1.0.0-alpha.13
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 +2 -2
- package/dist/core.esm.js +2 -2
- package/dist/react/index.esm.js +3 -3
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -135,8 +135,8 @@ let y=null,c=null,h=null;const m=e=>{var n;const i=h||l;return c&&(null===(n=c.c
|
|
|
135
135
|
this.mintWithSignature=_.bind(this),this.registerIpNFT=C.bind(this),this.updateTerms=k.bind(this),this.finalizeDelete=S.bind(this),this.getOrCreateRoyaltyVault=D.bind(this),this.getTerms=N.bind(this),this.ownerOf=P.bind(this),this.balanceOf=x.bind(this),this.tokenURI=O.bind(this),this.dataStatus=U.bind(this),this.isApprovedForAll=M.bind(this),this.transferFrom=B.bind(this),this.safeTransferFrom=R.bind(this),this.approve=F.bind(this),this.setApprovalForAll=$.bind(this),
|
|
136
136
|
// Marketplace methods
|
|
137
137
|
this.buyAccess=H.bind(this),this.hasAccess=j.bind(this),this.subscriptionExpiry=L.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,q,"m",W).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,q,"m",z).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,q,"m",z).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
|
|
138
|
-
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:[]}))[0],h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if("0x1"
|
|
139
|
-
if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const p=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],l=yield this.mintWithSignature(p,r,[],o,u,n,i,d);if("0x1"
|
|
138
|
+
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:[]}))[0],h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if(-1===["0x1","success"].indexOf(h.receipt.status))throw console.error("Minting failed:",h),new Error(`Minting failed with status: ${h.receipt.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
|
|
139
|
+
if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const p=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],l=yield this.mintWithSignature(p,r,[],o,u,n,i,d);if(-1===["0x1","success"].indexOf(l.status))throw new Error(`Minting Social IpNFT failed with status: ${l.status}`);return r.toString()}))}getOriginUploads(){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
|
|
140
140
|
/**
|
|
141
141
|
* Get the user's Origin stats (multiplier, consent, usage, etc.).
|
|
142
142
|
* @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
|
package/dist/core.esm.js
CHANGED
|
@@ -298,8 +298,8 @@ let g=null,E=null,_=null;const C=e=>{var t;const n=_||b;return E&&(null===(t=E.c
|
|
|
298
298
|
this.mintWithSignature=B.bind(this),this.registerIpNFT=R.bind(this),this.updateTerms=F.bind(this),this.finalizeDelete=$.bind(this),this.getOrCreateRoyaltyVault=H.bind(this),this.getTerms=j.bind(this),this.ownerOf=L.bind(this),this.balanceOf=W.bind(this),this.tokenURI=q.bind(this),this.dataStatus=z.bind(this),this.isApprovedForAll=K.bind(this),this.transferFrom=J.bind(this),this.safeTransferFrom=V.bind(this),this.approve=G.bind(this),this.setApprovalForAll=Y.bind(this),
|
|
299
299
|
// Marketplace methods
|
|
300
300
|
this.buyAccess=X.bind(this),this.hasAccess=Z.bind(this),this.subscriptionExpiry=Q.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return c(this,void 0,void 0,(function*(){let i;try{i=yield h(this,ee,"m",te).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 h(this,ee,"m",ne).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 h(this,ee,"m",ne).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,a){return c(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const r=yield this.uploadFile(e,a);if(!r||!r.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,r.key,i),{tokenId:d,signerAddress:u,creatorContentHash:p,signature:l,uri:y}=o;// 10 minutes from now
|
|
301
|
-
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:[]}))[0],h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if("0x1"
|
|
302
|
-
if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const p=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],l=yield this.mintWithSignature(p,r,[],o,u,n,i,d);if("0x1"
|
|
301
|
+
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:[]}))[0],h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if(-1===["0x1","success"].indexOf(h.receipt.status))throw console.error("Minting failed:",h),new Error(`Minting failed with status: ${h.receipt.status}`);return d.toString()}))}mintSocial(e,t,n){return c(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
|
|
302
|
+
if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const p=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],l=yield this.mintWithSignature(p,r,[],o,u,n,i,d);if(-1===["0x1","success"].indexOf(l.status))throw new Error(`Minting Social IpNFT failed with status: ${l.status}`);return r.toString()}))}getOriginUploads(){return c(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
|
|
303
303
|
/**
|
|
304
304
|
* Get the user's Origin stats (multiplier, consent, usage, etc.).
|
|
305
305
|
* @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
|
package/dist/react/index.esm.js
CHANGED
|
@@ -2982,9 +2982,9 @@ class Origin {
|
|
|
2982
2982
|
}));
|
|
2983
2983
|
const account = accounts[0];
|
|
2984
2984
|
const mintResult = yield this.mintWithSignature(account, tokenId, parents || [], creatorContentHash, uri, license, deadline, signature);
|
|
2985
|
-
if (mintResult.status
|
|
2985
|
+
if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
|
|
2986
2986
|
console.error("Minting failed:", mintResult);
|
|
2987
|
-
throw new Error(`Minting failed with status: ${mintResult.status}`);
|
|
2987
|
+
throw new Error(`Minting failed with status: ${mintResult.receipt.status}`);
|
|
2988
2988
|
}
|
|
2989
2989
|
return tokenId.toString();
|
|
2990
2990
|
});
|
|
@@ -3010,7 +3010,7 @@ class Origin {
|
|
|
3010
3010
|
}));
|
|
3011
3011
|
const account = accounts[0];
|
|
3012
3012
|
const mintResult = yield this.mintWithSignature(account, tokenId, [], creatorContentHash, uri, license, deadline, signature);
|
|
3013
|
-
if (mintResult.status
|
|
3013
|
+
if (["0x1", "success"].indexOf(mintResult.status) === -1) {
|
|
3014
3014
|
throw new Error(`Minting Social IpNFT failed with status: ${mintResult.status}`);
|
|
3015
3015
|
}
|
|
3016
3016
|
return tokenId.toString();
|