@campnetwork/origin 1.2.1 → 1.2.3
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 +154 -101
- package/dist/core.d.ts +190 -131
- package/dist/core.esm.d.ts +190 -131
- package/dist/core.esm.js +161 -117
- package/dist/react/index.esm.d.ts +57 -3
- package/dist/react/index.esm.js +455 -174
- package/package.json +1 -1
package/dist/core.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{createWalletClient as e,http as t,custom as n,createPublicClient as i,encodeFunctionData as a,checksumAddress as r,zeroAddress as s,keccak256 as o,toBytes as d,erc20Abi as u,getAbiItem as p,formatEther as l,formatUnits as y}from"viem";import{toAccount as c}from"viem/accounts";import{createSiweMessage as m}from"viem/siwe";import h from"axios";
|
|
2
2
|
/******************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,9 +13,51 @@ LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
|
13
13
|
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
14
14
|
PERFORMANCE OF THIS SOFTWARE.
|
|
15
15
|
***************************************************************************** */
|
|
16
|
-
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */function
|
|
16
|
+
/* global Reflect, Promise, SuppressedError, Symbol, Iterator */function T(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 f(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 v(e,t,n,i,a){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!a)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!a:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?a.call(e,n):a?a.value=n:t.set(e,n),n}"function"==typeof SuppressedError&&SuppressedError;
|
|
17
|
+
/**
|
|
18
|
+
* Adapter for viem WalletClient
|
|
19
|
+
*/
|
|
20
|
+
class w{constructor(e){this.type="viem",this.signer=e}getAddress(){return T(this,void 0,void 0,(function*(){if(this.signer.account)return this.signer.account.address;const e=yield this.signer.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in viem wallet client");return e[0]}))}signMessage(e){return T(this,void 0,void 0,(function*(){const t=yield this.getAddress();return yield this.signer.signMessage({account:t,message:e})}))}signTypedData(e,t,n){return T(this,void 0,void 0,(function*(){throw new Error("Viem WalletClient does not support signTypedData")}))}getChainId(){return T(this,void 0,void 0,(function*(){var e;return(null===(e=this.signer.chain)||void 0===e?void 0:e.id)||1}))}}
|
|
21
|
+
/**
|
|
22
|
+
* Adapter for ethers Signer (v5 and v6)
|
|
23
|
+
*/class g{constructor(e){this.type="ethers",this.signer=e}getAddress(){return T(this,void 0,void 0,(function*(){
|
|
24
|
+
// Works for both ethers v5 and v6
|
|
25
|
+
if("function"==typeof this.signer.getAddress)return yield this.signer.getAddress();if(this.signer.address)return this.signer.address;throw new Error("Unable to get address from ethers signer")}))}signMessage(e){return T(this,void 0,void 0,(function*(){if("function"!=typeof this.signer.signMessage)throw new Error("Signer does not support signMessage");return yield this.signer.signMessage(e)}))}signTypedData(e,t,n){return T(this,void 0,void 0,(function*(){if("function"==typeof this.signer._signTypedData)return yield this.signer._signTypedData(e,t,n);if("function"!=typeof this.signer.signTypedData)throw new Error("Signer does not support signTypedData or _signTypedData");return yield this.signer.signTypedData(e,t,n)}))}getChainId(){return T(this,void 0,void 0,(function*(){
|
|
26
|
+
// Try ethers v6 first
|
|
27
|
+
if(this.signer.provider&&"function"==typeof this.signer.provider.getNetwork){const e=yield this.signer.provider.getNetwork();
|
|
28
|
+
// ethers v6 returns bigint, v5 returns number
|
|
29
|
+
return"bigint"==typeof e.chainId?Number(e.chainId):e.chainId}
|
|
30
|
+
// Fallback for ethers v5
|
|
31
|
+
return"function"==typeof this.signer.getChainId?yield this.signer.getChainId():484;
|
|
32
|
+
// Default to mainnet if we can't determine
|
|
33
|
+
}))}}
|
|
34
|
+
/**
|
|
35
|
+
* Adapter for custom signer implementations
|
|
36
|
+
*/class A{constructor(e){this.type="custom",this.signer=e}getAddress(){return T(this,void 0,void 0,(function*(){if("function"==typeof this.signer.getAddress)return yield this.signer.getAddress();if(this.signer.address)return this.signer.address;throw new Error("Custom signer must implement getAddress() or have address property")}))}signMessage(e){return T(this,void 0,void 0,(function*(){if("function"!=typeof this.signer.signMessage)throw new Error("Custom signer must implement signMessage()");return yield this.signer.signMessage(e)}))}signTypedData(e,t,n){return T(this,void 0,void 0,(function*(){if("function"!=typeof this.signer.signTypedData)throw new Error("Custom signer must implement signTypedData()");return yield this.signer.signTypedData(e,t,n)}))}getChainId(){return T(this,void 0,void 0,(function*(){if("function"==typeof this.signer.getChainId){const e=yield this.signer.getChainId();return"bigint"==typeof e?Number(e):e}return void 0!==this.signer.chainId?"bigint"==typeof this.signer.chainId?Number(this.signer.chainId):this.signer.chainId:484;
|
|
37
|
+
// Default to mainnet
|
|
38
|
+
}))}}
|
|
39
|
+
/**
|
|
40
|
+
* Factory function to create appropriate adapter based on signer type
|
|
41
|
+
*/function I(e){
|
|
42
|
+
// Check for viem WalletClient
|
|
43
|
+
return e.transport&&e.chain&&"function"==typeof e.signMessage?new w(e):
|
|
44
|
+
// Check for ethers signer (v5 or v6)
|
|
45
|
+
e._isSigner||e.provider&&"function"==typeof e.signMessage?new g(e):new A(e)}
|
|
46
|
+
/**
|
|
47
|
+
* Browser localStorage adapter
|
|
48
|
+
*/class b{getItem(e){return T(this,void 0,void 0,(function*(){return"undefined"==typeof localStorage?null:localStorage.getItem(e)}))}setItem(e,t){return T(this,void 0,void 0,(function*(){"undefined"!=typeof localStorage&&localStorage.setItem(e,t)}))}removeItem(e){return T(this,void 0,void 0,(function*(){"undefined"!=typeof localStorage&&localStorage.removeItem(e)}))}}
|
|
49
|
+
/**
|
|
50
|
+
* In-memory storage adapter for Node.js
|
|
51
|
+
*/class E{constructor(){this.storage=new Map}getItem(e){return T(this,void 0,void 0,(function*(){return this.storage.get(e)||null}))}setItem(e,t){return T(this,void 0,void 0,(function*(){this.storage.set(e,t)}))}removeItem(e){return T(this,void 0,void 0,(function*(){this.storage.delete(e)}))}clear(){this.storage.clear()}}
|
|
52
|
+
/**
|
|
53
|
+
* Create a wallet client for Node.js environment
|
|
54
|
+
* @param account The viem account
|
|
55
|
+
* @param chain The chain to use
|
|
56
|
+
* @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
|
|
57
|
+
* @returns WalletClient
|
|
58
|
+
*/function C(n,i,a){return e({account:n,chain:i,transport:t(a)})}const _={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/"}}},k={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/"}}};class x 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}}}
|
|
17
59
|
// @ts-ignore
|
|
18
|
-
let A=null,g=null,I=null;const b=e=>{var t;const a=I||v;return g&&(null===(t=g.chain)||void 0===t?void 0:t.id)===a.id||(g=n({chain:a,transport:i()})),g};var E=[{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"approve",inputs:[{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"balanceOf",inputs:[{name:"owner",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"dataStatus",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint8",internalType:"enum IIpNFT.DataStatus"}],stateMutability:"view"},{type:"function",name:"disputeModule",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"erc6551Account",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IERC6551Account"}],stateMutability:"view"},{type:"function",name:"erc6551Registry",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IERC6551Registry"}],stateMutability:"view"},{type:"function",name:"finalizeDelete",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"getAccount",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"account",type:"address",internalType:"address"}],stateMutability:"nonpayable"},{type:"function",name:"getApproved",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"getTerms",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[{name:"name_",type:"string",internalType:"string"},{name:"symbol_",type:"string",internalType:"string"},{name:"maxTermDuration_",type:"uint256",internalType:"uint256"},{name:"signer_",type:"address",internalType:"address"},{name:"wCAMP_",type:"address",internalType:"address"},{name:"minTermDuration_",type:"uint256",internalType:"uint256"},{name:"minPrice_",type:"uint256",internalType:"uint256"},{name:"maxRoyaltyBps_",type:"uint256",internalType:"uint256"},{name:"registry_",type:"address",internalType:"contract IERC6551Registry"},{name:"implementation_",type:"address",internalType:"contract IERC6551Account"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"isApprovedForAll",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"operator",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"markDisputed",inputs:[{name:"_tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"marketPlace",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IMarketplace"}],stateMutability:"view"},{type:"function",name:"maxRoyaltyBps",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"maxTermDuration",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"minPrice",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"minTermDuration",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"mintWithSignature",inputs:[{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"creatorContentHash",type:"bytes32",internalType:"bytes32"},{name:"uri",type:"string",internalType:"string"},{name:"licenseTerms",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"parents",type:"uint256[]",internalType:"uint256[]"},{name:"isIP",type:"bool",internalType:"bool"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"ownerOf",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setApprovalForAll",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"approved",type:"bool",internalType:"bool"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setDisputeModule",inputs:[{name:"_disputeModule",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setMarketPlace",inputs:[{name:"_marketPlace",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setSigner",inputs:[{name:"_signer",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"signer",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"supportsInterface",inputs:[{name:"interfaceId",type:"bytes4",internalType:"bytes4"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"tokenInfo",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"tuple",internalType:"struct IIpNFT.TokenInfo",components:[{name:"tokenURI",type:"string",internalType:"string"},{name:"isIP",type:"bool",internalType:"bool"},{name:"contentHash",type:"bytes32",internalType:"bytes32"},{name:"terms",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]},{name:"status",type:"uint8",internalType:"enum IIpNFT.DataStatus"}]}],stateMutability:"view"},{type:"function",name:"tokenURI",inputs:[{name:"_tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"transferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateTerms",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"newTerms",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"upgradeToAndCall",inputs:[{name:"newImplementation",type:"address",internalType:"address"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"wCAMP",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"uint256",indexed:!1,internalType:"uint256"},{name:"amountPaid",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"AgentRegistered",inputs:[{name:"agentId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"ipNftId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"agentAddress",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Approval",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"ApprovalForAll",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"operator",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"ChildIpTagged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"childIp",type:"uint256",indexed:!0,internalType:"uint256"},{name:"parentIp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeleted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DataMinted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"},{name:"contentHash",type:"bytes32",indexed:!1,internalType:"bytes32"},{name:"parents",type:"uint256[]",indexed:!1,internalType:"uint256[]"}],anonymous:!1},{type:"event",name:"DisputeAssertion",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"counterEvidenceHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"DisputeCancelled",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DisputeJudged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"judgement",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"DisputeModuleUpdated",inputs:[{name:"disputeModule",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DisputeRaised",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"initiator",type:"address",indexed:!0,internalType:"address"},{name:"targetId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"disputeTag",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"version",type:"uint64",indexed:!1,internalType:"uint64"}],anonymous:!1},{type:"event",name:"MarketPlaceUpdated",inputs:[{name:"marketPlace",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Paused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"RoyaltyPaid",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"royaltyAmount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"creator",type:"address",indexed:!1,internalType:"address"},{name:"protocolAmount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"SignerUpdated",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"StatusUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"status",type:"uint8",indexed:!1,internalType:"enum IIpNFT.DataStatus"}],anonymous:!1},{type:"event",name:"TermsUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"newPrice",type:"uint128",indexed:!1,internalType:"uint128"},{name:"newDuration",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"},{name:"paymentToken",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Transfer",inputs:[{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Unpaused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Upgraded",inputs:[{name:"implementation",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressEmptyCode",inputs:[{name:"target",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ERC721IncorrectOwner",inputs:[{name:"sender",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InsufficientApproval",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ERC721InvalidApprover",inputs:[{name:"approver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOperator",inputs:[{name:"operator",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidReceiver",inputs:[{name:"receiver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidSender",inputs:[{name:"sender",type:"address",internalType:"address"}]},{type:"error",name:"ERC721NonexistentToken",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"EnforcedPause",inputs:[]},{type:"error",name:"ExpectedPause",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidDeadline",inputs:[]},{type:"error",name:"InvalidDuration",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidPaymentToken",inputs:[]},{type:"error",name:"InvalidPrice",inputs:[]},{type:"error",name:"InvalidRoyalty",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotTokenOwner",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]},{type:"error",name:"TokenAlreadyExists",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"Unauthorized",inputs:[]}],C=[{type:"function",name:"MAX_PARENTS",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"buyAccess",inputs:[{name:"buyer",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"expectedPrice",type:"uint256",internalType:"uint256"},{name:"expectedDuration",type:"uint32",internalType:"uint32"},{name:"expectedPaymentToken",type:"address",internalType:"address"}],outputs:[],stateMutability:"payable"},{type:"function",name:"hasParentIp",inputs:[{name:"ipId",type:"uint256",internalType:"uint256"},{name:"parent",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[{name:"dataNFT_",type:"address",internalType:"address"},{name:"protocolFeeBps_",type:"uint16",internalType:"uint16"},{name:"treasury_",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"ipToken",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IIpNFT"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"parentRoyaltyPercent",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"protocolFeeBps",inputs:[],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"royaltyStack",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"setParentIpsAndRoyaltyPercents",inputs:[{name:"childIpId",type:"uint256",internalType:"uint256"},{name:"parents",type:"uint256[]",internalType:"uint256[]"},{name:"creator",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"subscriptionExpiry",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"treasury",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateProtocolFee",inputs:[{name:"newFeeBps",type:"uint16",internalType:"uint16"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateTreasury",inputs:[{name:"newTreasury",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"upgradeToAndCall",inputs:[{name:"newImplementation",type:"address",internalType:"address"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"uint256",indexed:!1,internalType:"uint256"},{name:"amountPaid",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"AgentRegistered",inputs:[{name:"agentId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"ipNftId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"agentAddress",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"ChildIpTagged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"childIp",type:"uint256",indexed:!0,internalType:"uint256"},{name:"parentIp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeleted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DataMinted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"},{name:"contentHash",type:"bytes32",indexed:!1,internalType:"bytes32"},{name:"parents",type:"uint256[]",indexed:!1,internalType:"uint256[]"}],anonymous:!1},{type:"event",name:"DisputeAssertion",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"counterEvidenceHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"DisputeCancelled",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DisputeJudged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"judgement",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"DisputeModuleUpdated",inputs:[{name:"disputeModule",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DisputeRaised",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"initiator",type:"address",indexed:!0,internalType:"address"},{name:"targetId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"disputeTag",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"version",type:"uint64",indexed:!1,internalType:"uint64"}],anonymous:!1},{type:"event",name:"MarketPlaceUpdated",inputs:[{name:"marketPlace",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Paused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"RoyaltyPaid",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"royaltyAmount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"creator",type:"address",indexed:!1,internalType:"address"},{name:"protocolAmount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"SignerUpdated",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"StatusUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"status",type:"uint8",indexed:!1,internalType:"enum IIpNFT.DataStatus"}],anonymous:!1},{type:"event",name:"TermsUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"newPrice",type:"uint128",indexed:!1,internalType:"uint128"},{name:"newDuration",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"},{name:"paymentToken",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Unpaused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Upgraded",inputs:[{name:"implementation",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressEmptyCode",inputs:[{name:"target",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"EnforcedPause",inputs:[]},{type:"error",name:"ExpectedPause",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParentIp",inputs:[]},{type:"error",name:"InvalidPayment",inputs:[]},{type:"error",name:"InvalidRoyalty",inputs:[]},{type:"error",name:"MaxParentsExceeded",inputs:[]},{type:"error",name:"MaxRoyaltyExceeded",inputs:[]},{type:"error",name:"NoSubscriptionFound",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]},{type:"error",name:"ParentAlreadyExists",inputs:[]},{type:"error",name:"ParentIpAlreadyDeleted",inputs:[]},{type:"error",name:"ParentIpAlreadyDisputed",inputs:[]},{type:"error",name:"SubscriptionNotAllowed",inputs:[]},{type:"error",name:"TermsMismatch",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]}],_=[{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"}]}],k=[{type:"receive",stateMutability:"payable"},{type:"function",name:"execute",inputs:[{name:"to",type:"address",internalType:"address"},{name:"value",type:"uint256",internalType:"uint256"},{name:"data",type:"bytes",internalType:"bytes"},{name:"operation",type:"uint8",internalType:"uint8"}],outputs:[{name:"result",type:"bytes",internalType:"bytes"}],stateMutability:"payable"},{type:"function",name:"isValidSignature",inputs:[{name:"hash",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[{name:"magicValue",type:"bytes4",internalType:"bytes4"}],stateMutability:"view"},{type:"function",name:"isValidSigner",inputs:[{name:"signer",type:"address",internalType:"address"},{name:"",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"bytes4",internalType:"bytes4"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"state",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"supportsInterface",inputs:[{name:"interfaceId",type:"bytes4",internalType:"bytes4"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"token",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"},{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"}],M="Connect with Camp Network",P=2628e3,x=86400,N=1e15,S=1,D=1e4;const O={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:"0xB53F5723Dd4E46da32e1769Bd36A5aD880e707A5",MARKETPLACE_CONTRACT_ADDRESS:"0x97b0A18B2888e904940fFd19E480a28aeec3F055",CHAIN:v,IPNFT_ABI:E,MARKETPLACE_ABI:C,ROYALTY_VAULT_ABI:_,TBA_ABI:k},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:"0x39EeE1C3989f0dD543Dee60f8582F7F81F522C38",MARKETPLACE_CONTRACT_ADDRESS:"0xc69BAa987757d054455fC0f2d9797684E9FB8b9C",CHAIN:w,IPNFT_ABI:E,MARKETPLACE_ABI:C,ROYALTY_VAULT_ABI:_,TBA_ABI:k}};let R=[];const F=()=>R,U=e=>{function t(t){R.some((e=>e.info.uuid===t.detail.info.uuid))||(R=[...R,t.detail],e(R))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)};
|
|
60
|
+
let N=null,P=null,S=null;const M=e=>{var n;const a=S||_;return P&&(null===(n=P.chain)||void 0===n?void 0:n.id)===a.id||(P=i({chain:a,transport:t()})),P};var D=[{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"approve",inputs:[{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"balanceOf",inputs:[{name:"owner",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"dataStatus",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint8",internalType:"enum IIpNFT.DataStatus"}],stateMutability:"view"},{type:"function",name:"disputeModule",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"erc6551Account",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IERC6551Account"}],stateMutability:"view"},{type:"function",name:"erc6551Registry",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IERC6551Registry"}],stateMutability:"view"},{type:"function",name:"finalizeDelete",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"getAccount",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"account",type:"address",internalType:"address"}],stateMutability:"nonpayable"},{type:"function",name:"getApproved",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"getTerms",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[{name:"name_",type:"string",internalType:"string"},{name:"symbol_",type:"string",internalType:"string"},{name:"maxTermDuration_",type:"uint256",internalType:"uint256"},{name:"signer_",type:"address",internalType:"address"},{name:"wCAMP_",type:"address",internalType:"address"},{name:"minTermDuration_",type:"uint256",internalType:"uint256"},{name:"minPrice_",type:"uint256",internalType:"uint256"},{name:"maxRoyaltyBps_",type:"uint256",internalType:"uint256"},{name:"registry_",type:"address",internalType:"contract IERC6551Registry"},{name:"implementation_",type:"address",internalType:"contract IERC6551Account"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"isApprovedForAll",inputs:[{name:"owner",type:"address",internalType:"address"},{name:"operator",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"markDisputed",inputs:[{name:"_tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"marketPlace",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IMarketplace"}],stateMutability:"view"},{type:"function",name:"maxRoyaltyBps",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"maxTermDuration",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"minPrice",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"minTermDuration",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"mintWithSignature",inputs:[{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"creatorContentHash",type:"bytes32",internalType:"bytes32"},{name:"uri",type:"string",internalType:"string"},{name:"licenseTerms",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"parents",type:"uint256[]",internalType:"uint256[]"},{name:"isIP",type:"bool",internalType:"bool"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"name",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"ownerOf",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"safeTransferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setApprovalForAll",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"approved",type:"bool",internalType:"bool"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setDisputeModule",inputs:[{name:"_disputeModule",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setMarketPlace",inputs:[{name:"_marketPlace",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setSigner",inputs:[{name:"_signer",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"signer",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"supportsInterface",inputs:[{name:"interfaceId",type:"bytes4",internalType:"bytes4"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"symbol",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"tokenInfo",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"tuple",internalType:"struct IIpNFT.TokenInfo",components:[{name:"tokenURI",type:"string",internalType:"string"},{name:"isIP",type:"bool",internalType:"bool"},{name:"contentHash",type:"bytes32",internalType:"bytes32"},{name:"terms",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]},{name:"status",type:"uint8",internalType:"enum IIpNFT.DataStatus"}]}],stateMutability:"view"},{type:"function",name:"tokenURI",inputs:[{name:"_tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"transferFrom",inputs:[{name:"from",type:"address",internalType:"address"},{name:"to",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateTerms",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"newTerms",type:"tuple",internalType:"struct IIpNFT.LicenseTerms",components:[{name:"price",type:"uint128",internalType:"uint128"},{name:"duration",type:"uint32",internalType:"uint32"},{name:"royaltyBps",type:"uint16",internalType:"uint16"},{name:"paymentToken",type:"address",internalType:"address"}]}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"upgradeToAndCall",inputs:[{name:"newImplementation",type:"address",internalType:"address"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"function",name:"wCAMP",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"uint256",indexed:!1,internalType:"uint256"},{name:"amountPaid",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"AgentRegistered",inputs:[{name:"agentId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"ipNftId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"agentAddress",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Approval",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"ApprovalForAll",inputs:[{name:"owner",type:"address",indexed:!0,internalType:"address"},{name:"operator",type:"address",indexed:!0,internalType:"address"},{name:"approved",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"ChildIpTagged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"childIp",type:"uint256",indexed:!0,internalType:"uint256"},{name:"parentIp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeleted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DataMinted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"},{name:"contentHash",type:"bytes32",indexed:!1,internalType:"bytes32"},{name:"parents",type:"uint256[]",indexed:!1,internalType:"uint256[]"}],anonymous:!1},{type:"event",name:"DisputeAssertion",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"counterEvidenceHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"DisputeCancelled",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DisputeJudged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"judgement",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"DisputeModuleUpdated",inputs:[{name:"disputeModule",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DisputeRaised",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"initiator",type:"address",indexed:!0,internalType:"address"},{name:"targetId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"disputeTag",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"version",type:"uint64",indexed:!1,internalType:"uint64"}],anonymous:!1},{type:"event",name:"MarketPlaceUpdated",inputs:[{name:"marketPlace",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Paused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"RoyaltyPaid",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"royaltyAmount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"creator",type:"address",indexed:!1,internalType:"address"},{name:"protocolAmount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"SignerUpdated",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"StatusUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"status",type:"uint8",indexed:!1,internalType:"enum IIpNFT.DataStatus"}],anonymous:!1},{type:"event",name:"TermsUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"newPrice",type:"uint128",indexed:!1,internalType:"uint128"},{name:"newDuration",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"},{name:"paymentToken",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Transfer",inputs:[{name:"from",type:"address",indexed:!0,internalType:"address"},{name:"to",type:"address",indexed:!0,internalType:"address"},{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Unpaused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Upgraded",inputs:[{name:"implementation",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressEmptyCode",inputs:[{name:"target",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"ERC721IncorrectOwner",inputs:[{name:"sender",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InsufficientApproval",inputs:[{name:"operator",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"ERC721InvalidApprover",inputs:[{name:"approver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOperator",inputs:[{name:"operator",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidReceiver",inputs:[{name:"receiver",type:"address",internalType:"address"}]},{type:"error",name:"ERC721InvalidSender",inputs:[{name:"sender",type:"address",internalType:"address"}]},{type:"error",name:"ERC721NonexistentToken",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}]},{type:"error",name:"EnforcedPause",inputs:[]},{type:"error",name:"ExpectedPause",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidDeadline",inputs:[]},{type:"error",name:"InvalidDuration",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidPaymentToken",inputs:[]},{type:"error",name:"InvalidPrice",inputs:[]},{type:"error",name:"InvalidRoyalty",inputs:[]},{type:"error",name:"InvalidSignature",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotTokenOwner",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]},{type:"error",name:"TokenAlreadyExists",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"Unauthorized",inputs:[]}],R=[{type:"function",name:"MAX_PARENTS",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"buyAccess",inputs:[{name:"buyer",type:"address",internalType:"address"},{name:"tokenId",type:"uint256",internalType:"uint256"},{name:"expectedPrice",type:"uint256",internalType:"uint256"},{name:"expectedDuration",type:"uint32",internalType:"uint32"},{name:"expectedPaymentToken",type:"address",internalType:"address"}],outputs:[],stateMutability:"payable"},{type:"function",name:"hasParentIp",inputs:[{name:"ipId",type:"uint256",internalType:"uint256"},{name:"parent",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[{name:"dataNFT_",type:"address",internalType:"address"},{name:"protocolFeeBps_",type:"uint16",internalType:"uint16"},{name:"treasury_",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"ipToken",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IIpNFT"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"parentRoyaltyPercent",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"pause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"paused",inputs:[],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"protocolFeeBps",inputs:[],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"royaltyStack",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"uint16",internalType:"uint16"}],stateMutability:"view"},{type:"function",name:"setParentIpsAndRoyaltyPercents",inputs:[{name:"childIpId",type:"uint256",internalType:"uint256"},{name:"parents",type:"uint256[]",internalType:"uint256[]"},{name:"creator",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"subscriptionExpiry",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"treasury",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"unpause",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateProtocolFee",inputs:[{name:"newFeeBps",type:"uint16",internalType:"uint16"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateTreasury",inputs:[{name:"newTreasury",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"upgradeToAndCall",inputs:[{name:"newImplementation",type:"address",internalType:"address"},{name:"data",type:"bytes",internalType:"bytes"}],outputs:[],stateMutability:"payable"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"uint256",indexed:!1,internalType:"uint256"},{name:"amountPaid",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"AgentRegistered",inputs:[{name:"agentId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"ipNftId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"agentAddress",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"ChildIpTagged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"childIp",type:"uint256",indexed:!0,internalType:"uint256"},{name:"parentIp",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DataDeleted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DataMinted",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"creator",type:"address",indexed:!0,internalType:"address"},{name:"contentHash",type:"bytes32",indexed:!1,internalType:"bytes32"},{name:"parents",type:"uint256[]",indexed:!1,internalType:"uint256[]"}],anonymous:!1},{type:"event",name:"DisputeAssertion",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"counterEvidenceHash",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"DisputeCancelled",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"}],anonymous:!1},{type:"event",name:"DisputeJudged",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"judgement",type:"bool",indexed:!1,internalType:"bool"}],anonymous:!1},{type:"event",name:"DisputeModuleUpdated",inputs:[{name:"disputeModule",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"DisputeRaised",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"initiator",type:"address",indexed:!0,internalType:"address"},{name:"targetId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"disputeTag",type:"bytes32",indexed:!1,internalType:"bytes32"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"version",type:"uint64",indexed:!1,internalType:"uint64"}],anonymous:!1},{type:"event",name:"MarketPlaceUpdated",inputs:[{name:"marketPlace",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"OwnershipTransferred",inputs:[{name:"previousOwner",type:"address",indexed:!0,internalType:"address"},{name:"newOwner",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Paused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"RoyaltyPaid",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"royaltyAmount",type:"uint256",indexed:!1,internalType:"uint256"},{name:"creator",type:"address",indexed:!1,internalType:"address"},{name:"protocolAmount",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"SignerUpdated",inputs:[{name:"signer",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"StatusUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"status",type:"uint8",indexed:!1,internalType:"enum IIpNFT.DataStatus"}],anonymous:!1},{type:"event",name:"TermsUpdated",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"newPrice",type:"uint128",indexed:!1,internalType:"uint128"},{name:"newDuration",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"},{name:"paymentToken",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Unpaused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"Upgraded",inputs:[{name:"implementation",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AddressEmptyCode",inputs:[{name:"target",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"EnforcedPause",inputs:[]},{type:"error",name:"ExpectedPause",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidParentIp",inputs:[]},{type:"error",name:"InvalidPayment",inputs:[]},{type:"error",name:"InvalidRoyalty",inputs:[]},{type:"error",name:"MaxParentsExceeded",inputs:[]},{type:"error",name:"MaxRoyaltyExceeded",inputs:[]},{type:"error",name:"NoSubscriptionFound",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"OwnableInvalidOwner",inputs:[{name:"owner",type:"address",internalType:"address"}]},{type:"error",name:"OwnableUnauthorizedAccount",inputs:[{name:"account",type:"address",internalType:"address"}]},{type:"error",name:"ParentAlreadyExists",inputs:[]},{type:"error",name:"ParentIpAlreadyDeleted",inputs:[]},{type:"error",name:"ParentIpAlreadyDisputed",inputs:[]},{type:"error",name:"SubscriptionNotAllowed",inputs:[]},{type:"error",name:"TermsMismatch",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"Unauthorized",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]}],O=[{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"}]}],U=[{type:"receive",stateMutability:"payable"},{type:"function",name:"execute",inputs:[{name:"to",type:"address",internalType:"address"},{name:"value",type:"uint256",internalType:"uint256"},{name:"data",type:"bytes",internalType:"bytes"},{name:"operation",type:"uint8",internalType:"uint8"}],outputs:[{name:"result",type:"bytes",internalType:"bytes"}],stateMutability:"payable"},{type:"function",name:"isValidSignature",inputs:[{name:"hash",type:"bytes32",internalType:"bytes32"},{name:"signature",type:"bytes",internalType:"bytes"}],outputs:[{name:"magicValue",type:"bytes4",internalType:"bytes4"}],stateMutability:"view"},{type:"function",name:"isValidSigner",inputs:[{name:"signer",type:"address",internalType:"address"},{name:"",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"bytes4",internalType:"bytes4"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"state",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"supportsInterface",inputs:[{name:"interfaceId",type:"bytes4",internalType:"bytes4"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"token",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"},{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"}],F="Connect with Camp Network",B=2628e3,H=86400,$=1e15,j=1,L=1e4;const z={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:"0xB53F5723Dd4E46da32e1769Bd36A5aD880e707A5",MARKETPLACE_CONTRACT_ADDRESS:"0x97b0A18B2888e904940fFd19E480a28aeec3F055",CHAIN:_,IPNFT_ABI:D,MARKETPLACE_ABI:R,ROYALTY_VAULT_ABI:O,TBA_ABI:U},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:"0x39EeE1C3989f0dD543Dee60f8582F7F81F522C38",MARKETPLACE_CONTRACT_ADDRESS:"0xc69BAa987757d054455fC0f2d9797684E9FB8b9C",CHAIN:k,IPNFT_ABI:D,MARKETPLACE_ABI:R,ROYALTY_VAULT_ABI:O,TBA_ABI:U}};let q=[];const J=()=>q,W=e=>{function t(t){q.some((e=>e.info.uuid===t.detail.info.uuid))||(q=[...q,t.detail],e(q))}if("undefined"!=typeof window)return window.addEventListener("eip6963:announceProvider",t),window.dispatchEvent(new Event("eip6963:requestProvider")),()=>window.removeEventListener("eip6963:announceProvider",t)};
|
|
19
61
|
/**
|
|
20
62
|
* Uploads a file to a specified URL with progress tracking.
|
|
21
63
|
* Falls back to a simple fetch request if XMLHttpRequest is not available.
|
|
@@ -37,7 +79,7 @@ let A=null,g=null,I=null;const b=e=>{var t;const a=I||v;return g&&(null===(t=g.c
|
|
|
37
79
|
* @param signature The signature for the minting operation.
|
|
38
80
|
* @returns A promise that resolves when the minting is complete.
|
|
39
81
|
*/
|
|
40
|
-
function
|
|
82
|
+
function V(e,t,n,i,a,r,s,o,d){return T(this,void 0,void 0,(function*(){return yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"mintWithSignature",[e,t,a,r,s,o,n,i,d],{waitForReceipt:!0})}))}
|
|
41
83
|
/**
|
|
42
84
|
* Registers a Data NFT with the Origin service in order to obtain a signature for minting.
|
|
43
85
|
* @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
|
|
@@ -47,55 +89,55 @@ function B(e,t,n,i,a,s,r,o,d){return m(this,void 0,void 0,(function*(){return yi
|
|
|
47
89
|
* @param fileKey The file key(s) if the source is "file".
|
|
48
90
|
* @param parents The IDs of the parent NFTs, if applicable.
|
|
49
91
|
* @return A promise that resolves with the registration data.
|
|
50
|
-
*/function
|
|
92
|
+
*/function K(e,t,n,i,a,r){return T(this,void 0,void 0,(function*(){const s={source:e,deadline:Number(t),licenseTerms:{price:n.price.toString(),duration:n.duration,royaltyBps:n.royaltyBps,paymentToken:n.paymentToken},metadata:i,parentId:r?r.map((e=>e.toString())):[]};void 0!==a&&(s.fileKey=a);const o=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/register`,{method:"POST",headers:{Authorization:`Bearer ${this.getJwt()}`,"Content-Type":"application/json"},body:JSON.stringify(s)});if(!o.ok)throw new Error(`Failed to get signature: ${o.statusText}`);const d=yield o.json();if(d.isError)throw new Error(`Failed to get signature: ${d.message}`);return d.data}))}
|
|
51
93
|
/**
|
|
52
94
|
* Updates the license terms of a specified IPNFT.
|
|
53
95
|
* @param tokenId The ID of the IPNFT to update.
|
|
54
96
|
* @param newTerms The new license terms to set.
|
|
55
97
|
* @returns A promise that resolves when the transaction is complete.
|
|
56
|
-
*/function
|
|
98
|
+
*/function G(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"updateTerms",[e,t],{waitForReceipt:!0})}
|
|
57
99
|
/**
|
|
58
100
|
* Sets the IPNFT as deleted
|
|
59
101
|
* @param tokenId The token ID to set as deleted.
|
|
60
102
|
* @returns A promise that resolves when the transaction is complete.
|
|
61
|
-
*/function
|
|
103
|
+
*/function X(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"finalizeDelete",[e])}
|
|
62
104
|
/**
|
|
63
105
|
* Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
|
|
64
106
|
* @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
|
|
65
107
|
* @param simulateOnly If true, simulates the transaction without executing it.
|
|
66
108
|
* @returns The address of the royalty vault associated with the specified token owner.
|
|
67
|
-
*/function
|
|
109
|
+
*/function Y(e){return T(this,arguments,void 0,(function*(e,t=!1){const n=yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getOrCreateRoyaltyVault",[e],{waitForReceipt:!0,simulate:t});return t?n:n.simulatedResult}))}
|
|
68
110
|
/**
|
|
69
111
|
* Returns the license terms associated with a specific token ID.
|
|
70
112
|
* @param tokenId The token ID to query.
|
|
71
113
|
* @returns The license terms of the token ID.
|
|
72
|
-
*/function
|
|
114
|
+
*/function Z(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getTerms",[e])}
|
|
73
115
|
/**
|
|
74
116
|
* Returns the owner of the specified IPNFT.
|
|
75
117
|
* @param tokenId The ID of the IPNFT to query.
|
|
76
118
|
* @returns The address of the owner of the IPNFT.
|
|
77
|
-
*/function
|
|
119
|
+
*/function Q(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"ownerOf",[e])}
|
|
78
120
|
/**
|
|
79
121
|
* Returns the number of IPNFTs owned by the given address.
|
|
80
122
|
* @param owner The address to query.
|
|
81
123
|
* @returns The number of IPNFTs owned by the address.
|
|
82
|
-
*/function
|
|
124
|
+
*/function ee(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"balanceOf",[e])}
|
|
83
125
|
/**
|
|
84
126
|
* Returns the metadata URI associated with a specific token ID.
|
|
85
127
|
* @param tokenId The token ID to query.
|
|
86
128
|
* @returns The metadata URI of the token ID.
|
|
87
|
-
*/function
|
|
129
|
+
*/function te(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenURI",[e])}
|
|
88
130
|
/**
|
|
89
131
|
* Returns the data status of the given token ID.
|
|
90
132
|
* @param tokenId The token ID to query.
|
|
91
133
|
* @returns The data status of the token ID.
|
|
92
|
-
*/function
|
|
134
|
+
*/function ne(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"dataStatus",[e])}
|
|
93
135
|
/**
|
|
94
136
|
* Checks if an operator is approved to manage all assets of a given owner.
|
|
95
137
|
* @param owner The address of the asset owner.
|
|
96
138
|
* @param operator The address of the operator to check.
|
|
97
139
|
* @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
|
|
98
|
-
*/function
|
|
140
|
+
*/function ie(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"isApprovedForAll",[e,t])}function ae(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"transferFrom",[e,t,n])}function re(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 se(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"approve",[e,t])}function oe(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"setApprovalForAll",[e,t])}
|
|
99
141
|
/**
|
|
100
142
|
* Buys access to a data NFT for a specified duration.
|
|
101
143
|
* @param buyer The address of the buyer.
|
|
@@ -105,25 +147,30 @@ function B(e,t,n,i,a,s,r,o,d){return m(this,void 0,void 0,(function*(){return yi
|
|
|
105
147
|
* @param expectedPaymentToken The address of the payment token (use zero address for native token).
|
|
106
148
|
* @param value The amount of native token to send (only required if paying with native token).
|
|
107
149
|
* @returns A promise that resolves when the transaction is confirmed.
|
|
108
|
-
*/function
|
|
150
|
+
*/function de(e,t,n,i,a,r){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"buyAccess",[e,t,n,i,a],{waitForReceipt:!0,value:r})}
|
|
109
151
|
/**
|
|
110
152
|
* Checks if a user has access to a specific token based on subscription expiry.
|
|
111
153
|
* @param user - The address of the user.
|
|
112
154
|
* @param tokenId - The ID of the token.
|
|
113
155
|
* @returns A promise that resolves to a boolean indicating if the user has access.
|
|
114
|
-
*/function
|
|
115
|
-
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
|
|
156
|
+
*/function ue(e,t){return T(this,void 0,void 0,(function*(){try{const n=yield this.subscriptionExpiry(t,e);return n>BigInt(Math.floor(Date.now()/1e3))}catch(e){return!1}}))}function pe(e,t){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"subscriptionExpiry",[e,t])}
|
|
157
|
+
/**
|
|
158
|
+
* Settles an X402 payment response by purchasing access if needed.
|
|
159
|
+
* This method checks if the user already has access to the item, and if not,
|
|
160
|
+
* it calls buyAccess with the parameters from the X402 response.
|
|
161
|
+
* Supports viem WalletClient, ethers Signer, and custom signer implementations.
|
|
162
|
+
*
|
|
163
|
+
* @param x402Response - The response from getDataWithX402 containing payment details.
|
|
164
|
+
* @param signer - Optional signer object used to interact with the blockchain. If not provided, uses the connected wallet client.
|
|
165
|
+
* @returns A promise that resolves with the transaction hash and receipt, or null if access already exists.
|
|
166
|
+
* @throws {Error} If the response doesn't contain marketplace action or if the method is not buyAccess.
|
|
167
|
+
*/function le(e,t){return T(this,void 0,void 0,(function*(){if(!e.marketplaceAction)throw new Error("No marketplace action found in X402 response");const{marketplaceAction:n}=e;if("buyAccess"!==n.method)throw new Error(`Unsupported marketplace action method: ${n.method}`);const i=BigInt(n.tokenId),r=n.payer;if(yield this.hasAccess(r,i))return console.log("User already has access to this item"),null;const s=BigInt(n.amount),o=BigInt(n.duration),d=n.asset,u="0x0000000000000000000000000000000000000000"===d,p=u?s:BigInt(0);if(t){const e=I(t),n=this.environment.MARKETPLACE_CONTRACT_ADDRESS,u=this.environment.MARKETPLACE_ABI,l=a({abi:u,functionName:"buyAccess",args:[r,i,s,o,d]});if("viem"===e.type){const t=e.signer,i=yield t.sendTransaction({to:n,data:l,value:p,account:yield e.getAddress()});return{txHash:i,receipt:yield t.waitForTransactionReceipt({hash:i})}}if("ethers"===e.type){const t=e.signer,i=yield t.sendTransaction({to:n,data:l,value:p.toString()}),a=yield i.wait();return{txHash:i.hash,receipt:a}}{const t=e.signer;if("function"!=typeof t.sendTransaction)throw new Error("Custom signer must implement sendTransaction() method");const i=yield t.sendTransaction({to:n,data:l,value:p.toString()});if(i.wait&&"function"==typeof i.wait){const e=yield i.wait();return{txHash:i.hash,receipt:e}}return{txHash:i.hash||i}}}if(!this.viemClient)throw new Error("No signer or wallet client provided for settleX402");return yield this.buyAccess(r,i,s,o,d,u?p:void 0)}))}
|
|
120
168
|
/**
|
|
121
169
|
* Enum representing the status of data in the system.
|
|
122
170
|
* * - ACTIVE: The data is currently active and available.
|
|
123
171
|
* * - PENDING_DELETE: The data is scheduled for deletion but not yet removed.
|
|
124
172
|
* * - DELETED: The data has been deleted and is no longer available.
|
|
125
|
-
*/
|
|
126
|
-
var ne;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.PENDING_DELETE=1]="PENDING_DELETE",e[e.DELETED=2]="DELETED"}(ne||(ne={}));
|
|
173
|
+
*/var ye;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.PENDING_DELETE=1]="PENDING_DELETE",e[e.DELETED=2]="DELETED"}(ye||(ye={}));
|
|
127
174
|
/**
|
|
128
175
|
* Creates license terms for a digital asset.
|
|
129
176
|
* @param price The price of the asset in wei.
|
|
@@ -132,17 +179,51 @@ var ne;!function(e){e[e.ACTIVE=0]="ACTIVE",e[e.PENDING_DELETE=1]="PENDING_DELETE
|
|
|
132
179
|
* @param paymentToken The address of the payment token (ERC20 / address(0) for native currency).
|
|
133
180
|
* @returns The created license terms.
|
|
134
181
|
*/
|
|
135
|
-
const
|
|
182
|
+
const ce=(e,t,n,i)=>{if(n<j||n>L)throw new Error(`Royalty basis points must be between ${j} and ${L}`);if(t<H||t>B)throw new Error(`Duration must be between ${H} and ${B} seconds`);if(e<$)throw new Error(`Price must be at least ${$} wei`);return{price:e,duration:t,royaltyBps:n,paymentToken:i}},me={X402Intent:[{name:"payer",type:"address"},{name:"asset",type:"address"},{name:"amount",type:"uint256"},{name:"httpMethod",type:"string"},{name:"payTo",type:"address"},{name:"tokenId",type:"uint256"},{name:"duration",type:"uint32"},{name:"expiresAt",type:"uint256"},{name:"nonce",type:"bytes32"}]};
|
|
183
|
+
/**
|
|
184
|
+
* Defines the EIP-712 typed data structure for X402 Intent signatures.
|
|
185
|
+
*/
|
|
186
|
+
/**
|
|
187
|
+
* Fetch data with X402 payment handling.
|
|
188
|
+
* @param {bigint} tokenId The token ID to fetch data for.
|
|
189
|
+
* @param {any} [signer] Optional signer object for signing the X402 intent.
|
|
190
|
+
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
191
|
+
* @throws {Error} Throws an error if the data cannot be fetched or if no signer/wallet client is provided.
|
|
192
|
+
*/
|
|
193
|
+
function he(e,t){return T(this,void 0,void 0,(function*(){var n;const i=this.viemClient;if(!t&&!i)throw new Error("No signer or wallet client provided for X402 intent.");const a=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/data/${e}`,{method:"GET"});if(402!==a.status){if(!a.ok)throw new Error("Failed to fetch data");return a.json()}const s=i||I(t),o=i?yield ve.call(this):yield s.getAddress(),d=yield a.json();if(d.error)throw new Error(d.error);const u=d.accepts[0],p=yield Te.call(this,u,r(o),s),l=btoa(JSON.stringify(p)),y=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/data/${e}`,{method:"GET",headers:{"Content-Type":"application/json","X-PAYMENT":l}});if(402===y.status)
|
|
194
|
+
// subscription required
|
|
195
|
+
return y.json();if(!y.ok)throw new Error("Failed to fetch data after X402 payment");const c=yield y.json();return{error:null,data:null!==(n=c.data)&&void 0!==n?n:c}}))}
|
|
196
|
+
/**
|
|
197
|
+
* Build the X402 payment payload.
|
|
198
|
+
* @private
|
|
199
|
+
*/function Te(e,t,n){return T(this,void 0,void 0,(function*(){const i="native"===e.asset?s:e.asset,a=BigInt(e.maxAmountRequired||0),u=e.extra.duration,p=fe.call(this),l=me,y=crypto.randomUUID(),c=o(d(y)),m={payer:t,asset:i,amount:a.toString(),httpMethod:"GET",payTo:r(this.environment.MARKETPLACE_CONTRACT_ADDRESS),tokenId:e.extra.tokenId,duration:u,expiresAt:Math.floor(Date.now()/1e3)+e.maxTimeoutSeconds,nonce:c},h=I(n),T=yield h.signTypedData(p,l,m);return{x402Version:1,scheme:"exact",network:e.network,payload:Object.assign(Object.assign({},m),{sigType:"eip712",signature:T,license:{tokenId:e.extra.tokenId,duration:u}})}}))}
|
|
200
|
+
/**
|
|
201
|
+
* Create the X402 Intent domain for EIP-712 signing.
|
|
202
|
+
* @private
|
|
203
|
+
*/function fe(){return{name:"Origin X402 Intent",version:"1",chainId:this.environment.CHAIN.id,verifyingContract:this.environment.MARKETPLACE_CONTRACT_ADDRESS}}
|
|
204
|
+
/**
|
|
205
|
+
* Get the current account address.
|
|
206
|
+
* @private
|
|
207
|
+
*/function ve(){return T(this,void 0,void 0,(function*(){const e=this.viemClient;if(!e)throw new Error("WalletClient not connected. Please connect a wallet.");
|
|
208
|
+
// If account is already set on the client, return it directly
|
|
209
|
+
if(e.account)return e.account.address;
|
|
210
|
+
// Otherwise request accounts (browser wallet flow)
|
|
211
|
+
const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.length)throw new Error("No accounts found in connected wallet.");return t[0]}))}
|
|
212
|
+
/**
|
|
213
|
+
* Approves a spender to spend a specified amount of tokens on behalf of the owner.
|
|
214
|
+
* If the current allowance is less than the specified amount, it will perform the approval.
|
|
215
|
+
* @param {ApproveParams} params - The parameters for the approval.
|
|
216
|
+
*/var we,ge,Ae,Ie,be,Ee,Ce,_e,ke,xe,Ne,Pe,Se,Me,De,Re,Oe,Ue,Fe;
|
|
136
217
|
/**
|
|
137
218
|
* The Origin class
|
|
138
219
|
* Handles the upload of files to Origin, as well as querying the user's stats
|
|
139
|
-
*/class
|
|
220
|
+
*/class Be{constructor(e,t,n,i){we.add(this),t?this.jwt=t:console.warn("JWT not provided. Some features may be unavailable."),this.viemClient=n,this.environment="string"==typeof e?z[e]:e,this.baseParentId=i,
|
|
140
221
|
// DataNFT methods
|
|
141
|
-
this.mintWithSignature=
|
|
222
|
+
this.mintWithSignature=V.bind(this),this.registerIpNFT=K.bind(this),this.updateTerms=G.bind(this),this.finalizeDelete=X.bind(this),this.getOrCreateRoyaltyVault=Y.bind(this),this.getTerms=Z.bind(this),this.ownerOf=Q.bind(this),this.balanceOf=ee.bind(this),this.tokenURI=te.bind(this),this.dataStatus=ne.bind(this),this.isApprovedForAll=ie.bind(this),this.transferFrom=ae.bind(this),this.safeTransferFrom=re.bind(this),this.approve=se.bind(this),this.setApprovalForAll=oe.bind(this),
|
|
142
223
|
// Marketplace methods
|
|
143
|
-
this.buyAccess=
|
|
144
|
-
let d;this.baseParentId&&(i||(i=[]),i.unshift(this.baseParentId));try{d=yield this.registerIpNFT("file",o,n,t,
|
|
145
|
-
let s
|
|
224
|
+
this.buyAccess=de.bind(this),this.hasAccess=ue.bind(this),this.subscriptionExpiry=pe.bind(this),this.settleX402=le.bind(this),this.getDataWithX402=he.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}mintFile(e,t,n,i,a){return T(this,void 0,void 0,(function*(){let r,s=null;try{s=yield f(this,we,"m",Ce).call(this)}catch(e){throw new Error("Failed to mint file IP. Wallet not connected.")}try{if(r=yield f(this,we,"m",Ie).call(this,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)}`)}e.type&&(t.mimetype=e.type);const o=BigInt(Date.now()+6e5);// 10 minutes from now
|
|
225
|
+
let d;this.baseParentId&&(i||(i=[]),i.unshift(this.baseParentId));try{d=yield this.registerIpNFT("file",o,n,t,r.key,i)}catch(e){throw yield f(this,we,"m",Ae).call(this,r.key,"failed"),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:u,signerAddress:p,creatorContentHash:l,signature:y,uri:c}=d;if(!(u&&p&&l&&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||[],!0,l,c,n,o,y);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield f(this,we,"m",Ae).call(this,r.key,"failed"),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield f(this,we,"m",Ae).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 T(this,void 0,void 0,(function*(){let i=null;try{i=yield f(this,we,"m",Ce).call(this)}catch(e){throw new Error("Failed to mint social IP. Wallet not connected.")}t.mimetype=`social/${e}`;const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
|
|
226
|
+
let r,s=this.baseParentId?[this.baseParentId]:[];try{r=yield this.registerIpNFT(e,a,n,t,void 0,s)}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:p,uri:l}=r;if(!(o&&d&&u&&void 0!==p&&l))throw new Error("Failed to register Social IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(i,o,s,!0,u,l,n,a,p);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()}))}
|
|
146
227
|
/**
|
|
147
228
|
* Call a contract method.
|
|
148
229
|
* @param {string} contractAddress The contract address.
|
|
@@ -152,14 +233,20 @@ let s,r=this.baseParentId?[this.baseParentId]:[];try{s=yield this.registerIpNFT(
|
|
|
152
233
|
* @param {CallOptions} [options] The call options.
|
|
153
234
|
* @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
|
|
154
235
|
* @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
|
|
155
|
-
*/callContractMethod(e,t,n,i){return
|
|
236
|
+
*/callContractMethod(e,t,n,i){return T(this,arguments,void 0,(function*(e,t,n,i,a={}){var r;let s=null;try{s=yield f(this,we,"m",Ce).call(this)}catch(e){throw new Error("Failed to call contract method. Wallet not connected.")}const o=p({abi:t,name:n});if(o&&"stateMutability"in o&&("view"===o.stateMutability||"pure"===o.stateMutability)){const a=M();return(yield a.readContract({address:e,abi:t,functionName:n,args:i}))||null}yield f(this,we,"m",Ee).call(this,this.environment.CHAIN);const d=M(),{result:u,request:l}=yield d.simulateContract({account:s,address:e,abi:t,functionName:n,args:i,value:a.value});
|
|
156
237
|
// simulate
|
|
157
|
-
if(a.simulate)return
|
|
238
|
+
if(a.simulate)return u;try{const e=yield null===(r=this.viemClient)||void 0===r?void 0:r.writeContract(l);if("string"!=typeof e)throw new Error("Transaction failed to send.");if(!a.waitForReceipt)return{txHash:e,simulatedResult:u};return{txHash:e,receipt:yield f(this,we,"m",be).call(this,e),simulatedResult:u}}catch(e){throw console.error("Transaction failed:",e),new Error("Transaction failed: "+e)}}))}
|
|
158
239
|
/**
|
|
159
240
|
* Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
|
|
160
241
|
* @param {bigint} tokenId The token ID of the asset.
|
|
161
242
|
* @returns {Promise<any>} The result of the buyAccess call.
|
|
162
|
-
*/buyAccessSmart(e){return
|
|
243
|
+
*/buyAccessSmart(e){return T(this,void 0,void 0,(function*(){let t=null;try{t=yield f(this,we,"m",Ce).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:r}=n;if(void 0===i||void 0===a||void 0===r)throw new Error("Terms missing price, paymentToken, or duration");const o=i;return a===s?this.buyAccess(t,e,o,r,a,o):(yield function(e){return T(this,arguments,void 0,(function*({walletClient:e,publicClient:t,tokenAddress:n,owner:i,spender:a,amount:r}){(yield t.readContract({address:n,abi:u,functionName:"allowance",args:[i,a]}))<r&&(yield e.writeContract({address:n,account:i,abi:u,functionName:"approve",args:[a,r],chain:_}))}))}({walletClient:this.viemClient,publicClient:M(),tokenAddress:a,owner:t,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:o}),this.buyAccess(t,e,o,r,a))}))}
|
|
244
|
+
/**
|
|
245
|
+
* Fetch the underlying data associated with a specific token ID.
|
|
246
|
+
* @param {bigint} tokenId - The token ID to fetch data for.
|
|
247
|
+
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
248
|
+
* @throws {Error} Throws an error if the data cannot be fetched.
|
|
249
|
+
*/getData(e){return T(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()}))}
|
|
163
250
|
/**
|
|
164
251
|
* Get the Token Bound Account (TBA) address for a specific token ID.
|
|
165
252
|
* @param {bigint} tokenId - The token ID to get the TBA address for.
|
|
@@ -170,7 +257,7 @@ if(a.simulate)return p;try{const e=yield null===(r=this.viemClient)||void 0===r?
|
|
|
170
257
|
* const tbaAddress = await origin.getTokenBoundAccount(1n);
|
|
171
258
|
* console.log(`TBA Address: ${tbaAddress}`);
|
|
172
259
|
* ```
|
|
173
|
-
*/getTokenBoundAccount(e){return
|
|
260
|
+
*/getTokenBoundAccount(e){return T(this,void 0,void 0,(function*(){try{return yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getAccount",[e],{simulate:!0})}catch(t){throw new Error(`Failed to get Token Bound Account for token ${e}: ${t instanceof Error?t.message:String(t)}`)}}))}
|
|
174
261
|
/**
|
|
175
262
|
* Get royalty information for a token ID, including the token bound account address and its balance.
|
|
176
263
|
* @param {bigint} tokenId - The token ID to check royalties for.
|
|
@@ -185,9 +272,9 @@ if(a.simulate)return p;try{const e=yield null===(r=this.viemClient)||void 0===r?
|
|
|
185
272
|
* // Get ERC20 token royalties for a specific token
|
|
186
273
|
* const royalties = await origin.getRoyalties(1n, "0x1234...");
|
|
187
274
|
* ```
|
|
188
|
-
*/getRoyalties(e,t){return
|
|
275
|
+
*/getRoyalties(e,t){return T(this,void 0,void 0,(function*(){try{const n=yield this.getTokenBoundAccount(e),i=M();let a,r;if(t&&t!==s){
|
|
189
276
|
// erc20 (wrapped camp)
|
|
190
|
-
const e=[{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(t,e,"balanceOf",[n]);const i=yield this.callContractMethod(t,e,"decimals",[]);
|
|
277
|
+
const e=[{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(t,e,"balanceOf",[n]);const i=yield this.callContractMethod(t,e,"decimals",[]);r=y(a,i)}else a=yield i.getBalance({address:n}),r=l(a);return{tokenBoundAccount:n,balance:a,balanceFormatted:r}}catch(t){throw new Error(`Failed to retrieve royalties for token ${e}: ${t instanceof Error?t.message:String(t)}`)}}))}
|
|
191
278
|
/**
|
|
192
279
|
* Claim royalties from a token's Token Bound Account (TBA).
|
|
193
280
|
* @param {bigint} tokenId - The token ID to claim royalties from.
|
|
@@ -203,66 +290,31 @@ const e=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name
|
|
|
203
290
|
* // Claim ERC20 token royalties to a specific address
|
|
204
291
|
* await origin.claimRoyalties(1n, "0xRecipient...", "0xToken...");
|
|
205
292
|
* ```
|
|
206
|
-
*/claimRoyalties(e,t,n){return
|
|
293
|
+
*/claimRoyalties(e,t,n){return T(this,void 0,void 0,(function*(){const i=yield f(this,we,"m",_e).call(this,t),r=yield this.getTokenBoundAccount(e),o=(yield this.getRoyalties(e,n)).balance;if(o===BigInt(0))throw new Error("No royalties available to claim");let d,u,p;
|
|
207
294
|
// Call execute on the TBA
|
|
208
|
-
return n&&n!==
|
|
295
|
+
return n&&n!==s?(
|
|
209
296
|
// ERC20 token transfer
|
|
210
|
-
|
|
297
|
+
d=n,u=BigInt(0),
|
|
211
298
|
// Encode ERC20 transfer call: transfer(address to, uint256 amount)
|
|
212
|
-
p=
|
|
299
|
+
p=a({abi:[{inputs:[{name:"to",type:"address"},{name:"amount",type:"uint256"}],name:"transfer",outputs:[{name:"",type:"bool"}],stateMutability:"nonpayable",type:"function"}],functionName:"transfer",args:[i,o]})):(
|
|
213
300
|
// Native token transfer
|
|
214
|
-
|
|
215
|
-
{waitForReceipt:!0,value:BigInt(0)})}))}}
|
|
301
|
+
d=i,u=o,p="0x"),this.callContractMethod(r,this.environment.TBA_ABI,"execute",[d,u,p,0],// operation: 0 = CALL
|
|
302
|
+
{waitForReceipt:!0,value:BigInt(0)})}))}}we=new WeakSet,ge=function(e){return T(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}}))},Ae=function(e,t){return T(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}}))},Ie=function(e,t){return T(this,void 0,void 0,(function*(){let n;try{n=yield f(this,we,"m",ge).call(this,e)}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(!n)throw new Error("Failed to generate upload URL: No upload info returned");try{yield((e,t,n)=>new Promise(((i,a)=>{h.put(t,e,Object.assign({headers:{"Content-Type":e.type}},"undefined"!=typeof window&&"function"==typeof n?{onUploadProgress:e=>{if(e.total){const t=e.loaded/e.total*100;n(t)}}}:{})).then((e=>{i(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";a(n)}))})))(e,n.url,(null==t?void 0:t.progressCallback)||(()=>{}))}catch(e){try{yield f(this,we,"m",Ae).call(this,n.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 f(this,we,"m",Ae).call(this,n.key,"success")}catch(e){console.error("Failed to update status to success:",e)}return n}))},be=function(e){return T(this,arguments,void 0,(function*(e,t={}){var n,i,a;const r=M();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){
|
|
216
303
|
// fallback
|
|
217
|
-
const t=Date.now();for(;Date.now()-t<d;){try{const e=yield
|
|
304
|
+
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}}))},Ee=function(e){return T(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=>{S=e,P=null})// reset public client to be recreated with new chain
|
|
218
305
|
(e);try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(e.id).toString(16)}]})}catch(t){
|
|
219
306
|
// Unrecognized chain
|
|
220
|
-
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)}]})}}}))},
|
|
307
|
+
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)}]})}}}))},Ce=function(){return T(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected. Please connect a wallet.");
|
|
221
308
|
// If account is already set on the client, return it directly
|
|
222
309
|
if(this.viemClient.account)return this.viemClient.account.address;
|
|
223
310
|
// Otherwise request accounts (browser wallet flow)
|
|
224
|
-
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]}))},
|
|
225
|
-
/**
|
|
226
|
-
* Adapter for viem WalletClient
|
|
227
|
-
*/
|
|
228
|
-
class Ee{constructor(e){this.type="viem",this.signer=e}getAddress(){return m(this,void 0,void 0,(function*(){if(this.signer.account)return this.signer.account.address;const e=yield this.signer.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new Error("No accounts found in viem wallet client");return e[0]}))}signMessage(e){return m(this,void 0,void 0,(function*(){const t=yield this.getAddress();return yield this.signer.signMessage({account:t,message:e})}))}getChainId(){return m(this,void 0,void 0,(function*(){var e;return(null===(e=this.signer.chain)||void 0===e?void 0:e.id)||1}))}}
|
|
229
|
-
/**
|
|
230
|
-
* Adapter for ethers Signer (v5 and v6)
|
|
231
|
-
*/class Ce{constructor(e){this.type="ethers",this.signer=e}getAddress(){return m(this,void 0,void 0,(function*(){
|
|
232
|
-
// Works for both ethers v5 and v6
|
|
233
|
-
if("function"==typeof this.signer.getAddress)return yield this.signer.getAddress();if(this.signer.address)return this.signer.address;throw new Error("Unable to get address from ethers signer")}))}signMessage(e){return m(this,void 0,void 0,(function*(){if("function"!=typeof this.signer.signMessage)throw new Error("Signer does not support signMessage");return yield this.signer.signMessage(e)}))}getChainId(){return m(this,void 0,void 0,(function*(){
|
|
234
|
-
// Try ethers v6 first
|
|
235
|
-
if(this.signer.provider&&"function"==typeof this.signer.provider.getNetwork){const e=yield this.signer.provider.getNetwork();
|
|
236
|
-
// ethers v6 returns bigint, v5 returns number
|
|
237
|
-
return"bigint"==typeof e.chainId?Number(e.chainId):e.chainId}
|
|
238
|
-
// Fallback for ethers v5
|
|
239
|
-
return"function"==typeof this.signer.getChainId?yield this.signer.getChainId():484;
|
|
240
|
-
// Default to mainnet if we can't determine
|
|
241
|
-
}))}}
|
|
242
|
-
/**
|
|
243
|
-
* Adapter for custom signer implementations
|
|
244
|
-
*/class _e{constructor(e){this.type="custom",this.signer=e}getAddress(){return m(this,void 0,void 0,(function*(){if("function"==typeof this.signer.getAddress)return yield this.signer.getAddress();if(this.signer.address)return this.signer.address;throw new Error("Custom signer must implement getAddress() or have address property")}))}signMessage(e){return m(this,void 0,void 0,(function*(){if("function"!=typeof this.signer.signMessage)throw new Error("Custom signer must implement signMessage()");return yield this.signer.signMessage(e)}))}getChainId(){return m(this,void 0,void 0,(function*(){if("function"==typeof this.signer.getChainId){const e=yield this.signer.getChainId();return"bigint"==typeof e?Number(e):e}return void 0!==this.signer.chainId?"bigint"==typeof this.signer.chainId?Number(this.signer.chainId):this.signer.chainId:484;
|
|
245
|
-
// Default to mainnet
|
|
246
|
-
}))}}
|
|
247
|
-
/**
|
|
248
|
-
* Factory function to create appropriate adapter based on signer type
|
|
249
|
-
*/function ke(e){
|
|
250
|
-
// Check for viem WalletClient
|
|
251
|
-
return e.transport&&e.chain&&"function"==typeof e.signMessage?new Ee(e):
|
|
252
|
-
// Check for ethers signer (v5 or v6)
|
|
253
|
-
e._isSigner||e.provider&&"function"==typeof e.signMessage?new Ce(e):new _e(e)}
|
|
254
|
-
/**
|
|
255
|
-
* Browser localStorage adapter
|
|
256
|
-
*/class Me{getItem(e){return m(this,void 0,void 0,(function*(){return"undefined"==typeof localStorage?null:localStorage.getItem(e)}))}setItem(e,t){return m(this,void 0,void 0,(function*(){"undefined"!=typeof localStorage&&localStorage.setItem(e,t)}))}removeItem(e){return m(this,void 0,void 0,(function*(){"undefined"!=typeof localStorage&&localStorage.removeItem(e)}))}}
|
|
257
|
-
/**
|
|
258
|
-
* In-memory storage adapter for Node.js
|
|
259
|
-
*/class Pe{constructor(){this.storage=new Map}getItem(e){return m(this,void 0,void 0,(function*(){return this.storage.get(e)||null}))}setItem(e,t){return m(this,void 0,void 0,(function*(){this.storage.set(e,t)}))}removeItem(e){return m(this,void 0,void 0,(function*(){this.storage.delete(e)}))}clear(){this.storage.clear()}}
|
|
311
|
+
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]}))},_e=function(e){return T(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)}`)}}))};
|
|
260
312
|
/**
|
|
261
313
|
* The Auth class.
|
|
262
314
|
* @class
|
|
263
315
|
* @classdesc The Auth class is used to authenticate the user.
|
|
264
316
|
*/
|
|
265
|
-
class
|
|
317
|
+
class He{
|
|
266
318
|
/**
|
|
267
319
|
* Constructor for the Auth class.
|
|
268
320
|
* @param {object} options The options object.
|
|
@@ -272,9 +324,9 @@ class xe{
|
|
|
272
324
|
* @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
|
|
273
325
|
* @throws {APIError} - Throws an error if the clientId is not provided.
|
|
274
326
|
*/
|
|
275
|
-
constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT",baseParentId:i,storage:a}){if(
|
|
327
|
+
constructor({clientId:e,redirectUri:t,environment:n="DEVELOPMENT",baseParentId:i,storage:a}){if(ke.add(this),xe.set(this,void 0),Ne.set(this,void 0),Pe.set(this,void 0),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");v(this,Ne,"undefined"==typeof window,"f"),v(this,Se,a||(f(this,Ne,"f")?new E:new b),"f"),this.viem=null,this.environment=z[n],this.baseParentId=i,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,v(this,xe,{},"f"),
|
|
276
328
|
// only subscribe to providers in browser environment
|
|
277
|
-
|
|
329
|
+
f(this,Ne,"f")||W((e=>{f(this,ke,"m",Me).call(this,"providers",e)})),f(this,ke,"m",De).call(this)}
|
|
278
330
|
/**
|
|
279
331
|
* Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
|
|
280
332
|
* @param {("state"|"provider"|"providers"|"viem")} event The event.
|
|
@@ -284,26 +336,26 @@ h(this,me,"f")||U((e=>{h(this,ye,"m",fe).call(this,"providers",e)})),h(this,ye,"
|
|
|
284
336
|
* auth.on("state", (state) => {
|
|
285
337
|
* console.log(state);
|
|
286
338
|
* });
|
|
287
|
-
*/on(e,t){
|
|
339
|
+
*/on(e,t){f(this,xe,"f")[e]||(f(this,xe,"f")[e]=[]),f(this,xe,"f")[e].push(t),"providers"===e&&t(J())}
|
|
288
340
|
/**
|
|
289
341
|
* Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
|
|
290
342
|
* @param {("state"|"provider"|"providers"|"viem")} event The event.
|
|
291
343
|
* @param {function} callback The callback function.
|
|
292
344
|
* @returns {void}
|
|
293
|
-
*/off(e,t){
|
|
345
|
+
*/off(e,t){f(this,xe,"f")[e]&&(f(this,xe,"f")[e]=f(this,xe,"f")[e].filter((e=>e!==t)))}
|
|
294
346
|
/**
|
|
295
347
|
* Set the loading state.
|
|
296
348
|
* @param {boolean} loading The loading state.
|
|
297
349
|
* @returns {void}
|
|
298
|
-
*/setLoading(e){
|
|
350
|
+
*/setLoading(e){f(this,ke,"m",Me).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
|
|
299
351
|
/**
|
|
300
352
|
* 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.
|
|
301
353
|
* @param {object} options The options object. Includes the provider and the provider info.
|
|
302
354
|
* @returns {void}
|
|
303
355
|
* @throws {APIError} - Throws an error if the provider is not provided.
|
|
304
|
-
*/setProvider({provider:
|
|
356
|
+
*/setProvider({provider:t,info:i,address:a}){if(!t)throw new x("provider is required");this.viem=((t,i="window.ethereum",a,r)=>{var s,o;if(!t&&!N)return console.warn("Provider is required to create a client."),null;const d=a||_;if(!N||N.transport.name!==i&&t||r!==(null===(s=N.account)||void 0===s?void 0:s.address)&&t||(null==S?void 0:S.id)!==d.id){const a={chain:d,transport:n(t,{name:i})};r&&(a.account=c(r)),N=e(a),S=d,P&&(null===(o=P.chain)||void 0===o?void 0:o.id)!==d.id&&(P=null)}return N})(t,i.name,this.environment.CHAIN,a),this.origin&&this.origin.setViemClient(this.viem),
|
|
305
357
|
// TODO: only use one of these
|
|
306
|
-
|
|
358
|
+
f(this,ke,"m",Me).call(this,"viem",this.viem),f(this,ke,"m",Me).call(this,"provider",{provider:t,info:i}),f(this,Se,"f").setItem("camp-sdk:provider",JSON.stringify(i))}
|
|
307
359
|
/**
|
|
308
360
|
* 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.
|
|
309
361
|
* @param {string} walletAddress The wallet address.
|
|
@@ -312,29 +364,29 @@ h(this,ye,"m",fe).call(this,"viem",this.viem),h(this,ye,"m",fe).call(this,"provi
|
|
|
312
364
|
/**
|
|
313
365
|
* Recover the provider from local storage.
|
|
314
366
|
* @returns {Promise<void>}
|
|
315
|
-
*/recoverProvider(){return
|
|
367
|
+
*/recoverProvider(){return T(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=yield f(this,Se,"f").getItem("camp-sdk:provider");if(!c)return;const m=JSON.parse(c);let h;const T=null!==(e=J())&&void 0!==e?e:[];
|
|
316
368
|
// first pass: try to find provider by UUID/name and check if it has the right address
|
|
317
369
|
// without prompting (using eth_accounts)
|
|
318
|
-
for(const e of
|
|
370
|
+
for(const e of T)try{if(m.uuid&&(null===(t=e.info)||void 0===t?void 0:t.uuid)===m.uuid||m.name&&(null===(n=e.info)||void 0===n?void 0:n.name)===m.name){
|
|
319
371
|
// silently check if the wallet address matches first
|
|
320
|
-
const t=yield e.provider.request({method:"eth_accounts"});if(t.length>0&&(null===(i=t[0])||void 0===i?void 0:i.toLowerCase())===(null===(a=this.walletAddress)||void 0===a?void 0:a.toLowerCase())){
|
|
372
|
+
const t=yield e.provider.request({method:"eth_accounts"});if(t.length>0&&(null===(i=t[0])||void 0===i?void 0:i.toLowerCase())===(null===(a=this.walletAddress)||void 0===a?void 0:a.toLowerCase())){h=e;break}}}catch(e){console.warn("Failed to fetch accounts from provider:",e)}
|
|
321
373
|
// second pass: if no provider found by UUID/name match, try to find by address only
|
|
322
374
|
// but still avoid prompting
|
|
323
|
-
if(!
|
|
375
|
+
if(!h)for(const e of T)try{
|
|
324
376
|
// skip providers we already checked in the first pass
|
|
325
|
-
if(m.uuid&&(null===(
|
|
377
|
+
if(m.uuid&&(null===(r=e.info)||void 0===r?void 0:r.uuid)===m.uuid||m.name&&(null===(s=e.info)||void 0===s?void 0:s.name)===m.name)continue;const t=yield e.provider.request({method:"eth_accounts"});if(t.length>0&&(null===(o=t[0])||void 0===o?void 0:o.toLowerCase())===(null===(d=this.walletAddress)||void 0===d?void 0:d.toLowerCase())){h=e;break}}catch(e){console.warn("Failed to fetch accounts from provider:",e)}
|
|
326
378
|
// third pass: if still no provider found and we have UUID/name info,
|
|
327
379
|
// try prompting the user (only for the stored provider)
|
|
328
|
-
if(!
|
|
380
|
+
if(!h&&(m.uuid||m.name))for(const e of T)try{if(m.uuid&&(null===(u=e.info)||void 0===u?void 0:u.uuid)===m.uuid||m.name&&(null===(p=e.info)||void 0===p?void 0:p.name)===m.name){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.")}))}
|
|
329
381
|
/**
|
|
330
382
|
* Disconnect the user.
|
|
331
383
|
* @returns {Promise<void>}
|
|
332
|
-
*/disconnect(){return
|
|
384
|
+
*/disconnect(){return T(this,void 0,void 0,(function*(){this.isAuthenticated&&(f(this,ke,"m",Me).call(this,"state","unauthenticated"),this.isAuthenticated=!1,this.walletAddress=null,this.userId=null,this.jwt=null,this.origin=null,v(this,Pe,void 0,"f"),yield f(this,Se,"f").removeItem("camp-sdk:wallet-address"),yield f(this,Se,"f").removeItem("camp-sdk:user-id"),yield f(this,Se,"f").removeItem("camp-sdk:jwt"),yield f(this,Se,"f").removeItem("camp-sdk:environment"))}))}
|
|
333
385
|
/**
|
|
334
386
|
* Connect the user's wallet and sign the message.
|
|
335
387
|
* @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
|
|
336
388
|
* @throws {APIError} - Throws an error if the user cannot be authenticated.
|
|
337
|
-
*/connect(){return
|
|
389
|
+
*/connect(){return T(this,void 0,void 0,(function*(){f(this,ke,"m",Me).call(this,"state","loading");try{this.walletAddress||(yield f(this,ke,"m",Re).call(this)),this.walletAddress=r(this.walletAddress);const e=yield f(this,ke,"m",Oe).call(this),t=f(this,ke,"m",Fe).call(this,e),n=yield this.viem.signMessage({account:this.walletAddress,message:t}),i=yield f(this,ke,"m",Ue).call(this,t,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new Be(this.environment,this.jwt,this.viem,this.baseParentId),yield f(this,Se,"f").setItem("camp-sdk:jwt",this.jwt),yield f(this,Se,"f").setItem("camp-sdk:wallet-address",this.walletAddress),yield f(this,Se,"f").setItem("camp-sdk:user-id",this.userId),yield f(this,Se,"f").setItem("camp-sdk:environment",this.environment.NAME),f(this,ke,"m",Me).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,f(this,ke,"m",Me).call(this,"state","unauthenticated"),new x("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,f(this,ke,"m",Me).call(this,"state","unauthenticated"),new x(e)}}))}
|
|
338
390
|
/**
|
|
339
391
|
* Connect with a custom signer (for Node.js or custom wallet implementations).
|
|
340
392
|
* This method bypasses browser wallet interactions and uses the provided signer directly.
|
|
@@ -353,9 +405,9 @@ if(!T&&(m.uuid||m.name))for(const e of f)try{if(m.uuid&&(null===(u=e.info)||void
|
|
|
353
405
|
* const account = privateKeyToAccount('0x...');
|
|
354
406
|
* const client = createWalletClient({ account, chain: mainnet, transport: http() });
|
|
355
407
|
* await auth.connectWithSigner(client);
|
|
356
|
-
*/connectWithSigner(e,t){return
|
|
408
|
+
*/connectWithSigner(e,t){return T(this,void 0,void 0,(function*(){f(this,ke,"m",Me).call(this,"state","loading");try{v(this,Pe,I(e),"f"),this.walletAddress=r(yield f(this,Pe,"f").getAddress()),
|
|
357
409
|
// store the signer as viem client if it's a viem client, otherwise keep adapter
|
|
358
|
-
"viem"===
|
|
410
|
+
"viem"===f(this,Pe,"f").type&&(this.viem=e);const n=yield f(this,ke,"m",Oe).call(this),i=f(this,ke,"m",Fe).call(this,n,null==t?void 0:t.domain,null==t?void 0:t.uri),a=yield f(this,Pe,"f").signMessage(i),s=yield f(this,ke,"m",Ue).call(this,i,a);if(s.success)return this.isAuthenticated=!0,this.userId=s.userId,this.jwt=s.token,this.origin=new Be(this.environment,this.jwt,this.viem,this.baseParentId),yield f(this,Se,"f").setItem("camp-sdk:jwt",this.jwt),yield f(this,Se,"f").setItem("camp-sdk:wallet-address",this.walletAddress),yield f(this,Se,"f").setItem("camp-sdk:user-id",this.userId),yield f(this,Se,"f").setItem("camp-sdk:environment",this.environment.NAME),f(this,ke,"m",Me).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,f(this,ke,"m",Me).call(this,"state","unauthenticated"),new x("Failed to authenticate")}catch(e){throw this.isAuthenticated=!1,v(this,Pe,void 0,"f"),f(this,ke,"m",Me).call(this,"state","unauthenticated"),new x(e)}}))}
|
|
359
411
|
/**
|
|
360
412
|
* Get the user's linked social accounts.
|
|
361
413
|
* @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
|
|
@@ -364,34 +416,34 @@ if(!T&&(m.uuid||m.name))for(const e of f)try{if(m.uuid&&(null===(u=e.info)||void
|
|
|
364
416
|
* const auth = new Auth({ clientId: "your-client-id" });
|
|
365
417
|
* const socials = await auth.getLinkedSocials();
|
|
366
418
|
* console.log(socials);
|
|
367
|
-
*/getLinkedSocials(){return
|
|
419
|
+
*/getLinkedSocials(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/client-user/connections-sdk`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"}}).then((e=>e.json()));if(e.isError)throw new x(e.message||"Failed to fetch connections");{const t={};return Object.keys(e.data.data).forEach((n=>{t[n.split("User")[0]]=e.data.data[n]})),t}}))}
|
|
368
420
|
/**
|
|
369
421
|
* Link the user's Twitter account.
|
|
370
422
|
* @returns {Promise<void>}
|
|
371
423
|
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
372
|
-
*/linkTwitter(){return
|
|
424
|
+
*/linkTwitter(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(f(this,Ne,"f"))throw new Error("Social linking requires browser environment for OAuth flow");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
|
|
373
425
|
/**
|
|
374
426
|
* Link the user's Discord account.
|
|
375
427
|
* @returns {Promise<void>}
|
|
376
428
|
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
377
|
-
*/linkDiscord(){return
|
|
429
|
+
*/linkDiscord(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(f(this,Ne,"f"))throw new Error("Social linking requires browser environment for OAuth flow");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
|
|
378
430
|
/**
|
|
379
431
|
* Link the user's Spotify account.
|
|
380
432
|
* @returns {Promise<void>}
|
|
381
433
|
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
382
|
-
*/linkSpotify(){return
|
|
434
|
+
*/linkSpotify(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(f(this,Ne,"f"))throw new Error("Social linking requires browser environment for OAuth flow");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
|
|
383
435
|
/**
|
|
384
436
|
* Link the user's TikTok account.
|
|
385
437
|
* @param {string} handle The user's TikTok handle.
|
|
386
438
|
* @returns {Promise<any>} A promise that resolves with the TikTok account data.
|
|
387
439
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated.
|
|
388
|
-
*/linkTikTok(e){return
|
|
440
|
+
*/linkTikTok(e){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/tiktok/connect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userHandle:e,clientId:this.clientId,userId:this.userId})}).then((e=>e.json()));if(t.isError)throw"Request failed with status code 502"===t.message?new x("TikTok service is currently unavailable, try again later"):new x(t.message||"Failed to link TikTok account");return t.data}))}
|
|
389
441
|
/**
|
|
390
442
|
* Send an OTP to the user's Telegram account.
|
|
391
443
|
* @param {string} phoneNumber The user's phone number.
|
|
392
444
|
* @returns {Promise<any>} A promise that resolves with the OTP data.
|
|
393
445
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated.
|
|
394
|
-
*/sendTelegramOTP(e){return
|
|
446
|
+
*/sendTelegramOTP(e){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!e)throw new x("Phone number is required");yield this.unlinkTelegram();const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/telegram/sendOTP-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:e})}).then((e=>e.json()));if(t.isError)throw new x(t.message||"Failed to send Telegram OTP");return t.data}))}
|
|
395
447
|
/**
|
|
396
448
|
* Link the user's Telegram account.
|
|
397
449
|
* @param {string} phoneNumber The user's phone number.
|
|
@@ -399,42 +451,34 @@ if(!T&&(m.uuid||m.name))for(const e of f)try{if(m.uuid&&(null===(u=e.info)||void
|
|
|
399
451
|
* @param {string} phoneCodeHash The phone code hash.
|
|
400
452
|
* @returns {Promise<object>} A promise that resolves with the Telegram account data.
|
|
401
453
|
* @throws {APIError|Error} - Throws an error if the user is not authenticated. Also throws an error if the phone number, OTP, and phone code hash are not provided.
|
|
402
|
-
*/linkTelegram(e,t,n){return
|
|
454
|
+
*/linkTelegram(e,t,n){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");if(!e||!t||!n)throw new x("Phone number, OTP, and phone code hash are required");const i=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/telegram/signIn-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({phone:e,code:t,phone_code_hash:n,userId:this.userId,clientId:this.clientId})}).then((e=>e.json()));if(i.isError)throw new x(i.message||"Failed to link Telegram account");return i.data}))}
|
|
403
455
|
/**
|
|
404
456
|
* Unlink the user's Twitter account.
|
|
405
457
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
406
458
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
407
459
|
* @throws {APIError} - Throws an error if the request fails.
|
|
408
|
-
*/unlinkTwitter(){return
|
|
460
|
+
*/unlinkTwitter(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new Error("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/twitter/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((e=>e.json()));if(e.isError)throw new x(e.message||"Failed to unlink Twitter account");return e.data}))}
|
|
409
461
|
/**
|
|
410
462
|
* Unlink the user's Discord account.
|
|
411
463
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
412
464
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
413
465
|
* @throws {APIError} - Throws an error if the request fails.
|
|
414
|
-
*/unlinkDiscord(){return
|
|
466
|
+
*/unlinkDiscord(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new x("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/discord/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((e=>e.json()));if(e.isError)throw new x(e.message||"Failed to unlink Discord account");return e.data}))}
|
|
415
467
|
/**
|
|
416
468
|
* Unlink the user's Spotify account.
|
|
417
469
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
418
470
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
419
471
|
* @throws {APIError} - Throws an error if the request fails.
|
|
420
|
-
*/unlinkSpotify(){return
|
|
472
|
+
*/unlinkSpotify(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new x("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/spotify/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({id:this.userId})}).then((e=>e.json()));if(e.isError)throw new x(e.message||"Failed to unlink Spotify account");return e.data}))}
|
|
421
473
|
/**
|
|
422
474
|
* Unlink the user's TikTok account.
|
|
423
475
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
424
476
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
425
477
|
* @throws {APIError} - Throws an error if the request fails.
|
|
426
|
-
*/unlinkTikTok(){return
|
|
478
|
+
*/unlinkTikTok(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new x("User needs to be authenticated");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/tiktok/disconnect-sdk`,{method:"POST",redirect:"follow",headers:{Authorization:`Bearer ${this.jwt}`,"x-client-id":this.clientId,"Content-Type":"application/json"},body:JSON.stringify({userId:this.userId})}).then((e=>e.json()));if(e.isError)throw new x(e.message||"Failed to unlink TikTok account");return e.data}))}
|
|
427
479
|
/**
|
|
428
480
|
* Unlink the user's Telegram account.
|
|
429
481
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
430
482
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
431
483
|
* @throws {APIError} - Throws an error if the request fails.
|
|
432
|
-
*/unlinkTelegram(){return
|
|
433
|
-
/**
|
|
434
|
-
* Create a wallet client for Node.js environment
|
|
435
|
-
* @param account The viem account
|
|
436
|
-
* @param chain The chain to use
|
|
437
|
-
* @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
|
|
438
|
-
* @returns WalletClient
|
|
439
|
-
*/
|
|
440
|
-
function Ne(e,n,a){return t({account:e,chain:n,transport:i(a)})}ce=new WeakMap,me=new WeakMap,he=new WeakMap,Te=new WeakMap,ye=new WeakSet,fe=function(e,t){h(this,ce,"f")[e]&&h(this,ce,"f")[e].forEach((e=>e(t)))},ve=function(e){return m(this,void 0,void 0,(function*(){const t=yield h(this,Te,"f").getItem("camp-sdk:wallet-address"),n=yield h(this,Te,"f").getItem("camp-sdk:user-id"),i=yield h(this,Te,"f").getItem("camp-sdk:jwt"),a=yield h(this,Te,"f").getItem("camp-sdk:environment");t&&n&&i&&(a===this.environment.NAME||!a)?(this.walletAddress=t,this.userId=n,this.jwt=i,this.origin=new be(this.jwt,this.environment,this.viem,this.baseParentId),this.isAuthenticated=!0,e?this.setProvider({provider:e.provider,info:e.info||{name:"Unknown"},address:t}):h(this,me,"f")||(console.warn("No matching provider was given for the stored wallet address. Trying to recover provider."),yield this.recoverProvider())):this.isAuthenticated=!1}))},we=function(){return m(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=p(e),this.walletAddress}catch(e){throw new f(e)}}))},Ae=function(){return m(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)}}))},ge=function(e,t){return m(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],s=JSON.parse(atob(a));return{success:!i.isError,userId:s.id,token:i.data}}catch(e){throw new f(e)}}))},Ie=function(e,t,n){return y({domain:t||(h(this,me,"f")?"localhost":window.location.host),address:this.walletAddress,statement:M,uri:n||(h(this,me,"f")?"http://localhost":window.location.origin),version:"1",chainId:this.environment.CHAIN.id,nonce:e})};export{xe as Auth,Me as BrowserStorage,_e as CustomSignerAdapter,ne as DataStatus,Ce as EthersSignerAdapter,Pe as MemoryStorage,Ee as ViemSignerAdapter,w as campMainnet,v as campTestnet,ie as createLicenseTerms,Ne as createNodeWalletClient,ke as createSignerAdapter};
|
|
484
|
+
*/unlinkTelegram(){return T(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new x("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 x(e.message||"Failed to unlink Telegram account");return e.data}))}}xe=new WeakMap,Ne=new WeakMap,Pe=new WeakMap,Se=new WeakMap,ke=new WeakSet,Me=function(e,t){f(this,xe,"f")[e]&&f(this,xe,"f")[e].forEach((e=>e(t)))},De=function(e){return T(this,void 0,void 0,(function*(){const t=yield f(this,Se,"f").getItem("camp-sdk:wallet-address"),n=yield f(this,Se,"f").getItem("camp-sdk:user-id"),i=yield f(this,Se,"f").getItem("camp-sdk:jwt"),a=yield f(this,Se,"f").getItem("camp-sdk:environment");t&&n&&i&&(a===this.environment.NAME||!a)?(this.walletAddress=t,this.userId=n,this.jwt=i,this.origin=new Be(this.environment,this.jwt,this.viem,this.baseParentId),this.isAuthenticated=!0,e?this.setProvider({provider:e.provider,info:e.info||{name:"Unknown"},address:t}):f(this,Ne,"f")||(console.warn("No matching provider was given for the stored wallet address. Trying to recover provider."),yield this.recoverProvider())):this.isAuthenticated=!1}))},Re=function(){return T(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=r(e),this.walletAddress}catch(e){throw new x(e)}}))},Oe=function(){return T(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)}}))},Ue=function(e,t){return T(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 x(e)}}))},Fe=function(e,t,n){return m({domain:t||(f(this,Ne,"f")?"localhost":window.location.host),address:this.walletAddress,statement:F,uri:n||(f(this,Ne,"f")?"http://localhost":window.location.origin),version:"1",chainId:this.environment.CHAIN.id,nonce:e})};export{He as Auth,b as BrowserStorage,A as CustomSignerAdapter,ye as DataStatus,g as EthersSignerAdapter,E as MemoryStorage,Be as Origin,w as ViemSignerAdapter,k as campMainnet,_ as campTestnet,ce as createLicenseTerms,C as createNodeWalletClient,I as createSignerAdapter};
|