@campnetwork/origin 0.0.5 → 0.0.7

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 CHANGED
@@ -1,4 +1,4 @@
1
- "use strict";var t=require("axios"),e=require("viem"),n=require("viem/accounts"),i=require("viem/siwe");
1
+ "use strict";var e=require("axios"),t=require("viem"),n=require("viem/accounts"),i=require("viem/siwe");
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -14,7 +14,7 @@ OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14
14
  PERFORMANCE OF THIS SOFTWARE.
15
15
  ***************************************************************************** */
16
16
  /* global Reflect, Promise, SuppressedError, Symbol, Iterator */
17
- function a(t,e,n,i){return new(n||(n=Promise))((function(a,r){function s(t){try{d(i.next(t))}catch(t){r(t)}}function o(t){try{d(i.throw(t))}catch(t){r(t)}}function d(t){var e;t.done?a(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,o)}d((i=i.apply(t,e||[])).next())}))}function r(t,e,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof e?t!==e||!i:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(t):i?i.value:e.get(t)}function s(t,e,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof e?t!==e||!a:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(t,n):a?a.value=n:e.set(t,n),n}"function"==typeof SuppressedError&&SuppressedError;class o extends Error{constructor(t,e){super(t),this.name="APIError",this.statusCode=e||500,Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:this.statusCode||500}}}
17
+ function a(e,t,n,i){return new(n||(n=Promise))((function(a,r){function s(e){try{d(i.next(e))}catch(e){r(e)}}function o(e){try{d(i.throw(e))}catch(e){r(e)}}function d(e){var t;e.done?a(e.value):(t=e.value,t instanceof n?t:new n((function(e){e(t)}))).then(s,o)}d((i=i.apply(e,t||[])).next())}))}function r(e,t,n,i){if("a"===n&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===n?i:"a"===n?i.call(e):i?i.value:t.get(e)}function s(e,t,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(e,n):a?a.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;class o extends Error{constructor(e,t){super(e),this.name="APIError",this.statusCode=t||500,Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:this.statusCode||500}}}
18
18
  /**
19
19
  * Makes a GET request to the given URL with the provided headers.
20
20
  *
@@ -22,7 +22,7 @@ function a(t,e,n,i){return new(n||(n=Promise))((function(a,r){function s(t){try{
22
22
  * @param {object} headers - The headers to include in the request.
23
23
  * @returns {Promise<object>} - The response data.
24
24
  * @throws {APIError} - Throws an error if the request fails.
25
- */function d(e){return a(this,arguments,void 0,(function*(e,n={}){try{return(yield t.get(e,{headers:n})).data}catch(t){if(t.response)throw new o(t.response.data.message||"API request failed",t.response.status);throw new o("Network error or server is unavailable",500)}}))}
25
+ */function d(t){return a(this,arguments,void 0,(function*(t,n={}){try{return(yield e.get(t,{headers:n})).data}catch(e){if(e.response)throw new o(e.response.data.message||"API request failed",e.response.status);throw new o("Network error or server is unavailable",500)}}))}
26
26
  /**
27
27
  * Constructs a query string from an object of query parameters.
28
28
  *
@@ -36,9 +36,9 @@ function a(t,e,n,i){return new(n||(n=Promise))((function(a,r){function s(t){try{
36
36
  * @param {object} params - An object representing query parameters.
37
37
  * @returns {string} - The complete URL with query string.
38
38
  */
39
- function u(t,e={}){const n=function(t={}){return Object.keys(t).map((e=>`${encodeURIComponent(e)}=${encodeURIComponent(t[e])}`)).join("&")}(e);return n?`${t}?${n}`:t}const l="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",p="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";const c={id:123420001114,name:"Basecamp",nativeCurrency:{decimals:18,name:"Camp",symbol:"CAMP"},rpcUrls:{default:{http:["https://rpc-campnetwork.xyz","https://rpc.basecamp.t.raas.gelato.cloud"]}},blockExplorers:{default:{name:"Explorer",url:"https://basecamp.cloud.blockscout.com/"}}};
39
+ function u(e,t={}){const n=function(e={}){return Object.keys(e).map((t=>`${encodeURIComponent(t)}=${encodeURIComponent(e[t])}`)).join("&")}(t);return n?`${e}?${n}`:e}const l="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",p="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";const c={id:123420001114,name:"Basecamp",nativeCurrency:{decimals:18,name:"Camp",symbol:"CAMP"},rpcUrls:{default:{http:["https://rpc-campnetwork.xyz","https://rpc.basecamp.t.raas.gelato.cloud"]}},blockExplorers:{default:{name:"Explorer",url:"https://basecamp.cloud.blockscout.com/"}}};
40
40
  // @ts-ignore
41
- let y=null,h=null;const m=()=>(h||(h=e.createPublicClient({chain:c,transport:e.http()})),h);var f="Connect with Camp Network",w="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",v={USER_CONNECTED:"ed42542d-b676-4112-b6d9-6db98048b2e0",USER_DISCONNECTED:"20af31ac-e602-442e-9e0e-b589f4dd4016",TWITTER_LINKED:"7fbea086-90ef-4679-ba69-f47f9255b34c",DISCORD_LINKED:"d73f5ae3-a8e8-48f2-8532-85e0c7780d6a",SPOTIFY_LINKED:"fc1788b4-c984-42c8-96f4-c87f6bb0b8f7",TIKTOK_LINKED:"4a2ffdd3-f0e9-4784-8b49-ff76ec1c0a6a",TELEGRAM_LINKED:"9006bc5d-bcc9-4d01-a860-4f1a201e8e47"},T="0xd064817Dc0Af032c3fb5dd4671fd10E0a5F0515D",b="0x3B782d053de8910cC0EF3DC09EEA055229a70c6b";let g=[];const I=()=>g,A=t=>{function e(e){g.some((t=>t.info.uuid===e.detail.info.uuid))||(g=[...g,e.detail],t(g))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",e),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",e)};var k=[{inputs:[{internalType:"string",name:"_name",type:"string"},{internalType:"string",name:"_symbol",type:"string"},{internalType:"string",name:"_baseURI",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"DurationZero",type:"error"},{inputs:[{internalType:"uint16",name:"royaltyBps",type:"uint16"}],name:"InvalidRoyalty",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"caller",type:"address"}],name:"NotTokenOwner",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"TokenAlreadyExists",type:"error"},{inputs:[],name:"URIQueryForNonexistentToken",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"Verifier_InvalidDeadline",type:"error"},{inputs:[],name:"Verifier_InvalidSignature",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint32",name:"periods",type:"uint32"},{indexed:!1,internalType:"uint64",name:"newExpiry",type:"uint64"},{indexed:!1,internalType:"uint256",name:"amountPaid",type:"uint256"}],name:"AccessPurchased",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"DataDeleted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"}],name:"DataDeletionRequested",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"DataMinted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"royaltyAmount",type:"uint256"},{indexed:!1,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"uint256",name:"protocolAmount",type:"uint256"}],name:"RoyaltyPaid",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"newPrice",type:"uint128"},{indexed:!1,internalType:"uint32",name:"newDuration",type:"uint32"},{indexed:!1,internalType:"uint16",name:"newRoyaltyBps",type:"uint16"},{indexed:!1,internalType:"address",name:"paymentToken",type:"address"}],name:"TermsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{inputs:[{internalType:"address",name:"creator",type:"address"}],name:"addCreator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"pauser",type:"address"}],name:"addPauser",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner_",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"baseURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"contentHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"creators",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"dataStatus",outputs:[{internalType:"enum DataNFT.DataStatus",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"finalizeDelete",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getTerms",outputs:[{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner_",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"hash",type:"bytes32"},{internalType:"string",name:"uri",type:"string"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"licenseTerms",type:"tuple"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint8",name:"v",type:"uint8"},{internalType:"bytes32",name:"r",type:"bytes32"},{internalType:"bytes32",name:"s",type:"bytes32"}],name:"mintWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"pausers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"creator",type:"address"}],name:"removeCreator",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"pauser",type:"address"}],name:"removePauser",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"requestDelete",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"salePrice",type:"uint256"}],name:"royaltyInfo",outputs:[{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"royaltyAmount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyPercentages",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyReceivers",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"terms",outputs:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct DataNFT.LicenseTerms",name:"newTerms",type:"tuple"}],name:"updateTerms",outputs:[],stateMutability:"nonpayable",type:"function"}];
41
+ let y=null,h=null;const m=()=>(h||(h=t.createPublicClient({chain:c,transport:t.http()})),h);var f="Connect with Camp Network",w="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",v={USER_CONNECTED:"ed42542d-b676-4112-b6d9-6db98048b2e0",USER_DISCONNECTED:"20af31ac-e602-442e-9e0e-b589f4dd4016",TWITTER_LINKED:"7fbea086-90ef-4679-ba69-f47f9255b34c",DISCORD_LINKED:"d73f5ae3-a8e8-48f2-8532-85e0c7780d6a",SPOTIFY_LINKED:"fc1788b4-c984-42c8-96f4-c87f6bb0b8f7",TIKTOK_LINKED:"4a2ffdd3-f0e9-4784-8b49-ff76ec1c0a6a",TELEGRAM_LINKED:"9006bc5d-bcc9-4d01-a860-4f1a201e8e47"},T="0xb55066f2793773B3784f8c57c415a8b5932B33Cd",b="0x977fdEF62CE095Ae8750Fd3496730F24F60dea7a";let g=[];const I=()=>g,A=e=>{function t(t){g.some((e=>e.info.uuid===t.detail.info.uuid))||(g=[...g,t.detail],e(g))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)};var k=[{inputs:[{internalType:"string",name:"_name",type:"string"},{internalType:"string",name:"_symbol",type:"string"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"DurationZero",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"owner",type:"address"}],name:"ERC721IncorrectOwner",type:"error"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ERC721InsufficientApproval",type:"error"},{inputs:[{internalType:"address",name:"approver",type:"address"}],name:"ERC721InvalidApprover",type:"error"},{inputs:[{internalType:"address",name:"operator",type:"address"}],name:"ERC721InvalidOperator",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"ERC721InvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"receiver",type:"address"}],name:"ERC721InvalidReceiver",type:"error"},{inputs:[{internalType:"address",name:"sender",type:"address"}],name:"ERC721InvalidSender",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ERC721NonexistentToken",type:"error"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[],name:"InvalidDeadline",type:"error"},{inputs:[{internalType:"uint16",name:"royaltyBps",type:"uint16"}],name:"InvalidRoyalty",type:"error"},{inputs:[],name:"InvalidSignature",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"caller",type:"address"}],name:"NotTokenOwner",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[],name:"SignatureAlreadyUsed",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"TokenAlreadyExists",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint32",name:"periods",type:"uint32"},{indexed:!1,internalType:"uint256",name:"newExpiry",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amountPaid",type:"uint256"}],name:"AccessPurchased",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"approved",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Approval",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"owner",type:"address"},{indexed:!0,internalType:"address",name:"operator",type:"address"},{indexed:!1,internalType:"bool",name:"approved",type:"bool"}],name:"ApprovalForAll",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"}],name:"DataDeleted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"DataMinted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"royaltyAmount",type:"uint256"},{indexed:!1,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"uint256",name:"protocolAmount",type:"uint256"}],name:"RoyaltyPaid",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"newPrice",type:"uint128"},{indexed:!1,internalType:"uint32",name:"newDuration",type:"uint32"},{indexed:!1,internalType:"uint16",name:"newRoyaltyBps",type:"uint16"},{indexed:!1,internalType:"address",name:"paymentToken",type:"address"}],name:"TermsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"from",type:"address"},{indexed:!0,internalType:"address",name:"to",type:"address"},{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"}],name:"Transfer",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"approve",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"balanceOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"contentHash",outputs:[{internalType:"bytes32",name:"",type:"bytes32"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"dataStatus",outputs:[{internalType:"enum IpNFT.DataStatus",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"finalizeDelete",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getApproved",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"getTerms",outputs:[{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct IpNFT.LicenseTerms",name:"",type:"tuple"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"owner",type:"address"},{internalType:"address",name:"operator",type:"address"}],name:"isApprovedForAll",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes32",name:"creatorContentHash",type:"bytes32"},{internalType:"string",name:"uri",type:"string"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct IpNFT.LicenseTerms",name:"licenseTerms",type:"tuple"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"bytes",name:"signature",type:"bytes"}],name:"mintWithSignature",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"name",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"ownerOf",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"salePrice",type:"uint256"}],name:"royaltyInfo",outputs:[{internalType:"address",name:"receiver",type:"address"},{internalType:"uint256",name:"royaltyAmount",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyPercentages",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyReceivers",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"bytes",name:"data",type:"bytes"}],name:"safeTransferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"operator",type:"address"},{internalType:"bool",name:"approved",type:"bool"}],name:"setApprovalForAll",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes4",name:"interfaceId",type:"bytes4"}],name:"supportsInterface",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"symbol",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"terms",outputs:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"_tokenId",type:"uint256"}],name:"tokenURI",outputs:[{internalType:"string",name:"",type:"string"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"from",type:"address"},{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"transferFrom",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"address",name:"_royaltyReceiver",type:"address"},{components:[{internalType:"uint128",name:"price",type:"uint128"},{internalType:"uint32",name:"duration",type:"uint32"},{internalType:"uint16",name:"royaltyBps",type:"uint16"},{internalType:"address",name:"paymentToken",type:"address"}],internalType:"struct IpNFT.LicenseTerms",name:"newTerms",type:"tuple"}],name:"updateTerms",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"bytes32",name:"",type:"bytes32"}],name:"usedNonces",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"}];
42
42
  /**
43
43
  * Mints a Data NFT with a signature.
44
44
  * @param to The address to mint the NFT to.
@@ -49,14 +49,14 @@ let y=null,h=null;const m=()=>(h||(h=e.createPublicClient({chain:c,transport:e.h
49
49
  * @param deadline The deadline for the minting operation.
50
50
  * @param signature The signature for the minting operation.
51
51
  * @returns A promise that resolves when the minting is complete.
52
- */function C(t,e,n,i,r,s,o){return a(this,void 0,void 0,(function*(){return yield this.callContractMethod(T,k,"mintWithSignature",[t,e,n,i,r,s,o.v,o.r,o.s],{waitForReceipt:!0})}))}
52
+ */function C(e,t,n,i,r,s,o){return a(this,void 0,void 0,(function*(){return yield this.callContractMethod(T,k,"mintWithSignature",[e,t,n,i,r,s,o],{waitForReceipt:!0})}))}
53
53
  /**
54
54
  * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
55
55
  * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
56
56
  * @param deadline The deadline for the registration operation.
57
57
  * @param fileKey Optional file key for file uploads.
58
58
  * @return A promise that resolves with the registration data.
59
- */function M(t,e,n){return a(this,void 0,void 0,(function*(){const i={source:t,deadline:e.toString()};void 0!==n&&(i.fileKey=n);const a=yield fetch(`${w}/auth/origin/register`,{method:"POST",headers:{Authorization:`Bearer ${this.getJwt()}`},body:JSON.stringify(i)});if(!a.ok)throw new Error(`Failed to get signature: ${a.statusText}`);const r=yield a.json();if(r.isError)throw new Error(`Failed to get signature: ${r.message}`);return r.data}))}function E(t,e){return this.callContractMethod(T,k,"updateTerms",[t,e],{waitForReceipt:!0})}function x(t){return this.callContractMethod(T,k,"requestDelete",[t])}function S(t){return this.callContractMethod(T,k,"getTerms",[t])}function $(t){return this.callContractMethod(T,k,"ownerOf",[t])}function D(t){return this.callContractMethod(T,k,"balanceOf",[t])}function F(t){return this.callContractMethod(T,k,"contentHash",[t])}function j(t){return this.callContractMethod(T,k,"tokenURI",[t])}function P(t){return this.callContractMethod(T,k,"dataStatus",[t])}function U(t,e){return a(this,void 0,void 0,(function*(){return this.callContractMethod(T,k,"royaltyInfo",[t,e])}))}function N(t){return this.callContractMethod(T,k,"getApproved",[t])}function O(t,e){return this.callContractMethod(T,k,"isApprovedForAll",[t,e])}function B(t,e,n){return this.callContractMethod(T,k,"transferFrom",[t,e,n])}function _(t,e,n,i){const a=i?[t,e,n,i]:[t,e,n];return this.callContractMethod(T,k,"safeTransferFrom",a)}function W(t,e){return this.callContractMethod(T,k,"approve",[t,e])}function q(t,e){return this.callContractMethod(T,k,"setApprovalForAll",[t,e])}var R,z,L,K,J,H,G,V,Z,Q,Y,X,tt,et,nt,it=[{type:"constructor",inputs:[{name:"dataNFT_",type:"address",internalType:"address"},{name:"router_",type:"address",internalType:"address"},{name:"protocolFeeBps_",type:"uint16",internalType:"uint16"}],stateMutability:"nonpayable"},{type:"function",name:"addFeeManager",inputs:[{name:"feeManager",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"addPauser",inputs:[{name:"pauser",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"buyAccess",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"periods",type:"uint32",internalType:"uint32"}],outputs:[],stateMutability:"payable"},{type:"function",name:"dataNFT",inputs:[],outputs:[{name:"",type:"address",internalType:"contract DataNFT"}],stateMutability:"view"},{type:"function",name:"feeManagers",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"hasAccess",inputs:[{name:"user",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"pausers",inputs:[{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"protocolFeeBps",inputs:[],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"removeFeeManager",inputs:[{name:"feeManager",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"removePauser",inputs:[{name:"pauser",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renewAccess",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"buyer",type:"address",internalType:"address"},{name:"periods",type:"uint32",internalType:"uint32"}],outputs:[],stateMutability:"payable"},{type:"function",name:"router",inputs:[],outputs:[{name:"",type:"address",internalType:"contract RoyaltyRouter"}],stateMutability:"view"},{type:"function",name:"subscriptionExpiry",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint64",internalType:"uint64"}],stateMutability:"view"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateProtocolFee",inputs:[{name:"newFeeBps",type:"uint16",internalType:"uint16"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"uint64",indexed:!1,internalType:"uint64"},{name:"amountPaid",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeleted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeletionRequested",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DataMinted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"},{name:"contentHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"RoyaltyPaid",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"royaltyAmount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"creator",type:"address",indexed:!1,internalType:"address"},{name:"protocolAmount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"TermsUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"newPrice",type:"uint128",indexed:!1,internalType:"uint128"},{name:"newDuration",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"},{name:"paymentToken",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"error",name:"DurationZero",inputs:[]},{type:"error",name:"InvalidPayment",inputs:[{name:"expected",type:"uint256",internalType:"uint256"},{name:"actual",type:"uint256",internalType:"uint256"}]},{type:"error",name:"InvalidPeriods",inputs:[{name:"periods",type:"uint32",internalType:"uint32"}]},{type:"error",name:"InvalidRoyalty",inputs:[{name:"royaltyBps",type:"uint16",internalType:"uint16"}]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]}];function at(t,e,n){return this.callContractMethod(b,it,"buyAccess",[t,e],{waitForReceipt:!0,value:n})}function rt(t,e,n,i){return this.callContractMethod(b,it,"renewAccess",[t,e,n],void 0!==i?{value:i}:void 0)}function st(t,e){return this.callContractMethod(b,it,"hasAccess",[t,e])}function ot(t,e){return this.callContractMethod(b,it,"subscriptionExpiry",[t,e])}
59
+ */function E(e,t,n,i){return a(this,void 0,void 0,(function*(){const a={source:e,deadline:Number(t),licenseTerms:{price:n.price.toString(),duration:n.duration,royaltyBps:n.royaltyBps,paymentToken:n.paymentToken}};void 0!==i&&(a.fileKey=i);const r=yield fetch(`${w}/auth/origin/register`,{method:"POST",headers:{Authorization:`Bearer ${this.getJwt()}`},body:JSON.stringify(a)});if(!r.ok)throw new Error(`Failed to get signature: ${r.statusText}`);const s=yield r.json();if(s.isError)throw new Error(`Failed to get signature: ${s.message}`);return s.data}))}function x(e,t){return this.callContractMethod(T,k,"updateTerms",[e,t],{waitForReceipt:!0})}function M(e){return this.callContractMethod(T,k,"requestDelete",[e])}function S(e){return this.callContractMethod(T,k,"getTerms",[e])}function O(e){return this.callContractMethod(T,k,"ownerOf",[e])}function $(e){return this.callContractMethod(T,k,"balanceOf",[e])}function F(e){return this.callContractMethod(T,k,"contentHash",[e])}function P(e){return this.callContractMethod(T,k,"tokenURI",[e])}function j(e){return this.callContractMethod(T,k,"dataStatus",[e])}function U(e,t){return a(this,void 0,void 0,(function*(){return this.callContractMethod(T,k,"royaltyInfo",[e,t])}))}function N(e){return this.callContractMethod(T,k,"getApproved",[e])}function B(e,t){return this.callContractMethod(T,k,"isApprovedForAll",[e,t])}function D(e,t,n){return this.callContractMethod(T,k,"transferFrom",[e,t,n])}function _(e,t,n,i){const a=i?[e,t,n,i]:[e,t,n];return this.callContractMethod(T,k,"safeTransferFrom",a)}function W(e,t){return this.callContractMethod(T,k,"approve",[e,t])}function R(e,t){return this.callContractMethod(T,k,"setApprovalForAll",[e,t])}var q,z,L,K,J,H,G,V,Z,Y,Q,X,ee,te,ne,ie=[{inputs:[{internalType:"address",name:"dataNFT_",type:"address"},{internalType:"uint16",name:"protocolFeeBps_",type:"uint16"},{internalType:"address",name:"treasury_",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"EnforcedPause",type:"error"},{inputs:[],name:"ExpectedPause",type:"error"},{inputs:[{internalType:"uint256",name:"expected",type:"uint256"},{internalType:"uint256",name:"actual",type:"uint256"}],name:"InvalidPayment",type:"error"},{inputs:[{internalType:"uint32",name:"periods",type:"uint32"}],name:"InvalidPeriods",type:"error"},{inputs:[{internalType:"uint16",name:"royaltyBps",type:"uint16"}],name:"InvalidRoyalty",type:"error"},{inputs:[{internalType:"address",name:"owner",type:"address"}],name:"OwnableInvalidOwner",type:"error"},{inputs:[{internalType:"address",name:"account",type:"address"}],name:"OwnableUnauthorizedAccount",type:"error"},{inputs:[],name:"TransferFailed",type:"error"},{inputs:[],name:"Unauthorized",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint32",name:"periods",type:"uint32"},{indexed:!1,internalType:"uint256",name:"newExpiry",type:"uint256"},{indexed:!1,internalType:"uint256",name:"amountPaid",type:"uint256"}],name:"AccessPurchased",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"}],name:"DataDeleted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!0,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"bytes32",name:"contentHash",type:"bytes32"}],name:"DataMinted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"previousOwner",type:"address"},{indexed:!0,internalType:"address",name:"newOwner",type:"address"}],name:"OwnershipTransferred",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Paused",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint256",name:"royaltyAmount",type:"uint256"},{indexed:!1,internalType:"address",name:"creator",type:"address"},{indexed:!1,internalType:"uint256",name:"protocolAmount",type:"uint256"}],name:"RoyaltyPaid",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"uint128",name:"newPrice",type:"uint128"},{indexed:!1,internalType:"uint32",name:"newDuration",type:"uint32"},{indexed:!1,internalType:"uint16",name:"newRoyaltyBps",type:"uint16"},{indexed:!1,internalType:"address",name:"paymentToken",type:"address"}],name:"TermsUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!1,internalType:"address",name:"account",type:"address"}],name:"Unpaused",type:"event"},{inputs:[{internalType:"address",name:"feeManager",type:"address"}],name:"addFeeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"buyer",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint32",name:"periods",type:"uint32"}],name:"buyAccess",outputs:[],stateMutability:"payable",type:"function"},{inputs:[],name:"dataNFT",outputs:[{internalType:"contract IpNFT",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"",type:"address"}],name:"feeManagers",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"user",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"}],name:"hasAccess",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"pause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"paused",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"protocolFeeBps",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"feeManager",type:"address"}],name:"removeFeeManager",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"},{internalType:"address",name:"",type:"address"}],name:"subscriptionExpiry",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"newOwner",type:"address"}],name:"transferOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"treasury",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"unpause",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint16",name:"newFeeBps",type:"uint16"}],name:"updateProtocolFee",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"newTreasury",type:"address"}],name:"updateTreasury",outputs:[],stateMutability:"nonpayable",type:"function"},{stateMutability:"payable",type:"receive"}];function ae(e,t,n){return this.callContractMethod(b,ie,"buyAccess",[e,t],{waitForReceipt:!0,value:n})}function re(e,t,n,i){return this.callContractMethod(b,ie,"renewAccess",[e,t,n],void 0!==i?{value:i}:void 0)}function se(e,t){return this.callContractMethod(b,ie,"hasAccess",[e,t])}function oe(e,t){return this.callContractMethod(b,ie,"subscriptionExpiry",[e,t])}
60
60
  /**
61
61
  * Approves a spender to spend a specified amount of tokens on behalf of the owner.
62
62
  * If the current allowance is less than the specified amount, it will perform the approval.
@@ -66,35 +66,45 @@ let y=null,h=null;const m=()=>(h||(h=e.createPublicClient({chain:c,transport:e.h
66
66
  * The Origin class
67
67
  * Handles the upload of files to Origin, as well as querying the user's stats
68
68
  */
