@campnetwork/origin 1.4.0-alpha.0 → 1.4.0-alpha.2
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 +91 -84
- package/dist/core.d.ts +10 -6
- package/dist/core.esm.d.ts +10 -6
- package/dist/core.esm.js +112 -105
- package/dist/react/index.esm.d.ts +10 -6
- package/dist/react/index.esm.js +38 -11
- package/package.json +1 -1
|
@@ -566,18 +566,20 @@ declare function getVaultRevenueTokens(this: Origin, tokenId: bigint): Promise<A
|
|
|
566
566
|
|
|
567
567
|
/**
|
|
568
568
|
* Returns the amount of revenue claimable by a holder for a given token and revenue token.
|
|
569
|
-
* If no holder is provided, the
|
|
569
|
+
* If no holder is provided, the NFT's Token Bound Account (TBA) is used,
|
|
570
|
+
* since RT tokens are held in the TBA by default.
|
|
570
571
|
*
|
|
571
572
|
* @param tokenId The token ID whose vault to query.
|
|
572
573
|
* @param revenueToken The ERC20 revenue token address.
|
|
573
|
-
* @param holder Optional holder address. Defaults to
|
|
574
|
+
* @param holder Optional holder address. Defaults to the NFT's TBA.
|
|
574
575
|
* @returns The claimable amount in the revenue token's smallest unit.
|
|
575
576
|
*/
|
|
576
577
|
declare function claimableRevenue(this: Origin, tokenId: bigint, revenueToken: Address, holder?: Address): Promise<bigint>;
|
|
577
578
|
|
|
578
579
|
/**
|
|
579
580
|
* Claims accumulated revenue for a token from a specific revenue token.
|
|
580
|
-
*
|
|
581
|
+
* Executes the claim through the NFT's Token Bound Account (TBA),
|
|
582
|
+
* since the TBA holds the Royalty Tokens.
|
|
581
583
|
*
|
|
582
584
|
* @param tokenId The token ID whose vault to claim from.
|
|
583
585
|
* @param revenueToken The ERC20 revenue token address to claim.
|
|
@@ -587,7 +589,8 @@ declare function claimRevenue(this: Origin, tokenId: bigint, revenueToken: Addre
|
|
|
587
589
|
|
|
588
590
|
/**
|
|
589
591
|
* Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
|
|
590
|
-
*
|
|
592
|
+
* Executes the claim through the NFT's Token Bound Account (TBA),
|
|
593
|
+
* since the TBA holds the Royalty Tokens.
|
|
591
594
|
*
|
|
592
595
|
* @param tokenId The token ID whose vault to claim from.
|
|
593
596
|
* @param revenueTokens Array of ERC20 revenue token addresses to claim.
|
|
@@ -613,10 +616,11 @@ interface RoyaltyTokenBalance {
|
|
|
613
616
|
}
|
|
614
617
|
/**
|
|
615
618
|
* Gets the Royalty Token balance for a holder in a token's vault.
|
|
616
|
-
* If no holder is provided, the
|
|
619
|
+
* If no holder is provided, the NFT's Token Bound Account (TBA) is used,
|
|
620
|
+
* since RT tokens are minted to the TBA by default.
|
|
617
621
|
*
|
|
618
622
|
* @param tokenId The token ID whose vault to query.
|
|
619
|
-
* @param holder Optional holder address. Defaults to
|
|
623
|
+
* @param holder Optional holder address. Defaults to the NFT's TBA.
|
|
620
624
|
* @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
|
|
621
625
|
*/
|
|
622
626
|
declare function getRoyaltyTokenBalance(this: Origin, tokenId: bigint, holder?: Address): Promise<RoyaltyTokenBalance>;
|
package/dist/react/index.esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
import React, { createContext, useState, useContext, useEffect, useLayoutEffect, useRef, useSyncExternalStore } from 'react';
|
|
3
|
-
import { custom, createWalletClient, createPublicClient, http, zeroAddress, erc20Abi as erc20Abi$1, getAbiItem, formatEther, formatUnits,
|
|
3
|
+
import { custom, createWalletClient, createPublicClient, http, zeroAddress, erc20Abi as erc20Abi$1, encodeFunctionData, getAbiItem, formatEther, formatUnits, checksumAddress, parseEther } from 'viem';
|
|
4
4
|
import { toAccount } from 'viem/accounts';
|
|
5
5
|
import { createSiweMessage } from 'viem/siwe';
|
|
6
6
|
import axios from 'axios';
|
|
@@ -8032,16 +8032,17 @@ function getVaultRevenueTokens(tokenId) {
|
|
|
8032
8032
|
|
|
8033
8033
|
/**
|
|
8034
8034
|
* Returns the amount of revenue claimable by a holder for a given token and revenue token.
|
|
8035
|
-
* If no holder is provided, the
|
|
8035
|
+
* If no holder is provided, the NFT's Token Bound Account (TBA) is used,
|
|
8036
|
+
* since RT tokens are held in the TBA by default.
|
|
8036
8037
|
*
|
|
8037
8038
|
* @param tokenId The token ID whose vault to query.
|
|
8038
8039
|
* @param revenueToken The ERC20 revenue token address.
|
|
8039
|
-
* @param holder Optional holder address. Defaults to
|
|
8040
|
+
* @param holder Optional holder address. Defaults to the NFT's TBA.
|
|
8040
8041
|
* @returns The claimable amount in the revenue token's smallest unit.
|
|
8041
8042
|
*/
|
|
8042
8043
|
function claimableRevenue(tokenId, revenueToken, holder) {
|
|
8043
8044
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8044
|
-
const holderAddress = yield
|
|
8045
|
+
const holderAddress = holder || (yield this.getTokenBoundAccount(tokenId));
|
|
8045
8046
|
const amount = yield this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS, this.environment.MARKETPLACE_ABI, "claimableRevenue", [tokenId, holderAddress, revenueToken]);
|
|
8046
8047
|
return amount;
|
|
8047
8048
|
});
|
|
@@ -8049,7 +8050,8 @@ function claimableRevenue(tokenId, revenueToken, holder) {
|
|
|
8049
8050
|
|
|
8050
8051
|
/**
|
|
8051
8052
|
* Claims accumulated revenue for a token from a specific revenue token.
|
|
8052
|
-
*
|
|
8053
|
+
* Executes the claim through the NFT's Token Bound Account (TBA),
|
|
8054
|
+
* since the TBA holds the Royalty Tokens.
|
|
8053
8055
|
*
|
|
8054
8056
|
* @param tokenId The token ID whose vault to claim from.
|
|
8055
8057
|
* @param revenueToken The ERC20 revenue token address to claim.
|
|
@@ -8057,13 +8059,25 @@ function claimableRevenue(tokenId, revenueToken, holder) {
|
|
|
8057
8059
|
*/
|
|
8058
8060
|
function claimRevenue(tokenId, revenueToken) {
|
|
8059
8061
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8060
|
-
|
|
8062
|
+
const tokenBoundAccount = yield this.getTokenBoundAccount(tokenId);
|
|
8063
|
+
const data = encodeFunctionData({
|
|
8064
|
+
abi: this.environment.MARKETPLACE_ABI,
|
|
8065
|
+
functionName: "claimRevenue",
|
|
8066
|
+
args: [tokenId, revenueToken],
|
|
8067
|
+
});
|
|
8068
|
+
return this.callContractMethod(tokenBoundAccount, this.environment.TBA_ABI, "execute", [
|
|
8069
|
+
this.environment.MARKETPLACE_CONTRACT_ADDRESS,
|
|
8070
|
+
BigInt(0),
|
|
8071
|
+
data,
|
|
8072
|
+
0,
|
|
8073
|
+
], { waitForReceipt: true, value: BigInt(0) });
|
|
8061
8074
|
});
|
|
8062
8075
|
}
|
|
8063
8076
|
|
|
8064
8077
|
/**
|
|
8065
8078
|
* Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
|
|
8066
|
-
*
|
|
8079
|
+
* Executes the claim through the NFT's Token Bound Account (TBA),
|
|
8080
|
+
* since the TBA holds the Royalty Tokens.
|
|
8067
8081
|
*
|
|
8068
8082
|
* @param tokenId The token ID whose vault to claim from.
|
|
8069
8083
|
* @param revenueTokens Array of ERC20 revenue token addresses to claim.
|
|
@@ -8071,7 +8085,18 @@ function claimRevenue(tokenId, revenueToken) {
|
|
|
8071
8085
|
*/
|
|
8072
8086
|
function claimRevenueBatch(tokenId, revenueTokens) {
|
|
8073
8087
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8074
|
-
|
|
8088
|
+
const tokenBoundAccount = yield this.getTokenBoundAccount(tokenId);
|
|
8089
|
+
const data = encodeFunctionData({
|
|
8090
|
+
abi: this.environment.MARKETPLACE_ABI,
|
|
8091
|
+
functionName: "claimRevenueBatch",
|
|
8092
|
+
args: [tokenId, revenueTokens],
|
|
8093
|
+
});
|
|
8094
|
+
return this.callContractMethod(tokenBoundAccount, this.environment.TBA_ABI, "execute", [
|
|
8095
|
+
this.environment.MARKETPLACE_CONTRACT_ADDRESS,
|
|
8096
|
+
BigInt(0),
|
|
8097
|
+
data,
|
|
8098
|
+
0,
|
|
8099
|
+
], { waitForReceipt: true, value: BigInt(0) });
|
|
8075
8100
|
});
|
|
8076
8101
|
}
|
|
8077
8102
|
|
|
@@ -8113,15 +8138,17 @@ const erc20Abi = [
|
|
|
8113
8138
|
];
|
|
8114
8139
|
/**
|
|
8115
8140
|
* Gets the Royalty Token balance for a holder in a token's vault.
|
|
8116
|
-
* If no holder is provided, the
|
|
8141
|
+
* If no holder is provided, the NFT's Token Bound Account (TBA) is used,
|
|
8142
|
+
* since RT tokens are minted to the TBA by default.
|
|
8117
8143
|
*
|
|
8118
8144
|
* @param tokenId The token ID whose vault to query.
|
|
8119
|
-
* @param holder Optional holder address. Defaults to
|
|
8145
|
+
* @param holder Optional holder address. Defaults to the NFT's TBA.
|
|
8120
8146
|
* @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
|
|
8121
8147
|
*/
|
|
8122
8148
|
function getRoyaltyTokenBalance(tokenId, holder) {
|
|
8123
8149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8124
|
-
|
|
8150
|
+
// Default to the NFT's TBA, since RT tokens are minted there
|
|
8151
|
+
const holderAddress = holder || (yield this.getTokenBoundAccount(tokenId));
|
|
8125
8152
|
// Get vault address
|
|
8126
8153
|
const vaultAddress = yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS, this.environment.IPNFT_ABI, "getRoyaltyVault", [tokenId]);
|
|
8127
8154
|
if (!vaultAddress || vaultAddress === zeroAddress) {
|