@campnetwork/origin 0.0.17 → 1.0.0-alpha.1
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 +84 -105
- package/dist/core.d.ts +28 -9
- package/dist/core.esm.d.ts +28 -9
- package/dist/core.esm.js +88 -109
- package/dist/react/components/toasts.d.ts +10 -0
- package/dist/react/index.esm.d.ts +33 -10
- package/dist/react/index.esm.js +1455 -750
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -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(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)}
|
|
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"==typeof SuppressedError&&SuppressedError;class s 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(e,t,n,i){return new(n||(n=Promise))((function(a,r){function s(e){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
|
|
25
|
+
*/function o(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 s(e.response.data.message||"API request failed",e.response.status);throw new s("Network error or server is unavailable",500)}}))}
|
|
26
26
|
/**
|
|
27
27
|
* Constructs a query string from an object of query parameters.
|
|
28
28
|
*
|
|
@@ -36,67 +36,65 @@ function a(e,t,n,i){return new(n||(n=Promise))((function(a,r){function s(e){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
|
|
39
|
+
function d(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 u="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",p="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";const l={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=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",T={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"},v="0xF90733b9eCDa3b49C250B2C3E3E42c96fC93324E",b="0x5c5e6b458b2e3924E7688b8Dee1Bb49088F6Fef5";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"},{internalType:"uint256",name:"maxTermDuration_",type:"uint256"},{internalType:"address",name:"signer_",type:"address"}],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:[],name:"InvalidDuration",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:[],name:"maxTermDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"to",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"parentId",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:[{internalType:"uint256",name:"",type:"uint256"}],name:"parentIpOf",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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:"address",name:"_signer",type:"address"}],name:"setSigner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"signer",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",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"}];
|
|
41
|
+
let y=null,c=null;const h=()=>(c||(c=t.createPublicClient({chain:l,transport:t.http()})),c);var m=[{inputs:[{internalType:"string",name:"name_",type:"string"},{internalType:"string",name:"symbol_",type:"string"},{internalType:"uint256",name:"maxTermDuration_",type:"uint256"},{internalType:"address",name:"signer_",type:"address"},{internalType:"address",name:"wCAMP_",type:"address"},{internalType:"uint256",name:"minTermDuration_",type:"uint256"},{internalType:"uint256",name:"minPrice_",type:"uint256"},{internalType:"uint256",name:"maxRoyaltyBps_",type:"uint256"}],stateMutability:"nonpayable",type:"constructor"},{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:[],name:"InvalidDuration",type:"error"},{inputs:[],name:"InvalidPaymentToken",type:"error"},{inputs:[],name:"InvalidPrice",type:"error"},{inputs:[],name:"InvalidRoyalty",type:"error"},{inputs:[],name:"InvalidSignature",type:"error"},{inputs:[],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:"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:"id",type:"uint256"},{indexed:!0,internalType:"uint256",name:"childIp",type:"uint256"},{indexed:!1,internalType:"uint256",name:"parentIp",type:"uint256"}],name:"ChildIpTagged",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"},{indexed:!1,internalType:"uint256[]",name:"parents",type:"uint256[]"}],name:"DataMinted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"id",type:"uint256"},{indexed:!1,internalType:"bytes32",name:"counterEvidenceHash",type:"bytes32"}],name:"DisputeAssertion",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"id",type:"uint256"}],name:"DisputeCancelled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"id",type:"uint256"},{indexed:!1,internalType:"bool",name:"judgement",type:"bool"}],name:"DisputeJudged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"disputeModule",type:"address"}],name:"DisputeModuleUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"id",type:"uint256"},{indexed:!0,internalType:"address",name:"initiator",type:"address"},{indexed:!0,internalType:"uint256",name:"targetId",type:"uint256"},{indexed:!1,internalType:"bytes32",name:"disputeTag",type:"bytes32"}],name:"DisputeRaised",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"marketPlace",type:"address"}],name:"MarketPlaceUpdated",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:"address",name:"signer",type:"address"}],name:"SignerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"enum IIpNFT.DataStatus",name:"status",type:"uint8"}],name:"StatusUpdated",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:"tokenId",type:"uint256"}],name:"dataStatus",outputs:[{internalType:"enum IIpNFT.DataStatus",name:"",type:"uint8"}],stateMutability:"view",type:"function"},{inputs:[],name:"disputeModule",outputs:[{internalType:"address",name:"",type:"address"}],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:"address",name:"tokenOwner",type:"address"}],name:"getOrCreateRoyaltyVault",outputs:[{internalType:"address",name:"vault",type:"address"}],stateMutability:"nonpayable",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 IIpNFT.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:"uint256",name:"_tokenId",type:"uint256"}],name:"markDisputed",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"marketPlace",outputs:[{internalType:"contract IMarketplace",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxRoyaltyBps",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"maxTermDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"minPrice",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"minTermDuration",outputs:[{internalType:"uint256",name:"",type:"uint256"}],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 IIpNFT.LicenseTerms",name:"licenseTerms",type:"tuple"},{internalType:"uint256",name:"deadline",type:"uint256"},{internalType:"uint256[]",name:"parents",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:"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:"address",name:"_disputeModule",type:"address"}],name:"setDisputeModule",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_marketPlace",type:"address"}],name:"setMarketPlace",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"address",name:"_signer",type:"address"}],name:"setSigner",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"signer",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",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:"tokenInfo",outputs:[{internalType:"string",name:"tokenURI",type:"string"},{internalType:"bytes32",name:"contentHash",type:"bytes32"},{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 IIpNFT.LicenseTerms",name:"terms",type:"tuple"},{internalType:"enum IIpNFT.DataStatus",name:"status",type:"uint8"}],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"},{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 IIpNFT.LicenseTerms",name:"newTerms",type:"tuple"}],name:"updateTerms",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[],name:"wCAMP",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"}],T=[{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:[],name:"InvalidParentIp",type:"error"},{inputs:[],name:"InvalidPayment",type:"error"},{inputs:[],name:"InvalidRoyalty",type:"error"},{inputs:[],name:"MaxParentsExceeded",type:"error"},{inputs:[],name:"MaxRoyaltyExceeded",type:"error"},{inputs:[],name:"NoSubscriptionFound",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:"ParentAlreadyExists",type:"error"},{inputs:[],name:"ParentIpAlreadyDeleted",type:"error"},{inputs:[],name:"ParentIpAlreadyDisputed",type:"error"},{inputs:[],name:"TermsMismatch",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:"id",type:"uint256"},{indexed:!0,internalType:"uint256",name:"childIp",type:"uint256"},{indexed:!1,internalType:"uint256",name:"parentIp",type:"uint256"}],name:"ChildIpTagged",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:"uint256",name:"id",type:"uint256"},{indexed:!1,internalType:"bytes32",name:"counterEvidenceHash",type:"bytes32"}],name:"DisputeAssertion",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"id",type:"uint256"}],name:"DisputeCancelled",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"id",type:"uint256"},{indexed:!1,internalType:"bool",name:"judgement",type:"bool"}],name:"DisputeJudged",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"disputeModule",type:"address"}],name:"DisputeModuleUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"id",type:"uint256"},{indexed:!0,internalType:"address",name:"initiator",type:"address"},{indexed:!0,internalType:"uint256",name:"targetId",type:"uint256"},{indexed:!1,internalType:"bytes32",name:"disputeTag",type:"bytes32"}],name:"DisputeRaised",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"marketPlace",type:"address"}],name:"MarketPlaceUpdated",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:"address",name:"signer",type:"address"}],name:"SignerUpdated",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"uint256",name:"tokenId",type:"uint256"},{indexed:!1,internalType:"enum IIpNFT.DataStatus",name:"status",type:"uint8"}],name:"StatusUpdated",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:[],name:"MAX_PARENTS",outputs:[{internalType:"uint256",name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"address",name:"buyer",type:"address"},{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"expectedPrice",type:"uint256"},{internalType:"uint32",name:"expectedDuration",type:"uint32"},{internalType:"address",name:"expectedPaymentToken",type:"address"}],name:"buyAccess",outputs:[],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256",name:"ipId",type:"uint256"},{internalType:"uint256",name:"parent",type:"uint256"}],name:"hasParentIp",outputs:[{internalType:"bool",name:"",type:"bool"}],stateMutability:"view",type:"function"},{inputs:[],name:"ipToken",outputs:[{internalType:"contract IIpNFT",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"owner",outputs:[{internalType:"address",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"},{internalType:"uint256",name:"",type:"uint256"}],name:"parentRoyaltyPercent",outputs:[{internalType:"uint16",name:"",type:"uint16"}],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:[],name:"renounceOwnership",outputs:[],stateMutability:"nonpayable",type:"function"},{inputs:[{internalType:"uint256",name:"",type:"uint256"}],name:"royaltyStack",outputs:[{internalType:"uint16",name:"",type:"uint16"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256",name:"childIpId",type:"uint256"},{internalType:"uint256[]",name:"parents",type:"uint256[]"},{internalType:"address",name:"creator",type:"address"}],name:"setParentIpsAndRoyaltyPercents",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"}],f="Connect with Camp Network",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"};const w={DEVELOPMENT:{NAME:"DEVELOPMENT",AUTH_HUB_BASE_API:"https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",AUTH_ENDPOINT:"auth-testnet",ORIGIN_DASHBOARD:"https://origin.campnetwork.xyz",DATANFT_CONTRACT_ADDRESS:"0x8EB0E8C3bA99c04F05ab01A5BED34F00c6c3BE4D",MARKETPLACE_CONTRACT_ADDRESS:"0x2947eE8a352158fda08F2cf5c0AE8e5b1DFCfDc9",CHAIN:l,IPNFT_ABI:m,MARKETPLACE_ABI:T},PRODUCTION:{NAME:"PRODUCTION",AUTH_HUB_BASE_API:"https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",AUTH_ENDPOINT:"auth-mainnet",ORIGIN_DASHBOARD:"https://origin.campnetwork.xyz",DATANFT_CONTRACT_ADDRESS:"0x54d8490f034e3A4D07CD220a7Dc88D9B91B82c25",MARKETPLACE_CONTRACT_ADDRESS:"0x5D2be63c94931f82B602Ecd1538064ab4196F8e7",CHAIN:{id:484,name:"Camp Network",nativeCurrency:{decimals:18,name:"Camp",symbol:"CAMP"},rpcUrls:{default:{http:["https://rpc.camp.raas.gelato.cloud/"]}},blockExplorers:{default:{name:"Explorer",url:"https://camp.cloud.blockscout.com/"}}},IPNFT_ABI:m,MARKETPLACE_ABI:T}};let A=[];const I=()=>A,g=e=>{function t(t){A.some((e=>e.info.uuid===t.detail.info.uuid))||(A=[...A,t.detail],e(A))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)};
|
|
42
42
|
/**
|
|
43
43
|
* Mints a Data NFT with a signature.
|
|
44
44
|
* @param to The address to mint the NFT to.
|
|
45
45
|
* @param tokenId The ID of the token to mint.
|
|
46
|
-
* @param
|
|
46
|
+
* @param parents The IDs of the parent NFTs, if applicable.
|
|
47
47
|
* @param hash The hash of the data associated with the NFT.
|
|
48
48
|
* @param uri The URI of the NFT metadata.
|
|
49
49
|
* @param licenseTerms The terms of the license for the NFT.
|
|
50
50
|
* @param deadline The deadline for the minting operation.
|
|
51
51
|
* @param signature The signature for the minting operation.
|
|
52
52
|
* @returns A promise that resolves when the minting is complete.
|
|
53
|
-
*/function
|
|
53
|
+
*/function b(e,t,n,i,r,s,o,d){return a(this,void 0,void 0,(function*(){return yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"mintWithSignature",[e,t,i,r,s,o,n,d],{waitForReceipt:!0})}))}
|
|
54
54
|
/**
|
|
55
55
|
* Registers a Data NFT with the Origin service in order to obtain a signature for minting.
|
|
56
56
|
* @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
|
|
57
57
|
* @param deadline The deadline for the registration operation.
|
|
58
58
|
* @param fileKey Optional file key for file uploads.
|
|
59
59
|
* @return A promise that resolves with the registration data.
|
|
60
|
-
*/function E(e,t,n,i,r,s){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},metadata:i,parentId:
|
|
60
|
+
*/function E(e,t,n,i,r,s){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},metadata:i,parentId:s||[]};void 0!==r&&(a.fileKey=r);const o=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/register`,{method:"POST",headers:{Authorization:`Bearer ${this.getJwt()}`,"Content-Type":"application/json"},body:JSON.stringify(a)});if(!o.ok)throw new Error(`Failed to get signature: ${o.statusText}`);const d=yield o.json();if(d.isError)throw new Error(`Failed to get signature: ${d.message}`);return d.data}))}function _(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"updateTerms",[e,t,n],{waitForReceipt:!0})}function C(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"finalizeDelete",[e])}function S(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getTerms",[e])}function k(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"ownerOf",[e])}function D(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"balanceOf",[e])}function N(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"contentHash",[e])}function P(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenURI",[e])}function x(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"dataStatus",[e])}function M(e,t){return a(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"royaltyInfo",[e,t])}))}function U(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getApproved",[e])}function O(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"isApprovedForAll",[e,t])}function B(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"transferFrom",[e,t,n])}function F(e,t,n,i){const a=i?[e,t,n,i]:[e,t,n];return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"safeTransferFrom",a)}function R(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"approve",[e,t])}function $(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"setApprovalForAll",[e,t])}function H(e,t,n,i,a,r){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"buyAccess",[e,t,n,i,a],{waitForReceipt:!0,value:r})}function j(e,t,n,i){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"renewAccess",[e,t,n],void 0!==i?{value:i}:void 0)}function L(e,t){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"hasAccess",[e,t])}function W(e,t){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"subscriptionExpiry",[e,t])}
|
|
61
61
|
/**
|
|
62
62
|
* Approves a spender to spend a specified amount of tokens on behalf of the owner.
|
|
63
63
|
* If the current allowance is less than the specified amount, it will perform the approval.
|
|
64
64
|
* @param {ApproveParams} params - The parameters for the approval.
|
|
65
|
-
*/
|
|
65
|
+
*/var q,K,z,J,V,G,X,Y,Z,Q,ee,te,ne,ie,ae;
|
|
66
66
|
/**
|
|
67
67
|
* The Origin class
|
|
68
68
|
* Handles the upload of files to Origin, as well as querying the user's stats
|
|
69
|
-
*/
|
|
70
|
-
|
|
71
|
-
if(!(
|
|
72
|
-
if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const[l]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),p=yield this.mintWithSignature(l,r,BigInt(0),// parentId is not applicable for social IpNFTs
|
|
73
|
-
o,u,n,i,d);if("0x1"!==p.status)throw new Error(`Minting Social IpNFT failed with status: ${p.status}`);return r.toString()})),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,
|
|
69
|
+
*/class re{constructor(t,n,i){q.add(this),K.set(this,(e=>a(this,void 0,void 0,(function*(){try{const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/upload-url`,{method:"POST",body:JSON.stringify({name:e.name,type:e.type}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!t.ok)throw new Error(`HTTP ${t.status}: ${t.statusText}`);const n=yield t.json();if(n.isError)throw new Error(n.message||"Failed to generate upload URL");return n.data}catch(e){throw console.error("Failed to generate upload URL:",e),e}})))),z.set(this,((e,t)=>a(this,void 0,void 0,(function*(){try{const n=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/update-status`,{method:"PATCH",body:JSON.stringify({status:t,fileKey:e}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!n.ok){const e=yield n.text().catch((()=>"Unknown error"));throw new Error(`HTTP ${n.status}: ${e}`)}return!0}catch(e){throw console.error("Failed to update origin status:",e),e}})))),this.uploadFile=(t,n)=>a(this,void 0,void 0,(function*(){let i;try{i=yield r(this,K,"f").call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield r(this,z,"f").call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield r(this,z,"f").call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i})),this.mintFile=(e,t,n,i,r)=>a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const a=yield this.uploadFile(e,r);if(!a||!a.key)throw new Error("Failed to upload file or get upload info.");const s=BigInt(Date.now()+6e5),o=yield this.registerIpNFT("file",s,n,t,a.key,i),{tokenId:d,signerAddress:u,creatorContentHash:p,signature:l,uri:y}=o;// 10 minutes from now
|
|
70
|
+
if(console.log("[Origin MintFile] Sent payload:",{type:"file",deadline:s,license:n,metadata:t,key:a.key,parents:i}),console.log("[Origin MintFile] Registration response:",o),!(d&&u&&p&&void 0!==l&&y))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");const[c]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if("0x1"!==h.status)throw console.error("Minting failed:",h),new Error(`Minting failed with status: ${h.status}`);return d.toString()})),this.mintSocial=(e,t,n)=>a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=BigInt(Math.floor(Date.now()/1e3)+600),a=yield this.registerIpNFT(e,i,n,t),{tokenId:r,signerAddress:s,creatorContentHash:o,signature:d,uri:u}=a;// 10 minutes from now
|
|
71
|
+
if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const[p]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),l=yield this.mintWithSignature(p,r,[],o,u,n,i,d);if("0x1"!==l.status)throw new Error(`Minting Social IpNFT failed with status: ${l.status}`);return r.toString()})),this.getOriginUploads=()=>a(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data})),this.jwt=t,this.viemClient=i,this.environment=n,
|
|
74
72
|
// DataNFT methods
|
|
75
|
-
this.mintWithSignature=
|
|
73
|
+
this.mintWithSignature=b.bind(this),this.registerIpNFT=E.bind(this),this.updateTerms=_.bind(this),this.requestDelete=C.bind(this),this.getTerms=S.bind(this),this.ownerOf=k.bind(this),this.balanceOf=D.bind(this),this.contentHash=N.bind(this),this.tokenURI=P.bind(this),this.dataStatus=x.bind(this),this.royaltyInfo=M.bind(this),this.getApproved=U.bind(this),this.isApprovedForAll=O.bind(this),this.transferFrom=B.bind(this),this.safeTransferFrom=F.bind(this),this.approve=R.bind(this),this.setApprovalForAll=$.bind(this),
|
|
76
74
|
// Marketplace methods
|
|
77
|
-
this.buyAccess=
|
|
75
|
+
this.buyAccess=H.bind(this),this.renewAccess=j.bind(this),this.hasAccess=L.bind(this),this.subscriptionExpiry=W.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}
|
|
78
76
|
/**
|
|
79
77
|
* Get the user's Origin stats (multiplier, consent, usage, etc.).
|
|
80
78
|
* @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
|
|
81
|
-
*/getOriginUsage(){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${
|
|
79
|
+
*/getOriginUsage(){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/usage`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,
|
|
82
80
|
// "x-client-id": this.clientId,
|
|
83
|
-
"Content-Type":"application/json"}}).then((e=>e.json()));if(!e.isError&&e.data.user)return e;throw new
|
|
81
|
+
"Content-Type":"application/json"}}).then((e=>e.json()));if(!e.isError&&e.data.user)return e;throw new s(e.message||"Failed to fetch Origin usage")}))}
|
|
84
82
|
/**
|
|
85
83
|
* Set the user's consent for Origin usage.
|
|
86
84
|
* @param {boolean} consent The user's consent.
|
|
87
85
|
* @returns {Promise<void>}
|
|
88
86
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
|
|
89
|
-
*/setOriginConsent(e){return a(this,void 0,void 0,(function*(){if(void 0===e)throw new
|
|
87
|
+
*/setOriginConsent(e){return a(this,void 0,void 0,(function*(){if(void 0===e)throw new s("Consent is required");const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/status`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
|
|
90
88
|
// "x-client-id": this.clientId,
|
|
91
|
-
"Content-Type":"application/json"},body:JSON.stringify({active:e})}).then((e=>e.json()));if(t.isError)throw new
|
|
89
|
+
"Content-Type":"application/json"},body:JSON.stringify({active:e})}).then((e=>e.json()));if(t.isError)throw new s(t.message||"Failed to set Origin consent")}))}
|
|
92
90
|
/**
|
|
93
91
|
* Set the user's Origin multiplier.
|
|
94
92
|
* @param {number} multiplier The user's Origin multiplier.
|
|
95
93
|
* @returns {Promise<void>}
|
|
96
94
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the multiplier is not provided.
|
|
97
|
-
*/setOriginMultiplier(e){return a(this,void 0,void 0,(function*(){if(void 0===e)throw new
|
|
95
|
+
*/setOriginMultiplier(e){return a(this,void 0,void 0,(function*(){if(void 0===e)throw new s("Multiplier is required");const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/multiplier`,{method:"PATCH",headers:{Authorization:`Bearer ${this.jwt}`,
|
|
98
96
|
// "x-client-id": this.clientId,
|
|
99
|
-
"Content-Type":"application/json"},body:JSON.stringify({multiplier:e})}).then((e=>e.json()));if(t.isError)throw new
|
|
97
|
+
"Content-Type":"application/json"},body:JSON.stringify({multiplier:e})}).then((e=>e.json()));if(t.isError)throw new s(t.message||"Failed to set Origin multiplier")}))}
|
|
100
98
|
/**
|
|
101
99
|
* Call a contract method.
|
|
102
100
|
* @param {string} contractAddress The contract address.
|
|
@@ -106,38 +104,16 @@ this.buyAccess=ae.bind(this),this.renewAccess=re.bind(this),this.hasAccess=se.bi
|
|
|
106
104
|
* @param {CallOptions} [options] The call options.
|
|
107
105
|
* @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
|
|
108
106
|
* @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
|
|
109
|
-
*/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=
|
|
107
|
+
*/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=h();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",V).call(this,this.environment.CHAIN);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",J).call(this,t)}catch(e){throw console.error("Transaction failed:",e),new Error("Transaction failed: "+e)}}}))}
|
|
110
108
|
/**
|
|
111
109
|
* Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
|
|
112
110
|
* @param {bigint} tokenId The token ID of the asset.
|
|
113
|
-
* @param {number} periods The number of periods to buy access for.
|
|
114
111
|
* @returns {Promise<any>} The result of the buyAccess call.
|
|
115
|
-
*/buyAccessSmart(e
|
|
112
|
+
*/buyAccessSmart(e){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const n=yield this.getTerms(e);if(!n)throw new Error("Failed to fetch terms for asset");const{price:i,paymentToken:r,duration:s}=n;if(void 0===i||void 0===r||void 0===s)throw new Error("Terms missing price, paymentToken, or duration");const[o]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]}),d=i;return r===t.zeroAddress?this.buyAccess(o,e,d,s,r,d):(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:l}))}))}({walletClient:this.viemClient,publicClient:h(),tokenAddress:r,owner:o,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:d}),this.buyAccess(o,e,d,s,r))}))}getData(e){return a(this,void 0,void 0,(function*(){const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/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()}))}}K=new WeakMap,z=new WeakMap,q=new WeakSet,J=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)))}}))},V=function(e){return a(this,void 0,void 0,(function*(){
|
|
116
113
|
// return;
|
|
117
114
|
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){
|
|
118
115
|
// Unrecognized chain
|
|
119
|
-
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)}]})}}))};
|
|
120
|
-
/*
|
|
121
|
-
let selectedProvider = provider;
|
|
122
|
-
|
|
123
|
-
if (!selectedProvider) {
|
|
124
|
-
const providers = providerStore.value() ?? [];
|
|
125
|
-
for (const p of providers) {
|
|
126
|
-
try {
|
|
127
|
-
const accounts = await p.provider.request({
|
|
128
|
-
method: "eth_requestAccounts",
|
|
129
|
-
});
|
|
130
|
-
if (accounts[0]?.toLowerCase() === walletAddress.toLowerCase()) {
|
|
131
|
-
selectedProvider = p;
|
|
132
|
-
break;
|
|
133
|
-
}
|
|
134
|
-
} catch (err) {
|
|
135
|
-
console.warn("Failed to fetch accounts from provider:", err);
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
*/
|
|
140
|
-
e&&this.setProvider({provider:e.provider,info:e.info||{name:"Unknown"},address:t})):this.isAuthenticated=!1}))},Q=function(){return a(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=t.checksumAddress(e),this.walletAddress}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){
|
|
116
|
+
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)}]})}}))};X=new WeakMap,Y=new WeakMap,G=new WeakSet,Z=function(e,t){r(this,X,"f")[e]&&r(this,X,"f")[e].forEach((e=>e(t)))},Q=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"),a=null===localStorage||void 0===localStorage?void 0:localStorage.getItem("camp-sdk:environment");t&&n&&i&&(a===this.environment.NAME||!a)?(this.walletAddress=t,this.userId=n,this.jwt=i,this.origin=new re(this.jwt,this.environment),this.isAuthenticated=!0,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}))},ee=function(){return a(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=t.checksumAddress(e),this.walletAddress}catch(e){throw new s(e)}}))},te=function(){return a(this,void 0,void 0,(function*(){try{const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/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)}}))},ne=function(e,t){return a(this,void 0,void 0,(function*(){try{const n=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/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 s(e)}}))},ie=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})},ae=function(e,t){return a(this,arguments,void 0,(function*(e,t,n=1){
|
|
141
117
|
// if (this.#ackeeInstance)
|
|
142
118
|
// await sendAnalyticsEvent(this.#ackeeInstance, event, message, count);
|
|
143
119
|
// else return;
|
|
@@ -155,13 +131,10 @@ class{
|
|
|
155
131
|
* @param {string|object} options.redirectUri The redirect URI used for oauth. Leave empty if you want to use the current URL. If you want different redirect URIs for different socials, pass an object with the socials as keys and the redirect URIs as values.
|
|
156
132
|
* @param {boolean} [options.allowAnalytics=true] Whether to allow analytics to be sent.
|
|
157
133
|
* @param {object} [options.ackeeInstance] The Ackee instance.
|
|
134
|
+
* @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
|
|
158
135
|
* @throws {APIError} - Throws an error if the clientId is not provided.
|
|
159
136
|
*/
|
|
160
|
-
constructor({clientId:e,redirectUri:t,allowAnalytics:n=!0,ackeeInstance:i}){if(
|
|
161
|
-
// if (typeof window !== "undefined") {
|
|
162
|
-
// if (window.ethereum) this.viem = getClient(window.ethereum);
|
|
163
|
-
// }
|
|
164
|
-
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)}
|
|
137
|
+
constructor({clientId:e,redirectUri:t,allowAnalytics:n=!0,ackeeInstance:i,environment:a="DEVELOPMENT"}){if(G.add(this),X.set(this,void 0),Y.set(this,void 0),!e)throw new Error("clientId is required");if(-1===["PRODUCTION","DEVELOPMENT"].indexOf(a))throw new Error("Invalid environment, must be DEVELOPMENT or PRODUCTION");this.viem=null,this.environment=w[a],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),this.clientId=e,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,function(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");"a"===i?a.call(e,n):a?a.value=n:t.set(e,n)}(this,X,{},"f"),g((e=>{r(this,G,"m",Z).call(this,"providers",e)})),r(this,G,"m",Q).call(this)}
|
|
165
138
|
/**
|
|
166
139
|
* Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
|
|
167
140
|
* @param {("state"|"provider"|"providers"|"viem")} event The event.
|
|
@@ -171,34 +144,55 @@ this.redirectUri=(e=>{const t=["twitter","discord","spotify"];return"object"==ty
|
|
|
171
144
|
* auth.on("state", (state) => {
|
|
172
145
|
* console.log(state);
|
|
173
146
|
* });
|
|
174
|
-
*/on(e,t){r(this,
|
|
147
|
+
*/on(e,t){r(this,X,"f")[e]||(r(this,X,"f")[e]=[]),r(this,X,"f")[e].push(t),"providers"===e&&t(I())}
|
|
175
148
|
/**
|
|
176
149
|
* Set the loading state.
|
|
177
150
|
* @param {boolean} loading The loading state.
|
|
178
151
|
* @returns {void}
|
|
179
|
-
*/setLoading(e){r(this,
|
|
152
|
+
*/setLoading(e){r(this,G,"m",Z).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
|
|
180
153
|
/**
|
|
181
154
|
* 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.
|
|
182
155
|
* @param {object} options The options object. Includes the provider and the provider info.
|
|
183
156
|
* @returns {void}
|
|
184
157
|
* @throws {APIError} - Throws an error if the provider is not provided.
|
|
185
|
-
*/setProvider({provider:e,info:i,address:a}){if(!e)throw new
|
|
158
|
+
*/setProvider({provider:e,info:i,address:a}){if(!e)throw new s("provider is required");this.viem=((e,i="window.ethereum",
|
|
159
|
+
// chain: "mainnet" | "testnet" = "testnet",
|
|
160
|
+
a,r)=>{var s;if(!e&&!y)return console.warn("Provider is required to create a client."),null;if(!y||y.transport.name!==i&&e||r!==(null===(s=y.account)||void 0===s?void 0:s.address)&&e){const s={
|
|
161
|
+
// chain: chain === "mainnet" ? mainnet : testnet,
|
|
162
|
+
chain:a||l,transport:t.custom(e,{name:i})};r&&(s.account=n.toAccount(r)),y=t.createWalletClient(s)}return y})(e,i.name,this.environment.CHAIN,a),this.origin&&this.origin.setViemClient(this.viem),
|
|
186
163
|
// TODO: only use one of these
|
|
187
|
-
r(this,
|
|
164
|
+
r(this,G,"m",Z).call(this,"viem",this.viem),r(this,G,"m",Z).call(this,"provider",{provider:e,info:i}),localStorage.setItem("camp-sdk:provider",JSON.stringify(i))}
|
|
188
165
|
/**
|
|
189
166
|
* 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.
|
|
190
167
|
* @param {string} walletAddress The wallet address.
|
|
191
168
|
* @returns {void}
|
|
192
|
-
*/setWalletAddress(e){this.walletAddress=e}
|
|
169
|
+
*/setWalletAddress(e){this.walletAddress=e}
|
|
170
|
+
/**
|
|
171
|
+
* Recover the provider from local storage.
|
|
172
|
+
* @returns {Promise<void>}
|
|
173
|
+
*/recoverProvider(){return a(this,void 0,void 0,(function*(){var e,t,n,i,a,r,s,o,d,u,p,l,y,c,h;if(!this.walletAddress)return void console.warn("No wallet address found in local storage. Please connect your wallet again.");const m=JSON.parse(localStorage.getItem("camp-sdk:provider")||"{}");let T;const f=null!==(e=I())&&void 0!==e?e:[];
|
|
174
|
+
// first pass: try to find provider by UUID/name and check if it has the right address
|
|
175
|
+
// without prompting (using eth_accounts)
|
|
176
|
+
for(const e of f)try{if(m.uuid&&(null===(t=e.info)||void 0===t?void 0:t.uuid)===m.uuid||m.name&&(null===(n=e.info)||void 0===n?void 0:n.name)===m.name){
|
|
177
|
+
// silently check if the wallet address matches first
|
|
178
|
+
const t=yield e.provider.request({method:"eth_accounts"});if(t.length>0&&(null===(i=t[0])||void 0===i?void 0:i.toLowerCase())===(null===(a=this.walletAddress)||void 0===a?void 0:a.toLowerCase())){T=e;break}}}catch(e){console.warn("Failed to fetch accounts from provider:",e)}
|
|
179
|
+
// second pass: if no provider found by UUID/name match, try to find by address only
|
|
180
|
+
// but still avoid prompting
|
|
181
|
+
if(!T)for(const e of f)try{
|
|
182
|
+
// skip providers we already checked in the first pass
|
|
183
|
+
if(m.uuid&&(null===(r=e.info)||void 0===r?void 0:r.uuid)===m.uuid||m.name&&(null===(s=e.info)||void 0===s?void 0:s.name)===m.name)continue;const t=yield e.provider.request({method:"eth_accounts"});if(t.length>0&&(null===(o=t[0])||void 0===o?void 0:o.toLowerCase())===(null===(d=this.walletAddress)||void 0===d?void 0:d.toLowerCase())){T=e;break}}catch(e){console.warn("Failed to fetch accounts from provider:",e)}
|
|
184
|
+
// third pass: if still no provider found and we have UUID/name info,
|
|
185
|
+
// try prompting the user (only for the stored provider)
|
|
186
|
+
if(!T&&(m.uuid||m.name))for(const e of f)try{if(m.uuid&&(null===(u=e.info)||void 0===u?void 0:u.uuid)===m.uuid||m.name&&(null===(p=e.info)||void 0===p?void 0:p.name)===m.name){console.log("Attempting to reconnect to stored provider:",(null===(l=e.info)||void 0===l?void 0:l.name)||(null===(y=e.info)||void 0===y?void 0:y.uuid));const t=yield e.provider.request({method:"eth_requestAccounts"});if(t.length>0&&(null===(c=t[0])||void 0===c?void 0:c.toLowerCase())===(null===(h=this.walletAddress)||void 0===h?void 0:h.toLowerCase())){T=e;break}}}catch(e){console.warn("Failed to reconnect to stored provider:",e)}T?this.setProvider({provider:T.provider,info:T.info||{name:"Unknown"},address:this.walletAddress}):console.warn("No matching provider found for the stored wallet address. Please connect your wallet again.")}))}
|
|
193
187
|
/**
|
|
194
188
|
* Disconnect the user.
|
|
195
189
|
* @returns {Promise<void>}
|
|
196
|
-
*/disconnect(){return a(this,void 0,void 0,(function*(){this.isAuthenticated&&(r(this,
|
|
190
|
+
*/disconnect(){return a(this,void 0,void 0,(function*(){this.isAuthenticated&&(r(this,G,"m",Z).call(this,"state","unauthenticated"),this.isAuthenticated=!1,this.walletAddress=null,this.userId=null,this.jwt=null,this.origin=null,localStorage.removeItem("camp-sdk:wallet-address"),localStorage.removeItem("camp-sdk:user-id"),localStorage.removeItem("camp-sdk:jwt"),localStorage.removeItem("camp-sdk:environment"))}))}
|
|
197
191
|
/**
|
|
198
192
|
* Connect the user's wallet and sign the message.
|
|
199
193
|
* @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
|
|
200
194
|
* @throws {APIError} - Throws an error if the user cannot be authenticated.
|
|
201
|
-
*/connect(){return a(this,void 0,void 0,(function*(){r(this,
|
|
195
|
+
*/connect(){return a(this,void 0,void 0,(function*(){r(this,G,"m",Z).call(this,"state","loading");try{this.walletAddress||(yield r(this,G,"m",ee).call(this)),this.walletAddress=t.checksumAddress(this.walletAddress);const e=yield r(this,G,"m",te).call(this),n=r(this,G,"m",ie).call(this,e),i=yield this.viem.signMessage({account:this.walletAddress,message:n}),a=yield r(this,G,"m",ne).call(this,n,i);if(a.success)return this.isAuthenticated=!0,this.userId=a.userId,this.jwt=a.token,this.origin=new re(this.jwt,this.environment,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),localStorage.setItem("camp-sdk:environment",this.environment.NAME),r(this,G,"m",Z).call(this,"state","authenticated"),yield r(this,G,"m",ae).call(this,v.USER_CONNECTED,"User Connected"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,r(this,G,"m",Z).call(this,"state","unauthenticated"),new s("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,r(this,G,"m",Z).call(this,"state","unauthenticated"),new s(e)}}))}
|
|
202
196
|
/**
|
|
203
197
|
* Get the user's linked social accounts.
|
|
204
198
|
* @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
|
|
@@ -207,49 +201,34 @@ r(this,H,"m",Z).call(this,"viem",this.viem),r(this,H,"m",Z).call(this,"provider"
|
|
|
207
201
|
* const auth = new Auth({ clientId: "your-client-id" });
|
|
208
202
|
* const socials = await auth.getLinkedSocials();
|
|
209
203
|
* console.log(socials);
|
|
210
|
-
*/getLinkedSocials(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${
|
|
204
|
+
*/getLinkedSocials(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/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 s(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}}))}
|
|
211
205
|
/**
|
|
212
206
|
* Link the user's Twitter account.
|
|
213
207
|
* @returns {Promise<void>}
|
|
214
208
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
215
|
-
*/linkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
|
|
216
|
-
// await this.#sendAnalyticsEvent(
|
|
217
|
-
// constants.ACKEE_EVENTS.TWITTER_LINKED,
|
|
218
|
-
// "Twitter Linked"
|
|
219
|
-
// );
|
|
220
|
-
window.location.href=`${w}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
|
|
209
|
+
*/linkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
|
|
221
210
|
/**
|
|
222
211
|
* Link the user's Discord account.
|
|
223
212
|
* @returns {Promise<void>}
|
|
224
213
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
225
|
-
*/linkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
|
|
226
|
-
// await this.#sendAnalyticsEvent(
|
|
227
|
-
// constants.ACKEE_EVENTS.DISCORD_LINKED,
|
|
228
|
-
// "Discord Linked"
|
|
229
|
-
// );
|
|
230
|
-
window.location.href=`${w}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
|
|
214
|
+
*/linkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
|
|
231
215
|
/**
|
|
232
216
|
* Link the user's Spotify account.
|
|
233
217
|
* @returns {Promise<void>}
|
|
234
218
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
235
|
-
*/linkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");
|
|
236
|
-
// await this.#sendAnalyticsEvent(
|
|
237
|
-
// constants.ACKEE_EVENTS.SPOTIFY_LINKED,
|
|
238
|
-
// "Spotify Linked"
|
|
239
|
-
// );
|
|
240
|
-
window.location.href=`${w}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
|
|
219
|
+
*/linkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
|
|
241
220
|
/**
|
|
242
221
|
* Link the user's TikTok account.
|
|
243
222
|
* @param {string} handle The user's TikTok handle.
|
|
244
223
|
* @returns {Promise<any>} A promise that resolves with the TikTok account data.
|
|
245
224
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated.
|
|
246
|
-
*/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(`${
|
|
225
|
+
*/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(`${this.environment.AUTH_HUB_BASE_API}/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 s("TikTok service is currently unavailable, try again later"):new s(t.message||"Failed to link TikTok account");return r(this,G,"m",ae).call(this,v.TIKTOK_LINKED,"TikTok Linked"),t.data}))}
|
|
247
226
|
/**
|
|
248
227
|
* Send an OTP to the user's Telegram account.
|
|
249
228
|
* @param {string} phoneNumber The user's phone number.
|
|
250
229
|
* @returns {Promise<any>} A promise that resolves with the OTP data.
|
|
251
230
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated.
|
|
252
|
-
*/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
|
|
231
|
+
*/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 s("Phone number is required");yield this.unlinkTelegram();const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 s(t.message||"Failed to send Telegram OTP");return t.data}))}
|
|
253
232
|
/**
|
|
254
233
|
* Link the user's Telegram account.
|
|
255
234
|
* @param {string} phoneNumber The user's phone number.
|
|
@@ -257,37 +236,37 @@ window.location.href=`${w}/spotify/connect?clientId=${this.clientId}&userId=${th
|
|
|
257
236
|
* @param {string} phoneCodeHash The phone code hash.
|
|
258
237
|
* @returns {Promise<object>} A promise that resolves with the Telegram account data.
|
|
259
238
|
* @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.
|
|
260
|
-
*/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
|
|
239
|
+
*/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 s("Phone number, OTP, and phone code hash are required");const i=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 s(i.message||"Failed to link Telegram account");return r(this,G,"m",ae).call(this,v.TELEGRAM_LINKED,"Telegram Linked"),i.data}))}
|
|
261
240
|
/**
|
|
262
241
|
* Unlink the user's Twitter account.
|
|
263
242
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
264
243
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
265
244
|
* @throws {APIError} - Throws an error if the request fails.
|
|
266
|
-
*/unlinkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${
|
|
245
|
+
*/unlinkTwitter(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 s(e.message||"Failed to unlink Twitter account");return e.data}))}
|
|
267
246
|
/**
|
|
268
247
|
* Unlink the user's Discord account.
|
|
269
248
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
270
249
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
271
250
|
* @throws {APIError} - Throws an error if the request fails.
|
|
272
|
-
*/unlinkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new
|
|
251
|
+
*/unlinkDiscord(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new s("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 s(e.message||"Failed to unlink Discord account");return e.data}))}
|
|
273
252
|
/**
|
|
274
253
|
* Unlink the user's Spotify account.
|
|
275
254
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
276
255
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
277
256
|
* @throws {APIError} - Throws an error if the request fails.
|
|
278
|
-
*/unlinkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new
|
|
257
|
+
*/unlinkSpotify(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new s("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 s(e.message||"Failed to unlink Spotify account");return e.data}))}
|
|
279
258
|
/**
|
|
280
259
|
* Unlink the user's TikTok account.
|
|
281
260
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
282
261
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
283
262
|
* @throws {APIError} - Throws an error if the request fails.
|
|
284
|
-
*/unlinkTikTok(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new
|
|
263
|
+
*/unlinkTikTok(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new s("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 s(e.message||"Failed to unlink TikTok account");return e.data}))}
|
|
285
264
|
/**
|
|
286
265
|
* Unlink the user's Telegram account.
|
|
287
266
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
288
267
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
289
268
|
* @throws {APIError} - Throws an error if the request fails.
|
|
290
|
-
*/unlinkTelegram(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new
|
|
269
|
+
*/unlinkTelegram(){return a(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new s("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 s(e.message||"Failed to unlink Telegram account");return e.data}))}},exports.SpotifyAPI=
|
|
291
270
|
/**
|
|
292
271
|
* The SpotifyAPI class.
|
|
293
272
|
* @class
|
|
@@ -306,51 +285,51 @@ constructor(e){this.apiKey=e.apiKey}
|
|
|
306
285
|
* @param {string} spotifyId - The user's Spotify ID.
|
|
307
286
|
* @returns {Promise<object>} - The saved tracks.
|
|
308
287
|
* @throws {APIError} - Throws an error if the request fails.
|
|
309
|
-
*/fetchSavedTracksById(e){return a(this,void 0,void 0,(function*(){const t=
|
|
288
|
+
*/fetchSavedTracksById(e){return a(this,void 0,void 0,(function*(){const t=d(`${p}/save-tracks`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
|
|
310
289
|
/**
|
|
311
290
|
* Fetch the played tracks of a user by Spotify ID.
|
|
312
291
|
* @param {string} spotifyId - The user's Spotify ID.
|
|
313
292
|
* @returns {Promise<object>} - The played tracks.
|
|
314
293
|
* @throws {APIError} - Throws an error if the request fails.
|
|
315
|
-
*/fetchPlayedTracksById(e){return a(this,void 0,void 0,(function*(){const t=
|
|
294
|
+
*/fetchPlayedTracksById(e){return a(this,void 0,void 0,(function*(){const t=d(`${p}/played-tracks`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
|
|
316
295
|
/**
|
|
317
296
|
* Fetch the user's saved albums by Spotify user ID.
|
|
318
297
|
* @param {string} spotifyId - The user's Spotify ID.
|
|
319
298
|
* @returns {Promise<object>} - The saved albums.
|
|
320
299
|
* @throws {APIError} - Throws an error if the request fails.
|
|
321
|
-
*/fetchSavedAlbumsById(e){return a(this,void 0,void 0,(function*(){const t=
|
|
300
|
+
*/fetchSavedAlbumsById(e){return a(this,void 0,void 0,(function*(){const t=d(`${p}/saved-albums`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
|
|
322
301
|
/**
|
|
323
302
|
* Fetch the user's saved playlists by Spotify user ID.
|
|
324
303
|
* @param {string} spotifyId - The user's Spotify ID.
|
|
325
304
|
* @returns {Promise<object>} - The saved playlists.
|
|
326
305
|
* @throws {APIError} - Throws an error if the request fails.
|
|
327
|
-
*/fetchSavedPlaylistsById(e){return a(this,void 0,void 0,(function*(){const t=
|
|
306
|
+
*/fetchSavedPlaylistsById(e){return a(this,void 0,void 0,(function*(){const t=d(`${p}/saved-playlists`,{spotifyId:e});return this._fetchDataWithAuth(t)}))}
|
|
328
307
|
/**
|
|
329
308
|
* Fetch the tracks of an album by album ID.
|
|
330
309
|
* @param {string} spotifyId - The Spotify ID of the user.
|
|
331
310
|
* @param {string} albumId - The album ID.
|
|
332
311
|
* @returns {Promise<object>} - The tracks in the album.
|
|
333
312
|
* @throws {APIError} - Throws an error if the request fails.
|
|
334
|
-
*/fetchTracksInAlbum(e,t){return a(this,void 0,void 0,(function*(){const n=
|
|
313
|
+
*/fetchTracksInAlbum(e,t){return a(this,void 0,void 0,(function*(){const n=d(`${p}/album/tracks`,{spotifyId:e,albumId:t});return this._fetchDataWithAuth(n)}))}
|
|
335
314
|
/**
|
|
336
315
|
* Fetch the tracks in a playlist by playlist ID.
|
|
337
316
|
* @param {string} spotifyId - The Spotify ID of the user.
|
|
338
317
|
* @param {string} playlistId - The playlist ID.
|
|
339
318
|
* @returns {Promise<object>} - The tracks in the playlist.
|
|
340
319
|
* @throws {APIError} - Throws an error if the request fails.
|
|
341
|
-
*/fetchTracksInPlaylist(e,t){return a(this,void 0,void 0,(function*(){const n=
|
|
320
|
+
*/fetchTracksInPlaylist(e,t){return a(this,void 0,void 0,(function*(){const n=d(`${p}/playlist/tracks`,{spotifyId:e,playlistId:t});return this._fetchDataWithAuth(n)}))}
|
|
342
321
|
/**
|
|
343
322
|
* Fetch the user's Spotify data by wallet address.
|
|
344
323
|
* @param {string} walletAddress - The wallet address.
|
|
345
324
|
* @returns {Promise<object>} - The user's Spotify data.
|
|
346
325
|
* @throws {APIError} - Throws an error if the request fails.
|
|
347
|
-
*/fetchUserByWalletAddress(e){return a(this,void 0,void 0,(function*(){const t=
|
|
326
|
+
*/fetchUserByWalletAddress(e){return a(this,void 0,void 0,(function*(){const t=d(`${p}/wallet-spotify-data`,{walletAddress:e});return this._fetchDataWithAuth(t)}))}
|
|
348
327
|
/**
|
|
349
328
|
* Private method to fetch data with authorization header.
|
|
350
329
|
* @param {string} url - The URL to fetch.
|
|
351
330
|
* @returns {Promise<object>} - The response data.
|
|
352
331
|
* @throws {APIError} - Throws an error if the request fails.
|
|
353
|
-
*/_fetchDataWithAuth(e){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new
|
|
332
|
+
*/_fetchDataWithAuth(e){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new s("API key is required for fetching data",401);try{return yield o(e,{"x-api-key":this.apiKey})}catch(e){throw new s(e.message,e.statusCode)}}))}},exports.TwitterAPI=
|
|
354
333
|
/**
|
|
355
334
|
* The TwitterAPI class.
|
|
356
335
|
* @class
|
|
@@ -368,7 +347,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
368
347
|
* @param {string} twitterUserName - The Twitter username.
|
|
369
348
|
* @returns {Promise<object>} - The user details.
|
|
370
349
|
* @throws {APIError} - Throws an error if the request fails.
|
|
371
|
-
*/fetchUserByUsername(e){return a(this,void 0,void 0,(function*(){const t=
|
|
350
|
+
*/fetchUserByUsername(e){return a(this,void 0,void 0,(function*(){const t=d(`${u}/user`,{twitterUserName:e});return this._fetchDataWithAuth(t)}))}
|
|
372
351
|
/**
|
|
373
352
|
* Fetch tweets by Twitter username.
|
|
374
353
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -376,7 +355,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
376
355
|
* @param {number} limit - The number of items per page.
|
|
377
356
|
* @returns {Promise<object>} - The tweets.
|
|
378
357
|
* @throws {APIError} - Throws an error if the request fails.
|
|
379
|
-
*/fetchTweetsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
358
|
+
*/fetchTweetsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/tweets`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
380
359
|
/**
|
|
381
360
|
* Fetch followers by Twitter username.
|
|
382
361
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -384,7 +363,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
384
363
|
* @param {number} limit - The number of items per page.
|
|
385
364
|
* @returns {Promise<object>} - The followers.
|
|
386
365
|
* @throws {APIError} - Throws an error if the request fails.
|
|
387
|
-
*/fetchFollowersByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
366
|
+
*/fetchFollowersByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/followers`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
388
367
|
/**
|
|
389
368
|
* Fetch following by Twitter username.
|
|
390
369
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -392,13 +371,13 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
392
371
|
* @param {number} limit - The number of items per page.
|
|
393
372
|
* @returns {Promise<object>} - The following.
|
|
394
373
|
* @throws {APIError} - Throws an error if the request fails.
|
|
395
|
-
*/fetchFollowingByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
374
|
+
*/fetchFollowingByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/following`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
396
375
|
/**
|
|
397
376
|
* Fetch tweet by tweet ID.
|
|
398
377
|
* @param {string} tweetId - The tweet ID.
|
|
399
378
|
* @returns {Promise<object>} - The tweet.
|
|
400
379
|
* @throws {APIError} - Throws an error if the request fails.
|
|
401
|
-
*/fetchTweetById(e){return a(this,void 0,void 0,(function*(){const t=
|
|
380
|
+
*/fetchTweetById(e){return a(this,void 0,void 0,(function*(){const t=d(`${u}/getTweetById`,{tweetId:e});return this._fetchDataWithAuth(t)}))}
|
|
402
381
|
/**
|
|
403
382
|
* Fetch user by wallet address.
|
|
404
383
|
* @param {string} walletAddress - The wallet address.
|
|
@@ -406,7 +385,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
406
385
|
* @param {number} limit - The number of items per page.
|
|
407
386
|
* @returns {Promise<object>} - The user data.
|
|
408
387
|
* @throws {APIError} - Throws an error if the request fails.
|
|
409
|
-
*/fetchUserByWalletAddress(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
388
|
+
*/fetchUserByWalletAddress(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/wallet-twitter-data`,{walletAddress:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
410
389
|
/**
|
|
411
390
|
* Fetch reposted tweets by Twitter username.
|
|
412
391
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -414,7 +393,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
414
393
|
* @param {number} limit - The number of items per page.
|
|
415
394
|
* @returns {Promise<object>} - The reposted tweets.
|
|
416
395
|
* @throws {APIError} - Throws an error if the request fails.
|
|
417
|
-
*/fetchRepostedByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
396
|
+
*/fetchRepostedByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/reposted`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
418
397
|
/**
|
|
419
398
|
* Fetch replies by Twitter username.
|
|
420
399
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -422,7 +401,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
422
401
|
* @param {number} limit - The number of items per page.
|
|
423
402
|
* @returns {Promise<object>} - The replies.
|
|
424
403
|
* @throws {APIError} - Throws an error if the request fails.
|
|
425
|
-
*/fetchRepliesByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
404
|
+
*/fetchRepliesByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/replies`,{twitterUserName:e,page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
426
405
|
/**
|
|
427
406
|
* Fetch likes by Twitter username.
|
|
428
407
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -430,7 +409,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
430
409
|
* @param {number} limit - The number of items per page.
|
|
431
410
|
* @returns {Promise<object>} - The likes.
|
|
432
411
|
* @throws {APIError} - Throws an error if the request fails.
|
|
433
|
-
*/fetchLikesByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
412
|
+
*/fetchLikesByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/event/likes/${e}`,{page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
434
413
|
/**
|
|
435
414
|
* Fetch follows by Twitter username.
|
|
436
415
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -438,7 +417,7 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
438
417
|
* @param {number} limit - The number of items per page.
|
|
439
418
|
* @returns {Promise<object>} - The follows.
|
|
440
419
|
* @throws {APIError} - Throws an error if the request fails.
|
|
441
|
-
*/fetchFollowsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
420
|
+
*/fetchFollowsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/event/follows/${e}`,{page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
442
421
|
/**
|
|
443
422
|
* Fetch viewed tweets by Twitter username.
|
|
444
423
|
* @param {string} twitterUserName - The Twitter username.
|
|
@@ -446,10 +425,10 @@ constructor({apiKey:e}){this.apiKey=e}
|
|
|
446
425
|
* @param {number} limit - The number of items per page.
|
|
447
426
|
* @returns {Promise<object>} - The viewed tweets.
|
|
448
427
|
* @throws {APIError} - Throws an error if the request fails.
|
|
449
|
-
*/fetchViewedTweetsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=
|
|
428
|
+
*/fetchViewedTweetsByUsername(e){return a(this,arguments,void 0,(function*(e,t=1,n=10){const i=d(`${u}/event/viewed-tweets/${e}`,{page:t,limit:n});return this._fetchDataWithAuth(i)}))}
|
|
450
429
|
/**
|
|
451
430
|
* Private method to fetch data with authorization header.
|
|
452
431
|
* @param {string} url - The URL to fetch.
|
|
453
432
|
* @returns {Promise<object>} - The response data.
|
|
454
433
|
* @throws {APIError} - Throws an error if the request fails.
|
|
455
|
-
*/_fetchDataWithAuth(e){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new
|
|
434
|
+
*/_fetchDataWithAuth(e){return a(this,void 0,void 0,(function*(){if(!this.apiKey)throw new s("API key is required for fetching data",401);try{return yield o(e,{"x-api-key":this.apiKey})}catch(e){throw new s(e.message,e.statusCode)}}))}};
|