69
- class dt{constructor(e,n){R.add(this),z.set(this,(t=>a(this,void 0,void 0,(function*(){const e=yield fetch(`${w}/auth/origin/upload-url`,{method:"POST",body:JSON.stringify({name:t.name,type:t.type}),headers:{Authorization:`Bearer ${this.jwt}`}}),n=yield e.json();return n.isError?n.message:n.data})))),L.set(this,((t,e)=>a(this,void 0,void 0,(function*(){(yield fetch(`${w}/auth/origin/update-status`,{method:"PATCH",body:JSON.stringify({status:e,fileKey:t}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}})).ok||console.error("Failed to update origin status")})))),this.uploadFile=(e,n)=>a(this,void 0,void 0,(function*(){const i=yield r(this,z,"f").call(this,e);if(i){try{yield((e,n,i)=>new Promise(((a,r)=>{t.put(n,e,Object.assign({headers:{"Content-Type":e.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:t=>{if(t.total){const e=t.loaded/t.total*100;i(e)}}}:{})).then((t=>{a(t.data)})).catch((t=>{var e;const n=(null===(e=null==t?void 0:t.response)||void 0===e?void 0:e.data)||(null==t?void 0:t.message)||"Upload failed";r(n)}))})))(e,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(t){throw yield r(this,L,"f").call(this,i.key,"failed"),new Error("Failed to upload file: "+t)}return yield r(this,L,"f").call(this,i.key,"success"),i}console.error("Failed to generate upload URL")})),this.mintFile=(t,e,n)=>a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");try{const i=yield this.uploadFile(t,n);if(!i||!i.key)return console.error("Invalid upload info:",i),null;const a=BigInt(Math.floor(Date.now()/1e3)+600),r=yield this.registerDataNFT("file",a,i.key),{tokenId:s,signerAddress:o,hash:d,v:u,r:l,s:p}=r;// 10 minutes from now
70
- if(!s||!o||!d||void 0===u||void 0===l||void 0===p)return console.error("Invalid registration data:",r),null;const[c]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),y={v:u,r:l,s:p};yield this.mintWithSignature(c,s,d,i.url,e,a,y);return s.toString()}catch(t){return console.error("Failed to upload file:",t),null}})),this.mintSocial=t=>a(this,void 0,void 0,(function*(){try{const e=BigInt(Math.floor(Date.now()/1e3)+600),n=yield this.registerDataNFT(t,e);// 10 minutes from now (temp)
71
- return n?n.tokenId.toString():(console.error("Failed to register DataNFT"),null)}catch(t){return console.error("Failed to mint social DataNFT:",t),null}})),this.getOriginUploads=()=>a(this,void 0,void 0,(function*(){const t=yield fetch(`${w}/auth/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!t.ok)return console.error("Failed to get origin uploads"),null;return(yield t.json()).data})),this.jwt=e,this.viemClient=n,
69
+ class de{constructor(t,n){q.add(this),z.set(this,(e=>a(this,void 0,void 0,(function*(){const t=yield fetch(`${w}/auth/origin/upload-url`,{method:"POST",body:JSON.stringify({name:e.name,type:e.type}),headers:{Authorization:`Bearer ${this.jwt}`}}),n=yield t.json();return n.isError?n.message:n.data})))),L.set(this,((e,t)=>a(this,void 0,void 0,(function*(){(yield fetch(`${w}/auth/origin/update-status`,{method:"PATCH",body:JSON.stringify({status:t,fileKey:e}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}})).ok||console.error("Failed to update origin status")})))),this.uploadFile=(t,n)=>a(this,void 0,void 0,(function*(){const i=yield r(this,z,"f").call(this,t);if(i){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){throw yield r(this,L,"f").call(this,i.key,"failed"),new Error("Failed to upload file: "+e)}return yield r(this,L,"f").call(this,i.key,"success"),i}console.error("Failed to generate upload URL")})),this.mintFile=(e,t,n)=>a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=yield this.uploadFile(e,n);if(!i||!i.key)throw new Error("Failed to upload file or get upload info.");const a=BigInt(Math.floor(Date.now())+600),r=yield this.registerIpNFT("file",a,t,i.key),{tokenId:s,signerAddress:o,creatorContentHash:d,signature:u,uri:l}=r;// 10 minutes from now
70
+ if(!(s&&o&&d&&void 0!==u&&l))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");const[p]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),c=yield this.mintWithSignature(p,s,d,l,t,a,u);if("0x1"!==c.status)throw new Error(`Minting failed with status: ${c.status}`);return s.toString()})),this.mintSocial=(e,t)=>a(this,void 0,void 0,(function*(){
71
+ // try {
72
+ const n=BigInt(Math.floor(Date.now())+600),i=yield this.registerIpNFT(e,n,t);// 10 minutes from now (temp)
73
+ if(!i)
74
+ // console.error("Failed to register IpNFT");
75
+ // return null;
76
+ throw new Error("Failed to register Social IpNFT");return i.tokenId.toString();
77
+ // } catch (error) {
78
+ // console.error("Failed to mint social IpNFT:", error);
79
+ // return null;
80
+ // }
81
+ })),this.getOriginUploads=()=>a(this,void 0,void 0,(function*(){const e=yield fetch(`${w}/auth/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})),this.jwt=t,this.viemClient=n,
72
82
  // DataNFT methods
73
- this.mintWithSignature=C.bind(this),this.registerDataNFT=M.bind(this),this.updateTerms=E.bind(this),this.requestDelete=x.bind(this),this.getTerms=S.bind(this),this.ownerOf=$.bind(this),this.balanceOf=D.bind(this),this.contentHash=F.bind(this),this.tokenURI=j.bind(this),this.dataStatus=P.bind(this),this.royaltyInfo=U.bind(this),this.getApproved=N.bind(this),this.isApprovedForAll=O.bind(this),this.transferFrom=B.bind(this),this.safeTransferFrom=_.bind(this),this.approve=W.bind(this),this.setApprovalForAll=q.bind(this),
83
+ this.mintWithSignature=C.bind(this),this.registerIpNFT=E.bind(this),this.updateTerms=x.bind(this),this.requestDelete=M.bind(this),this.getTerms=S.bind(this),this.ownerOf=O.bind(this),this.balanceOf=$.bind(this),this.contentHash=F.bind(this),this.tokenURI=P.bind(this),this.dataStatus=j.bind(this),this.royaltyInfo=U.bind(this),this.getApproved=N.bind(this),this.isApprovedForAll=B.bind(this),this.transferFrom=D.bind(this),this.safeTransferFrom=_.bind(this),this.approve=W.bind(this),this.setApprovalForAll=R.bind(this),
74
84
  // Marketplace methods
75
- this.buyAccess=at.bind(this),this.renewAccess=rt.bind(this),this.hasAccess=st.bind(this),this.subscriptionExpiry=ot.bind(this)}getJwt(){return this.jwt}setViemClient(t){this.viemClient=t}
85
+ this.buyAccess=ae.bind(this),this.renewAccess=re.bind(this),this.hasAccess=se.bind(this),this.subscriptionExpiry=oe.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}
76
86
  /**
77
87
  * Get the user's Origin stats (multiplier, consent, usage, etc.).
78
88
  * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
79
- */getOriginUsage(){return a(this,void 0,void 0,(function*(){const t=yield fetch(`${w}/auth/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
89
+ */getOriginUsage(){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${w}/auth/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
80
90
  // "x-client-id": this.clientId,
81
- "Content-Type":"application/json"}}).then((t=>t.json()));if(!t.isError&&t.data.user)return t;throw new o(t.message||"Failed to fetch Origin usage")}))}
91
+ "Content-Type":"application/json"}}).then((e=>e.json()));if(!e.isError&&e.data.user)return e;throw new o(e.message||"Failed to fetch Origin usage")}))}
82
92
  /**
83
93
  * Set the user's consent for Origin usage.
84
94
  * @param {boolean} consent The user's consent.
85
95
  * @returns {Promise<void>}
86
96
  * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
87
- */setOriginConsent(t){return a(this,void 0,void 0,(function*(){if(void 0===t)throw new o("Consent is required");const e=yield fetch(`${w}/auth/origin/status`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
97
+ */setOriginConsent(e){return a(this,void 0,void 0,(function*(){if(void 0===e)throw new o("Consent is required");const t=yield fetch(`${w}/auth/origin/status`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
88
98
  // "x-client-id": this.clientId,
89
- "Content-Type":"application/json"},body:JSON.stringify({active:t})}).then((t=>t.json()));if(e.isError)throw new o(e.message||"Failed to set Origin consent")}))}
99
+ "Content-Type":"application/json"},body:JSON.stringify({active:e})}).then((e=>e.json()));if(t.isError)throw new o(t.message||"Failed to set Origin consent")}))}
90
100
  /**
91
101
  * Set the user's Origin multiplier.
92
102
  * @param {number} multiplier The user's Origin multiplier.
93
103
  * @returns {Promise<void>}
94
104
  * @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the multiplier is not provided.
95
- */setOriginMultiplier(t){return a(this,void 0,void 0,(function*(){if(void 0===t)throw new o("Multiplier is required");const e=yield fetch(`${w}/auth/origin/multiplier`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
105
+ */setOriginMultiplier(e){return a(this,void 0,void 0,(function*(){if(void 0===e)throw new o("Multiplier is required");const t=yield fetch(`${w}/auth/origin/multiplier`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
96
106
  // "x-client-id": this.clientId,
97
- "Content-Type":"application/json"},body:JSON.stringify({multiplier:t})}).then((t=>t.json()));if(e.isError)throw new o(e.message||"Failed to set Origin multiplier")}))}
107
+ "Content-Type":"application/json"},body:JSON.stringify({multiplier:e})}).then((e=>e.json()));if(t.isError)throw new o(t.message||"Failed to set Origin multiplier")}))}
98
108
  /**
99
109
  * Call a contract method.
100
110
  * @param {string} contractAddress The contract address.
@@ -104,17 +114,17 @@ this.buyAccess=at.bind(this),this.renewAccess=rt.bind(this),this.hasAccess=st.bi
104
114
  * @param {CallOptions} [options] The call options.
105
115
  * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
106
116
  * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
107
- */callContractMethod(t,n,i,s){return a(this,arguments,void 0,(function*(t,n,i,a,s={}){const o=e.getAbiItem({abi:n,name:i}),d=o&&"stateMutability"in o&&("view"===o.stateMutability||"pure"===o.stateMutability);if(!d&&!this.viemClient)throw new Error("WalletClient not connected.");if(d){const e=m();return(yield e.readContract({address:t,abi:n,functionName:i,args:a}))||null}{const[o]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),d=e.encodeFunctionData({abi:n,functionName:i,args:a});yield r(this,R,"m",J).call(this,c);const u=yield this.viemClient.sendTransaction({to:t,data:d,account:o,value:s.value,gas:s.gas});if("string"!=typeof u)throw new Error("Transaction failed to send.");if(!s.waitForReceipt)return u;return yield r(this,R,"m",K).call(this,u)}}))}
117
+ */callContractMethod(e,n,i,s){return a(this,arguments,void 0,(function*(e,n,i,a,s={}){const o=t.getAbiItem({abi:n,name:i}),d=o&&"stateMutability"in o&&("view"===o.stateMutability||"pure"===o.stateMutability);if(!d&&!this.viemClient)throw new Error("WalletClient not connected.");if(d){const t=m();return(yield t.readContract({address:e,abi:n,functionName:i,args:a}))||null}{const[o]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),d=t.encodeFunctionData({abi:n,functionName:i,args:a});yield r(this,q,"m",J).call(this,c);try{const t=yield this.viemClient.sendTransaction({to:e,data:d,account:o,value:s.value,gas:s.gas});if("string"!=typeof t)throw new Error("Transaction failed to send.");if(!s.waitForReceipt)return t;return yield r(this,q,"m",K).call(this,t)}catch(e){throw console.error("Transaction failed:",e),new Error("Transaction failed: "+e)}}}))}
108
118
  /**
109
119
  * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
110
120
  * @param {bigint} tokenId The token ID of the asset.
111
121
  * @param {number} periods The number of periods to buy access for.
112
122
  * @returns {Promise<any>} The result of the buyAccess call.
113
- */buyAccessSmart(t,n){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=yield this.getTerms(t);if(!i)throw new Error("Failed to fetch terms for asset");const{price:r,paymentToken:s}=i;if(void 0===r||void 0===s)throw new Error("Terms missing price or paymentToken");const o=r*BigInt(n);if(s===e.zeroAddress)return this.buyAccess(t,n,o);const d=yield this.viemClient.getAddress();return yield function(t){return a(this,arguments,void 0,(function*({walletClient:t,publicClient:n,tokenAddress:i,owner:a,spender:r,amount:s}){(yield n.readContract({address:i,abi:e.erc20Abi,functionName:"allowance",args:[a,r]}))<s&&(yield t.writeContract({address:i,account:a,abi:e.erc20Abi,functionName:"approve",args:[r,s],chain:c}))}))}({walletClient:this.viemClient,publicClient:m(),tokenAddress:s,owner:d,spender:b,amount:o}),this.buyAccess(t,n)}))}getData(t){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${w}/auth/origin/data/${t}`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!e.ok)throw new Error("Failed to fetch data");return e.json()}))}}z=new WeakMap,L=new WeakMap,R=new WeakSet,K=function(t){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");for(;;){const e=yield this.viemClient.request({method:"eth_getTransactionReceipt",params:[t]});if(e&&e.blockNumber)return e;yield new Promise((t=>setTimeout(t,1e3)))}}))},J=function(t){return a(this,void 0,void 0,(function*(){
123
+ */buyAccessSmart(e,n){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=yield this.getTerms(e);if(!i)throw new Error("Failed to fetch terms for asset");const{price:r,paymentToken:s}=i;if(void 0===r||void 0===s)throw new Error("Terms missing price or paymentToken");const o=r*BigInt(n);if(s===t.zeroAddress)return this.buyAccess(e,n,o);const d=yield this.viemClient.getAddress();return yield function(e){return a(this,arguments,void 0,(function*({walletClient:e,publicClient:n,tokenAddress:i,owner:a,spender:r,amount:s}){(yield n.readContract({address:i,abi:t.erc20Abi,functionName:"allowance",args:[a,r]}))<s&&(yield e.writeContract({address:i,account:a,abi:t.erc20Abi,functionName:"approve",args:[r,s],chain:c}))}))}({walletClient:this.viemClient,publicClient:m(),tokenAddress:s,owner:d,spender:b,amount:o}),this.buyAccess(e,n)}))}getData(e){return a(this,void 0,void 0,(function*(){const t=yield fetch(`${w}/auth/origin/data/${e}`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch data");return t.json()}))}}z=new WeakMap,L=new WeakMap,q=new WeakSet,K=function(e){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");for(;;){const t=yield this.viemClient.request({method:"eth_getTransactionReceipt",params:[e]});if(t&&t.blockNumber)return t;yield new Promise((e=>setTimeout(e,1e3)))}}))},J=function(e){return a(this,void 0,void 0,(function*(){
114
124
  // return;
115
- if(!this.viemClient)throw new Error("WalletClient not connected.");let e=yield this.viemClient.request({method:"eth_chainId",params:[]});if("string"==typeof e&&(e=parseInt(e,16)),e!==t.id)try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}catch(e){
125
+ if(!this.viemClient)throw new Error("WalletClient not connected.");let t=yield this.viemClient.request({method:"eth_chainId",params:[]});if("string"==typeof t&&(t=parseInt(t,16)),t!==e.id)try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(e.id).toString(16)}]})}catch(t){
116
126
  // Unrecognized chain
117
- if(4902!==e.code)throw e;yield this.viemClient.request({method:"wallet_addEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16),chainName:t.name,rpcUrls:t.rpcUrls.default.http,nativeCurrency:t.nativeCurrency}]}),yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(t.id).toString(16)}]})}}))};G=new WeakMap,V=new WeakMap,H=new WeakSet,Z=function(t,e){r(this,G,"f")[t]&&r(this,G,"f")[t].forEach((t=>t(e)))},Q=function(t){return a(this,void 0,void 0,(function*(){if("undefined"==typeof localStorage)return;const e=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:wallet-address"),n=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:user-id"),i=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:jwt");e&&n&&i?(this.walletAddress=e,this.userId=n,this.jwt=i,this.origin=new dt(this.jwt),this.isAuthenticated=!0,
127
+ if(4902!==t.code)throw t;yield this.viemClient.request({method:"wallet_addEthereumChain",params:[{chainId:"0x"+BigInt(e.id).toString(16),chainName:e.name,rpcUrls:e.rpcUrls.default.http,nativeCurrency:e.nativeCurrency}]}),yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(e.id).toString(16)}]})}}))};G=new WeakMap,V=new WeakMap,H=new WeakSet,Z=function(e,t){r(this,G,"f")[e]&&r(this,G,"f")[e].forEach((e=>e(t)))},Y=function(e){return a(this,void 0,void 0,(function*(){if("undefined"==typeof localStorage)return;const t=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:wallet-address"),n=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:user-id"),i=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:jwt");t&&n&&i?(this.walletAddress=t,this.userId=n,this.jwt=i,this.origin=new de(this.jwt),this.isAuthenticated=!0,
118
128
  /*
119
129
  let selectedProvider = provider;
120
130
 
@@ -135,7 +145,7 @@ if(4902!==e.code)throw e;yield this.viemClient.request({method:"wallet_addEthere
135
145
  }
136
146
  }
137
147
  */
138
- t?this.setProvider({provider:t.provider,info:t.info||{name:"Unknown"},address:e}):(console.warn("No matching provider was given for the stored wallet address. Trying to recover provider."),yield this.recoverProvider())):this.isAuthenticated=!1}))},Y=function(){return a(this,void 0,void 0,(function*(){try{const[t]=yield this.viem.requestAddresses();return this.walletAddress=t,t}catch(t){throw new o(t)}}))},X=function(){return a(this,void 0,void 0,(function*(){try{const t=yield fetch(`${w}/auth/client-user/nonce`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({walletAddress:this.walletAddress})}),e=yield t.json();return 200!==t.status?Promise.reject(e.message||"Failed to fetch nonce"):e.data}catch(t){throw new Error(t)}}))},tt=function(t,e){return a(this,void 0,void 0,(function*(){try{const n=yield fetch(`${w}/auth/client-user/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({message:t,signature:e,walletAddress:this.walletAddress})}),i=yield n.json(),a=i.data.split(".")[1],r=JSON.parse(atob(a));return{success:!i.isError,userId:r.id,token:i.data}}catch(t){throw new o(t)}}))},et=function(t){return i.createSiweMessage({domain:window.location.host,address:this.walletAddress,statement:f,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:t})},nt=function(t,e){return a(this,arguments,void 0,(function*(t,e,n=1){
148
+ e?this.setProvider({provider:e.provider,info:e.info||{name:"Unknown"},address:t}):(console.warn("No matching provider was given for the stored wallet address. Trying to recover provider."),yield this.recoverProvider())):this.isAuthenticated=!1}))},Q=function(){return a(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=e,e}catch(e){throw new o(e)}}))},X=function(){return a(this,void 0,void 0,(function*(){try{const e=yield fetch(`${w}/auth/client-user/nonce`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({walletAddress:this.walletAddress})}),t=yield e.json();return 200!==e.status?Promise.reject(t.message||"Failed to fetch nonce"):t.data}catch(e){throw new Error(e)}}))},ee=function(e,t){return a(this,void 0,void 0,(function*(){try{const n=yield fetch(`${w}/auth/client-user/verify`,{method:"POST",headers:{"Content-Type":"application/json","x-client-id":this.clientId},body:JSON.stringify({message:e,signature:t,walletAddress:this.walletAddress})}),i=yield n.json(),a=i.data.split(".")[1],r=JSON.parse(atob(a));return{success:!i.isError,userId:r.id,token:i.data}}catch(e){throw new o(e)}}))},te=function(e){return i.createSiweMessage({domain:window.location.host,address:this.walletAddress,statement:f,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:e})},ne=function(e,t){return a(this,arguments,void 0,(function*(e,t,n=1){
139
149
  // if (this.#ackeeInstance)
140
150
  // await sendAnalyticsEvent(this.#ackeeInstance, event, message, count);
141
151
  // else return;
@@ -155,11 +165,11 @@ class{
155
165
  * @param {object} [options.ackeeInstance] The Ackee instance.
156
166
  * @throws {APIError} - Throws an error if the clientId is not provided.
157
167
  */
158
- constructor({clientId:t,redirectUri:e,allowAnalytics:n=!0,ackeeInstance:i}){if(H.add(this),G.set(this,void 0),V.set(this,void 0),!t)throw new Error("clientId is required");this.viem=null,
168
+ constructor({clientId:e,redirectUri:t,allowAnalytics:n=!0,ackeeInstance:i}){if(H.add(this),G.set(this,void 0),V.set(this,void 0),!e)throw new Error("clientId is required");this.viem=null,
159
169
  // if (typeof window !== "undefined") {
160
170
  // if (window.ethereum) this.viem = getClient(window.ethereum);
161
171
  // }
162
- this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==typeof t?e.reduce(((e,n)=>(e[n]=t[n]||("undefined"!=typeof window?window.location.href:""),e)),{}):"string"==typeof t?e.reduce(((e,n)=>(e[n]=t,e)),{}):t?{}:e.reduce(((t,e)=>(t[e]="undefined"!=typeof window?window.location.href:"",t)),{})})(e),i&&s(this,V,i,"f"),n&&r(this,V,"f"),this.clientId=t,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,s(this,G,{},"f"),A((t=>{r(this,H,"m",Z).call(this,"providers",t)})),r(this,H,"m",Q).call(this)}
172
+ this.redirectUri=(e=>{const t=["twitter","discord","spotify"];return"object"==typeof e?t.reduce(((t,n)=>(t[n]=e[n]||("undefined"!=typeof window?window.location.href:""),t)),{}):"string"==typeof e?t.reduce(((t,n)=>(t[n]=e,t)),{}):e?{}:t.reduce(((e,t)=>(e[t]="undefined"!=typeof window?window.location.href:"",e)),{})})(t),i&&s(this,V,i,"f"),n&&r(this,V,"f"),this.clientId=e,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,s(this,G,{},"f"),A((e=>{r(this,H,"m",Z).call(this,"providers",e)})),r(this,H,"m",Y).call(this)}
163
173
  /**
164
174
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
165
175
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
@@ -169,25 +179,25 @@ this.redirectUri=(t=>{const e=["twitter","discord","spotify"];return"object"==ty
169
179
  * auth.on("state", (state) => {
170
180
  * console.log(state);
171
181
  * });
172
- */on(t,e){r(this,G,"f")[t]||(r(this,G,"f")[t]=[]),r(this,G,"f")[t].push(e),"providers"===t&&e(I())}
182
+ */on(e,t){r(this,G,"f")[e]||(r(this,G,"f")[e]=[]),r(this,G,"f")[e].push(t),"providers"===e&&t(I())}
173
183
  /**
174
184
  * Set the loading state.
175
185
  * @param {boolean} loading The loading state.
176
186
  * @returns {void}
177
- */setLoading(t){r(this,H,"m",Z).call(this,"state",t?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
187
+ */setLoading(e){r(this,H,"m",Z).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
178
188
  /**
179
189
  * Set the provider. This is useful for setting the provider when the user selects a provider from the UI or when dApp wishes to use a specific provider.
180
190
  * @param {object} options The options object. Includes the provider and the provider info.
181
191
  * @returns {void}
182
192
  * @throws {APIError} - Throws an error if the provider is not provided.
183
- */setProvider({provider:t,info:i,address:a}){if(!t)throw new o("provider is required");this.viem=((t,i="window.ethereum",a)=>{var r;if(!t&&!y)return console.warn("Provider is required to create a client."),null;if(!y||y.transport.name!==i&&t||a!==(null===(r=y.account)||void 0===r?void 0:r.address)&&t){const r={chain:c,transport:e.custom(t,{name:i})};a&&(r.account=n.toAccount(a)),y=e.createWalletClient(r)}return y})(t,i.name,a),this.origin&&this.origin.setViemClient(this.viem),
193
+ */setProvider({provider:e,info:i,address:a}){if(!e)throw new o("provider is required");this.viem=((e,i="window.ethereum",a)=>{var r;if(!e&&!y)return console.warn("Provider is required to create a client."),null;if(!y||y.transport.name!==i&&e||a!==(null===(r=y.account)||void 0===r?void 0:r.address)&&e){const r={chain:c,transport:t.custom(e,{name:i})};a&&(r.account=n.toAccount(a)),y=t.createWalletClient(r)}return y})(e,i.name,a),this.origin&&this.origin.setViemClient(this.viem),
184
194
  // TODO: only use one of these
185
- r(this,H,"m",Z).call(this,"viem",this.viem),r(this,H,"m",Z).call(this,"provider",{provider:t,info:i})}
195
+ r(this,H,"m",Z).call(this,"viem",this.viem),r(this,H,"m",Z).call(this,"provider",{provider:e,info:i})}
186
196
  /**
187
197
  * Set the wallet address. This is useful for edge cases where the provider can't return the wallet address. Don't use this unless you know what you're doing.
188
198
  * @param {string} walletAddress The wallet address.
189
199
  * @returns {void}
190
- */setWalletAddress(t){this.walletAddress=t}recoverProvider(){return a(this,void 0,void 0,(function*(){var t,e,n;if(!this.walletAddress)return void console.warn("No wallet address found in local storage. Please connect your wallet again.");let i;const a=null!==(t=I())&&void 0!==t?t:[];for(const t of a)try{if((null===(e=(yield t.provider.request({method:"eth_requestAccounts"}))[0])||void 0===e?void 0:e.toLowerCase())===(null===(n=this.walletAddress)||void 0===n?void 0:n.toLowerCase())){i=t;break}}catch(t){console.warn("Failed to fetch accounts from provider:",t)}i?this.setProvider({provider:i.provider,info:i.info||{name:"Unknown"},address:this.walletAddress}):console.warn("No matching provider found for the stored wallet address. Please connect your wallet again.")}))}
200
+ */setWalletAddress(e){this.walletAddress=e}recoverProvider(){return a(this,void 0,void 0,(function*(){var e,t,n;if(!this.walletAddress)return void console.warn("No wallet address found in local storage. Please connect your wallet again.");let i;const a=null!==(e=I())&&void 0!==e?e:[];for(const e of a)try{if((null===(t=(yield e.provider.request({method:"eth_requestAccounts"}))[0])||void 0===t?void 0:t.toLowerCase())===(null===(n=this.walletAddress)||void 0===n?void 0:n.toLowerCase())){i=e;break}}catch(e){console.warn("Failed to fetch accounts from provider:",e)}i?this.setProvider({provider:i.provider,info:i.info||{name:"Unknown"},address:this.walletAddress}):console.warn("No matching provider found for the stored wallet address. Please connect your wallet again.")}))}
191
201
  /**
192
202
  * Disconnect the user.
193
203
  * @returns {Promise<void>}
@@ -196,7 +206,7 @@ r(this,H,"m",Z).call(this,"viem",this.viem),r(this,H,"m",Z).call(this,"provider"
196
206
  * Connect the user's wallet and sign the message.
197
207
  * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
198
208
  * @throws {APIError} - Throws an error if the user cannot be authenticated.
199
- */connect(){return a(this,void 0,void 0,(function*(){r(this,H,"m",Z).call(this,"state","loading");try{this.walletAddress||(yield r(this,H,"m",Y).call(this));const t=yield r(this,H,"m",X).call(this),e=r(this,H,"m",et).call(this,t),n=yield this.viem.signMessage({account:this.walletAddress,message:e}),i=yield r(this,H,"m",tt).call(this,e,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new dt(this.jwt,this.viem),localStorage.setItem("camp-sdk:jwt",this.jwt),localStorage.setItem("camp-sdk:wallet-address",this.walletAddress),localStorage.setItem("camp-sdk:user-id",this.userId),r(this,H,"m",Z).call(this,"state","authenticated"),yield r(this,H,"m",nt).call(this,v.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,r(this,H,"m",Z).call(this,"state","unauthenticated"),new o("Failed to authenticate")}catch(t){throw this.isAuthenticated=!1,r(this,H,"m",Z).call(this,"state","unauthenticated"),new o(t)}}))}
209
+ */connect(){return a(this,void 0,void 0,(function*(){r(this,H,"m",Z).call(this,"state","loading");try{this.walletAddress||(yield r(this,H,"m",Q).call(this));const e=yield r(this,H,"m",X).call(this),t=r(this,H,"m",te).call(this,e),n=yield this.viem.signMessage({account:this.walletAddress,message:t}),i=yield r(this,H,"m",ee).call(this,t,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new de(this.jwt,this.viem),localStorage.setItem("camp-sdk:jwt",this.jwt),localStorage.setItem("camp-sdk:wallet-address",this.walletAddress),localStorage.setItem("camp-sdk:user-id",this.userId),r(this,H,"m",Z).call(this,"state","authenticated"),yield r(this,H,"m",ne).call(this,v.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,r(this,H,"m",Z).call(this,"state","unauthenticated"),new o("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,r(this,H,"m",Z).call(this,"state","unauthenticated"),new o(e)}}))}
200
210
  /**
201
211
  * Get the user's linked social accounts.
202
212
  * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
@@ -205,7 +215,7 @@ r(this,H,"m",Z).call(this,"viem",this.viem),r(this,H,"m",Z).call(this,"provider"
205
215
  * const auth = new Auth({ clientId: "your-client-id" });
206
216
  * const socials = await auth.getLinkedSocials();
207
217
  * console.log(socials);
208
- */getLinkedSocials(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${w}/auth/client-user/connections-sdk`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"}}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to fetch connections");{const e={};return Object.keys(t.data.data).forEach((n=>{e[n.split("User")[0]]=t.data.data[n]})),e}}))}
218
+ */getLinkedSocials(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${w}/auth/client-user/connections-sdk`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"}}).then((e=>e.json()));if(e.isError)throw new o(e.message||"Failed to fetch connections");{const t={};return Object.keys(e.data.data).forEach((n=>{t[n.split("User")[0]]=e.data.data[n]})),t}}))}
209
219
  /**
210
220
  * Link the user's Twitter account.
211
221
  * @returns {Promise<void>}
@@ -241,13 +251,13 @@ window.location.href=`${w}/spotify/connect?clientId=${this.clientId}&userId=${th
241
251
  * @param {string} handle The user's TikTok handle.
242
252
  * @returns {Promise<any>} A promise that resolves with the TikTok account data.
243
253
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
244
- */linkTikTok(t){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${w}/tiktok/connect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userHandle:t,clientId:this.clientId,userId:this.userId})}).then((t=>t.json()));if(e.isError)throw"Request failed with status code 502"===e.message?new o("TikTok service is currently unavailable, try again later"):new o(e.message||"Failed to link TikTok account");return r(this,H,"m",nt).call(this,v.TIKTOK_LINKED,"TikTok Linked"),e.data}))}
254
+ */linkTikTok(e){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${w}/tiktok/connect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userHandle:e,clientId:this.clientId,userId:this.userId})}).then((e=>e.json()));if(t.isError)throw"Request failed with status code 502"===t.message?new o("TikTok service is currently unavailable, try again later"):new o(t.message||"Failed to link TikTok account");return r(this,H,"m",ne).call(this,v.TIKTOK_LINKED,"TikTok Linked"),t.data}))}
245
255
  /**
246
256
  * Send an OTP to the user's Telegram account.
247
257
  * @param {string} phoneNumber The user's phone number.
248
258
  * @returns {Promise<any>} A promise that resolves with the OTP data.
249
259
  * @throws {Error|APIError} - Throws an error if the user is not authenticated.
250
- */sendTelegramOTP(t){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t)throw new o("Phone number is required");yield this.unlinkTelegram();const e=yield fetch(`${w}/telegram/sendOTP-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t})}).then((t=>t.json()));if(e.isError)throw new o(e.message||"Failed to send Telegram OTP");return e.data}))}
260
+ */sendTelegramOTP(e){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!e)throw new o("Phone number is required");yield this.unlinkTelegram();const t=yield fetch(`${w}/telegram/sendOTP-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:e})}).then((e=>e.json()));if(t.isError)throw new o(t.message||"Failed to send Telegram OTP");return t.data}))}
251
261
  /**
252
262
  * Link the user's Telegram account.
253
263
  * @param {string} phoneNumber The user's phone number.
@@ -255,37 +265,37 @@ window.location.href=`${w}/spotify/connect?clientId=${this.clientId}&userId=${th
255
265
  * @param {string} phoneCodeHash The phone code hash.
256
266
  * @returns {Promise<object>} A promise that resolves with the Telegram account data.
257
267
  * @throws {APIError|Error} - Throws an error if the user is not authenticated. Also throws an error if the phone number, OTP, and phone code hash are not provided.
258
- */linkTelegram(t,e,n){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!t||!e||!n)throw new o("Phone number, OTP, and phone code hash are required");const i=yield fetch(`${w}/telegram/signIn-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:t,code:e,phone_code_hash:n,userId:this.userId,clientId:this.clientId})}).then((t=>t.json()));if(i.isError)throw new o(i.message||"Failed to link Telegram account");return r(this,H,"m",nt).call(this,v.TELEGRAM_LINKED,"Telegram Linked"),i.data}))}
268
+ */linkTelegram(e,t,n){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!e||!t||!n)throw new o("Phone number, OTP, and phone code hash are required");const i=yield fetch(`${w}/telegram/signIn-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:e,code:t,phone_code_hash:n,userId:this.userId,clientId:this.clientId})}).then((e=>e.json()));if(i.isError)throw new o(i.message||"Failed to link Telegram account");return r(this,H,"m",ne).call(this,v.TELEGRAM_LINKED,"Telegram Linked"),i.data}))}
259
269
  /**
260
270
  * Unlink the user's Twitter account.
261
271
  * @returns {Promise<any>} A promise that resolves with the unlink result.
262
272
  * @throws {Error} - Throws an error if the user is not authenticated.
263
273
  * @throws {APIError} - Throws an error if the request fails.
264
- */unlinkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${w}/twitter/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Twitter account");return t.data}))}
274
+ */unlinkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${w}/twitter/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((e=>e.json()));if(e.isError)throw new o(e.message||"Failed to unlink Twitter account");return e.data}))}
265
275
  /**
266
276
  * Unlink the user's Discord account.
267
277
  * @returns {Promise<any>} A promise that resolves with the unlink result.
268
278
  * @throws {Error} - Throws an error if the user is not authenticated.
269
279
  * @throws {APIError} - Throws an error if the request fails.
270
- */unlinkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/discord/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Discord account");return t.data}))}
280
+ */unlinkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const e=yield fetch(`${w}/discord/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((e=>e.json()));if(e.isError)throw new o(e.message||"Failed to unlink Discord account");return e.data}))}
271
281
  /**
272
282
  * Unlink the user's Spotify account.
273
283
  * @returns {Promise<any>} A promise that resolves with the unlink result.
274
284
  * @throws {Error} - Throws an error if the user is not authenticated.
275
285
  * @throws {APIError} - Throws an error if the request fails.
276
- */unlinkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/spotify/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Spotify account");return t.data}))}
286
+ */unlinkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const e=yield fetch(`${w}/spotify/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((e=>e.json()));if(e.isError)throw new o(e.message||"Failed to unlink Spotify account");return e.data}))}
277
287
  /**
278
288
  * Unlink the user's TikTok account.
279
289
  * @returns {Promise<any>} A promise that resolves with the unlink result.
280
290
  * @throws {Error} - Throws an error if the user is not authenticated.
281
291
  * @throws {APIError} - Throws an error if the request fails.
282
- */unlinkTikTok(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/tiktok/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink TikTok account");return t.data}))}
292
+ */unlinkTikTok(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const e=yield fetch(`${w}/tiktok/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((e=>e.json()));if(e.isError)throw new o(e.message||"Failed to unlink TikTok account");return e.data}))}
283
293
  /**
284
294
  * Unlink the user's Telegram account.
285
295
  * @returns {Promise<any>} A promise that resolves with the unlink result.
286
296
  * @throws {Error} - Throws an error if the user is not authenticated.
287
297
  * @throws {APIError} - Throws an error if the request fails.
288
- */unlinkTelegram(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const t=yield fetch(`${w}/telegram/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((t=>t.json()));if(t.isError)throw new o(t.message||"Failed to unlink Telegram account");return t.data}))}},exports.SpotifyAPI=
298
+ */unlinkTelegram(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new o("User needs to be authenticated");const e=yield fetch(`${w}/telegram/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((e=>e.json()));if(e.isError)throw new o(e.message||"Failed to unlink Telegram account");return e.data}))}},exports.SpotifyAPI=
289
299
  /**
290
300
  * The SpotifyAPI class.
291
301
  * @class
@@ -298,57 +308,57 @@ class{
298
308
  * @param {string} options.apiKey - The Spotify API key.
299
309
  * @throws {Error} - Throws an error if the API key is not provided.
300
310
  */
301
- constructor(t){this.apiKey=t.apiKey}
311
+ constructor(e){this.apiKey=e.apiKey}
302
312
  /**
303
313
  * Fetch the user's saved tracks by Spotify user ID.
304
314
  * @param {string} spotifyId - The user's Spotify ID.
305
315
  * @returns {Promise<object>} - The saved tracks.
306
316
  * @throws {APIError} - Throws an error if the request fails.
307
- */fetchSavedTracksById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/save-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
317
+ */fetchSavedTracksById(e){return a(this,void 0,void 0,(function*(){const t=u(`${p}/save-tracks`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
308
318
  /**
309
319
  * Fetch the played tracks of a user by Spotify ID.
310
320
  * @param {string} spotifyId - The user's Spotify ID.
311
321
  * @returns {Promise<object>} - The played tracks.
312
322
  * @throws {APIError} - Throws an error if the request fails.
313
- */fetchPlayedTracksById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/played-tracks`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
323
+ */fetchPlayedTracksById(e){return a(this,void 0,void 0,(function*(){const t=u(`${p}/played-tracks`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
314
324
  /**
315
325
  * Fetch the user's saved albums by Spotify user ID.
316
326
  * @param {string} spotifyId - The user's Spotify ID.
317
327
  * @returns {Promise<object>} - The saved albums.
318
328
  * @throws {APIError} - Throws an error if the request fails.
319
- */fetchSavedAlbumsById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/saved-albums`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
329
+ */fetchSavedAlbumsById(e){return a(this,void 0,void 0,(function*(){const t=u(`${p}/saved-albums`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
320
330
  /**
321
331
  * Fetch the user's saved playlists by Spotify user ID.
322
332
  * @param {string} spotifyId - The user's Spotify ID.
323
333
  * @returns {Promise<object>} - The saved playlists.
324
334
  * @throws {APIError} - Throws an error if the request fails.
325
- */fetchSavedPlaylistsById(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/saved-playlists`,{spotifyId:t});return this._fetchDataWithAuth(e)}))}
335
+ */fetchSavedPlaylistsById(e){return a(this,void 0,void 0,(function*(){const t=u(`${p}/saved-playlists`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
326
336
  /**
327
337
  * Fetch the tracks of an album by album ID.
328
338
  * @param {string} spotifyId - The Spotify ID of the user.
329
339
  * @param {string} albumId - The album ID.
330
340
  * @returns {Promise<object>} - The tracks in the album.
331
341
  * @throws {APIError} - Throws an error if the request fails.
332
- */fetchTracksInAlbum(t,e){return a(this,void 0,void 0,(function*(){const n=u(`${p}/album/tracks`,{spotifyId:t,albumId:e});return this._fetchDataWithAuth(n)}))}
342
+ */fetchTracksInAlbum(e,t){return a(this,void 0,void 0,(function*(){const n=u(`${p}/album/tracks`,{spotifyId:e,albumId:t});return this._fetchDataWithAuth(n)}))}
333
343
  /**
334
344
  * Fetch the tracks in a playlist by playlist ID.
335
345
  * @param {string} spotifyId - The Spotify ID of the user.
336
346
  * @param {string} playlistId - The playlist ID.
337
347
  * @returns {Promise<object>} - The tracks in the playlist.
338
348
  * @throws {APIError} - Throws an error if the request fails.
339
- */fetchTracksInPlaylist(t,e){return a(this,void 0,void 0,(function*(){const n=u(`${p}/playlist/tracks`,{spotifyId:t,playlistId:e});return this._fetchDataWithAuth(n)}))}
349
+ */fetchTracksInPlaylist(e,t){return a(this,void 0,void 0,(function*(){const n=u(`${p}/playlist/tracks`,{spotifyId:e,playlistId:t});return this._fetchDataWithAuth(n)}))}
340
350
  /**
341
351
  * Fetch the user's Spotify data by wallet address.
342
352
  * @param {string} walletAddress - The wallet address.
343
353
  * @returns {Promise<object>} - The user's Spotify data.
344
354
  * @throws {APIError} - Throws an error if the request fails.
345
- */fetchUserByWalletAddress(t){return a(this,void 0,void 0,(function*(){const e=u(`${p}/wallet-spotify-data`,{walletAddress:t});return this._fetchDataWithAuth(e)}))}
355
+ */fetchUserByWalletAddress(e){return a(this,void 0,void 0,(function*(){const t=u(`${p}/wallet-spotify-data`,{walletAddress:e});return this._fetchDataWithAuth(t)}))}
346
356
  /**
347
357
  * Private method to fetch data with authorization header.
348
358
  * @param {string} url - The URL to fetch.
349
359
  * @returns {Promise<object>} - The response data.
350
360
  * @throws {APIError} - Throws an error if the request fails.
351
- */_fetchDataWithAuth(t){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new o("API key is required for fetching data",401);try{return yield d(t,{"x-api-key":this.apiKey})}catch(t){throw new o(t.message,t.statusCode)}}))}},exports.TwitterAPI=
361
+ */_fetchDataWithAuth(e){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new o("API key is required for fetching data",401);try{return yield d(e,{"x-api-key":this.apiKey})}catch(e){throw new o(e.message,e.statusCode)}}))}},exports.TwitterAPI=
352
362
  /**
353
363
  * The TwitterAPI class.
354
364
  * @class
@@ -360,13 +370,13 @@ class{
360
370
  * @param {object} options - The options object.
361
371
  * @param {string} options.apiKey - The API key. (Needed for data fetching)
362
372
  */
