@campnetwork/origin 1.0.0 → 1.0.1-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/core.cjs CHANGED
@@ -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)}"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}}}const o={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/"}}};var d=[{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"}],u=[{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"}],p=[{type:"constructor",inputs:[{name:"_owner",type:"address",internalType:"address"}],stateMutability:"nonpayable"},{type:"receive",stateMutability:"payable"},{type:"function",name:"claimRoyalty",inputs:[{name:"token",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]}],l="Connect with Camp Network";const y={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:o,IPNFT_ABI:d,MARKETPLACE_ABI:u,ROYALTY_VAULT_ABI:p},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:d,MARKETPLACE_ABI:u,ROYALTY_VAULT_ABI:p}};
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}}}const o={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/"}}};var d=[{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"}],u=[{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"}],l=[{type:"constructor",inputs:[{name:"_owner",type:"address",internalType:"address"}],stateMutability:"nonpayable"},{type:"receive",stateMutability:"payable"},{type:"function",name:"claimRoyalty",inputs:[{name:"token",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]}],p="Connect with Camp Network";const y={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:o,IPNFT_ABI:d,MARKETPLACE_ABI:u,ROYALTY_VAULT_ABI:l},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:d,MARKETPLACE_ABI:u,ROYALTY_VAULT_ABI:l}};
18
18
  /**
19
19
  * Makes a GET request to the given URL with the provided headers.
20
20
  *
@@ -38,7 +38,7 @@ function a(e,t,n,i){return new(n||(n=Promise))((function(a,r){function s(e){try{
38
38
  */
39
39
  function h(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 m="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/twitter",T="https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev/spotify";
40
40
  // @ts-ignore
41
- let f=null,v=null,w=null;const A=e=>{var n;const i=w||o;return v&&(null===(n=v.chain)||void 0===n?void 0:n.id)===i.id||(v=t.createPublicClient({chain:i,transport:t.http()})),v};let I=[];const b=()=>I,g=e=>{function t(t){I.some((e=>e.info.uuid===t.detail.info.uuid))||(I=[...I,t.detail],e(I))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)};
41
+ let f=null,v=null,w=null;const A=e=>{var n;const i=w||o;return v&&(null===(n=v.chain)||void 0===n?void 0:n.id)===i.id||(v=t.createPublicClient({chain:i,transport:t.http()})),v};let I=[];const g=()=>I,b=e=>{function t(t){I.some((e=>e.info.uuid===t.detail.info.uuid))||(I=[...I,t.detail],e(I))}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.
@@ -89,12 +89,12 @@ let f=null,v=null,w=null;const A=e=>{var n;const i=w||o;return v&&(null===(n=v.c
89
89
  * Returns the number of IPNFTs owned by the given address.
90
90
  * @param owner The address to query.
91
91
  * @returns The number of IPNFTs owned by the address.
92
- */function D(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"balanceOf",[e])}
92
+ */function N(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"balanceOf",[e])}
93
93
  /**
94
94
  * Returns the metadata URI associated with a specific token ID.
95
95
  * @param tokenId The token ID to query.
96
96
  * @returns The metadata URI of the token ID.
97
- */function N(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenURI",[e])}
97
+ */function D(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenURI",[e])}
98
98
  /**
99
99
  * Returns the data status of the given token ID.
100
100
  * @param tokenId The token ID to query.
@@ -105,7 +105,7 @@ let f=null,v=null,w=null;const A=e=>{var n;const i=w||o;return v&&(null===(n=v.c
105
105
  * @param owner The address of the asset owner.
106
106
  * @param operator The address of the operator to check.
107
107
  * @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
108
- */function U(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"isApprovedForAll",[e,t])}function M(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"transferFrom",[e,t,n])}function B(e,t,n,i){const a=i?[e,t,n,i]:[e,t,n];return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"safeTransferFrom",a)}function F(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"approve",[e,t])}function R(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"setApprovalForAll",[e,t])}
108
+ */function M(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"isApprovedForAll",[e,t])}function U(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"transferFrom",[e,t,n])}function B(e,t,n,i){const a=i?[e,t,n,i]:[e,t,n];return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"safeTransferFrom",a)}function F(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"approve",[e,t])}function R(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"setApprovalForAll",[e,t])}
109
109
  /**
110
110
  * Buys access to a data NFT for a specified duration.
111
111
  * @param buyer The address of the buyer.
@@ -126,17 +126,17 @@ let f=null,v=null,w=null;const A=e=>{var n;const i=w||o;return v&&(null===(n=v.c
126
126
  * Approves a spender to spend a specified amount of tokens on behalf of the owner.
127
127
  * If the current allowance is less than the specified amount, it will perform the approval.
128
128
  * @param {ApproveParams} params - The parameters for the approval.
129
- */var q,L,W,z,J,K,V,G,Y,X,Z,Q,ee,te;
129
+ */var L,W,q,z,J,K,V,G,Y,X,Z,Q,ee,te,ne;
130
130
  /**
131
131
  * The Origin class
132
132
  * Handles the upload of files to Origin, as well as querying the user's stats
133
- */class ne{constructor(e,t,n){q.add(this),this.jwt=e,this.viemClient=n,this.environment=t,
133
+ */class ie{constructor(e,t,n){L.add(this),this.jwt=e,this.viemClient=n,this.environment=t,
134
134
  // DataNFT methods
135
- this.mintWithSignature=E.bind(this),this.registerIpNFT=_.bind(this),this.updateTerms=C.bind(this),this.finalizeDelete=k.bind(this),this.getOrCreateRoyaltyVault=S.bind(this),this.getTerms=P.bind(this),this.ownerOf=x.bind(this),this.balanceOf=D.bind(this),this.tokenURI=N.bind(this),this.dataStatus=O.bind(this),this.isApprovedForAll=U.bind(this),this.transferFrom=M.bind(this),this.safeTransferFrom=B.bind(this),this.approve=F.bind(this),this.setApprovalForAll=R.bind(this),
135
+ this.mintWithSignature=E.bind(this),this.registerIpNFT=_.bind(this),this.updateTerms=C.bind(this),this.finalizeDelete=k.bind(this),this.getOrCreateRoyaltyVault=S.bind(this),this.getTerms=P.bind(this),this.ownerOf=x.bind(this),this.balanceOf=N.bind(this),this.tokenURI=D.bind(this),this.dataStatus=O.bind(this),this.isApprovedForAll=M.bind(this),this.transferFrom=U.bind(this),this.safeTransferFrom=B.bind(this),this.approve=F.bind(this),this.setApprovalForAll=R.bind(this),
136
136
  // Marketplace methods
137
- this.buyAccess=$.bind(this),this.hasAccess=H.bind(this),this.subscriptionExpiry=j.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return a(this,void 0,void 0,(function*(){let i;try{i=yield r(this,q,"m",L).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield r(this,q,"m",W).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield r(this,q,"m",W).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,r){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const a=yield this.uploadFile(e,r);if(!a||!a.key)throw new Error("Failed to upload file or get upload info.");const s=BigInt(Date.now()+6e5),o=yield this.registerIpNFT("file",s,n,t,a.key,i),{tokenId:d,signerAddress:u,creatorContentHash:p,signature:l,uri:y}=o;// 10 minutes from now
138
- if(!(d&&u&&p&&void 0!==l&&y))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");const c=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if(-1===["0x1","success"].indexOf(h.receipt.status))throw console.error("Minting failed:",h),new Error(`Minting failed with status: ${h.receipt.status}`);return d.toString()}))}mintSocial(e,t,n){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=BigInt(Math.floor(Date.now()/1e3)+600),a=yield this.registerIpNFT(e,i,n,t),{tokenId:r,signerAddress:s,creatorContentHash:o,signature:d,uri:u}=a;// 10 minutes from now
139
- if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const p=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],l=yield this.mintWithSignature(p,r,[],o,u,n,i,d);if(-1===["0x1","success"].indexOf(l.receipt.status))throw new Error(`Minting Social IpNFT failed with status: ${l.receipt.status}`);return r.toString()}))}getOriginUploads(){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
137
+ this.buyAccess=$.bind(this),this.hasAccess=H.bind(this),this.subscriptionExpiry=j.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return a(this,void 0,void 0,(function*(){let i;try{i=yield r(this,L,"m",W).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield r(this,L,"m",q).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield r(this,L,"m",q).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,s){return a(this,void 0,void 0,(function*(){let a,o=null;try{o=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to mint file IP. Wallet not connected.")}try{if(a=yield this.uploadFile(e,s),!a||!a.key)throw new Error("Failed to upload file or get upload info.")}catch(e){throw new Error(`File upload failed: ${e instanceof Error?e.message:String(e)}`)}const d=BigInt(Date.now()+6e5);// 10 minutes from now
138
+ let u;try{u=yield this.registerIpNFT("file",d,n,t,a.key,i)}catch(e){throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:l,signerAddress:p,creatorContentHash:y,signature:c,uri:h}=u;if(!(l&&p&&y&&void 0!==c&&h))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(o,l,i||[],y,h,n,d,c);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield r(this,L,"m",q).call(this,a.key,"failed"),new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return l.toString()}))}mintSocial(e,t,n){return a(this,void 0,void 0,(function*(){let i=null;try{i=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to mint social IP. Wallet not connected.")}const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
139
+ let s;try{s=yield this.registerIpNFT(e,a,n,t)}catch(e){throw new Error(`Failed to register Social IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:o,signerAddress:d,creatorContentHash:u,signature:l,uri:p}=s;if(!(o&&d&&u&&void 0!==l&&p))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(i,o,[],u,p,n,a,l);if(-1===["0x1","success"].indexOf(e.receipt.status))throw new Error(`Minting Social IpNFT failed with status: ${e.receipt.status}`)}catch(e){throw new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return o.toString()}))}getOriginUploads(){return a(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
140
140
  /**
141
141
  * Get the user's Origin stats (multiplier, consent, usage, etc.).
142
142
  * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
@@ -156,14 +156,14 @@ if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: M
156
156
  * @param {CallOptions} [options] The call options.
157
157
  * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
158
158
  * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
159
- */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});if(o&&"stateMutability"in o&&("view"===o.stateMutability||"pure"===o.stateMutability)){const t=A();return(yield t.readContract({address:e,abi:n,functionName:i,args:a}))||null}if(!this.viemClient)throw new Error("WalletClient not connected.");const[d]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});yield r(this,q,"m",J).call(this,this.environment.CHAIN);const u=A(),{result:p,request:l}=yield u.simulateContract({account:d,address:e,abi:n,functionName:i,args:a,value:s.value});
159
+ */callContractMethod(e,n,i,s){return a(this,arguments,void 0,(function*(e,n,i,a,s={}){var o;let d=null;try{d=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to call contract method. Wallet not connected.")}const u=t.getAbiItem({abi:n,name:i});if(u&&"stateMutability"in u&&("view"===u.stateMutability||"pure"===u.stateMutability)){const t=A();return(yield t.readContract({address:e,abi:n,functionName:i,args:a}))||null}yield r(this,L,"m",J).call(this,this.environment.CHAIN);const l=A(),{result:p,request:y}=yield l.simulateContract({account:d,address:e,abi:n,functionName:i,args:a,value:s.value});
160
160
  // simulate
161
- if(s.simulate)return p;try{const e=yield this.viemClient.writeContract(l);if("string"!=typeof e)throw new Error("Transaction failed to send.");if(!s.waitForReceipt)return{txHash:e,simulatedResult:p};return{txHash:e,receipt:yield r(this,q,"m",z).call(this,e),simulatedResult:p}}catch(e){throw console.error("Transaction failed:",e),new Error("Transaction failed: "+e)}}))}
161
+ if(s.simulate)return p;try{const e=yield null===(o=this.viemClient)||void 0===o?void 0:o.writeContract(y);if("string"!=typeof e)throw new Error("Transaction failed to send.");if(!s.waitForReceipt)return{txHash:e,simulatedResult:p};return{txHash:e,receipt:yield r(this,L,"m",z).call(this,e),simulatedResult:p}}catch(e){throw console.error("Transaction failed:",e),new Error("Transaction failed: "+e)}}))}
162
162
  /**
163
163
  * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
164
164
  * @param {bigint} tokenId The token ID of the asset.
165
165
  * @returns {Promise<any>} The result of the buyAccess call.
166
- */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 d=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],u=i;return r===t.zeroAddress?this.buyAccess(d,e,u,s,r,u):(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:o}))}))}({walletClient:this.viemClient,publicClient:A(),tokenAddress:r,owner:d,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:u}),this.buyAccess(d,e,u,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()}))}
166
+ */buyAccessSmart(e){return a(this,void 0,void 0,(function*(){let n=null;try{n=yield r(this,L,"m",K).call(this)}catch(e){throw new Error("Failed to buy access. Wallet not connected.")}const i=yield this.getTerms(e);if(!i)throw new Error("Failed to fetch terms for asset");const{price:s,paymentToken:d,duration:u}=i;if(void 0===s||void 0===d||void 0===u)throw new Error("Terms missing price, paymentToken, or duration");const l=s;return d===t.zeroAddress?this.buyAccess(n,e,l,u,d,l):(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:o}))}))}({walletClient:this.viemClient,publicClient:A(),tokenAddress:d,owner:n,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:l}),this.buyAccess(n,e,l,u,d))}))}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()}))}
167
167
  /**
168
168
  * Get royalty information for a wallet address, including the royalty vault address and its balance.
169
169
  * @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
@@ -178,7 +178,7 @@ if(s.simulate)return p;try{const e=yield this.viemClient.writeContract(l);if("st
178
178
  * // Get royalties for specific address
179
179
  * const royalties = await origin.getRoyalties("0x1234...");
180
180
  * ```
181
- */getRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,q,"m",K).call(this,n);try{const n=yield this.getOrCreateRoyaltyVault(i,!0),a=A();let r,s;if(e&&e!==t.zeroAddress){
181
+ */getRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,L,"m",V).call(this,n);try{const n=yield this.getOrCreateRoyaltyVault(i,!0),a=A();let r,s;if(e&&e!==t.zeroAddress){
182
182
  // erc20 (wrapped camp)
183
183
  const i=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],stateMutability:"view",type:"function"}];r=yield this.callContractMethod(e,i,"balanceOf",[n]);const a=yield this.callContractMethod(e,i,"decimals",[]);s=t.formatUnits(r,a)}else r=yield a.getBalance({address:n}),s=t.formatEther(r);return{royaltyVault:n,balance:r,balanceFormatted:s}}catch(e){throw new Error(`Failed to retrieve royalties for address ${i}: ${e instanceof Error?e.message:String(e)}`)}}))}
184
184
  /**
@@ -187,14 +187,12 @@ const i=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name
187
187
  * @param {Address} [owner] - Optional wallet address to claim royalties for. If not provided, uses the connected wallet.
188
188
  * @returns {Promise<any>} A promise that resolves when the claim transaction is confirmed.
189
189
  * @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
190
- */claimRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,q,"m",K).call(this,n),a=yield this.getOrCreateRoyaltyVault(i,!0);return this.callContractMethod(a,this.environment.ROYALTY_VAULT_ABI,"claimRoyalty",[null!=e?e:t.zeroAddress],{waitForReceipt:!0})}))}}q=new WeakSet,L=function(e){return 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}}))},W=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}/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}}))},z=function(e){return a(this,arguments,void 0,(function*(e,t={}){var n,i,a;const r=A();let s=e;const o=null!==(n=t.confirmations)&&void 0!==n?n:1,d=null!==(i=t.timeoutMs)&&void 0!==i?i:18e4,u=null!==(a=t.pollingIntervalMs)&&void 0!==a?a:1500;try{return yield r.waitForTransactionReceipt({hash:s,confirmations:o,timeout:d,pollingInterval:u,onReplaced:e=>{s=e.transaction.hash}})}catch(e){
190
+ */claimRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,L,"m",V).call(this,n),a=yield this.getOrCreateRoyaltyVault(i,!0);return this.callContractMethod(a,this.environment.ROYALTY_VAULT_ABI,"claimRoyalty",[null!=e?e:t.zeroAddress],{waitForReceipt:!0})}))}}L=new WeakSet,W=function(e){return 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}}))},q=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}/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}}))},z=function(e){return a(this,arguments,void 0,(function*(e,t={}){var n,i,a;const r=A();let s=e;const o=null!==(n=t.confirmations)&&void 0!==n?n:1,d=null!==(i=t.timeoutMs)&&void 0!==i?i:18e4,u=null!==(a=t.pollingIntervalMs)&&void 0!==a?a:1500;try{return yield r.waitForTransactionReceipt({hash:s,confirmations:o,timeout:d,pollingInterval:u,onReplaced:e=>{s=e.transaction.hash}})}catch(e){
191
191
  // fallback
192
- const t=Date.now();for(;Date.now()-t<d;){try{const e=yield r.getTransactionReceipt({hash:s});if(e&&e.blockNumber)return e}catch(e){}yield new Promise((e=>setTimeout(e,u)))}throw e}}))},J=function(e){return a(this,void 0,void 0,(function*(){
193
- // return;
194
- 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){(e=>{w=e,v=null})// reset public client to be recreated with new chain
192
+ const t=Date.now();for(;Date.now()-t<d;){try{const e=yield r.getTransactionReceipt({hash:s});if(e&&e.blockNumber)return e}catch(e){}yield new Promise((e=>setTimeout(e,u)))}throw e}}))},J=function(e){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected. Could not ensure chain ID.");let t=yield this.viemClient.request({method:"eth_chainId",params:[]});if("string"==typeof t&&(t=parseInt(t,16)),t!==e.id){(e=>{w=e,v=null})// reset public client to be recreated with new chain
195
193
  (e);try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(e.id).toString(16)}]})}catch(t){
196
194
  // Unrecognized chain
197
- 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)}]})}}}))},K=function(e){return a(this,void 0,void 0,(function*(){if(e)return e;if(!this.viemClient)throw new Error("No wallet address provided and no wallet client connected. Please provide an owner address or connect a wallet.");try{const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in connected wallet.");return e[0]}catch(e){throw new Error(`Failed to get wallet address: ${e instanceof Error?e.message:String(e)}`)}}))};G=new WeakMap,V=new WeakSet,Y=function(e,t){r(this,G,"f")[e]&&r(this,G,"f")[e].forEach((e=>e(t)))},X=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 ne(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}))},Z=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)}}))},Q=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)}}))},ee=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)}}))},te=function(e){return i.createSiweMessage({domain:window.location.host,address:this.walletAddress,statement:l,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:e})},exports.Auth=
195
+ 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)}]})}}}))},K=function(){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected. Please connect a wallet.");const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in connected wallet.");return e[0]}))},V=function(e){return a(this,void 0,void 0,(function*(){if(e)return e;if(!this.viemClient)throw new Error("No wallet address provided and no wallet client connected. Please provide an owner address or connect a wallet.");try{const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in connected wallet.");return e[0]}catch(e){throw new Error(`Failed to get wallet address: ${e instanceof Error?e.message:String(e)}`)}}))};Y=new WeakMap,G=new WeakSet,X=function(e,t){r(this,Y,"f")[e]&&r(this,Y,"f")[e].forEach((e=>e(t)))},Z=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 ie(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}))},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 s(e)}}))},ee=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)}}))},te=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)}}))},ne=function(e){return i.createSiweMessage({domain:window.location.host,address:this.walletAddress,statement:p,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:e})},exports.Auth=
198
196
  /**
199
197
  * The Auth class.
200
198
  * @class
@@ -209,7 +207,7 @@ class{
209
207
  * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
210
208
  * @throws {APIError} - Throws an error if the clientId is not provided.
211
209
  */
212
- constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT"}){if(V.add(this),G.set(this,void 0),!e)throw new Error("clientId is required");if(-1===["PRODUCTION","DEVELOPMENT"].indexOf(n))throw new Error("Invalid environment, must be DEVELOPMENT or PRODUCTION");this.viem=null,this.environment=y[n],this.redirectUri=(e=>{const t=["twitter","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,G,{},"f"),g((e=>{r(this,V,"m",Y).call(this,"providers",e)})),r(this,V,"m",X).call(this)}
210
+ constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT"}){if(G.add(this),Y.set(this,void 0),!e)throw new Error("clientId is required");if(-1===["PRODUCTION","DEVELOPMENT"].indexOf(n))throw new Error("Invalid environment, must be DEVELOPMENT or PRODUCTION");this.viem=null,this.environment=y[n],this.redirectUri=(e=>{const t=["twitter","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,Y,{},"f"),b((e=>{r(this,G,"m",X).call(this,"providers",e)})),r(this,G,"m",Z).call(this)}
213
211
  /**
214
212
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
215
213
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
@@ -219,18 +217,18 @@ constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT"}){if(V.add(thi
219
217
  * auth.on("state", (state) => {
220
218
  * console.log(state);
221
219
  * });
222
- */on(e,t){r(this,G,"f")[e]||(r(this,G,"f")[e]=[]),r(this,G,"f")[e].push(t),"providers"===e&&t(b())}
220
+ */on(e,t){r(this,Y,"f")[e]||(r(this,Y,"f")[e]=[]),r(this,Y,"f")[e].push(t),"providers"===e&&t(g())}
223
221
  /**
224
222
  * Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
225
223
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
226
224
  * @param {function} callback The callback function.
227
225
  * @returns {void}
228
- */off(e,t){r(this,G,"f")[e]&&(r(this,G,"f")[e]=r(this,G,"f")[e].filter((e=>e!==t)))}
226
+ */off(e,t){r(this,Y,"f")[e]&&(r(this,Y,"f")[e]=r(this,Y,"f")[e].filter((e=>e!==t)))}
229
227
  /**
230
228
  * Set the loading state.
231
229
  * @param {boolean} loading The loading state.
232
230
  * @returns {void}
233
- */setLoading(e){r(this,V,"m",Y).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
231
+ */setLoading(e){r(this,G,"m",X).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
234
232
  /**
235
233
  * 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.
236
234
  * @param {object} options The options object. Includes the provider and the provider info.
@@ -238,7 +236,7 @@ constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT"}){if(V.add(thi
238
236
  * @throws {APIError} - Throws an error if the provider is not provided.
239
237
  */setProvider({provider:e,info:i,address:a}){if(!e)throw new s("provider is required");this.viem=((e,i="window.ethereum",a,r)=>{var s,d;if(!e&&!f)return console.warn("Provider is required to create a client."),null;const u=a||o;if(!f||f.transport.name!==i&&e||r!==(null===(s=f.account)||void 0===s?void 0:s.address)&&e||(null==w?void 0:w.id)!==u.id){const a={chain:u,transport:t.custom(e,{name:i})};r&&(a.account=n.toAccount(r)),f=t.createWalletClient(a),w=u,v&&(null===(d=v.chain)||void 0===d?void 0:d.id)!==u.id&&(v=null)}return f})(e,i.name,this.environment.CHAIN,a),this.origin&&this.origin.setViemClient(this.viem),
240
238
  // TODO: only use one of these
241
- r(this,V,"m",Y).call(this,"viem",this.viem),r(this,V,"m",Y).call(this,"provider",{provider:e,info:i}),localStorage.setItem("camp-sdk:provider",JSON.stringify(i))}
239
+ r(this,G,"m",X).call(this,"viem",this.viem),r(this,G,"m",X).call(this,"provider",{provider:e,info:i}),localStorage.setItem("camp-sdk:provider",JSON.stringify(i))}
242
240
  /**
243
241
  * 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.
244
242
  * @param {string} walletAddress The wallet address.
@@ -247,7 +245,7 @@ r(this,V,"m",Y).call(this,"viem",this.viem),r(this,V,"m",Y).call(this,"provider"
247
245
  /**
248
246
  * Recover the provider from local storage.
249
247
  * @returns {Promise<void>}
250
- */recoverProvider(){return a(this,void 0,void 0,(function*(){var e,t,n,i,a,r,s,o,d,u,p,l,y;if(!this.walletAddress)return void console.warn("No wallet address found in local storage. Please connect your wallet again.");const c=JSON.parse(localStorage.getItem("camp-sdk:provider")||"{}");let h;const m=null!==(e=b())&&void 0!==e?e:[];
248
+ */recoverProvider(){return a(this,void 0,void 0,(function*(){var e,t,n,i,a,r,s,o,d,u,l,p,y;if(!this.walletAddress)return void console.warn("No wallet address found in local storage. Please connect your wallet again.");const c=JSON.parse(localStorage.getItem("camp-sdk:provider")||"{}");let h;const m=null!==(e=g())&&void 0!==e?e:[];
251
249
  // first pass: try to find provider by UUID/name and check if it has the right address
252
250
  // without prompting (using eth_accounts)
253
251
  for(const e of m)try{if(c.uuid&&(null===(t=e.info)||void 0===t?void 0:t.uuid)===c.uuid||c.name&&(null===(n=e.info)||void 0===n?void 0:n.name)===c.name){
@@ -260,16 +258,16 @@ if(!h)for(const e of m)try{
260
258
  if(c.uuid&&(null===(r=e.info)||void 0===r?void 0:r.uuid)===c.uuid||c.name&&(null===(s=e.info)||void 0===s?void 0:s.name)===c.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())){h=e;break}}catch(e){console.warn("Failed to fetch accounts from provider:",e)}
261
259
  // third pass: if still no provider found and we have UUID/name info,
262
260
  // try prompting the user (only for the stored provider)
263
- if(!h&&(c.uuid||c.name))for(const e of m)try{if(c.uuid&&(null===(u=e.info)||void 0===u?void 0:u.uuid)===c.uuid||c.name&&(null===(p=e.info)||void 0===p?void 0:p.name)===c.name){const t=yield e.provider.request({method:"eth_requestAccounts"});if(t.length>0&&(null===(l=t[0])||void 0===l?void 0:l.toLowerCase())===(null===(y=this.walletAddress)||void 0===y?void 0:y.toLowerCase())){h=e;break}}}catch(e){console.warn("Failed to reconnect to stored provider:",e)}h?this.setProvider({provider:h.provider,info:h.info||{name:"Unknown"},address:this.walletAddress}):console.warn("No matching provider found for the stored wallet address. Please connect your wallet again.")}))}
261
+ if(!h&&(c.uuid||c.name))for(const e of m)try{if(c.uuid&&(null===(u=e.info)||void 0===u?void 0:u.uuid)===c.uuid||c.name&&(null===(l=e.info)||void 0===l?void 0:l.name)===c.name){const t=yield e.provider.request({method:"eth_requestAccounts"});if(t.length>0&&(null===(p=t[0])||void 0===p?void 0:p.toLowerCase())===(null===(y=this.walletAddress)||void 0===y?void 0:y.toLowerCase())){h=e;break}}}catch(e){console.warn("Failed to reconnect to stored provider:",e)}h?this.setProvider({provider:h.provider,info:h.info||{name:"Unknown"},address:this.walletAddress}):console.warn("No matching provider found for the stored wallet address. Please connect your wallet again.")}))}
264
262
  /**
265
263
  * Disconnect the user.
266
264
  * @returns {Promise<void>}
267
- */disconnect(){return a(this,void 0,void 0,(function*(){this.isAuthenticated&&(r(this,V,"m",Y).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"))}))}
265
+ */disconnect(){return a(this,void 0,void 0,(function*(){this.isAuthenticated&&(r(this,G,"m",X).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"))}))}
268
266
  /**
269
267
  * Connect the user's wallet and sign the message.
270
268
  * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
271
269
  * @throws {APIError} - Throws an error if the user cannot be authenticated.
272
- */connect(){return a(this,void 0,void 0,(function*(){r(this,V,"m",Y).call(this,"state","loading");try{this.walletAddress||(yield r(this,V,"m",Z).call(this)),this.walletAddress=t.checksumAddress(this.walletAddress);const e=yield r(this,V,"m",Q).call(this),n=r(this,V,"m",te).call(this,e),i=yield this.viem.signMessage({account:this.walletAddress,message:n}),a=yield r(this,V,"m",ee).call(this,n,i);if(a.success)return this.isAuthenticated=!0,this.userId=a.userId,this.jwt=a.token,this.origin=new ne(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,V,"m",Y).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,r(this,V,"m",Y).call(this,"state","unauthenticated"),new s("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,r(this,V,"m",Y).call(this,"state","unauthenticated"),new s(e)}}))}
270
+ */connect(){return a(this,void 0,void 0,(function*(){r(this,G,"m",X).call(this,"state","loading");try{this.walletAddress||(yield r(this,G,"m",Q).call(this)),this.walletAddress=t.checksumAddress(this.walletAddress);const e=yield r(this,G,"m",ee).call(this),n=r(this,G,"m",ne).call(this,e),i=yield this.viem.signMessage({account:this.walletAddress,message:n}),a=yield r(this,G,"m",te).call(this,n,i);if(a.success)return this.isAuthenticated=!0,this.userId=a.userId,this.jwt=a.token,this.origin=new ie(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",X).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,r(this,G,"m",X).call(this,"state","unauthenticated"),new s("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,r(this,G,"m",X).call(this,"state","unauthenticated"),new s(e)}}))}
273
271
  /**
274
272
  * Get the user's linked social accounts.
275
273
  * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
package/dist/core.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import e from"axios";import{custom as t,createWalletClient as n,createPublicClient as i,http as a,erc20Abi as r,getAbiItem as s,zeroAddress as o,formatEther as d,formatUnits as u,checksumAddress as p}from"viem";import{toAccount as l}from"viem/accounts";import{createSiweMessage as y}from"viem/siwe";
1
+ import e from"axios";import{custom as t,createWalletClient as n,createPublicClient as i,http as a,erc20Abi as r,getAbiItem as s,zeroAddress as o,formatEther as d,formatUnits as u,checksumAddress as l}from"viem";import{toAccount as p}from"viem/accounts";import{createSiweMessage as y}from"viem/siwe";
2
2
  /******************************************************************************
3
3
  Copyright (c) Microsoft Corporation.
4
4
 
@@ -201,7 +201,7 @@ constructor(e){this.apiKey=e.apiKey}
201
201
  * @throws {APIError} - Throws an error if the request fails.
202
202
  */_fetchDataWithAuth(e){return c(this,void 0,void 0,(function*(){if(!this.apiKey)throw new m("API key is required for fetching data",401);try{return yield g(e,{"x-api-key":this.apiKey})}catch(e){throw new m(e.message,e.statusCode)}}))}}
203
203
  // @ts-ignore
204
- let S=null,P=null,x=null;const D=e=>{var t;const n=x||T;return P&&(null===(t=P.chain)||void 0===t?void 0:t.id)===n.id||(P=i({chain:n,transport:a()})),P};let N=[];const O=()=>N,U=e=>{function t(t){N.some((e=>e.info.uuid===t.detail.info.uuid))||(N=[...N,t.detail],e(N))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)};
204
+ let S=null,P=null,x=null;const N=e=>{var t;const n=x||T;return P&&(null===(t=P.chain)||void 0===t?void 0:t.id)===n.id||(P=i({chain:n,transport:a()})),P};let D=[];const O=()=>D,M=e=>{function t(t){D.some((e=>e.info.uuid===t.detail.info.uuid))||(D=[...D,t.detail],e(D))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)};
205
205
  /**
206
206
  * Mints a Data NFT with a signature.
207
207
  * @param to The address to mint the NFT to.
@@ -213,7 +213,7 @@ let S=null,P=null,x=null;const D=e=>{var t;const n=x||T;return P&&(null===(t=P.c
213
213
  * @param deadline The deadline for the minting operation.
214
214
  * @param signature The signature for the minting operation.
215
215
  * @returns A promise that resolves when the minting is complete.
216
- */function M(e,t,n,i,a,r,s,o){return c(this,void 0,void 0,(function*(){return yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"mintWithSignature",[e,t,i,a,r,s,n,o],{waitForReceipt:!0})}))}
216
+ */function U(e,t,n,i,a,r,s,o){return c(this,void 0,void 0,(function*(){return yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"mintWithSignature",[e,t,i,a,r,s,n,o],{waitForReceipt:!0})}))}
217
217
  /**
218
218
  * Registers a Data NFT with the Origin service in order to obtain a signature for minting.
219
219
  * @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
@@ -257,12 +257,12 @@ let S=null,P=null,x=null;const D=e=>{var t;const n=x||T;return P&&(null===(t=P.c
257
257
  * Returns the metadata URI associated with a specific token ID.
258
258
  * @param tokenId The token ID to query.
259
259
  * @returns The metadata URI of the token ID.
260
- */function q(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenURI",[e])}
260
+ */function W(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenURI",[e])}
261
261
  /**
262
262
  * Returns the data status of the given token ID.
263
263
  * @param tokenId The token ID to query.
264
264
  * @returns The data status of the token ID.
265
- */function W(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"dataStatus",[e])}
265
+ */function q(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"dataStatus",[e])}
266
266
  /**
267
267
  * Checks if an operator is approved to manage all assets of a given owner.
268
268
  * @param owner The address of the asset owner.
@@ -289,17 +289,17 @@ let S=null,P=null,x=null;const D=e=>{var t;const n=x||T;return P&&(null===(t=P.c
289
289
  * Approves a spender to spend a specified amount of tokens on behalf of the owner.
290
290
  * If the current allowance is less than the specified amount, it will perform the approval.
291
291
  * @param {ApproveParams} params - The parameters for the approval.
292
- */var Q,ee,te,ne,ie,ae,re,se,oe,de,ue,pe,le,ye;
292
+ */var Q,ee,te,ne,ie,ae,re,se,oe,de,ue,le,pe,ye,ce;
293
293
  /**
294
294
  * The Origin class
295
295
  * Handles the upload of files to Origin, as well as querying the user's stats
296
- */class ce{constructor(e,t,n){Q.add(this),this.jwt=e,this.viemClient=n,this.environment=t,
296
+ */class he{constructor(e,t,n){Q.add(this),this.jwt=e,this.viemClient=n,this.environment=t,
297
297
  // DataNFT methods
298
- this.mintWithSignature=M.bind(this),this.registerIpNFT=B.bind(this),this.updateTerms=F.bind(this),this.finalizeDelete=R.bind(this),this.getOrCreateRoyaltyVault=$.bind(this),this.getTerms=H.bind(this),this.ownerOf=j.bind(this),this.balanceOf=L.bind(this),this.tokenURI=q.bind(this),this.dataStatus=W.bind(this),this.isApprovedForAll=z.bind(this),this.transferFrom=J.bind(this),this.safeTransferFrom=K.bind(this),this.approve=V.bind(this),this.setApprovalForAll=G.bind(this),
298
+ this.mintWithSignature=U.bind(this),this.registerIpNFT=B.bind(this),this.updateTerms=F.bind(this),this.finalizeDelete=R.bind(this),this.getOrCreateRoyaltyVault=$.bind(this),this.getTerms=H.bind(this),this.ownerOf=j.bind(this),this.balanceOf=L.bind(this),this.tokenURI=W.bind(this),this.dataStatus=q.bind(this),this.isApprovedForAll=z.bind(this),this.transferFrom=J.bind(this),this.safeTransferFrom=K.bind(this),this.approve=V.bind(this),this.setApprovalForAll=G.bind(this),
299
299
  // Marketplace methods
300
- this.buyAccess=Y.bind(this),this.hasAccess=X.bind(this),this.subscriptionExpiry=Z.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return c(this,void 0,void 0,(function*(){let i;try{i=yield h(this,Q,"m",ee).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield h(this,Q,"m",te).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield h(this,Q,"m",te).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,a){return c(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const r=yield this.uploadFile(e,a);if(!r||!r.key)throw new Error("Failed to upload file or get upload info.");const s=BigInt(Date.now()+6e5),o=yield this.registerIpNFT("file",s,n,t,r.key,i),{tokenId:d,signerAddress:u,creatorContentHash:p,signature:l,uri:y}=o;// 10 minutes from now
301
- if(!(d&&u&&p&&void 0!==l&&y))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");const c=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],h=yield this.mintWithSignature(c,d,i||[],p,y,n,s,l);if(-1===["0x1","success"].indexOf(h.receipt.status))throw console.error("Minting failed:",h),new Error(`Minting failed with status: ${h.receipt.status}`);return d.toString()}))}mintSocial(e,t,n){return c(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const i=BigInt(Math.floor(Date.now()/1e3)+600),a=yield this.registerIpNFT(e,i,n,t),{tokenId:r,signerAddress:s,creatorContentHash:o,signature:d,uri:u}=a;// 10 minutes from now
302
- if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");const p=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],l=yield this.mintWithSignature(p,r,[],o,u,n,i,d);if(-1===["0x1","success"].indexOf(l.receipt.status))throw new Error(`Minting Social IpNFT failed with status: ${l.receipt.status}`);return r.toString()}))}getOriginUploads(){return c(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
300
+ this.buyAccess=Y.bind(this),this.hasAccess=X.bind(this),this.subscriptionExpiry=Z.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}uploadFile(t,n){return c(this,void 0,void 0,(function*(){let i;try{i=yield h(this,Q,"m",ee).call(this,t)}catch(e){throw console.error("Failed to generate upload URL:",e),new Error(`Failed to generate upload URL: ${e instanceof Error?e.message:String(e)}`)}if(!i)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((t,n,i)=>new Promise(((a,r)=>{e.put(n,t,Object.assign({headers:{"Content-Type":t.type}},"undefined"!=typeof window&&"function"==typeof i?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;i(t)}}}:{})).then((e=>{a(e.data)})).catch((e=>{var t;const n=(null===(t=null==e?void 0:e.response)||void 0===t?void 0:t.data)||(null==e?void 0:e.message)||"Upload failed";r(n)}))})))(t,i.url,(null==n?void 0:n.progressCallback)||(()=>{}))}catch(e){try{yield h(this,Q,"m",te).call(this,i.key,"failed")}catch(e){console.error("Failed to update status to failed:",e)}const t=e instanceof Error?e.message:String(e);throw new Error(`Failed to upload file: ${t}`)}try{yield h(this,Q,"m",te).call(this,i.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return i}))}mintFile(e,t,n,i,a){return c(this,void 0,void 0,(function*(){let r,s=null;try{s=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to mint file IP. Wallet not connected.")}try{if(r=yield this.uploadFile(e,a),!r||!r.key)throw new Error("Failed to upload file or get upload info.")}catch(e){throw new Error(`File upload failed: ${e instanceof Error?e.message:String(e)}`)}const o=BigInt(Date.now()+6e5);// 10 minutes from now
301
+ let d;try{d=yield this.registerIpNFT("file",o,n,t,r.key,i)}catch(e){throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:u,signerAddress:l,creatorContentHash:p,signature:y,uri:c}=d;if(!(u&&l&&p&&void 0!==y&&c))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(s,u,i||[],p,c,n,o,y);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield h(this,Q,"m",te).call(this,r.key,"failed"),new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return u.toString()}))}mintSocial(e,t,n){return c(this,void 0,void 0,(function*(){let i=null;try{i=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to mint social IP. Wallet not connected.")}const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
302
+ let r;try{r=yield this.registerIpNFT(e,a,n,t)}catch(e){throw new Error(`Failed to register Social IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:s,signerAddress:o,creatorContentHash:d,signature:u,uri:l}=r;if(!(s&&o&&d&&void 0!==u&&l))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(i,s,[],d,l,n,a,u);if(-1===["0x1","success"].indexOf(e.receipt.status))throw new Error(`Minting Social IpNFT failed with status: ${e.receipt.status}`)}catch(e){throw new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return s.toString()}))}getOriginUploads(){return c(this,void 0,void 0,(function*(){const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/files`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`}});if(!e.ok)return console.error("Failed to get origin uploads"),null;return(yield e.json()).data}))}
303
303
  /**
304
304
  * Get the user's Origin stats (multiplier, consent, usage, etc.).
305
305
  * @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
@@ -319,14 +319,14 @@ if(!(r&&s&&o&&void 0!==d&&u))throw new Error("Failed to register Social IpNFT: M
319
319
  * @param {CallOptions} [options] The call options.
320
320
  * @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
321
321
  * @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
322
- */callContractMethod(e,t,n,i){return c(this,arguments,void 0,(function*(e,t,n,i,a={}){const r=s({abi:t,name:n});if(r&&"stateMutability"in r&&("view"===r.stateMutability||"pure"===r.stateMutability)){const a=D();return(yield a.readContract({address:e,abi:t,functionName:n,args:i}))||null}if(!this.viemClient)throw new Error("WalletClient not connected.");const[o]=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});yield h(this,Q,"m",ie).call(this,this.environment.CHAIN);const d=D(),{result:u,request:p}=yield d.simulateContract({account:o,address:e,abi:t,functionName:n,args:i,value:a.value});
322
+ */callContractMethod(e,t,n,i){return c(this,arguments,void 0,(function*(e,t,n,i,a={}){var r;let o=null;try{o=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to call contract method. Wallet not connected.")}const d=s({abi:t,name:n});if(d&&"stateMutability"in d&&("view"===d.stateMutability||"pure"===d.stateMutability)){const a=N();return(yield a.readContract({address:e,abi:t,functionName:n,args:i}))||null}yield h(this,Q,"m",ie).call(this,this.environment.CHAIN);const u=N(),{result:l,request:p}=yield u.simulateContract({account:o,address:e,abi:t,functionName:n,args:i,value:a.value});
323
323
  // simulate
324
- if(a.simulate)return u;try{const e=yield this.viemClient.writeContract(p);if("string"!=typeof e)throw new Error("Transaction failed to send.");if(!a.waitForReceipt)return{txHash:e,simulatedResult:u};return{txHash:e,receipt:yield h(this,Q,"m",ne).call(this,e),simulatedResult:u}}catch(e){throw console.error("Transaction failed:",e),new Error("Transaction failed: "+e)}}))}
324
+ if(a.simulate)return l;try{const e=yield null===(r=this.viemClient)||void 0===r?void 0:r.writeContract(p);if("string"!=typeof e)throw new Error("Transaction failed to send.");if(!a.waitForReceipt)return{txHash:e,simulatedResult:l};return{txHash:e,receipt:yield h(this,Q,"m",ne).call(this,e),simulatedResult:l}}catch(e){throw console.error("Transaction failed:",e),new Error("Transaction failed: "+e)}}))}
325
325
  /**
326
326
  * Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
327
327
  * @param {bigint} tokenId The token ID of the asset.
328
328
  * @returns {Promise<any>} The result of the buyAccess call.
329
- */buyAccessSmart(e){return c(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const t=yield this.getTerms(e);if(!t)throw new Error("Failed to fetch terms for asset");const{price:n,paymentToken:i,duration:a}=t;if(void 0===n||void 0===i||void 0===a)throw new Error("Terms missing price, paymentToken, or duration");const s=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],d=n;return i===o?this.buyAccess(s,e,d,a,i,d):(yield function(e){return c(this,arguments,void 0,(function*({walletClient:e,publicClient:t,tokenAddress:n,owner:i,spender:a,amount:s}){(yield t.readContract({address:n,abi:r,functionName:"allowance",args:[i,a]}))<s&&(yield e.writeContract({address:n,account:i,abi:r,functionName:"approve",args:[a,s],chain:T}))}))}({walletClient:this.viemClient,publicClient:D(),tokenAddress:i,owner:s,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:d}),this.buyAccess(s,e,d,a,i))}))}getData(e){return c(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()}))}
329
+ */buyAccessSmart(e){return c(this,void 0,void 0,(function*(){let t=null;try{t=yield h(this,Q,"m",ae).call(this)}catch(e){throw new Error("Failed to buy access. Wallet not connected.")}const n=yield this.getTerms(e);if(!n)throw new Error("Failed to fetch terms for asset");const{price:i,paymentToken:a,duration:s}=n;if(void 0===i||void 0===a||void 0===s)throw new Error("Terms missing price, paymentToken, or duration");const d=i;return a===o?this.buyAccess(t,e,d,s,a,d):(yield function(e){return c(this,arguments,void 0,(function*({walletClient:e,publicClient:t,tokenAddress:n,owner:i,spender:a,amount:s}){(yield t.readContract({address:n,abi:r,functionName:"allowance",args:[i,a]}))<s&&(yield e.writeContract({address:n,account:i,abi:r,functionName:"approve",args:[a,s],chain:T}))}))}({walletClient:this.viemClient,publicClient:N(),tokenAddress:a,owner:t,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:d}),this.buyAccess(t,e,d,s,a))}))}getData(e){return c(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()}))}
330
330
  /**
331
331
  * Get royalty information for a wallet address, including the royalty vault address and its balance.
332
332
  * @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
@@ -341,7 +341,7 @@ if(a.simulate)return u;try{const e=yield this.viemClient.writeContract(p);if("st
341
341
  * // Get royalties for specific address
342
342
  * const royalties = await origin.getRoyalties("0x1234...");
343
343
  * ```
344
- */getRoyalties(e,t){return c(this,void 0,void 0,(function*(){const n=yield h(this,Q,"m",ae).call(this,t);try{const t=yield this.getOrCreateRoyaltyVault(n,!0),i=D();let a,r;if(e&&e!==o){
344
+ */getRoyalties(e,t){return c(this,void 0,void 0,(function*(){const n=yield h(this,Q,"m",re).call(this,t);try{const t=yield this.getOrCreateRoyaltyVault(n,!0),i=N();let a,r;if(e&&e!==o){
345
345
  // erc20 (wrapped camp)
346
346
  const n=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],stateMutability:"view",type:"function"}];a=yield this.callContractMethod(e,n,"balanceOf",[t]);const i=yield this.callContractMethod(e,n,"decimals",[]);r=u(a,i)}else a=yield i.getBalance({address:t}),r=d(a);return{royaltyVault:t,balance:a,balanceFormatted:r}}catch(e){throw new Error(`Failed to retrieve royalties for address ${n}: ${e instanceof Error?e.message:String(e)}`)}}))}
347
347
  /**
@@ -350,20 +350,18 @@ const n=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name
350
350
  * @param {Address} [owner] - Optional wallet address to claim royalties for. If not provided, uses the connected wallet.
351
351
  * @returns {Promise<any>} A promise that resolves when the claim transaction is confirmed.
352
352
  * @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
353
- */claimRoyalties(e,t){return c(this,void 0,void 0,(function*(){const n=yield h(this,Q,"m",ae).call(this,t),i=yield this.getOrCreateRoyaltyVault(n,!0);return this.callContractMethod(i,this.environment.ROYALTY_VAULT_ABI,"claimRoyalty",[null!=e?e:o],{waitForReceipt:!0})}))}}Q=new WeakSet,ee=function(e){return c(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}}))},te=function(e,t){return c(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}}))},ne=function(e){return c(this,arguments,void 0,(function*(e,t={}){var n,i,a;const r=D();let s=e;const o=null!==(n=t.confirmations)&&void 0!==n?n:1,d=null!==(i=t.timeoutMs)&&void 0!==i?i:18e4,u=null!==(a=t.pollingIntervalMs)&&void 0!==a?a:1500;try{return yield r.waitForTransactionReceipt({hash:s,confirmations:o,timeout:d,pollingInterval:u,onReplaced:e=>{s=e.transaction.hash}})}catch(e){
353
+ */claimRoyalties(e,t){return c(this,void 0,void 0,(function*(){const n=yield h(this,Q,"m",re).call(this,t),i=yield this.getOrCreateRoyaltyVault(n,!0);return this.callContractMethod(i,this.environment.ROYALTY_VAULT_ABI,"claimRoyalty",[null!=e?e:o],{waitForReceipt:!0})}))}}Q=new WeakSet,ee=function(e){return c(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}}))},te=function(e,t){return c(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}}))},ne=function(e){return c(this,arguments,void 0,(function*(e,t={}){var n,i,a;const r=N();let s=e;const o=null!==(n=t.confirmations)&&void 0!==n?n:1,d=null!==(i=t.timeoutMs)&&void 0!==i?i:18e4,u=null!==(a=t.pollingIntervalMs)&&void 0!==a?a:1500;try{return yield r.waitForTransactionReceipt({hash:s,confirmations:o,timeout:d,pollingInterval:u,onReplaced:e=>{s=e.transaction.hash}})}catch(e){
354
354
  // fallback
355
- const t=Date.now();for(;Date.now()-t<d;){try{const e=yield r.getTransactionReceipt({hash:s});if(e&&e.blockNumber)return e}catch(e){}yield new Promise((e=>setTimeout(e,u)))}throw e}}))},ie=function(e){return c(this,void 0,void 0,(function*(){
356
- // return;
357
- 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){(e=>{x=e,P=null})// reset public client to be recreated with new chain
355
+ const t=Date.now();for(;Date.now()-t<d;){try{const e=yield r.getTransactionReceipt({hash:s});if(e&&e.blockNumber)return e}catch(e){}yield new Promise((e=>setTimeout(e,u)))}throw e}}))},ie=function(e){return c(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected. Could not ensure chain ID.");let t=yield this.viemClient.request({method:"eth_chainId",params:[]});if("string"==typeof t&&(t=parseInt(t,16)),t!==e.id){(e=>{x=e,P=null})// reset public client to be recreated with new chain
358
356
  (e);try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(e.id).toString(16)}]})}catch(t){
359
357
  // Unrecognized chain
360
- 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)}]})}}}))},ae=function(e){return c(this,void 0,void 0,(function*(){if(e)return e;if(!this.viemClient)throw new Error("No wallet address provided and no wallet client connected. Please provide an owner address or connect a wallet.");try{const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in connected wallet.");return e[0]}catch(e){throw new Error(`Failed to get wallet address: ${e instanceof Error?e.message:String(e)}`)}}))};
358
+ 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)}]})}}}))},ae=function(){return c(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected. Please connect a wallet.");const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in connected wallet.");return e[0]}))},re=function(e){return c(this,void 0,void 0,(function*(){if(e)return e;if(!this.viemClient)throw new Error("No wallet address provided and no wallet client connected. Please provide an owner address or connect a wallet.");try{const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in connected wallet.");return e[0]}catch(e){throw new Error(`Failed to get wallet address: ${e instanceof Error?e.message:String(e)}`)}}))};
361
359
  /**
362
360
  * The Auth class.
363
361
  * @class
364
362
  * @classdesc The Auth class is used to authenticate the user.
365
363
  */
366
- class he{
364
+ class me{
367
365
  /**
368
366
  * Constructor for the Auth class.
369
367
  * @param {object} options The options object.
@@ -372,7 +370,7 @@ class he{
372
370
  * @param {("DEVELOPMENT"|"PRODUCTION")} [options.environment="DEVELOPMENT"] The environment to use.
373
371
  * @throws {APIError} - Throws an error if the clientId is not provided.
374
372
  */
375
- constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT"}){if(re.add(this),se.set(this,void 0),!e)throw new Error("clientId is required");if(-1===["PRODUCTION","DEVELOPMENT"].indexOf(n))throw new Error("Invalid environment, must be DEVELOPMENT or PRODUCTION");this.viem=null,this.environment=I[n],this.redirectUri=(e=>{const t=["twitter","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,se,{},"f"),U((e=>{h(this,re,"m",oe).call(this,"providers",e)})),h(this,re,"m",de).call(this)}
373
+ constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT"}){if(se.add(this),oe.set(this,void 0),!e)throw new Error("clientId is required");if(-1===["PRODUCTION","DEVELOPMENT"].indexOf(n))throw new Error("Invalid environment, must be DEVELOPMENT or PRODUCTION");this.viem=null,this.environment=I[n],this.redirectUri=(e=>{const t=["twitter","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,oe,{},"f"),M((e=>{h(this,se,"m",de).call(this,"providers",e)})),h(this,se,"m",ue).call(this)}
376
374
  /**
377
375
  * Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
378
376
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
@@ -382,26 +380,26 @@ constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT"}){if(re.add(th
382
380
  * auth.on("state", (state) => {
383
381
  * console.log(state);
384
382
  * });
385
- */on(e,t){h(this,se,"f")[e]||(h(this,se,"f")[e]=[]),h(this,se,"f")[e].push(t),"providers"===e&&t(O())}
383
+ */on(e,t){h(this,oe,"f")[e]||(h(this,oe,"f")[e]=[]),h(this,oe,"f")[e].push(t),"providers"===e&&t(O())}
386
384
  /**
387
385
  * Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
388
386
  * @param {("state"|"provider"|"providers"|"viem")} event The event.
389
387
  * @param {function} callback The callback function.
390
388
  * @returns {void}
391
- */off(e,t){h(this,se,"f")[e]&&(h(this,se,"f")[e]=h(this,se,"f")[e].filter((e=>e!==t)))}
389
+ */off(e,t){h(this,oe,"f")[e]&&(h(this,oe,"f")[e]=h(this,oe,"f")[e].filter((e=>e!==t)))}
392
390
  /**
393
391
  * Set the loading state.
394
392
  * @param {boolean} loading The loading state.
395
393
  * @returns {void}
396
- */setLoading(e){h(this,re,"m",oe).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
394
+ */setLoading(e){h(this,se,"m",de).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
397
395
  /**
398
396
  * 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.
399
397
  * @param {object} options The options object. Includes the provider and the provider info.
400
398
  * @returns {void}
401
399
  * @throws {APIError} - Throws an error if the provider is not provided.
402
- */setProvider({provider:e,info:i,address:a}){if(!e)throw new m("provider is required");this.viem=((e,i="window.ethereum",a,r)=>{var s,o;if(!e&&!S)return console.warn("Provider is required to create a client."),null;const d=a||T;if(!S||S.transport.name!==i&&e||r!==(null===(s=S.account)||void 0===s?void 0:s.address)&&e||(null==x?void 0:x.id)!==d.id){const a={chain:d,transport:t(e,{name:i})};r&&(a.account=l(r)),S=n(a),x=d,P&&(null===(o=P.chain)||void 0===o?void 0:o.id)!==d.id&&(P=null)}return S})(e,i.name,this.environment.CHAIN,a),this.origin&&this.origin.setViemClient(this.viem),
400
+ */setProvider({provider:e,info:i,address:a}){if(!e)throw new m("provider is required");this.viem=((e,i="window.ethereum",a,r)=>{var s,o;if(!e&&!S)return console.warn("Provider is required to create a client."),null;const d=a||T;if(!S||S.transport.name!==i&&e||r!==(null===(s=S.account)||void 0===s?void 0:s.address)&&e||(null==x?void 0:x.id)!==d.id){const a={chain:d,transport:t(e,{name:i})};r&&(a.account=p(r)),S=n(a),x=d,P&&(null===(o=P.chain)||void 0===o?void 0:o.id)!==d.id&&(P=null)}return S})(e,i.name,this.environment.CHAIN,a),this.origin&&this.origin.setViemClient(this.viem),
403
401
  // TODO: only use one of these
404
- h(this,re,"m",oe).call(this,"viem",this.viem),h(this,re,"m",oe).call(this,"provider",{provider:e,info:i}),localStorage.setItem("camp-sdk:provider",JSON.stringify(i))}
402
+ h(this,se,"m",de).call(this,"viem",this.viem),h(this,se,"m",de).call(this,"provider",{provider:e,info:i}),localStorage.setItem("camp-sdk:provider",JSON.stringify(i))}
405
403
  /**
406
404
  * 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.
407
405
  * @param {string} walletAddress The wallet address.
@@ -410,7 +408,7 @@ h(this,re,"m",oe).call(this,"viem",this.viem),h(this,re,"m",oe).call(this,"provi
410
408
  /**
411
409
  * Recover the provider from local storage.
412
410
  * @returns {Promise<void>}
413
- */recoverProvider(){return c(this,void 0,void 0,(function*(){var e,t,n,i,a,r,s,o,d,u,p,l,y;if(!this.walletAddress)return void console.warn("No wallet address found in local storage. Please connect your wallet again.");const c=JSON.parse(localStorage.getItem("camp-sdk:provider")||"{}");let h;const m=null!==(e=O())&&void 0!==e?e:[];
411
+ */recoverProvider(){return c(this,void 0,void 0,(function*(){var e,t,n,i,a,r,s,o,d,u,l,p,y;if(!this.walletAddress)return void console.warn("No wallet address found in local storage. Please connect your wallet again.");const c=JSON.parse(localStorage.getItem("camp-sdk:provider")||"{}");let h;const m=null!==(e=O())&&void 0!==e?e:[];
414
412
  // first pass: try to find provider by UUID/name and check if it has the right address
415
413
  // without prompting (using eth_accounts)
416
414
  for(const e of m)try{if(c.uuid&&(null===(t=e.info)||void 0===t?void 0:t.uuid)===c.uuid||c.name&&(null===(n=e.info)||void 0===n?void 0:n.name)===c.name){
@@ -423,16 +421,16 @@ if(!h)for(const e of m)try{
423
421
  if(c.uuid&&(null===(r=e.info)||void 0===r?void 0:r.uuid)===c.uuid||c.name&&(null===(s=e.info)||void 0===s?void 0:s.name)===c.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())){h=e;break}}catch(e){console.warn("Failed to fetch accounts from provider:",e)}
424
422
  // third pass: if still no provider found and we have UUID/name info,
425
423
  // try prompting the user (only for the stored provider)
426
- if(!h&&(c.uuid||c.name))for(const e of m)try{if(c.uuid&&(null===(u=e.info)||void 0===u?void 0:u.uuid)===c.uuid||c.name&&(null===(p=e.info)||void 0===p?void 0:p.name)===c.name){const t=yield e.provider.request({method:"eth_requestAccounts"});if(t.length>0&&(null===(l=t[0])||void 0===l?void 0:l.toLowerCase())===(null===(y=this.walletAddress)||void 0===y?void 0:y.toLowerCase())){h=e;break}}}catch(e){console.warn("Failed to reconnect to stored provider:",e)}h?this.setProvider({provider:h.provider,info:h.info||{name:"Unknown"},address:this.walletAddress}):console.warn("No matching provider found for the stored wallet address. Please connect your wallet again.")}))}
424
+ if(!h&&(c.uuid||c.name))for(const e of m)try{if(c.uuid&&(null===(u=e.info)||void 0===u?void 0:u.uuid)===c.uuid||c.name&&(null===(l=e.info)||void 0===l?void 0:l.name)===c.name){const t=yield e.provider.request({method:"eth_requestAccounts"});if(t.length>0&&(null===(p=t[0])||void 0===p?void 0:p.toLowerCase())===(null===(y=this.walletAddress)||void 0===y?void 0:y.toLowerCase())){h=e;break}}}catch(e){console.warn("Failed to reconnect to stored provider:",e)}h?this.setProvider({provider:h.provider,info:h.info||{name:"Unknown"},address:this.walletAddress}):console.warn("No matching provider found for the stored wallet address. Please connect your wallet again.")}))}
427
425
  /**
428
426
  * Disconnect the user.
429
427
  * @returns {Promise<void>}
430
- */disconnect(){return c(this,void 0,void 0,(function*(){this.isAuthenticated&&(h(this,re,"m",oe).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"))}))}
428
+ */disconnect(){return c(this,void 0,void 0,(function*(){this.isAuthenticated&&(h(this,se,"m",de).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"))}))}
431
429
  /**
432
430
  * Connect the user's wallet and sign the message.
433
431
  * @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
434
432
  * @throws {APIError} - Throws an error if the user cannot be authenticated.
435
- */connect(){return c(this,void 0,void 0,(function*(){h(this,re,"m",oe).call(this,"state","loading");try{this.walletAddress||(yield h(this,re,"m",ue).call(this)),this.walletAddress=p(this.walletAddress);const e=yield h(this,re,"m",pe).call(this),t=h(this,re,"m",ye).call(this,e),n=yield this.viem.signMessage({account:this.walletAddress,message:t}),i=yield h(this,re,"m",le).call(this,t,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new ce(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),h(this,re,"m",oe).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,h(this,re,"m",oe).call(this,"state","unauthenticated"),new m("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,h(this,re,"m",oe).call(this,"state","unauthenticated"),new m(e)}}))}
433
+ */connect(){return c(this,void 0,void 0,(function*(){h(this,se,"m",de).call(this,"state","loading");try{this.walletAddress||(yield h(this,se,"m",le).call(this)),this.walletAddress=l(this.walletAddress);const e=yield h(this,se,"m",pe).call(this),t=h(this,se,"m",ce).call(this,e),n=yield this.viem.signMessage({account:this.walletAddress,message:t}),i=yield h(this,se,"m",ye).call(this,t,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new he(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),h(this,se,"m",de).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,h(this,se,"m",de).call(this,"state","unauthenticated"),new m("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,h(this,se,"m",de).call(this,"state","unauthenticated"),new m(e)}}))}
436
434
  /**
437
435
  * Get the user's linked social accounts.
438
436
  * @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
@@ -506,4 +504,4 @@ if(!h&&(c.uuid||c.name))for(const e of m)try{if(c.uuid&&(null===(u=e.info)||void
506
504
  * @returns {Promise<any>} A promise that resolves with the unlink result.
507
505
  * @throws {Error} - Throws an error if the user is not authenticated.
508
506
  * @throws {APIError} - Throws an error if the request fails.
509
- */unlinkTelegram(){return c(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new m("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 m(e.message||"Failed to unlink Telegram account");return e.data}))}}se=new WeakMap,re=new WeakSet,oe=function(e,t){h(this,se,"f")[e]&&h(this,se,"f")[e].forEach((e=>e(t)))},de=function(e){return c(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 ce(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}))},ue=function(){return c(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=p(e),this.walletAddress}catch(e){throw new m(e)}}))},pe=function(){return c(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)}}))},le=function(e,t){return c(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 m(e)}}))},ye=function(e){return y({domain:window.location.host,address:this.walletAddress,statement:A,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:e})};export{he as Auth,k as SpotifyAPI,C as TwitterAPI};
507
+ */unlinkTelegram(){return c(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new m("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 m(e.message||"Failed to unlink Telegram account");return e.data}))}}oe=new WeakMap,se=new WeakSet,de=function(e,t){h(this,oe,"f")[e]&&h(this,oe,"f")[e].forEach((e=>e(t)))},ue=function(e){return c(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 he(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}))},le=function(){return c(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=l(e),this.walletAddress}catch(e){throw new m(e)}}))},pe=function(){return c(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)}}))},ye=function(e,t){return c(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 m(e)}}))},ce=function(e){return y({domain:window.location.host,address:this.walletAddress,statement:A,uri:window.location.origin,version:"1",chainId:this.viem.chain.id,nonce:e})};export{me as Auth,k as SpotifyAPI,C as TwitterAPI};
@@ -2935,7 +2935,7 @@ function approveIfNeeded(_a) {
2935
2935
  });
2936
2936
  }
2937
2937
 
2938
- var _Origin_instances, _Origin_generateURL, _Origin_setOriginStatus, _Origin_waitForTxReceipt, _Origin_ensureChainId, _Origin_resolveWalletAddress;
2938
+ var _Origin_instances, _Origin_generateURL, _Origin_setOriginStatus, _Origin_waitForTxReceipt, _Origin_ensureChainId, _Origin_getCurrentAccount, _Origin_resolveWalletAddress;
2939
2939
  /**
2940
2940
  * The Origin class
2941
2941
  * Handles the upload of files to Origin, as well as querying the user's stats
@@ -3010,15 +3010,32 @@ class Origin {
3010
3010
  }
3011
3011
  mintFile(file, metadata, license, parents, options) {
3012
3012
  return __awaiter(this, void 0, void 0, function* () {
3013
- if (!this.viemClient) {
3014
- throw new Error("WalletClient not connected.");
3013
+ let account = null;
3014
+ try {
3015
+ account = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_getCurrentAccount).call(this);
3016
+ }
3017
+ catch (error) {
3018
+ throw new Error("Failed to mint file IP. Wallet not connected.");
3015
3019
  }
3016
- const info = yield this.uploadFile(file, options);
3017
- if (!info || !info.key) {
3018
- throw new Error("Failed to upload file or get upload info.");
3020
+ let info;
3021
+ try {
3022
+ info = yield this.uploadFile(file, options);
3023
+ if (!info || !info.key) {
3024
+ throw new Error("Failed to upload file or get upload info.");
3025
+ }
3026
+ }
3027
+ catch (error) {
3028
+ throw new Error(`File upload failed: ${error instanceof Error ? error.message : String(error)}`);
3019
3029
  }
3020
3030
  const deadline = BigInt(Date.now() + 600000); // 10 minutes from now
3021
- const registration = yield this.registerIpNFT("file", deadline, license, metadata, info.key, parents);
3031
+ let registration;
3032
+ try {
3033
+ registration = yield this.registerIpNFT("file", deadline, license, metadata, info.key, parents);
3034
+ }
3035
+ catch (error) {
3036
+ yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_setOriginStatus).call(this, info.key, "failed");
3037
+ throw new Error(`Failed to register IpNFT: ${error instanceof Error ? error.message : String(error)}`);
3038
+ }
3022
3039
  const { tokenId, signerAddress, creatorContentHash, signature, uri } = registration;
3023
3040
  if (!tokenId ||
3024
3041
  !signerAddress ||
@@ -3027,26 +3044,37 @@ class Origin {
3027
3044
  !uri) {
3028
3045
  throw new Error("Failed to register IpNFT: Missing required fields in registration response.");
3029
3046
  }
3030
- const accounts = (yield this.viemClient.request({
3031
- method: "eth_requestAccounts",
3032
- params: [],
3033
- }));
3034
- const account = accounts[0];
3035
- const mintResult = yield this.mintWithSignature(account, tokenId, parents || [], creatorContentHash, uri, license, deadline, signature);
3036
- if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
3037
- console.error("Minting failed:", mintResult);
3038
- throw new Error(`Minting failed with status: ${mintResult.receipt.status}`);
3047
+ try {
3048
+ const mintResult = yield this.mintWithSignature(account, tokenId, parents || [], creatorContentHash, uri, license, deadline, signature);
3049
+ if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
3050
+ yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_setOriginStatus).call(this, info.key, "failed");
3051
+ throw new Error(`Minting failed with status: ${mintResult.receipt.status}`);
3052
+ }
3053
+ }
3054
+ catch (error) {
3055
+ yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_setOriginStatus).call(this, info.key, "failed");
3056
+ throw new Error(`Minting transaction failed: ${error instanceof Error ? error.message : String(error)}`);
3039
3057
  }
3040
3058
  return tokenId.toString();
3041
3059
  });
3042
3060
  }
3043
3061
  mintSocial(source, metadata, license) {
3044
3062
  return __awaiter(this, void 0, void 0, function* () {
3045
- if (!this.viemClient) {
3046
- throw new Error("WalletClient not connected.");
3063
+ let account = null;
3064
+ try {
3065
+ account = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_getCurrentAccount).call(this);
3066
+ }
3067
+ catch (error) {
3068
+ throw new Error("Failed to mint social IP. Wallet not connected.");
3047
3069
  }
3048
3070
  const deadline = BigInt(Math.floor(Date.now() / 1000) + 600); // 10 minutes from now
3049
- const registration = yield this.registerIpNFT(source, deadline, license, metadata);
3071
+ let registration;
3072
+ try {
3073
+ registration = yield this.registerIpNFT(source, deadline, license, metadata);
3074
+ }
3075
+ catch (error) {
3076
+ throw new Error(`Failed to register Social IpNFT: ${error instanceof Error ? error.message : String(error)}`);
3077
+ }
3050
3078
  const { tokenId, signerAddress, creatorContentHash, signature, uri } = registration;
3051
3079
  if (!tokenId ||
3052
3080
  !signerAddress ||
@@ -3055,14 +3083,14 @@ class Origin {
3055
3083
  !uri) {
3056
3084
  throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");
3057
3085
  }
3058
- const accounts = (yield this.viemClient.request({
3059
- method: "eth_requestAccounts",
3060
- params: [],
3061
- }));
3062
- const account = accounts[0];
3063
- const mintResult = yield this.mintWithSignature(account, tokenId, [], creatorContentHash, uri, license, deadline, signature);
3064
- if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
3065
- throw new Error(`Minting Social IpNFT failed with status: ${mintResult.receipt.status}`);
3086
+ try {
3087
+ const mintResult = yield this.mintWithSignature(account, tokenId, [], creatorContentHash, uri, license, deadline, signature);
3088
+ if (["0x1", "success"].indexOf(mintResult.receipt.status) === -1) {
3089
+ throw new Error(`Minting Social IpNFT failed with status: ${mintResult.receipt.status}`);
3090
+ }
3091
+ }
3092
+ catch (error) {
3093
+ throw new Error(`Minting transaction failed: ${error instanceof Error ? error.message : String(error)}`);
3066
3094
  }
3067
3095
  return tokenId.toString();
3068
3096
  });
@@ -3145,6 +3173,14 @@ class Origin {
3145
3173
  */
3146
3174
  callContractMethod(contractAddress_1, abi_1, methodName_1, params_1) {
3147
3175
  return __awaiter(this, arguments, void 0, function* (contractAddress, abi, methodName, params, options = {}) {
3176
+ var _a;
3177
+ let account = null;
3178
+ try {
3179
+ account = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_getCurrentAccount).call(this);
3180
+ }
3181
+ catch (error) {
3182
+ throw new Error("Failed to call contract method. Wallet not connected.");
3183
+ }
3148
3184
  const abiItem = getAbiItem({ abi, name: methodName });
3149
3185
  const isView = abiItem &&
3150
3186
  "stateMutability" in abiItem &&
@@ -3160,18 +3196,11 @@ class Origin {
3160
3196
  })) || null;
3161
3197
  return result;
3162
3198
  }
3163
- if (!this.viemClient) {
3164
- throw new Error("WalletClient not connected.");
3165
- }
3166
- const [account] = (yield this.viemClient.request({
3167
- method: "eth_requestAccounts",
3168
- params: [],
3169
- }));
3170
3199
  yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_ensureChainId).call(this, this.environment.CHAIN);
3171
3200
  const publicClient = getPublicClient();
3172
3201
  // simulate
3173
3202
  const { result: simulatedResult, request } = yield publicClient.simulateContract({
3174
- account,
3203
+ account: account,
3175
3204
  address: contractAddress,
3176
3205
  abi,
3177
3206
  functionName: methodName,
@@ -3182,7 +3211,7 @@ class Origin {
3182
3211
  return simulatedResult;
3183
3212
  }
3184
3213
  try {
3185
- const txHash = yield this.viemClient.writeContract(request);
3214
+ const txHash = yield ((_a = this.viemClient) === null || _a === void 0 ? void 0 : _a.writeContract(request));
3186
3215
  if (typeof txHash !== "string") {
3187
3216
  throw new Error("Transaction failed to send.");
3188
3217
  }
@@ -3205,8 +3234,12 @@ class Origin {
3205
3234
  */
3206
3235
  buyAccessSmart(tokenId) {
3207
3236
  return __awaiter(this, void 0, void 0, function* () {
3208
- if (!this.viemClient) {
3209
- throw new Error("WalletClient not connected.");
3237
+ let account = null;
3238
+ try {
3239
+ account = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_getCurrentAccount).call(this);
3240
+ }
3241
+ catch (error) {
3242
+ throw new Error("Failed to buy access. Wallet not connected.");
3210
3243
  }
3211
3244
  const terms = yield this.getTerms(tokenId);
3212
3245
  if (!terms)
@@ -3217,15 +3250,9 @@ class Origin {
3217
3250
  duration === undefined) {
3218
3251
  throw new Error("Terms missing price, paymentToken, or duration");
3219
3252
  }
3220
- const accounts = (yield this.viemClient.request({
3221
- method: "eth_requestAccounts",
3222
- params: [],
3223
- }));
3224
- const account = accounts[0];
3225
3253
  const totalCost = price;
3226
3254
  const isNative = paymentToken === zeroAddress;
3227
3255
  if (isNative) {
3228
- // return this.buyAccess(account, tokenId, periods, totalCost);
3229
3256
  return this.buyAccess(account, tokenId, totalCost, duration, paymentToken, totalCost);
3230
3257
  }
3231
3258
  yield approveIfNeeded({
@@ -3425,9 +3452,8 @@ _Origin_instances = new WeakSet(), _Origin_generateURL = function _Origin_genera
3425
3452
  });
3426
3453
  }, _Origin_ensureChainId = function _Origin_ensureChainId(chain) {
3427
3454
  return __awaiter(this, void 0, void 0, function* () {
3428
- // return;
3429
3455
  if (!this.viemClient)
3430
- throw new Error("WalletClient not connected.");
3456
+ throw new Error("WalletClient not connected. Could not ensure chain ID.");
3431
3457
  let currentChainId = (yield this.viemClient.request({
3432
3458
  method: "eth_chainId",
3433
3459
  params: [],
@@ -3468,6 +3494,20 @@ _Origin_instances = new WeakSet(), _Origin_generateURL = function _Origin_genera
3468
3494
  }
3469
3495
  }
3470
3496
  });
3497
+ }, _Origin_getCurrentAccount = function _Origin_getCurrentAccount() {
3498
+ return __awaiter(this, void 0, void 0, function* () {
3499
+ if (!this.viemClient) {
3500
+ throw new Error("WalletClient not connected. Please connect a wallet.");
3501
+ }
3502
+ const accounts = yield this.viemClient.request({
3503
+ method: "eth_requestAccounts",
3504
+ params: [],
3505
+ });
3506
+ if (!accounts || accounts.length === 0) {
3507
+ throw new Error("No accounts found in connected wallet.");
3508
+ }
3509
+ return accounts[0];
3510
+ });
3471
3511
  }, _Origin_resolveWalletAddress = function _Origin_resolveWalletAddress(owner) {
3472
3512
  return __awaiter(this, void 0, void 0, function* () {
3473
3513
  if (owner) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@campnetwork/origin",
3
- "version": "1.0.0",
3
+ "version": "1.0.1-alpha.0",
4
4
  "main": "dist/core.cjs",
5
5
  "exports": {
6
6
  ".": {
@@ -53,6 +53,7 @@
53
53
  "@babel/core": "^7.25.8",
54
54
  "@babel/preset-env": "^7.26.0",
55
55
  "@babel/preset-react": "^7.25.9",
56
+ "@release-it/conventional-changelog": "^10.0.1",
56
57
  "@rollup/plugin-babel": "^6.0.4",
57
58
  "@rollup/plugin-json": "^6.1.0",
58
59
  "@rollup/plugin-node-resolve": "^15.3.0",
@@ -76,7 +77,19 @@
76
77
  "release-it": {
77
78
  "$schema": "https://unpkg.com/release-it/schema/release-it.json",
78
79
  "github": {
79
- "release": true
80
+ "release": false
81
+ },
82
+ "git": {
83
+ "commitMessage": "chore: release v${version}",
84
+ "tagName": "v${version}"
85
+ },
86
+ "plugins": {
87
+ "@release-it/conventional-changelog": {
88
+ "preset": "conventionalcommits",
89
+ "infile": "CHANGELOG.md",
90
+ "header": "# Changelog\n\nAll notable changes to this project will be documented in this file.\n",
91
+ "releaseCount": 0
92
+ }
80
93
  }
81
94
  }
82
95
  }