@campnetwork/origin 1.0.0-alpha.11 → 1.0.0-alpha.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core.cjs +3 -2
- package/dist/core.d.ts +1 -0
- package/dist/core.esm.d.ts +1 -0
- package/dist/core.esm.js +3 -2
- package/dist/react/index.esm.d.ts +1 -0
- package/dist/react/index.esm.js +5 -4
- package/package.json +1 -1
package/dist/core.cjs
CHANGED
|
@@ -74,7 +74,7 @@ let y=null,c=null,h=null;const m=e=>{var n;const i=h||l;return c&&(null===(n=c.c
|
|
|
74
74
|
* @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
|
|
75
75
|
* @param simulateOnly If true, simulates the transaction without executing it.
|
|
76
76
|
* @returns The address of the royalty vault associated with the specified token owner.
|
|
77
|
-
*/function D(e){return a(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
|
|
77
|
+
*/function D(e){return a(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}))}
|
|
78
78
|
/**
|
|
79
79
|
* Returns the license terms associated with a specific token ID.
|
|
80
80
|
* @param tokenId The token ID to query.
|
|
@@ -166,6 +166,7 @@ if(s.simulate)return p;try{const e=yield this.viemClient.writeContract(l);if("st
|
|
|
166
166
|
*/buyAccessSmart(e){return a(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const n=yield this.getTerms(e);if(!n)throw new Error("Failed to fetch terms for asset");const{price:i,paymentToken:r,duration:s}=n;if(void 0===i||void 0===r||void 0===s)throw new Error("Terms missing price, paymentToken, or duration");const o=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],d=i;return r===t.zeroAddress?this.buyAccess(o,e,d,s,r,d):(yield function(e){return a(this,arguments,void 0,(function*({walletClient:e,publicClient:n,tokenAddress:i,owner:a,spender:r,amount:s}){(yield n.readContract({address:i,abi:t.erc20Abi,functionName:"allowance",args:[a,r]}))<s&&(yield e.writeContract({address:i,account:a,abi:t.erc20Abi,functionName:"approve",args:[r,s],chain:l}))}))}({walletClient:this.viemClient,publicClient:m(),tokenAddress:r,owner:o,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:d}),this.buyAccess(o,e,d,s,r))}))}getData(e){return a(this,void 0,void 0,(function*(){const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/data/${e}`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch data");return t.json()}))}
|
|
167
167
|
/**
|
|
168
168
|
* Get royalty information for a wallet address, including the royalty vault address and its balance.
|
|
169
|
+
* @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
|
|
169
170
|
* @param {Address} [owner] - Optional wallet address to check royalties for. If not provided, uses the connected wallet.
|
|
170
171
|
* @returns {Promise<RoyaltyInfo>} A promise that resolves with the royalty vault address and balance information.
|
|
171
172
|
* @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
|
|
@@ -177,7 +178,7 @@ if(s.simulate)return p;try{const e=yield this.viemClient.writeContract(l);if("st
|
|
|
177
178
|
* // Get royalties for specific address
|
|
178
179
|
* const royalties = await origin.getRoyalties("0x1234...");
|
|
179
180
|
* ```
|
|
180
|
-
*/getRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,q,"m",V).call(this,n);try{const n=yield this.getOrCreateRoyaltyVault(i)
|
|
181
|
+
*/getRoyalties(e,n){return a(this,void 0,void 0,(function*(){const i=yield r(this,q,"m",V).call(this,n);try{const n=yield this.getOrCreateRoyaltyVault(i,!0),a=m();let r,s;if(e&&e!==t.zeroAddress){
|
|
181
182
|
// erc20 (wrapped camp)
|
|
182
183
|
const i=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],stateMutability:"view",type:"function"}];r=yield this.callContractMethod(e,i,"balanceOf",[n]);const a=yield this.callContractMethod(e,i,"decimals",[]);s=t.formatUnits(r,a)}else r=yield a.getBalance({address:n}),s=t.formatEther(r);return{royaltyVault:n,balance:r,balanceFormatted:s}}catch(e){throw new Error(`Failed to retrieve royalties for address ${i}: ${e instanceof Error?e.message:String(e)}`)}}))}
|
|
183
184
|
/**
|
package/dist/core.d.ts
CHANGED
|
@@ -447,6 +447,7 @@ declare class Origin {
|
|
|
447
447
|
getData(tokenId: bigint): Promise<any>;
|
|
448
448
|
/**
|
|
449
449
|
* Get royalty information for a wallet address, including the royalty vault address and its balance.
|
|
450
|
+
* @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
|
|
450
451
|
* @param {Address} [owner] - Optional wallet address to check royalties for. If not provided, uses the connected wallet.
|
|
451
452
|
* @returns {Promise<RoyaltyInfo>} A promise that resolves with the royalty vault address and balance information.
|
|
452
453
|
* @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
|
package/dist/core.esm.d.ts
CHANGED
|
@@ -447,6 +447,7 @@ declare class Origin {
|
|
|
447
447
|
getData(tokenId: bigint): Promise<any>;
|
|
448
448
|
/**
|
|
449
449
|
* Get royalty information for a wallet address, including the royalty vault address and its balance.
|
|
450
|
+
* @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
|
|
450
451
|
* @param {Address} [owner] - Optional wallet address to check royalties for. If not provided, uses the connected wallet.
|
|
451
452
|
* @returns {Promise<RoyaltyInfo>} A promise that resolves with the royalty vault address and balance information.
|
|
452
453
|
* @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
|
package/dist/core.esm.js
CHANGED
|
@@ -237,7 +237,7 @@ let g=null,E=null,_=null;const C=e=>{var t;const n=_||b;return E&&(null===(t=E.c
|
|
|
237
237
|
* @param tokenOwner The address of the token owner for whom to get or create the royalty vault.
|
|
238
238
|
* @param simulateOnly If true, simulates the transaction without executing it.
|
|
239
239
|
* @returns The address of the royalty vault associated with the specified token owner.
|
|
240
|
-
*/function H(e){return c(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
|
|
240
|
+
*/function H(e){return c(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}))}
|
|
241
241
|
/**
|
|
242
242
|
* Returns the license terms associated with a specific token ID.
|
|
243
243
|
* @param tokenId The token ID to query.
|
|
@@ -329,6 +329,7 @@ if(a.simulate)return u;try{const e=yield this.viemClient.writeContract(p);if("st
|
|
|
329
329
|
*/buyAccessSmart(e){return c(this,void 0,void 0,(function*(){if(!this.viemClient)throw new Error("WalletClient not connected.");const t=yield this.getTerms(e);if(!t)throw new Error("Failed to fetch terms for asset");const{price:n,paymentToken:i,duration:a}=t;if(void 0===n||void 0===i||void 0===a)throw new Error("Terms missing price, paymentToken, or duration");const s=(yield this.viemClient.request({method:"eth_requestAccounts",params:[]}))[0],d=n;return i===o?this.buyAccess(s,e,d,a,i,d):(yield function(e){return c(this,arguments,void 0,(function*({walletClient:e,publicClient:t,tokenAddress:n,owner:i,spender:a,amount:s}){(yield t.readContract({address:n,abi:r,functionName:"allowance",args:[i,a]}))<s&&(yield e.writeContract({address:n,account:i,abi:r,functionName:"approve",args:[a,s],chain:b}))}))}({walletClient:this.viemClient,publicClient:C(),tokenAddress:i,owner:s,spender:this.environment.MARKETPLACE_CONTRACT_ADDRESS,amount:d}),this.buyAccess(s,e,d,a,i))}))}getData(e){return c(this,void 0,void 0,(function*(){const t=yield fetch(`${this.environment.AUTH_HUB_BASE_API}/${this.environment.AUTH_ENDPOINT}/origin/data/${e}`,{method:"GET",headers:{Authorization:`Bearer ${this.jwt}`,"Content-Type":"application/json"}});if(!t.ok)throw new Error("Failed to fetch data");return t.json()}))}
|
|
330
330
|
/**
|
|
331
331
|
* Get royalty information for a wallet address, including the royalty vault address and its balance.
|
|
332
|
+
* @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
|
|
332
333
|
* @param {Address} [owner] - Optional wallet address to check royalties for. If not provided, uses the connected wallet.
|
|
333
334
|
* @returns {Promise<RoyaltyInfo>} A promise that resolves with the royalty vault address and balance information.
|
|
334
335
|
* @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
|
|
@@ -340,7 +341,7 @@ if(a.simulate)return u;try{const e=yield this.viemClient.writeContract(p);if("st
|
|
|
340
341
|
* // Get royalties for specific address
|
|
341
342
|
* const royalties = await origin.getRoyalties("0x1234...");
|
|
342
343
|
* ```
|
|
343
|
-
*/getRoyalties(e,t){return c(this,void 0,void 0,(function*(){const n=yield h(this,ee,"m",re).call(this,t);try{const t=yield this.getOrCreateRoyaltyVault(n)
|
|
344
|
+
*/getRoyalties(e,t){return c(this,void 0,void 0,(function*(){const n=yield h(this,ee,"m",re).call(this,t);try{const t=yield this.getOrCreateRoyaltyVault(n,!0),i=C();let a,r;if(e&&e!==o){
|
|
344
345
|
// erc20 (wrapped camp)
|
|
345
346
|
const n=[{inputs:[{name:"owner",type:"address"}],name:"balanceOf",outputs:[{name:"",type:"uint256"}],stateMutability:"view",type:"function"},{inputs:[],name:"decimals",outputs:[{name:"",type:"uint8"}],stateMutability:"view",type:"function"}];a=yield this.callContractMethod(e,n,"balanceOf",[t]);const i=yield this.callContractMethod(e,n,"decimals",[]);r=u(a,i)}else a=yield i.getBalance({address:t}),r=d(a);return{royaltyVault:t,balance:a,balanceFormatted:r}}catch(e){throw new Error(`Failed to retrieve royalties for address ${n}: ${e instanceof Error?e.message:String(e)}`)}}))}
|
|
346
347
|
/**
|
|
@@ -253,6 +253,7 @@ declare class Origin {
|
|
|
253
253
|
getData(tokenId: bigint): Promise<any>;
|
|
254
254
|
/**
|
|
255
255
|
* Get royalty information for a wallet address, including the royalty vault address and its balance.
|
|
256
|
+
* @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
|
|
256
257
|
* @param {Address} [owner] - Optional wallet address to check royalties for. If not provided, uses the connected wallet.
|
|
257
258
|
* @returns {Promise<RoyaltyInfo>} A promise that resolves with the royalty vault address and balance information.
|
|
258
259
|
* @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
|
package/dist/react/index.esm.js
CHANGED
|
@@ -2742,8 +2742,9 @@ function finalizeDelete(tokenId) {
|
|
|
2742
2742
|
function getOrCreateRoyaltyVault(tokenOwner_1) {
|
|
2743
2743
|
return __awaiter(this, arguments, void 0, function* (tokenOwner, simulateOnly = false) {
|
|
2744
2744
|
const royaltyVaultTx = yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS, this.environment.IPNFT_ABI, "getOrCreateRoyaltyVault", [tokenOwner], { waitForReceipt: true, simulate: simulateOnly });
|
|
2745
|
-
|
|
2746
|
-
|
|
2745
|
+
return simulateOnly
|
|
2746
|
+
? royaltyVaultTx
|
|
2747
|
+
: royaltyVaultTx.simulatedResult;
|
|
2747
2748
|
});
|
|
2748
2749
|
}
|
|
2749
2750
|
|
|
@@ -3204,6 +3205,7 @@ class Origin {
|
|
|
3204
3205
|
}
|
|
3205
3206
|
/**
|
|
3206
3207
|
* Get royalty information for a wallet address, including the royalty vault address and its balance.
|
|
3208
|
+
* @param {Address} [token] - Optional token address to check royalties for. If not provided, checks for native token.
|
|
3207
3209
|
* @param {Address} [owner] - Optional wallet address to check royalties for. If not provided, uses the connected wallet.
|
|
3208
3210
|
* @returns {Promise<RoyaltyInfo>} A promise that resolves with the royalty vault address and balance information.
|
|
3209
3211
|
* @throws {Error} Throws an error if no wallet is connected and no owner address is provided.
|
|
@@ -3220,8 +3222,7 @@ class Origin {
|
|
|
3220
3222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
3221
3223
|
const walletAddress = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_resolveWalletAddress).call(this, owner);
|
|
3222
3224
|
try {
|
|
3223
|
-
const royaltyVaultAddress = yield this.getOrCreateRoyaltyVault(walletAddress);
|
|
3224
|
-
console.log("Royalty Vault Address:", royaltyVaultAddress);
|
|
3225
|
+
const royaltyVaultAddress = yield this.getOrCreateRoyaltyVault(walletAddress, true);
|
|
3225
3226
|
const publicClient = getPublicClient();
|
|
3226
3227
|
let balance;
|
|
3227
3228
|
let balanceFormatted;
|