@campnetwork/origin 1.2.0 → 1.2.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/README.md +0 -6
- package/dist/core.cjs +127 -112
- package/dist/core.d.ts +150 -156
- package/dist/core.esm.d.ts +150 -156
- package/dist/core.esm.js +133 -127
- package/dist/react/index.esm.d.ts +18 -47
- package/dist/react/index.esm.js +373 -412
- package/package.json +1 -1
package/dist/core.d.ts
CHANGED
|
@@ -1,4 +1,135 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WalletClient, Account, Chain, Address, Hex, Abi } from 'viem';
|
|
2
|
+
|
|
3
|
+
interface BaseSigner {
|
|
4
|
+
getAddress(): Promise<string>;
|
|
5
|
+
signMessage(message: string): Promise<string>;
|
|
6
|
+
signTypedData?(domain: any, types: any, value: any): Promise<string>;
|
|
7
|
+
getChainId(): Promise<number>;
|
|
8
|
+
}
|
|
9
|
+
type SignerType = "viem" | "ethers" | "custom";
|
|
10
|
+
interface SignerAdapter {
|
|
11
|
+
type: SignerType;
|
|
12
|
+
signer: any;
|
|
13
|
+
getAddress(): Promise<string>;
|
|
14
|
+
signMessage(message: string): Promise<string>;
|
|
15
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
16
|
+
getChainId(): Promise<number>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adapter for viem WalletClient
|
|
21
|
+
*/
|
|
22
|
+
declare class ViemSignerAdapter implements SignerAdapter {
|
|
23
|
+
type: SignerType;
|
|
24
|
+
signer: WalletClient;
|
|
25
|
+
constructor(signer: WalletClient);
|
|
26
|
+
getAddress(): Promise<string>;
|
|
27
|
+
signMessage(message: string): Promise<string>;
|
|
28
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
29
|
+
getChainId(): Promise<number>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Adapter for ethers Signer (v5 and v6)
|
|
33
|
+
*/
|
|
34
|
+
declare class EthersSignerAdapter implements SignerAdapter {
|
|
35
|
+
type: SignerType;
|
|
36
|
+
signer: any;
|
|
37
|
+
constructor(signer: any);
|
|
38
|
+
getAddress(): Promise<string>;
|
|
39
|
+
signMessage(message: string): Promise<string>;
|
|
40
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
41
|
+
getChainId(): Promise<number>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Adapter for custom signer implementations
|
|
45
|
+
*/
|
|
46
|
+
declare class CustomSignerAdapter implements SignerAdapter {
|
|
47
|
+
type: SignerType;
|
|
48
|
+
signer: any;
|
|
49
|
+
constructor(signer: any);
|
|
50
|
+
getAddress(): Promise<string>;
|
|
51
|
+
signMessage(message: string): Promise<string>;
|
|
52
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
53
|
+
getChainId(): Promise<number>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Factory function to create appropriate adapter based on signer type
|
|
57
|
+
*/
|
|
58
|
+
declare function createSignerAdapter(signer: any): SignerAdapter;
|
|
59
|
+
|
|
60
|
+
interface StorageAdapter {
|
|
61
|
+
getItem(key: string): Promise<string | null>;
|
|
62
|
+
setItem(key: string, value: string): Promise<void>;
|
|
63
|
+
removeItem(key: string): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Browser localStorage adapter
|
|
67
|
+
*/
|
|
68
|
+
declare class BrowserStorage implements StorageAdapter {
|
|
69
|
+
getItem(key: string): Promise<string | null>;
|
|
70
|
+
setItem(key: string, value: string): Promise<void>;
|
|
71
|
+
removeItem(key: string): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* In-memory storage adapter for Node.js
|
|
75
|
+
*/
|
|
76
|
+
declare class MemoryStorage implements StorageAdapter {
|
|
77
|
+
private storage;
|
|
78
|
+
getItem(key: string): Promise<string | null>;
|
|
79
|
+
setItem(key: string, value: string): Promise<void>;
|
|
80
|
+
removeItem(key: string): Promise<void>;
|
|
81
|
+
clear(): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Create a wallet client for Node.js environment
|
|
86
|
+
* @param account The viem account
|
|
87
|
+
* @param chain The chain to use
|
|
88
|
+
* @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
|
|
89
|
+
* @returns WalletClient
|
|
90
|
+
*/
|
|
91
|
+
declare function createNodeWalletClient(account: Account, chain: Chain, rpcUrl?: string): WalletClient;
|
|
92
|
+
|
|
93
|
+
declare const testnet: {
|
|
94
|
+
id: number;
|
|
95
|
+
name: string;
|
|
96
|
+
nativeCurrency: {
|
|
97
|
+
decimals: number;
|
|
98
|
+
name: string;
|
|
99
|
+
symbol: string;
|
|
100
|
+
};
|
|
101
|
+
rpcUrls: {
|
|
102
|
+
default: {
|
|
103
|
+
http: string[];
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
blockExplorers: {
|
|
107
|
+
default: {
|
|
108
|
+
name: string;
|
|
109
|
+
url: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
declare const mainnet: {
|
|
114
|
+
id: number;
|
|
115
|
+
name: string;
|
|
116
|
+
nativeCurrency: {
|
|
117
|
+
decimals: number;
|
|
118
|
+
name: string;
|
|
119
|
+
symbol: string;
|
|
120
|
+
};
|
|
121
|
+
rpcUrls: {
|
|
122
|
+
default: {
|
|
123
|
+
http: string[];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
blockExplorers: {
|
|
127
|
+
default: {
|
|
128
|
+
name: string;
|
|
129
|
+
url: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
2
133
|
|
|
3
134
|
interface Environment {
|
|
4
135
|
NAME: string;
|
|
@@ -175,15 +306,6 @@ declare function hasAccess(this: Origin, user: Address, tokenId: bigint): Promis
|
|
|
175
306
|
|
|
176
307
|
declare function subscriptionExpiry(this: Origin, tokenId: bigint, user: Address): Promise<bigint>;
|
|
177
308
|
|
|
178
|
-
interface OriginUsageReturnType {
|
|
179
|
-
user: {
|
|
180
|
-
multiplier: number;
|
|
181
|
-
points: number;
|
|
182
|
-
active: boolean;
|
|
183
|
-
};
|
|
184
|
-
teams: Array<any>;
|
|
185
|
-
dataSources: Array<any>;
|
|
186
|
-
}
|
|
187
309
|
interface RoyaltyInfo {
|
|
188
310
|
tokenBoundAccount: Address;
|
|
189
311
|
balance: bigint;
|
|
@@ -219,33 +341,17 @@ declare class Origin {
|
|
|
219
341
|
buyAccess: typeof buyAccess;
|
|
220
342
|
hasAccess: typeof hasAccess;
|
|
221
343
|
subscriptionExpiry: typeof subscriptionExpiry;
|
|
222
|
-
private jwt
|
|
344
|
+
private jwt?;
|
|
223
345
|
environment: Environment;
|
|
224
346
|
private viemClient?;
|
|
225
347
|
baseParentId?: bigint;
|
|
226
|
-
constructor(
|
|
227
|
-
getJwt(): string;
|
|
348
|
+
constructor(environment: Environment | string, jwt?: string, viemClient?: WalletClient, baseParentId?: bigint);
|
|
349
|
+
getJwt(): string | undefined;
|
|
228
350
|
setViemClient(client: WalletClient): void;
|
|
229
|
-
uploadFile(file: File, options?: {
|
|
230
|
-
progressCallback?: (percent: number) => void;
|
|
231
|
-
}): Promise<any>;
|
|
232
351
|
mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
|
|
233
352
|
progressCallback?: (percent: number) => void;
|
|
234
353
|
}): Promise<string | null>;
|
|
235
354
|
mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
|
|
236
|
-
getOriginUploads(): Promise<any[] | null>;
|
|
237
|
-
/**
|
|
238
|
-
* Get the user's Origin stats (multiplier, consent, usage, etc.).
|
|
239
|
-
* @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
|
|
240
|
-
*/
|
|
241
|
-
getOriginUsage(): Promise<OriginUsageReturnType>;
|
|
242
|
-
/**
|
|
243
|
-
* Set the user's consent for Origin usage.
|
|
244
|
-
* @param {boolean} consent The user's consent.
|
|
245
|
-
* @returns {Promise<void>}
|
|
246
|
-
* @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
|
|
247
|
-
*/
|
|
248
|
-
setOriginConsent(consent: boolean): Promise<void>;
|
|
249
355
|
/**
|
|
250
356
|
* Call a contract method.
|
|
251
357
|
* @param {string} contractAddress The contract address.
|
|
@@ -263,7 +369,21 @@ declare class Origin {
|
|
|
263
369
|
* @returns {Promise<any>} The result of the buyAccess call.
|
|
264
370
|
*/
|
|
265
371
|
buyAccessSmart(tokenId: bigint): Promise<any>;
|
|
372
|
+
/**
|
|
373
|
+
* Fetch the underlying data associated with a specific token ID.
|
|
374
|
+
* @param {bigint} tokenId - The token ID to fetch data for.
|
|
375
|
+
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
376
|
+
* @throws {Error} Throws an error if the data cannot be fetched.
|
|
377
|
+
*/
|
|
266
378
|
getData(tokenId: bigint): Promise<any>;
|
|
379
|
+
/**
|
|
380
|
+
* Fetch data with X402 payment handling.
|
|
381
|
+
* @param {bigint} tokenId The token ID to fetch data for.
|
|
382
|
+
* @param {any} [signer] Optional signer object for signing the X402 intent.
|
|
383
|
+
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
384
|
+
* @throws {Error} Throws an error if the data cannot be fetched or if no signer/wallet client is provided.
|
|
385
|
+
*/
|
|
386
|
+
getDataWithX402(tokenId: bigint, signer?: any): Promise<any>;
|
|
267
387
|
/**
|
|
268
388
|
* Get the Token Bound Account (TBA) address for a specific token ID.
|
|
269
389
|
* @param {bigint} tokenId - The token ID to get the TBA address for.
|
|
@@ -311,30 +431,6 @@ declare class Origin {
|
|
|
311
431
|
claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
|
|
312
432
|
}
|
|
313
433
|
|
|
314
|
-
interface StorageAdapter {
|
|
315
|
-
getItem(key: string): Promise<string | null>;
|
|
316
|
-
setItem(key: string, value: string): Promise<void>;
|
|
317
|
-
removeItem(key: string): Promise<void>;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Browser localStorage adapter
|
|
321
|
-
*/
|
|
322
|
-
declare class BrowserStorage implements StorageAdapter {
|
|
323
|
-
getItem(key: string): Promise<string | null>;
|
|
324
|
-
setItem(key: string, value: string): Promise<void>;
|
|
325
|
-
removeItem(key: string): Promise<void>;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* In-memory storage adapter for Node.js
|
|
329
|
-
*/
|
|
330
|
-
declare class MemoryStorage implements StorageAdapter {
|
|
331
|
-
private storage;
|
|
332
|
-
getItem(key: string): Promise<string | null>;
|
|
333
|
-
setItem(key: string, value: string): Promise<void>;
|
|
334
|
-
removeItem(key: string): Promise<void>;
|
|
335
|
-
clear(): void;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
434
|
declare global {
|
|
339
435
|
interface Window {
|
|
340
436
|
ethereum?: any;
|
|
@@ -549,106 +645,4 @@ declare class Auth {
|
|
|
549
645
|
unlinkTelegram(): Promise<any>;
|
|
550
646
|
}
|
|
551
647
|
|
|
552
|
-
|
|
553
|
-
getAddress(): Promise<string>;
|
|
554
|
-
signMessage(message: string): Promise<string>;
|
|
555
|
-
getChainId(): Promise<number>;
|
|
556
|
-
}
|
|
557
|
-
type SignerType = "viem" | "ethers" | "custom";
|
|
558
|
-
interface SignerAdapter {
|
|
559
|
-
type: SignerType;
|
|
560
|
-
signer: any;
|
|
561
|
-
getAddress(): Promise<string>;
|
|
562
|
-
signMessage(message: string): Promise<string>;
|
|
563
|
-
getChainId(): Promise<number>;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Adapter for viem WalletClient
|
|
568
|
-
*/
|
|
569
|
-
declare class ViemSignerAdapter implements SignerAdapter {
|
|
570
|
-
type: SignerType;
|
|
571
|
-
signer: WalletClient;
|
|
572
|
-
constructor(signer: WalletClient);
|
|
573
|
-
getAddress(): Promise<string>;
|
|
574
|
-
signMessage(message: string): Promise<string>;
|
|
575
|
-
getChainId(): Promise<number>;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Adapter for ethers Signer (v5 and v6)
|
|
579
|
-
*/
|
|
580
|
-
declare class EthersSignerAdapter implements SignerAdapter {
|
|
581
|
-
type: SignerType;
|
|
582
|
-
signer: any;
|
|
583
|
-
constructor(signer: any);
|
|
584
|
-
getAddress(): Promise<string>;
|
|
585
|
-
signMessage(message: string): Promise<string>;
|
|
586
|
-
getChainId(): Promise<number>;
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* Adapter for custom signer implementations
|
|
590
|
-
*/
|
|
591
|
-
declare class CustomSignerAdapter implements SignerAdapter {
|
|
592
|
-
type: SignerType;
|
|
593
|
-
signer: any;
|
|
594
|
-
constructor(signer: any);
|
|
595
|
-
getAddress(): Promise<string>;
|
|
596
|
-
signMessage(message: string): Promise<string>;
|
|
597
|
-
getChainId(): Promise<number>;
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Factory function to create appropriate adapter based on signer type
|
|
601
|
-
*/
|
|
602
|
-
declare function createSignerAdapter(signer: any): SignerAdapter;
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Create a wallet client for Node.js environment
|
|
606
|
-
* @param account The viem account
|
|
607
|
-
* @param chain The chain to use
|
|
608
|
-
* @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
|
|
609
|
-
* @returns WalletClient
|
|
610
|
-
*/
|
|
611
|
-
declare function createNodeWalletClient(account: Account, chain: Chain, rpcUrl?: string): WalletClient;
|
|
612
|
-
|
|
613
|
-
declare const testnet: {
|
|
614
|
-
id: number;
|
|
615
|
-
name: string;
|
|
616
|
-
nativeCurrency: {
|
|
617
|
-
decimals: number;
|
|
618
|
-
name: string;
|
|
619
|
-
symbol: string;
|
|
620
|
-
};
|
|
621
|
-
rpcUrls: {
|
|
622
|
-
default: {
|
|
623
|
-
http: string[];
|
|
624
|
-
};
|
|
625
|
-
};
|
|
626
|
-
blockExplorers: {
|
|
627
|
-
default: {
|
|
628
|
-
name: string;
|
|
629
|
-
url: string;
|
|
630
|
-
};
|
|
631
|
-
};
|
|
632
|
-
};
|
|
633
|
-
declare const mainnet: {
|
|
634
|
-
id: number;
|
|
635
|
-
name: string;
|
|
636
|
-
nativeCurrency: {
|
|
637
|
-
decimals: number;
|
|
638
|
-
name: string;
|
|
639
|
-
symbol: string;
|
|
640
|
-
};
|
|
641
|
-
rpcUrls: {
|
|
642
|
-
default: {
|
|
643
|
-
http: string[];
|
|
644
|
-
};
|
|
645
|
-
};
|
|
646
|
-
blockExplorers: {
|
|
647
|
-
default: {
|
|
648
|
-
name: string;
|
|
649
|
-
url: string;
|
|
650
|
-
};
|
|
651
|
-
};
|
|
652
|
-
};
|
|
653
|
-
|
|
654
|
-
export { Auth, type BaseSigner, BrowserStorage, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, type SignerAdapter, type SignerType, type StorageAdapter, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|
|
648
|
+
export { Auth, type BaseSigner, BrowserStorage, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|
package/dist/core.esm.d.ts
CHANGED
|
@@ -1,4 +1,135 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { WalletClient, Account, Chain, Address, Hex, Abi } from 'viem';
|
|
2
|
+
|
|
3
|
+
interface BaseSigner {
|
|
4
|
+
getAddress(): Promise<string>;
|
|
5
|
+
signMessage(message: string): Promise<string>;
|
|
6
|
+
signTypedData?(domain: any, types: any, value: any): Promise<string>;
|
|
7
|
+
getChainId(): Promise<number>;
|
|
8
|
+
}
|
|
9
|
+
type SignerType = "viem" | "ethers" | "custom";
|
|
10
|
+
interface SignerAdapter {
|
|
11
|
+
type: SignerType;
|
|
12
|
+
signer: any;
|
|
13
|
+
getAddress(): Promise<string>;
|
|
14
|
+
signMessage(message: string): Promise<string>;
|
|
15
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
16
|
+
getChainId(): Promise<number>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Adapter for viem WalletClient
|
|
21
|
+
*/
|
|
22
|
+
declare class ViemSignerAdapter implements SignerAdapter {
|
|
23
|
+
type: SignerType;
|
|
24
|
+
signer: WalletClient;
|
|
25
|
+
constructor(signer: WalletClient);
|
|
26
|
+
getAddress(): Promise<string>;
|
|
27
|
+
signMessage(message: string): Promise<string>;
|
|
28
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
29
|
+
getChainId(): Promise<number>;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Adapter for ethers Signer (v5 and v6)
|
|
33
|
+
*/
|
|
34
|
+
declare class EthersSignerAdapter implements SignerAdapter {
|
|
35
|
+
type: SignerType;
|
|
36
|
+
signer: any;
|
|
37
|
+
constructor(signer: any);
|
|
38
|
+
getAddress(): Promise<string>;
|
|
39
|
+
signMessage(message: string): Promise<string>;
|
|
40
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
41
|
+
getChainId(): Promise<number>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Adapter for custom signer implementations
|
|
45
|
+
*/
|
|
46
|
+
declare class CustomSignerAdapter implements SignerAdapter {
|
|
47
|
+
type: SignerType;
|
|
48
|
+
signer: any;
|
|
49
|
+
constructor(signer: any);
|
|
50
|
+
getAddress(): Promise<string>;
|
|
51
|
+
signMessage(message: string): Promise<string>;
|
|
52
|
+
signTypedData(domain: any, types: any, value: any): Promise<string>;
|
|
53
|
+
getChainId(): Promise<number>;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Factory function to create appropriate adapter based on signer type
|
|
57
|
+
*/
|
|
58
|
+
declare function createSignerAdapter(signer: any): SignerAdapter;
|
|
59
|
+
|
|
60
|
+
interface StorageAdapter {
|
|
61
|
+
getItem(key: string): Promise<string | null>;
|
|
62
|
+
setItem(key: string, value: string): Promise<void>;
|
|
63
|
+
removeItem(key: string): Promise<void>;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* Browser localStorage adapter
|
|
67
|
+
*/
|
|
68
|
+
declare class BrowserStorage implements StorageAdapter {
|
|
69
|
+
getItem(key: string): Promise<string | null>;
|
|
70
|
+
setItem(key: string, value: string): Promise<void>;
|
|
71
|
+
removeItem(key: string): Promise<void>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* In-memory storage adapter for Node.js
|
|
75
|
+
*/
|
|
76
|
+
declare class MemoryStorage implements StorageAdapter {
|
|
77
|
+
private storage;
|
|
78
|
+
getItem(key: string): Promise<string | null>;
|
|
79
|
+
setItem(key: string, value: string): Promise<void>;
|
|
80
|
+
removeItem(key: string): Promise<void>;
|
|
81
|
+
clear(): void;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Create a wallet client for Node.js environment
|
|
86
|
+
* @param account The viem account
|
|
87
|
+
* @param chain The chain to use
|
|
88
|
+
* @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
|
|
89
|
+
* @returns WalletClient
|
|
90
|
+
*/
|
|
91
|
+
declare function createNodeWalletClient(account: Account, chain: Chain, rpcUrl?: string): WalletClient;
|
|
92
|
+
|
|
93
|
+
declare const testnet: {
|
|
94
|
+
id: number;
|
|
95
|
+
name: string;
|
|
96
|
+
nativeCurrency: {
|
|
97
|
+
decimals: number;
|
|
98
|
+
name: string;
|
|
99
|
+
symbol: string;
|
|
100
|
+
};
|
|
101
|
+
rpcUrls: {
|
|
102
|
+
default: {
|
|
103
|
+
http: string[];
|
|
104
|
+
};
|
|
105
|
+
};
|
|
106
|
+
blockExplorers: {
|
|
107
|
+
default: {
|
|
108
|
+
name: string;
|
|
109
|
+
url: string;
|
|
110
|
+
};
|
|
111
|
+
};
|
|
112
|
+
};
|
|
113
|
+
declare const mainnet: {
|
|
114
|
+
id: number;
|
|
115
|
+
name: string;
|
|
116
|
+
nativeCurrency: {
|
|
117
|
+
decimals: number;
|
|
118
|
+
name: string;
|
|
119
|
+
symbol: string;
|
|
120
|
+
};
|
|
121
|
+
rpcUrls: {
|
|
122
|
+
default: {
|
|
123
|
+
http: string[];
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
blockExplorers: {
|
|
127
|
+
default: {
|
|
128
|
+
name: string;
|
|
129
|
+
url: string;
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
};
|
|
2
133
|
|
|
3
134
|
interface Environment {
|
|
4
135
|
NAME: string;
|
|
@@ -175,15 +306,6 @@ declare function hasAccess(this: Origin, user: Address, tokenId: bigint): Promis
|
|
|
175
306
|
|
|
176
307
|
declare function subscriptionExpiry(this: Origin, tokenId: bigint, user: Address): Promise<bigint>;
|
|
177
308
|
|
|
178
|
-
interface OriginUsageReturnType {
|
|
179
|
-
user: {
|
|
180
|
-
multiplier: number;
|
|
181
|
-
points: number;
|
|
182
|
-
active: boolean;
|
|
183
|
-
};
|
|
184
|
-
teams: Array<any>;
|
|
185
|
-
dataSources: Array<any>;
|
|
186
|
-
}
|
|
187
309
|
interface RoyaltyInfo {
|
|
188
310
|
tokenBoundAccount: Address;
|
|
189
311
|
balance: bigint;
|
|
@@ -219,33 +341,17 @@ declare class Origin {
|
|
|
219
341
|
buyAccess: typeof buyAccess;
|
|
220
342
|
hasAccess: typeof hasAccess;
|
|
221
343
|
subscriptionExpiry: typeof subscriptionExpiry;
|
|
222
|
-
private jwt
|
|
344
|
+
private jwt?;
|
|
223
345
|
environment: Environment;
|
|
224
346
|
private viemClient?;
|
|
225
347
|
baseParentId?: bigint;
|
|
226
|
-
constructor(
|
|
227
|
-
getJwt(): string;
|
|
348
|
+
constructor(environment: Environment | string, jwt?: string, viemClient?: WalletClient, baseParentId?: bigint);
|
|
349
|
+
getJwt(): string | undefined;
|
|
228
350
|
setViemClient(client: WalletClient): void;
|
|
229
|
-
uploadFile(file: File, options?: {
|
|
230
|
-
progressCallback?: (percent: number) => void;
|
|
231
|
-
}): Promise<any>;
|
|
232
351
|
mintFile(file: File, metadata: Record<string, unknown>, license: LicenseTerms, parents?: bigint[], options?: {
|
|
233
352
|
progressCallback?: (percent: number) => void;
|
|
234
353
|
}): Promise<string | null>;
|
|
235
354
|
mintSocial(source: "spotify" | "twitter" | "tiktok", metadata: Record<string, unknown>, license: LicenseTerms): Promise<string | null>;
|
|
236
|
-
getOriginUploads(): Promise<any[] | null>;
|
|
237
|
-
/**
|
|
238
|
-
* Get the user's Origin stats (multiplier, consent, usage, etc.).
|
|
239
|
-
* @returns {Promise<OriginUsageReturnType>} A promise that resolves with the user's Origin stats.
|
|
240
|
-
*/
|
|
241
|
-
getOriginUsage(): Promise<OriginUsageReturnType>;
|
|
242
|
-
/**
|
|
243
|
-
* Set the user's consent for Origin usage.
|
|
244
|
-
* @param {boolean} consent The user's consent.
|
|
245
|
-
* @returns {Promise<void>}
|
|
246
|
-
* @throws {Error|APIError} - Throws an error if the user is not authenticated. Also throws an error if the consent is not provided.
|
|
247
|
-
*/
|
|
248
|
-
setOriginConsent(consent: boolean): Promise<void>;
|
|
249
355
|
/**
|
|
250
356
|
* Call a contract method.
|
|
251
357
|
* @param {string} contractAddress The contract address.
|
|
@@ -263,7 +369,21 @@ declare class Origin {
|
|
|
263
369
|
* @returns {Promise<any>} The result of the buyAccess call.
|
|
264
370
|
*/
|
|
265
371
|
buyAccessSmart(tokenId: bigint): Promise<any>;
|
|
372
|
+
/**
|
|
373
|
+
* Fetch the underlying data associated with a specific token ID.
|
|
374
|
+
* @param {bigint} tokenId - The token ID to fetch data for.
|
|
375
|
+
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
376
|
+
* @throws {Error} Throws an error if the data cannot be fetched.
|
|
377
|
+
*/
|
|
266
378
|
getData(tokenId: bigint): Promise<any>;
|
|
379
|
+
/**
|
|
380
|
+
* Fetch data with X402 payment handling.
|
|
381
|
+
* @param {bigint} tokenId The token ID to fetch data for.
|
|
382
|
+
* @param {any} [signer] Optional signer object for signing the X402 intent.
|
|
383
|
+
* @returns {Promise<any>} A promise that resolves with the fetched data.
|
|
384
|
+
* @throws {Error} Throws an error if the data cannot be fetched or if no signer/wallet client is provided.
|
|
385
|
+
*/
|
|
386
|
+
getDataWithX402(tokenId: bigint, signer?: any): Promise<any>;
|
|
267
387
|
/**
|
|
268
388
|
* Get the Token Bound Account (TBA) address for a specific token ID.
|
|
269
389
|
* @param {bigint} tokenId - The token ID to get the TBA address for.
|
|
@@ -311,30 +431,6 @@ declare class Origin {
|
|
|
311
431
|
claimRoyalties(tokenId: bigint, recipient?: Address, token?: Address): Promise<any>;
|
|
312
432
|
}
|
|
313
433
|
|
|
314
|
-
interface StorageAdapter {
|
|
315
|
-
getItem(key: string): Promise<string | null>;
|
|
316
|
-
setItem(key: string, value: string): Promise<void>;
|
|
317
|
-
removeItem(key: string): Promise<void>;
|
|
318
|
-
}
|
|
319
|
-
/**
|
|
320
|
-
* Browser localStorage adapter
|
|
321
|
-
*/
|
|
322
|
-
declare class BrowserStorage implements StorageAdapter {
|
|
323
|
-
getItem(key: string): Promise<string | null>;
|
|
324
|
-
setItem(key: string, value: string): Promise<void>;
|
|
325
|
-
removeItem(key: string): Promise<void>;
|
|
326
|
-
}
|
|
327
|
-
/**
|
|
328
|
-
* In-memory storage adapter for Node.js
|
|
329
|
-
*/
|
|
330
|
-
declare class MemoryStorage implements StorageAdapter {
|
|
331
|
-
private storage;
|
|
332
|
-
getItem(key: string): Promise<string | null>;
|
|
333
|
-
setItem(key: string, value: string): Promise<void>;
|
|
334
|
-
removeItem(key: string): Promise<void>;
|
|
335
|
-
clear(): void;
|
|
336
|
-
}
|
|
337
|
-
|
|
338
434
|
declare global {
|
|
339
435
|
interface Window {
|
|
340
436
|
ethereum?: any;
|
|
@@ -549,106 +645,4 @@ declare class Auth {
|
|
|
549
645
|
unlinkTelegram(): Promise<any>;
|
|
550
646
|
}
|
|
551
647
|
|
|
552
|
-
|
|
553
|
-
getAddress(): Promise<string>;
|
|
554
|
-
signMessage(message: string): Promise<string>;
|
|
555
|
-
getChainId(): Promise<number>;
|
|
556
|
-
}
|
|
557
|
-
type SignerType = "viem" | "ethers" | "custom";
|
|
558
|
-
interface SignerAdapter {
|
|
559
|
-
type: SignerType;
|
|
560
|
-
signer: any;
|
|
561
|
-
getAddress(): Promise<string>;
|
|
562
|
-
signMessage(message: string): Promise<string>;
|
|
563
|
-
getChainId(): Promise<number>;
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
/**
|
|
567
|
-
* Adapter for viem WalletClient
|
|
568
|
-
*/
|
|
569
|
-
declare class ViemSignerAdapter implements SignerAdapter {
|
|
570
|
-
type: SignerType;
|
|
571
|
-
signer: WalletClient;
|
|
572
|
-
constructor(signer: WalletClient);
|
|
573
|
-
getAddress(): Promise<string>;
|
|
574
|
-
signMessage(message: string): Promise<string>;
|
|
575
|
-
getChainId(): Promise<number>;
|
|
576
|
-
}
|
|
577
|
-
/**
|
|
578
|
-
* Adapter for ethers Signer (v5 and v6)
|
|
579
|
-
*/
|
|
580
|
-
declare class EthersSignerAdapter implements SignerAdapter {
|
|
581
|
-
type: SignerType;
|
|
582
|
-
signer: any;
|
|
583
|
-
constructor(signer: any);
|
|
584
|
-
getAddress(): Promise<string>;
|
|
585
|
-
signMessage(message: string): Promise<string>;
|
|
586
|
-
getChainId(): Promise<number>;
|
|
587
|
-
}
|
|
588
|
-
/**
|
|
589
|
-
* Adapter for custom signer implementations
|
|
590
|
-
*/
|
|
591
|
-
declare class CustomSignerAdapter implements SignerAdapter {
|
|
592
|
-
type: SignerType;
|
|
593
|
-
signer: any;
|
|
594
|
-
constructor(signer: any);
|
|
595
|
-
getAddress(): Promise<string>;
|
|
596
|
-
signMessage(message: string): Promise<string>;
|
|
597
|
-
getChainId(): Promise<number>;
|
|
598
|
-
}
|
|
599
|
-
/**
|
|
600
|
-
* Factory function to create appropriate adapter based on signer type
|
|
601
|
-
*/
|
|
602
|
-
declare function createSignerAdapter(signer: any): SignerAdapter;
|
|
603
|
-
|
|
604
|
-
/**
|
|
605
|
-
* Create a wallet client for Node.js environment
|
|
606
|
-
* @param account The viem account
|
|
607
|
-
* @param chain The chain to use
|
|
608
|
-
* @param rpcUrl Optional RPC URL (defaults to chain's default RPC)
|
|
609
|
-
* @returns WalletClient
|
|
610
|
-
*/
|
|
611
|
-
declare function createNodeWalletClient(account: Account, chain: Chain, rpcUrl?: string): WalletClient;
|
|
612
|
-
|
|
613
|
-
declare const testnet: {
|
|
614
|
-
id: number;
|
|
615
|
-
name: string;
|
|
616
|
-
nativeCurrency: {
|
|
617
|
-
decimals: number;
|
|
618
|
-
name: string;
|
|
619
|
-
symbol: string;
|
|
620
|
-
};
|
|
621
|
-
rpcUrls: {
|
|
622
|
-
default: {
|
|
623
|
-
http: string[];
|
|
624
|
-
};
|
|
625
|
-
};
|
|
626
|
-
blockExplorers: {
|
|
627
|
-
default: {
|
|
628
|
-
name: string;
|
|
629
|
-
url: string;
|
|
630
|
-
};
|
|
631
|
-
};
|
|
632
|
-
};
|
|
633
|
-
declare const mainnet: {
|
|
634
|
-
id: number;
|
|
635
|
-
name: string;
|
|
636
|
-
nativeCurrency: {
|
|
637
|
-
decimals: number;
|
|
638
|
-
name: string;
|
|
639
|
-
symbol: string;
|
|
640
|
-
};
|
|
641
|
-
rpcUrls: {
|
|
642
|
-
default: {
|
|
643
|
-
http: string[];
|
|
644
|
-
};
|
|
645
|
-
};
|
|
646
|
-
blockExplorers: {
|
|
647
|
-
default: {
|
|
648
|
-
name: string;
|
|
649
|
-
url: string;
|
|
650
|
-
};
|
|
651
|
-
};
|
|
652
|
-
};
|
|
653
|
-
|
|
654
|
-
export { Auth, type BaseSigner, BrowserStorage, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, type SignerAdapter, type SignerType, type StorageAdapter, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|
|
648
|
+
export { Auth, type BaseSigner, BrowserStorage, CustomSignerAdapter, DataStatus, EthersSignerAdapter, type LicenseTerms, MemoryStorage, Origin, type SignerAdapter, type SignerType, type StorageAdapter, ViemSignerAdapter, mainnet as campMainnet, testnet as campTestnet, createLicenseTerms, createNodeWalletClient, createSignerAdapter };
|