363
- constructor({apiKey:t}){this.apiKey=t}
373
+ constructor({apiKey:e}){this.apiKey=e}
364
374
  /**
365
375
  * Fetch Twitter user details by username.
366
376
  * @param {string} twitterUserName - The Twitter username.
367
377
  * @returns {Promise<object>} - The user details.
368
378
  * @throws {APIError} - Throws an error if the request fails.
369
- */fetchUserByUsername(t){return a(this,void 0,void 0,(function*(){const e=u(`${l}/user`,{twitterUserName:t});return this._fetchDataWithAuth(e)}))}
379
+ */fetchUserByUsername(e){return a(this,void 0,void 0,(function*(){const t=u(`${l}/user`,{twitterUserName:e});return this._fetchDataWithAuth(t)}))}
370
380
  /**
371
381
  * Fetch tweets by Twitter username.
372
382
  * @param {string} twitterUserName - The Twitter username.
@@ -374,7 +384,7 @@ constructor({apiKey:t}){this.apiKey=t}
374
384
  * @param {number} limit - The number of items per page.
375
385
  * @returns {Promise<object>} - The tweets.
376
386
  * @throws {APIError} - Throws an error if the request fails.
377
- */fetchTweetsByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/tweets`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
387
+ */fetchTweetsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/tweets`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
378
388
  /**
379
389
  * Fetch followers by Twitter username.
380
390
  * @param {string} twitterUserName - The Twitter username.
@@ -382,7 +392,7 @@ constructor({apiKey:t}){this.apiKey=t}
382
392
  * @param {number} limit - The number of items per page.
383
393
  * @returns {Promise<object>} - The followers.
384
394
  * @throws {APIError} - Throws an error if the request fails.
385
- */fetchFollowersByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/followers`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
395
+ */fetchFollowersByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/followers`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
386
396
  /**
387
397
  * Fetch following by Twitter username.
388
398
  * @param {string} twitterUserName - The Twitter username.
@@ -390,13 +400,13 @@ constructor({apiKey:t}){this.apiKey=t}
390
400
  * @param {number} limit - The number of items per page.
391
401
  * @returns {Promise<object>} - The following.
392
402
  * @throws {APIError} - Throws an error if the request fails.
393
- */fetchFollowingByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/following`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
403
+ */fetchFollowingByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/following`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
394
404
  /**
395
405
  * Fetch tweet by tweet ID.
396
406
  * @param {string} tweetId - The tweet ID.
397
407
  * @returns {Promise<object>} - The tweet.
398
408
  * @throws {APIError} - Throws an error if the request fails.
399
- */fetchTweetById(t){return a(this,void 0,void 0,(function*(){const e=u(`${l}/getTweetById`,{tweetId:t});return this._fetchDataWithAuth(e)}))}
409
+ */fetchTweetById(e){return a(this,void 0,void 0,(function*(){const t=u(`${l}/getTweetById`,{tweetId:e});return this._fetchDataWithAuth(t)}))}
400
410
  /**
401
411
  * Fetch user by wallet address.
402
412
  * @param {string} walletAddress - The wallet address.
@@ -404,7 +414,7 @@ constructor({apiKey:t}){this.apiKey=t}
404
414
  * @param {number} limit - The number of items per page.
405
415
  * @returns {Promise<object>} - The user data.
406
416
  * @throws {APIError} - Throws an error if the request fails.
407
- */fetchUserByWalletAddress(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/wallet-twitter-data`,{walletAddress:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
417
+ */fetchUserByWalletAddress(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/wallet-twitter-data`,{walletAddress:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
408
418
  /**
409
419
  * Fetch reposted tweets by Twitter username.
410
420
  * @param {string} twitterUserName - The Twitter username.
@@ -412,7 +422,7 @@ constructor({apiKey:t}){this.apiKey=t}
412
422
  * @param {number} limit - The number of items per page.
413
423
  * @returns {Promise<object>} - The reposted tweets.
414
424
  * @throws {APIError} - Throws an error if the request fails.
415
- */fetchRepostedByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/reposted`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
425
+ */fetchRepostedByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/reposted`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
416
426
  /**
417
427
  * Fetch replies by Twitter username.
418
428
  * @param {string} twitterUserName - The Twitter username.
@@ -420,7 +430,7 @@ constructor({apiKey:t}){this.apiKey=t}
420
430
  * @param {number} limit - The number of items per page.
421
431
  * @returns {Promise<object>} - The replies.
422
432
  * @throws {APIError} - Throws an error if the request fails.
423
- */fetchRepliesByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/replies`,{twitterUserName:t,page:e,limit:n});return this._fetchDataWithAuth(i)}))}
433
+ */fetchRepliesByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/replies`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
424
434
  /**
425
435
  * Fetch likes by Twitter username.
426
436
  * @param {string} twitterUserName - The Twitter username.
@@ -428,7 +438,7 @@ constructor({apiKey:t}){this.apiKey=t}
428
438
  * @param {number} limit - The number of items per page.
429
439
  * @returns {Promise<object>} - The likes.
430
440
  * @throws {APIError} - Throws an error if the request fails.
431
- */fetchLikesByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/event/likes/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
441
+ */fetchLikesByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/event/likes/${e}`,{page:t,limit:n});return this._fetchDataWithAuth(i)}))}
432
442
  /**
433
443
  * Fetch follows by Twitter username.
434
444
  * @param {string} twitterUserName - The Twitter username.
@@ -436,7 +446,7 @@ constructor({apiKey:t}){this.apiKey=t}
436
446
  * @param {number} limit - The number of items per page.
437
447
  * @returns {Promise<object>} - The follows.
438
448
  * @throws {APIError} - Throws an error if the request fails.
439
- */fetchFollowsByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/event/follows/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
449
+ */fetchFollowsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/event/follows/${e}`,{page:t,limit:n});return this._fetchDataWithAuth(i)}))}
440
450
  /**
441
451
  * Fetch viewed tweets by Twitter username.
442
452
  * @param {string} twitterUserName - The Twitter username.
@@ -444,10 +454,10 @@ constructor({apiKey:t}){this.apiKey=t}
444
454
  * @param {number} limit - The number of items per page.
445
455
  * @returns {Promise<object>} - The viewed tweets.
446
456
  * @throws {APIError} - Throws an error if the request fails.
447
- */fetchViewedTweetsByUsername(t){return a(this,arguments,void 0,(function*(t,e=1,n=10){const i=u(`${l}/event/viewed-tweets/${t}`,{page:e,limit:n});return this._fetchDataWithAuth(i)}))}
457
+ */fetchViewedTweetsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=u(`${l}/event/viewed-tweets/${e}`,{page:t,limit:n});return this._fetchDataWithAuth(i)}))}
448
458
  /**
449
459
  * Private method to fetch data with authorization header.
450
460
  * @param {string} url - The URL to fetch.
451
461
  * @returns {Promise<object>} - The response data.
452
462
  * @throws {APIError} - Throws an error if the request fails.
453
- */_fetchDataWithAuth(t){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new o("API key is required for fetching data",401);try{return yield d(t,{"x-api-key":this.apiKey})}catch(t){throw new o(t.message,t.statusCode)}}))}};
463
+ */_fetchDataWithAuth(e){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new o("API key is required for fetching data",401);try{return yield d(e,{"x-api-key":this.apiKey})}catch(e){throw new o(e.message,e.statusCode)}}))}};