@campnetwork/origin 1.2.8 → 1.3.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +403 -34
- package/dist/core.cjs +570 -93
- package/dist/core.d.ts +596 -18
- package/dist/core.esm.d.ts +596 -18
- package/dist/core.esm.js +566 -105
- package/dist/react/index.esm.d.ts +594 -16
- package/dist/react/index.esm.js +4561 -892
- package/package.json +1 -1
package/dist/core.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{createWalletClient as e,http as t,custom as n,createPublicClient as i,encodeFunctionData as a,checksumAddress as
|
|
1
|
+
import{createWalletClient as e,http as t,custom as n,createPublicClient as i,encodeFunctionData as a,checksumAddress as s,zeroAddress as r,keccak256 as o,toBytes as d,toHex as u,erc20Abi as p,getAbiItem as l,formatEther as y,formatUnits as c}from"viem";import{toAccount as m}from"viem/accounts";import{createSiweMessage as h}from"viem/siwe";import T from"axios";
|
|
2
2
|
/******************************************************************************
|
|
3
3
|
Copyright (c) Microsoft Corporation.
|
|
4
4
|
|
|
@@ -13,16 +13,16 @@ 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 f(e,t,n,i){return new(n||(n=Promise))((function(a,s){function r(e){try{d(i.next(e))}catch(e){s(e)}}function o(e){try{d(i.throw(e))}catch(e){s(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(r,o)}d((i=i.apply(e,t||[])).next())}))}function v(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 A(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
17
|
/**
|
|
18
18
|
* Adapter for viem WalletClient
|
|
19
19
|
*/
|
|
20
|
-
class w{constructor(e){this.type="viem",this.signer=e}getAddress(){return
|
|
20
|
+
class w{constructor(e){this.type="viem",this.signer=e}getAddress(){return f(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 f(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 f(this,void 0,void 0,(function*(){throw new Error("Viem WalletClient does not support signTypedData")}))}getChainId(){return f(this,void 0,void 0,(function*(){var e;return(null===(e=this.signer.chain)||void 0===e?void 0:e.id)||1}))}}
|
|
21
21
|
/**
|
|
22
22
|
* Adapter for ethers Signer (v5 and v6)
|
|
23
|
-
*/class
|
|
23
|
+
*/class I{constructor(e){this.type="ethers",this.signer=e}getAddress(){return f(this,void 0,void 0,(function*(){
|
|
24
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
|
|
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 f(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 f(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 f(this,void 0,void 0,(function*(){
|
|
26
26
|
// Try ethers v6 first
|
|
27
27
|
if(this.signer.provider&&"function"==typeof this.signer.provider.getNetwork){const e=yield this.signer.provider.getNetwork();
|
|
28
28
|
// ethers v6 returns bigint, v5 returns number
|
|
@@ -33,36 +33,50 @@ return"function"==typeof this.signer.getChainId?yield this.signer.getChainId():4
|
|
|
33
33
|
}))}}
|
|
34
34
|
/**
|
|
35
35
|
* Adapter for custom signer implementations
|
|
36
|
-
*/class g{constructor(e){this.type="custom",this.signer=e}getAddress(){return
|
|
36
|
+
*/class g{constructor(e){this.type="custom",this.signer=e}getAddress(){return f(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 f(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 f(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 f(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
37
|
// Default to mainnet
|
|
38
38
|
}))}}
|
|
39
39
|
/**
|
|
40
40
|
* Factory function to create appropriate adapter based on signer type
|
|
41
|
-
*/function
|
|
41
|
+
*/function b(e){
|
|
42
42
|
// Check for viem WalletClient
|
|
43
43
|
return e.transport&&e.chain&&"function"==typeof e.signMessage?new w(e):
|
|
44
44
|
// Check for ethers signer (v5 or v6)
|
|
45
|
-
e._isSigner||e.provider&&"function"==typeof e.signMessage?new
|
|
45
|
+
e._isSigner||e.provider&&"function"==typeof e.signMessage?new I(e):new g(e)}
|
|
46
46
|
/**
|
|
47
47
|
* Browser localStorage adapter
|
|
48
|
-
*/class
|
|
48
|
+
*/class C{getItem(e){return f(this,void 0,void 0,(function*(){return"undefined"==typeof localStorage?null:localStorage.getItem(e)}))}setItem(e,t){return f(this,void 0,void 0,(function*(){"undefined"!=typeof localStorage&&localStorage.setItem(e,t)}))}removeItem(e){return f(this,void 0,void 0,(function*(){"undefined"!=typeof localStorage&&localStorage.removeItem(e)}))}}
|
|
49
49
|
/**
|
|
50
50
|
* In-memory storage adapter for Node.js
|
|
51
|
-
*/class E{constructor(){this.storage=new Map}getItem(e){return
|
|
51
|
+
*/class E{constructor(){this.storage=new Map}getItem(e){return f(this,void 0,void 0,(function*(){return this.storage.get(e)||null}))}setItem(e,t){return f(this,void 0,void 0,(function*(){this.storage.set(e,t)}))}removeItem(e){return f(this,void 0,void 0,(function*(){this.storage.delete(e)}))}clear(){this.storage.clear()}}
|
|
52
52
|
/**
|
|
53
53
|
* Create a wallet client for Node.js environment
|
|
54
54
|
* @param account The viem account
|
|
55
55
|
* @param chain The chain to use
|
|
56
56
|
* @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
|
|
57
57
|
* @returns WalletClient
|
|
58
|
-
*/function
|
|
58
|
+
*/function S(n,i,a){return e({account:n,chain:i,transport:t(a)})}const P={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/"}}},R={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 _ 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}}}class D extends Error{constructor(e){super(e),this.name="ValidationError",Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:400}}}class N extends Error{constructor(e){super(e),this.name="AuthenticationError",Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:401}}}class x extends Error{constructor(e){super(e),this.name="WalletError",Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:400}}}class k extends Error{constructor(e,t){super(e),this.name="ContractError",this.contractName=null==t?void 0:t.contractName,this.methodName=null==t?void 0:t.methodName,Error.captureStackTrace(this,this.constructor)}toJSON(){return{error:this.name,message:this.message,statusCode:400,contractName:this.contractName,methodName:this.methodName}}}function M(e){if(e instanceof Error)return e.message;if("string"==typeof e)return e;try{return JSON.stringify(e)}catch(t){return String(e)}}
|
|
59
59
|
// @ts-ignore
|
|
60
|
-
let S=null,x=null,N=null;const D=e=>{var n;const a=N||P;return x&&(null===(n=x.chain)||void 0===n?void 0:n.id)===a.id||(x=i({chain:a,transport:t()})),x};var M=[{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:[]}],B=[{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"}],U=[{inputs:[{internalType:"address",name:"_marketplace",type:"address"},{internalType:"address",name:"_ipNFT",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"EmptyPurchaseList",type:"error"},{inputs:[],name:"InvalidTotalPayment",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"reason",type:"string"}],name:"PurchaseFailed",type:"error"},{inputs:[],name:"RefundFailed",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint256",name:"count",type:"uint256"},{indexed:!1,internalType:"uint256",name:"totalPaid",type:"uint256"}],name:"BulkPurchaseExecuted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint256",name:"successCount",type:"uint256"},{indexed:!1,internalType:"uint256",name:"failureCount",type:"uint256"},{indexed:!1,internalType:"uint256[]",name:"failedTokenIds",type:"uint256[]"}],name:"BulkPurchasePartial",type:"event"},{inputs:[{internalType:"address",name:"buyer",type:"address"},{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"expectedPrice",type:"uint256"},{internalType:"uint32",name:"expectedDuration",type:"uint32"},{internalType:"address",name:"expectedPaymentToken",type:"address"}],internalType:"struct IBatchPurchase.BuyParams[]",name:"purchases",type:"tuple[]"}],name:"bulkBuyAccess",outputs:[{internalType:"uint256",name:"totalPaid",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"buyer",type:"address"},{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"expectedPrice",type:"uint256"},{internalType:"uint32",name:"expectedDuration",type:"uint32"},{internalType:"address",name:"expectedPaymentToken",type:"address"}],internalType:"struct IBatchPurchase.BuyParams[]",name:"purchases",type:"tuple[]"}],name:"bulkBuyAccessTolerant",outputs:[{components:[{internalType:"uint256",name:"successCount",type:"uint256"},{internalType:"uint256",name:"failureCount",type:"uint256"},{internalType:"uint256",name:"totalSpent",type:"uint256"},{internalType:"uint256",name:"refundAmount",type:"uint256"},{internalType:"uint256[]",name:"failedTokenIds",type:"uint256[]"}],internalType:"struct IBatchPurchase.TolerantResult",name:"result",type:"tuple"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],name:"buildPurchaseParams",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"expectedPrice",type:"uint256"},{internalType:"uint32",name:"expectedDuration",type:"uint32"},{internalType:"address",name:"expectedPaymentToken",type:"address"}],internalType:"struct IBatchPurchase.BuyParams[]",name:"purchases",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],name:"checkActiveStatus",outputs:[{internalType:"bool[]",name:"activeFlags",type:"bool[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"ipNFT",outputs:[{internalType:"contract IIpNFT",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"marketplace",outputs:[{internalType:"contract IMarketplace",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],name:"previewBulkCost",outputs:[{components:[{internalType:"uint256",name:"totalNativeCost",type:"uint256"},{internalType:"uint256",name:"totalERC20Cost",type:"uint256"},{internalType:"uint256",name:"validCount",type:"uint256"},{internalType:"uint256[]",name:"invalidTokenIds",type:"uint256[]"}],internalType:"struct IBatchPurchase.BulkCostPreview",name:"preview",type:"tuple"}],stateMutability:"view",type:"function"}],F="Connect with Camp Network",O=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",BATCH_PURCHASE_CONTRACT_ADDRESS:"0xaF0cF04DBfeeAcEdC77Dc68A91381AFB967B8518",CHAIN:P,IPNFT_ABI:M,MARKETPLACE_ABI:R,TBA_ABI:B,BATCH_PURCHASE_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",BATCH_PURCHASE_CONTRACT_ADDRESS:"0x31885cD2A445322067dF890bACf6CeFE9b233BCC",CHAIN:k,IPNFT_ABI:M,MARKETPLACE_ABI:R,TBA_ABI:B,BATCH_PURCHASE_ABI:U}};let q=[];const W=()=>q,J=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)};
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
let F=null,B=null,O=null;const U=e=>{var n;const a=O||P;return B&&(null===(n=B.chain)||void 0===n?void 0:n.id)===a.id||(B=i({chain:a,transport:t()})),B};var $=[{type:"constructor",inputs:[],stateMutability:"nonpayable"},{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"appRegistry",inputs:[],outputs:[{name:"",type:"address",internalType:"contract AppRegistry"}],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:"view"},{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"},{name:"licenseType",type:"uint8",internalType:"enum IIpNFT.LicenseType"}]}],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"},{name:"appRegistry_",type:"address",internalType:"contract AppRegistry"}],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:"licenseType",type:"uint8",internalType:"enum IIpNFT.LicenseType"}]},{name:"deadline",type:"uint256",internalType:"uint256"},{name:"parents",type:"uint256[]",internalType:"uint256[]"},{name:"isIP",type:"bool",internalType:"bool"},{name:"appId",type:"string",internalType:"string"},{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:"setAppRegistry",inputs:[{name:"_appRegistry",type:"address",internalType:"address"}],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:"licenseType",type:"uint8",internalType:"enum IIpNFT.LicenseType"}]},{name:"status",type:"uint8",internalType:"enum IIpNFT.DataStatus"},{name:"appId",type:"string",internalType:"string"}]}],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"},{name:"licenseType",type:"uint8",internalType:"enum IIpNFT.LicenseType"}]}],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:"AppRegistryUpdated",inputs:[{name:"appRegistry",type:"address",indexed:!0,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:"ParentIpsSet",inputs:[{name:"childIpId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"parentIds",type:"uint256[]",indexed:!1,internalType:"uint256[]"},{name:"totalRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"}],anonymous:!1},{type:"event",name:"Paused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"ProtocolFeeUpdated",inputs:[{name:"newFeeBps",type:"uint16",indexed:!1,internalType:"uint16"}],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:"TreasuryUpdated",inputs:[{name:"newTreasury",type:"address",indexed:!0,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:"event",name:"Voted",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"voter",type:"address",indexed:!0,internalType:"address"},{name:"support",type:"bool",indexed:!1,internalType:"bool"},{name:"weight",type:"uint256",indexed:!1,internalType:"uint256"}],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:[]}],H=[{type:"constructor",inputs:[],stateMutability:"nonpayable"},{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"},{name:"expectedProtocolFeeBps",type:"uint16",internalType:"uint16"},{name:"expectedAppFeeBps",type:"uint16",internalType:"uint16"}],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:"AppRegistryUpdated",inputs:[{name:"appRegistry",type:"address",indexed:!0,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:"ParentIpsSet",inputs:[{name:"childIpId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"parentIds",type:"uint256[]",indexed:!1,internalType:"uint256[]"},{name:"totalRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"}],anonymous:!1},{type:"event",name:"Paused",inputs:[{name:"account",type:"address",indexed:!1,internalType:"address"}],anonymous:!1},{type:"event",name:"ProtocolFeeUpdated",inputs:[{name:"newFeeBps",type:"uint16",indexed:!1,internalType:"uint16"}],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:"TreasuryUpdated",inputs:[{name:"newTreasury",type:"address",indexed:!0,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:"event",name:"Voted",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"voter",type:"address",indexed:!0,internalType:"address"},{name:"support",type:"bool",indexed:!1,internalType:"bool"},{name:"weight",type:"uint256",indexed:!1,internalType:"uint256"}],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:"FeesExceedMaximum",inputs:[]},{type:"error",name:"FeesMismatch",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidLicenseType",inputs:[]},{type:"error",name:"InvalidParentIp",inputs:[]},{type:"error",name:"InvalidPayment",inputs:[]},{type:"error",name:"InvalidPrice",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:[]}],j=[{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"}],L=[{inputs:[{internalType:"address",name:"_marketplace",type:"address"},{internalType:"address",name:"_ipNFT",type:"address"}],stateMutability:"nonpayable",type:"constructor"},{inputs:[],name:"EmptyPurchaseList",type:"error"},{inputs:[],name:"InvalidTotalPayment",type:"error"},{inputs:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"string",name:"reason",type:"string"}],name:"PurchaseFailed",type:"error"},{inputs:[],name:"RefundFailed",type:"error"},{inputs:[],name:"ZeroAddress",type:"error"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint256",name:"count",type:"uint256"},{indexed:!1,internalType:"uint256",name:"totalPaid",type:"uint256"}],name:"BulkPurchaseExecuted",type:"event"},{anonymous:!1,inputs:[{indexed:!0,internalType:"address",name:"buyer",type:"address"},{indexed:!1,internalType:"uint256",name:"successCount",type:"uint256"},{indexed:!1,internalType:"uint256",name:"failureCount",type:"uint256"},{indexed:!1,internalType:"uint256[]",name:"failedTokenIds",type:"uint256[]"}],name:"BulkPurchasePartial",type:"event"},{inputs:[{internalType:"address",name:"buyer",type:"address"},{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"expectedPrice",type:"uint256"},{internalType:"uint32",name:"expectedDuration",type:"uint32"},{internalType:"address",name:"expectedPaymentToken",type:"address"}],internalType:"struct IBatchPurchase.BuyParams[]",name:"purchases",type:"tuple[]"}],name:"bulkBuyAccess",outputs:[{internalType:"uint256",name:"totalPaid",type:"uint256"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"address",name:"buyer",type:"address"},{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"expectedPrice",type:"uint256"},{internalType:"uint32",name:"expectedDuration",type:"uint32"},{internalType:"address",name:"expectedPaymentToken",type:"address"}],internalType:"struct IBatchPurchase.BuyParams[]",name:"purchases",type:"tuple[]"}],name:"bulkBuyAccessTolerant",outputs:[{components:[{internalType:"uint256",name:"successCount",type:"uint256"},{internalType:"uint256",name:"failureCount",type:"uint256"},{internalType:"uint256",name:"totalSpent",type:"uint256"},{internalType:"uint256",name:"refundAmount",type:"uint256"},{internalType:"uint256[]",name:"failedTokenIds",type:"uint256[]"}],internalType:"struct IBatchPurchase.TolerantResult",name:"result",type:"tuple"}],stateMutability:"payable",type:"function"},{inputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],name:"buildPurchaseParams",outputs:[{components:[{internalType:"uint256",name:"tokenId",type:"uint256"},{internalType:"uint256",name:"expectedPrice",type:"uint256"},{internalType:"uint32",name:"expectedDuration",type:"uint32"},{internalType:"address",name:"expectedPaymentToken",type:"address"}],internalType:"struct IBatchPurchase.BuyParams[]",name:"purchases",type:"tuple[]"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],name:"checkActiveStatus",outputs:[{internalType:"bool[]",name:"activeFlags",type:"bool[]"}],stateMutability:"view",type:"function"},{inputs:[],name:"ipNFT",outputs:[{internalType:"contract IIpNFT",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[],name:"marketplace",outputs:[{internalType:"contract IMarketplace",name:"",type:"address"}],stateMutability:"view",type:"function"},{inputs:[{internalType:"uint256[]",name:"tokenIds",type:"uint256[]"}],name:"previewBulkCost",outputs:[{components:[{internalType:"uint256",name:"totalNativeCost",type:"uint256"},{internalType:"uint256",name:"totalERC20Cost",type:"uint256"},{internalType:"uint256",name:"validCount",type:"uint256"},{internalType:"uint256[]",name:"invalidTokenIds",type:"uint256[]"}],internalType:"struct IBatchPurchase.BulkCostPreview",name:"preview",type:"tuple"}],stateMutability:"view",type:"function"}],z=[{type:"constructor",inputs:[],stateMutability:"nonpayable"},{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"cancelDispute",inputs:[{name:"id",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"disputeAssertion",inputs:[{name:"id",type:"uint256",internalType:"uint256"},{name:"_counterEvidenceHash",type:"bytes32",internalType:"bytes32"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"disputeBond",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"disputeCoolDownPeriod",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"disputeCounter",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"disputeJudgementPeriod",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"disputeQuorum",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"disputeToken",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IERC20"}],stateMutability:"view"},{type:"function",name:"disputes",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"initiator",type:"address",internalType:"address"},{name:"targetId",type:"uint256",internalType:"uint256"},{name:"disputeTag",type:"bytes32",internalType:"bytes32"},{name:"disputeEvidenceHash",type:"bytes32",internalType:"bytes32"},{name:"counterEvidenceHash",type:"bytes32",internalType:"bytes32"},{name:"disputeTimestamp",type:"uint256",internalType:"uint256"},{name:"assertionTimestamp",type:"uint256",internalType:"uint256"},{name:"yesVotes",type:"uint256",internalType:"uint256"},{name:"noVotes",type:"uint256",internalType:"uint256"},{name:"status",type:"uint8",internalType:"enum DisputeModule.DisputeStatus"},{name:"bondAmount",type:"uint256",internalType:"uint256"},{name:"protocolFeeAmount",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"hasVoted",inputs:[{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"address",internalType:"address"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[{name:"_ipToken",type:"address",internalType:"contract IIpNFT"},{name:"_marketplace",type:"address",internalType:"contract IMarketplace"},{name:"_disputeToken",type:"address",internalType:"contract IERC20"},{name:"_disputeBond",type:"uint256",internalType:"uint256"},{name:"_disputeCoolDownPeriod",type:"uint256",internalType:"uint256"},{name:"_disputeJudgementPeriod",type:"uint256",internalType:"uint256"},{name:"_bondFeeBPS",type:"uint16",internalType:"uint16"},{name:"_stakingThreshold",type:"uint256",internalType:"uint256"},{name:"_stakingVault",type:"address",internalType:"contract ICampStakingVault"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"ipToken",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IIpNFT"}],stateMutability:"view"},{type:"function",name:"isUsedEvidenceHash",inputs:[{name:"",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"marketplace",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IMarketplace"}],stateMutability:"view"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"protocolDisputeFee",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"raiseDispute",inputs:[{name:"_targetIpId",type:"uint256",internalType:"uint256"},{name:"_disputeEvidenceHash",type:"bytes32",internalType:"bytes32"},{name:"_disputeTag",type:"bytes32",internalType:"bytes32"}],outputs:[{name:"id",type:"uint256",internalType:"uint256"}],stateMutability:"nonpayable"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"resolveDispute",inputs:[{name:"id",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"setDisputeQuorum",inputs:[{name:"_disputeQuorum",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"stakingThreshold",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"stakingVault",inputs:[],outputs:[{name:"",type:"address",internalType:"contract ICampStakingVault"}],stateMutability:"view"},{type:"function",name:"tagChildIp",inputs:[{name:"_childIpId",type:"uint256",internalType:"uint256"},{name:"_infringerDisputeId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",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:"voteOnDispute",inputs:[{name:"id",type:"uint256",internalType:"uint256"},{name:"support",type:"bool",internalType:"bool"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"AccessPurchased",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"buyer",type:"address",indexed:!0,internalType:"address"},{name:"periods",type:"uint32",indexed:!1,internalType:"uint32"},{name:"newExpiry",type:"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:"AppRegistryUpdated",inputs:[{name:"appRegistry",type:"address",indexed:!0,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:"ParentIpsSet",inputs:[{name:"childIpId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"parentIds",type:"uint256[]",indexed:!1,internalType:"uint256[]"},{name:"totalRoyaltyBps",type:"uint16",indexed:!1,internalType:"uint16"}],anonymous:!1},{type:"event",name:"ProtocolFeeUpdated",inputs:[{name:"newFeeBps",type:"uint16",indexed:!1,internalType:"uint16"}],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:"TreasuryUpdated",inputs:[{name:"newTreasury",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Upgraded",inputs:[{name:"implementation",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"event",name:"Voted",inputs:[{name:"id",type:"uint256",indexed:!0,internalType:"uint256"},{name:"voter",type:"address",indexed:!0,internalType:"address"},{name:"support",type:"bool",indexed:!1,internalType:"bool"},{name:"weight",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"error",name:"AddressEmptyCode",inputs:[{name:"target",type:"address",internalType:"address"}]},{type:"error",name:"AlreadyVoted",inputs:[]},{type:"error",name:"CoolDownPeriodActive",inputs:[]},{type:"error",name:"CoolDownPeriodOver",inputs:[]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"EvidenceAlreadyUsed",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidBondFeeBps",inputs:[]},{type:"error",name:"InvalidChildIpId",inputs:[]},{type:"error",name:"InvalidDisputeStatus",inputs:[]},{type:"error",name:"InvalidDisputeTag",inputs:[]},{type:"error",name:"InvalidEvidenceHash",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidTargetIp",inputs:[]},{type:"error",name:"NoVotingPower",inputs:[]},{type:"error",name:"NotAParentIp",inputs:[]},{type:"error",name:"NotInitializing",inputs:[]},{type:"error",name:"NotInitiator",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:"ParentNotDisputed",inputs:[]},{type:"error",name:"SelfAssertionNotAllowed",inputs:[]},{type:"error",name:"StakedAfterDispute",inputs:[]},{type:"error",name:"TagNotAllowed",inputs:[]},{type:"error",name:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"VotingPeriodActive",inputs:[]},{type:"error",name:"VotingPeriodOver",inputs:[]}],V=[{type:"constructor",inputs:[{name:"ipNFT_",type:"address",internalType:"contract IIpNFT"},{name:"exchangeRate_",type:"uint256",internalType:"uint256"}],stateMutability:"nonpayable"},{type:"function",name:"exchangeRate",inputs:[],outputs:[{name:"",type:"uint256",internalType:"uint256"}],stateMutability:"view"},{type:"function",name:"fractionalize",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"getTokenForNFT",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"ipNFT",inputs:[],outputs:[{name:"",type:"address",internalType:"contract IIpNFT"}],stateMutability:"view"},{type:"function",name:"nftToToken",inputs:[{name:"",type:"uint256",internalType:"uint256"}],outputs:[{name:"",type:"address",internalType:"contract FractionalToken"}],stateMutability:"view"},{type:"function",name:"onERC721Received",inputs:[{name:"",type:"address",internalType:"address"},{name:"",type:"address",internalType:"address"},{name:"",type:"uint256",internalType:"uint256"},{name:"",type:"bytes",internalType:"bytes"}],outputs:[{name:"",type:"bytes4",internalType:"bytes4"}],stateMutability:"pure"},{type:"function",name:"redeem",inputs:[{name:"tokenId",type:"uint256",internalType:"uint256"}],outputs:[],stateMutability:"nonpayable"},{type:"event",name:"Fractionalized",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"depositor",type:"address",indexed:!0,internalType:"address"},{name:"token",type:"address",indexed:!1,internalType:"address"},{name:"supply",type:"uint256",indexed:!1,internalType:"uint256"}],anonymous:!1},{type:"event",name:"Redeemed",inputs:[{name:"tokenId",type:"uint256",indexed:!0,internalType:"uint256"},{name:"redeemer",type:"address",indexed:!0,internalType:"address"}],anonymous:!1},{type:"error",name:"AlreadyFractionalized",inputs:[]},{type:"error",name:"InsufficientFractionalTokens",inputs:[]},{type:"error",name:"InvalidExchangeRate",inputs:[]},{type:"error",name:"NotFractionalized",inputs:[]},{type:"error",name:"NotTokenOwner",inputs:[]},{type:"error",name:"ZeroAddress",inputs:[]}],q=[{type:"constructor",inputs:[],stateMutability:"nonpayable"},{type:"function",name:"UPGRADE_INTERFACE_VERSION",inputs:[],outputs:[{name:"",type:"string",internalType:"string"}],stateMutability:"view"},{type:"function",name:"appExists",inputs:[{name:"",type:"string",internalType:"string"}],outputs:[{name:"",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"apps",inputs:[{name:"",type:"string",internalType:"string"}],outputs:[{name:"treasury",type:"address",internalType:"address"},{name:"revenueShareBps",type:"uint16",internalType:"uint16"},{name:"isActive",type:"bool",internalType:"bool"}],stateMutability:"view"},{type:"function",name:"deactivateApp",inputs:[{name:"appId",type:"string",internalType:"string"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"getAppInfo",inputs:[{name:"appId",type:"string",internalType:"string"}],outputs:[{name:"",type:"tuple",internalType:"struct AppRegistry.AppInfo",components:[{name:"treasury",type:"address",internalType:"address"},{name:"revenueShareBps",type:"uint16",internalType:"uint16"},{name:"isActive",type:"bool",internalType:"bool"}]}],stateMutability:"view"},{type:"function",name:"initialize",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"owner",inputs:[],outputs:[{name:"",type:"address",internalType:"address"}],stateMutability:"view"},{type:"function",name:"proxiableUUID",inputs:[],outputs:[{name:"",type:"bytes32",internalType:"bytes32"}],stateMutability:"view"},{type:"function",name:"reactivateApp",inputs:[{name:"appId",type:"string",internalType:"string"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"registerApp",inputs:[{name:"appId",type:"string",internalType:"string"},{name:"treasury",type:"address",internalType:"address"},{name:"revenueShareBps",type:"uint16",internalType:"uint16"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"renounceOwnership",inputs:[],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"transferOwnership",inputs:[{name:"newOwner",type:"address",internalType:"address"}],outputs:[],stateMutability:"nonpayable"},{type:"function",name:"updateApp",inputs:[{name:"appId",type:"string",internalType:"string"},{name:"treasury",type:"address",internalType:"address"},{name:"revenueShareBps",type:"uint16",internalType:"uint16"}],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:"AppDeactivated",inputs:[{name:"appId",type:"string",indexed:!0,internalType:"string"}],anonymous:!1},{type:"event",name:"AppReactivated",inputs:[{name:"appId",type:"string",indexed:!0,internalType:"string"}],anonymous:!1},{type:"event",name:"AppRegistered",inputs:[{name:"appId",type:"string",indexed:!0,internalType:"string"},{name:"treasury",type:"address",indexed:!1,internalType:"address"},{name:"revenueShareBps",type:"uint16",indexed:!1,internalType:"uint16"}],anonymous:!1},{type:"event",name:"AppUpdated",inputs:[{name:"appId",type:"string",indexed:!0,internalType:"string"},{name:"treasury",type:"address",indexed:!1,internalType:"address"},{name:"revenueShareBps",type:"uint16",indexed:!1,internalType:"uint16"}],anonymous:!1},{type:"event",name:"Initialized",inputs:[{name:"version",type:"uint64",indexed:!1,internalType:"uint64"}],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:"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:"AppAlreadyActive",inputs:[]},{type:"error",name:"AppAlreadyExists",inputs:[]},{type:"error",name:"AppAlreadyInactive",inputs:[]},{type:"error",name:"AppNotFound",inputs:[]},{type:"error",name:"ERC1967InvalidImplementation",inputs:[{name:"implementation",type:"address",internalType:"address"}]},{type:"error",name:"ERC1967NonPayable",inputs:[]},{type:"error",name:"FailedCall",inputs:[]},{type:"error",name:"InvalidAppId",inputs:[]},{type:"error",name:"InvalidInitialization",inputs:[]},{type:"error",name:"InvalidRoyalty",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:"UUPSUnauthorizedCallContext",inputs:[]},{type:"error",name:"UUPSUnsupportedProxiableUUID",inputs:[{name:"slot",type:"bytes32",internalType:"bytes32"}]},{type:"error",name:"ZeroAddress",inputs:[]}],J="Connect with Camp Network",G=2628e3,Y=86400,W=1e15,Z=1,K=1e4;const X={DEVELOPMENT:{NAME:"DEVELOPMENT",AUTH_HUB_BASE_API:"https://origin-backend-iota.vercel.app",ORIGIN_DASHBOARD:"https://origin.campnetwork.xyz",DATANFT_CONTRACT_ADDRESS:"0x4d9aF5800701A4A686Df6b096A27B81486de36eB",MARKETPLACE_CONTRACT_ADDRESS:"0x68B202caA162C418d3A2DF92F29fA1CAF90C58c1",BATCH_PURCHASE_CONTRACT_ADDRESS:"0xaF0cF04DBfeeAcEdC77Dc68A91381AFB967B8518",DISPUTE_CONTRACT_ADDRESS:"0x45719337b1450b0D105cA671972be4263E6A9380",APP_REGISTRY_CONTRACT_ADDRESS:"0x2096eb980Dd590DDF690Cb698572b80552B6F9Bb",
|
|
61
|
+
// TODO: Add actual contract addresse when deployed
|
|
62
|
+
FRACTIONALIZER_CONTRACT_ADDRESS:"",USDC_CONTRACT_ADDRESS:"0x8a2B28364102Bea189D99A475C494330Ef2bDD0B",CHAIN:P,IPNFT_ABI:$,MARKETPLACE_ABI:H,TBA_ABI:j,BATCH_PURCHASE_ABI:L,DISPUTE_ABI:z,FRACTIONALIZER_ABI:V,APP_REGISTRY_ABI:q},PRODUCTION:{NAME:"PRODUCTION",AUTH_HUB_BASE_API:"https://wv2h4to5qa.execute-api.us-east-2.amazonaws.com/dev",ORIGIN_DASHBOARD:"https://origin.campnetwork.xyz",DATANFT_CONTRACT_ADDRESS:"0x39EeE1C3989f0dD543Dee60f8582F7F81F522C38",MARKETPLACE_CONTRACT_ADDRESS:"0xc69BAa987757d054455fC0f2d9797684E9FB8b9C",BATCH_PURCHASE_CONTRACT_ADDRESS:"0x31885cD2A445322067dF890bACf6CeFE9b233BCC",
|
|
63
|
+
// TODO: Add actual contract addresses when deployed
|
|
64
|
+
DISPUTE_CONTRACT_ADDRESS:"",FRACTIONALIZER_CONTRACT_ADDRESS:"",APP_REGISTRY_CONTRACT_ADDRESS:"",USDC_CONTRACT_ADDRESS:"",CHAIN:R,IPNFT_ABI:$,MARKETPLACE_ABI:H,TBA_ABI:j,BATCH_PURCHASE_ABI:L,DISPUTE_ABI:z,FRACTIONALIZER_ABI:V,APP_REGISTRY_ABI:q}};let Q=[];const ee=()=>Q,te=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)},ne=(e,t,n)=>{const i=[];let a=[],s=!1,r=0;const o=e.length;return new Promise(((d,u)=>{function p(){n(r/o*100)}function l(e,t,n){return f(this,arguments,void 0,(function*(e,t,n,i=0){var a;try{const i=null===(a=(yield T.put(t,e,{headers:{"Content-Type":e.type||"application/octet-stream"},timeout:3e5})).headers.etag)||void 0===a?void 0:a.replace(/"/g,"");if(!i)throw new Error(`Missing ETag for part ${n}`);return{ETag:i,PartNumber:n}}catch(a){if(i<3){const a=1e3*Math.pow(2,i);// Exponential backoff
|
|
65
|
+
return yield new Promise((e=>setTimeout(e,a))),l(e,t,n,i+1)}throw new Error(`Part ${n} failed after 3 retries: ${a.message}`)}}))}
|
|
66
|
+
// Expose abort method
|
|
67
|
+
ne.abort=()=>{s=!0,T.isCancel("Upload aborted")},p(),// Initial 0%
|
|
68
|
+
function(){return f(this,void 0,void 0,(function*(){const n=[];for(let d=0;d<o&&!s;d++){const s=(()=>f(this,void 0,void 0,(function*(){try{if(a.includes(d))return;const n=yield l(e[d],t[d],d+1);i.push(n),r++,p()}catch(e){if(console.error(`Part ${d+1} failed:`,e),a.push(d),a.length>.1*o)
|
|
69
|
+
// Fail fast if >10% fail
|
|
70
|
+
throw e}})))();n.push(s),
|
|
71
|
+
// Limit concurrency
|
|
72
|
+
n.length>=4&&(yield Promise.race(n),
|
|
73
|
+
// Remove settled promises to continue
|
|
74
|
+
n.splice(0,n.length,...(yield Promise.allSettled(n)).map(((e,t)=>n[t])).filter(Boolean)))}yield Promise.allSettled(n),s?u(new Error("Upload aborted by user")):a.length>0?u(new Error(`Failed to upload ${a.length}/${o} parts: ${a.join(", ")}`)):(i.sort(((e,t)=>e.PartNumber-t.PartNumber)),d(i))}))}().catch(u)}))};
|
|
75
|
+
/**
|
|
76
|
+
* Uploads chunks to respective presigned URLs with progress tracking.
|
|
63
77
|
* Falls back to a simple fetch request if XMLHttpRequest is not available.
|
|
64
|
-
* @param {
|
|
65
|
-
* @param {string}
|
|
78
|
+
* @param {Blob[]} chunks - The file to upload.
|
|
79
|
+
* @param {string[]} urls - The URL to upload the file to.
|
|
66
80
|
* @param {UploadProgressCallback} onProgress - A callback function to track upload progress.
|
|
67
81
|
* @returns {Promise<string>} - A promise that resolves with the response from the server.
|
|
68
82
|
*/
|
|
@@ -77,9 +91,12 @@ let S=null,x=null,N=null;const D=e=>{var n;const a=N||P;return x&&(null===(n=x.c
|
|
|
77
91
|
* @param licenseTerms The terms of the license for the NFT.
|
|
78
92
|
* @param deadline The deadline for the minting operation.
|
|
79
93
|
* @param signature The signature for the minting operation.
|
|
94
|
+
* @param appId Optional app ID for the minting operation.
|
|
80
95
|
* @returns A promise that resolves when the minting is complete.
|
|
81
96
|
*/
|
|
82
|
-
function
|
|
97
|
+
function ie(e,t,n,i,a,s,r,o,d,u){return f(this,void 0,void 0,(function*(){var p;
|
|
98
|
+
// use provided appId, else use instance appId, else default to empty string
|
|
99
|
+
const l=null!==(p=null!=u?u:this.appId)&&void 0!==p?p:"";return yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"mintWithSignature",[e,t,a,s,r,o,n,i,l,d],{waitForReceipt:!0})}))}
|
|
83
100
|
/**
|
|
84
101
|
* Registers a Data NFT with the Origin service in order to obtain a signature for minting.
|
|
85
102
|
* @param source The source of the Data NFT (e.g., "spotify", "twitter", "tiktok", or "file").
|
|
@@ -89,55 +106,55 @@ function V(e,t,n,i,a,r,s,o,d){return T(this,void 0,void 0,(function*(){return yi
|
|
|
89
106
|
* @param fileKey The file key(s) if the source is "file".
|
|
90
107
|
* @param parents The IDs of the parent NFTs, if applicable.
|
|
91
108
|
* @return A promise that resolves with the registration data.
|
|
92
|
-
*/function
|
|
109
|
+
*/function ae(e,t,n,i,a,s,r,o){return f(this,void 0,void 0,(function*(){var d;const u=null!==(d=null!=o?o:this.appId)&&void 0!==d?d:"",p={source:e,deadline:Number(t),licenseTerms:{price:n.price.toString(),duration:n.duration,royaltyBps:n.royaltyBps,paymentToken:n.paymentToken,licenseType:n.licenseType},appId:u,isIp:a,metadata:i,parentId:r?r.map((e=>e.toString())):[]};void 0!==s&&(p.fileKey=s);const l=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/origin/register`,{method:"POST",headers:{Authorization:`Bearer ${this.getJwt()}`,"Content-Type":"application/json"},body:JSON.stringify(p)}),y=yield l.json();if(y.isError)throw new Error(`Failed to get signature: ${y.message}`);if(!l.ok)throw new Error(`Failed to get signature: ${l.statusText}`);return y.data}))}
|
|
93
110
|
/**
|
|
94
111
|
* Updates the license terms of a specified IPNFT.
|
|
95
112
|
* @param tokenId The ID of the IPNFT to update.
|
|
96
113
|
* @param newTerms The new license terms to set.
|
|
97
114
|
* @returns A promise that resolves when the transaction is complete.
|
|
98
|
-
*/function
|
|
115
|
+
*/function se(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"updateTerms",[e,t],{waitForReceipt:!0})}
|
|
99
116
|
/**
|
|
100
117
|
* Sets the IPNFT as deleted
|
|
101
118
|
* @param tokenId The token ID to set as deleted.
|
|
102
119
|
* @returns A promise that resolves when the transaction is complete.
|
|
103
|
-
*/function
|
|
120
|
+
*/function re(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"finalizeDelete",[e])}
|
|
104
121
|
/**
|
|
105
122
|
* Calls the getOrCreateRoyaltyVault method on the IPNFT contract.
|
|
106
123
|
* @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
|
|
107
124
|
* @param simulateOnly If true, simulates the transaction without executing it.
|
|
108
125
|
* @returns The address of the royalty vault associated with the specified token owner.
|
|
109
|
-
*/function
|
|
126
|
+
*/function oe(e){return f(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}))}
|
|
110
127
|
/**
|
|
111
128
|
* Returns the license terms associated with a specific token ID.
|
|
112
129
|
* @param tokenId The token ID to query.
|
|
113
130
|
* @returns The license terms of the token ID.
|
|
114
|
-
*/function
|
|
131
|
+
*/function de(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"getTerms",[e])}
|
|
115
132
|
/**
|
|
116
133
|
* Returns the owner of the specified IPNFT.
|
|
117
134
|
* @param tokenId The ID of the IPNFT to query.
|
|
118
135
|
* @returns The address of the owner of the IPNFT.
|
|
119
|
-
*/function
|
|
136
|
+
*/function ue(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"ownerOf",[e])}
|
|
120
137
|
/**
|
|
121
138
|
* Returns the number of IPNFTs owned by the given address.
|
|
122
139
|
* @param owner The address to query.
|
|
123
140
|
* @returns The number of IPNFTs owned by the address.
|
|
124
|
-
*/function
|
|
141
|
+
*/function pe(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"balanceOf",[e])}
|
|
125
142
|
/**
|
|
126
143
|
* Returns the metadata URI associated with a specific token ID.
|
|
127
144
|
* @param tokenId The token ID to query.
|
|
128
145
|
* @returns The metadata URI of the token ID.
|
|
129
|
-
*/function
|
|
146
|
+
*/function le(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenURI",[e])}
|
|
130
147
|
/**
|
|
131
148
|
* Returns the data status of the given token ID.
|
|
132
149
|
* @param tokenId The token ID to query.
|
|
133
150
|
* @returns The data status of the token ID.
|
|
134
|
-
*/function
|
|
151
|
+
*/function ye(e){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"dataStatus",[e])}
|
|
135
152
|
/**
|
|
136
153
|
* Checks if an operator is approved to manage all assets of a given owner.
|
|
137
154
|
* @param owner The address of the asset owner.
|
|
138
155
|
* @param operator The address of the operator to check.
|
|
139
156
|
* @return A promise that resolves to a boolean indicating if the operator is approved for all assets of the owner.
|
|
140
|
-
*/function
|
|
157
|
+
*/function ce(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"isApprovedForAll",[e,t])}function me(e,t,n){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"transferFrom",[e,t,n])}function he(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 Te(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"approve",[e,t])}function fe(e,t){return this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"setApprovalForAll",[e,t])}
|
|
141
158
|
/**
|
|
142
159
|
* Buys access to a data NFT for a specified duration.
|
|
143
160
|
* @param buyer The address of the buyer.
|
|
@@ -145,15 +162,23 @@ function V(e,t,n,i,a,r,s,o,d){return T(this,void 0,void 0,(function*(){return yi
|
|
|
145
162
|
* @param expectedPrice The expected price for the access.
|
|
146
163
|
* @param expectedDuration The expected duration of the access in seconds.
|
|
147
164
|
* @param expectedPaymentToken The address of the payment token (use zero address for native token).
|
|
165
|
+
* @param expectedProtocolFeeBps The expected protocol fee in basis points (0-10000). Defaults to 0.
|
|
166
|
+
* @param expectedAppFeeBps The expected app fee in basis points (0-10000). Defaults to 0.
|
|
148
167
|
* @param value The amount of native token to send (only required if paying with native token).
|
|
149
168
|
* @returns A promise that resolves when the transaction is confirmed.
|
|
150
|
-
*/function
|
|
169
|
+
*/function ve(e,t,n,i,a,s=0,r=0,o){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"buyAccess",[e,t,n,i,a,s,r],{waitForReceipt:!0,value:o})}
|
|
151
170
|
/**
|
|
152
171
|
* Checks if a user has access to a specific token based on subscription expiry.
|
|
153
172
|
* @param user - The address of the user.
|
|
154
173
|
* @param tokenId - The ID of the token.
|
|
155
174
|
* @returns A promise that resolves to a boolean indicating if the user has access.
|
|
156
|
-
*/function
|
|
175
|
+
*/function Ae(e,t){return f(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 we(e,t){return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"subscriptionExpiry",[e,t])}
|
|
176
|
+
/**
|
|
177
|
+
* Fetches the protocol fee from the marketplace contract.
|
|
178
|
+
*/function Ie(e){return f(this,void 0,void 0,(function*(){try{const t=yield e.callContractMethod(e.environment.MARKETPLACE_CONTRACT_ADDRESS,e.environment.MARKETPLACE_ABI,"protocolFeeBps",[]);return Number(t)}catch(e){return console.warn("Failed to fetch protocol fee, defaulting to 0:",e),0}}))}
|
|
179
|
+
/**
|
|
180
|
+
* Fetches the app fee for a specific token from the AppRegistry.
|
|
181
|
+
*/function ge(e,t){return f(this,void 0,void 0,(function*(){try{const n=yield e.callContractMethod(e.environment.DATANFT_CONTRACT_ADDRESS,e.environment.IPNFT_ABI,"tokenInfo",[t]),i=null==n?void 0:n.appId;if(!i||""===i)return 0;if(!e.environment.APP_REGISTRY_CONTRACT_ADDRESS||!e.environment.APP_REGISTRY_ABI)return 0;const a=yield e.callContractMethod(e.environment.APP_REGISTRY_CONTRACT_ADDRESS,e.environment.APP_REGISTRY_ABI,"getAppInfo",[i]);return(null==a?void 0:a.isActive)?Number(a.revenueShareBps):0}catch(e){return console.warn("Failed to fetch app fee, defaulting to 0:",e),0}}))}
|
|
157
182
|
/**
|
|
158
183
|
* EXPERIMENTAL METHOD
|
|
159
184
|
* Settles a payment intent response by purchasing access if needed.
|
|
@@ -165,22 +190,32 @@ function V(e,t,n,i,a,r,s,o,d){return T(this,void 0,void 0,(function*(){return yi
|
|
|
165
190
|
* @param signer - Optional signer object used to interact with the blockchain. If not provided, uses the connected wallet client.
|
|
166
191
|
* @returns A promise that resolves with the transaction hash and receipt, or null if access already exists.
|
|
167
192
|
* @throws {Error} If the response doesn't contain marketplace action or if the method is not buyAccess.
|
|
168
|
-
*/function
|
|
193
|
+
*/function be(e,t){return f(this,void 0,void 0,(function*(){if(!e.marketplaceAction)throw new D("Invalid X402 response: no marketplace action found. The response may be malformed or the server returned an error.");const{marketplaceAction:n}=e;if("buyAccess"!==n.method)throw new D(`Unsupported marketplace action method "${n.method}". Only "buyAccess" is currently supported.`);const i=BigInt(n.tokenId),s=n.payer;if(yield this.hasAccess(s,i))return console.log("User already has access to this item"),null;const r=BigInt(n.amount),o=BigInt(n.duration),d=n.asset,u="0x0000000000000000000000000000000000000000"===d,p=u?r:BigInt(0),[l,y]=yield Promise.all([Ie(this),ge(this,i)]);if(t){const e=b(t),n=this.environment.MARKETPLACE_CONTRACT_ADDRESS,u=this.environment.MARKETPLACE_ABI,c=a({abi:u,functionName:"buyAccess",args:[s,i,r,o,d,l,y]});if("viem"===e.type){const t=e.signer,i=yield t.sendTransaction({to:n,data:c,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:c,value:p.toString()}),a=yield i.wait();return{txHash:i.hash,receipt:a}}{const t=e.signer;if("function"!=typeof t.sendTransaction)throw new D("Custom signer must implement sendTransaction() method to settle payment intents");const i=yield t.sendTransaction({to:n,data:c,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 x("Cannot settle payment intent: no signer or wallet connected. Please connect a wallet or provide a signer.");return yield this.buyAccess(s,i,r,o,d,l,y,u?p:void 0)}))}
|
|
169
194
|
/**
|
|
170
|
-
*
|
|
171
|
-
*
|
|
172
|
-
*
|
|
173
|
-
*
|
|
174
|
-
|
|
195
|
+
* Resolves a wallet address from an optional address parameter or connected wallet.
|
|
196
|
+
* Checks viemClient.account first, then falls back to eth_requestAccounts.
|
|
197
|
+
*
|
|
198
|
+
* @param viemClient The viem WalletClient instance.
|
|
199
|
+
* @param address Optional address to use directly.
|
|
200
|
+
* @returns The resolved wallet address.
|
|
201
|
+
* @throws Error if no address provided and no wallet connected or no accounts found.
|
|
202
|
+
*/function Ce(e,t){return f(this,void 0,void 0,(function*(){if(t)return t;if(!e)throw new Error("No address provided and no wallet connected. Please provide an address or connect a wallet.");if(e.account)return e.account.address;const n=yield e.request({method:"eth_requestAccounts",params:[]});if(!n||0===n.length)throw new Error("No accounts found in connected wallet.");return n[0]}))}
|
|
203
|
+
/**
|
|
204
|
+
* Enum representing the type of license for an IP NFT.
|
|
205
|
+
* - DURATION_BASED: License expires after a set duration (subscription model).
|
|
206
|
+
* - SINGLE_PAYMENT: One-time payment for perpetual access.
|
|
207
|
+
* - X402: HTTP 402-based micropayment license (no on-chain payments).
|
|
208
|
+
*/var Ee,Se,Pe;!function(e){e[e.DURATION_BASED=0]="DURATION_BASED",e[e.SINGLE_PAYMENT=1]="SINGLE_PAYMENT",e[e.X402=2]="X402"}(Ee||(Ee={})),function(e){e[e.ACTIVE=0]="ACTIVE",e[e.DELETED=1]="DELETED",e[e.DISPUTED=2]="DISPUTED"}(Se||(Se={})),function(e){e[e.Uninitialized=0]="Uninitialized",e[e.Raised=1]="Raised",e[e.Asserted=2]="Asserted",e[e.Resolved=3]="Resolved",e[e.Cancelled=4]="Cancelled"}(Pe||(Pe={}));
|
|
175
209
|
/**
|
|
176
210
|
* Creates license terms for a digital asset.
|
|
177
211
|
* @param price The price of the asset in wei.
|
|
178
|
-
* @param duration The duration of the license in seconds.
|
|
212
|
+
* @param duration The duration of the license in seconds (use 0 for SINGLE_PAYMENT and X402).
|
|
179
213
|
* @param royaltyBps The royalty percentage in basis points (0-10000).
|
|
180
214
|
* @param paymentToken The address of the payment token (ERC20 / address(0) for native currency).
|
|
215
|
+
* @param licenseType The type of license (defaults to DURATION_BASED).
|
|
181
216
|
* @returns The created license terms.
|
|
182
217
|
*/
|
|
183
|
-
const
|
|
218
|
+
const Re=(e,t,n,i,a=Ee.DURATION_BASED)=>{if(n<Z||n>K)throw new Error(`Royalty basis points must be between ${Z} and ${K}`);if(a===Ee.DURATION_BASED){if(t<Y||t>G)throw new Error(`Duration must be between ${Y} and ${G} seconds for DURATION_BASED licenses`)}else if((a===Ee.SINGLE_PAYMENT||a===Ee.X402)&&t>0)throw new Error(`Duration must be 0 for ${Ee[a]} licenses`);if(e<W)throw new Error(`Price must be at least ${W} wei`);return{price:e,duration:t,royaltyBps:n,paymentToken:i,licenseType:a}},_e={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"}]},De=(e,t,n)=>f(void 0,void 0,void 0,(function*(){return yield fetch(`${e.environment.AUTH_HUB_BASE_API}/origin/data/${t}`,{method:"GET",headers:Object.assign({"Content-Type":"application/json"},n)})}))
|
|
184
219
|
/**
|
|
185
220
|
* EXPERIMENTAL METHOD
|
|
186
221
|
* Fetch data with X402 payment handling.
|
|
@@ -191,34 +226,389 @@ const ce=(e,t,n,i)=>{if(n<j||n>L)throw new Error(`Royalty basis points must be b
|
|
|
191
226
|
*/;
|
|
192
227
|
/**
|
|
193
228
|
* Defines the EIP-712 typed data structure for X402 Intent signatures.
|
|
194
|
-
*/function
|
|
229
|
+
*/function Ne(e,t,n){return f(this,void 0,void 0,(function*(){var i;const a=this.viemClient;if(!t&&!a)throw new x(`Cannot fetch data for token ${e}: no signer or wallet client provided. Please connect a wallet or provide a signer.`);const r=yield De(this,e,{});if(402!==r.status){if(!r.ok){const t=yield r.text().catch((()=>r.statusText));throw new _(`Failed to fetch data for token ${e} (HTTP ${r.status}): ${t}`,r.status)}return r.json()}const o=a||b(t),d=a?yield Me.call(this):yield o.getAddress(),u=yield r.json();if(u.error)throw new _(`Failed to process X402 intent for token ${e}: ${u.error}`);const p=u.accepts[0],l=yield xe.call(this,p,s(d),o),y=btoa(JSON.stringify(l)),c=yield De(this,e,{"X-PAYMENT":y});if(402===c.status){
|
|
195
230
|
// subscription required
|
|
196
|
-
if(n){const i=yield c.json();if(yield n(i.marketplaceAction)){const n=yield this.settlePaymentIntent(i,t||a);if(n&&!n.txHash)throw new
|
|
231
|
+
if(n){const i=yield c.json();if(yield n(i.marketplaceAction)){const n=yield this.settlePaymentIntent(i,t||a);if(n&&!n.txHash)throw new _(`Failed to settle X402 payment for token ${e}: no transaction hash returned`);
|
|
197
232
|
// retry fetching data after settlement
|
|
198
233
|
return yield this.getDataWithIntent(e,t,void 0)}
|
|
199
234
|
// user declined to proceed with payment
|
|
200
|
-
return{error:"User declined to proceed with payment",data:null}}return c.json()}if(!c.ok)throw new
|
|
235
|
+
return{error:"User declined to proceed with payment",data:null}}return c.json()}if(!c.ok){const t=yield c.text().catch((()=>c.statusText));throw new _(`Failed to fetch data for token ${e} after X402 payment (HTTP ${c.status}): ${t}`,c.status)}const m=yield c.json();return{error:null,data:null!==(i=m.data)&&void 0!==i?i:m}}))}
|
|
201
236
|
/**
|
|
202
237
|
* Build the X402 payment payload.
|
|
203
238
|
* @private
|
|
204
|
-
*/function
|
|
239
|
+
*/function xe(e,t,n){return f(this,void 0,void 0,(function*(){const i="native"===e.asset?r:e.asset,a=BigInt(e.maxAmountRequired||0),u=e.extra.duration,p=ke.call(this),l=_e,y=crypto.randomUUID(),c=o(d(y)),m={payer:t,asset:i,amount:a.toString(),httpMethod:"GET",payTo:s(this.environment.MARKETPLACE_CONTRACT_ADDRESS),tokenId:e.extra.tokenId,duration:u,expiresAt:Math.floor(Date.now()/1e3)+e.maxTimeoutSeconds,nonce:c},h=b(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}})}}))}
|
|
205
240
|
/**
|
|
206
241
|
* Create the X402 Intent domain for EIP-712 signing.
|
|
207
242
|
* @private
|
|
208
|
-
*/function
|
|
243
|
+
*/function ke(){return{name:"Origin X402 Intent",version:"1",chainId:this.environment.CHAIN.id,verifyingContract:this.environment.MARKETPLACE_CONTRACT_ADDRESS}}
|
|
209
244
|
/**
|
|
210
245
|
* Get the current account address.
|
|
211
246
|
* @private
|
|
212
|
-
*/function
|
|
247
|
+
*/function Me(){return f(this,void 0,void 0,(function*(){const e=this.viemClient;if(!e)throw new x("No wallet connected. Please connect a wallet to perform this action.");
|
|
213
248
|
// If account is already set on the client, return it directly
|
|
214
249
|
if(e.account)return e.account.address;
|
|
215
250
|
// Otherwise request accounts (browser wallet flow)
|
|
216
|
-
const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.length)throw new
|
|
251
|
+
const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.length)throw new x("No accounts found in connected wallet. Please unlock your wallet or add an account.");return t[0]}))}
|
|
252
|
+
/**
|
|
253
|
+
* Raises a dispute against an IP NFT.
|
|
254
|
+
* Requires the caller to have the dispute bond amount in dispute tokens.
|
|
255
|
+
*
|
|
256
|
+
* @param targetIpId The token ID of the IP NFT to dispute.
|
|
257
|
+
* @param evidenceHash The hash of evidence supporting the dispute.
|
|
258
|
+
* @param disputeTag A tag identifying the type of dispute.
|
|
259
|
+
* @returns A promise that resolves with the transaction result including the dispute ID.
|
|
260
|
+
*
|
|
261
|
+
* @example
|
|
262
|
+
* ```typescript
|
|
263
|
+
* const result = await origin.raiseDispute(
|
|
264
|
+
* 1n,
|
|
265
|
+
* "0x1234...", // evidence hash
|
|
266
|
+
* "0x5678..." // dispute tag (e.g., "infringement", "fraud")
|
|
267
|
+
* );
|
|
268
|
+
* ```
|
|
269
|
+
*/function Fe(e,t,n){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DISPUTE_CONTRACT_ADDRESS,this.environment.DISPUTE_ABI,"raiseDispute",[e,t,n],{waitForReceipt:!0})}))}
|
|
270
|
+
/**
|
|
271
|
+
* Raises a dispute with automatic evidence upload to IPFS.
|
|
272
|
+
* Uploads evidence JSON to IPFS, hashes the CID to bytes32 for on-chain storage,
|
|
273
|
+
* and calls raiseDispute.
|
|
274
|
+
*
|
|
275
|
+
* @param targetIpId The token ID of the IP NFT to dispute.
|
|
276
|
+
* @param evidence The evidence JSON object to upload to IPFS.
|
|
277
|
+
* @param disputeTag A tag identifying the type of dispute.
|
|
278
|
+
* @returns A promise that resolves with the transaction result, IPFS CID, and evidence hash.
|
|
279
|
+
*
|
|
280
|
+
* @example
|
|
281
|
+
* ```typescript
|
|
282
|
+
* const result = await origin.raiseDisputeSmart(
|
|
283
|
+
* 1n,
|
|
284
|
+
* { reason: "copyright", details: "Unauthorized use of copyrighted material" },
|
|
285
|
+
* "0x696e6672696e67656d656e74..." // dispute tag
|
|
286
|
+
* );
|
|
287
|
+
*
|
|
288
|
+
* // Store the CID for evidence retrieval
|
|
289
|
+
* console.log("Evidence CID:", result.evidenceCid);
|
|
290
|
+
*
|
|
291
|
+
* // Fetch evidence later via IPFS gateway
|
|
292
|
+
* // https://ipfs.io/ipfs/{result.evidenceCid}
|
|
293
|
+
*
|
|
294
|
+
* // Verify evidence hash matches on-chain: keccak256(toHex(evidenceCid)) === evidenceHash
|
|
295
|
+
* ```
|
|
296
|
+
*/function Be(e,t,n){return f(this,void 0,void 0,(function*(){const i=yield this.uploadJSONToIPFS(t),a=o(u(i));return{transactionResult:yield this.raiseDispute(e,a,n),evidenceCid:i,evidenceHash:a}}))}
|
|
297
|
+
/**
|
|
298
|
+
* Asserts a dispute as the IP owner with counter-evidence.
|
|
299
|
+
* Must be called by the owner of the disputed IP within the cooldown period.
|
|
300
|
+
*
|
|
301
|
+
* @param disputeId The ID of the dispute to assert.
|
|
302
|
+
* @param counterEvidenceHash The hash of evidence countering the dispute.
|
|
303
|
+
* @returns A promise that resolves with the transaction result.
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* ```typescript
|
|
307
|
+
* await origin.disputeAssertion(1n, "0x1234..."); // counter-evidence hash
|
|
308
|
+
* ```
|
|
309
|
+
*/function Oe(e,t){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DISPUTE_CONTRACT_ADDRESS,this.environment.DISPUTE_ABI,"disputeAssertion",[e,t],{waitForReceipt:!0})}))}
|
|
310
|
+
/**
|
|
311
|
+
* Votes on a dispute as a CAMP token staker.
|
|
312
|
+
* Only users who staked before the dispute was raised can vote.
|
|
313
|
+
* Requires the caller to have voting power >= staking threshold.
|
|
314
|
+
*
|
|
315
|
+
* @param disputeId The ID of the dispute to vote on.
|
|
316
|
+
* @param support True to vote in favor of the dispute, false to vote against.
|
|
317
|
+
* @returns A promise that resolves with the transaction result.
|
|
318
|
+
*
|
|
319
|
+
* @example
|
|
320
|
+
* ```typescript
|
|
321
|
+
* // Vote in favor of the dispute
|
|
322
|
+
* await origin.voteOnDispute(1n, true);
|
|
323
|
+
*
|
|
324
|
+
* // Vote against the dispute
|
|
325
|
+
* await origin.voteOnDispute(1n, false);
|
|
326
|
+
* ```
|
|
327
|
+
*/function Ue(e,t){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DISPUTE_CONTRACT_ADDRESS,this.environment.DISPUTE_ABI,"voteOnDispute",[e,t],{waitForReceipt:!0})}))}
|
|
328
|
+
/**
|
|
329
|
+
* Resolves a dispute after the voting period has ended.
|
|
330
|
+
* Can be called by anyone - resolution is deterministic based on votes and quorum.
|
|
331
|
+
* If the dispute is valid, the IP is marked as disputed and bond is returned.
|
|
332
|
+
* If invalid, the bond is split between the IP owner and resolver (protocol fee to caller).
|
|
333
|
+
*
|
|
334
|
+
* @param disputeId The ID of the dispute to resolve.
|
|
335
|
+
* @returns A promise that resolves with the transaction result.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
* ```typescript
|
|
339
|
+
* await origin.resolveDispute(1n);
|
|
340
|
+
* ```
|
|
341
|
+
*/function $e(e){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DISPUTE_CONTRACT_ADDRESS,this.environment.DISPUTE_ABI,"resolveDispute",[e],{waitForReceipt:!0})}))}
|
|
342
|
+
/**
|
|
343
|
+
* Cancels a dispute that is still in the raised state.
|
|
344
|
+
* Can only be called by the dispute initiator during the cooldown period.
|
|
345
|
+
* The bond is returned to the initiator.
|
|
346
|
+
*
|
|
347
|
+
* @param disputeId The ID of the dispute to cancel.
|
|
348
|
+
* @returns A promise that resolves with the transaction result.
|
|
349
|
+
*
|
|
350
|
+
* @example
|
|
351
|
+
* ```typescript
|
|
352
|
+
* await origin.cancelDispute(1n);
|
|
353
|
+
* ```
|
|
354
|
+
*/function He(e){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DISPUTE_CONTRACT_ADDRESS,this.environment.DISPUTE_ABI,"cancelDispute",[e],{waitForReceipt:!0})}))}
|
|
355
|
+
/**
|
|
356
|
+
* Tags a child IP as disputed if its parent has been successfully disputed.
|
|
357
|
+
* This propagates the dispute status to derivative IPs.
|
|
358
|
+
*
|
|
359
|
+
* @param childIpId The token ID of the child IP to tag.
|
|
360
|
+
* @param infringerDisputeId The ID of the resolved dispute against the parent IP.
|
|
361
|
+
* @returns A promise that resolves with the transaction result.
|
|
362
|
+
*
|
|
363
|
+
* @example
|
|
364
|
+
* ```typescript
|
|
365
|
+
* // After parent IP (tokenId 1) has been disputed, tag child IP (tokenId 2)
|
|
366
|
+
* await origin.tagChildIp(2n, 1n); // childIpId, disputeId of parent
|
|
367
|
+
* ```
|
|
368
|
+
*/function je(e,t){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DISPUTE_CONTRACT_ADDRESS,this.environment.DISPUTE_ABI,"tagChildIp",[e,t],{waitForReceipt:!0})}))}
|
|
369
|
+
/**
|
|
370
|
+
* Gets the details of a dispute by its ID.
|
|
371
|
+
*
|
|
372
|
+
* @param disputeId The ID of the dispute to fetch.
|
|
373
|
+
* @returns A promise that resolves with the dispute details.
|
|
374
|
+
*
|
|
375
|
+
* @example
|
|
376
|
+
* ```typescript
|
|
377
|
+
* const dispute = await origin.getDispute(1n);
|
|
378
|
+
* console.log(`Status: ${dispute.status}`);
|
|
379
|
+
* console.log(`Yes votes: ${dispute.yesVotes}`);
|
|
380
|
+
* console.log(`No votes: ${dispute.noVotes}`);
|
|
381
|
+
* ```
|
|
382
|
+
*/function Le(e){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.DISPUTE_CONTRACT_ADDRESS,this.environment.DISPUTE_ABI,"disputes",[e])}))}
|
|
383
|
+
// minimal ABI for staking vault
|
|
384
|
+
const ze=[{inputs:[{name:"account",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[{name:"account",type:"address"}],name:"userStakeTimestamp",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"}];
|
|
385
|
+
/**
|
|
386
|
+
* Checks if a user meets the requirements to vote on a dispute.
|
|
387
|
+
* Returns detailed information about eligibility and reason if ineligible.
|
|
388
|
+
*
|
|
389
|
+
* @param disputeId The ID of the dispute to check.
|
|
390
|
+
* @param voter Optional address to check. If not provided, uses connected wallet.
|
|
391
|
+
* @returns A promise that resolves with the vote eligibility details.
|
|
392
|
+
*
|
|
393
|
+
* @example
|
|
394
|
+
* ```typescript
|
|
395
|
+
* const eligibility = await origin.canVoteOnDispute(1n);
|
|
396
|
+
*
|
|
397
|
+
* if (eligibility.canVote) {
|
|
398
|
+
* console.log(`You can vote with weight: ${eligibility.votingWeight}`);
|
|
399
|
+
* await origin.voteOnDispute(1n, true);
|
|
400
|
+
* } else {
|
|
401
|
+
* console.log(`Cannot vote: ${eligibility.reason}`);
|
|
402
|
+
* }
|
|
403
|
+
* ```
|
|
404
|
+
*/function Ve(e,t){return f(this,void 0,void 0,(function*(){const n=yield Ce(this.viemClient,t),i=U(),a=this.environment.DISPUTE_CONTRACT_ADDRESS,s=this.environment.DISPUTE_ABI,[r,o,d,u,p,l]=yield Promise.all([this.getDispute(e),i.readContract({address:a,abi:s,functionName:"stakingVault",args:[]}),i.readContract({address:a,abi:s,functionName:"stakingThreshold",args:[]}),i.readContract({address:a,abi:s,functionName:"disputeCoolDownPeriod",args:[]}),i.readContract({address:a,abi:s,functionName:"disputeJudgementPeriod",args:[]}),i.readContract({address:a,abi:s,functionName:"hasVoted",args:[e,n]})]),y=r.status,c=r.disputeTimestamp,m=r.assertionTimestamp,[h,T]=yield Promise.all([i.readContract({address:o,abi:ze,functionName:"userStakeTimestamp",args:[n]}),i.readContract({address:o,abi:ze,functionName:"balanceOf",args:[n]})]),f=BigInt(Math.floor(Date.now()/1e3));let v,A=!1;y===Pe.Asserted?(
|
|
405
|
+
// for asserted disputes, voting period is relative to assertion timestamp
|
|
406
|
+
v=m+p,A=f<=v):y===Pe.Raised&&(
|
|
407
|
+
// for raised disputes, voting period extends from cooldown through judgement
|
|
408
|
+
v=c+u+p,A=f<=v);
|
|
409
|
+
// build base result
|
|
410
|
+
const w={canVote:!1,votingWeight:T,stakingThreshold:d,hasAlreadyVoted:l,userStakeTimestamp:h,disputeTimestamp:c,disputeStatus:y,isVotingPeriodActive:A};
|
|
411
|
+
// check all requirements
|
|
412
|
+
return y!==Pe.Raised&&y!==Pe.Asserted?Object.assign(Object.assign({},w),{reason:`Dispute is not in a voteable status (current: ${Pe[y]})`}):A?l?Object.assign(Object.assign({},w),{reason:"You have already voted on this dispute"}):h===BigInt(0)?Object.assign(Object.assign({},w),{reason:"You have never staked CAMP tokens"}):h>=c?Object.assign(Object.assign({},w),{reason:"You staked after this dispute was raised (vote recycling prevention)"}):T<d?Object.assign(Object.assign({},w),{reason:`Insufficient stake: you have ${T} but need at least ${d}`}):Object.assign(Object.assign({},w),{canVote:!0}):Object.assign(Object.assign({},w),{reason:"Voting period has ended"})}))}
|
|
413
|
+
/**
|
|
414
|
+
* Gets detailed progress and voting statistics for a dispute.
|
|
415
|
+
* Includes vote counts, percentages, quorum progress, and timeline.
|
|
416
|
+
*
|
|
417
|
+
* @param disputeId The ID of the dispute to check.
|
|
418
|
+
* @returns A promise that resolves with the dispute progress details.
|
|
419
|
+
*
|
|
420
|
+
* @example
|
|
421
|
+
* ```typescript
|
|
422
|
+
* const progress = await origin.getDisputeProgress(1n);
|
|
423
|
+
*
|
|
424
|
+
* console.log(`Yes: ${progress.yesPercentage}% | No: ${progress.noPercentage}%`);
|
|
425
|
+
* console.log(`Quorum: ${progress.quorumPercentage}% (${progress.quorumMet ? 'met' : 'not met'})`);
|
|
426
|
+
* console.log(`Projected outcome: ${progress.projectedOutcome}`);
|
|
427
|
+
*
|
|
428
|
+
* if (progress.timeline.canResolveNow) {
|
|
429
|
+
* await origin.resolveDispute(1n);
|
|
430
|
+
* } else {
|
|
431
|
+
* console.log(`Can resolve in ${progress.timeline.timeUntilResolution} seconds`);
|
|
432
|
+
* }
|
|
433
|
+
* ```
|
|
434
|
+
*/function qe(e){return f(this,void 0,void 0,(function*(){var t,n,i,a,s,r,o,d,u;const p=U(),l=this.environment.DISPUTE_CONTRACT_ADDRESS,y=this.environment.DISPUTE_ABI,[c,m,h,T]=yield Promise.all([p.readContract({address:l,abi:y,functionName:"disputes",args:[e]}),p.readContract({address:l,abi:y,functionName:"disputeQuorum",args:[]}),p.readContract({address:l,abi:y,functionName:"disputeCoolDownPeriod",args:[]}),p.readContract({address:l,abi:y,functionName:"disputeJudgementPeriod",args:[]})]),f=Number(null!==(t=c.status)&&void 0!==t?t:c[9]),v=BigInt(null!==(i=null!==(n=c.disputeTimestamp)&&void 0!==n?n:c[5])&&void 0!==i?i:0),A=BigInt(null!==(s=null!==(a=c.assertionTimestamp)&&void 0!==a?a:c[6])&&void 0!==s?s:0),w=BigInt(null!==(o=null!==(r=c.yesVotes)&&void 0!==r?r:c[7])&&void 0!==o?o:0),I=BigInt(null!==(u=null!==(d=c.noVotes)&&void 0!==d?d:c[8])&&void 0!==u?u:0),g=w+I;let b=0,C=0;g>BigInt(0)&&(b=Number(w*BigInt(1e4)/g)/100,C=Number(I*BigInt(1e4)/g)/100);
|
|
435
|
+
// calculate quorum progress
|
|
436
|
+
let E=0;m>BigInt(0)&&(E=Number(g*BigInt(1e4)/m)/100);const S=g>=m;
|
|
437
|
+
// determine projected outcome
|
|
438
|
+
let P;P=S?w>I?"dispute_succeeds":"dispute_fails":"no_quorum";
|
|
439
|
+
// calculate timeline
|
|
440
|
+
const R=BigInt(Math.floor(Date.now()/1e3)),_=new Date(1e3*Number(v)),D=new Date(1e3*Number(v+h));let N,x;f===Pe.Asserted?(
|
|
441
|
+
// for asserted disputes, voting ends relative to assertion
|
|
442
|
+
N=new Date(1e3*Number(A+T)),x=A+T):(
|
|
443
|
+
// for raised disputes, voting ends after cooldown + judgement
|
|
444
|
+
N=new Date(1e3*Number(v+h+T)),x=v+h+T);const k=(f===Pe.Raised||f===Pe.Asserted)&&R>x,M=k?0:Number(x-R);return{disputeId:e,status:f,yesVotes:w,noVotes:I,totalVotes:g,yesPercentage:b,noPercentage:C,quorum:m,quorumPercentage:E,quorumMet:S,projectedOutcome:P,timeline:{raisedAt:_,cooldownEndsAt:D,votingEndsAt:N,canResolveNow:k,timeUntilResolution:M}}}))}
|
|
445
|
+
/**
|
|
446
|
+
* Fractionalizes an IP NFT into fungible ERC20 tokens.
|
|
447
|
+
* The NFT is transferred to the fractionalizer contract and a new ERC20 token is created.
|
|
448
|
+
* The caller receives the full supply of fractional tokens.
|
|
449
|
+
*
|
|
450
|
+
* @param tokenId The token ID of the IP NFT to fractionalize.
|
|
451
|
+
* @returns A promise that resolves with the transaction result.
|
|
452
|
+
*
|
|
453
|
+
* @example
|
|
454
|
+
* ```typescript
|
|
455
|
+
* // First approve the fractionalizer contract to transfer your NFT
|
|
456
|
+
* await origin.approve(fractionalizerAddress, tokenId);
|
|
457
|
+
*
|
|
458
|
+
* // Then fractionalize
|
|
459
|
+
* const result = await origin.fractionalize(1n);
|
|
460
|
+
* ```
|
|
461
|
+
*/function Je(e){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.FRACTIONALIZER_CONTRACT_ADDRESS,this.environment.FRACTIONALIZER_ABI,"fractionalize",[e],{waitForReceipt:!0})}))}
|
|
462
|
+
/**
|
|
463
|
+
* Redeems an IP NFT by burning all of its fractional tokens.
|
|
464
|
+
* The caller must hold the entire supply of the NFT's fractional token.
|
|
465
|
+
* After redemption, the NFT is transferred back to the caller.
|
|
466
|
+
*
|
|
467
|
+
* @param tokenId The token ID of the IP NFT to redeem.
|
|
468
|
+
* @returns A promise that resolves with the transaction result.
|
|
469
|
+
*
|
|
470
|
+
* @example
|
|
471
|
+
* ```typescript
|
|
472
|
+
* // Requires holding 100% of the fractional token supply
|
|
473
|
+
* await origin.redeem(1n);
|
|
474
|
+
* ```
|
|
475
|
+
*/function Ge(e){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.FRACTIONALIZER_CONTRACT_ADDRESS,this.environment.FRACTIONALIZER_ABI,"redeem",[e],{waitForReceipt:!0})}))}
|
|
476
|
+
/**
|
|
477
|
+
* Gets the fractional ERC20 token address for a specific IP NFT.
|
|
478
|
+
* Returns zero address if the NFT has not been fractionalized.
|
|
479
|
+
*
|
|
480
|
+
* @param tokenId The token ID of the IP NFT.
|
|
481
|
+
* @returns A promise that resolves with the fractional token address.
|
|
482
|
+
*
|
|
483
|
+
* @example
|
|
484
|
+
* ```typescript
|
|
485
|
+
* const fractionalToken = await origin.getTokenForNFT(1n);
|
|
486
|
+
* if (fractionalToken !== zeroAddress) {
|
|
487
|
+
* console.log(`Fractional token: ${fractionalToken}`);
|
|
488
|
+
* } else {
|
|
489
|
+
* console.log("NFT has not been fractionalized");
|
|
490
|
+
* }
|
|
491
|
+
* ```
|
|
492
|
+
*/function Ye(e){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.FRACTIONALIZER_CONTRACT_ADDRESS,this.environment.FRACTIONALIZER_ABI,"getTokenForNFT",[e])}))}
|
|
493
|
+
/**
|
|
494
|
+
* Fractionalizes an IP NFT with automatic approval.
|
|
495
|
+
* This method first approves the fractionalizer contract to transfer your NFT,
|
|
496
|
+
* then calls fractionalize. This is the recommended method for most use cases.
|
|
497
|
+
*
|
|
498
|
+
* @param tokenId The token ID of the IP NFT to fractionalize.
|
|
499
|
+
* @returns A promise that resolves with the transaction result.
|
|
500
|
+
*
|
|
501
|
+
* @example
|
|
502
|
+
* ```typescript
|
|
503
|
+
* // Single call handles approval and fractionalization
|
|
504
|
+
* const result = await origin.fractionalizeWithApproval(1n);
|
|
505
|
+
* ```
|
|
506
|
+
*/function We(e){return f(this,void 0,void 0,(function*(){return yield this.approve(this.environment.FRACTIONALIZER_CONTRACT_ADDRESS,e),this.callContractMethod(this.environment.FRACTIONALIZER_CONTRACT_ADDRESS,this.environment.FRACTIONALIZER_ABI,"fractionalize",[e],{waitForReceipt:!0})}))}
|
|
507
|
+
/**
|
|
508
|
+
* Redeems fractional tokens for the underlying NFT, but only if the caller owns 100% of the supply.
|
|
509
|
+
* This method checks the caller's balance before attempting to redeem, providing a clear error
|
|
510
|
+
* if they don't hold the full supply.
|
|
511
|
+
*
|
|
512
|
+
* @param tokenId The token ID of the original NFT to redeem.
|
|
513
|
+
* @returns A promise that resolves with the transaction result.
|
|
514
|
+
* @throws Error if the caller doesn't own 100% of the fractional tokens.
|
|
515
|
+
*
|
|
516
|
+
* @example
|
|
517
|
+
* ```typescript
|
|
518
|
+
* try {
|
|
519
|
+
* const result = await origin.redeemIfComplete(1n);
|
|
520
|
+
* console.log("NFT redeemed successfully!");
|
|
521
|
+
* } catch (error) {
|
|
522
|
+
* console.log("You don't own all fractional tokens yet");
|
|
523
|
+
* }
|
|
524
|
+
* ```
|
|
525
|
+
*/function Ze(e){return f(this,void 0,void 0,(function*(){
|
|
526
|
+
// get the ERC20 token address for this NFT
|
|
527
|
+
const t=yield this.getTokenForNFT(e);if(!t||"0x0000000000000000000000000000000000000000"===t)throw new Error("This NFT has not been fractionalized");
|
|
528
|
+
// get current wallet address
|
|
529
|
+
const n=yield Ce(this.viemClient),i=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"}],a=U(),[s,r]=yield Promise.all([a.readContract({address:t,abi:i,functionName:"balanceOf",args:[n]}),a.readContract({address:t,abi:i,functionName:"totalSupply",args:[]})]);
|
|
530
|
+
// check caller's balance and total supply
|
|
531
|
+
if(s<r){const e=s*BigInt(1e4)/r;throw new Error(`Cannot redeem: you own ${e/BigInt(100)}.${e%BigInt(100)}% of the fractional tokens (${s}/${r}). You need 100% to redeem.`)}
|
|
532
|
+
// proceed with redemption
|
|
533
|
+
return this.callContractMethod(this.environment.FRACTIONALIZER_CONTRACT_ADDRESS,this.environment.FRACTIONALIZER_ABI,"redeem",[e],{waitForReceipt:!0})}))}
|
|
534
|
+
// minimal ERC20 ABI
|
|
535
|
+
const Ke=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"totalSupply",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],stateMutability:"view",type:"function"}];
|
|
536
|
+
/**
|
|
537
|
+
* Gets a user's ownership percentage of a fractionalized NFT.
|
|
538
|
+
* Returns detailed information about the user's fractional token holdings.
|
|
539
|
+
*
|
|
540
|
+
* @param tokenId The token ID of the original NFT.
|
|
541
|
+
* @param owner Optional address to check. If not provided, uses connected wallet.
|
|
542
|
+
* @returns A promise that resolves with the ownership details.
|
|
543
|
+
*
|
|
544
|
+
* @example
|
|
545
|
+
* ```typescript
|
|
546
|
+
* const ownership = await origin.getFractionOwnership(1n);
|
|
547
|
+
*
|
|
548
|
+
* if (!ownership.isFractionalized) {
|
|
549
|
+
* console.log("This NFT has not been fractionalized");
|
|
550
|
+
* } else {
|
|
551
|
+
* console.log(`You own ${ownership.ownershipPercentage}% of this NFT`);
|
|
552
|
+
* console.log(`Balance: ${ownership.balance} / ${ownership.totalSupply}`);
|
|
553
|
+
*
|
|
554
|
+
* if (ownership.canRedeem) {
|
|
555
|
+
* console.log("You can redeem the original NFT!");
|
|
556
|
+
* await origin.redeem(1n);
|
|
557
|
+
* }
|
|
558
|
+
* }
|
|
559
|
+
* ```
|
|
560
|
+
*/function Xe(e,t){return f(this,void 0,void 0,(function*(){const n=yield Ce(this.viemClient,t),i=yield this.getTokenForNFT(e);
|
|
561
|
+
// get the ERC20 token address for this NFT
|
|
562
|
+
// check if fractionalized
|
|
563
|
+
if(!i||i===r)return{tokenId:e,erc20Address:r,isFractionalized:!1,balance:BigInt(0),totalSupply:BigInt(0),ownershipPercentage:0,canRedeem:!1,decimals:18};const a=U(),[s,o,d]=yield Promise.all([a.readContract({address:i,abi:Ke,functionName:"balanceOf",args:[n]}),a.readContract({address:i,abi:Ke,functionName:"totalSupply",args:[]}),a.readContract({address:i,abi:Ke,functionName:"decimals",args:[]})]);
|
|
564
|
+
// fetch ERC20 data
|
|
565
|
+
// calculate ownership percentage
|
|
566
|
+
let u=0;o>BigInt(0)&&(u=Number(s*BigInt(1e4)/o)/100);const p=s>=o&&o>BigInt(0);return{tokenId:e,erc20Address:i,isFractionalized:!0,balance:s,totalSupply:o,ownershipPercentage:u,canRedeem:p,decimals:d}}))}
|
|
567
|
+
/**
|
|
568
|
+
* Checks if a user can fractionalize an NFT and why not if they can't.
|
|
569
|
+
* Returns detailed information about eligibility requirements.
|
|
570
|
+
*
|
|
571
|
+
* @param tokenId The token ID of the NFT to check.
|
|
572
|
+
* @param owner Optional address to check. If not provided, uses connected wallet.
|
|
573
|
+
* @returns A promise that resolves with the fractionalize eligibility details.
|
|
574
|
+
*
|
|
575
|
+
* @example
|
|
576
|
+
* ```typescript
|
|
577
|
+
* const eligibility = await origin.canFractionalize(1n);
|
|
578
|
+
*
|
|
579
|
+
* if (eligibility.canFractionalize) {
|
|
580
|
+
* if (eligibility.needsApproval) {
|
|
581
|
+
* // Use fractionalizeWithApproval for convenience
|
|
582
|
+
* await origin.fractionalizeWithApproval(1n);
|
|
583
|
+
* } else {
|
|
584
|
+
* await origin.fractionalize(1n);
|
|
585
|
+
* }
|
|
586
|
+
* } else {
|
|
587
|
+
* console.log(`Cannot fractionalize: ${eligibility.reason}`);
|
|
588
|
+
* }
|
|
589
|
+
* ```
|
|
590
|
+
*/function Qe(e,t){return f(this,void 0,void 0,(function*(){const n=yield Ce(this.viemClient,t),i=U(),a=this.environment.FRACTIONALIZER_CONTRACT_ADDRESS,[s,o,d,u,p]=yield Promise.all([this.ownerOf(e),this.dataStatus(e),this.getTokenForNFT(e),i.readContract({address:this.environment.DATANFT_CONTRACT_ADDRESS,abi:this.environment.IPNFT_ABI,functionName:"getApproved",args:[e]}),i.readContract({address:this.environment.DATANFT_CONTRACT_ADDRESS,abi:this.environment.IPNFT_ABI,functionName:"isApprovedForAll",args:[n,a]})]),l=s.toLowerCase()===n.toLowerCase(),y=d&&d!==r,c=p||u.toLowerCase()===a.toLowerCase(),m={canFractionalize:!1,isOwner:l,currentOwner:s,isAlreadyFractionalized:!!y,existingErc20Address:y?d:void 0,dataStatus:o,isApproved:c,needsApproval:!c};
|
|
591
|
+
// check requirements
|
|
592
|
+
return l?y?Object.assign(Object.assign({},m),{reason:`This NFT is already fractionalized. ERC20: ${d}`}):o===Se.DELETED?Object.assign(Object.assign({},m),{reason:"This NFT has been deleted and cannot be fractionalized"}):o===Se.DISPUTED?Object.assign(Object.assign({},m),{reason:"This NFT is disputed and cannot be fractionalized"}):Object.assign(Object.assign({},m),{canFractionalize:!0}):Object.assign(Object.assign({},m),{reason:`You don't own this NFT. Current owner: ${s}`})}))}
|
|
593
|
+
/**
|
|
594
|
+
* Gets information about a registered app from the AppRegistry.
|
|
595
|
+
*
|
|
596
|
+
* @param appId The app ID to look up.
|
|
597
|
+
* @returns A promise that resolves with the app information.
|
|
598
|
+
*
|
|
599
|
+
* @example
|
|
600
|
+
* ```typescript
|
|
601
|
+
* const appInfo = await origin.getAppInfo("my-app-id");
|
|
602
|
+
* console.log(`Treasury: ${appInfo.treasury}`);
|
|
603
|
+
* console.log(`Revenue Share: ${appInfo.revenueShareBps / 100}%`);
|
|
604
|
+
* console.log(`Active: ${appInfo.isActive}`);
|
|
605
|
+
* ```
|
|
606
|
+
*/function et(e){return f(this,void 0,void 0,(function*(){return this.callContractMethod(this.environment.APP_REGISTRY_CONTRACT_ADDRESS,this.environment.APP_REGISTRY_ABI,"getAppInfo",[e])}))}
|
|
217
607
|
/**
|
|
218
608
|
* Approves a spender to spend a specified amount of tokens on behalf of the owner.
|
|
219
609
|
* If the current allowance is less than the specified amount, it will perform the approval.
|
|
220
610
|
* @param {ApproveParams} params - The parameters for the approval.
|
|
221
|
-
*/function
|
|
611
|
+
*/function tt(e){return f(this,arguments,void 0,(function*({walletClient:e,publicClient:t,tokenAddress:n,owner:i,spender:a,amount:s}){(yield t.readContract({address:n,abi:p,functionName:"allowance",args:[i,a]}))<s&&(yield e.writeContract({address:n,account:i,abi:p,functionName:"approve",args:[a,s],chain:P}))}))}
|
|
222
612
|
/**
|
|
223
613
|
* Executes an atomic bulk purchase of multiple IP-NFT licenses.
|
|
224
614
|
* All purchases succeed or all fail together.
|
|
@@ -237,7 +627,7 @@ const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.l
|
|
|
237
627
|
* const totalValue = 3000000000000000n;
|
|
238
628
|
* await origin.bulkBuyAccess(buyerAddress, purchases, totalValue);
|
|
239
629
|
* ```
|
|
240
|
-
*/function
|
|
630
|
+
*/function nt(e,t,n){return this.callContractMethod(this.environment.BATCH_PURCHASE_CONTRACT_ADDRESS,this.environment.BATCH_PURCHASE_ABI,"bulkBuyAccess",[e,t],{waitForReceipt:!0,value:n})}
|
|
241
631
|
/**
|
|
242
632
|
* Executes a fault-tolerant bulk purchase of multiple IP-NFT licenses.
|
|
243
633
|
* Individual purchases can fail without reverting the entire transaction.
|
|
@@ -254,7 +644,7 @@ const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.l
|
|
|
254
644
|
* console.log(`Purchased ${result.successCount} of ${purchases.length} IPs`);
|
|
255
645
|
* console.log(`Failed tokens: ${result.failedTokenIds}`);
|
|
256
646
|
* ```
|
|
257
|
-
*/function
|
|
647
|
+
*/function it(e,t,n){return this.callContractMethod(this.environment.BATCH_PURCHASE_CONTRACT_ADDRESS,this.environment.BATCH_PURCHASE_ABI,"bulkBuyAccessTolerant",[e,t],{waitForReceipt:!0,value:n})}
|
|
258
648
|
/**
|
|
259
649
|
* Previews the total cost of purchasing multiple IP-NFT licenses.
|
|
260
650
|
* This is a view function that doesn't require a transaction.
|
|
@@ -268,7 +658,7 @@ const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.l
|
|
|
268
658
|
* console.log(`Total cost: ${preview.totalNativeCost} wei`);
|
|
269
659
|
* console.log(`Valid tokens: ${preview.validCount}`);
|
|
270
660
|
* ```
|
|
271
|
-
*/function
|
|
661
|
+
*/function at(e){return this.callContractMethod(this.environment.BATCH_PURCHASE_CONTRACT_ADDRESS,this.environment.BATCH_PURCHASE_ABI,"previewBulkCost",[e])}
|
|
272
662
|
/**
|
|
273
663
|
* Builds purchase parameters for multiple tokens by fetching their current license terms.
|
|
274
664
|
* This is a view function that doesn't require a transaction.
|
|
@@ -281,7 +671,7 @@ const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.l
|
|
|
281
671
|
* const params = await origin.buildPurchaseParams([1n, 2n, 3n]);
|
|
282
672
|
* await origin.bulkBuyAccess(buyer, params, totalValue);
|
|
283
673
|
* ```
|
|
284
|
-
*/function
|
|
674
|
+
*/function st(e){return this.callContractMethod(this.environment.BATCH_PURCHASE_CONTRACT_ADDRESS,this.environment.BATCH_PURCHASE_ABI,"buildPurchaseParams",[e])}
|
|
285
675
|
/**
|
|
286
676
|
* Checks the active status of multiple tokens.
|
|
287
677
|
*
|
|
@@ -293,7 +683,7 @@ const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.l
|
|
|
293
683
|
* const activeFlags = await origin.checkActiveStatus([1n, 2n, 3n]);
|
|
294
684
|
* const activeTokens = tokenIds.filter((_, i) => activeFlags[i]);
|
|
295
685
|
* ```
|
|
296
|
-
*/function
|
|
686
|
+
*/function rt(e){return this.callContractMethod(this.environment.BATCH_PURCHASE_CONTRACT_ADDRESS,this.environment.BATCH_PURCHASE_ABI,"checkActiveStatus",[e])}
|
|
297
687
|
/**
|
|
298
688
|
* Smart bulk purchase that automatically fetches terms and handles the entire purchase flow.
|
|
299
689
|
* This is the recommended method for most use cases.
|
|
@@ -310,29 +700,41 @@ const t=yield e.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.l
|
|
|
310
700
|
* // Tolerant purchase - continue even if some fail
|
|
311
701
|
* const result = await origin.bulkBuyAccessSmart([1n, 2n, 3n], { tolerant: true });
|
|
312
702
|
* ```
|
|
313
|
-
*/function
|
|
703
|
+
*/function ot(e,t){return f(this,void 0,void 0,(function*(){if(!e||0===e.length)throw new D("No token IDs provided for bulk purchase. Please provide at least one token ID.");
|
|
314
704
|
// Get the buyer's wallet address
|
|
315
|
-
const n=this.viemClient;if(!n)throw new
|
|
705
|
+
const n=this.viemClient;if(!n)throw new x("Cannot perform bulk purchase: wallet not connected. Please connect a wallet first.");let i;if(n.account)i=n.account.address;else{const e=yield n.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new x("No accounts found in connected wallet. Please unlock your wallet or add an account.");i=e[0]}
|
|
316
706
|
// Build purchase params from on-chain data
|
|
317
707
|
const a=yield this.buildPurchaseParams(e);
|
|
318
708
|
// Calculate total native token cost
|
|
319
|
-
let
|
|
709
|
+
let s=BigInt(0);const o=[];for(const e of a)if(e.expectedPaymentToken===r)s+=e.expectedPrice;else{
|
|
320
710
|
// Group ERC20 purchases by token
|
|
321
711
|
const t=o.find((t=>t.token===e.expectedPaymentToken));t?t.amount+=e.expectedPrice:o.push({token:e.expectedPaymentToken,amount:e.expectedPrice})}
|
|
322
712
|
// Approve ERC20 tokens if needed
|
|
323
|
-
const d=
|
|
713
|
+
const d=U();for(const e of o)yield tt({walletClient:n,publicClient:d,tokenAddress:e.token,owner:i,spender:this.environment.BATCH_PURCHASE_CONTRACT_ADDRESS,amount:e.amount});
|
|
324
714
|
// Execute the purchase
|
|
325
|
-
return(null==t?void 0:t.tolerant)?this.bulkBuyAccessTolerant(i,a,
|
|
715
|
+
return(null==t?void 0:t.tolerant)?this.bulkBuyAccessTolerant(i,a,s):this.bulkBuyAccess(i,a,s)}))}var dt,ut,pt,lt,yt,ct,mt,ht,Tt,ft,vt,At,wt,It,gt,bt,Ct,Et,St,Pt,Rt,_t;
|
|
326
716
|
/**
|
|
327
717
|
* The Origin class
|
|
328
718
|
* Handles interactions with Origin protocol.
|
|
329
|
-
*/class
|
|
719
|
+
*/class Dt{constructor(e,t,n,i,a){dt.add(this),t?this.jwt=t:console.warn("JWT not provided. Some features may be unavailable."),this.viemClient=n,this.environment="string"==typeof e?X[e]:e||X.DEVELOPMENT,this.environment.AUTH_HUB_BASE_API+="PRODUCTION"===e?"/auth-mainnet":"",this.baseParentId=i,this.appId=a,
|
|
330
720
|
// DataNFT methods
|
|
331
|
-
this.mintWithSignature=
|
|
721
|
+
this.mintWithSignature=ie.bind(this),this.registerIpNFT=ae.bind(this),this.updateTerms=se.bind(this),this.finalizeDelete=re.bind(this),this.getOrCreateRoyaltyVault=oe.bind(this),this.getTerms=de.bind(this),this.ownerOf=ue.bind(this),this.balanceOf=pe.bind(this),this.tokenURI=le.bind(this),this.dataStatus=ye.bind(this),this.isApprovedForAll=ce.bind(this),this.transferFrom=me.bind(this),this.safeTransferFrom=he.bind(this),this.approve=Te.bind(this),this.setApprovalForAll=fe.bind(this),
|
|
332
722
|
// Marketplace methods
|
|
333
|
-
this.buyAccess=
|
|
723
|
+
this.buyAccess=ve.bind(this),this.hasAccess=Ae.bind(this),this.subscriptionExpiry=we.bind(this),this.settlePaymentIntent=be.bind(this),this.getDataWithIntent=Ne.bind(this),
|
|
334
724
|
// Bulk purchase methods
|
|
335
|
-
this.bulkBuyAccess=
|
|
725
|
+
this.bulkBuyAccess=nt.bind(this),this.bulkBuyAccessTolerant=it.bind(this),this.bulkBuyAccessSmart=ot.bind(this),this.previewBulkCost=at.bind(this),this.buildPurchaseParams=st.bind(this),this.checkActiveStatus=rt.bind(this),
|
|
726
|
+
// Dispute module methods
|
|
727
|
+
this.raiseDispute=Fe.bind(this),this.raiseDisputeSmart=Be.bind(this),this.disputeAssertion=Oe.bind(this),this.voteOnDispute=Ue.bind(this),this.resolveDispute=$e.bind(this),this.cancelDispute=He.bind(this),this.tagChildIp=je.bind(this),this.getDispute=Le.bind(this),this.canVoteOnDispute=Ve.bind(this),this.getDisputeProgress=qe.bind(this),
|
|
728
|
+
// Fractionalizer module methods
|
|
729
|
+
this.fractionalize=Je.bind(this),this.redeem=Ge.bind(this),this.getTokenForNFT=Ye.bind(this),this.fractionalizeWithApproval=We.bind(this),this.redeemIfComplete=Ze.bind(this),this.getFractionOwnership=Xe.bind(this),this.canFractionalize=Qe.bind(this),
|
|
730
|
+
// AppRegistry module methods
|
|
731
|
+
this.getAppInfo=et.bind(this)}getJwt(){return this.jwt}setViemClient(e){this.viemClient=e}
|
|
732
|
+
/**
|
|
733
|
+
* Uploads a JSON object to IPFS and returns the resulting CID.
|
|
734
|
+
* @param data The JSON object to upload.
|
|
735
|
+
* @returns The CID of the uploaded JSON.
|
|
736
|
+
* @throws {APIError} If the upload fails.
|
|
737
|
+
*/uploadJSONToIPFS(e){return f(this,void 0,void 0,(function*(){const t=JSON.stringify(e),n=new File([t],"evidence.json",{type:"application/json"}),i=yield v(this,dt,"m",lt).call(this,n);if(!i)throw new _("Failed to upload evidence to IPFS");return i}))}
|
|
336
738
|
/**
|
|
337
739
|
* Mints a file-based IpNFT.
|
|
338
740
|
* @param file The file to mint.
|
|
@@ -341,16 +743,20 @@ this.bulkBuyAccess=ge.bind(this),this.bulkBuyAccessTolerant=Ie.bind(this),this.b
|
|
|
341
743
|
* @param parents Optional parent token IDs for lineage tracking.
|
|
342
744
|
* @param options Optional parameters including progress callback, preview image, and use asset as preview flag.
|
|
343
745
|
* @returns The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
344
|
-
*/mintFile(e,t,n,i,a){return
|
|
345
|
-
let u;this.baseParentId&&(i||(i=[]),i.unshift(this.baseParentId));try{u=yield this.registerIpNFT("file",d,n,t
|
|
746
|
+
*/mintFile(e,t,n,i,a){return f(this,void 0,void 0,(function*(){let s,r=null;try{r=yield v(this,dt,"m",ht).call(this)}catch(t){throw new x(`Cannot mint file "${e.name}": wallet not connected. Please connect a wallet first.`)}try{if(s=yield v(this,dt,"m",yt).call(this,e,a),!s||!s.key)throw new _(`Failed to upload file "${e.name}": no upload info returned from server`)}catch(t){if(t instanceof _||t instanceof x)throw t;throw new _(`Failed to upload file "${e.name}": ${M(t)}`)}e.type&&(t.mimetype=e.type);let o=null;(null==a?void 0:a.previewImage)&&(null==a?void 0:a.previewImage.type.startsWith("image/"))?o=yield v(this,dt,"m",lt).call(this,a.previewImage):(null==a?void 0:a.useAssetAsPreview)&&e.type.startsWith("image/")&&(o=yield v(this,dt,"m",lt).call(this,e)),o&&(t.image=`ipfs://${o}`);const d=BigInt(Date.now()+6e5);// 10 minutes from now
|
|
747
|
+
let u;this.baseParentId&&(i||(i=[]),i.unshift(this.baseParentId));try{u=yield this.registerIpNFT("file",d,n,t,!0,// isIp
|
|
748
|
+
s.key,// fileKey
|
|
749
|
+
i,this.appId)}catch(e){throw yield v(this,dt,"m",pt).call(this,s.key,s.uploadId,[]),new Error(`Failed to register IpNFT: ${e instanceof Error?e.message:String(e)}`)}const{tokenId:p,signerAddress:l,creatorContentHash:y,signature:c,uri:m}=u;if(!(p&&l&&y&&void 0!==c&&m))throw new Error("Failed to register IpNFT: Missing required fields in registration response.");try{const e=yield this.mintWithSignature(r,p,i||[],!0,y,m,n,d,c,this.appId);if(-1===["0x1","success"].indexOf(e.receipt.status))throw yield v(this,dt,"m",pt).call(this,s.key,s.uploadId,[]),new Error(`Minting failed with status: ${e.receipt.status}`)}catch(e){throw yield v(this,dt,"m",pt).call(this,s.key,s.uploadId,[]),new Error(`Minting transaction failed: ${e instanceof Error?e.message:String(e)}`)}return p.toString()}))}
|
|
346
750
|
/**
|
|
347
751
|
* Mints a social IpNFT.
|
|
348
752
|
* @param source The social media source (spotify, twitter, tiktok).
|
|
349
753
|
* @param metadata The metadata associated with the social media content.
|
|
350
754
|
* @param license The license terms for the IpNFT.
|
|
351
755
|
* @return The token ID of the minted IpNFT as a string, or null if minting failed.
|
|
352
|
-
*/mintSocial(e,t,n){return
|
|
353
|
-
let r
|
|
756
|
+
*/mintSocial(e,t,n){return f(this,void 0,void 0,(function*(){let i=null;try{i=yield v(this,dt,"m",ht).call(this)}catch(t){throw new x(`Cannot mint ${e} social IP: wallet not connected. Please connect a wallet first.`)}t.mimetype=`social/${e}`;const a=BigInt(Math.floor(Date.now()/1e3)+600);// 10 minutes from now
|
|
757
|
+
let s,r=this.baseParentId?[this.baseParentId]:[];try{s=yield this.registerIpNFT(e,a,n,t,!0,// isIp
|
|
758
|
+
void 0,// fileKey
|
|
759
|
+
r,this.appId)}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}=s;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,r,!0,u,l,n,a,p,this.appId);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()}))}
|
|
354
760
|
/**
|
|
355
761
|
* Call a contract method.
|
|
356
762
|
* @param {string} contractAddress The contract address.
|
|
@@ -360,20 +766,63 @@ let r,s=this.baseParentId?[this.baseParentId]:[];try{r=yield this.registerIpNFT(
|
|
|
360
766
|
* @param {CallOptions} [options] The call options.
|
|
361
767
|
* @returns {Promise<any>} A promise that resolves with the result of the contract call or transaction hash.
|
|
362
768
|
* @throws {Error} - Throws an error if the wallet client is not connected and the method is not a view function.
|
|
363
|
-
*/callContractMethod(e,t,n,i){return
|
|
769
|
+
*/callContractMethod(e,t,n,i){return f(this,arguments,void 0,(function*(e,t,n,i,a={}){var s;let r=null;try{r=yield v(this,dt,"m",ht).call(this)}catch(t){throw new x(`Cannot call "${n}" on contract ${e}: wallet not connected`)}const o=l({abi:t,name:n});if(o&&"stateMutability"in o&&("view"===o.stateMutability||"pure"===o.stateMutability)){const a=U();return(yield a.readContract({address:e,abi:t,functionName:n,args:i}))||null}yield v(this,dt,"m",mt).call(this,this.environment.CHAIN);const d=U(),{result:u,request:p}=yield d.simulateContract({account:r,address:e,abi:t,functionName:n,args:i,value:a.value});
|
|
364
770
|
// simulate
|
|
365
|
-
if(a.simulate)return u;try{const
|
|
771
|
+
if(a.simulate)return u;try{const t=yield null===(s=this.viemClient)||void 0===s?void 0:s.writeContract(p);if("string"!=typeof t)throw new k(`Transaction for "${n}" failed to send: no transaction hash returned`,{contractName:e,methodName:n});if(!a.waitForReceipt)return{txHash:t,simulatedResult:u};return{txHash:t,receipt:yield v(this,dt,"m",ct).call(this,t),simulatedResult:u}}catch(t){if(t instanceof k||t instanceof x)throw t;throw new k(`Transaction for "${n}" failed: ${M(t)}`,{contractName:e,methodName:n})}}))}
|
|
772
|
+
/**
|
|
773
|
+
* Gets comprehensive token information in a single call.
|
|
774
|
+
* Combines owner, status, terms, URI, and access information.
|
|
775
|
+
*
|
|
776
|
+
* @param tokenId The token ID to get information for.
|
|
777
|
+
* @param owner Optional address to check access for. If not provided, uses connected wallet.
|
|
778
|
+
* @returns A promise that resolves with comprehensive token information.
|
|
779
|
+
*
|
|
780
|
+
* @example
|
|
781
|
+
* ```typescript
|
|
782
|
+
* const info = await origin.getTokenInfoSmart(1n);
|
|
783
|
+
* console.log(`Owner: ${info.owner}`);
|
|
784
|
+
* console.log(`Price: ${info.terms.price}`);
|
|
785
|
+
* console.log(`Has access: ${info.hasAccess}`);
|
|
786
|
+
* ```
|
|
787
|
+
*/getTokenInfoSmart(e,t){return f(this,void 0,void 0,(function*(){var n;
|
|
788
|
+
// Resolve the address to check access for
|
|
789
|
+
let i;if(t)i=t;else if(null===(n=this.viemClient)||void 0===n?void 0:n.account)i=this.viemClient.account.address;else if(this.viemClient)try{const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});i=e&&e.length>0?e[0]:"0x0000000000000000000000000000000000000000"}catch(e){i="0x0000000000000000000000000000000000000000"}else i="0x0000000000000000000000000000000000000000";
|
|
790
|
+
// Fetch all information in parallel
|
|
791
|
+
const[a,s,r,o,d]=yield Promise.all([this.ownerOf(e),this.tokenURI(e),this.dataStatus(e),this.getTerms(e),this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenInfo",[e]).catch((()=>({appId:""})))]);
|
|
792
|
+
// Get access info if we have a valid address
|
|
793
|
+
let u=!1,p=null;if("0x0000000000000000000000000000000000000000"!==i)try{[u,p]=yield Promise.all([this.hasAccess(i,e),this.subscriptionExpiry(e,i)])}catch(e){
|
|
794
|
+
// Access check failed, defaults are fine
|
|
795
|
+
}return{tokenId:e,owner:a,uri:s,status:r,terms:o,hasAccess:u,accessExpiry:p,appId:(null==d?void 0:d.appId)||""}}))}
|
|
366
796
|
/**
|
|
367
797
|
* Buy access to an asset by first checking its price via getTerms, then calling buyAccess.
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
|
|
798
|
+
* Automatically fetches protocol and app fees from the contracts.
|
|
799
|
+
* If the user already has access, returns null without making a transaction.
|
|
800
|
+
*
|
|
801
|
+
* @param tokenId The token ID of the asset.
|
|
802
|
+
* @returns The result of the buyAccess call, or null if user already has access.
|
|
803
|
+
*
|
|
804
|
+
* @example
|
|
805
|
+
* ```typescript
|
|
806
|
+
* const result = await origin.buyAccessSmart(1n);
|
|
807
|
+
* if (result === null) {
|
|
808
|
+
* console.log("You already have access to this asset");
|
|
809
|
+
* } else {
|
|
810
|
+
* console.log("Access purchased:", result.txHash);
|
|
811
|
+
* }
|
|
812
|
+
* ```
|
|
813
|
+
*/buyAccessSmart(e){return f(this,void 0,void 0,(function*(){let t=null;try{t=yield v(this,dt,"m",ht).call(this)}catch(t){throw new x(`Cannot buy access to token ${e}: wallet not connected. Please connect a wallet first.`)}
|
|
814
|
+
// Check if user already has access
|
|
815
|
+
if(yield this.hasAccess(t,e))return console.log("User already has access to this asset"),null;const n=yield this.getTerms(e);if(!n)throw new _(`Failed to fetch license terms for token ${e}: no terms returned`);const{price:i,paymentToken:a,duration:s}=n;if(void 0===i||void 0===a||void 0===s)throw new _(`Invalid license terms for token ${e}: missing price, paymentToken, or duration`);
|
|
816
|
+
// Fetch protocol fee from marketplace
|
|
817
|
+
const o=yield v(this,dt,"m",Tt).call(this),d=yield v(this,dt,"m",ft).call(this,e),u=i;
|
|
818
|
+
// Fetch app fee from token's appId
|
|
819
|
+
return a===r?this.buyAccess(t,e,u,s,a,o,d,u):(yield tt({walletClient:this.viemClient,publicClient:U(),tokenAddress:a,owner:t,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:u}),this.buyAccess(t,e,u,s,a,o,d))}))}
|
|
371
820
|
/**
|
|
372
821
|
* Fetch the underlying data associated with a specific token ID.
|
|
373
822
|
* @param {bigint} tokenId - The token ID to fetch data for.
|
|
374
823
|
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
375
824
|
* @throws {Error} Throws an error if the data cannot be fetched.
|
|
376
|
-
*/getData(e){return
|
|
825
|
+
*/getData(e){return f(this,void 0,void 0,(function*(){const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/origin/data/${e}`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!t.ok){const n=yield t.text().catch((()=>t.statusText));throw new _(`Failed to fetch data for token ${e} (HTTP ${t.status}): ${n}`,t.status)}return t.json()}))}
|
|
377
826
|
/**
|
|
378
827
|
* Get the Token Bound Account (TBA) address for a specific token ID.
|
|
379
828
|
* @param {bigint} tokenId - The token ID to get the TBA address for.
|
|
@@ -384,7 +833,7 @@ if(a.simulate)return u;try{const e=yield null===(r=this.viemClient)||void 0===r?
|
|
|
384
833
|
* const tbaAddress = await origin.getTokenBoundAccount(1n);
|
|
385
834
|
* console.log(`TBA Address: ${tbaAddress}`);
|
|
386
835
|
* ```
|
|
387
|
-
*/getTokenBoundAccount(e){return
|
|
836
|
+
*/getTokenBoundAccount(e){return f(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)}`)}}))}
|
|
388
837
|
/**
|
|
389
838
|
* Get royalty information for a token ID, including the token bound account address and its balance.
|
|
390
839
|
* @param {bigint} tokenId - The token ID to check royalties for.
|
|
@@ -399,9 +848,9 @@ if(a.simulate)return u;try{const e=yield null===(r=this.viemClient)||void 0===r?
|
|
|
399
848
|
* // Get ERC20 token royalties for a specific token
|
|
400
849
|
* const royalties = await origin.getRoyalties(1n, "0x1234...");
|
|
401
850
|
* ```
|
|
402
|
-
*/getRoyalties(e,t){return
|
|
851
|
+
*/getRoyalties(e,t){return f(this,void 0,void 0,(function*(){try{const n=yield this.getTokenBoundAccount(e),i=U();let a,s;if(t&&t!==r){
|
|
403
852
|
// erc20 (wrapped camp)
|
|
404
|
-
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",[]);
|
|
853
|
+
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",[]);s=c(a,i)}else a=yield i.getBalance({address:n}),s=y(a);return{tokenBoundAccount:n,balance:a,balanceFormatted:s}}catch(t){throw new Error(`Failed to retrieve royalties for token ${e}: ${t instanceof Error?t.message:String(t)}`)}}))}
|
|
405
854
|
/**
|
|
406
855
|
* Claim royalties from a token's Token Bound Account (TBA).
|
|
407
856
|
* @param {bigint} tokenId - The token ID to claim royalties from.
|
|
@@ -417,31 +866,43 @@ const e=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name
|
|
|
417
866
|
* // Claim ERC20 token royalties to a specific address
|
|
418
867
|
* await origin.claimRoyalties(1n, "0xRecipient...", "0xToken...");
|
|
419
868
|
* ```
|
|
420
|
-
*/claimRoyalties(e,t,n){return
|
|
869
|
+
*/claimRoyalties(e,t,n){return f(this,void 0,void 0,(function*(){const i=yield v(this,dt,"m",vt).call(this,t),s=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;
|
|
421
870
|
// Call execute on the TBA
|
|
422
|
-
return n&&n!==
|
|
871
|
+
return n&&n!==r?(
|
|
423
872
|
// ERC20 token transfer
|
|
424
873
|
d=n,u=BigInt(0),
|
|
425
874
|
// Encode ERC20 transfer call: transfer(address to, uint256 amount)
|
|
426
875
|
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]})):(
|
|
427
876
|
// Native token transfer
|
|
428
|
-
d=i,u=o,p="0x"),this.callContractMethod(
|
|
429
|
-
{waitForReceipt:!0,value:BigInt(0)})}))}}
|
|
877
|
+
d=i,u=o,p="0x"),this.callContractMethod(s,this.environment.TBA_ABI,"execute",[d,u,p,0],// operation: 0 = CALL
|
|
878
|
+
{waitForReceipt:!0,value:BigInt(0)})}))}}dt=new WeakSet,ut=function(e,t){return f(this,void 0,void 0,(function*(){try{const n=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/origin/upload-url`,{method:"POST",body:JSON.stringify({name:e.name,type:e.type,partCount:t}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!n.ok)throw new Error(`HTTP ${n.status}: ${n.statusText}`);const i=yield n.json();if(i.isError)throw new Error(i.message||"Failed to generate upload URL");return i.data}catch(e){throw console.error("Failed to generate upload URL:",e),e}}))},pt=function(e,t,n){return f(this,void 0,void 0,(function*(){try{const i=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/origin/update-status`,{method:"PATCH",body:JSON.stringify({fileKey:e,uploadId:t,parts:n}),headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!i.ok){const e=yield i.text().catch((()=>"Unknown error"));throw new Error(`HTTP ${i.status}: ${e}`)}return!0}catch(e){throw console.error("Failed to update origin status:",e),e}}))},lt=function(e){return f(this,void 0,void 0,(function*(){var t;if(!e)return null;try{const n=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/origin/upload-url-ipfs`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.jwt}`},body:JSON.stringify({fileName:e.name,fileType:e.type})});if(!n.ok){const e=yield n.text().catch((()=>"Unknown error"));throw new Error(`Failed to get presigned URL (HTTP ${n.status}): ${e}`)}const i=yield n.json(),{isError:a,data:s,message:r}=i;if(a||!s)throw new Error(`Failed to get presigned URL: ${r||"No URL returned from server"}`);const o=new FormData;o.append("file",e);const d=yield fetch(s,{method:"POST",body:o});if(!d.ok){const e=yield d.text().catch((()=>d.statusText));throw new Error(`Failed to upload preview image to IPFS (HTTP ${d.status}): ${e}`)}const u=yield d.json();if(!u||!u.data)throw new Error("Invalid response from IPFS upload: Missing data field");return null===(t=u.data)||void 0===t?void 0:t.cid}catch(e){const t=e instanceof Error?e.message:String(e);throw console.error("Error uploading preview image to IPFS:",t),new Error(`Failed to upload preview image to IPFS: ${t}`)}}))},yt=function(e,t){return f(this,void 0,void 0,(function*(){let n,i;try{i=((e,t)=>{const n=[];let i=0;for(;i<e.size;)n.push(e.slice(i,i+t)),i+=t;return n})(e,10485760),n=yield v(this,dt,"m",ut).call(this,e,i.length)}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");let a;try{a=yield ne(i,n.urls,(null==t?void 0:t.progressCallback)||(()=>{}))}catch(e){try{yield v(this,dt,"m",pt).call(this,n.key,n.uploadId,a||[])}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 v(this,dt,"m",pt).call(this,n.key,n.uploadId,a)}catch(e){console.error("Failed to update status to success:",e)}return n}))},ct=function(e){return f(this,arguments,void 0,(function*(e,t={}){var n,i,a;const s=U();let r=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 s.waitForTransactionReceipt({hash:r,confirmations:o,timeout:d,pollingInterval:u,onReplaced:e=>{r=e.transaction.hash}})}catch(e){
|
|
430
879
|
// fallback
|
|
431
|
-
const t=Date.now();for(;Date.now()-t<d;){try{const e=yield
|
|
880
|
+
const t=Date.now();for(;Date.now()-t<d;){try{const e=yield s.getTransactionReceipt({hash:r});if(e&&e.blockNumber)return e}catch(e){}yield new Promise((e=>setTimeout(e,u)))}throw e}}))},mt=function(e){return f(this,void 0,void 0,(function*(){if(!this.viemClient)throw new x(`Cannot switch to chain "${e.name}": wallet not connected. Please connect a wallet first.`);let t=yield this.viemClient.request({method:"eth_chainId",params:[]});if("string"==typeof t&&(t=parseInt(t,16)),t!==e.id){(e=>{O=e,B=null})// reset public client to be recreated with new chain
|
|
432
881
|
(e);try{yield this.viemClient.request({method:"wallet_switchEthereumChain",params:[{chainId:"0x"+BigInt(e.id).toString(16)}]})}catch(t){
|
|
433
882
|
// Unrecognized chain
|
|
434
|
-
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)}]})}}}))},
|
|
883
|
+
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)}]})}}}))},ht=function(){return f(this,void 0,void 0,(function*(){if(!this.viemClient)throw new x("No wallet connected. Please connect a wallet to perform this action.");
|
|
884
|
+
// If account is already set on the client, return it directly
|
|
885
|
+
if(this.viemClient.account)return this.viemClient.account.address;
|
|
886
|
+
// Otherwise request accounts (browser wallet flow)
|
|
887
|
+
const e=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!e||0===e.length)throw new x("No accounts found in connected wallet. Please unlock your wallet or add an account.");return e[0]}))},Tt=function(){return f(this,void 0,void 0,(function*(){try{const e=yield this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS,this.environment.MARKETPLACE_ABI,"protocolFeeBps",[]);return Number(e)}catch(e){return console.warn("Failed to fetch protocol fee, defaulting to 0:",e),0}}))},ft=function(e){return f(this,void 0,void 0,(function*(){try{
|
|
888
|
+
// First, get the token info to find its appId
|
|
889
|
+
const t=yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS,this.environment.IPNFT_ABI,"tokenInfo",[e]),n=null==t?void 0:t.appId;if(!n||""===n)return 0;
|
|
890
|
+
// Check if app registry is configured
|
|
891
|
+
if(!this.environment.APP_REGISTRY_CONTRACT_ADDRESS||!this.environment.APP_REGISTRY_ABI)return 0;
|
|
892
|
+
// Fetch app info from registry
|
|
893
|
+
const i=yield this.callContractMethod(this.environment.APP_REGISTRY_CONTRACT_ADDRESS,this.environment.APP_REGISTRY_ABI,"getAppInfo",[n]);
|
|
894
|
+
// Only return fee if app is active
|
|
895
|
+
return(null==i?void 0:i.isActive)?Number(i.revenueShareBps):0}catch(e){return console.warn("Failed to fetch app fee, defaulting to 0:",e),0}}))},vt=function(e){return f(this,void 0,void 0,(function*(){if(e)return e;if(!this.viemClient)throw new x("No wallet address provided and no wallet connected. Please provide an address or connect a wallet.");
|
|
435
896
|
// If account is already set on the client, return it directly
|
|
436
897
|
if(this.viemClient.account)return this.viemClient.account.address;
|
|
437
898
|
// Otherwise request accounts (browser wallet flow)
|
|
438
|
-
const
|
|
899
|
+
const t=yield this.viemClient.request({method:"eth_requestAccounts",params:[]});if(!t||0===t.length)throw new x("No accounts found in connected wallet. Please unlock your wallet or add an account.");return t[0]}))};
|
|
439
900
|
/**
|
|
440
901
|
* The Auth class.
|
|
441
902
|
* @class
|
|
442
903
|
* @classdesc The Auth class is used to authenticate the user.
|
|
443
904
|
*/
|
|
444
|
-
class
|
|
905
|
+
class Nt{
|
|
445
906
|
/**
|
|
446
907
|
* Constructor for the Auth class.
|
|
447
908
|
* @param {object} options The options object.
|
|
@@ -451,9 +912,9 @@ class Ke{
|
|
|
451
912
|
* @param {StorageAdapter} [options.storage] Custom storage adapter. Defaults to localStorage in browser, memory storage in Node.js.
|
|
452
913
|
* @throws {APIError} - Throws an error if the clientId is not provided.
|
|
453
914
|
*/
|
|
454
|
-
constructor({clientId:e,
|
|
915
|
+
constructor({clientId:e,appId:t,redirectUri:n,environment:i="DEVELOPMENT",baseParentId:a,storage:s}){if(At.add(this),wt.set(this,void 0),It.set(this,void 0),gt.set(this,void 0),bt.set(this,void 0),!e)throw new D("clientId is required");if(!t)throw new D("appId is required");if(-1===["PRODUCTION","DEVELOPMENT"].indexOf(i))throw new D(`Invalid environment "${i}". Must be "DEVELOPMENT" or "PRODUCTION"`);A(this,It,"undefined"==typeof window,"f"),A(this,bt,s||(v(this,It,"f")?new E:new C),"f"),this.viem=null,this.environment=X[i],this.environment.AUTH_HUB_BASE_API+="PRODUCTION"===i?"/auth-mainnet":"",this.baseParentId=a,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)),{})})(n),this.clientId=e,this.appId=t,this.isAuthenticated=!1,this.jwt=null,this.origin=null,this.walletAddress=null,this.userId=null,A(this,wt,{},"f"),
|
|
455
916
|
// only subscribe to providers in browser environment
|
|
456
|
-
|
|
917
|
+
v(this,It,"f")||te((e=>{v(this,At,"m",Ct).call(this,"providers",e)})),v(this,At,"m",Et).call(this)}
|
|
457
918
|
/**
|
|
458
919
|
* Subscribe to an event. Possible events are "state", "provider", "providers", and "viem".
|
|
459
920
|
* @param {("state"|"provider"|"providers"|"viem")} event The event.
|
|
@@ -463,26 +924,26 @@ f(this,Oe,"f")||J((e=>{f(this,Ue,"m",je).call(this,"providers",e)})),f(this,Ue,"
|
|
|
463
924
|
* auth.on("state", (state) => {
|
|
464
925
|
* console.log(state);
|
|
465
926
|
* });
|
|
466
|
-
*/on(e,t){
|
|
927
|
+
*/on(e,t){v(this,wt,"f")[e]||(v(this,wt,"f")[e]=[]),v(this,wt,"f")[e].push(t),"providers"===e&&t(ee())}
|
|
467
928
|
/**
|
|
468
929
|
* Unsubscribe from an event. Possible events are "state", "provider", "providers", and "viem".
|
|
469
930
|
* @param {("state"|"provider"|"providers"|"viem")} event The event.
|
|
470
931
|
* @param {function} callback The callback function.
|
|
471
932
|
* @returns {void}
|
|
472
|
-
*/off(e,t){
|
|
933
|
+
*/off(e,t){v(this,wt,"f")[e]&&(v(this,wt,"f")[e]=v(this,wt,"f")[e].filter((e=>e!==t)))}
|
|
473
934
|
/**
|
|
474
935
|
* Set the loading state.
|
|
475
936
|
* @param {boolean} loading The loading state.
|
|
476
937
|
* @returns {void}
|
|
477
|
-
*/setLoading(e){
|
|
938
|
+
*/setLoading(e){v(this,At,"m",Ct).call(this,"state",e?"loading":this.isAuthenticated?"authenticated":"unauthenticated")}
|
|
478
939
|
/**
|
|
479
940
|
* 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.
|
|
480
941
|
* @param {object} options The options object. Includes the provider and the provider info.
|
|
481
942
|
* @returns {void}
|
|
482
943
|
* @throws {APIError} - Throws an error if the provider is not provided.
|
|
483
|
-
*/setProvider({provider:t,info:i,address:a}){if(!t)throw new _("provider is required");this.viem=((t,i="window.ethereum",a,
|
|
944
|
+
*/setProvider({provider:t,info:i,address:a}){if(!t)throw new _("provider is required");this.viem=((t,i="window.ethereum",a,s)=>{var r,o;if(!t&&!F)return console.warn("Provider is required to create a client."),null;const d=a||P;if(!F||F.transport.name!==i&&t||s!==(null===(r=F.account)||void 0===r?void 0:r.address)&&t||(null==O?void 0:O.id)!==d.id){const a={chain:d,transport:n(t,{name:i})};s&&(a.account=m(s)),F=e(a),O=d,B&&(null===(o=B.chain)||void 0===o?void 0:o.id)!==d.id&&(B=null)}return F})(t,i.name,this.environment.CHAIN,a),this.origin&&this.origin.setViemClient(this.viem),
|
|
484
945
|
// TODO: only use one of these
|
|
485
|
-
|
|
946
|
+
v(this,At,"m",Ct).call(this,"viem",this.viem),v(this,At,"m",Ct).call(this,"provider",{provider:t,info:i}),v(this,bt,"f").setItem("camp-sdk:provider",JSON.stringify(i))}
|
|
486
947
|
/**
|
|
487
948
|
* 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.
|
|
488
949
|
* @param {string} walletAddress The wallet address.
|
|
@@ -491,7 +952,7 @@ f(this,Ue,"m",je).call(this,"viem",this.viem),f(this,Ue,"m",je).call(this,"provi
|
|
|
491
952
|
/**
|
|
492
953
|
* Recover the provider from local storage.
|
|
493
954
|
* @returns {Promise<void>}
|
|
494
|
-
*/recoverProvider(){return
|
|
955
|
+
*/recoverProvider(){return f(this,void 0,void 0,(function*(){var e,t,n,i,a,s,r,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 v(this,bt,"f").getItem("camp-sdk:provider");if(!c)return;const m=JSON.parse(c);let h;const T=null!==(e=ee())&&void 0!==e?e:[];
|
|
495
956
|
// first pass: try to find provider by UUID/name and check if it has the right address
|
|
496
957
|
// without prompting (using eth_accounts)
|
|
497
958
|
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){
|
|
@@ -501,19 +962,19 @@ const t=yield e.provider.request({method:"eth_accounts"});if(t.length>0&&(null==
|
|
|
501
962
|
// but still avoid prompting
|
|
502
963
|
if(!h)for(const e of T)try{
|
|
503
964
|
// skip providers we already checked in the first pass
|
|
504
|
-
if(m.uuid&&(null===(
|
|
965
|
+
if(m.uuid&&(null===(s=e.info)||void 0===s?void 0:s.uuid)===m.uuid||m.name&&(null===(r=e.info)||void 0===r?void 0:r.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)}
|
|
505
966
|
// third pass: if still no provider found and we have UUID/name info,
|
|
506
967
|
// try prompting the user (only for the stored provider)
|
|
507
968
|
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.")}))}
|
|
508
969
|
/**
|
|
509
970
|
* Disconnect the user.
|
|
510
971
|
* @returns {Promise<void>}
|
|
511
|
-
*/disconnect(){return
|
|
972
|
+
*/disconnect(){return f(this,void 0,void 0,(function*(){this.isAuthenticated&&(v(this,At,"m",Ct).call(this,"state","unauthenticated"),this.isAuthenticated=!1,this.walletAddress=null,this.userId=null,this.jwt=null,this.origin=null,A(this,gt,void 0,"f"),yield v(this,bt,"f").removeItem("camp-sdk:wallet-address"),yield v(this,bt,"f").removeItem("camp-sdk:user-id"),yield v(this,bt,"f").removeItem("camp-sdk:jwt"),yield v(this,bt,"f").removeItem("camp-sdk:environment"))}))}
|
|
512
973
|
/**
|
|
513
974
|
* Connect the user's wallet and sign the message.
|
|
514
975
|
* @returns {Promise<{ success: boolean; message: string; walletAddress: string }>} A promise that resolves with the authentication result.
|
|
515
976
|
* @throws {APIError} - Throws an error if the user cannot be authenticated.
|
|
516
|
-
*/connect(){return
|
|
977
|
+
*/connect(){return f(this,void 0,void 0,(function*(){v(this,At,"m",Ct).call(this,"state","loading");try{this.walletAddress||(yield v(this,At,"m",St).call(this)),this.walletAddress=s(this.walletAddress);const e=yield v(this,At,"m",Pt).call(this),t=v(this,At,"m",_t).call(this,e),n=yield this.viem.signMessage({account:this.walletAddress,message:t}),i=yield v(this,At,"m",Rt).call(this,t,n);if(i.success)return this.isAuthenticated=!0,this.userId=i.userId,this.jwt=i.token,this.origin=new Dt(this.environment,this.jwt,this.viem,this.baseParentId,this.appId),yield v(this,bt,"f").setItem("camp-sdk:jwt",this.jwt),yield v(this,bt,"f").setItem("camp-sdk:wallet-address",this.walletAddress),yield v(this,bt,"f").setItem("camp-sdk:user-id",this.userId),yield v(this,bt,"f").setItem("camp-sdk:environment",this.environment.NAME),v(this,At,"m",Ct).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,v(this,At,"m",Ct).call(this,"state","unauthenticated"),new _("Failed to authenticate: signature verification failed")}catch(e){if(this.isAuthenticated=!1,v(this,At,"m",Ct).call(this,"state","unauthenticated"),e instanceof _||e instanceof x)throw e;throw new _(`Failed to authenticate: ${M(e)}`)}}))}
|
|
517
978
|
/**
|
|
518
979
|
* Connect with a custom signer (for Node.js or custom wallet implementations).
|
|
519
980
|
* This method bypasses browser wallet interactions and uses the provided signer directly.
|
|
@@ -532,9 +993,9 @@ if(!h&&(m.uuid||m.name))for(const e of T)try{if(m.uuid&&(null===(u=e.info)||void
|
|
|
532
993
|
* const account = privateKeyToAccount('0x...');
|
|
533
994
|
* const client = createWalletClient({ account, chain: mainnet, transport: http() });
|
|
534
995
|
* await auth.connectWithSigner(client);
|
|
535
|
-
*/connectWithSigner(e,t){return
|
|
996
|
+
*/connectWithSigner(e,t){return f(this,void 0,void 0,(function*(){v(this,At,"m",Ct).call(this,"state","loading");try{A(this,gt,b(e),"f"),this.walletAddress=s(yield v(this,gt,"f").getAddress()),
|
|
536
997
|
// store the signer as viem client if it's a viem client, otherwise keep adapter
|
|
537
|
-
"viem"===
|
|
998
|
+
"viem"===v(this,gt,"f").type&&(this.viem=e);const n=yield v(this,At,"m",Pt).call(this),i=v(this,At,"m",_t).call(this,n,null==t?void 0:t.domain,null==t?void 0:t.uri),a=yield v(this,gt,"f").signMessage(i),r=yield v(this,At,"m",Rt).call(this,i,a);if(r.success)return this.isAuthenticated=!0,this.userId=r.userId,this.jwt=r.token,this.origin=new Dt(this.environment,this.jwt,this.viem,this.baseParentId,this.appId),yield v(this,bt,"f").setItem("camp-sdk:jwt",this.jwt),yield v(this,bt,"f").setItem("camp-sdk:wallet-address",this.walletAddress),yield v(this,bt,"f").setItem("camp-sdk:user-id",this.userId),yield v(this,bt,"f").setItem("camp-sdk:environment",this.environment.NAME),v(this,At,"m",Ct).call(this,"state","authenticated"),{success:!0,message:"Successfully authenticated",walletAddress:this.walletAddress};throw this.isAuthenticated=!1,v(this,At,"m",Ct).call(this,"state","unauthenticated"),new _("Failed to authenticate: signature verification failed")}catch(e){if(this.isAuthenticated=!1,A(this,gt,void 0,"f"),v(this,At,"m",Ct).call(this,"state","unauthenticated"),e instanceof _||e instanceof x)throw e;throw new _(`Failed to authenticate: ${M(e)}`)}}))}
|
|
538
999
|
/**
|
|
539
1000
|
* Get the user's linked social accounts.
|
|
540
1001
|
* @returns {Promise<Record<string, boolean>>} A promise that resolves with the user's linked social accounts.
|
|
@@ -543,34 +1004,34 @@ if(!h&&(m.uuid||m.name))for(const e of T)try{if(m.uuid&&(null===(u=e.info)||void
|
|
|
543
1004
|
* const auth = new Auth({ clientId: "your-client-id" });
|
|
544
1005
|
* const socials = await auth.getLinkedSocials();
|
|
545
1006
|
* console.log(socials);
|
|
546
|
-
*/getLinkedSocials(){return
|
|
1007
|
+
*/getLinkedSocials(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to get linked social accounts");const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 _(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}}))}
|
|
547
1008
|
/**
|
|
548
1009
|
* Link the user's Twitter account.
|
|
549
1010
|
* @returns {Promise<void>}
|
|
550
1011
|
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
551
|
-
*/linkTwitter(){return
|
|
1012
|
+
*/linkTwitter(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to link Twitter account");if(v(this,It,"f"))throw new _("Cannot link Twitter: OAuth flow requires a browser environment");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/twitter/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.twitter}`}))}
|
|
552
1013
|
/**
|
|
553
1014
|
* Link the user's Discord account.
|
|
554
1015
|
* @returns {Promise<void>}
|
|
555
1016
|
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
556
|
-
*/linkDiscord(){return
|
|
1017
|
+
*/linkDiscord(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to link Discord account");if(v(this,It,"f"))throw new _("Cannot link Discord: OAuth flow requires a browser environment");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/discord/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.discord}`}))}
|
|
557
1018
|
/**
|
|
558
1019
|
* Link the user's Spotify account.
|
|
559
1020
|
* @returns {Promise<void>}
|
|
560
1021
|
* @throws {Error} - Throws an error if the user is not authenticated or in Node.js environment.
|
|
561
|
-
*/linkSpotify(){return
|
|
1022
|
+
*/linkSpotify(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to link Spotify account");if(v(this,It,"f"))throw new _("Cannot link Spotify: OAuth flow requires a browser environment");window.location.href=`${this.environment.AUTH_HUB_BASE_API}/spotify/connect?clientId=${this.clientId}&userId=${this.userId}&redirect_url=${this.redirectUri.spotify}`}))}
|
|
562
1023
|
/**
|
|
563
1024
|
* Link the user's TikTok account.
|
|
564
1025
|
* @param {string} handle The user's TikTok handle.
|
|
565
1026
|
* @returns {Promise<any>} A promise that resolves with the TikTok account data.
|
|
566
1027
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated.
|
|
567
|
-
*/linkTikTok(e){return
|
|
1028
|
+
*/linkTikTok(e){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to link TikTok account");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 _("TikTok service is currently unavailable, try again later"):new _(t.message||"Failed to link TikTok account");return t.data}))}
|
|
568
1029
|
/**
|
|
569
1030
|
* Send an OTP to the user's Telegram account.
|
|
570
1031
|
* @param {string} phoneNumber The user's phone number.
|
|
571
1032
|
* @returns {Promise<any>} A promise that resolves with the OTP data.
|
|
572
1033
|
* @throws {Error|APIError} - Throws an error if the user is not authenticated.
|
|
573
|
-
*/sendTelegramOTP(e){return
|
|
1034
|
+
*/sendTelegramOTP(e){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to send Telegram OTP");if(!e)throw new D("Phone number is required to send Telegram OTP");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 _(t.message||"Failed to send Telegram OTP");return t.data}))}
|
|
574
1035
|
/**
|
|
575
1036
|
* Link the user's Telegram account.
|
|
576
1037
|
* @param {string} phoneNumber The user's phone number.
|
|
@@ -578,34 +1039,34 @@ if(!h&&(m.uuid||m.name))for(const e of T)try{if(m.uuid&&(null===(u=e.info)||void
|
|
|
578
1039
|
* @param {string} phoneCodeHash The phone code hash.
|
|
579
1040
|
* @returns {Promise<object>} A promise that resolves with the Telegram account data.
|
|
580
1041
|
* @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.
|
|
581
|
-
*/linkTelegram(e,t,n){return
|
|
1042
|
+
*/linkTelegram(e,t,n){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to link Telegram account");if(!e||!t||!n)throw new D("Phone number, OTP, and phone code hash are all required to link Telegram");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 _(i.message||"Failed to link Telegram account");return i.data}))}
|
|
582
1043
|
/**
|
|
583
1044
|
* Unlink the user's Twitter account.
|
|
584
1045
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
585
1046
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
586
1047
|
* @throws {APIError} - Throws an error if the request fails.
|
|
587
|
-
*/unlinkTwitter(){return
|
|
1048
|
+
*/unlinkTwitter(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to unlink Twitter account");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 _(e.message||"Failed to unlink Twitter account");return e.data}))}
|
|
588
1049
|
/**
|
|
589
1050
|
* Unlink the user's Discord account.
|
|
590
1051
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
591
1052
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
592
1053
|
* @throws {APIError} - Throws an error if the request fails.
|
|
593
|
-
*/unlinkDiscord(){return
|
|
1054
|
+
*/unlinkDiscord(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to unlink Discord account");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 _(e.message||"Failed to unlink Discord account");return e.data}))}
|
|
594
1055
|
/**
|
|
595
1056
|
* Unlink the user's Spotify account.
|
|
596
1057
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
597
1058
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
598
1059
|
* @throws {APIError} - Throws an error if the request fails.
|
|
599
|
-
*/unlinkSpotify(){return
|
|
1060
|
+
*/unlinkSpotify(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to unlink Spotify account");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 _(e.message||"Failed to unlink Spotify account");return e.data}))}
|
|
600
1061
|
/**
|
|
601
1062
|
* Unlink the user's TikTok account.
|
|
602
1063
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
603
1064
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
604
1065
|
* @throws {APIError} - Throws an error if the request fails.
|
|
605
|
-
*/unlinkTikTok(){return
|
|
1066
|
+
*/unlinkTikTok(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to unlink TikTok account");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 _(e.message||"Failed to unlink TikTok account");return e.data}))}
|
|
606
1067
|
/**
|
|
607
1068
|
* Unlink the user's Telegram account.
|
|
608
1069
|
* @returns {Promise<any>} A promise that resolves with the unlink result.
|
|
609
1070
|
* @throws {Error} - Throws an error if the user is not authenticated.
|
|
610
1071
|
* @throws {APIError} - Throws an error if the request fails.
|
|
611
|
-
*/unlinkTelegram(){return
|
|
1072
|
+
*/unlinkTelegram(){return f(this,void 0,void 0,(function*(){if(!this.isAuthenticated)throw new N("User must be authenticated to unlink Telegram account");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 _(e.message||"Failed to unlink Telegram account");return e.data}))}}wt=new WeakMap,It=new WeakMap,gt=new WeakMap,bt=new WeakMap,At=new WeakSet,Ct=function(e,t){v(this,wt,"f")[e]&&v(this,wt,"f")[e].forEach((e=>e(t)))},Et=function(e){return f(this,void 0,void 0,(function*(){const t=yield v(this,bt,"f").getItem("camp-sdk:wallet-address"),n=yield v(this,bt,"f").getItem("camp-sdk:user-id"),i=yield v(this,bt,"f").getItem("camp-sdk:jwt"),a=yield v(this,bt,"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 Dt(this.environment,this.jwt,this.viem,this.baseParentId,this.appId),this.isAuthenticated=!0,e?this.setProvider({provider:e.provider,info:e.info||{name:"Unknown"},address:t}):v(this,It,"f")||(console.warn("No matching provider was given for the stored wallet address. Trying to recover provider."),yield this.recoverProvider())):this.isAuthenticated=!1}))},St=function(){return f(this,void 0,void 0,(function*(){try{const[e]=yield this.viem.requestAddresses();return this.walletAddress=s(e),this.walletAddress}catch(e){throw new x(`Failed to connect wallet: ${M(e)}`)}}))},Pt=function(){return f(this,void 0,void 0,(function*(){try{const e=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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();if(200!==e.status)throw new _(t.message||`Failed to fetch nonce (HTTP ${e.status})`,e.status);return t.data}catch(e){if(e instanceof _)throw e;throw new _(`Failed to fetch nonce: ${M(e)}`)}}))},Rt=function(e,t){return f(this,void 0,void 0,(function*(){try{const n=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/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 _(`Failed to verify signature: ${M(e)}`)}}))},_t=function(e,t,n){return h({domain:t||(v(this,It,"f")?"localhost":window.location.host),address:this.walletAddress,statement:J,uri:n||(v(this,It,"f")?"http://localhost":window.location.origin),version:"1",chainId:this.environment.CHAIN.id,nonce:e})};export{Nt as Auth,C as BrowserStorage,g as CustomSignerAdapter,Se as DataStatus,Pe as DisputeStatus,I as EthersSignerAdapter,Ee as LicenseType,E as MemoryStorage,Dt as Origin,w as ViemSignerAdapter,R as campMainnet,P as campTestnet,Re as createLicenseTerms,S as createNodeWalletClient,b as createSignerAdapter};
|