@campnetwork/origin 1.4.0-alpha.2 → 1.4.0-alpha.4
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 +34 -29
- package/dist/core.d.ts +16 -10
- package/dist/core.esm.d.ts +16 -10
- package/dist/core.esm.js +82 -77
- package/dist/react/index.esm.d.ts +16 -10
- package/dist/react/index.esm.js +30 -42
- package/package.json +1 -1
|
@@ -566,20 +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
|
|
570
|
-
* since RT tokens are
|
|
569
|
+
* If no holder is provided, the connected wallet address is used,
|
|
570
|
+
* since RT tokens are sent directly to the wallet.
|
|
571
571
|
*
|
|
572
572
|
* @param tokenId The token ID whose vault to query.
|
|
573
573
|
* @param revenueToken The ERC20 revenue token address.
|
|
574
|
-
* @param holder Optional holder address. Defaults to the
|
|
574
|
+
* @param holder Optional holder address. Defaults to the connected wallet.
|
|
575
575
|
* @returns The claimable amount in the revenue token's smallest unit.
|
|
576
576
|
*/
|
|
577
577
|
declare function claimableRevenue(this: Origin, tokenId: bigint, revenueToken: Address, holder?: Address): Promise<bigint>;
|
|
578
578
|
|
|
579
579
|
/**
|
|
580
580
|
* Claims accumulated revenue for a token from a specific revenue token.
|
|
581
|
-
*
|
|
582
|
-
*
|
|
581
|
+
* The connected wallet must hold Royalty Tokens for the given token.
|
|
582
|
+
* Revenue is sent directly to the connected wallet.
|
|
583
583
|
*
|
|
584
584
|
* @param tokenId The token ID whose vault to claim from.
|
|
585
585
|
* @param revenueToken The ERC20 revenue token address to claim.
|
|
@@ -589,8 +589,8 @@ declare function claimRevenue(this: Origin, tokenId: bigint, revenueToken: Addre
|
|
|
589
589
|
|
|
590
590
|
/**
|
|
591
591
|
* Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
|
|
592
|
-
*
|
|
593
|
-
*
|
|
592
|
+
* The connected wallet must hold Royalty Tokens for the given token.
|
|
593
|
+
* Revenue is sent directly to the connected wallet.
|
|
594
594
|
*
|
|
595
595
|
* @param tokenId The token ID whose vault to claim from.
|
|
596
596
|
* @param revenueTokens Array of ERC20 revenue token addresses to claim.
|
|
@@ -616,11 +616,11 @@ interface RoyaltyTokenBalance {
|
|
|
616
616
|
}
|
|
617
617
|
/**
|
|
618
618
|
* Gets the Royalty Token balance for a holder in a token's vault.
|
|
619
|
-
* If no holder is provided, the
|
|
620
|
-
* since RT tokens are
|
|
619
|
+
* If no holder is provided, the connected wallet address is used,
|
|
620
|
+
* since RT tokens are sent directly to the wallet.
|
|
621
621
|
*
|
|
622
622
|
* @param tokenId The token ID whose vault to query.
|
|
623
|
-
* @param holder Optional holder address. Defaults to the
|
|
623
|
+
* @param holder Optional holder address. Defaults to the connected wallet.
|
|
624
624
|
* @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
|
|
625
625
|
*/
|
|
626
626
|
declare function getRoyaltyTokenBalance(this: Origin, tokenId: bigint, holder?: Address): Promise<RoyaltyTokenBalance>;
|
|
@@ -1067,6 +1067,12 @@ declare class Origin {
|
|
|
1067
1067
|
* ```
|
|
1068
1068
|
*/
|
|
1069
1069
|
claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
|
|
1070
|
+
/**
|
|
1071
|
+
* Get the connected wallet address.
|
|
1072
|
+
* @returns {Promise<Address>} The connected wallet address.
|
|
1073
|
+
* @throws {WalletError} Throws if no wallet is connected.
|
|
1074
|
+
*/
|
|
1075
|
+
getWalletAddress(): Promise<Address>;
|
|
1070
1076
|
}
|
|
1071
1077
|
|
|
1072
1078
|
interface StorageAdapter {
|
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,
|
|
3
|
+
import { custom, createWalletClient, createPublicClient, http, zeroAddress, erc20Abi as erc20Abi$1, getAbiItem, formatEther, formatUnits, encodeFunctionData, 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,17 +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
|
|
8036
|
-
* since RT tokens are
|
|
8035
|
+
* If no holder is provided, the connected wallet address is used,
|
|
8036
|
+
* since RT tokens are sent directly to the wallet.
|
|
8037
8037
|
*
|
|
8038
8038
|
* @param tokenId The token ID whose vault to query.
|
|
8039
8039
|
* @param revenueToken The ERC20 revenue token address.
|
|
8040
|
-
* @param holder Optional holder address. Defaults to the
|
|
8040
|
+
* @param holder Optional holder address. Defaults to the connected wallet.
|
|
8041
8041
|
* @returns The claimable amount in the revenue token's smallest unit.
|
|
8042
8042
|
*/
|
|
8043
8043
|
function claimableRevenue(tokenId, revenueToken, holder) {
|
|
8044
8044
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8045
|
-
const holderAddress = holder || (yield this.
|
|
8045
|
+
const holderAddress = holder || (yield this.getWalletAddress());
|
|
8046
8046
|
const amount = yield this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS, this.environment.MARKETPLACE_ABI, "claimableRevenue", [tokenId, holderAddress, revenueToken]);
|
|
8047
8047
|
return amount;
|
|
8048
8048
|
});
|
|
@@ -8050,8 +8050,8 @@ function claimableRevenue(tokenId, revenueToken, holder) {
|
|
|
8050
8050
|
|
|
8051
8051
|
/**
|
|
8052
8052
|
* Claims accumulated revenue for a token from a specific revenue token.
|
|
8053
|
-
*
|
|
8054
|
-
*
|
|
8053
|
+
* The connected wallet must hold Royalty Tokens for the given token.
|
|
8054
|
+
* Revenue is sent directly to the connected wallet.
|
|
8055
8055
|
*
|
|
8056
8056
|
* @param tokenId The token ID whose vault to claim from.
|
|
8057
8057
|
* @param revenueToken The ERC20 revenue token address to claim.
|
|
@@ -8059,25 +8059,14 @@ function claimableRevenue(tokenId, revenueToken, holder) {
|
|
|
8059
8059
|
*/
|
|
8060
8060
|
function claimRevenue(tokenId, revenueToken) {
|
|
8061
8061
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8062
|
-
|
|
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) });
|
|
8062
|
+
return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS, this.environment.MARKETPLACE_ABI, "claimRevenue", [tokenId, revenueToken], { waitForReceipt: true });
|
|
8074
8063
|
});
|
|
8075
8064
|
}
|
|
8076
8065
|
|
|
8077
8066
|
/**
|
|
8078
8067
|
* Claims accumulated revenue for a token from multiple revenue tokens in a single transaction.
|
|
8079
|
-
*
|
|
8080
|
-
*
|
|
8068
|
+
* The connected wallet must hold Royalty Tokens for the given token.
|
|
8069
|
+
* Revenue is sent directly to the connected wallet.
|
|
8081
8070
|
*
|
|
8082
8071
|
* @param tokenId The token ID whose vault to claim from.
|
|
8083
8072
|
* @param revenueTokens Array of ERC20 revenue token addresses to claim.
|
|
@@ -8085,18 +8074,7 @@ function claimRevenue(tokenId, revenueToken) {
|
|
|
8085
8074
|
*/
|
|
8086
8075
|
function claimRevenueBatch(tokenId, revenueTokens) {
|
|
8087
8076
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8088
|
-
|
|
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) });
|
|
8077
|
+
return this.callContractMethod(this.environment.MARKETPLACE_CONTRACT_ADDRESS, this.environment.MARKETPLACE_ABI, "claimRevenueBatch", [tokenId, revenueTokens], { waitForReceipt: true });
|
|
8100
8078
|
});
|
|
8101
8079
|
}
|
|
8102
8080
|
|
|
@@ -8138,17 +8116,17 @@ const erc20Abi = [
|
|
|
8138
8116
|
];
|
|
8139
8117
|
/**
|
|
8140
8118
|
* Gets the Royalty Token balance for a holder in a token's vault.
|
|
8141
|
-
* If no holder is provided, the
|
|
8142
|
-
* since RT tokens are
|
|
8119
|
+
* If no holder is provided, the connected wallet address is used,
|
|
8120
|
+
* since RT tokens are sent directly to the wallet.
|
|
8143
8121
|
*
|
|
8144
8122
|
* @param tokenId The token ID whose vault to query.
|
|
8145
|
-
* @param holder Optional holder address. Defaults to the
|
|
8123
|
+
* @param holder Optional holder address. Defaults to the connected wallet.
|
|
8146
8124
|
* @returns The royalty token balance info including vault address, balance, total supply, percentage, and decimals.
|
|
8147
8125
|
*/
|
|
8148
8126
|
function getRoyaltyTokenBalance(tokenId, holder) {
|
|
8149
8127
|
return __awaiter(this, void 0, void 0, function* () {
|
|
8150
|
-
// Default to the
|
|
8151
|
-
const holderAddress = holder || (yield this.
|
|
8128
|
+
// Default to the connected wallet, since RT tokens are sent there directly
|
|
8129
|
+
const holderAddress = holder || (yield this.getWalletAddress());
|
|
8152
8130
|
// Get vault address
|
|
8153
8131
|
const vaultAddress = yield this.callContractMethod(this.environment.DATANFT_CONTRACT_ADDRESS, this.environment.IPNFT_ABI, "getRoyaltyVault", [tokenId]);
|
|
8154
8132
|
if (!vaultAddress || vaultAddress === zeroAddress) {
|
|
@@ -8874,7 +8852,7 @@ class Origin {
|
|
|
8874
8852
|
*/
|
|
8875
8853
|
callContractMethod(contractAddress_1, abi_1, methodName_1, params_1) {
|
|
8876
8854
|
return __awaiter(this, arguments, void 0, function* (contractAddress, abi, methodName, params, options = {}) {
|
|
8877
|
-
var _a;
|
|
8855
|
+
var _a, _b;
|
|
8878
8856
|
let account = null;
|
|
8879
8857
|
try {
|
|
8880
8858
|
account = yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_getCurrentAccount).call(this);
|
|
@@ -8889,12 +8867,12 @@ class Origin {
|
|
|
8889
8867
|
abiItem.stateMutability === "pure");
|
|
8890
8868
|
if (isView) {
|
|
8891
8869
|
const publicClient = getPublicClient();
|
|
8892
|
-
const result = (yield publicClient.readContract({
|
|
8870
|
+
const result = (_a = (yield publicClient.readContract({
|
|
8893
8871
|
address: contractAddress,
|
|
8894
8872
|
abi,
|
|
8895
8873
|
functionName: methodName,
|
|
8896
8874
|
args: params,
|
|
8897
|
-
}))
|
|
8875
|
+
}))) !== null && _a !== void 0 ? _a : null;
|
|
8898
8876
|
return result;
|
|
8899
8877
|
}
|
|
8900
8878
|
yield __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_ensureChainId).call(this, this.environment.CHAIN);
|
|
@@ -8912,7 +8890,7 @@ class Origin {
|
|
|
8912
8890
|
return simulatedResult;
|
|
8913
8891
|
}
|
|
8914
8892
|
try {
|
|
8915
|
-
const txHash = yield ((
|
|
8893
|
+
const txHash = yield ((_b = this.viemClient) === null || _b === void 0 ? void 0 : _b.writeContract(request));
|
|
8916
8894
|
if (typeof txHash !== "string") {
|
|
8917
8895
|
throw new ContractError(`Transaction for "${methodName}" failed to send: no transaction hash returned`, { contractName: contractAddress, methodName });
|
|
8918
8896
|
}
|
|
@@ -9242,6 +9220,16 @@ class Origin {
|
|
|
9242
9220
|
{ waitForReceipt: true, value: BigInt(0) });
|
|
9243
9221
|
});
|
|
9244
9222
|
}
|
|
9223
|
+
/**
|
|
9224
|
+
* Get the connected wallet address.
|
|
9225
|
+
* @returns {Promise<Address>} The connected wallet address.
|
|
9226
|
+
* @throws {WalletError} Throws if no wallet is connected.
|
|
9227
|
+
*/
|
|
9228
|
+
getWalletAddress() {
|
|
9229
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
9230
|
+
return __classPrivateFieldGet(this, _Origin_instances, "m", _Origin_resolveWalletAddress).call(this);
|
|
9231
|
+
});
|
|
9232
|
+
}
|
|
9245
9233
|
}
|
|
9246
9234
|
_Origin_instances = new WeakSet(), _Origin_generateURL = function _Origin_generateURL(file, partCount) {
|
|
9247
9235
|
return __awaiter(this, void 0, void 0, function* () {
|