@campnetwork/origin 1.3.1 → 1.4.0-alpha.0
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 +47 -64
- package/dist/core.cjs +174 -265
- package/dist/core.d.ts +56 -170
- package/dist/core.esm.d.ts +56 -170
- package/dist/core.esm.js +190 -281
- package/dist/react/index.esm.d.ts +56 -170
- package/dist/react/index.esm.js +3186 -2872
- 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
|
|
|
@@ -70,6 +70,7 @@ The Auth class is the entry point for authenticating users with the Origin SDK.
|
|
|
70
70
|
- `spotify` - The URI to redirect to after the user completes oauth for Spotify.
|
|
71
71
|
- `environment` - `string` - The environment to use. Can be either `DEVELOPMENT` or `PRODUCTION`. Defaults to `DEVELOPMENT`.
|
|
72
72
|
- `baseParentId` - `bigint` - A valid tokenID to be used as the parent of all IPNFTs minted on your platform, making them all derivatives of your base asset.
|
|
73
|
+
- `appId` - `string` - The app ID of your app. This is used to identify your app in the AppRegistry smart contract and to apply any app fees or revenue sharing that you have set up.
|
|
73
74
|
|
|
74
75
|
You may use the `redirectUri` object to redirect the user to different pages based on the social they are linking.
|
|
75
76
|
You may only define the URIs for the socials you are using, the rest will default to `window.location.href`.
|
|
@@ -80,6 +81,7 @@ import { Auth } from "@campnetwork/origin";
|
|
|
80
81
|
const auth = new Auth({
|
|
81
82
|
clientId: string,
|
|
82
83
|
redirectUri: string | object,
|
|
84
|
+
appId?: string,
|
|
83
85
|
});
|
|
84
86
|
```
|
|
85
87
|
|
|
@@ -494,8 +496,7 @@ import {
|
|
|
494
496
|
BulkCostPreview,
|
|
495
497
|
VoteEligibility,
|
|
496
498
|
DisputeProgress,
|
|
497
|
-
|
|
498
|
-
FractionalizeEligibility,
|
|
499
|
+
RoyaltyTokenBalance,
|
|
499
500
|
} from "@campnetwork/origin";
|
|
500
501
|
```
|
|
501
502
|
|
|
@@ -542,6 +543,7 @@ It can also take the following optional props:
|
|
|
542
543
|
- `environment` - `string` - The environment to use. Can be either `DEVELOPMENT` or `PRODUCTION`. Defaults to `DEVELOPMENT`.
|
|
543
544
|
- - the `DEVELOPMENT` environment uses the Camp Testnet while the `PRODUCTION` environment uses the Camp Mainnet.
|
|
544
545
|
- `baseParentId` - `string | bigint` - A valid tokenID to be used as the parent of all IPNFTs minted on your platform, making them all derivatives of your base asset.
|
|
546
|
+
- `appId` - `string` - The app ID of your app. This is used to identify your app in the AppRegistry smart contract and to apply any app fees or revenue sharing that you have set up.
|
|
545
547
|
|
|
546
548
|
```jsx
|
|
547
549
|
import { CampProvider } from "@campnetwork/origin/react";
|
|
@@ -552,6 +554,7 @@ function App() {
|
|
|
552
554
|
clientId="your-client-id"
|
|
553
555
|
redirectUri="https://your-website.com"
|
|
554
556
|
environment="DEVELOPMENT"
|
|
557
|
+
appId="your-app-id"
|
|
555
558
|
>
|
|
556
559
|
<div>Your app</div>
|
|
557
560
|
</CampProvider>
|
|
@@ -1201,7 +1204,6 @@ Most methods mirror smart contract functions and require appropriate permissions
|
|
|
1201
1204
|
- `bulkMintTolerant(mints)` — Low-level tolerant bulk mint (partial success allowed, returns success/failure counts)
|
|
1202
1205
|
- `updateTerms(tokenId, license)` — Update license terms
|
|
1203
1206
|
- `finalizeDelete(tokenId)` — Finalize deletion of an IP NFT
|
|
1204
|
-
- `getOrCreateRoyaltyVault(tokenId)` — Get or create Token Bound Account for royalties
|
|
1205
1207
|
- `getTerms(tokenId)` — Get license terms for a token
|
|
1206
1208
|
- `ownerOf(tokenId)` — Get owner address
|
|
1207
1209
|
- `balanceOf(owner)` — Get token count for an owner
|
|
@@ -1374,80 +1376,59 @@ if (progress.timeline.canResolveNow) {
|
|
|
1374
1376
|
}
|
|
1375
1377
|
```
|
|
1376
1378
|
|
|
1377
|
-
####
|
|
1379
|
+
#### Royalty Vault Module Methods
|
|
1378
1380
|
|
|
1379
|
-
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.
|
|
1380
1382
|
|
|
1381
|
-
- `
|
|
1382
|
-
- `
|
|
1383
|
-
- `
|
|
1384
|
-
- `
|
|
1385
|
-
- `
|
|
1386
|
-
- `
|
|
1387
|
-
- `
|
|
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
|
|
1388
1390
|
|
|
1389
|
-
**
|
|
1391
|
+
**RoyaltyTokenBalance Interface:**
|
|
1390
1392
|
|
|
1391
1393
|
```typescript
|
|
1392
|
-
interface
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
ownershipPercentage: number; // 0-100
|
|
1399
|
-
canRedeem: boolean; // True if owns 100%
|
|
1400
|
-
decimals: number;
|
|
1401
|
-
}
|
|
1402
|
-
```
|
|
1403
|
-
|
|
1404
|
-
**FractionalizeEligibility Interface:**
|
|
1405
|
-
|
|
1406
|
-
```typescript
|
|
1407
|
-
interface FractionalizeEligibility {
|
|
1408
|
-
canFractionalize: boolean;
|
|
1409
|
-
reason?: string; // Why not (if false)
|
|
1410
|
-
isOwner: boolean;
|
|
1411
|
-
currentOwner: Address;
|
|
1412
|
-
isAlreadyFractionalized: boolean;
|
|
1413
|
-
existingErc20Address?: Address;
|
|
1414
|
-
dataStatus: DataStatus;
|
|
1415
|
-
isApproved: boolean; // Fractionalizer approved to transfer
|
|
1416
|
-
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
|
|
1417
1400
|
}
|
|
1418
1401
|
```
|
|
1419
1402
|
|
|
1420
1403
|
**Example:**
|
|
1421
1404
|
|
|
1422
1405
|
```typescript
|
|
1423
|
-
// Check if
|
|
1424
|
-
const
|
|
1406
|
+
// Check if a vault exists for a token
|
|
1407
|
+
const vault = await auth.origin.getRoyaltyVault(1n);
|
|
1425
1408
|
|
|
1426
|
-
if (
|
|
1427
|
-
//
|
|
1428
|
-
await auth.origin.
|
|
1429
|
-
} else {
|
|
1430
|
-
console.log(`Cannot fractionalize: ${eligibility.reason}`);
|
|
1431
|
-
// Possible reasons:
|
|
1432
|
-
// - "You don't own this NFT"
|
|
1433
|
-
// - "This NFT is already fractionalized"
|
|
1434
|
-
// - "This NFT has been deleted"
|
|
1435
|
-
// - "This NFT is disputed"
|
|
1409
|
+
if (!vault) {
|
|
1410
|
+
// Deploy a vault for an existing NFT (migration)
|
|
1411
|
+
await auth.origin.deployVaultForExistingNFT(1n);
|
|
1436
1412
|
}
|
|
1437
1413
|
|
|
1438
|
-
// Check your
|
|
1439
|
-
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}`);
|
|
1440
1418
|
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
console.log(`You own ${ownership.ownershipPercentage}% of this NFT`);
|
|
1445
|
-
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}`);
|
|
1446
1422
|
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
}
|
|
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);
|
|
1451
1432
|
}
|
|
1452
1433
|
```
|
|
1453
1434
|
|
|
@@ -1466,10 +1447,12 @@ console.log(`Revenue Share: ${appInfo.revenueShareBps / 100}%`);
|
|
|
1466
1447
|
console.log(`Active: ${appInfo.isActive}`);
|
|
1467
1448
|
```
|
|
1468
1449
|
|
|
1469
|
-
#### 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.
|
|
1470
1453
|
|
|
1471
1454
|
- `getTokenBoundAccount(tokenId)` — Get the Token Bound Account address for a token
|
|
1472
|
-
- `getRoyalties(tokenId, token?)` — Get royalty balance for a token
|
|
1455
|
+
- `getRoyalties(tokenId, token?)` — Get TBA royalty balance for a token
|
|
1473
1456
|
- `claimRoyalties(tokenId, recipient?, token?)` — Claim royalties from a token's TBA
|
|
1474
1457
|
- `getData(tokenId)` — Fetch the underlying IP data (requires access)
|
|
1475
1458
|
|