@campnetwork/origin 1.2.0-3 → 1.2.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 +39 -222
- package/dist/core.cjs +92 -266
- package/dist/core.d.ts +11 -200
- package/dist/core.esm.d.ts +11 -200
- package/dist/core.esm.js +94 -267
- package/dist/react/index.esm.d.ts +14 -6
- package/dist/react/index.esm.js +27 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,8 +15,6 @@
|
|
|
15
15
|
The Origin SDK currently exposes the following modules:
|
|
16
16
|
|
|
17
17
|
- `"@campnetwork/origin"` - The main entry point for the SDK, exposes the following classes:
|
|
18
|
-
- `TwitterAPI` - For fetching user Twitter data from Origin
|
|
19
|
-
- `SpotifyAPI` - For fetching user Spotify data from Origin
|
|
20
18
|
- `Auth` - For authenticating users with the Origin SDK (browser and Node.js)
|
|
21
19
|
- Signer adapters and utilities for Node.js support (ethers, viem, custom signers)
|
|
22
20
|
- Camp Network chain configurations (`campMainnet`, `campTestnet`)
|
|
@@ -45,229 +43,13 @@ The core modules can be imported either as a CommonJS module or as an ES6 module
|
|
|
45
43
|
### CommonJS
|
|
46
44
|
|
|
47
45
|
```js
|
|
48
|
-
const {
|
|
46
|
+
const { Auth } = require("@campnetwork/origin");
|
|
49
47
|
```
|
|
50
48
|
|
|
51
49
|
### ES6
|
|
52
50
|
|
|
53
51
|
```js
|
|
54
|
-
import {
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
## Socials
|
|
58
|
-
|
|
59
|
-
### TwitterAPI
|
|
60
|
-
|
|
61
|
-
The TwitterAPI class is the entry point for fetching user Twitter data from Origin. It requires an API key to be instantiated.
|
|
62
|
-
|
|
63
|
-
**Note: The methods for fetching data will only return data for users who have authenticated to your app via the Origin SDK.**
|
|
64
|
-
|
|
65
|
-
#### Constructor
|
|
66
|
-
|
|
67
|
-
`apiKey` - The API key of your app.
|
|
68
|
-
|
|
69
|
-
```js
|
|
70
|
-
const twitter = new TwitterAPI({
|
|
71
|
-
apiKey: string,
|
|
72
|
-
});
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
#### Methods
|
|
76
|
-
|
|
77
|
-
##### fetchUserByUsername
|
|
78
|
-
|
|
79
|
-
`fetchUserByUsername(twitterUserName: string)`
|
|
80
|
-
|
|
81
|
-
```js
|
|
82
|
-
const user = await twitter.fetchUserByUsername("jack");
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
##### fetchTweetsByUsername
|
|
86
|
-
|
|
87
|
-
`fetchTweetsByUsername(twitterUserName: string, page: number, limit: number)`
|
|
88
|
-
|
|
89
|
-
```js
|
|
90
|
-
const tweets = await twitter.fetchTweetsByUsername("jack", 1, 10);
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
##### fetchFollowersByUsername
|
|
94
|
-
|
|
95
|
-
`fetchFollowersByUsername(twitterUserName: string, page: number, limit: number)`
|
|
96
|
-
|
|
97
|
-
```js
|
|
98
|
-
const followers = await twitter.fetchFollowersByUsername("jack", 1, 10);
|
|
99
|
-
```
|
|
100
|
-
|
|
101
|
-
##### fetchFollowingByUsername
|
|
102
|
-
|
|
103
|
-
`fetchFollowingByUsername(twitterUserName: string, page: number, limit: number)`
|
|
104
|
-
|
|
105
|
-
```js
|
|
106
|
-
const following = await twitter.fetchFollowingByUsername("jack", 1, 10);
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
##### fetchTweetById
|
|
110
|
-
|
|
111
|
-
`fetchTweetById(tweetId: string)`
|
|
112
|
-
|
|
113
|
-
```js
|
|
114
|
-
const tweet = await twitter.fetchTweetById("1234567890");
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
##### fetchUserByWalletAddress
|
|
118
|
-
|
|
119
|
-
`fetchUserByWalletAddress(walletAddress: string, page: number, limit: number)`
|
|
120
|
-
|
|
121
|
-
```js
|
|
122
|
-
const user = await twitter.fetchUserByWalletAddress("0x1234567890", 1, 10);
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
##### fetchRepostedByUsername
|
|
126
|
-
|
|
127
|
-
`fetchRepostedByUsername(twitterUserName: string, page: number, limit: number)`
|
|
128
|
-
|
|
129
|
-
```js
|
|
130
|
-
const reposts = await twitter.fetchRepostedByUsername("jack", 1, 10);
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
##### fetchRepliesByUsername
|
|
134
|
-
|
|
135
|
-
`fetchRepliesByUsername(twitterUserName: string, page: number, limit: number)`
|
|
136
|
-
|
|
137
|
-
```js
|
|
138
|
-
const replies = await twitter.fetchRepliesByUsername("jack", 1, 10);
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
##### fetchLikesByUsername
|
|
142
|
-
|
|
143
|
-
`fetchLikesByUsername(twitterUserName: string, page: number, limit: number)`
|
|
144
|
-
|
|
145
|
-
```js
|
|
146
|
-
const likes = await twitter.fetchLikesByUsername("jack", 1, 10);
|
|
147
|
-
```
|
|
148
|
-
|
|
149
|
-
##### fetchFollowsByUsername
|
|
150
|
-
|
|
151
|
-
`fetchFollowsByUsername(twitterUserName: string, page: number, limit: number)`
|
|
152
|
-
|
|
153
|
-
```js
|
|
154
|
-
const follows = await twitter.fetchFollowsByUsername("jack", 1, 10);
|
|
155
|
-
```
|
|
156
|
-
|
|
157
|
-
##### fetchViewedTweetsByUsername
|
|
158
|
-
|
|
159
|
-
`fetchViewedTweetsByUsername(twitterUserName: string, page: number, limit: number)`
|
|
160
|
-
|
|
161
|
-
```js
|
|
162
|
-
const viewedTweets = await twitter.fetchViewedTweetsByUsername("jack", 1, 10);
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### SpotifyAPI
|
|
166
|
-
|
|
167
|
-
The SpotifyAPI class is the entry point for fetching user Spotify data from Origin. It requires an API key to be instantiated.
|
|
168
|
-
|
|
169
|
-
**Note: The methods for fetching data will only return data for users who have authenticated to your app via the Origin SDK.**
|
|
170
|
-
|
|
171
|
-
#### Constructor
|
|
172
|
-
|
|
173
|
-
`apiKey` - The API key of your app.
|
|
174
|
-
|
|
175
|
-
```js
|
|
176
|
-
const spotify = new SpotifyAPI({
|
|
177
|
-
apiKey: string,
|
|
178
|
-
});
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
#### Methods
|
|
182
|
-
|
|
183
|
-
##### fetchSavedTracksById
|
|
184
|
-
|
|
185
|
-
`fetchSavedTracksById(spotifyId: string)`
|
|
186
|
-
|
|
187
|
-
```js
|
|
188
|
-
const savedTracks = await spotify.fetchSavedTracksById("1234567890");
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
##### fetchPlayedTracksById
|
|
192
|
-
|
|
193
|
-
`fetchPlayedTracksById(spotifyId: string)`
|
|
194
|
-
|
|
195
|
-
```js
|
|
196
|
-
const playedTracks = await spotify.fetchPlayedTracksById("1234567890");
|
|
197
|
-
```
|
|
198
|
-
|
|
199
|
-
##### fetchSavedAlbumsById
|
|
200
|
-
|
|
201
|
-
`fetchSavedAlbumsById(spotifyId: string)`
|
|
202
|
-
|
|
203
|
-
```js
|
|
204
|
-
const savedAlbums = await spotify.fetchSavedAlbumsById("1234567890");
|
|
205
|
-
```
|
|
206
|
-
|
|
207
|
-
##### fetchSavedPlaylistsById
|
|
208
|
-
|
|
209
|
-
`fetchSavedPlaylistsById(spotifyId: string)`
|
|
210
|
-
|
|
211
|
-
```js
|
|
212
|
-
const savedPlaylists = await spotify.fetchSavedPlaylistsById("1234567890");
|
|
213
|
-
```
|
|
214
|
-
|
|
215
|
-
##### fetchTracksInAlbum
|
|
216
|
-
|
|
217
|
-
`fetchTracksInAlbum(spotifyId: string, albumId: string)`
|
|
218
|
-
|
|
219
|
-
```js
|
|
220
|
-
const tracks = await spotify.fetchTracksInAlbum("1234567890", "1234567890");
|
|
221
|
-
```
|
|
222
|
-
|
|
223
|
-
##### fetchTracksInPlaylist
|
|
224
|
-
|
|
225
|
-
`fetchTracksInPlaylist(spotifyId: string, playlistId: string)`
|
|
226
|
-
|
|
227
|
-
```js
|
|
228
|
-
const tracks = await spotify.fetchTracksInPlaylist("1234567890", "1234567890");
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
##### fetchUserByWalletAddress
|
|
232
|
-
|
|
233
|
-
`fetchUserByWalletAddress(walletAddress: string)`
|
|
234
|
-
|
|
235
|
-
```js
|
|
236
|
-
const user = await spotify.fetchUserByWalletAddress("0x1234567890");
|
|
237
|
-
```
|
|
238
|
-
|
|
239
|
-
### TikTokAPI
|
|
240
|
-
|
|
241
|
-
The TikTokAPI class is the entry point for fetching user TikTok data from Origin. It requires an API key to be instantiated.
|
|
242
|
-
|
|
243
|
-
**Note: The methods for fetching data will only return data for users who have authenticated to your app via the Origin SDK.**
|
|
244
|
-
|
|
245
|
-
#### Constructor
|
|
246
|
-
|
|
247
|
-
`apiKey` - The API key of your app.
|
|
248
|
-
|
|
249
|
-
```js
|
|
250
|
-
const tiktok = new TikTokAPI({
|
|
251
|
-
apiKey: string,
|
|
252
|
-
});
|
|
253
|
-
```
|
|
254
|
-
|
|
255
|
-
#### Methods
|
|
256
|
-
|
|
257
|
-
##### fetchUserByUsername
|
|
258
|
-
|
|
259
|
-
`fetchUserByUsername(tiktokUserName: string)`
|
|
260
|
-
|
|
261
|
-
```js
|
|
262
|
-
const user = await tiktok.fetchUserByUsername("jack");
|
|
263
|
-
```
|
|
264
|
-
|
|
265
|
-
##### fetchVideoById
|
|
266
|
-
|
|
267
|
-
`fetchVideoById(userHandle: string, videoId: string)`
|
|
268
|
-
|
|
269
|
-
```js
|
|
270
|
-
const video = await tiktok.fetchVideo("jack", "1234567890");
|
|
52
|
+
import { Auth } from "@campnetwork/origin";
|
|
271
53
|
```
|
|
272
54
|
|
|
273
55
|
## Auth
|
|
@@ -276,11 +58,13 @@ The Auth class is the entry point for authenticating users with the Origin SDK.
|
|
|
276
58
|
|
|
277
59
|
### Constructor
|
|
278
60
|
|
|
279
|
-
- `clientId` - The client ID of your app. This is required to authenticate users with the Origin SDK.
|
|
61
|
+
- `clientId` - `string` - The client ID of your app. This is required to authenticate users with the Origin SDK.
|
|
280
62
|
- `redirectUri` - The URI to redirect to after the user completes oauth for any of the socials. Defaults to `window.location.href`.
|
|
281
63
|
The `redirectUri` can also be an object with the following optional properties:
|
|
282
64
|
- `twitter` - The URI to redirect to after the user completes oauth for Twitter.
|
|
283
65
|
- `spotify` - The URI to redirect to after the user completes oauth for Spotify.
|
|
66
|
+
- `environment` - `string` - The environment to use. Can be either `DEVELOPMENT` or `PRODUCTION`. Defaults to `DEVELOPMENT`.
|
|
67
|
+
- `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.
|
|
284
68
|
|
|
285
69
|
You may use the `redirectUri` object to redirect the user to different pages based on the social they are linking.
|
|
286
70
|
You may only define the URIs for the socials you are using, the rest will default to `window.location.href`.
|
|
@@ -291,7 +75,6 @@ import { Auth } from "@campnetwork/origin";
|
|
|
291
75
|
const auth = new Auth({
|
|
292
76
|
clientId: string,
|
|
293
77
|
redirectUri: string | object,
|
|
294
|
-
allowAnalytics: boolean,
|
|
295
78
|
});
|
|
296
79
|
```
|
|
297
80
|
|
|
@@ -305,6 +88,13 @@ const auth = new Auth({
|
|
|
305
88
|
});
|
|
306
89
|
```
|
|
307
90
|
|
|
91
|
+
```js
|
|
92
|
+
const auth = new Auth({
|
|
93
|
+
clientId: "your-client-id",
|
|
94
|
+
baseParentId: 123n,
|
|
95
|
+
});
|
|
96
|
+
```
|
|
97
|
+
|
|
308
98
|
### Methods
|
|
309
99
|
|
|
310
100
|
#### connect
|
|
@@ -722,6 +512,7 @@ It can also take the following optional props:
|
|
|
722
512
|
- `redirectUri` - `string | object` - Either a string that will be used as the redirect URI for all socials, or an object with the following optional properties: `twitter`, `spotify`. This is used to redirect the user to different pages after they have completed the OAuth flow for a social.
|
|
723
513
|
- `environment` - `string` - The environment to use. Can be either `DEVELOPMENT` or `PRODUCTION`. Defaults to `DEVELOPMENT`.
|
|
724
514
|
- - the `DEVELOPMENT` environment uses the Camp Testnet while the `PRODUCTION` environment uses the Camp Mainnet.
|
|
515
|
+
- `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.
|
|
725
516
|
|
|
726
517
|
```jsx
|
|
727
518
|
import { CampProvider } from "@campnetwork/origin/react";
|
|
@@ -1263,6 +1054,32 @@ Call these methods as `await auth.origin.methodName(...)` after authenticating.
|
|
|
1263
1054
|
|
|
1264
1055
|
---
|
|
1265
1056
|
|
|
1057
|
+
# Advanced flows
|
|
1058
|
+
|
|
1059
|
+
## App Revenue Share in Origin using derivatives
|
|
1060
|
+
|
|
1061
|
+
You can enable app-level revenue sharing in **Origin** using the following setup:
|
|
1062
|
+
|
|
1063
|
+
1. **Mint a base (genesis) IPNFT** for your platform and set its royalty percentage to whatever share you want the platform to receive. This can be done using the Origin UI, or the SDK.
|
|
1064
|
+
2. **Make all user-created IPNFTs derivatives** of this base IPNFT. There are two ways to do this:
|
|
1065
|
+
- **Automatic (recommended):**
|
|
1066
|
+
Set the `baseParentId` parameter on the `CampProvider` or `Auth` class (depending on your integration) to the tokenId of the base IPNFT.
|
|
1067
|
+
→ This automatically applies to _all mints_, including those made through the **Camp SDK Modal**.
|
|
1068
|
+
- **Manual:**
|
|
1069
|
+
If you’re using a custom mint flow, add the base IPNFT’s tokenId to the `parents` array before calling `origin.mintFile` or `origin.mintSocial`.
|
|
1070
|
+
→ Note: this does **not** affect mints made through the Camp SDK Modal.
|
|
1071
|
+
3. **Royalties flow automatically:**
|
|
1072
|
+
|
|
1073
|
+
The royalty percentage defined on the base IPNFT will be collected from every subscription to its derivative IPNFTs.
|
|
1074
|
+
|
|
1075
|
+
4. **Claim your platform royalties:**
|
|
1076
|
+
|
|
1077
|
+
You can view and claim the accumulated platform royalties directly from your **Creator Dashboard** in the **Origin UI**.
|
|
1078
|
+
|
|
1079
|
+
**Note:** Each IPNFT can have a maximum of 8 parents. Using one parent slot for app-level revenue sharing reduces the available slots for user-defined parent–derivative relationships to 7.
|
|
1080
|
+
|
|
1081
|
+
---
|
|
1082
|
+
|
|
1266
1083
|
# Contributing
|
|
1267
1084
|
|
|
1268
1085
|
Install the dependencies.
|