@campnetwork/origin 1.3.2 → 1.4.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 +43 -64
- package/dist/core.cjs +174 -266
- package/dist/core.d.ts +55 -168
- package/dist/core.esm.d.ts +55 -168
- package/dist/core.esm.js +190 -282
- package/dist/react/index.esm.d.ts +54 -167
- package/dist/react/index.esm.js +3120 -2804
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -31,7 +31,7 @@ The Origin SDK currently exposes the following modules:
|
|
|
31
31
|
- **Flexible Storage** - Custom storage adapters for session persistence
|
|
32
32
|
- **Multiple License Types** - Duration-based, single payment, and X402 micropayment licenses
|
|
33
33
|
- **Dispute Resolution** - Raise and resolve IP disputes with CAMP token voting
|
|
34
|
-
- **
|
|
34
|
+
- **Royalty Vault System** - Deploy revenue vaults for IP NFTs and claim royalties with Royalty Tokens
|
|
35
35
|
- **App Revenue Sharing** - Built-in app fee support via AppRegistry
|
|
36
36
|
- **Bulk Operations** - Purchase multiple IP NFTs in a single transaction
|
|
37
37
|
|
|
@@ -496,8 +496,7 @@ import {
|
|
|
496
496
|
BulkCostPreview,
|
|
497
497
|
VoteEligibility,
|
|
498
498
|
DisputeProgress,
|
|
499
|
-
|
|
500
|
-
FractionalizeEligibility,
|
|
499
|
+
RoyaltyTokenBalance,
|
|
501
500
|
} from "@campnetwork/origin";
|
|
502
501
|
```
|
|
503
502
|
|
|
@@ -1205,7 +1204,6 @@ Most methods mirror smart contract functions and require appropriate permissions
|
|
|
1205
1204
|
- `bulkMintTolerant(mints)` — Low-level tolerant bulk mint (partial success allowed, returns success/failure counts)
|
|
1206
1205
|
- `updateTerms(tokenId, license)` — Update license terms
|
|
1207
1206
|
- `finalizeDelete(tokenId)` — Finalize deletion of an IP NFT
|
|
1208
|
-
- `getOrCreateRoyaltyVault(tokenId)` — Get or create Token Bound Account for royalties
|
|
1209
1207
|
- `getTerms(tokenId)` — Get license terms for a token
|
|
1210
1208
|
- `ownerOf(tokenId)` — Get owner address
|
|
1211
1209
|
- `balanceOf(owner)` — Get token count for an owner
|
|
@@ -1378,80 +1376,59 @@ if (progress.timeline.canResolveNow) {
|
|
|
1378
1376
|
}
|
|
1379
1377
|
```
|
|
1380
1378
|
|
|
1381
|
-
####
|
|
1379
|
+
#### Royalty Vault Module Methods
|
|
1382
1380
|
|
|
1383
|
-
Methods for
|
|
1381
|
+
Methods for managing royalty vaults and claiming revenue from IP NFTs. The royalty vault system deploys a revenue vault per NFT and issues 100 Royalty Tokens (RT) with real revenue-claiming rights. The NFT stays with the owner.
|
|
1384
1382
|
|
|
1385
|
-
- `
|
|
1386
|
-
- `
|
|
1387
|
-
- `
|
|
1388
|
-
- `
|
|
1389
|
-
- `
|
|
1390
|
-
- `
|
|
1391
|
-
- `
|
|
1383
|
+
- `getRoyaltyVault(tokenId)` — Get the royalty vault address for a token (returns `null` if no vault exists)
|
|
1384
|
+
- `getVaultRevenueTokens(tokenId)` — Get the list of ERC20 revenue token addresses in a vault
|
|
1385
|
+
- `claimableRevenue(tokenId, revenueToken, holder?)` — Check how much revenue is claimable by a holder
|
|
1386
|
+
- `claimRevenue(tokenId, revenueToken)` — Claim revenue for a single revenue token
|
|
1387
|
+
- `claimRevenueBatch(tokenId, revenueTokens)` — Claim revenue for multiple revenue tokens in one transaction
|
|
1388
|
+
- `deployVaultForExistingNFT(tokenId)` — Deploy a vault for an NFT minted before the vault system (migration)
|
|
1389
|
+
- `getRoyaltyTokenBalance(tokenId, holder?)` — Get Royalty Token balance and ownership percentage
|
|
1392
1390
|
|
|
1393
|
-
**
|
|
1391
|
+
**RoyaltyTokenBalance Interface:**
|
|
1394
1392
|
|
|
1395
1393
|
```typescript
|
|
1396
|
-
interface
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
ownershipPercentage: number; // 0-100
|
|
1403
|
-
canRedeem: boolean; // True if owns 100%
|
|
1404
|
-
decimals: number;
|
|
1405
|
-
}
|
|
1406
|
-
```
|
|
1407
|
-
|
|
1408
|
-
**FractionalizeEligibility Interface:**
|
|
1409
|
-
|
|
1410
|
-
```typescript
|
|
1411
|
-
interface FractionalizeEligibility {
|
|
1412
|
-
canFractionalize: boolean;
|
|
1413
|
-
reason?: string; // Why not (if false)
|
|
1414
|
-
isOwner: boolean;
|
|
1415
|
-
currentOwner: Address;
|
|
1416
|
-
isAlreadyFractionalized: boolean;
|
|
1417
|
-
existingErc20Address?: Address;
|
|
1418
|
-
dataStatus: DataStatus;
|
|
1419
|
-
isApproved: boolean; // Fractionalizer approved to transfer
|
|
1420
|
-
needsApproval: boolean;
|
|
1394
|
+
interface RoyaltyTokenBalance {
|
|
1395
|
+
vaultAddress: Address; // The vault contract address
|
|
1396
|
+
balance: bigint; // Holder's Royalty Token balance
|
|
1397
|
+
totalSupply: bigint; // Total supply of Royalty Tokens
|
|
1398
|
+
percentage: number; // 0-100 ownership percentage
|
|
1399
|
+
decimals: number; // Token decimals
|
|
1421
1400
|
}
|
|
1422
1401
|
```
|
|
1423
1402
|
|
|
1424
1403
|
**Example:**
|
|
1425
1404
|
|
|
1426
1405
|
```typescript
|
|
1427
|
-
// Check if
|
|
1428
|
-
const
|
|
1406
|
+
// Check if a vault exists for a token
|
|
1407
|
+
const vault = await auth.origin.getRoyaltyVault(1n);
|
|
1429
1408
|
|
|
1430
|
-
if (
|
|
1431
|
-
//
|
|
1432
|
-
await auth.origin.
|
|
1433
|
-
} else {
|
|
1434
|
-
console.log(`Cannot fractionalize: ${eligibility.reason}`);
|
|
1435
|
-
// Possible reasons:
|
|
1436
|
-
// - "You don't own this NFT"
|
|
1437
|
-
// - "This NFT is already fractionalized"
|
|
1438
|
-
// - "This NFT has been deleted"
|
|
1439
|
-
// - "This NFT is disputed"
|
|
1409
|
+
if (!vault) {
|
|
1410
|
+
// Deploy a vault for an existing NFT (migration)
|
|
1411
|
+
await auth.origin.deployVaultForExistingNFT(1n);
|
|
1440
1412
|
}
|
|
1441
1413
|
|
|
1442
|
-
// Check your
|
|
1443
|
-
const
|
|
1414
|
+
// Check your Royalty Token balance
|
|
1415
|
+
const rtBalance = await auth.origin.getRoyaltyTokenBalance(1n);
|
|
1416
|
+
console.log(`You own ${rtBalance.percentage}% of royalty rights`);
|
|
1417
|
+
console.log(`Balance: ${rtBalance.balance} / ${rtBalance.totalSupply}`);
|
|
1444
1418
|
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
console.log(`You own ${ownership.ownershipPercentage}% of this NFT`);
|
|
1449
|
-
console.log(`Balance: ${ownership.balance} / ${ownership.totalSupply}`);
|
|
1419
|
+
// Check which revenue tokens have accumulated
|
|
1420
|
+
const revenueTokens = await auth.origin.getVaultRevenueTokens(1n);
|
|
1421
|
+
console.log(`Revenue tokens: ${revenueTokens.length}`);
|
|
1450
1422
|
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
}
|
|
1423
|
+
// Check claimable revenue for each token
|
|
1424
|
+
for (const token of revenueTokens) {
|
|
1425
|
+
const claimable = await auth.origin.claimableRevenue(1n, token);
|
|
1426
|
+
console.log(`Claimable from ${token}: ${claimable}`);
|
|
1427
|
+
}
|
|
1428
|
+
|
|
1429
|
+
// Claim all revenue in one transaction
|
|
1430
|
+
if (revenueTokens.length > 0) {
|
|
1431
|
+
await auth.origin.claimRevenueBatch(1n, revenueTokens);
|
|
1455
1432
|
}
|
|
1456
1433
|
```
|
|
1457
1434
|
|
|
@@ -1470,10 +1447,12 @@ console.log(`Revenue Share: ${appInfo.revenueShareBps / 100}%`);
|
|
|
1470
1447
|
console.log(`Active: ${appInfo.isActive}`);
|
|
1471
1448
|
```
|
|
1472
1449
|
|
|
1473
|
-
#### Royalty & Data Methods
|
|
1450
|
+
#### TBA Royalty & Data Methods
|
|
1451
|
+
|
|
1452
|
+
These methods work with the Token Bound Account (TBA) that exists for all NFTs. For the new Royalty Vault system, see the [Royalty Vault Module Methods](#royalty-vault-module-methods) section above.
|
|
1474
1453
|
|
|
1475
1454
|
- `getTokenBoundAccount(tokenId)` — Get the Token Bound Account address for a token
|
|
1476
|
-
- `getRoyalties(tokenId, token?)` — Get royalty balance for a token
|
|
1455
|
+
- `getRoyalties(tokenId, token?)` — Get TBA royalty balance for a token
|
|
1477
1456
|
- `claimRoyalties(tokenId, recipient?, token?)` — Claim royalties from a token's TBA
|
|
1478
1457
|
- `getData(tokenId)` — Fetch the underlying IP data (requires access)
|
|
1479
1458
|
|