@audius/sdk 1.0.8-beta.1 → 1.0.9

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/types.d.ts DELETED
@@ -1,2443 +0,0 @@
1
- import * as axios from 'axios';
2
- import { AxiosResponse, AxiosRequestConfig, Method, AxiosError } from 'axios';
3
- import { PathArg } from 'proper-url-join';
4
- import * as BN from 'bn.js';
5
- import BN__default from 'bn.js';
6
- import * as Web3 from 'web3';
7
- import Web3__default from 'web3';
8
- import { AbiItem } from 'web3-utils';
9
- import * as web3_core from 'web3-core';
10
- import { Log, TransactionReceipt, HttpProvider, EventLog } from 'web3-core';
11
- import Wallet from 'ethereumjs-wallet';
12
- import abiDecoder from 'abi-decoder';
13
- import { Hedgehog } from '@audius/hedgehog';
14
- import { EIP712TypedData } from 'eth-sig-util';
15
- import * as web3_eth_contract from 'web3-eth-contract';
16
- import { Contract } from 'web3-eth-contract';
17
- import { UserImporterOptions, ImportCandidate } from 'ipfs-unixfs-importer';
18
- import * as ipfs_unixfs_importer_types_src_types from 'ipfs-unixfs-importer/types/src/types';
19
- import FormData from 'form-data';
20
-
21
- declare type Content = ReadableStream | Buffer | string;
22
- interface ImageHasher {
23
- options: UserImporterOptions;
24
- content: ImportCandidate;
25
- }
26
- interface NonImageHasher {
27
- options: UserImporterOptions;
28
- content: Uint8Array;
29
- }
30
- interface HashedImage {
31
- path: string | undefined;
32
- cid: string;
33
- size: number;
34
- }
35
-
36
- type ContractABI = {
37
- abi: AbiItem[]
38
- contractName: string
39
- }
40
-
41
- declare class Utils {
42
- static importDataContractABI(pathStr: string): ContractABI;
43
- static importEthContractABI(pathStr: string): ContractABI;
44
- static utf8ToHex(utf8Str: string): string;
45
- static padRight(hexStr: string, size: number): string;
46
- static hexToUtf8(hexStr: string): string;
47
- static keccak256(utf8Str: string): string;
48
- static isBN(number: number | string): boolean;
49
- static toBN(number: number, base?: number): BN;
50
- static BN(): typeof BN;
51
- static checkStrLen(str: string, maxLen: number, minLen?: number): void;
52
- static wait(milliseconds: number): Promise<void>;
53
- static isFQDN(url: string): boolean;
54
- static isHttps(url: string): boolean;
55
- static isHealthy(url: string): Promise<any>;
56
- static formatOptionalMultihash(multihash: string): string;
57
- static decodeMultihash(multihash: string): {
58
- digest: string;
59
- hashFn: number;
60
- size: number;
61
- };
62
- /**
63
- * Given a digest value (written on chain, obtained through AudiusABIDecoder.decodeMethod),
64
- * convert back to a IFPS CIDv0
65
- * @param multihashDigest digest value from decodeMultihash
66
- * @returns String CID value
67
- */
68
- static encodeMultihash(multihashDigest: string): string;
69
- static parseDataFromResponse(response: AxiosResponse): any;
70
- static configureWeb3(web3Provider: string, chainNetworkId: string, requiresAccount?: boolean): Promise<false | Web3.default>;
71
- static get zeroAddress(): string;
72
- static isZeroAddress(address: string): boolean;
73
- static makeUuid(): string;
74
- /**
75
- * Decodes a string id into an int. Returns null if an invalid ID.
76
- */
77
- static decodeHashId(id: string): number | null;
78
- /**
79
- * Encodes an int to a string based hashid
80
- */
81
- static encodeHashId(id: number | null): string | null;
82
- /**
83
- * If `promise` responds before `timeoutMs`,
84
- * this function returns its response; else rejects with `timeoutMessage`
85
- */
86
- static racePromiseWithTimeout(promise: Promise<void>, timeoutMs: number, timeoutMessage: string): Promise<unknown>;
87
- static fileHasher: {
88
- convertNanosToMillis(nanoSeconds: bigint): bigint;
89
- initImageHasher(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, options: ipfs_unixfs_importer_types_src_types.UserImporterOptions): ImageHasher;
90
- initNonImageHasher(content: Uint8Array, options: ipfs_unixfs_importer_types_src_types.UserImporterOptions): NonImageHasher;
91
- convertToBuffer(content: Content, logger: any): Promise<Buffer>;
92
- hashNonImages(content: Uint8Array, options?: ipfs_unixfs_importer_types_src_types.UserImporterOptions): Promise<string>;
93
- hashImages(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, options?: ipfs_unixfs_importer_types_src_types.UserImporterOptions): Promise<HashedImage[]>;
94
- generateNonImageCid(content: Content, logger?: any): Promise<string>;
95
- generateImageCids(content: ipfs_unixfs_importer_types_src_types.ImportCandidate, logger?: any): Promise<HashedImage[]>;
96
- };
97
- }
98
-
99
- declare global {
100
- interface Window {
101
- grecaptcha: {
102
- ready: (callback: () => void) => Promise<void>;
103
- execute: (siteKey: string, config: {
104
- action: string;
105
- }) => Promise<string>;
106
- };
107
- }
108
- }
109
- interface CaptchaConfig {
110
- siteKey: string;
111
- serviceKey: string;
112
- }
113
- declare class Captcha {
114
- siteKey: string;
115
- serviceKey: string;
116
- constructor({ siteKey, serviceKey }: CaptchaConfig);
117
- /**
118
- * Intended to be called by clients. Will generate a token used to calculate recaptcha score.
119
- * @param action name for this "action" for grouping
120
- */
121
- generate(action: string): Promise<string>;
122
- /**
123
- * Intended to be called by services. According to recaptcha v3 docs:
124
- * A score of 1.0 is very likely a good interaction, 0.0 is very likely a bot
125
- * @param token
126
- * @param minScore score must be >= minScore to be ok
127
- * @returns
128
- * {boolean | null} ok - whether score > minScore (false if something went wrong)
129
- * {number | null} score - the raw score [0, 1] (or null if a score was not computed)
130
- */
131
- verify(token: string, minScore?: number): Promise<{
132
- score: any;
133
- ok: boolean;
134
- hostname: any;
135
- }>;
136
- }
137
-
138
- interface ContractMethod {
139
- arguments: string[];
140
- estimateGas: (config: {
141
- from: Wallet | string | undefined;
142
- gas: number | undefined;
143
- }) => Promise<number>;
144
- _method: {
145
- name: string;
146
- inputs: Array<{
147
- type: string;
148
- }>;
149
- };
150
- encodeABI: () => string;
151
- send: <Tx>(config: {
152
- from: Wallet | string | undefined;
153
- gas: number;
154
- gasPrice?: number;
155
- }) => Tx;
156
- }
157
-
158
- declare type ServiceName = string;
159
- interface ServiceWithEndpoint {
160
- endpoint: string;
161
- spID?: string;
162
- }
163
- declare type Service = ServiceName | ServiceWithEndpoint;
164
-
165
- declare type Maybe<T> = T | undefined;
166
- declare type Nullable<T> = T | null;
167
- interface Logger {
168
- /**
169
- * Write a 'log' level log.
170
- */
171
- log: (message: any, ...optionalParams: any[]) => any;
172
- /**
173
- * Write a 'info' level log.
174
- */
175
- info: (message: any, ...optionalParams: any[]) => any;
176
- /**
177
- * Write an 'error' level log.
178
- */
179
- error: (message: any, ...optionalParams: any[]) => any;
180
- /**
181
- * Write a 'warn' level log.
182
- */
183
- warn: (message: any, ...optionalParams: any[]) => any;
184
- /**
185
- * Write a 'debug' level log.
186
- */
187
- debug?: (message: any, ...optionalParams: any[]) => any;
188
- /**
189
- * Write a 'verbose' level log.
190
- */
191
- verbose?: (message: any, ...optionalParams: any[]) => any;
192
- }
193
-
194
- declare type GetServicesInput = (() => Promise<ServiceName[]>) | ((config: {
195
- verbose: false;
196
- }) => Promise<ServiceName[]>) | ((config: {
197
- verbose: true;
198
- }) => Promise<ServiceWithEndpoint[]>) | ((config: {
199
- verbose: boolean;
200
- }) => Promise<ServiceName[] | ServiceWithEndpoint[]>);
201
- interface GetServices {
202
- (): Promise<ServiceName[]>;
203
- (config: {
204
- verbose: false;
205
- }): Promise<ServiceName[]>;
206
- (config: {
207
- verbose: true;
208
- }): Promise<ServiceWithEndpoint[]>;
209
- (config: {
210
- verbose: boolean;
211
- }): Promise<Service[]>;
212
- }
213
- interface Decision {
214
- stage: string;
215
- val?: unknown;
216
- }
217
- declare type Backup = {
218
- block_difference: number;
219
- version: string;
220
- };
221
- interface ServiceSelectionConfig {
222
- blacklist?: Set<string> | undefined | null;
223
- whitelist?: Set<string> | undefined | null;
224
- getServices: GetServicesInput;
225
- maxConcurrentRequests?: number;
226
- requestTimeout?: Maybe<number>;
227
- unhealthyTTL?: number;
228
- backupsTTL?: number;
229
- }
230
- /**
231
- * A class that assists with autoselecting services.
232
- * `ServiceSelection` is intended to be overridden with further
233
- * business logic that a particular sevice might preference.
234
- *
235
- * The general use case is as follows:
236
- *
237
- * ```
238
- *
239
- * const selector = new ServiceSelection({
240
- * getServices: ethContracts.getDiscoveryProviders()
241
- * })
242
- *
243
- * const service = await selector.select()
244
- *
245
- * ```
246
- *
247
- * This class operates by taking a list of services and
248
- * round-robin makes requests at them until a suitable one is found.
249
- *
250
- * Two types of "bad" services are defined below:
251
- * - Unhealthy: this service is bad and should not be used
252
- * - Backup: this service is bad, but if we can't find anything better, maybe use it
253
- *
254
- * Classes that extend `ServiceSelection` can choose to implement custom logic on top
255
- * of them and is generally how this class is intended to be used.
256
- */
257
- declare class ServiceSelection {
258
- blacklist: Set<string> | undefined | null;
259
- whitelist: Set<string> | undefined | null;
260
- getServices: GetServices;
261
- maxConcurrentRequests: number;
262
- requestTimeout: number;
263
- unhealthyTTL: number;
264
- backupsTTL: number;
265
- unhealthy: Set<string>;
266
- backups: Record<string, Backup>;
267
- totalAttempts: number;
268
- decisionTree: Decision[];
269
- unhealthyCleanupTimeout: NodeJS.Timeout | null;
270
- backupCleanupTimeout: NodeJS.Timeout | null;
271
- constructor({ blacklist, whitelist, getServices, maxConcurrentRequests, requestTimeout, // 30s
272
- unhealthyTTL, // 1 hour
273
- backupsTTL }: ServiceSelectionConfig);
274
- /**
275
- * Selects a service
276
- * @param reset if reset is true, clear the decision tree
277
- */
278
- select(reset?: any): Promise<any>;
279
- /**
280
- * Finds all selectable services (respecting whitelist, health checks & timeouts).
281
- * Note: this method is potentially slow.
282
- * If you need just a single service, prefer calling `.select()`
283
- * @param {boolean} verbose whether or not to return full services metadata
284
- * @param {Set} whitelist a whitelist to override the set of endpoints
285
- */
286
- findAll({ verbose, whitelist }?: {
287
- verbose?: boolean | undefined;
288
- whitelist?: Set<string> | null | undefined;
289
- }): Promise<(Service | null)[]>;
290
- /** Triggers a clean up of unhealthy and backup services so they can be retried later */
291
- triggerCleanup(): void;
292
- clearUnhealthy(): void;
293
- clearBackups(): void;
294
- /** A short-circuit. If overriden, can be used to skip selection (which could be slow) */
295
- shortcircuit(): null | string;
296
- /**
297
- * Filter out services that are in the blacklist
298
- * @param services endpoints
299
- */
300
- filterFromBlacklist(services: string[]): string[];
301
- /** Filter down services to those in the whitelist */
302
- filterToWhitelist(services: string[]): string[];
303
- /** Filter out known unhealthy services from the provided */
304
- filterOutKnownUnhealthy(services: string[]): string[];
305
- /** Given a list of services, samples maxConcurrentRequests from them */
306
- getSelectionRound(services: string[]): string[];
307
- /** Gets the total number of attempts we've made this instantiation */
308
- getTotalAttempts(): number;
309
- /** Where does the health check for this type of service live */
310
- static getHealthCheckEndpoint(service: string): string;
311
- /**
312
- * What the criteria is for a healthy service
313
- * @param response axios response
314
- * @param {{ [key: string]: string}} urlMap health check urls mapped to their cannonical url
315
- * e.g. https://discoveryprovider.audius.co/health_check => https://discoveryprovider.audius.co
316
- */
317
- isHealthy(response: AxiosResponse, _urlMap: Record<string, Service>): boolean;
318
- /** Races requests against each other with provided timeouts and health checks */
319
- race(services: string[]): Promise<{
320
- best: null;
321
- errored: (string | undefined)[];
322
- }>;
323
- /** Adds a service to the unhealthy set */
324
- addUnhealthy(service: ServiceName): void;
325
- /** Gets unhealthy set size */
326
- getUnhealthySize(): number;
327
- /**
328
- * Removes from unhealthy set
329
- * @param key service endpoint
330
- */
331
- removeFromUnhealthy(key: string): void;
332
- /**
333
- * Adds a service to the list of backups
334
- * @param service the service to add
335
- * @param response the services response. This can be used to weigh various
336
- * backups against eachother
337
- */
338
- addBackup(service: string, response: Backup): void;
339
- /**
340
- * Controls how a backup is picked. Overriding methods may choose to use the backup's response.
341
- * e.g. pick a backup that's the fewest versions behind
342
- */
343
- selectFromBackups(): Promise<string | undefined>;
344
- /**
345
- * Removes from backups
346
- * @param key service endpoint
347
- */
348
- removeFromBackups(key: string): void;
349
- /**
350
- * Returns the size of backups
351
- */
352
- getBackupsSize(): number;
353
- }
354
-
355
- declare type TimeFrame = 'day' | 'week' | 'month' | 'year' | 'millennium';
356
-
357
- declare type Web3Config$1 = {
358
- useExternalWeb3: boolean;
359
- internalWeb3Config: {
360
- web3ProviderEndpoints: string[];
361
- privateKey?: string;
362
- };
363
- externalWeb3Config?: {
364
- web3: Web3__default;
365
- ownerWallet: Wallet;
366
- };
367
- };
368
-
369
- declare class AudiusABIDecoder {
370
- static decodeMethod(contractName: string, encodedABI: string): abiDecoder.DecodedMethod;
371
- static decodeLogs(_: string, logs: Log[]): abiDecoder.DecodedLog;
372
- }
373
-
374
- declare type Web3ManagerConfig = {
375
- web3Config: Web3Config$1;
376
- identityService: IdentityService;
377
- hedgehog: Hedgehog;
378
- isServer?: boolean;
379
- };
380
- /** singleton class to be instantiated and persisted with every AudiusLibs */
381
- declare class Web3Manager {
382
- web3Config: Web3Config$1;
383
- isServer: boolean;
384
- identityService: IdentityService;
385
- hedgehog: Hedgehog;
386
- AudiusABIDecoder: typeof AudiusABIDecoder;
387
- web3: Web3__default | undefined;
388
- useExternalWeb3: boolean | undefined;
389
- ownerWallet: Wallet;
390
- constructor({ web3Config, identityService, hedgehog, isServer }: Web3ManagerConfig);
391
- init(): Promise<void>;
392
- getWeb3(): Web3__default;
393
- setWeb3(web3: Web3__default): void;
394
- getWalletAddress(): any;
395
- setOwnerWallet(ownerWallet: Wallet): void;
396
- web3IsExternal(): boolean | undefined;
397
- getOwnerWalletPrivateKey(): Buffer;
398
- /**
399
- * Signs provided string data (should be timestamped).
400
- * @param data
401
- */
402
- sign(data: string): Promise<string | undefined>;
403
- /**
404
- * Given a data payload and signature, verifies that signature is valid, and returns
405
- * Ethereum wallet address used to sign data.
406
- * @param data information that was signed
407
- * @param signature hex-formatted signature of data generated by web3 personalSign method
408
- */
409
- verifySignature(data: string, signature: string): Promise<string>;
410
- signTypedData(signatureData: EIP712TypedData): Promise<unknown>;
411
- sendTransaction(contractMethod: ContractMethod, contractRegistryKey?: string | null, contractAddress?: string | null, txRetries?: number, txGasLimit?: number): Promise<TransactionReceipt>;
412
- provider(url: string, timeout: number): HttpProvider;
413
- monkeyPatchProvider(httpProvider: HttpProvider): HttpProvider;
414
- }
415
-
416
- declare type Data = Record<string, unknown>;
417
- declare type RelayTransaction = {
418
- resp: {
419
- txHash: string;
420
- txParams: {
421
- data: string;
422
- gasLimit: string;
423
- gasPrice: number;
424
- nonce: string;
425
- to: string;
426
- value: string;
427
- };
428
- };
429
- };
430
- declare type TransactionData = {
431
- recentBlockhash: string;
432
- secpInstruction?: {
433
- publicKey: string;
434
- message: string;
435
- signature: any;
436
- recoveryId: number;
437
- };
438
- instruction: {
439
- keys: Array<{
440
- pubkey: string;
441
- isSigner?: boolean;
442
- isWritable?: boolean;
443
- }>;
444
- programId: string;
445
- data: Record<string, unknown>;
446
- };
447
- };
448
- declare type AttestationResult = {
449
- status: string;
450
- userId: string;
451
- challengeId: string;
452
- amount: number;
453
- source: string;
454
- specifier: string;
455
- error?: string;
456
- phase?: string;
457
- reason?: string;
458
- };
459
- declare type Reaction = {
460
- reactedTo: string;
461
- reactionValue: number;
462
- };
463
- declare type IdentityServiceConfig = {
464
- identityServiceEndpoint: string;
465
- captcha?: Captcha;
466
- };
467
- declare class IdentityService {
468
- identityServiceEndpoint: string;
469
- captcha: Captcha | undefined;
470
- web3Manager: Web3Manager | null;
471
- constructor({ identityServiceEndpoint, captcha }: IdentityServiceConfig);
472
- setWeb3Manager(web3Manager: Web3Manager): void;
473
- getFn(params: {
474
- lookupKey: string;
475
- username: string;
476
- }): Promise<{
477
- iv: string;
478
- cipherText: string;
479
- }>;
480
- setAuthFn(obj: Data): Promise<unknown>;
481
- setUserFn(obj: Data & {
482
- token?: string;
483
- }): Promise<unknown>;
484
- getUserEvents(walletAddress: string): Promise<unknown>;
485
- sendRecoveryInfo(obj: Record<string, unknown>): Promise<unknown>;
486
- /**
487
- * Check if an email address has been previously registered.
488
- */
489
- checkIfEmailRegistered(email: string): Promise<{
490
- exists: boolean;
491
- }>;
492
- getUserEmail(): Promise<{
493
- email: string | undefined | null;
494
- }>;
495
- /**
496
- * Associates a user with a twitter uuid.
497
- * @param uuid from the Twitter API
498
- * @param userId
499
- * @param handle User handle
500
- */
501
- associateTwitterUser(uuid: string, userId: number, handle: string): Promise<unknown>;
502
- /**
503
- * Associates a user with an instagram uuid.
504
- * @param uuid from the Instagram API
505
- * @param userId
506
- * @param handle
507
- */
508
- associateInstagramUser(uuid: string, userId: number, handle: string): Promise<unknown>;
509
- /**
510
- * Logs a track listen for a given user id.
511
- * @param trackId
512
- * @param userId
513
- * @param listenerAddress if logging this listen on behalf of another IP address, pass through here
514
- * @param signatureData if logging this listen via a 3p service, a signed piece of data proving authenticity
515
- */
516
- logTrackListen(trackId: number, userId: number, listenerAddress: string, signatureData?: {
517
- signature: string;
518
- timestamp: string;
519
- }, solanaListen?: boolean): Promise<unknown>;
520
- /**
521
- * Return listen history tracks for a given user id.
522
- * @param userId - User ID
523
- * @param limit - max # of items to return
524
- * @param offset - offset into list to return from (for pagination)
525
- */
526
- getListenHistoryTracks(userId: number, limit?: number, offset?: number): Promise<unknown>;
527
- /**
528
- * Looks up a Twitter account by handle.
529
- * @returns twitter API response.
530
- */
531
- lookupTwitterHandle(handle: string): Promise<unknown>;
532
- /**
533
- * Gets tracks trending on Audius.
534
- * @param timeFrame one of day, week, month, or year
535
- * @param idsArray track ids
536
- * @param limit
537
- * @param offset
538
- */
539
- getTrendingTracks(timeFrame?: string | null, idsArray?: number[] | null, limit?: number | null, offset?: number | null): Promise<{
540
- listenCounts: Array<{
541
- trackId: number;
542
- listens: number;
543
- }>;
544
- }>;
545
- /**
546
- * Gets listens for tracks bucketted by timeFrame.
547
- * @param timeFrame one of day, week, month, or year
548
- * @param idsArray track ids
549
- * @param startTime parseable by Date.parse
550
- * @param endTime parseable by Date.parse
551
- * @param limit
552
- * @param offset
553
- */
554
- getTrackListens(timeFrame?: TimeFrame | null, idsArray?: number[] | null, startTime?: string | null, endTime?: string | null, limit?: number | null, offset?: number | null): Promise<{
555
- bucket: Array<{
556
- trackId: number;
557
- date: string;
558
- listens: number;
559
- }>;
560
- }>;
561
- createUserRecord(email: string, walletAddress: string): Promise<unknown>;
562
- relay(contractRegistryKey: string | null | undefined, contractAddress: string | null | undefined, senderAddress: string, encodedABI: string, gasLimit: number): Promise<{
563
- receipt: TransactionReceipt;
564
- }>;
565
- ethRelay(contractAddress: string, senderAddress: Wallet | string, encodedABI: string, gasLimit: string): Promise<RelayTransaction>;
566
- wormholeRelay({ senderAddress, permit, transferTokens }: {
567
- senderAddress: string;
568
- permit: string;
569
- transferTokens: string[];
570
- }): Promise<unknown>;
571
- /**
572
- * Gets the correct wallet that will relay a txn for `senderAddress`
573
- * @param senderAddress wallet
574
- */
575
- getEthRelayer(senderAddress: string): Promise<unknown>;
576
- getRandomFeePayer(): Promise<unknown>;
577
- solanaRelay(transactionData: TransactionData): Promise<unknown>;
578
- solanaRelayRaw(transactionData: TransactionData): Promise<unknown>;
579
- getMinimumDelegationAmount(wallet: string): Promise<unknown>;
580
- updateMinimumDelegationAmount(wallet: string, minimumDelegationAmount: number, signedData: AxiosRequestConfig['headers']): Promise<unknown>;
581
- /**
582
- * Sends an attestation result to identity.
583
- *
584
- */
585
- sendAttestationResult(data: AttestationResult): Promise<unknown>;
586
- /**
587
- * Post a reaction to identity.
588
- */
589
- submitReaction(data: Reaction): Promise<unknown>;
590
- _makeRequest<T = unknown>(axiosRequestObj: AxiosRequestConfig): Promise<T>;
591
- _signData(): Promise<{
592
- "Encoded-Data-Message": string;
593
- "Encoded-Data-Signature": string | undefined;
594
- } | {
595
- "Encoded-Data-Message"?: undefined;
596
- "Encoded-Data-Signature"?: undefined;
597
- }>;
598
- }
599
-
600
- declare type EthWeb3Config = {
601
- ownerWallet: Wallet | string;
602
- providers: string[];
603
- };
604
- declare type EthWeb3ManagerConfig = {
605
- web3Config: EthWeb3Config;
606
- identityService: IdentityService;
607
- hedgehog?: Hedgehog;
608
- };
609
- /** Singleton state-manager for Audius Eth Contracts */
610
- declare class EthWeb3Manager {
611
- web3Config: EthWeb3Config;
612
- web3: Web3__default;
613
- identityService: IdentityService;
614
- hedgehog?: Hedgehog;
615
- ownerWallet: Maybe<Wallet | string>;
616
- constructor({ web3Config, identityService, hedgehog }: EthWeb3ManagerConfig);
617
- getWeb3(): Web3__default;
618
- getWalletAddress(): any;
619
- /**
620
- * Signs provided string data (should be timestamped).
621
- */
622
- sign(data: string): Promise<string>;
623
- sendTransaction(contractMethod: ContractMethod, contractAddress?: string | null, privateKey?: string | null, txRetries?: number, txGasLimit?: number | null): Promise<TransactionReceipt>;
624
- /**
625
- * Relays an eth transaction via the identity service with retries
626
- * The relay pays for the transaction fee on behalf of the user
627
- * The gas Limit is estimated if not provided
628
- */
629
- relayTransaction(contractMethod: ContractMethod, contractAddress: string, ownerWallet: Wallet | string, relayerWallet?: Wallet | string, txRetries?: number, txGasLimit?: number | null): Promise<Maybe<RelayTransaction['resp']>>;
630
- getRelayMethodParams(contractAddress: string, contractMethod: ContractMethod, relayerWallet: Wallet): Promise<{
631
- contractAddress: string;
632
- encodedABI: string;
633
- gasLimit: number;
634
- }>;
635
- }
636
-
637
- declare class AudiusTokenClient {
638
- ethWeb3Manager: EthWeb3Manager;
639
- contractABI: AbiItem[];
640
- contractAddress: string;
641
- web3: Web3__default;
642
- AudiusTokenContract: Contract;
643
- bustCacheNonce: number;
644
- constructor(ethWeb3Manager: EthWeb3Manager, contractABI: AbiItem[], contractAddress: string);
645
- bustCache(): Promise<void>;
646
- balanceOf(account: string): Promise<BN__default>;
647
- name(): Promise<any>;
648
- nonces(wallet: string): Promise<number>;
649
- transfer(recipient: string, amount: BN__default): Promise<{
650
- txReceipt: web3_core.TransactionReceipt;
651
- }>;
652
- transferFrom(owner: string, recipient: string, relayer: string, amount: BN__default): Promise<{
653
- txReceipt: Maybe<{
654
- txHash: string;
655
- txParams: {
656
- data: string;
657
- gasLimit: string;
658
- gasPrice: number;
659
- nonce: string;
660
- to: string;
661
- value: string;
662
- };
663
- }>;
664
- }>;
665
- permit(owner: string, // address
666
- spender: string, // address
667
- value: BN__default, // uint
668
- deadline: number, // uint
669
- v: number, // uint8
670
- r: Uint8Array | Buffer, // bytes32
671
- s: Uint8Array | Buffer): Promise<Maybe<{
672
- txHash: string;
673
- txParams: {
674
- data: string;
675
- gasLimit: string;
676
- gasPrice: number;
677
- nonce: string;
678
- to: string;
679
- value: string;
680
- };
681
- }>>;
682
- approve(spender: string, value: BN__default, privateKey?: null): Promise<{
683
- txReceipt: web3_core.TransactionReceipt;
684
- }>;
685
- approveProxyTokens(owner: string, spender: string, value: BN__default, relayer: string): Promise<{
686
- txReceipt: Maybe<{
687
- txHash: string;
688
- txParams: {
689
- data: string;
690
- gasLimit: string;
691
- gasPrice: number;
692
- nonce: string;
693
- to: string;
694
- value: string;
695
- };
696
- }>;
697
- }>;
698
- }
699
-
700
- declare class RegistryClient {
701
- web3Manager: EthWeb3Manager;
702
- contractABI: AbiItem[];
703
- contractAddress: string;
704
- web3: Web3__default;
705
- Registry: Contract;
706
- constructor(web3Manager: EthWeb3Manager, contractABI: AbiItem[], contractAddress: string);
707
- getContract(contractRegistryKey: string): Promise<string>;
708
- }
709
-
710
- /**
711
- * This class provides the logic to select a healthy gateway
712
- */
713
- declare class ProviderSelection extends ServiceSelection {
714
- services: string[];
715
- constructor(services?: string[]);
716
- /**
717
- * Filters out previously tried providers, and then initializes the client
718
- * (ContractClient, RegistryClient) with a healthy POA provider.
719
- *
720
- * @param client object used for making transaction calls
721
- */
722
- select(client: {
723
- web3Manager: Web3Manager | EthWeb3Manager;
724
- }): Promise<void>;
725
- getServicesSize(): number;
726
- }
727
-
728
- declare type GetRegistryAddress = (key: string) => Promise<string>;
729
- declare class ContractClient {
730
- web3Manager: Web3Manager | EthWeb3Manager;
731
- contractABI: ContractABI['abi'];
732
- contractRegistryKey: string;
733
- getRegistryAddress: GetRegistryAddress;
734
- _contractAddress: Nullable<string>;
735
- _contract: Nullable<Contract>;
736
- _isInitialized: boolean;
737
- _isInitializing: boolean;
738
- _initAttempts: number;
739
- providerSelector: Nullable<ProviderSelection>;
740
- logger: Logger;
741
- constructor(web3Manager: Web3Manager | EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, logger?: Logger, contractAddress?: Nullable<string>);
742
- /** Inits the contract if necessary */
743
- init(): Promise<void>;
744
- retryInit(selectNewEndpoint?: boolean): Promise<void>;
745
- /**
746
- * Adds current provider into unhealthy set and selects the next healthy provider
747
- */
748
- selectNewEndpoint(): Promise<void>;
749
- /** Gets the contract address and ensures that the contract has initted. */
750
- getAddress(): Promise<string>;
751
- /**
752
- * Gets a contract method and ensures that the contract has initted
753
- * The contract can then be invoked with .call() or be passed to a sendTransaction.
754
- * @param methodName the name of the contract method
755
- */
756
- getMethod(methodName: string, ...args: any[]): Promise<any>;
757
- getEthNetId(): Promise<number>;
758
- getContract(): Promise<Contract>;
759
- }
760
-
761
- declare class StakingProxyClient extends ContractClient {
762
- audiusTokenClient: AudiusTokenClient;
763
- toBN: (value: string | number) => BN__default;
764
- constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, logger?: Logger);
765
- token(): Promise<any>;
766
- totalStaked(): Promise<BN__default>;
767
- supportsHistory(): Promise<any>;
768
- totalStakedFor(account: string): Promise<BN__default>;
769
- totalStakedForAt(account: string, blockNumber: string): Promise<BN__default>;
770
- totalStakedAt(blockNumber: number): Promise<BN__default>;
771
- isStaker(account: string): Promise<any>;
772
- getDelegateManagerAddress(): Promise<any>;
773
- getClaimsManagerAddress(): Promise<any>;
774
- getServiceProviderFactoryAddress(): Promise<any>;
775
- getGovernanceAddress(): Promise<any>;
776
- getLastClaimedBlockForUser(): Promise<any>;
777
- }
778
-
779
- declare type ProposalTxn = {
780
- proposalId: string;
781
- proposer: string;
782
- submissionBlockNumber: string;
783
- targetContractRegistryKey: string;
784
- targetContractAddress: string;
785
- callValue: string;
786
- functionSignature: string;
787
- callData: string;
788
- outcome: string;
789
- numVotes: string;
790
- voteMagnitudeYes: string;
791
- voteMagnitudeNo: string;
792
- };
793
- declare class GovernanceClient extends ContractClient {
794
- audiusTokenClient: AudiusTokenClient;
795
- stakingProxyClient: StakingProxyClient;
796
- isDebug: boolean;
797
- constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, stakingProxyClient: StakingProxyClient, logger?: Logger, isDebug?: boolean);
798
- /**
799
- * Gets the function signature and call data for a contract method.
800
- * The signature and call data are passed to other contracts (like governance)
801
- * as arguments.
802
- * @param methodName
803
- * @param contractMethod
804
- */
805
- getSignatureAndCallData(methodName: string, contractMethod: ContractMethod): {
806
- signature: string;
807
- callData: string;
808
- };
809
- guardianExecuteTransaction(contractRegistryKey: string, functionSignature: string, callData: string): Promise<ContractMethod>;
810
- getVotingPeriod(): Promise<number>;
811
- setVotingPeriod(period: string): Promise<web3_core.TransactionReceipt>;
812
- getVotingQuorumPercent(): Promise<number>;
813
- getExecutionDelay(): Promise<number>;
814
- setExecutionDelay(delay: number): Promise<web3_core.TransactionReceipt>;
815
- getProposalById(id: number): Promise<{
816
- proposalId: number;
817
- proposer: string;
818
- submissionBlockNumber: number;
819
- targetContractRegistryKey: string;
820
- targetContractAddress: string;
821
- callValue: number;
822
- functionSignature: string;
823
- callData: string;
824
- outcome: number;
825
- numVotes: number;
826
- voteMagnitudeYes: BN;
827
- voteMagnitudeNo: BN;
828
- }>;
829
- getProposalTargetContractHash(id: string): Promise<any>;
830
- getProposals(queryStartBlock?: number): Promise<{
831
- proposalId: number;
832
- proposer: any;
833
- description: any;
834
- name: any;
835
- blockNumber: number;
836
- }[]>;
837
- getProposalsForAddresses(addresses: string[], queryStartBlock?: number): Promise<{
838
- proposalId: number;
839
- proposer: any;
840
- description: any;
841
- name: any;
842
- blockNumber: number;
843
- }[]>;
844
- getProposalSubmission(proposalId: number, queryStartBlock?: number): Promise<{
845
- proposalId: number;
846
- proposer: any;
847
- description: any;
848
- name: any;
849
- blockNumber: number;
850
- }>;
851
- getInProgressProposals(): Promise<any>;
852
- submitProposal({ targetContractRegistryKey, callValue, functionSignature, callData, // array of args, e.g. [slashAmount, targetAddress]
853
- name, description }: {
854
- targetContractRegistryKey: string;
855
- callValue: string;
856
- functionSignature: string;
857
- callData: string[];
858
- name: string;
859
- description: string;
860
- }): Promise<any>;
861
- submitVote({ proposalId, vote }: {
862
- proposalId: number;
863
- vote: string;
864
- }): Promise<void>;
865
- updateVote({ proposalId, vote }: {
866
- proposalId: number;
867
- vote: string;
868
- }): Promise<void>;
869
- evaluateProposalOutcome(proposalId: number): Promise<web3_core.TransactionReceipt>;
870
- getProposalEvaluation(proposalId: number, queryStartBlock?: number): Promise<web3_eth_contract.EventData[]>;
871
- getVotes({ proposalId, queryStartBlock }: {
872
- proposalId: number;
873
- queryStartBlock: number;
874
- }): Promise<{
875
- proposalId: number;
876
- voter: any;
877
- vote: number;
878
- voterStake: BN;
879
- blockNumber: number;
880
- }[]>;
881
- getVoteUpdates({ proposalId, queryStartBlock }: {
882
- proposalId: number;
883
- queryStartBlock: number;
884
- }): Promise<{
885
- proposalId: number;
886
- voter: any;
887
- vote: number;
888
- voterStake: BN;
889
- blockNumber: number;
890
- }[]>;
891
- getVoteSubmissionsByAddress({ addresses, queryStartBlock }: {
892
- addresses: string[];
893
- queryStartBlock: number;
894
- }): Promise<{
895
- proposalId: number;
896
- voter: any;
897
- vote: number;
898
- voterStake: BN;
899
- blockNumber: number;
900
- }[]>;
901
- getVoteUpdatesByAddress({ addresses, queryStartBlock }: {
902
- addresses: string[];
903
- queryStartBlock: number;
904
- }): Promise<{
905
- proposalId: number;
906
- voter: any;
907
- vote: number;
908
- voterStake: BN;
909
- blockNumber: number;
910
- }[]>;
911
- getVoteByProposalAndVoter({ proposalId, voterAddress }: {
912
- proposalId: number[];
913
- voterAddress: number;
914
- }): Promise<number>;
915
- /**
916
- * ABI encodes argument types and values together into one encoded string
917
- */
918
- abiEncode(types: string[], values: string[]): string;
919
- toBN(val: string): BN;
920
- /**
921
- * Prune off extraneous fields from proposal returned by txn
922
- */
923
- formatProposal(proposal: ProposalTxn): {
924
- proposalId: number;
925
- proposer: string;
926
- submissionBlockNumber: number;
927
- targetContractRegistryKey: string;
928
- targetContractAddress: string;
929
- callValue: number;
930
- functionSignature: string;
931
- callData: string;
932
- outcome: number;
933
- numVotes: number;
934
- voteMagnitudeYes: BN;
935
- voteMagnitudeNo: BN;
936
- };
937
- /**
938
- * Formats a proposal event
939
- */
940
- formatProposalEvent(proposalEvent: EventLog): {
941
- proposalId: number;
942
- proposer: any;
943
- description: any;
944
- name: any;
945
- blockNumber: number;
946
- };
947
- /**
948
- * Prune off extraneous fields from vote event
949
- */
950
- formatVote(voteEvent: EventLog): {
951
- proposalId: number;
952
- voter: any;
953
- vote: number;
954
- voterStake: BN;
955
- blockNumber: number;
956
- };
957
- /**
958
- *
959
- * @param {Number} proposalId id of the governance proposal
960
- * @returns {BN} amount of tokens in wei required to reach quorum
961
- */
962
- calculateQuorum(proposalId: number): Promise<any>;
963
- }
964
-
965
- /**
966
- * Contract class that extends a ContractClient and provides an interface
967
- * to retrieve governed methods that cannot be executed directly.
968
- */
969
- declare class GovernedContractClient extends ContractClient {
970
- governanceClient: GovernanceClient;
971
- constructor(web3Manager: Web3Manager | EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, governanceClient: GovernanceClient, logger?: Logger);
972
- /**
973
- * Gets a governed version of a method and allows a single transaction
974
- * to be sent to the governance client with the appropriate payload.
975
- * Similar to `getMethod`
976
- */
977
- getGovernedMethod(methodName: string, ...args: unknown[]): Promise<ContractMethod>;
978
- }
979
-
980
- declare class ServiceTypeManagerClient extends GovernedContractClient {
981
- /**
982
- *
983
- * @param serviceType Type of service to set the version, either `discovery-node` or `content-node`
984
- * @param serviceVersion Version string to set on chain
985
- * @param privateKey Optional privateKey to pass along to web3Manager sendTransaction
986
- * @param dryRun Optional parameter to return the generated parameters without sending tx
987
- * @returns comma-separated String of serviceType and serviceVersion if dryRun; else response from web3Manager.sendTransaction
988
- */
989
- setServiceVersion(serviceType: string, serviceVersion: string, privateKey?: string | null, dryRun?: boolean): Promise<string | web3_core.TransactionReceipt>;
990
- addServiceType(serviceType: string, serviceTypeMin: string, serviceTypeMax: string, privateKey?: string | null): Promise<web3_core.TransactionReceipt>;
991
- getValidServiceTypes(): Promise<string[]>;
992
- getCurrentVersion(serviceType: string): Promise<string>;
993
- getVersion(serviceType: string, serviceTypeIndex: number): Promise<string>;
994
- getNumberOfVersions(serviceType: string): Promise<number>;
995
- /**
996
- * @notice Add a new service type
997
- * @returns {
998
- * isValid: Is the types type is isValid
999
- * minStake: minimum stake for service type
1000
- * maxStake: minimum stake for service type
1001
- * }
1002
- */
1003
- getServiceTypeInfo(serviceType: string): Promise<{
1004
- isValid: any;
1005
- minStake: BN;
1006
- maxStake: BN;
1007
- }>;
1008
- }
1009
-
1010
- declare type GetEvent$1 = {
1011
- serviceType: string;
1012
- owner: string;
1013
- queryStartBlock: number;
1014
- };
1015
- declare class ServiceProviderFactoryClient extends GovernedContractClient {
1016
- audiusTokenClient: AudiusTokenClient;
1017
- stakingProxyClient: StakingProxyClient;
1018
- isDebug: boolean;
1019
- constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, stakingProxyClient: StakingProxyClient, governanceClient: GovernanceClient, logger?: Logger, isDebug?: boolean);
1020
- registerWithDelegate(serviceType: string, endpoint: string, amount: number | string | BN__default, delegateOwnerWallet: string): Promise<{
1021
- txReceipt: web3_core.TransactionReceipt;
1022
- spID: number;
1023
- serviceType: string;
1024
- owner: any;
1025
- endpoint: any;
1026
- tokenApproveReceipt: {
1027
- txReceipt: web3_core.TransactionReceipt;
1028
- };
1029
- }>;
1030
- register(serviceType: string, endpoint: string, amount: BN__default): Promise<{
1031
- txReceipt: web3_core.TransactionReceipt;
1032
- spID: number;
1033
- serviceType: string;
1034
- owner: any;
1035
- endpoint: any;
1036
- tokenApproveReceipt: {
1037
- txReceipt: web3_core.TransactionReceipt;
1038
- };
1039
- }>;
1040
- getRegisteredServiceProviderEvents({ serviceType, owner, queryStartBlock }: GetEvent$1): Promise<{
1041
- blockNumber: number;
1042
- spID: number;
1043
- serviceType: string;
1044
- owner: any;
1045
- endpoint: any;
1046
- stakeAmount: BN__default;
1047
- }[]>;
1048
- getDeregisteredServiceProviderEvents({ serviceType, owner, queryStartBlock }: GetEvent$1): Promise<{
1049
- blockNumber: number;
1050
- spID: number;
1051
- serviceType: string;
1052
- owner: any;
1053
- endpoint: any;
1054
- stakeAmount: BN__default;
1055
- }[]>;
1056
- getIncreasedStakeEvents({ owner, queryStartBlock }: {
1057
- owner: string;
1058
- queryStartBlock: number;
1059
- }): Promise<{
1060
- blockNumber: number;
1061
- owner: any;
1062
- increaseAmount: BN__default;
1063
- newStakeAmount: BN__default;
1064
- }[]>;
1065
- getDecreasedStakeEvaluatedEvents({ owner, queryStartBlock }: {
1066
- owner: string;
1067
- queryStartBlock: number;
1068
- }): Promise<{
1069
- blockNumber: number;
1070
- owner: any;
1071
- decreaseAmount: BN__default;
1072
- newStakeAmount: BN__default;
1073
- }[]>;
1074
- getDecreasedStakeRequestedEvents({ owner, queryStartBlock }: {
1075
- owner: string;
1076
- queryStartBlock: number;
1077
- }): Promise<{
1078
- blockNumber: number;
1079
- owner: any;
1080
- decreaseAmount: BN__default;
1081
- lockupExpiryBlock: number;
1082
- }[]>;
1083
- getDecreasedStakeCancelledEvents({ owner, queryStartBlock }: {
1084
- owner: string;
1085
- queryStartBlock: number;
1086
- }): Promise<{
1087
- blockNumber: number;
1088
- owner: any;
1089
- decreaseAmount: BN__default;
1090
- lockupExpiryBlock: number;
1091
- }[]>;
1092
- getDeregisteredService({ serviceType, spID, queryStartBlock }: {
1093
- serviceType: string;
1094
- spID: string;
1095
- queryStartBlock: number;
1096
- }): Promise<{
1097
- endpoint: string;
1098
- delegateOwnerWallet: string;
1099
- owner?: string | undefined;
1100
- }>;
1101
- increaseStake(amount: BN__default): Promise<{
1102
- txReceipt: web3_core.TransactionReceipt;
1103
- tokenApproveReceipt: {
1104
- txReceipt: web3_core.TransactionReceipt;
1105
- };
1106
- }>;
1107
- /**
1108
- * Makes a request to decrease stake
1109
- * @param amount
1110
- * @returns decrease stake lockup expiry block
1111
- */
1112
- requestDecreaseStake(amount: BN__default): Promise<number>;
1113
- /**
1114
- * Gets the pending decrease stake request for a given account
1115
- * @param account wallet address to fetch for
1116
- */
1117
- getPendingDecreaseStakeRequest(account: string): Promise<{
1118
- amount: BN__default;
1119
- lockupExpiryBlock: number;
1120
- }>;
1121
- /**
1122
- * Gets the pending decrease stake lockup duration
1123
- */
1124
- getDecreaseStakeLockupDuration(): Promise<number>;
1125
- /**
1126
- * Gets the deployer cut lockup duration
1127
- */
1128
- getDeployerCutLockupDuration(): Promise<number>;
1129
- /**
1130
- * Cancels the pending decrease stake request
1131
- * @param account wallet address to cancel request for
1132
- */
1133
- cancelDecreaseStakeRequest(account: string): Promise<void>;
1134
- /**
1135
- * Fetches the pending decrease stake lockup expiry block for a user
1136
- * @param account wallet address to fetch for
1137
- */
1138
- getLockupExpiry(account: string): Promise<number>;
1139
- decreaseStake(): Promise<{
1140
- txReceipt: web3_core.TransactionReceipt;
1141
- }>;
1142
- /**
1143
- * Deregisters a service
1144
- * @param serviceType
1145
- * @param endpoint
1146
- */
1147
- deregister(serviceType: string, endpoint: string): Promise<{
1148
- txReceipt: web3_core.TransactionReceipt;
1149
- spID: number;
1150
- serviceType: string;
1151
- owner: any;
1152
- endpoint: any;
1153
- }>;
1154
- getTotalServiceTypeProviders(serviceType: string): Promise<number>;
1155
- getServiceProviderIdFromEndpoint(endpoint: string): Promise<number>;
1156
- getServiceProviderInfo(serviceType: string, serviceId: number): Promise<{
1157
- owner: any;
1158
- endpoint: any;
1159
- spID: number;
1160
- type: string;
1161
- blockNumber: number;
1162
- delegateOwnerWallet: any;
1163
- }>;
1164
- getServiceEndpointInfo(serviceType: string, serviceId: number): Promise<{
1165
- owner: any;
1166
- endpoint: any;
1167
- spID: number;
1168
- type: string;
1169
- blockNumber: number;
1170
- delegateOwnerWallet: any;
1171
- }>;
1172
- getServiceProviderInfoFromEndpoint(endpoint: string): Promise<{
1173
- owner: any;
1174
- endpoint: any;
1175
- spID: number;
1176
- type: string;
1177
- blockNumber: number;
1178
- delegateOwnerWallet: any;
1179
- }>;
1180
- getServiceProviderIdsFromAddress(ownerAddress: string, serviceType: string): Promise<number[]>;
1181
- getServiceProviderIdFromAddress(ownerAddress: string, serviceType: string): Promise<number>;
1182
- getServiceEndpointInfoFromAddress(ownerAddress: string, serviceType: string): Promise<{
1183
- owner: any;
1184
- endpoint: any;
1185
- spID: number;
1186
- type: string;
1187
- blockNumber: number;
1188
- delegateOwnerWallet: any;
1189
- }[]>;
1190
- /**
1191
- * Returns all service providers of requested `serviceType`
1192
- * Returns array of objects with schema { blockNumber, delegateOwnerWallet, endpoint, owner, spID, type }
1193
- */
1194
- getServiceProviderList(serviceType: string): Promise<{
1195
- owner: any;
1196
- endpoint: any;
1197
- spID: number;
1198
- type: string;
1199
- blockNumber: number;
1200
- delegateOwnerWallet: any;
1201
- }[]>;
1202
- updateDecreaseStakeLockupDuration(duration: string): Promise<web3_core.TransactionReceipt>;
1203
- getServiceProviderDetails(serviceProviderAddress: string): Promise<{
1204
- deployerCut: number;
1205
- deployerStake: BN__default;
1206
- maxAccountStake: BN__default;
1207
- minAccountStake: BN__default;
1208
- numberOfEndpoints: number;
1209
- validBounds: any;
1210
- }>;
1211
- updateDelegateOwnerWallet(serviceType: string, endpoint: string, updatedDelegateOwnerWallet: string): Promise<web3_core.TransactionReceipt>;
1212
- updateEndpoint(serviceType: string, oldEndpoint: string, newEndpoint: string): Promise<web3_core.TransactionReceipt>;
1213
- requestUpdateDeployerCut(ownerAddress: string, deployerCut: string): Promise<web3_core.TransactionReceipt>;
1214
- getPendingUpdateDeployerCutRequest(ownerAddress: string): Promise<{
1215
- lockupExpiryBlock: number;
1216
- newDeployerCut: number;
1217
- }>;
1218
- cancelUpdateDeployerCut(ownerAddress: string): Promise<web3_core.TransactionReceipt>;
1219
- updateDeployerCut(ownerAddress: string): Promise<web3_core.TransactionReceipt>;
1220
- updateServiceProviderStake(ownerAddress: string, newAmount: string): Promise<web3_core.TransactionReceipt>;
1221
- }
1222
-
1223
- declare type GetEvent = {
1224
- delegator: string;
1225
- serviceProvider: string;
1226
- queryStartBlock: number;
1227
- };
1228
- declare class DelegateManagerClient extends GovernedContractClient {
1229
- audiusTokenClient: AudiusTokenClient;
1230
- stakingProxyClient: StakingProxyClient;
1231
- constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, stakingProxyClient: StakingProxyClient, governanceClient: GovernanceClient, logger?: Logger);
1232
- delegateStake(targetSP: string, amount: BN__default): Promise<{
1233
- txReceipt: web3_core.TransactionReceipt;
1234
- tokenApproveReceipt: {
1235
- txReceipt: web3_core.TransactionReceipt;
1236
- };
1237
- delegator: any;
1238
- serviceProvider: any;
1239
- increaseAmount: BN__default;
1240
- }>;
1241
- getIncreaseDelegateStakeEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1242
- blockNumber: number;
1243
- delegator: any;
1244
- increaseAmount: BN__default;
1245
- serviceProvider: any;
1246
- }[]>;
1247
- getDecreaseDelegateStakeEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1248
- blockNumber: number;
1249
- delegator: any;
1250
- amount: BN__default;
1251
- serviceProvider: any;
1252
- }[]>;
1253
- getUndelegateStakeRequestedEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1254
- blockNumber: number;
1255
- lockupExpiryBlock: number;
1256
- delegator: any;
1257
- amount: BN__default;
1258
- serviceProvider: any;
1259
- }[]>;
1260
- getUndelegateStakeCancelledEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1261
- blockNumber: number;
1262
- delegator: any;
1263
- amount: BN__default;
1264
- serviceProvider: any;
1265
- }[]>;
1266
- getClaimEvents({ claimer, queryStartBlock }: {
1267
- claimer: string;
1268
- queryStartBlock: number;
1269
- }): Promise<{
1270
- blockNumber: number;
1271
- claimer: any;
1272
- rewards: BN__default;
1273
- newTotal: BN__default;
1274
- }[]>;
1275
- getSlashEvents({ target, queryStartBlock }: {
1276
- target: string;
1277
- queryStartBlock: number;
1278
- }): Promise<{
1279
- blockNumber: number;
1280
- target: any;
1281
- amount: BN__default;
1282
- newTotal: BN__default;
1283
- }[]>;
1284
- getDelegatorRemovedEvents({ target, queryStartBlock }: {
1285
- target: string;
1286
- queryStartBlock: number;
1287
- }): Promise<{
1288
- blockNumber: number;
1289
- serviceProvider: any;
1290
- delegator: any;
1291
- unstakedAmount: BN__default;
1292
- }[]>;
1293
- requestUndelegateStake(targetSP: string, amount: BN__default): Promise<web3_core.TransactionReceipt>;
1294
- cancelUndelegateStakeRequest(): Promise<web3_core.TransactionReceipt>;
1295
- undelegateStake(): Promise<{
1296
- txReceipt: web3_core.TransactionReceipt;
1297
- delegator: any;
1298
- serviceProvider: any;
1299
- decreaseAmount: BN__default;
1300
- }>;
1301
- claimRewards(serviceProvider: string, txRetries?: number): Promise<web3_core.TransactionReceipt>;
1302
- requestRemoveDelegator(serviceProvider: string, delegator: string): Promise<web3_core.TransactionReceipt>;
1303
- cancelRemoveDelegatorRequest(serviceProvider: string, delegator: string): Promise<web3_core.TransactionReceipt>;
1304
- removeDelegator(serviceProvider: string, delegator: string): Promise<{
1305
- txReceipt: web3_core.TransactionReceipt;
1306
- delegator: any;
1307
- serviceProvider: any;
1308
- unstakedAmount: BN__default;
1309
- }>;
1310
- getDelegatorsList(serviceProvider: string): Promise<any>;
1311
- getTotalDelegatedToServiceProvider(serviceProvider: string): Promise<BN__default>;
1312
- getTotalDelegatorStake(delegator: string): Promise<BN__default>;
1313
- getTotalLockedDelegationForServiceProvider(serviceProvider: string): Promise<BN__default>;
1314
- getDelegatorStakeForServiceProvider(delegator: string, serviceProvider: string): Promise<BN__default>;
1315
- getPendingUndelegateRequest(delegator: string): Promise<{
1316
- amount: BN__default;
1317
- lockupExpiryBlock: number;
1318
- target: any;
1319
- }>;
1320
- getPendingRemoveDelegatorRequest(serviceProvider: string, delegator: string): Promise<{
1321
- lockupExpiryBlock: number;
1322
- }>;
1323
- getUndelegateLockupDuration(): Promise<number>;
1324
- getMaxDelegators(): Promise<number>;
1325
- getMinDelegationAmount(): Promise<BN__default>;
1326
- getRemoveDelegatorLockupDuration(): Promise<number>;
1327
- getRemoveDelegatorEvalDuration(): Promise<number>;
1328
- getGovernanceAddress(): Promise<any>;
1329
- getServiceProviderFactoryAddress(): Promise<any>;
1330
- getClaimsManagerAddress(): Promise<any>;
1331
- getStakingAddress(): Promise<any>;
1332
- getSPMinDelegationAmount({ serviceProvider }: {
1333
- serviceProvider: string;
1334
- }): Promise<BN__default>;
1335
- updateSPMinDelegationAmount({ serviceProvider, amount }: {
1336
- serviceProvider: string;
1337
- amount: BN__default;
1338
- }): Promise<web3_core.TransactionReceipt>;
1339
- updateRemoveDelegatorLockupDuration(duration: string): Promise<web3_core.TransactionReceipt>;
1340
- updateUndelegateLockupDuration(duration: string): Promise<web3_core.TransactionReceipt>;
1341
- }
1342
-
1343
- declare class ClaimsManagerClient extends ContractClient {
1344
- web3Manager: EthWeb3Manager;
1345
- getFundingRoundBlockDiff(): Promise<number>;
1346
- getLastFundedBlock(): Promise<number>;
1347
- getFundsPerRound(): Promise<BN>;
1348
- getTotalClaimedInRound(): Promise<BN>;
1349
- getGovernanceAddress(): Promise<any>;
1350
- getServiceProviderFactoryAddress(): Promise<any>;
1351
- getDelegateManagerAddress(): Promise<any>;
1352
- getStakingAddress(): Promise<any>;
1353
- claimPending(address: string): Promise<any>;
1354
- initiateRound(txRetries?: number): Promise<web3_core.TransactionReceipt>;
1355
- getClaimProcessedEvents({ claimer, queryStartBlock }: {
1356
- claimer: string;
1357
- queryStartBlock: number;
1358
- }): Promise<{
1359
- blockNumber: number;
1360
- claimer: any;
1361
- rewards: BN;
1362
- oldTotal: BN;
1363
- newTotal: BN;
1364
- }[]>;
1365
- }
1366
-
1367
- declare class ClaimDistributionClient extends ContractClient {
1368
- /**
1369
- * Calls the contract method to check if the claim index has been claimed
1370
- */
1371
- isClaimed(index: number): Promise<any>;
1372
- /**
1373
- * Proxies the calls the contract method to make a claim
1374
- * @param index
1375
- * @param account
1376
- * @param amount
1377
- * @param merkleProof
1378
- * @returns transaction
1379
- */
1380
- claim(index: number, account: string, amount: BN__default, merkleProof: string[]): Promise<Maybe<{
1381
- txHash: string;
1382
- txParams: {
1383
- /**
1384
- * Proxies the calls the contract method to make a claim
1385
- * @param index
1386
- * @param account
1387
- * @param amount
1388
- * @param merkleProof
1389
- * @returns transaction
1390
- */
1391
- data: string;
1392
- gasLimit: string;
1393
- gasPrice: number;
1394
- nonce: string;
1395
- to: string;
1396
- value: string;
1397
- };
1398
- }>>;
1399
- }
1400
-
1401
- declare class WormholeClient {
1402
- ethWeb3Manager: EthWeb3Manager;
1403
- contractABI: ContractABI['abi'];
1404
- contractAddress: string;
1405
- web3: Web3__default;
1406
- audiusTokenClient: AudiusTokenClient;
1407
- WormholeContract: Contract;
1408
- constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractAddress: string, audiusTokenClient: AudiusTokenClient);
1409
- nonces(wallet: string): Promise<number>;
1410
- initialize(fromAcct: string, wormholeAddress: string, relayer: string): Promise<{
1411
- txReceipt: Maybe<{
1412
- txHash: string;
1413
- txParams: {
1414
- data: string;
1415
- gasLimit: string;
1416
- gasPrice: number;
1417
- nonce: string;
1418
- to: string;
1419
- value: string;
1420
- };
1421
- }>;
1422
- }>;
1423
- /**
1424
- * Transfers in eth from the user's wallet to the wormhole contract and
1425
- * specifies a solana wallet to realized the tokens in SOL
1426
- */
1427
- transferTokens(fromAcct: string, amount: BN__default, chainId: number, solanaAccount: string, arbiterFee: string, deadline: string, signedDigest: {
1428
- v: string;
1429
- r: string;
1430
- s: string;
1431
- }, relayer: string): Promise<Maybe<{
1432
- txHash: string;
1433
- txParams: {
1434
- data: string;
1435
- gasLimit: string;
1436
- gasPrice: number;
1437
- nonce: string;
1438
- to: string;
1439
- value: string;
1440
- };
1441
- }>>;
1442
- }
1443
-
1444
- declare class EthRewardsManagerClient extends ContractClient {
1445
- token(): Promise<any>;
1446
- getGovernanceAddress(): Promise<any>;
1447
- getRecipientAddress(): Promise<any>;
1448
- getAntiAbuseOracleAddresses(): Promise<any>;
1449
- }
1450
-
1451
- declare class TrustedNotifierManagerClient extends GovernedContractClient {
1452
- /**
1453
- * Register Trusted Notifier with specified fields (wallet, endpoint, email)
1454
- * @notice Only callable by Governance contract
1455
- * @notice All fields must be unique and non-falsey
1456
- * @notice New Trusted Notifier is assigned an auto-incremented integer ID
1457
- * @returns Newly assigned integer ID
1458
- */
1459
- registerNotifier(wallet: string, endpoint: string, email: string, privateKey?: string | null): Promise<web3_core.TransactionReceipt>;
1460
- /**
1461
- * Deregister Trusted Notifier associated with wallet
1462
- * @notice Only callable by Governance contract or wallet
1463
- * @returns ID of deregistered Trusted Notifier
1464
- */
1465
- deregisterNotifier(wallet: string, privateKey?: string | null): Promise<web3_core.TransactionReceipt>;
1466
- getLatestNotifierID(): Promise<number>;
1467
- /**
1468
- * Returns all TrustedNotifier info associated with ID
1469
- */
1470
- getNotifierForID(ID: string): Promise<{
1471
- wallet: any;
1472
- endpoint: any;
1473
- email: any;
1474
- }>;
1475
- /**
1476
- * Returns all TrustedNotifier info associated with wallet
1477
- */
1478
- getNotifierForWallet(wallet: string): Promise<{
1479
- ID: any;
1480
- endpoint: any;
1481
- email: any;
1482
- }>;
1483
- /**
1484
- * Returns all TrustedNotifier info associated with endpoint
1485
- */
1486
- getNotifierForEndpoint(endpoint: string): Promise<{
1487
- ID: any;
1488
- wallet: any;
1489
- email: any;
1490
- }>;
1491
- /**
1492
- * Returns all TrustedNotifier info associated with email
1493
- */
1494
- getNotifierForEmail(email: string): Promise<{
1495
- ID: any;
1496
- wallet: any;
1497
- endpoint: any;
1498
- }>;
1499
- }
1500
-
1501
- declare type EthContractsConfig = {
1502
- ethWeb3Manager: EthWeb3Manager;
1503
- tokenContractAddress: string;
1504
- registryAddress: string;
1505
- claimDistributionContractAddress: string;
1506
- wormholeContractAddress: string;
1507
- isServer?: boolean;
1508
- logger?: Logger;
1509
- isDebug?: boolean;
1510
- };
1511
- declare class EthContracts {
1512
- ethWeb3Manager: EthWeb3Manager;
1513
- tokenContractAddress: string;
1514
- claimDistributionContractAddress: string;
1515
- wormholeContractAddress: string;
1516
- registryAddress: string;
1517
- isServer: boolean;
1518
- logger: Logger;
1519
- isDebug: boolean;
1520
- expectedServiceVersions: null | string[];
1521
- AudiusTokenClient: AudiusTokenClient;
1522
- RegistryClient: RegistryClient;
1523
- StakingProxyClient: StakingProxyClient;
1524
- GovernanceClient: GovernanceClient;
1525
- ClaimsManagerClient: ClaimsManagerClient;
1526
- EthRewardsManagerClient: EthRewardsManagerClient;
1527
- ServiceTypeManagerClient: ServiceTypeManagerClient;
1528
- ServiceProviderFactoryClient: ServiceProviderFactoryClient;
1529
- DelegateManagerClient: DelegateManagerClient;
1530
- ClaimDistributionClient: ClaimDistributionClient | undefined;
1531
- WormholeClient: WormholeClient;
1532
- TrustedNotifierManagerClient: TrustedNotifierManagerClient;
1533
- contractClients: ContractClient[];
1534
- _regressedMode: boolean;
1535
- contracts: Record<string, string> | undefined;
1536
- contractAddresses: Record<string, string> | undefined;
1537
- constructor({ ethWeb3Manager, tokenContractAddress, registryAddress, claimDistributionContractAddress, wormholeContractAddress, isServer, logger, isDebug }: EthContractsConfig);
1538
- init(): Promise<void>;
1539
- /**
1540
- * Estabilishes that connection to discovery providers has regressed
1541
- */
1542
- enterRegressedMode(): void;
1543
- isInRegressedMode(): boolean;
1544
- getRegistryAddressForContract(contractName: string): Promise<string>;
1545
- getCurrentVersion(serviceType: string): Promise<string>;
1546
- getExpectedServiceVersions(): Promise<Record<string, string | null | undefined>>;
1547
- /**
1548
- * Determine whether major and minor versions match for two version strings
1549
- * Version string 2 must have equivalent major/minor versions and a patch >= version1
1550
- * @param version1 string 1
1551
- * @param version2 string 2
1552
- */
1553
- isValidSPVersion(version1: string, version2: string): boolean;
1554
- /**
1555
- * Determines whether the major and minor versions are equal
1556
- * @param version1 string 1
1557
- * @param version2 string 2
1558
- */
1559
- hasSameMajorAndMinorVersion(version1: string, version2: string): boolean;
1560
- getServiceProviderList(spType: string): Promise<{
1561
- owner: any;
1562
- endpoint: any;
1563
- spID: number;
1564
- type: string;
1565
- blockNumber: number;
1566
- delegateOwnerWallet: any;
1567
- }[]>;
1568
- getNumberOfVersions(spType: string): Promise<number>;
1569
- getVersion(spType: string, queryIndex: number): Promise<string>;
1570
- getServiceTypeInfo(spType: string): Promise<{
1571
- isValid: any;
1572
- minStake: BN;
1573
- maxStake: BN;
1574
- }>;
1575
- }
1576
-
1577
- declare type DiscoveryProviderSelectionConfig = Omit<ServiceSelectionConfig, 'getServices'> & {
1578
- reselectTimeout?: number;
1579
- selectionCallback?: (endpoint: string, decisionTree: Decision[]) => void;
1580
- monitoringCallbacks?: {
1581
- healthCheck: (config: Record<string, unknown>) => void;
1582
- request: (config: Record<string, unknown>) => void;
1583
- };
1584
- unhealthySlotDiffPlays?: number;
1585
- unhealthyBlockDiff?: number;
1586
- };
1587
- declare class DiscoveryProviderSelection extends ServiceSelection {
1588
- currentVersion: string;
1589
- ethContracts: EthContracts;
1590
- reselectTimeout: Maybe<number>;
1591
- selectionCallback: Maybe<DiscoveryProviderSelectionConfig['selectionCallback']>;
1592
- monitoringCallbacks: NonNullable<DiscoveryProviderSelectionConfig['monitoringCallbacks']> | {};
1593
- unhealthySlotDiffPlays: Nullable<number>;
1594
- unhealthyBlockDiff: number;
1595
- _regressedMode: boolean;
1596
- validVersions: Nullable<string[]>;
1597
- constructor(config: DiscoveryProviderSelectionConfig, ethContracts: EthContracts);
1598
- /** Retrieves a cached discovery provider from localstorage */
1599
- getCached(): any;
1600
- /** Clears any cached discovery provider from localstorage */
1601
- clearCached(): void;
1602
- /** Sets a cached discovery provider in localstorage */
1603
- setCached(endpoint: string): void;
1604
- /** Allows the selection take a shortcut if there's a cached provider */
1605
- shortcircuit(): any;
1606
- select(): Promise<any>;
1607
- /**
1608
- * Checks whether a given response is healthy:
1609
- * - Not behind in blocks
1610
- * - 200 response
1611
- * - Current version
1612
- *
1613
- * Other responses are collected in `this.backups` if
1614
- * - Behind by only a patch version
1615
- *
1616
- * @param response axios response
1617
- * @param urlMap health check urls mapped to their cannonical url
1618
- * e.g. https://discoveryprovider.audius.co/health_check => https://discoveryprovider.audius.co
1619
- */
1620
- isHealthy(response: AxiosResponse, urlMap: Record<string, string>): boolean;
1621
- /**
1622
- * Estabilishes that connection to discovery providers has regressed
1623
- */
1624
- enterRegressedMode(): void;
1625
- setUnhealthyBlockDiff(updatedDiff?: number): void;
1626
- setUnhealthySlotDiffPlays(updatedDiff: number): void;
1627
- isInRegressedMode(): boolean;
1628
- /**
1629
- * In the case of no "healthy" services, we resort to backups in the following order:
1630
- * 1. Pick the most recent (patch) version that's not behind
1631
- * 2. Pick the least behind provider that is a valid patch version and enter "regressed mode"
1632
- * 3. Pick `null`
1633
- */
1634
- selectFromBackups(): Promise<string>;
1635
- }
1636
-
1637
- declare type CurrentUser = {
1638
- user_id: string;
1639
- wallet: string;
1640
- blocknumber: number;
1641
- track_blocknumber: number;
1642
- creator_node_endpoint: string;
1643
- is_creator: boolean;
1644
- };
1645
- /**
1646
- * Singleton class to store the current user if initialized.
1647
- * Some instances of AudiusLibs and services require a current user to
1648
- * return valid queries, e.g. requesting the a discprov to return a reposted track.
1649
- */
1650
- declare class UserStateManager {
1651
- currentUser: CurrentUser | null;
1652
- constructor();
1653
- /**
1654
- * Sets this.currentUser with currentUser
1655
- * @param {Object} currentUser fields to override this.currentUser with
1656
- */
1657
- setCurrentUser(currentUser: CurrentUser): void;
1658
- getCurrentUser(): CurrentUser | null;
1659
- getCurrentUserId(): string | null;
1660
- clearUser(): void;
1661
- }
1662
-
1663
- declare type RequestParams = {
1664
- queryParams: Record<string, string>;
1665
- endpoint: string;
1666
- timeout?: number;
1667
- method?: Method;
1668
- urlParams?: PathArg;
1669
- headers?: Record<string, string>;
1670
- data?: Record<string, unknown>;
1671
- };
1672
- declare type DiscoveryProviderConfig = {
1673
- whitelist?: Set<string>;
1674
- blacklist?: Set<string>;
1675
- userStateManager: UserStateManager;
1676
- ethContracts: EthContracts;
1677
- web3Manager?: Web3Manager;
1678
- reselectTimeout?: number;
1679
- selectionCallback?: DiscoveryProviderSelectionConfig['selectionCallback'];
1680
- monitoringCallbacks?: DiscoveryProviderSelectionConfig['monitoringCallbacks'];
1681
- selectionRequestTimeout?: number;
1682
- selectionRequestRetries?: number;
1683
- unhealthySlotDiffPlays?: number;
1684
- unhealthyBlockDiff?: number;
1685
- };
1686
- declare type UserProfile = {
1687
- userId: number;
1688
- email: string;
1689
- name: string;
1690
- handle: string;
1691
- verified: boolean;
1692
- profilePicture: {
1693
- '150x150': string;
1694
- '480x480': string;
1695
- '1000x1000': string;
1696
- } | null | undefined;
1697
- sub: number;
1698
- iat: string;
1699
- };
1700
- /**
1701
- * Constructs a service class for a discovery node
1702
- * @param whitelist whether or not to only include specified nodes in selection
1703
- * @param userStateManager singleton UserStateManager instance
1704
- * @param ethContracts singleton EthContracts instance
1705
- * @param web3Manager
1706
- * @param reselectTimeout timeout to clear locally cached discovery providers
1707
- * @param selectionCallback invoked when a discovery node is selected
1708
- * @param monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
1709
- * @param monitoringCallbacks.request
1710
- * @param monitoringCallbacks.healthCheck
1711
- * @param selectionRequestTimeout the amount of time (ms) an individual request should take before reselecting
1712
- * @param selectionRequestRetries the number of retries to a given discovery node we make before reselecting
1713
- * @param unhealthySlotDiffPlays the number of slots we would consider a discovery node unhealthy
1714
- * @param unhealthyBlockDiff the number of missed blocks after which we would consider a discovery node unhealthy
1715
- */
1716
- declare class DiscoveryProvider {
1717
- whitelist: Set<string> | undefined;
1718
- blacklist: Set<string> | undefined;
1719
- userStateManager: UserStateManager;
1720
- ethContracts: EthContracts;
1721
- web3Manager: Web3Manager | undefined;
1722
- unhealthyBlockDiff: number;
1723
- serviceSelector: DiscoveryProviderSelection;
1724
- selectionRequestTimeout: number;
1725
- selectionRequestRetries: number;
1726
- unhealthySlotDiffPlays: number | undefined;
1727
- request404Count: number;
1728
- maxRequestsForTrue404: number;
1729
- monitoringCallbacks: DiscoveryProviderSelection['monitoringCallbacks'] | undefined;
1730
- discoveryProviderEndpoint: string | undefined;
1731
- constructor({ whitelist, blacklist, userStateManager, ethContracts, web3Manager, reselectTimeout, selectionCallback, monitoringCallbacks, selectionRequestTimeout, selectionRequestRetries, unhealthySlotDiffPlays, unhealthyBlockDiff }: DiscoveryProviderConfig);
1732
- init(): Promise<void>;
1733
- setEndpoint(endpoint: string): void;
1734
- setUnhealthyBlockDiff(updatedBlockDiff?: number): void;
1735
- setUnhealthySlotDiffPlays(updatedDiff: number): void;
1736
- /**
1737
- * Get users with all relevant user data
1738
- * can be filtered by providing an integer array of ids
1739
- * @param limit
1740
- * @param offset
1741
- * @param idsArray
1742
- * @param walletAddress
1743
- * @param handle
1744
- * @param isCreator null returns all users, true returns creators only, false returns users only
1745
- * @returns {Object} {Array of User metadata Objects}
1746
- * additional metadata fields on user objects:
1747
- * {Integer} track_count - track count for given user
1748
- * {Integer} playlist_count - playlist count for given user
1749
- * {Integer} album_count - album count for given user
1750
- * {Integer} follower_count - follower count for given user
1751
- * {Integer} followee_count - followee count for given user
1752
- * {Integer} repost_count - repost count for given user
1753
- * {Integer} track_blocknumber - blocknumber of latest track for user
1754
- * {Boolean} does_current_user_follow - does current user follow given user
1755
- * {Array} followee_follows - followees of current user that follow given user
1756
- * @example
1757
- * await getUsers()
1758
- * await getUsers(100, 0, [3,2,6]) - Invalid user ids will not be accepted
1759
- */
1760
- getUsers(limit?: number, offset?: number, idsArray?: string[], walletAddress?: string, handle?: string, isCreator?: null, minBlockNumber?: number): Promise<unknown>;
1761
- /**
1762
- * get tracks with all relevant track data
1763
- * can be filtered by providing an integer array of ids
1764
- * @param limit
1765
- * @param offset
1766
- * @param idsArray
1767
- * @param targetUserId the owner of the tracks being queried
1768
- * @param sort a string of form eg. blocknumber:asc,timestamp:desc describing a sort path
1769
- * @param minBlockNumber The min block number
1770
- * @param filterDeleted If set to true, filters the deleted tracks
1771
- * @returns {Object} {Array of track metadata Objects}
1772
- * additional metadata fields on track objects:
1773
- * {Integer} repost_count - repost count for given track
1774
- * {Integer} save_count - save count for given track
1775
- * {Array} followee_reposts - followees of current user that have reposted given track
1776
- * {Boolean} has_current_user_reposted - has current user reposted given track
1777
- * {Boolean} has_current_user_saved - has current user saved given track
1778
- * @example
1779
- * await getTracks()
1780
- * await getTracks(100, 0, [3,2,6]) - Invalid track ids will not be accepted
1781
- */
1782
- getTracks(limit?: number, offset?: number, idsArray?: string[], targetUserId?: string, sort?: boolean, minBlockNumber?: number, filterDeleted?: boolean, withUsers?: boolean): Promise<unknown>;
1783
- /**
1784
- * Gets a particular track by its creator's handle and the track's URL slug
1785
- * @param handle the handle of the owner of the track
1786
- * @param slug the URL slug of the track, generally the title urlized
1787
- * @returns {Object} the requested track's metadata
1788
- */
1789
- getTracksByHandleAndSlug(handle: string, slug: string): Promise<unknown>;
1790
- /**
1791
- * @typedef {Object} getTracksIdentifier
1792
- * @property {string} handle
1793
- * @property {number} id
1794
- * @property {string} url_title
1795
- */
1796
- /**
1797
- * gets all tracks matching identifiers, including unlisted.
1798
- *
1799
- * @param identifiers
1800
- * @returns {(Array)} track
1801
- */
1802
- getTracksIncludingUnlisted(identifiers: string[], withUsers?: boolean): Promise<unknown>;
1803
- /**
1804
- * Gets random tracks from trending tracks for a given genre.
1805
- * If genre not given, will return trending tracks across all genres.
1806
- * Excludes specified track ids.
1807
- *
1808
- * @param genre
1809
- * @param limit
1810
- * @param exclusionList
1811
- * @param time
1812
- * @returns {(Array)} track
1813
- */
1814
- getRandomTracks(genre: string, limit: number, exclusionList: number[], time: string): Promise<unknown>;
1815
- /**
1816
- * Gets all stems for a given trackId as an array of tracks.
1817
- * @param trackId
1818
- * @returns {(Array)} track
1819
- */
1820
- getStemsForTrack(trackId: number): Promise<unknown>;
1821
- /**
1822
- * Gets all the remixes of a given trackId as an array of tracks.
1823
- * @param trackId
1824
- * @param limit
1825
- * @param offset
1826
- * @returns {(Array)} track
1827
- */
1828
- getRemixesOfTrack(trackId: number, limit?: number, offset?: number): Promise<unknown>;
1829
- /**
1830
- * Gets the remix parents of a given trackId as an array of tracks.
1831
- * @param limit
1832
- * @param offset
1833
- * @returns {(Array)} track
1834
- */
1835
- getRemixTrackParents(trackId: number, limit?: number, offset?: number): Promise<unknown>;
1836
- /**
1837
- * Gets tracks trending on Audius.
1838
- * @param genre
1839
- * @param timeFrame one of day, week, month, or year
1840
- * @param idsArray track ids
1841
- * @param limit
1842
- * @param offset
1843
- */
1844
- getTrendingTracks(genre?: string, timeFrame?: string, idsArray?: number[], limit?: number, offset?: number, withUsers?: boolean): Promise<{
1845
- listenCounts: Array<{
1846
- trackId: number;
1847
- listens: number;
1848
- }>;
1849
- } | null | undefined>;
1850
- /**
1851
- * get full playlist objects, including tracks, for passed in array of playlistId
1852
- * @returns {Array} array of playlist objects
1853
- * additional metadata fields on playlist objects:
1854
- * {Integer} repost_count - repost count for given playlist
1855
- * {Integer} save_count - save count for given playlist
1856
- * {Boolean} has_current_user_reposted - has current user reposted given playlist
1857
- * {Array} followee_reposts - followees of current user that have reposted given playlist
1858
- * {Boolean} has_current_user_reposted - has current user reposted given playlist
1859
- * {Boolean} has_current_user_saved - has current user saved given playlist
1860
- */
1861
- getPlaylists(limit?: number, offset?: number, idsArray?: null, targetUserId?: null, withUsers?: boolean): Promise<unknown>;
1862
- /**
1863
- * Return social feed for current user
1864
- * @param filter - filter by "all", "original", or "repost"
1865
- * @param limit - max # of items to return
1866
- * @param offset - offset into list to return from (for pagination)
1867
- * @returns {Object} {Array of track and playlist metadata objects}
1868
- * additional metadata fields on track and playlist objects:
1869
- * {String} activity_timestamp - timestamp of requested user's repost for given track or playlist,
1870
- * used for sorting feed
1871
- * {Integer} repost_count - repost count of given track/playlist
1872
- * {Integer} save_count - save count of given track/playlist
1873
- * {Boolean} has_current_user_reposted - has current user reposted given track/playlist
1874
- * {Array} followee_reposts - followees of current user that have reposted given track/playlist
1875
- */
1876
- getSocialFeed(filter: string, limit?: number, offset?: number, withUsers?: boolean, tracksOnly?: boolean): Promise<unknown>;
1877
- /**
1878
- * Return repost feed for requested user
1879
- * @param userId - requested user id
1880
- * @param limit - max # of items to return (for pagination)
1881
- * @param offset - offset into list to return from (for pagination)
1882
- * @returns {Object} {Array of track and playlist metadata objects}
1883
- * additional metadata fields on track and playlist objects:
1884
- * {String} activity_timestamp - timestamp of requested user's repost for given track or playlist,
1885
- * used for sorting feed
1886
- * {Integer} repost_count - repost count of given track/playlist
1887
- * {Integer} save_count - save count of given track/playlist
1888
- * {Boolean} has_current_user_reposted - has current user reposted given track/playlist
1889
- * {Array} followee_reposts - followees of current user that have reposted given track/playlist
1890
- */
1891
- getUserRepostFeed(userId: number, limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
1892
- /**
1893
- * get intersection of users that follow followeeUserId and users that are followed by followerUserId
1894
- * @param followeeUserId user that is followed
1895
- * @param followerUserId user that follows
1896
- * @example
1897
- * getFollowIntersectionUsers(100, 0, 1, 1) - IDs must be valid
1898
- */
1899
- getFollowIntersectionUsers(limit: number | undefined, offset: number | undefined, followeeUserId: number, followerUserId: number): Promise<unknown>;
1900
- /**
1901
- * get intersection of users that have reposted repostTrackId and users that are followed by followerUserId
1902
- * followee = user that is followed; follower = user that follows
1903
- * @param repostTrackId track that is reposted
1904
- * @param followerUserId user that reposted track
1905
- * @example
1906
- * getTrackRepostIntersectionUsers(100, 0, 1, 1) - IDs must be valid
1907
- */
1908
- getTrackRepostIntersectionUsers(limit: number | undefined, offset: number | undefined, repostTrackId: number, followerUserId: number): Promise<unknown>;
1909
- /**
1910
- * get intersection of users that have reposted repostPlaylistId and users that are followed by followerUserId
1911
- * followee = user that is followed; follower = user that follows
1912
- * @param repostPlaylistId playlist that is reposted
1913
- * @param followerUserId user that reposted track
1914
- * @example
1915
- * getPlaylistRepostIntersectionUsers(100, 0, 1, 1) - IDs must be valid
1916
- */
1917
- getPlaylistRepostIntersectionUsers(limit: number | undefined, offset: number | undefined, repostPlaylistId: number, followerUserId: number): Promise<unknown>;
1918
- /**
1919
- * get users that follow followeeUserId, sorted by follower count descending
1920
- * @param followeeUserId user that is followed
1921
- * @return {Array} array of user objects with standard user metadata
1922
- */
1923
- getFollowersForUser(limit: number | undefined, offset: number | undefined, followeeUserId: number): Promise<unknown>;
1924
- /**
1925
- * get users that are followed by followerUserId, sorted by follower count descending
1926
- * @param followerUserId user - i am the one who follows
1927
- * @return {Array} array of user objects with standard user metadata
1928
- */
1929
- getFolloweesForUser(limit: number | undefined, offset: number | undefined, followerUserId: number): Promise<unknown>;
1930
- /**
1931
- * get users that reposted repostTrackId, sorted by follower count descending
1932
- * @param repostTrackId
1933
- * @return {Array} array of user objects
1934
- * additional metadata fields on user objects:
1935
- * {Integer} follower_count - follower count of given user
1936
- * @example
1937
- * getRepostersForTrack(100, 0, 1) - ID must be valid
1938
- */
1939
- getRepostersForTrack(limit: number | undefined, offset: number | undefined, repostTrackId: number): Promise<unknown>;
1940
- /**
1941
- * get users that reposted repostPlaylistId, sorted by follower count descending
1942
- * @param repostPlaylistId
1943
- * @return {Array} array of user objects
1944
- * additional metadata fields on user objects:
1945
- * {Integer} follower_count - follower count of given user
1946
- * @example
1947
- * getRepostersForPlaylist(100, 0, 1) - ID must be valid
1948
- */
1949
- getRepostersForPlaylist(limit: number | undefined, offset: number | undefined, repostPlaylistId: number): Promise<unknown>;
1950
- /**
1951
- * get users that saved saveTrackId, sorted by follower count descending
1952
- * @param saveTrackId
1953
- * @return {Array} array of user objects
1954
- * additional metadata fields on user objects:
1955
- * {Integer} follower_count - follower count of given user
1956
- * @example
1957
- * getSaversForTrack(100, 0, 1) - ID must be valid
1958
- */
1959
- getSaversForTrack(limit: number | undefined, offset: number | undefined, saveTrackId: number): Promise<unknown>;
1960
- /**
1961
- * get users that saved savePlaylistId, sorted by follower count descending
1962
- * @param savePlaylistId
1963
- * @return {Array} array of user objects
1964
- * additional metadata fields on user objects:
1965
- * {Integer} follower_count - follower count of given user
1966
- * @example
1967
- * getSaversForPlaylist(100, 0, 1) - ID must be valid
1968
- */
1969
- getSaversForPlaylist(limit: number | undefined, offset: number | undefined, savePlaylistId: number): Promise<unknown>;
1970
- /**
1971
- * get whether a JWT given by Audius Oauth popup is valid
1972
- * @param token - JWT
1973
- * @return {UserProfile | false} profile info of user attached to JWT payload if the JWT is valid, else false
1974
- */
1975
- verifyToken(token: string): Promise<UserProfile | false>;
1976
- /**
1977
- * Perform a full-text search. Returns tracks, users, playlists, albums
1978
- * with optional user-specific results for each
1979
- * - user, track, and playlist objects have all same data as returned from standalone endpoints
1980
- * @param text search query
1981
- * @param kind 'tracks', 'users', 'playlists', 'albums', 'all'
1982
- * @param limit max # of items to return per list (for pagination)
1983
- * @param offset offset into list to return from (for pagination)
1984
- */
1985
- searchFull(text: string, kind: string, limit?: number, offset?: number): Promise<unknown>;
1986
- /**
1987
- * Perform a lighter-weight full-text search. Returns tracks, users, playlists, albums
1988
- * with optional user-specific results for each
1989
- * - user, track, and playlist objects have core data, and track & playlist objects
1990
- * also return user object
1991
- * @param text search query
1992
- * @param limit max # of items to return per list (for pagination)
1993
- * @param offset offset into list to return from (for pagination)
1994
- */
1995
- searchAutocomplete(text: string, limit?: number, offset?: number): Promise<unknown>;
1996
- /**
1997
- * Perform a tags-only search. Returns tracks with required tag and users
1998
- * that have used a tag greater than a specified number of times
1999
- * @param text search query
2000
- * @param userTagCount min # of times a user must have used a tag to be returned
2001
- * @param kind 'tracks', 'users', 'playlists', 'albums', 'all'
2002
- * @param limit max # of items to return per list (for pagination)
2003
- * @param offset offset into list to return from (for pagination)
2004
- */
2005
- searchTags(text: string, userTagCount?: number, kind?: string, limit?: number, offset?: number): Promise<unknown>;
2006
- /**
2007
- * Return saved playlists for current user
2008
- * NOTE in returned JSON, SaveType string one of track, playlist, album
2009
- * @param limit - max # of items to return
2010
- * @param offset - offset into list to return from (for pagination)
2011
- */
2012
- getSavedPlaylists(limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
2013
- /**
2014
- * Return saved albums for current user
2015
- * NOTE in returned JSON, SaveType string one of track, playlist, album
2016
- * @param limit - max # of items to return
2017
- * @param offset - offset into list to return from (for pagination)
2018
- */
2019
- getSavedAlbums(limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
2020
- /**
2021
- * Return saved tracks for current user
2022
- * NOTE in returned JSON, SaveType string one of track, playlist, album
2023
- * @param limit - max # of items to return
2024
- * @param offset - offset into list to return from (for pagination)
2025
- */
2026
- getSavedTracks(limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
2027
- /**
2028
- * Return user collections (saved & uploaded) along w/ users for those collections
2029
- */
2030
- getUserAccount(wallet: string): Promise<CurrentUser | null | undefined>;
2031
- getTopPlaylists(type: string, limit: number, mood: string, filter: string, withUsers?: boolean): Promise<unknown>;
2032
- getTopFolloweeWindowed(type: string, window: string, limit: string, withUsers?: boolean): Promise<unknown>;
2033
- getTopFolloweeSaves(type: string, limit: string, withUsers?: boolean): Promise<unknown>;
2034
- getLatest(type: string): Promise<unknown>;
2035
- getTopCreatorsByGenres(genres: string[], limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
2036
- getURSMContentNodes(ownerWallet?: string | null): Promise<unknown>;
2037
- getNotifications(minBlockNumber: string, trackIds: string[], timeout: number): Promise<unknown>;
2038
- getSolanaNotifications(minSlotNumber: number, timeout: number): Promise<unknown>;
2039
- getTrackListenMilestones(timeout: number): Promise<unknown>;
2040
- getChallengeAttestation(challengeId: string, encodedUserId: string, specifier: string, oracleAddress: string, discoveryProviderEndpoint: string): Promise<any>;
2041
- getCreateSenderAttestation(senderEthAddress: string, discoveryProviderEndpoint: string): Promise<any>;
2042
- getUndisbursedChallenges(limit?: number | null, offset?: number | null, completedBlockNumber?: string | null, encodedUserId?: number | null): Promise<{
2043
- amount: number;
2044
- }[]>;
2045
- /**
2046
- * Performs a single request, defined in the request, via axios, calling any
2047
- * monitoring callbacks as needed.
2048
- *
2049
- * @param {{
2050
- endpoint: string,
2051
- urlParams: string,
2052
- queryParams: object,
2053
- method: string,
2054
- headers: object,
2055
- }} requestObj
2056
- * @param {string} discoveryProviderEndpoint
2057
- * @returns
2058
- * @memberof DiscoveryProvider
2059
- */
2060
- _performRequestWithMonitoring(requestObj: RequestParams, discoveryProviderEndpoint: string): Promise<any>;
2061
- /**
2062
- * Gets how many blocks behind a discovery node is.
2063
- * If this method throws (missing data in health check response),
2064
- * return an unhealthy number of blocks
2065
- * @param parsedResponse health check response object
2066
- * @returns a number of blocks if behind or null if not behind
2067
- */
2068
- _getBlocksBehind(parsedResponse: {
2069
- latest_indexed_block: number;
2070
- latest_chain_block: number;
2071
- }): Promise<number | null>;
2072
- /**
2073
- * Gets how many plays slots behind a discovery node is.
2074
- * If this method throws (missing data in health check response),
2075
- * return an unhealthy number of slots
2076
- * @param parsedResponse health check response object
2077
- * @returns a number of slots if behind or null if not behind
2078
- */
2079
- _getPlaysSlotsBehind(parsedResponse: {
2080
- latest_indexed_slot_plays: number;
2081
- latest_chain_slot_plays: number;
2082
- }): Promise<number | null>;
2083
- /**
2084
- * Makes a request to a discovery node, reselecting if necessary
2085
- * @param {{
2086
- * endpoint: string
2087
- * urlParams: object
2088
- * queryParams: object
2089
- * method: string
2090
- * headers: object
2091
- * }} {
2092
- * endpoint: the base route
2093
- * urlParams: string of URL params to be concatenated after base route
2094
- * queryParams: URL query (search) params
2095
- * method: string HTTP method
2096
- * }
2097
- * @param retry whether to retry on failure
2098
- * @param attemptedRetries number of attempted retries (stops retrying at max)
2099
- */
2100
- _makeRequest<Response>(requestObj: Record<string, unknown>, retry?: boolean, attemptedRetries?: number): Promise<Response | undefined | null>;
2101
- /**
2102
- * Gets the healthy discovery provider endpoint used in creating the axios request later.
2103
- * If the number of retries is over the max count for retires, clear the cache and reselect
2104
- * another healthy discovery provider. Else, return the current discovery provider endpoint
2105
- * @param attemptedRetries the number of attempted requests made to the current disc prov endpoint
2106
- */
2107
- getHealthyDiscoveryProviderEndpoint(attemptedRetries: number): Promise<string>;
2108
- /**
2109
- * Creates the discovery provider axios request object with necessary configs
2110
- * @param requestObj
2111
- * @param discoveryProviderEndpoint
2112
- */
2113
- _createDiscProvRequest(requestObj: RequestParams, discoveryProviderEndpoint: string): AxiosRequestConfig;
2114
- }
2115
-
2116
- declare type LoginSuccessCallback = (profile: UserProfile) => void;
2117
- declare type LoginErrorCallback = (errorMessage: string) => void;
2118
- declare type ButtonOptions = {
2119
- size: 'small' | 'medium' | 'large';
2120
- corners: 'default' | 'pill';
2121
- customText: string;
2122
- disableHoverGrow: boolean;
2123
- fullWidth: boolean;
2124
- };
2125
- declare type OauthConfig = {
2126
- appName: string;
2127
- discoveryProvider: DiscoveryProvider;
2128
- };
2129
- declare class Oauth {
2130
- discoveryProvider: DiscoveryProvider;
2131
- appName: string;
2132
- activePopupWindow: null | Window;
2133
- popupCheckInterval: NodeJS.Timer | null;
2134
- loginSuccessCallback: LoginSuccessCallback | null;
2135
- loginErrorCallback: LoginErrorCallback | null;
2136
- constructor({ discoveryProvider, appName }: OauthConfig);
2137
- init(successCallback: LoginSuccessCallback, errorCallback?: LoginErrorCallback): void;
2138
- login(): void;
2139
- renderButton(element: HTMLElement, options?: ButtonOptions): void;
2140
- verifyToken(token: string): Promise<false | UserProfile>;
2141
- _surfaceError(errorMessage: string): void;
2142
- _clearPopupCheckInterval(): void;
2143
- _receiveMessage(event: MessageEvent): Promise<void>;
2144
- }
2145
-
2146
- declare type Web3Config = {
2147
- providers: string[];
2148
- };
2149
- declare type SdkConfig = {
2150
- appName: string;
2151
- discoveryNodeConfig?: DiscoveryProviderConfig;
2152
- ethContractsConfig?: EthContractsConfig;
2153
- ethWeb3Config?: EthWeb3Config;
2154
- identityServiceConfig?: IdentityService;
2155
- web3Config?: Web3Config;
2156
- };
2157
- /**
2158
- * The Audius SDK
2159
- */
2160
- declare const sdk: (config: SdkConfig) => Promise<{
2161
- oauth: Oauth | undefined;
2162
- discoveryNode: DiscoveryProvider;
2163
- }>;
2164
-
2165
- declare type SchemaConfig = {
2166
- schema: {
2167
- definitions: Record<string, {
2168
- required: string[];
2169
- properties: Record<string, {
2170
- default: unknown;
2171
- }>;
2172
- } | {}>;
2173
- };
2174
- baseDefinition: string;
2175
- validate?: (obj: Record<string, unknown>) => void;
2176
- };
2177
- declare type Schemas = {
2178
- TrackSchema: SchemaConfig;
2179
- UserSchema: SchemaConfig;
2180
- };
2181
-
2182
- declare type Metadata = {
2183
- track_segments: unknown;
2184
- download?: {
2185
- is_downloadable: boolean;
2186
- cid: string;
2187
- };
2188
- cover_art_sizes: string;
2189
- };
2190
- declare type ProgressCB = (loaded: number, total: number) => void;
2191
- declare type MonitoringCallbacks = {
2192
- request?: Function;
2193
- healthCheck?: Function;
2194
- };
2195
- declare type ClockValueRequestConfig = {
2196
- user: CurrentUser;
2197
- endpoint: string;
2198
- timeout?: number;
2199
- };
2200
- declare type FileUploadResponse = {
2201
- data: {
2202
- uuid: string;
2203
- };
2204
- error: Error;
2205
- };
2206
- declare class CreatorNode {
2207
- /**
2208
- * Pulls off the primary creator node from a creator node endpoint string.
2209
- * @param endpoints user.creator_node_endpoint
2210
- */
2211
- static getPrimary(endpoints: string): string | undefined;
2212
- /**
2213
- * Pulls off the secondary creator nodes from a creator node endpoint string.
2214
- * @param endpoints user.creator_node_endpoint
2215
- */
2216
- static getSecondaries(endpoints: string): string[];
2217
- /**
2218
- * Pulls the user's creator nodes out of the list
2219
- * @param endpoints user.creator_node_endpoint
2220
- */
2221
- static getEndpoints(endpoints: string): string[];
2222
- /**
2223
- * Builds the creator_node_endpoint value off of a primary and secondaries list
2224
- * @param primary the primary endpoint
2225
- * @param secondaries a list of secondary endpoints
2226
- */
2227
- static buildEndpoint(primary: string, secondaries: string[]): string;
2228
- /**
2229
- * Pulls off the user's clock value from a creator node endpoint and the user's wallet address.
2230
- * @param endpoint content node endpoint
2231
- * @param wallet user wallet address
2232
- * @param timeout max time alloted for clock request
2233
- * @param params optional query string params
2234
- */
2235
- static getClockValue(endpoint: string, wallet: string, timeout: number, params?: Record<string, string>): Promise<any>;
2236
- /**
2237
- * Checks if a download is available from provided creator node endpoints
2238
- * @param endpoints creator node endpoints
2239
- * @param trackId
2240
- */
2241
- static checkIfDownloadAvailable(endpoints: string, trackId: number): Promise<any>;
2242
- web3Manager: Web3Manager;
2243
- creatorNodeEndpoint: string;
2244
- isServer: boolean;
2245
- userStateManager: UserStateManager;
2246
- lazyConnect: boolean;
2247
- schemas: Schemas;
2248
- passList: Set<string> | null;
2249
- blockList: Set<string> | null;
2250
- monitoringCallbacks: MonitoringCallbacks;
2251
- connected: boolean;
2252
- connecting: boolean;
2253
- authToken: null;
2254
- maxBlockNumber: number;
2255
- /**
2256
- * Constructs a service class for a creator node
2257
- * @param web3Manager
2258
- * @param creatorNodeEndpoint fallback creator node endpoint (to be deprecated)
2259
- * @param isServer
2260
- * @param userStateManager singleton UserStateManager instance
2261
- * @param lazyConnect whether or not to lazy connect (sign in) on load
2262
- * @param schemas
2263
- * @param passList whether or not to include only specified nodes (default null)
2264
- * @param blockList whether or not to exclude any nodes (default null)
2265
- * @param monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
2266
- */
2267
- constructor(web3Manager: Web3Manager, creatorNodeEndpoint: string, isServer: boolean, userStateManager: UserStateManager, lazyConnect: boolean, schemas: Schemas, passList?: Set<string> | null, blockList?: Set<string> | null, monitoringCallbacks?: MonitoringCallbacks);
2268
- init(): Promise<void>;
2269
- /** Establishes a connection to a content node endpoint */
2270
- connect(): Promise<void>;
2271
- /** Checks if connected, otherwise establishing a connection */
2272
- ensureConnected(): Promise<void>;
2273
- getEndpoint(): string;
2274
- /**
2275
- * Switch from one creatorNodeEndpoint to another including logging out from the old node, updating the endpoint and logging into new node */
2276
- setEndpoint(creatorNodeEndpoint: string): Promise<void>;
2277
- /** Clear all connection state in this class by deleting authToken and setting 'connected' = false */
2278
- clearConnection(): void;
2279
- /**
2280
- * Uploads creator content to a creator node
2281
- * @param metadata the creator metadata
2282
- */
2283
- uploadCreatorContent(metadata: Metadata, blockNumber?: null): Promise<any>;
2284
- /**
2285
- * Creates a creator on the creator node, associating user id with file content
2286
- * @param audiusUserId returned by user creation on-blockchain
2287
- * @param metadataFileUUID unique ID for metadata file
2288
- * @param blockNumber
2289
- */
2290
- associateCreator(audiusUserId: number, metadataFileUUID: string, blockNumber: number): Promise<void>;
2291
- /**
2292
- * Uploads a track (including audio and image content) to a creator node
2293
- * @param trackFile the audio content
2294
- * @param coverArtFile the image content
2295
- * @param metadata the metadata for the track
2296
- * @param onProgress an optional on progress callback
2297
- */
2298
- uploadTrackContent(trackFile: File, coverArtFile: File, metadata: Metadata, onProgress?: ProgressCB): Promise<any>;
2299
- /**
2300
- * Uploads track metadata to a creator node
2301
- * The metadata object must include a `track_id` field or a
2302
- * source file must be provided (returned from uploading track content).
2303
- * @param metadata
2304
- * @param sourceFile
2305
- */
2306
- uploadTrackMetadata(metadata: Metadata, sourceFile: string): Promise<any>;
2307
- /**
2308
- * Creates a track on the content node, associating track id with file content
2309
- * @param audiusTrackId returned by track creation on-blockchain
2310
- * @param metadataFileUUID unique ID for metadata file
2311
- * @param blockNumber
2312
- * @param transcodedTrackUUID the CID for the transcoded master if this is a first-time upload
2313
- */
2314
- associateTrack(audiusTrackId: number, metadataFileUUID: string, blockNumber: number, transcodedTrackUUID: string): Promise<void>;
2315
- /**
2316
- * Uploads an image to the connected content node
2317
- * @param file image to upload
2318
- * @param onProgress called with loaded bytes and total bytes
2319
- * @param timeoutMs timeout in ms axios request to upload file to CN will wait
2320
- * @return response body
2321
- */
2322
- uploadImage(file: File, square: boolean | undefined, onProgress: ProgressCB, timeoutMs?: number | null): Promise<{
2323
- uuid: string;
2324
- }>;
2325
- /**
2326
- * @param file track to upload
2327
- * @param onProgress called with loaded bytes and total bytes
2328
- * @return response body
2329
- */
2330
- uploadTrackAudio(file: File, onProgress: ProgressCB): Promise<any>;
2331
- handleAsyncTrackUpload(file: File, onProgress: ProgressCB): Promise<any>;
2332
- pollProcessingStatus(uuid: string): Promise<any>;
2333
- /**
2334
- * Gets the task progress given the task type and uuid associated with the task
2335
- * @param uuid the uuid of the track transcoding task
2336
- * @returns the status, and the success or failed response if the task is complete
2337
- */
2338
- getTrackContentProcessingStatus(uuid: string): Promise<any>;
2339
- /**
2340
- * Given a particular endpoint to a creator node, check whether
2341
- * this user has a sync in progress on that node.
2342
- * @param endpoint
2343
- * @param timeout ms
2344
- */
2345
- getSyncStatus(endpoint: string, timeout?: number | null): Promise<{
2346
- status: any;
2347
- userBlockNumber: number;
2348
- trackBlockNumber: number;
2349
- isBehind: boolean;
2350
- isConfigured: boolean;
2351
- }>;
2352
- /**
2353
- * Syncs a secondary creator node for a given user
2354
- * @param secondary
2355
- * @param primary specific primary to use
2356
- * @param immediate whether or not this is a blocking request and handled right away
2357
- * @param validate whether or not to validate the provided secondary is valid
2358
- */
2359
- syncSecondary(secondary: string, primary?: string, immediate?: boolean, validate?: boolean): Promise<axios.AxiosResponse<any> | undefined>;
2360
- /**
2361
- * Signs up a creator node user with a wallet address
2362
- * @param walletAddress
2363
- */
2364
- _signupNodeUser(walletAddress: string): Promise<void>;
2365
- /**
2366
- * Logs user into cnode, if not already logged in.
2367
- * Requests a challenge from cnode, sends signed challenge response to cn.
2368
- * If successful, receive and set authToken locally.
2369
- */
2370
- _loginNodeUser(): Promise<void>;
2371
- /** Calls logout on the content node. Needs an authToken for this since logout is an authenticated endpoint */
2372
- _logoutNodeUser(): Promise<void>;
2373
- /**
2374
- * Gets and returns the clock values across the replica set for the wallet in userStateManager.
2375
- * @returns Array of objects with the structure:
2376
- *
2377
- * {
2378
- * type: 'primary' or 'secondary',
2379
- * endpoint: <Content Node endpoint>,
2380
- * clockValue: clock value (should be an integer) or null
2381
- * }
2382
- *
2383
- * 'clockValue' may be null if the request to fetch the clock value fails
2384
- */
2385
- getClockValuesFromReplicaSet(): Promise<{
2386
- type: string;
2387
- endpoint: string;
2388
- clockValue: any;
2389
- }[] | undefined>;
2390
- /**
2391
- * Wrapper around getClockValue() to return either a proper or null clock value
2392
- * @param {Object} param
2393
- * @param {Object} param.user user metadata object from userStateManager
2394
- * @param {string} param.endpoint the Content Node endpoint to check the clock value for
2395
- * @param {number?} [param.timeout=1000] the max time allotted for a clock request; defaulted to 1000ms
2396
- */
2397
- _clockValueRequest({ user, endpoint, timeout }: ClockValueRequestConfig): Promise<{
2398
- type: string;
2399
- endpoint: string;
2400
- clockValue: any;
2401
- }>;
2402
- /**
2403
- * Makes an axios request to the connected creator node.
2404
- * @param requiresConnection if set, the currently configured creator node
2405
- * is connected to before the request is made.
2406
- * @return response body
2407
- */
2408
- _makeRequest(axiosRequestObj: AxiosRequestConfig, requiresConnection?: boolean): Promise<any>;
2409
- /**
2410
- * Create headers and formData for file upload
2411
- * @param file the file to upload
2412
- * @returns headers and formData in an object
2413
- */
2414
- createFormDataAndUploadHeaders(file: File, extraFormDataOptions?: Record<string, unknown>): {
2415
- headers: Record<string, string | null>;
2416
- formData: FormData;
2417
- };
2418
- /**
2419
- * Uploads a file to the connected creator node.
2420
- * @param file
2421
- * @param route route to handle upload (image_upload, track_upload, etc.)
2422
- * @param onProgress called with loaded bytes and total bytes
2423
- * @param extraFormDataOptions extra FormData fields passed to the upload
2424
- * @param retries max number of attempts made for axios request to upload file to CN before erroring
2425
- * @param timeoutMs timeout in ms axios request to upload file to CN will wait
2426
- */
2427
- _uploadFile(file: File, route: string, onProgress?: ProgressCB, extraFormDataOptions?: Record<string, unknown>, retries?: number, timeoutMs?: number | null): Promise<FileUploadResponse>;
2428
- _handleErrorHelper(e: Error | AxiosError, requestUrl?: string, requestId?: string | null): Promise<void>;
2429
- }
2430
-
2431
- type Options = { skipRollover: boolean }
2432
-
2433
- declare class SanityChecks {
2434
- libs: any
2435
- options: Options
2436
-
2437
- constructor(libsInstance: any, options?: Options): void
2438
- async run(creatorNodeWhitelist: string[] | null): Promise<void>
2439
- }
2440
-
2441
- declare const libs: any;
2442
-
2443
- export { CreatorNode, SanityChecks, Utils, libs, sdk };