@audius/sdk 0.0.0 → 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,17 +1,22 @@
1
- import { UserImporterOptions, ImportCandidate } from 'ipfs-unixfs-importer';
2
- import * as ipfs_unixfs_importer_types_src_types from 'ipfs-unixfs-importer/types/src/types';
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';
3
6
  import * as Web3 from 'web3';
4
7
  import Web3__default from 'web3';
5
- import * as BN from 'bn.js';
6
8
  import { AbiItem } from 'web3-utils';
7
- import * as axios from 'axios';
8
- import { AxiosResponse, AxiosRequestConfig, AxiosError } from 'axios';
9
- import FormData from 'form-data';
9
+ import * as web3_core from 'web3-core';
10
+ import { Log, TransactionReceipt, HttpProvider, EventLog } from 'web3-core';
10
11
  import Wallet from 'ethereumjs-wallet';
11
- import { HttpProvider, AbstractProvider, Log, TransactionReceipt } from 'web3-core';
12
12
  import abiDecoder from 'abi-decoder';
13
13
  import { Hedgehog } from '@audius/hedgehog';
14
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';
15
20
 
16
21
  declare type Content = ReadableStream | Buffer | string;
17
22
  interface ImageHasher {
@@ -144,43 +149,218 @@ interface ContractMethod {
144
149
  };
145
150
  encodeABI: () => string;
146
151
  send: <Tx>(config: {
147
- from: Wallet | undefined;
152
+ from: Wallet | string | undefined;
148
153
  gas: number;
149
154
  gasPrice?: number;
150
155
  }) => Tx;
151
156
  }
152
157
 
153
- declare type Providers = [
154
- HttpProvider,
155
- ...Array<HttpProvider | AbstractProvider>
156
- ];
158
+ declare type ServiceName = string;
159
+ interface ServiceWithEndpoint {
160
+ endpoint: string;
161
+ spID?: string;
162
+ }
163
+ declare type Service = ServiceName | ServiceWithEndpoint;
157
164
 
158
- declare type SchemaConfig = {
159
- schema: {
160
- definitions: Record<string, {
161
- required: string[];
162
- properties: Record<string, {
163
- default: unknown;
164
- }>;
165
- } | {}>;
166
- };
167
- baseDefinition: string;
168
- validate?: (obj: Record<string, unknown>) => void;
169
- };
170
- declare type Schemas = {
171
- TrackSchema: SchemaConfig;
172
- UserSchema: SchemaConfig;
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;
173
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
+ }
174
354
 
175
- declare type Web3Config = {
176
- ownerWallet: Wallet;
177
- providers: Providers;
355
+ declare type TimeFrame = 'day' | 'week' | 'month' | 'year' | 'millennium';
356
+
357
+ declare type Web3Config$1 = {
178
358
  useExternalWeb3: boolean;
179
359
  internalWeb3Config: {
180
360
  web3ProviderEndpoints: string[];
181
- privateKey: string;
361
+ privateKey?: string;
182
362
  };
183
- externalWeb3Config: {
363
+ externalWeb3Config?: {
184
364
  web3: Web3__default;
185
365
  ownerWallet: Wallet;
186
366
  };
@@ -191,7 +371,47 @@ declare class AudiusABIDecoder {
191
371
  static decodeLogs(_: string, logs: Log[]): abiDecoder.DecodedLog;
192
372
  }
193
373
 
194
- declare type TimeFrame = 'day' | 'week' | 'month' | 'year' | 'millennium';
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
+ }
195
415
 
196
416
  declare type Data = Record<string, unknown>;
197
417
  declare type RelayTransaction = {
@@ -236,11 +456,15 @@ declare type AttestationResult = {
236
456
  phase?: string;
237
457
  reason?: string;
238
458
  };
459
+ declare type IdentityServiceConfig = {
460
+ identityServiceEndpoint: string;
461
+ captcha?: Captcha;
462
+ };
239
463
  declare class IdentityService {
240
464
  identityServiceEndpoint: string;
241
- captcha: Captcha;
465
+ captcha: Captcha | undefined;
242
466
  web3Manager: Web3Manager | null;
243
- constructor(identityServiceEndpoint: string, captcha: Captcha);
467
+ constructor({ identityServiceEndpoint, captcha }: IdentityServiceConfig);
244
468
  setWeb3Manager(web3Manager: Web3Manager): void;
245
469
  getFn(params: {
246
470
  lookupKey: string;
@@ -365,40 +589,1039 @@ declare class IdentityService {
365
589
  }>;
366
590
  }
367
591
 
368
- /** singleton class to be instantiated and persisted with every AudiusLibs */
369
- declare class Web3Manager {
370
- web3Config: Web3Config;
371
- isServer: boolean;
592
+ declare type EthWeb3Config = {
593
+ ownerWallet: Wallet | string;
594
+ providers: string[];
595
+ };
596
+ declare type EthWeb3ManagerConfig = {
597
+ web3Config: EthWeb3Config;
372
598
  identityService: IdentityService;
373
- hedgehog: Hedgehog;
374
- AudiusABIDecoder: typeof AudiusABIDecoder;
375
- web3: Web3__default | undefined;
376
- useExternalWeb3: boolean | undefined;
377
- ownerWallet: Wallet;
378
- constructor(web3Config: Web3Config, identityService: IdentityService, hedgehog: Hedgehog, isServer: boolean);
379
- init(): Promise<void>;
599
+ hedgehog?: Hedgehog;
600
+ };
601
+ /** Singleton state-manager for Audius Eth Contracts */
602
+ declare class EthWeb3Manager {
603
+ web3Config: EthWeb3Config;
604
+ web3: Web3__default;
605
+ identityService: IdentityService;
606
+ hedgehog?: Hedgehog;
607
+ ownerWallet: Maybe<Wallet | string>;
608
+ constructor({ web3Config, identityService, hedgehog }: EthWeb3ManagerConfig);
380
609
  getWeb3(): Web3__default;
381
- setWeb3(web3: Web3__default): void;
382
610
  getWalletAddress(): any;
383
- setOwnerWallet(ownerWallet: Wallet): void;
384
- web3IsExternal(): boolean | undefined;
385
- getOwnerWalletPrivateKey(): Buffer;
386
611
  /**
387
612
  * Signs provided string data (should be timestamped).
388
- * @param data
389
613
  */
390
- sign(data: string): Promise<string | undefined>;
614
+ sign(data: string): Promise<string>;
615
+ sendTransaction(contractMethod: ContractMethod, contractAddress?: string | null, privateKey?: string | null, txRetries?: number, txGasLimit?: number | null): Promise<TransactionReceipt>;
391
616
  /**
392
- * Given a data payload and signature, verifies that signature is valid, and returns
393
- * Ethereum wallet address used to sign data.
394
- * @param data information that was signed
395
- * @param signature hex-formatted signature of data generated by web3 personalSign method
617
+ * Relays an eth transaction via the identity service with retries
618
+ * The relay pays for the transaction fee on behalf of the user
619
+ * The gas Limit is estimated if not provided
396
620
  */
397
- verifySignature(data: string, signature: string): Promise<string>;
398
- signTypedData(signatureData: EIP712TypedData): Promise<unknown>;
399
- sendTransaction(contractMethod: ContractMethod, contractRegistryKey?: string | null, contractAddress?: string | null, txRetries?: number, txGasLimit?: number): Promise<TransactionReceipt>;
400
- provider(url: string, timeout: number): HttpProvider;
401
- monkeyPatchProvider(httpProvider: HttpProvider): HttpProvider;
621
+ relayTransaction(contractMethod: ContractMethod, contractAddress: string, ownerWallet: Wallet | string, relayerWallet?: Wallet | string, txRetries?: number, txGasLimit?: number | null): Promise<Maybe<RelayTransaction['resp']>>;
622
+ getRelayMethodParams(contractAddress: string, contractMethod: ContractMethod, relayerWallet: Wallet): Promise<{
623
+ contractAddress: string;
624
+ encodedABI: string;
625
+ gasLimit: number;
626
+ }>;
627
+ }
628
+
629
+ declare class AudiusTokenClient {
630
+ ethWeb3Manager: EthWeb3Manager;
631
+ contractABI: AbiItem[];
632
+ contractAddress: string;
633
+ web3: Web3__default;
634
+ AudiusTokenContract: Contract;
635
+ bustCacheNonce: number;
636
+ constructor(ethWeb3Manager: EthWeb3Manager, contractABI: AbiItem[], contractAddress: string);
637
+ bustCache(): Promise<void>;
638
+ balanceOf(account: string): Promise<BN__default>;
639
+ name(): Promise<any>;
640
+ nonces(wallet: string): Promise<number>;
641
+ transfer(recipient: string, amount: BN__default): Promise<{
642
+ txReceipt: web3_core.TransactionReceipt;
643
+ }>;
644
+ transferFrom(owner: string, recipient: string, relayer: string, amount: BN__default): Promise<{
645
+ txReceipt: Maybe<{
646
+ txHash: string;
647
+ txParams: {
648
+ data: string;
649
+ gasLimit: string;
650
+ gasPrice: number;
651
+ nonce: string;
652
+ to: string;
653
+ value: string;
654
+ };
655
+ }>;
656
+ }>;
657
+ permit(owner: string, // address
658
+ spender: string, // address
659
+ value: BN__default, // uint
660
+ deadline: number, // uint
661
+ v: number, // uint8
662
+ r: Uint8Array | Buffer, // bytes32
663
+ s: Uint8Array | Buffer): Promise<Maybe<{
664
+ txHash: string;
665
+ txParams: {
666
+ data: string;
667
+ gasLimit: string;
668
+ gasPrice: number;
669
+ nonce: string;
670
+ to: string;
671
+ value: string;
672
+ };
673
+ }>>;
674
+ approve(spender: string, value: BN__default, privateKey?: null): Promise<{
675
+ txReceipt: web3_core.TransactionReceipt;
676
+ }>;
677
+ approveProxyTokens(owner: string, spender: string, value: BN__default, relayer: string): Promise<{
678
+ txReceipt: Maybe<{
679
+ txHash: string;
680
+ txParams: {
681
+ data: string;
682
+ gasLimit: string;
683
+ gasPrice: number;
684
+ nonce: string;
685
+ to: string;
686
+ value: string;
687
+ };
688
+ }>;
689
+ }>;
690
+ }
691
+
692
+ declare class RegistryClient {
693
+ web3Manager: EthWeb3Manager;
694
+ contractABI: AbiItem[];
695
+ contractAddress: string;
696
+ web3: Web3__default;
697
+ Registry: Contract;
698
+ constructor(web3Manager: EthWeb3Manager, contractABI: AbiItem[], contractAddress: string);
699
+ getContract(contractRegistryKey: string): Promise<string>;
700
+ }
701
+
702
+ /**
703
+ * This class provides the logic to select a healthy gateway
704
+ */
705
+ declare class ProviderSelection extends ServiceSelection {
706
+ services: string[];
707
+ constructor(services?: string[]);
708
+ /**
709
+ * Filters out previously tried providers, and then initializes the client
710
+ * (ContractClient, RegistryClient) with a healthy POA provider.
711
+ *
712
+ * @param client object used for making transaction calls
713
+ */
714
+ select(client: ContractClient): Promise<void>;
715
+ getServicesSize(): number;
716
+ }
717
+
718
+ declare type GetRegistryAddress = (key: string) => Promise<string>;
719
+ declare class ContractClient {
720
+ web3Manager: Web3Manager | EthWeb3Manager;
721
+ contractABI: ContractABI['abi'];
722
+ contractRegistryKey: string;
723
+ getRegistryAddress: GetRegistryAddress;
724
+ _contractAddress: Nullable<string>;
725
+ _contract: Nullable<Contract>;
726
+ _isInitialized: boolean;
727
+ _isInitializing: boolean;
728
+ _initAttempts: number;
729
+ providerSelector: Nullable<ProviderSelection>;
730
+ logger: Logger;
731
+ constructor(web3Manager: Web3Manager | EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, logger?: Logger, contractAddress?: Nullable<string>);
732
+ /** Inits the contract if necessary */
733
+ init(): Promise<void>;
734
+ retryInit(selectNewEndpoint?: boolean): Promise<void>;
735
+ /**
736
+ * Adds current provider into unhealthy set and selects the next healthy provider
737
+ */
738
+ selectNewEndpoint(): Promise<void>;
739
+ /** Gets the contract address and ensures that the contract has initted. */
740
+ getAddress(): Promise<string>;
741
+ /**
742
+ * Gets a contract method and ensures that the contract has initted
743
+ * The contract can then be invoked with .call() or be passed to a sendTransaction.
744
+ * @param methodName the name of the contract method
745
+ */
746
+ getMethod(methodName: string, ...args: any[]): Promise<any>;
747
+ getEthNetId(): Promise<number>;
748
+ getContract(): Promise<Contract>;
749
+ }
750
+
751
+ declare class StakingProxyClient extends ContractClient {
752
+ audiusTokenClient: AudiusTokenClient;
753
+ toBN: (value: string | number) => BN__default;
754
+ constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, logger?: Logger);
755
+ token(): Promise<any>;
756
+ totalStaked(): Promise<BN__default>;
757
+ supportsHistory(): Promise<any>;
758
+ totalStakedFor(account: string): Promise<BN__default>;
759
+ totalStakedForAt(account: string, blockNumber: string): Promise<BN__default>;
760
+ totalStakedAt(blockNumber: number): Promise<BN__default>;
761
+ isStaker(account: string): Promise<any>;
762
+ getDelegateManagerAddress(): Promise<any>;
763
+ getClaimsManagerAddress(): Promise<any>;
764
+ getServiceProviderFactoryAddress(): Promise<any>;
765
+ getGovernanceAddress(): Promise<any>;
766
+ getLastClaimedBlockForUser(): Promise<any>;
767
+ }
768
+
769
+ declare type ProposalTxn = {
770
+ proposalId: string;
771
+ proposer: string;
772
+ submissionBlockNumber: string;
773
+ targetContractRegistryKey: string;
774
+ targetContractAddress: string;
775
+ callValue: string;
776
+ functionSignature: string;
777
+ callData: string;
778
+ outcome: string;
779
+ numVotes: string;
780
+ voteMagnitudeYes: string;
781
+ voteMagnitudeNo: string;
782
+ };
783
+ declare class GovernanceClient extends ContractClient {
784
+ audiusTokenClient: AudiusTokenClient;
785
+ stakingProxyClient: StakingProxyClient;
786
+ isDebug: boolean;
787
+ constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, stakingProxyClient: StakingProxyClient, logger?: Logger, isDebug?: boolean);
788
+ /**
789
+ * Gets the function signature and call data for a contract method.
790
+ * The signature and call data are passed to other contracts (like governance)
791
+ * as arguments.
792
+ * @param methodName
793
+ * @param contractMethod
794
+ */
795
+ getSignatureAndCallData(methodName: string, contractMethod: ContractMethod): {
796
+ signature: string;
797
+ callData: string;
798
+ };
799
+ guardianExecuteTransaction(contractRegistryKey: string, functionSignature: string, callData: string): Promise<ContractMethod>;
800
+ getVotingPeriod(): Promise<number>;
801
+ setVotingPeriod(period: string): Promise<web3_core.TransactionReceipt>;
802
+ getVotingQuorumPercent(): Promise<number>;
803
+ getExecutionDelay(): Promise<number>;
804
+ setExecutionDelay(delay: number): Promise<web3_core.TransactionReceipt>;
805
+ getProposalById(id: number): Promise<{
806
+ proposalId: number;
807
+ proposer: string;
808
+ submissionBlockNumber: number;
809
+ targetContractRegistryKey: string;
810
+ targetContractAddress: string;
811
+ callValue: number;
812
+ functionSignature: string;
813
+ callData: string;
814
+ outcome: number;
815
+ numVotes: number;
816
+ voteMagnitudeYes: BN;
817
+ voteMagnitudeNo: BN;
818
+ }>;
819
+ getProposalTargetContractHash(id: string): Promise<any>;
820
+ getProposals(queryStartBlock?: number): Promise<{
821
+ proposalId: number;
822
+ proposer: any;
823
+ description: any;
824
+ name: any;
825
+ blockNumber: number;
826
+ }[]>;
827
+ getProposalsForAddresses(addresses: string[], queryStartBlock?: number): Promise<{
828
+ proposalId: number;
829
+ proposer: any;
830
+ description: any;
831
+ name: any;
832
+ blockNumber: number;
833
+ }[]>;
834
+ getProposalSubmission(proposalId: number, queryStartBlock?: number): Promise<{
835
+ proposalId: number;
836
+ proposer: any;
837
+ description: any;
838
+ name: any;
839
+ blockNumber: number;
840
+ }>;
841
+ getInProgressProposals(): Promise<any>;
842
+ submitProposal({ targetContractRegistryKey, callValue, functionSignature, callData, // array of args, e.g. [slashAmount, targetAddress]
843
+ name, description }: {
844
+ targetContractRegistryKey: string;
845
+ callValue: string;
846
+ functionSignature: string;
847
+ callData: string[];
848
+ name: string;
849
+ description: string;
850
+ }): Promise<any>;
851
+ submitVote({ proposalId, vote }: {
852
+ proposalId: number;
853
+ vote: string;
854
+ }): Promise<void>;
855
+ updateVote({ proposalId, vote }: {
856
+ proposalId: number;
857
+ vote: string;
858
+ }): Promise<void>;
859
+ evaluateProposalOutcome(proposalId: number): Promise<web3_core.TransactionReceipt>;
860
+ getProposalEvaluation(proposalId: number, queryStartBlock?: number): Promise<web3_eth_contract.EventData[]>;
861
+ getVotes({ proposalId, queryStartBlock }: {
862
+ proposalId: number;
863
+ queryStartBlock: number;
864
+ }): Promise<{
865
+ proposalId: number;
866
+ voter: any;
867
+ vote: number;
868
+ voterStake: BN;
869
+ blockNumber: number;
870
+ }[]>;
871
+ getVoteUpdates({ 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
+ getVoteSubmissionsByAddress({ addresses, queryStartBlock }: {
882
+ addresses: string[];
883
+ queryStartBlock: number;
884
+ }): Promise<{
885
+ proposalId: number;
886
+ voter: any;
887
+ vote: number;
888
+ voterStake: BN;
889
+ blockNumber: number;
890
+ }[]>;
891
+ getVoteUpdatesByAddress({ 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
+ getVoteByProposalAndVoter({ proposalId, voterAddress }: {
902
+ proposalId: number[];
903
+ voterAddress: number;
904
+ }): Promise<number>;
905
+ /**
906
+ * ABI encodes argument types and values together into one encoded string
907
+ */
908
+ abiEncode(types: string[], values: string[]): string;
909
+ toBN(val: string): BN;
910
+ /**
911
+ * Prune off extraneous fields from proposal returned by txn
912
+ */
913
+ formatProposal(proposal: ProposalTxn): {
914
+ proposalId: number;
915
+ proposer: string;
916
+ submissionBlockNumber: number;
917
+ targetContractRegistryKey: string;
918
+ targetContractAddress: string;
919
+ callValue: number;
920
+ functionSignature: string;
921
+ callData: string;
922
+ outcome: number;
923
+ numVotes: number;
924
+ voteMagnitudeYes: BN;
925
+ voteMagnitudeNo: BN;
926
+ };
927
+ /**
928
+ * Formats a proposal event
929
+ */
930
+ formatProposalEvent(proposalEvent: EventLog): {
931
+ proposalId: number;
932
+ proposer: any;
933
+ description: any;
934
+ name: any;
935
+ blockNumber: number;
936
+ };
937
+ /**
938
+ * Prune off extraneous fields from vote event
939
+ */
940
+ formatVote(voteEvent: EventLog): {
941
+ proposalId: number;
942
+ voter: any;
943
+ vote: number;
944
+ voterStake: BN;
945
+ blockNumber: number;
946
+ };
947
+ /**
948
+ *
949
+ * @param {Number} proposalId id of the governance proposal
950
+ * @returns {BN} amount of tokens in wei required to reach quorum
951
+ */
952
+ calculateQuorum(proposalId: number): Promise<any>;
953
+ }
954
+
955
+ /**
956
+ * Contract class that extends a ContractClient and provides an interface
957
+ * to retrieve governed methods that cannot be executed directly.
958
+ */
959
+ declare class GovernedContractClient extends ContractClient {
960
+ governanceClient: GovernanceClient;
961
+ constructor(web3Manager: Web3Manager | EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, governanceClient: GovernanceClient, logger?: Logger);
962
+ /**
963
+ * Gets a governed version of a method and allows a single transaction
964
+ * to be sent to the governance client with the appropriate payload.
965
+ * Similar to `getMethod`
966
+ */
967
+ getGovernedMethod(methodName: string, ...args: unknown[]): Promise<ContractMethod>;
968
+ }
969
+
970
+ declare class ServiceTypeManagerClient extends GovernedContractClient {
971
+ /**
972
+ *
973
+ * @param serviceType Type of service to set the version, either `discovery-node` or `content-node`
974
+ * @param serviceVersion Version string to set on chain
975
+ * @param privateKey Optional privateKey to pass along to web3Manager sendTransaction
976
+ * @param dryRun Optional parameter to return the generated parameters without sending tx
977
+ * @returns comma-separated String of serviceType and serviceVersion if dryRun; else response from web3Manager.sendTransaction
978
+ */
979
+ setServiceVersion(serviceType: string, serviceVersion: string, privateKey?: string | null, dryRun?: boolean): Promise<string | web3_core.TransactionReceipt>;
980
+ addServiceType(serviceType: string, serviceTypeMin: string, serviceTypeMax: string, privateKey?: string | null): Promise<web3_core.TransactionReceipt>;
981
+ getValidServiceTypes(): Promise<string[]>;
982
+ getCurrentVersion(serviceType: string): Promise<string>;
983
+ getVersion(serviceType: string, serviceTypeIndex: number): Promise<string>;
984
+ getNumberOfVersions(serviceType: string): Promise<number>;
985
+ /**
986
+ * @notice Add a new service type
987
+ * @returns {
988
+ * isValid: Is the types type is isValid
989
+ * minStake: minimum stake for service type
990
+ * maxStake: minimum stake for service type
991
+ * }
992
+ */
993
+ getServiceTypeInfo(serviceType: string): Promise<{
994
+ isValid: any;
995
+ minStake: BN;
996
+ maxStake: BN;
997
+ }>;
998
+ }
999
+
1000
+ declare type GetEvent$1 = {
1001
+ serviceType: string;
1002
+ owner: string;
1003
+ queryStartBlock: number;
1004
+ };
1005
+ declare class ServiceProviderFactoryClient extends GovernedContractClient {
1006
+ audiusTokenClient: AudiusTokenClient;
1007
+ stakingProxyClient: StakingProxyClient;
1008
+ isDebug: boolean;
1009
+ constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, stakingProxyClient: StakingProxyClient, governanceClient: GovernanceClient, logger?: Logger, isDebug?: boolean);
1010
+ registerWithDelegate(serviceType: string, endpoint: string, amount: number | string | BN__default, delegateOwnerWallet: string): Promise<{
1011
+ txReceipt: web3_core.TransactionReceipt;
1012
+ spID: number;
1013
+ serviceType: string;
1014
+ owner: any;
1015
+ endpoint: any;
1016
+ tokenApproveReceipt: {
1017
+ txReceipt: web3_core.TransactionReceipt;
1018
+ };
1019
+ }>;
1020
+ register(serviceType: string, endpoint: string, amount: BN__default): 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
+ getRegisteredServiceProviderEvents({ serviceType, owner, queryStartBlock }: GetEvent$1): Promise<{
1031
+ blockNumber: number;
1032
+ spID: number;
1033
+ serviceType: string;
1034
+ owner: any;
1035
+ endpoint: any;
1036
+ stakeAmount: BN__default;
1037
+ }[]>;
1038
+ getDeregisteredServiceProviderEvents({ serviceType, owner, queryStartBlock }: GetEvent$1): Promise<{
1039
+ blockNumber: number;
1040
+ spID: number;
1041
+ serviceType: string;
1042
+ owner: any;
1043
+ endpoint: any;
1044
+ stakeAmount: BN__default;
1045
+ }[]>;
1046
+ getIncreasedStakeEvents({ owner, queryStartBlock }: {
1047
+ owner: string;
1048
+ queryStartBlock: number;
1049
+ }): Promise<{
1050
+ blockNumber: number;
1051
+ owner: any;
1052
+ increaseAmount: BN__default;
1053
+ newStakeAmount: BN__default;
1054
+ }[]>;
1055
+ getDecreasedStakeEvaluatedEvents({ owner, queryStartBlock }: {
1056
+ owner: string;
1057
+ queryStartBlock: number;
1058
+ }): Promise<{
1059
+ blockNumber: number;
1060
+ owner: any;
1061
+ decreaseAmount: BN__default;
1062
+ newStakeAmount: BN__default;
1063
+ }[]>;
1064
+ getDecreasedStakeRequestedEvents({ owner, queryStartBlock }: {
1065
+ owner: string;
1066
+ queryStartBlock: number;
1067
+ }): Promise<{
1068
+ blockNumber: number;
1069
+ owner: any;
1070
+ decreaseAmount: BN__default;
1071
+ lockupExpiryBlock: number;
1072
+ }[]>;
1073
+ getDecreasedStakeCancelledEvents({ owner, queryStartBlock }: {
1074
+ owner: string;
1075
+ queryStartBlock: number;
1076
+ }): Promise<{
1077
+ blockNumber: number;
1078
+ owner: any;
1079
+ decreaseAmount: BN__default;
1080
+ lockupExpiryBlock: number;
1081
+ }[]>;
1082
+ getDeregisteredService({ serviceType, spID, queryStartBlock }: {
1083
+ serviceType: string;
1084
+ spID: string;
1085
+ queryStartBlock: number;
1086
+ }): Promise<{
1087
+ endpoint: string;
1088
+ delegateOwnerWallet: string;
1089
+ owner?: string | undefined;
1090
+ }>;
1091
+ increaseStake(amount: BN__default): Promise<{
1092
+ txReceipt: web3_core.TransactionReceipt;
1093
+ tokenApproveReceipt: {
1094
+ txReceipt: web3_core.TransactionReceipt;
1095
+ };
1096
+ }>;
1097
+ /**
1098
+ * Makes a request to decrease stake
1099
+ * @param amount
1100
+ * @returns decrease stake lockup expiry block
1101
+ */
1102
+ requestDecreaseStake(amount: BN__default): Promise<number>;
1103
+ /**
1104
+ * Gets the pending decrease stake request for a given account
1105
+ * @param account wallet address to fetch for
1106
+ */
1107
+ getPendingDecreaseStakeRequest(account: string): Promise<{
1108
+ amount: BN__default;
1109
+ lockupExpiryBlock: number;
1110
+ }>;
1111
+ /**
1112
+ * Gets the pending decrease stake lockup duration
1113
+ */
1114
+ getDecreaseStakeLockupDuration(): Promise<number>;
1115
+ /**
1116
+ * Gets the deployer cut lockup duration
1117
+ */
1118
+ getDeployerCutLockupDuration(): Promise<number>;
1119
+ /**
1120
+ * Cancels the pending decrease stake request
1121
+ * @param account wallet address to cancel request for
1122
+ */
1123
+ cancelDecreaseStakeRequest(account: string): Promise<void>;
1124
+ /**
1125
+ * Fetches the pending decrease stake lockup expiry block for a user
1126
+ * @param account wallet address to fetch for
1127
+ */
1128
+ getLockupExpiry(account: string): Promise<number>;
1129
+ decreaseStake(): Promise<{
1130
+ txReceipt: web3_core.TransactionReceipt;
1131
+ }>;
1132
+ /**
1133
+ * Deregisters a service
1134
+ * @param serviceType
1135
+ * @param endpoint
1136
+ */
1137
+ deregister(serviceType: string, endpoint: string): Promise<{
1138
+ txReceipt: web3_core.TransactionReceipt;
1139
+ spID: number;
1140
+ serviceType: string;
1141
+ owner: any;
1142
+ endpoint: any;
1143
+ }>;
1144
+ getTotalServiceTypeProviders(serviceType: string): Promise<number>;
1145
+ getServiceProviderIdFromEndpoint(endpoint: string): Promise<number>;
1146
+ getServiceProviderInfo(serviceType: string, serviceId: number): Promise<{
1147
+ owner: any;
1148
+ endpoint: any;
1149
+ spID: number;
1150
+ type: string;
1151
+ blockNumber: number;
1152
+ delegateOwnerWallet: any;
1153
+ }>;
1154
+ getServiceEndpointInfo(serviceType: string, serviceId: number): Promise<{
1155
+ owner: any;
1156
+ endpoint: any;
1157
+ spID: number;
1158
+ type: string;
1159
+ blockNumber: number;
1160
+ delegateOwnerWallet: any;
1161
+ }>;
1162
+ getServiceProviderInfoFromEndpoint(endpoint: string): Promise<{
1163
+ owner: any;
1164
+ endpoint: any;
1165
+ spID: number;
1166
+ type: string;
1167
+ blockNumber: number;
1168
+ delegateOwnerWallet: any;
1169
+ }>;
1170
+ getServiceProviderIdsFromAddress(ownerAddress: string, serviceType: string): Promise<number[]>;
1171
+ getServiceProviderIdFromAddress(ownerAddress: string, serviceType: string): Promise<number>;
1172
+ getServiceEndpointInfoFromAddress(ownerAddress: string, serviceType: string): Promise<{
1173
+ owner: any;
1174
+ endpoint: any;
1175
+ spID: number;
1176
+ type: string;
1177
+ blockNumber: number;
1178
+ delegateOwnerWallet: any;
1179
+ }[]>;
1180
+ /**
1181
+ * Returns all service providers of requested `serviceType`
1182
+ * Returns array of objects with schema { blockNumber, delegateOwnerWallet, endpoint, owner, spID, type }
1183
+ */
1184
+ getServiceProviderList(serviceType: string): Promise<{
1185
+ owner: any;
1186
+ endpoint: any;
1187
+ spID: number;
1188
+ type: string;
1189
+ blockNumber: number;
1190
+ delegateOwnerWallet: any;
1191
+ }[]>;
1192
+ updateDecreaseStakeLockupDuration(duration: string): Promise<web3_core.TransactionReceipt>;
1193
+ getServiceProviderDetails(serviceProviderAddress: string): Promise<{
1194
+ deployerCut: number;
1195
+ deployerStake: BN__default;
1196
+ maxAccountStake: BN__default;
1197
+ minAccountStake: BN__default;
1198
+ numberOfEndpoints: number;
1199
+ validBounds: any;
1200
+ }>;
1201
+ updateDelegateOwnerWallet(serviceType: string, endpoint: string, updatedDelegateOwnerWallet: string): Promise<web3_core.TransactionReceipt>;
1202
+ updateEndpoint(serviceType: string, oldEndpoint: string, newEndpoint: string): Promise<web3_core.TransactionReceipt>;
1203
+ requestUpdateDeployerCut(ownerAddress: string, deployerCut: string): Promise<web3_core.TransactionReceipt>;
1204
+ getPendingUpdateDeployerCutRequest(ownerAddress: string): Promise<{
1205
+ lockupExpiryBlock: number;
1206
+ newDeployerCut: number;
1207
+ }>;
1208
+ cancelUpdateDeployerCut(ownerAddress: string): Promise<web3_core.TransactionReceipt>;
1209
+ updateDeployerCut(ownerAddress: string): Promise<web3_core.TransactionReceipt>;
1210
+ updateServiceProviderStake(ownerAddress: string, newAmount: string): Promise<web3_core.TransactionReceipt>;
1211
+ }
1212
+
1213
+ declare type GetEvent = {
1214
+ delegator: string;
1215
+ serviceProvider: string;
1216
+ queryStartBlock: number;
1217
+ };
1218
+ declare class DelegateManagerClient extends GovernedContractClient {
1219
+ audiusTokenClient: AudiusTokenClient;
1220
+ stakingProxyClient: StakingProxyClient;
1221
+ constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractRegistryKey: string, getRegistryAddress: GetRegistryAddress, audiusTokenClient: AudiusTokenClient, stakingProxyClient: StakingProxyClient, governanceClient: GovernanceClient, logger?: Logger);
1222
+ delegateStake(targetSP: string, amount: BN__default): Promise<{
1223
+ txReceipt: web3_core.TransactionReceipt;
1224
+ tokenApproveReceipt: {
1225
+ txReceipt: web3_core.TransactionReceipt;
1226
+ };
1227
+ delegator: any;
1228
+ serviceProvider: any;
1229
+ increaseAmount: BN__default;
1230
+ }>;
1231
+ getIncreaseDelegateStakeEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1232
+ blockNumber: number;
1233
+ delegator: any;
1234
+ increaseAmount: BN__default;
1235
+ serviceProvider: any;
1236
+ }[]>;
1237
+ getDecreaseDelegateStakeEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1238
+ blockNumber: number;
1239
+ delegator: any;
1240
+ amount: BN__default;
1241
+ serviceProvider: any;
1242
+ }[]>;
1243
+ getUndelegateStakeRequestedEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1244
+ blockNumber: number;
1245
+ lockupExpiryBlock: number;
1246
+ delegator: any;
1247
+ amount: BN__default;
1248
+ serviceProvider: any;
1249
+ }[]>;
1250
+ getUndelegateStakeCancelledEvents({ delegator, serviceProvider, queryStartBlock }: GetEvent): Promise<{
1251
+ blockNumber: number;
1252
+ delegator: any;
1253
+ amount: BN__default;
1254
+ serviceProvider: any;
1255
+ }[]>;
1256
+ getClaimEvents({ claimer, queryStartBlock }: {
1257
+ claimer: string;
1258
+ queryStartBlock: number;
1259
+ }): Promise<{
1260
+ blockNumber: number;
1261
+ claimer: any;
1262
+ rewards: BN__default;
1263
+ newTotal: BN__default;
1264
+ }[]>;
1265
+ getSlashEvents({ target, queryStartBlock }: {
1266
+ target: string;
1267
+ queryStartBlock: number;
1268
+ }): Promise<{
1269
+ blockNumber: number;
1270
+ target: any;
1271
+ amount: BN__default;
1272
+ newTotal: BN__default;
1273
+ }[]>;
1274
+ getDelegatorRemovedEvents({ target, queryStartBlock }: {
1275
+ target: string;
1276
+ queryStartBlock: number;
1277
+ }): Promise<{
1278
+ blockNumber: number;
1279
+ serviceProvider: any;
1280
+ delegator: any;
1281
+ unstakedAmount: BN__default;
1282
+ }[]>;
1283
+ requestUndelegateStake(targetSP: string, amount: BN__default): Promise<web3_core.TransactionReceipt>;
1284
+ cancelUndelegateStakeRequest(): Promise<web3_core.TransactionReceipt>;
1285
+ undelegateStake(): Promise<{
1286
+ txReceipt: web3_core.TransactionReceipt;
1287
+ delegator: any;
1288
+ serviceProvider: any;
1289
+ decreaseAmount: BN__default;
1290
+ }>;
1291
+ claimRewards(serviceProvider: string, txRetries?: number): Promise<web3_core.TransactionReceipt>;
1292
+ requestRemoveDelegator(serviceProvider: string, delegator: string): Promise<web3_core.TransactionReceipt>;
1293
+ cancelRemoveDelegatorRequest(serviceProvider: string, delegator: string): Promise<web3_core.TransactionReceipt>;
1294
+ removeDelegator(serviceProvider: string, delegator: string): Promise<{
1295
+ txReceipt: web3_core.TransactionReceipt;
1296
+ delegator: any;
1297
+ serviceProvider: any;
1298
+ unstakedAmount: BN__default;
1299
+ }>;
1300
+ getDelegatorsList(serviceProvider: string): Promise<any>;
1301
+ getTotalDelegatedToServiceProvider(serviceProvider: string): Promise<BN__default>;
1302
+ getTotalDelegatorStake(delegator: string): Promise<BN__default>;
1303
+ getTotalLockedDelegationForServiceProvider(serviceProvider: string): Promise<BN__default>;
1304
+ getDelegatorStakeForServiceProvider(delegator: string, serviceProvider: string): Promise<BN__default>;
1305
+ getPendingUndelegateRequest(delegator: string): Promise<{
1306
+ amount: BN__default;
1307
+ lockupExpiryBlock: number;
1308
+ target: any;
1309
+ }>;
1310
+ getPendingRemoveDelegatorRequest(serviceProvider: string, delegator: string): Promise<{
1311
+ lockupExpiryBlock: number;
1312
+ }>;
1313
+ getUndelegateLockupDuration(): Promise<number>;
1314
+ getMaxDelegators(): Promise<number>;
1315
+ getMinDelegationAmount(): Promise<BN__default>;
1316
+ getRemoveDelegatorLockupDuration(): Promise<number>;
1317
+ getRemoveDelegatorEvalDuration(): Promise<number>;
1318
+ getGovernanceAddress(): Promise<any>;
1319
+ getServiceProviderFactoryAddress(): Promise<any>;
1320
+ getClaimsManagerAddress(): Promise<any>;
1321
+ getStakingAddress(): Promise<any>;
1322
+ getSPMinDelegationAmount({ serviceProvider }: {
1323
+ serviceProvider: string;
1324
+ }): Promise<BN__default>;
1325
+ updateSPMinDelegationAmount({ serviceProvider, amount }: {
1326
+ serviceProvider: string;
1327
+ amount: BN__default;
1328
+ }): Promise<web3_core.TransactionReceipt>;
1329
+ updateRemoveDelegatorLockupDuration(duration: string): Promise<web3_core.TransactionReceipt>;
1330
+ updateUndelegateLockupDuration(duration: string): Promise<web3_core.TransactionReceipt>;
1331
+ }
1332
+
1333
+ declare class ClaimsManagerClient extends ContractClient {
1334
+ web3Manager: EthWeb3Manager;
1335
+ getFundingRoundBlockDiff(): Promise<number>;
1336
+ getLastFundedBlock(): Promise<number>;
1337
+ getFundsPerRound(): Promise<BN>;
1338
+ getTotalClaimedInRound(): Promise<BN>;
1339
+ getGovernanceAddress(): Promise<any>;
1340
+ getServiceProviderFactoryAddress(): Promise<any>;
1341
+ getDelegateManagerAddress(): Promise<any>;
1342
+ getStakingAddress(): Promise<any>;
1343
+ claimPending(address: string): Promise<any>;
1344
+ initiateRound(txRetries?: number): Promise<web3_core.TransactionReceipt>;
1345
+ getClaimProcessedEvents({ claimer, queryStartBlock }: {
1346
+ claimer: string;
1347
+ queryStartBlock: number;
1348
+ }): Promise<{
1349
+ blockNumber: number;
1350
+ claimer: any;
1351
+ rewards: BN;
1352
+ oldTotal: BN;
1353
+ newTotal: BN;
1354
+ }[]>;
1355
+ }
1356
+
1357
+ declare class ClaimDistributionClient extends ContractClient {
1358
+ /**
1359
+ * Calls the contract method to check if the claim index has been claimed
1360
+ */
1361
+ isClaimed(index: number): Promise<any>;
1362
+ /**
1363
+ * Proxies the calls the contract method to make a claim
1364
+ * @param index
1365
+ * @param account
1366
+ * @param amount
1367
+ * @param merkleProof
1368
+ * @returns transaction
1369
+ */
1370
+ claim(index: number, account: string, amount: BN__default, merkleProof: string[]): Promise<Maybe<{
1371
+ txHash: string;
1372
+ txParams: {
1373
+ /**
1374
+ * Proxies the calls the contract method to make a claim
1375
+ * @param index
1376
+ * @param account
1377
+ * @param amount
1378
+ * @param merkleProof
1379
+ * @returns transaction
1380
+ */
1381
+ data: string;
1382
+ gasLimit: string;
1383
+ gasPrice: number;
1384
+ nonce: string;
1385
+ to: string;
1386
+ value: string;
1387
+ };
1388
+ }>>;
1389
+ }
1390
+
1391
+ declare class WormholeClient {
1392
+ ethWeb3Manager: EthWeb3Manager;
1393
+ contractABI: ContractABI['abi'];
1394
+ contractAddress: string;
1395
+ web3: Web3__default;
1396
+ audiusTokenClient: AudiusTokenClient;
1397
+ WormholeContract: Contract;
1398
+ constructor(ethWeb3Manager: EthWeb3Manager, contractABI: ContractABI['abi'], contractAddress: string, audiusTokenClient: AudiusTokenClient);
1399
+ nonces(wallet: string): Promise<number>;
1400
+ initialize(fromAcct: string, wormholeAddress: string, relayer: string): Promise<{
1401
+ txReceipt: Maybe<{
1402
+ txHash: string;
1403
+ txParams: {
1404
+ data: string;
1405
+ gasLimit: string;
1406
+ gasPrice: number;
1407
+ nonce: string;
1408
+ to: string;
1409
+ value: string;
1410
+ };
1411
+ }>;
1412
+ }>;
1413
+ /**
1414
+ * Transfers in eth from the user's wallet to the wormhole contract and
1415
+ * specifies a solana wallet to realized the tokens in SOL
1416
+ */
1417
+ transferTokens(fromAcct: string, amount: BN__default, chainId: number, solanaAccount: string, arbiterFee: string, deadline: string, signedDigest: {
1418
+ v: string;
1419
+ r: string;
1420
+ s: string;
1421
+ }, relayer: string): Promise<Maybe<{
1422
+ txHash: string;
1423
+ txParams: {
1424
+ data: string;
1425
+ gasLimit: string;
1426
+ gasPrice: number;
1427
+ nonce: string;
1428
+ to: string;
1429
+ value: string;
1430
+ };
1431
+ }>>;
1432
+ }
1433
+
1434
+ declare class EthRewardsManagerClient extends ContractClient {
1435
+ token(): Promise<any>;
1436
+ getGovernanceAddress(): Promise<any>;
1437
+ getRecipientAddress(): Promise<any>;
1438
+ getAntiAbuseOracleAddresses(): Promise<any>;
1439
+ }
1440
+
1441
+ declare class TrustedNotifierManagerClient extends GovernedContractClient {
1442
+ /**
1443
+ * Register Trusted Notifier with specified fields (wallet, endpoint, email)
1444
+ * @notice Only callable by Governance contract
1445
+ * @notice All fields must be unique and non-falsey
1446
+ * @notice New Trusted Notifier is assigned an auto-incremented integer ID
1447
+ * @returns Newly assigned integer ID
1448
+ */
1449
+ registerNotifier(wallet: string, endpoint: string, email: string, privateKey?: string | null): Promise<web3_core.TransactionReceipt>;
1450
+ /**
1451
+ * Deregister Trusted Notifier associated with wallet
1452
+ * @notice Only callable by Governance contract or wallet
1453
+ * @returns ID of deregistered Trusted Notifier
1454
+ */
1455
+ deregisterNotifier(wallet: string, privateKey?: string | null): Promise<web3_core.TransactionReceipt>;
1456
+ getLatestNotifierID(): Promise<number>;
1457
+ /**
1458
+ * Returns all TrustedNotifier info associated with ID
1459
+ */
1460
+ getNotifierForID(ID: string): Promise<{
1461
+ wallet: any;
1462
+ endpoint: any;
1463
+ email: any;
1464
+ }>;
1465
+ /**
1466
+ * Returns all TrustedNotifier info associated with wallet
1467
+ */
1468
+ getNotifierForWallet(wallet: string): Promise<{
1469
+ ID: any;
1470
+ endpoint: any;
1471
+ email: any;
1472
+ }>;
1473
+ /**
1474
+ * Returns all TrustedNotifier info associated with endpoint
1475
+ */
1476
+ getNotifierForEndpoint(endpoint: string): Promise<{
1477
+ ID: any;
1478
+ wallet: any;
1479
+ email: any;
1480
+ }>;
1481
+ /**
1482
+ * Returns all TrustedNotifier info associated with email
1483
+ */
1484
+ getNotifierForEmail(email: string): Promise<{
1485
+ ID: any;
1486
+ wallet: any;
1487
+ endpoint: any;
1488
+ }>;
1489
+ }
1490
+
1491
+ declare type EthContractsConfig = {
1492
+ ethWeb3Manager: EthWeb3Manager;
1493
+ tokenContractAddress: string;
1494
+ registryAddress: string;
1495
+ claimDistributionContractAddress: string;
1496
+ wormholeContractAddress: string;
1497
+ isServer?: boolean;
1498
+ logger?: Logger;
1499
+ isDebug?: boolean;
1500
+ };
1501
+ declare class EthContracts {
1502
+ ethWeb3Manager: EthWeb3Manager;
1503
+ tokenContractAddress: string;
1504
+ claimDistributionContractAddress: string;
1505
+ wormholeContractAddress: string;
1506
+ registryAddress: string;
1507
+ isServer: boolean;
1508
+ logger: Logger;
1509
+ isDebug: boolean;
1510
+ expectedServiceVersions: null | string[];
1511
+ AudiusTokenClient: AudiusTokenClient;
1512
+ RegistryClient: RegistryClient;
1513
+ StakingProxyClient: StakingProxyClient;
1514
+ GovernanceClient: GovernanceClient;
1515
+ ClaimsManagerClient: ClaimsManagerClient;
1516
+ EthRewardsManagerClient: EthRewardsManagerClient;
1517
+ ServiceTypeManagerClient: ServiceTypeManagerClient;
1518
+ ServiceProviderFactoryClient: ServiceProviderFactoryClient;
1519
+ DelegateManagerClient: DelegateManagerClient;
1520
+ ClaimDistributionClient: ClaimDistributionClient | undefined;
1521
+ WormholeClient: WormholeClient;
1522
+ TrustedNotifierManagerClient: TrustedNotifierManagerClient;
1523
+ contractClients: ContractClient[];
1524
+ _regressedMode: boolean;
1525
+ contracts: Record<string, string> | undefined;
1526
+ contractAddresses: Record<string, string> | undefined;
1527
+ constructor({ ethWeb3Manager, tokenContractAddress, registryAddress, claimDistributionContractAddress, wormholeContractAddress, isServer, logger, isDebug }: EthContractsConfig);
1528
+ init(): Promise<void>;
1529
+ /**
1530
+ * Estabilishes that connection to discovery providers has regressed
1531
+ */
1532
+ enterRegressedMode(): void;
1533
+ isInRegressedMode(): boolean;
1534
+ getRegistryAddressForContract(contractName: string): Promise<string>;
1535
+ getCurrentVersion(serviceType: string): Promise<string>;
1536
+ getExpectedServiceVersions(): Promise<Record<string, string | null | undefined>>;
1537
+ /**
1538
+ * Determine whether major and minor versions match for two version strings
1539
+ * Version string 2 must have equivalent major/minor versions and a patch >= version1
1540
+ * @param version1 string 1
1541
+ * @param version2 string 2
1542
+ */
1543
+ isValidSPVersion(version1: string, version2: string): boolean;
1544
+ /**
1545
+ * Determines whether the major and minor versions are equal
1546
+ * @param version1 string 1
1547
+ * @param version2 string 2
1548
+ */
1549
+ hasSameMajorAndMinorVersion(version1: string, version2: string): boolean;
1550
+ getServiceProviderList(spType: string): Promise<{
1551
+ owner: any;
1552
+ endpoint: any;
1553
+ spID: number;
1554
+ type: string;
1555
+ blockNumber: number;
1556
+ delegateOwnerWallet: any;
1557
+ }[]>;
1558
+ getNumberOfVersions(spType: string): Promise<number>;
1559
+ getVersion(spType: string, queryIndex: number): Promise<string>;
1560
+ getServiceTypeInfo(spType: string): Promise<{
1561
+ isValid: any;
1562
+ minStake: BN;
1563
+ maxStake: BN;
1564
+ }>;
1565
+ }
1566
+
1567
+ declare type DiscoveryProviderSelectionConfig = Omit<ServiceSelectionConfig, 'getServices'> & {
1568
+ reselectTimeout?: number;
1569
+ selectionCallback?: (endpoint: string, decisionTree: Decision[]) => void;
1570
+ monitoringCallbacks?: {
1571
+ healthCheck: (config: Record<string, unknown>) => void;
1572
+ request: (config: Record<string, unknown>) => void;
1573
+ };
1574
+ unhealthySlotDiffPlays?: number;
1575
+ unhealthyBlockDiff?: number;
1576
+ };
1577
+ declare class DiscoveryProviderSelection extends ServiceSelection {
1578
+ currentVersion: string;
1579
+ ethContracts: EthContracts;
1580
+ reselectTimeout: Maybe<number>;
1581
+ selectionCallback: Maybe<DiscoveryProviderSelectionConfig['selectionCallback']>;
1582
+ monitoringCallbacks: NonNullable<DiscoveryProviderSelectionConfig['monitoringCallbacks']> | {};
1583
+ unhealthySlotDiffPlays: Nullable<number>;
1584
+ unhealthyBlockDiff: number;
1585
+ _regressedMode: boolean;
1586
+ validVersions: Nullable<string[]>;
1587
+ constructor(config: DiscoveryProviderSelectionConfig, ethContracts: EthContracts);
1588
+ /** Retrieves a cached discovery provider from localstorage */
1589
+ getCached(): any;
1590
+ /** Clears any cached discovery provider from localstorage */
1591
+ clearCached(): void;
1592
+ /** Sets a cached discovery provider in localstorage */
1593
+ setCached(endpoint: string): void;
1594
+ /** Allows the selection take a shortcut if there's a cached provider */
1595
+ shortcircuit(): any;
1596
+ select(): Promise<any>;
1597
+ /**
1598
+ * Checks whether a given response is healthy:
1599
+ * - Not behind in blocks
1600
+ * - 200 response
1601
+ * - Current version
1602
+ *
1603
+ * Other responses are collected in `this.backups` if
1604
+ * - Behind by only a patch version
1605
+ *
1606
+ * @param response axios response
1607
+ * @param urlMap health check urls mapped to their cannonical url
1608
+ * e.g. https://discoveryprovider.audius.co/health_check => https://discoveryprovider.audius.co
1609
+ */
1610
+ isHealthy(response: AxiosResponse, urlMap: Record<string, string>): boolean;
1611
+ /**
1612
+ * Estabilishes that connection to discovery providers has regressed
1613
+ */
1614
+ enterRegressedMode(): void;
1615
+ setUnhealthyBlockDiff(updatedDiff?: number): void;
1616
+ setUnhealthySlotDiffPlays(updatedDiff: number): void;
1617
+ isInRegressedMode(): boolean;
1618
+ /**
1619
+ * In the case of no "healthy" services, we resort to backups in the following order:
1620
+ * 1. Pick the most recent (patch) version that's not behind
1621
+ * 2. Pick the least behind provider that is a valid patch version and enter "regressed mode"
1622
+ * 3. Pick `null`
1623
+ */
1624
+ selectFromBackups(): Promise<string>;
402
1625
  }
403
1626
 
404
1627
  declare type CurrentUser = {
@@ -427,6 +1650,521 @@ declare class UserStateManager {
427
1650
  clearUser(): void;
428
1651
  }
429
1652
 
1653
+ declare type RequestParams = {
1654
+ queryParams: Record<string, string>;
1655
+ endpoint: string;
1656
+ timeout?: number;
1657
+ method?: Method;
1658
+ urlParams?: PathArg;
1659
+ headers?: Record<string, string>;
1660
+ data?: Record<string, unknown>;
1661
+ };
1662
+ declare type DiscoveryProviderConfig = {
1663
+ whitelist?: Set<string>;
1664
+ blacklist?: Set<string>;
1665
+ userStateManager: UserStateManager;
1666
+ ethContracts: EthContracts;
1667
+ web3Manager?: Web3Manager;
1668
+ reselectTimeout?: number;
1669
+ selectionCallback?: DiscoveryProviderSelectionConfig['selectionCallback'];
1670
+ monitoringCallbacks?: DiscoveryProviderSelectionConfig['monitoringCallbacks'];
1671
+ selectionRequestTimeout?: number;
1672
+ selectionRequestRetries?: number;
1673
+ unhealthySlotDiffPlays?: number;
1674
+ unhealthyBlockDiff?: number;
1675
+ };
1676
+ declare type UserProfile = {
1677
+ userId: number;
1678
+ email: string;
1679
+ name: string;
1680
+ handle: string;
1681
+ verified: boolean;
1682
+ imageURL?: string;
1683
+ sub: number;
1684
+ iat: string;
1685
+ };
1686
+ /**
1687
+ * Constructs a service class for a discovery node
1688
+ * @param whitelist whether or not to only include specified nodes in selection
1689
+ * @param userStateManager singleton UserStateManager instance
1690
+ * @param ethContracts singleton EthContracts instance
1691
+ * @param web3Manager
1692
+ * @param reselectTimeout timeout to clear locally cached discovery providers
1693
+ * @param selectionCallback invoked when a discovery node is selected
1694
+ * @param monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
1695
+ * @param monitoringCallbacks.request
1696
+ * @param monitoringCallbacks.healthCheck
1697
+ * @param selectionRequestTimeout the amount of time (ms) an individual request should take before reselecting
1698
+ * @param selectionRequestRetries the number of retries to a given discovery node we make before reselecting
1699
+ * @param unhealthySlotDiffPlays the number of slots we would consider a discovery node unhealthy
1700
+ * @param unhealthyBlockDiff the number of missed blocks after which we would consider a discovery node unhealthy
1701
+ */
1702
+ declare class DiscoveryProvider {
1703
+ whitelist: Set<string> | undefined;
1704
+ blacklist: Set<string> | undefined;
1705
+ userStateManager: UserStateManager;
1706
+ ethContracts: EthContracts;
1707
+ web3Manager: Web3Manager | undefined;
1708
+ unhealthyBlockDiff: number;
1709
+ serviceSelector: DiscoveryProviderSelection;
1710
+ selectionRequestTimeout: number;
1711
+ selectionRequestRetries: number;
1712
+ unhealthySlotDiffPlays: number | undefined;
1713
+ request404Count: number;
1714
+ maxRequestsForTrue404: number;
1715
+ monitoringCallbacks: DiscoveryProviderSelection['monitoringCallbacks'] | undefined;
1716
+ discoveryProviderEndpoint: string | undefined;
1717
+ constructor({ whitelist, blacklist, userStateManager, ethContracts, web3Manager, reselectTimeout, selectionCallback, monitoringCallbacks, selectionRequestTimeout, selectionRequestRetries, unhealthySlotDiffPlays, unhealthyBlockDiff }: DiscoveryProviderConfig);
1718
+ init(): Promise<void>;
1719
+ setEndpoint(endpoint: string): void;
1720
+ setUnhealthyBlockDiff(updatedBlockDiff?: number): void;
1721
+ setUnhealthySlotDiffPlays(updatedDiff: number): void;
1722
+ /**
1723
+ * Get users with all relevant user data
1724
+ * can be filtered by providing an integer array of ids
1725
+ * @param limit
1726
+ * @param offset
1727
+ * @param idsArray
1728
+ * @param walletAddress
1729
+ * @param handle
1730
+ * @param isCreator null returns all users, true returns creators only, false returns users only
1731
+ * @returns {Object} {Array of User metadata Objects}
1732
+ * additional metadata fields on user objects:
1733
+ * {Integer} track_count - track count for given user
1734
+ * {Integer} playlist_count - playlist count for given user
1735
+ * {Integer} album_count - album count for given user
1736
+ * {Integer} follower_count - follower count for given user
1737
+ * {Integer} followee_count - followee count for given user
1738
+ * {Integer} repost_count - repost count for given user
1739
+ * {Integer} track_blocknumber - blocknumber of latest track for user
1740
+ * {Boolean} does_current_user_follow - does current user follow given user
1741
+ * {Array} followee_follows - followees of current user that follow given user
1742
+ * @example
1743
+ * await getUsers()
1744
+ * await getUsers(100, 0, [3,2,6]) - Invalid user ids will not be accepted
1745
+ */
1746
+ getUsers(limit?: number, offset?: number, idsArray?: string[], walletAddress?: string, handle?: string, isCreator?: null, minBlockNumber?: number): Promise<unknown>;
1747
+ /**
1748
+ * get tracks with all relevant track data
1749
+ * can be filtered by providing an integer array of ids
1750
+ * @param limit
1751
+ * @param offset
1752
+ * @param idsArray
1753
+ * @param targetUserId the owner of the tracks being queried
1754
+ * @param sort a string of form eg. blocknumber:asc,timestamp:desc describing a sort path
1755
+ * @param minBlockNumber The min block number
1756
+ * @param filterDeleted If set to true, filters the deleted tracks
1757
+ * @returns {Object} {Array of track metadata Objects}
1758
+ * additional metadata fields on track objects:
1759
+ * {Integer} repost_count - repost count for given track
1760
+ * {Integer} save_count - save count for given track
1761
+ * {Array} followee_reposts - followees of current user that have reposted given track
1762
+ * {Boolean} has_current_user_reposted - has current user reposted given track
1763
+ * {Boolean} has_current_user_saved - has current user saved given track
1764
+ * @example
1765
+ * await getTracks()
1766
+ * await getTracks(100, 0, [3,2,6]) - Invalid track ids will not be accepted
1767
+ */
1768
+ getTracks(limit?: number, offset?: number, idsArray?: string[], targetUserId?: string, sort?: boolean, minBlockNumber?: number, filterDeleted?: boolean, withUsers?: boolean): Promise<unknown>;
1769
+ /**
1770
+ * Gets a particular track by its creator's handle and the track's URL slug
1771
+ * @param handle the handle of the owner of the track
1772
+ * @param slug the URL slug of the track, generally the title urlized
1773
+ * @returns {Object} the requested track's metadata
1774
+ */
1775
+ getTracksByHandleAndSlug(handle: string, slug: string): Promise<unknown>;
1776
+ /**
1777
+ * @typedef {Object} getTracksIdentifier
1778
+ * @property {string} handle
1779
+ * @property {number} id
1780
+ * @property {string} url_title
1781
+ */
1782
+ /**
1783
+ * gets all tracks matching identifiers, including unlisted.
1784
+ *
1785
+ * @param identifiers
1786
+ * @returns {(Array)} track
1787
+ */
1788
+ getTracksIncludingUnlisted(identifiers: string[], withUsers?: boolean): Promise<unknown>;
1789
+ /**
1790
+ * Gets random tracks from trending tracks for a given genre.
1791
+ * If genre not given, will return trending tracks across all genres.
1792
+ * Excludes specified track ids.
1793
+ *
1794
+ * @param genre
1795
+ * @param limit
1796
+ * @param exclusionList
1797
+ * @param time
1798
+ * @returns {(Array)} track
1799
+ */
1800
+ getRandomTracks(genre: string, limit: number, exclusionList: number[], time: string): Promise<unknown>;
1801
+ /**
1802
+ * Gets all stems for a given trackId as an array of tracks.
1803
+ * @param trackId
1804
+ * @returns {(Array)} track
1805
+ */
1806
+ getStemsForTrack(trackId: number): Promise<unknown>;
1807
+ /**
1808
+ * Gets all the remixes of a given trackId as an array of tracks.
1809
+ * @param trackId
1810
+ * @param limit
1811
+ * @param offset
1812
+ * @returns {(Array)} track
1813
+ */
1814
+ getRemixesOfTrack(trackId: number, limit?: number, offset?: number): Promise<unknown>;
1815
+ /**
1816
+ * Gets the remix parents of a given trackId as an array of tracks.
1817
+ * @param limit
1818
+ * @param offset
1819
+ * @returns {(Array)} track
1820
+ */
1821
+ getRemixTrackParents(trackId: number, limit?: number, offset?: number): Promise<unknown>;
1822
+ /**
1823
+ * Gets tracks trending on Audius.
1824
+ * @param genre
1825
+ * @param timeFrame one of day, week, month, or year
1826
+ * @param idsArray track ids
1827
+ * @param limit
1828
+ * @param offset
1829
+ */
1830
+ getTrendingTracks(genre?: string, timeFrame?: string, idsArray?: number[], limit?: number, offset?: number, withUsers?: boolean): Promise<{
1831
+ listenCounts: Array<{
1832
+ trackId: number;
1833
+ listens: number;
1834
+ }>;
1835
+ } | null | undefined>;
1836
+ /**
1837
+ * get full playlist objects, including tracks, for passed in array of playlistId
1838
+ * @returns {Array} array of playlist objects
1839
+ * additional metadata fields on playlist objects:
1840
+ * {Integer} repost_count - repost count for given playlist
1841
+ * {Integer} save_count - save count for given playlist
1842
+ * {Boolean} has_current_user_reposted - has current user reposted given playlist
1843
+ * {Array} followee_reposts - followees of current user that have reposted given playlist
1844
+ * {Boolean} has_current_user_reposted - has current user reposted given playlist
1845
+ * {Boolean} has_current_user_saved - has current user saved given playlist
1846
+ */
1847
+ getPlaylists(limit?: number, offset?: number, idsArray?: null, targetUserId?: null, withUsers?: boolean): Promise<unknown>;
1848
+ /**
1849
+ * Return social feed for current user
1850
+ * @param filter - filter by "all", "original", or "repost"
1851
+ * @param limit - max # of items to return
1852
+ * @param offset - offset into list to return from (for pagination)
1853
+ * @returns {Object} {Array of track and playlist metadata objects}
1854
+ * additional metadata fields on track and playlist objects:
1855
+ * {String} activity_timestamp - timestamp of requested user's repost for given track or playlist,
1856
+ * used for sorting feed
1857
+ * {Integer} repost_count - repost count of given track/playlist
1858
+ * {Integer} save_count - save count of given track/playlist
1859
+ * {Boolean} has_current_user_reposted - has current user reposted given track/playlist
1860
+ * {Array} followee_reposts - followees of current user that have reposted given track/playlist
1861
+ */
1862
+ getSocialFeed(filter: string, limit?: number, offset?: number, withUsers?: boolean, tracksOnly?: boolean): Promise<unknown>;
1863
+ /**
1864
+ * Return repost feed for requested user
1865
+ * @param userId - requested user id
1866
+ * @param limit - max # of items to return (for pagination)
1867
+ * @param offset - offset into list to return from (for pagination)
1868
+ * @returns {Object} {Array of track and playlist metadata objects}
1869
+ * additional metadata fields on track and playlist objects:
1870
+ * {String} activity_timestamp - timestamp of requested user's repost for given track or playlist,
1871
+ * used for sorting feed
1872
+ * {Integer} repost_count - repost count of given track/playlist
1873
+ * {Integer} save_count - save count of given track/playlist
1874
+ * {Boolean} has_current_user_reposted - has current user reposted given track/playlist
1875
+ * {Array} followee_reposts - followees of current user that have reposted given track/playlist
1876
+ */
1877
+ getUserRepostFeed(userId: number, limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
1878
+ /**
1879
+ * get intersection of users that follow followeeUserId and users that are followed by followerUserId
1880
+ * @param followeeUserId user that is followed
1881
+ * @param followerUserId user that follows
1882
+ * @example
1883
+ * getFollowIntersectionUsers(100, 0, 1, 1) - IDs must be valid
1884
+ */
1885
+ getFollowIntersectionUsers(limit: number | undefined, offset: number | undefined, followeeUserId: number, followerUserId: number): Promise<unknown>;
1886
+ /**
1887
+ * get intersection of users that have reposted repostTrackId and users that are followed by followerUserId
1888
+ * followee = user that is followed; follower = user that follows
1889
+ * @param repostTrackId track that is reposted
1890
+ * @param followerUserId user that reposted track
1891
+ * @example
1892
+ * getTrackRepostIntersectionUsers(100, 0, 1, 1) - IDs must be valid
1893
+ */
1894
+ getTrackRepostIntersectionUsers(limit: number | undefined, offset: number | undefined, repostTrackId: number, followerUserId: number): Promise<unknown>;
1895
+ /**
1896
+ * get intersection of users that have reposted repostPlaylistId and users that are followed by followerUserId
1897
+ * followee = user that is followed; follower = user that follows
1898
+ * @param repostPlaylistId playlist that is reposted
1899
+ * @param followerUserId user that reposted track
1900
+ * @example
1901
+ * getPlaylistRepostIntersectionUsers(100, 0, 1, 1) - IDs must be valid
1902
+ */
1903
+ getPlaylistRepostIntersectionUsers(limit: number | undefined, offset: number | undefined, repostPlaylistId: number, followerUserId: number): Promise<unknown>;
1904
+ /**
1905
+ * get users that follow followeeUserId, sorted by follower count descending
1906
+ * @param followeeUserId user that is followed
1907
+ * @return {Array} array of user objects with standard user metadata
1908
+ */
1909
+ getFollowersForUser(limit: number | undefined, offset: number | undefined, followeeUserId: number): Promise<unknown>;
1910
+ /**
1911
+ * get users that are followed by followerUserId, sorted by follower count descending
1912
+ * @param followerUserId user - i am the one who follows
1913
+ * @return {Array} array of user objects with standard user metadata
1914
+ */
1915
+ getFolloweesForUser(limit: number | undefined, offset: number | undefined, followerUserId: number): Promise<unknown>;
1916
+ /**
1917
+ * get users that reposted repostTrackId, sorted by follower count descending
1918
+ * @param repostTrackId
1919
+ * @return {Array} array of user objects
1920
+ * additional metadata fields on user objects:
1921
+ * {Integer} follower_count - follower count of given user
1922
+ * @example
1923
+ * getRepostersForTrack(100, 0, 1) - ID must be valid
1924
+ */
1925
+ getRepostersForTrack(limit: number | undefined, offset: number | undefined, repostTrackId: number): Promise<unknown>;
1926
+ /**
1927
+ * get users that reposted repostPlaylistId, sorted by follower count descending
1928
+ * @param repostPlaylistId
1929
+ * @return {Array} array of user objects
1930
+ * additional metadata fields on user objects:
1931
+ * {Integer} follower_count - follower count of given user
1932
+ * @example
1933
+ * getRepostersForPlaylist(100, 0, 1) - ID must be valid
1934
+ */
1935
+ getRepostersForPlaylist(limit: number | undefined, offset: number | undefined, repostPlaylistId: number): Promise<unknown>;
1936
+ /**
1937
+ * get users that saved saveTrackId, sorted by follower count descending
1938
+ * @param saveTrackId
1939
+ * @return {Array} array of user objects
1940
+ * additional metadata fields on user objects:
1941
+ * {Integer} follower_count - follower count of given user
1942
+ * @example
1943
+ * getSaversForTrack(100, 0, 1) - ID must be valid
1944
+ */
1945
+ getSaversForTrack(limit: number | undefined, offset: number | undefined, saveTrackId: number): Promise<unknown>;
1946
+ /**
1947
+ * get users that saved savePlaylistId, sorted by follower count descending
1948
+ * @param savePlaylistId
1949
+ * @return {Array} array of user objects
1950
+ * additional metadata fields on user objects:
1951
+ * {Integer} follower_count - follower count of given user
1952
+ * @example
1953
+ * getSaversForPlaylist(100, 0, 1) - ID must be valid
1954
+ */
1955
+ getSaversForPlaylist(limit: number | undefined, offset: number | undefined, savePlaylistId: number): Promise<unknown>;
1956
+ /**
1957
+ * get whether a JWT given by Audius Oauth popup is valid
1958
+ * @param token - JWT
1959
+ * @return {UserProfile | false} profile info of user attached to JWT payload if the JWT is valid, else false
1960
+ */
1961
+ verifyToken(token: string): Promise<UserProfile | false>;
1962
+ /**
1963
+ * Perform a full-text search. Returns tracks, users, playlists, albums
1964
+ * with optional user-specific results for each
1965
+ * - user, track, and playlist objects have all same data as returned from standalone endpoints
1966
+ * @param text search query
1967
+ * @param kind 'tracks', 'users', 'playlists', 'albums', 'all'
1968
+ * @param limit max # of items to return per list (for pagination)
1969
+ * @param offset offset into list to return from (for pagination)
1970
+ */
1971
+ searchFull(text: string, kind: string, limit?: number, offset?: number): Promise<unknown>;
1972
+ /**
1973
+ * Perform a lighter-weight full-text search. Returns tracks, users, playlists, albums
1974
+ * with optional user-specific results for each
1975
+ * - user, track, and playlist objects have core data, and track & playlist objects
1976
+ * also return user object
1977
+ * @param text search query
1978
+ * @param limit max # of items to return per list (for pagination)
1979
+ * @param offset offset into list to return from (for pagination)
1980
+ */
1981
+ searchAutocomplete(text: string, limit?: number, offset?: number): Promise<unknown>;
1982
+ /**
1983
+ * Perform a tags-only search. Returns tracks with required tag and users
1984
+ * that have used a tag greater than a specified number of times
1985
+ * @param text search query
1986
+ * @param userTagCount min # of times a user must have used a tag to be returned
1987
+ * @param kind 'tracks', 'users', 'playlists', 'albums', 'all'
1988
+ * @param limit max # of items to return per list (for pagination)
1989
+ * @param offset offset into list to return from (for pagination)
1990
+ */
1991
+ searchTags(text: string, userTagCount?: number, kind?: string, limit?: number, offset?: number): Promise<unknown>;
1992
+ /**
1993
+ * Return saved playlists for current user
1994
+ * NOTE in returned JSON, SaveType string one of track, playlist, album
1995
+ * @param limit - max # of items to return
1996
+ * @param offset - offset into list to return from (for pagination)
1997
+ */
1998
+ getSavedPlaylists(limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
1999
+ /**
2000
+ * Return saved albums for current user
2001
+ * NOTE in returned JSON, SaveType string one of track, playlist, album
2002
+ * @param limit - max # of items to return
2003
+ * @param offset - offset into list to return from (for pagination)
2004
+ */
2005
+ getSavedAlbums(limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
2006
+ /**
2007
+ * Return saved tracks 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
+ getSavedTracks(limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
2013
+ /**
2014
+ * Return user collections (saved & uploaded) along w/ users for those collections
2015
+ */
2016
+ getUserAccount(wallet: string): Promise<CurrentUser | null | undefined>;
2017
+ getTopPlaylists(type: string, limit: number, mood: string, filter: string, withUsers?: boolean): Promise<unknown>;
2018
+ getTopFolloweeWindowed(type: string, window: string, limit: string, withUsers?: boolean): Promise<unknown>;
2019
+ getTopFolloweeSaves(type: string, limit: string, withUsers?: boolean): Promise<unknown>;
2020
+ getLatest(type: string): Promise<unknown>;
2021
+ getTopCreatorsByGenres(genres: string[], limit?: number, offset?: number, withUsers?: boolean): Promise<unknown>;
2022
+ getURSMContentNodes(ownerWallet?: string | null): Promise<unknown>;
2023
+ getNotifications(minBlockNumber: string, trackIds: string[], timeout: number): Promise<unknown>;
2024
+ getSolanaNotifications(minSlotNumber: number, timeout: number): Promise<unknown>;
2025
+ getTrackListenMilestones(timeout: number): Promise<unknown>;
2026
+ getChallengeAttestation(challengeId: string, encodedUserId: string, specifier: string, oracleAddress: string, discoveryProviderEndpoint: string): Promise<any>;
2027
+ getCreateSenderAttestation(senderEthAddress: string, discoveryProviderEndpoint: string): Promise<any>;
2028
+ getUndisbursedChallenges(limit?: number | null, offset?: number | null, completedBlockNumber?: string | null, encodedUserId?: number | null): Promise<{
2029
+ amount: number;
2030
+ }[]>;
2031
+ /**
2032
+ * Performs a single request, defined in the request, via axios, calling any
2033
+ * monitoring callbacks as needed.
2034
+ *
2035
+ * @param {{
2036
+ endpoint: string,
2037
+ urlParams: string,
2038
+ queryParams: object,
2039
+ method: string,
2040
+ headers: object,
2041
+ }} requestObj
2042
+ * @param {string} discoveryProviderEndpoint
2043
+ * @returns
2044
+ * @memberof DiscoveryProvider
2045
+ */
2046
+ _performRequestWithMonitoring(requestObj: RequestParams, discoveryProviderEndpoint: string): Promise<any>;
2047
+ /**
2048
+ * Gets how many blocks behind a discovery node is.
2049
+ * If this method throws (missing data in health check response),
2050
+ * return an unhealthy number of blocks
2051
+ * @param parsedResponse health check response object
2052
+ * @returns a number of blocks if behind or null if not behind
2053
+ */
2054
+ _getBlocksBehind(parsedResponse: {
2055
+ latest_indexed_block: number;
2056
+ latest_chain_block: number;
2057
+ }): Promise<number | null>;
2058
+ /**
2059
+ * Gets how many plays slots behind a discovery node is.
2060
+ * If this method throws (missing data in health check response),
2061
+ * return an unhealthy number of slots
2062
+ * @param parsedResponse health check response object
2063
+ * @returns a number of slots if behind or null if not behind
2064
+ */
2065
+ _getPlaysSlotsBehind(parsedResponse: {
2066
+ latest_indexed_slot_plays: number;
2067
+ latest_chain_slot_plays: number;
2068
+ }): Promise<number | null>;
2069
+ /**
2070
+ * Makes a request to a discovery node, reselecting if necessary
2071
+ * @param {{
2072
+ * endpoint: string
2073
+ * urlParams: object
2074
+ * queryParams: object
2075
+ * method: string
2076
+ * headers: object
2077
+ * }} {
2078
+ * endpoint: the base route
2079
+ * urlParams: string of URL params to be concatenated after base route
2080
+ * queryParams: URL query (search) params
2081
+ * method: string HTTP method
2082
+ * }
2083
+ * @param retry whether to retry on failure
2084
+ * @param attemptedRetries number of attempted retries (stops retrying at max)
2085
+ */
2086
+ _makeRequest<Response>(requestObj: Record<string, unknown>, retry?: boolean, attemptedRetries?: number): Promise<Response | undefined | null>;
2087
+ /**
2088
+ * Gets the healthy discovery provider endpoint used in creating the axios request later.
2089
+ * If the number of retries is over the max count for retires, clear the cache and reselect
2090
+ * another healthy discovery provider. Else, return the current discovery provider endpoint
2091
+ * @param attemptedRetries the number of attempted requests made to the current disc prov endpoint
2092
+ */
2093
+ getHealthyDiscoveryProviderEndpoint(attemptedRetries: number): Promise<string>;
2094
+ /**
2095
+ * Creates the discovery provider axios request object with necessary configs
2096
+ * @param requestObj
2097
+ * @param discoveryProviderEndpoint
2098
+ */
2099
+ _createDiscProvRequest(requestObj: RequestParams, discoveryProviderEndpoint: string): AxiosRequestConfig;
2100
+ }
2101
+
2102
+ declare type LoginSuccessCallback = (profile: UserProfile) => void;
2103
+ declare type LoginErrorCallback = (errorMessage: string) => void;
2104
+ declare type ButtonOptions = {
2105
+ size: 'small' | 'medium' | 'large';
2106
+ corners: 'default' | 'pill';
2107
+ customText: string;
2108
+ disableHoverGrow: boolean;
2109
+ fullWidth: boolean;
2110
+ };
2111
+ declare type OauthConfig = {
2112
+ appName?: string;
2113
+ discoveryProvider: DiscoveryProvider;
2114
+ };
2115
+ declare class Oauth {
2116
+ discoveryProvider: DiscoveryProvider;
2117
+ appName: string | null;
2118
+ activePopupWindow: null | Window;
2119
+ popupCheckInterval: NodeJS.Timer | null;
2120
+ loginSuccessCallback: LoginSuccessCallback | null;
2121
+ loginErrorCallback: LoginErrorCallback | null;
2122
+ constructor({ discoveryProvider, appName }: OauthConfig);
2123
+ init(successCallback: LoginSuccessCallback, errorCallback?: LoginErrorCallback): void;
2124
+ login(): void;
2125
+ renderButton(element: HTMLElement, options?: ButtonOptions): void;
2126
+ verifyToken(token: string): Promise<false | UserProfile>;
2127
+ _surfaceError(errorMessage: string): void;
2128
+ _clearPopupCheckInterval(): void;
2129
+ _receiveMessage(event: MessageEvent): Promise<void>;
2130
+ }
2131
+
2132
+ declare type Web3Config = {
2133
+ providers: string[];
2134
+ };
2135
+ declare type SdkConfig = {
2136
+ appName: string;
2137
+ discoveryNodeConfig?: DiscoveryProviderConfig;
2138
+ ethContractsConfig?: EthContractsConfig;
2139
+ ethWeb3Config?: EthWeb3Config;
2140
+ identityServiceConfig?: IdentityService;
2141
+ web3Config?: Web3Config;
2142
+ };
2143
+ /**
2144
+ * The Audius SDK
2145
+ */
2146
+ declare const sdk: (config?: SdkConfig | undefined) => Promise<{
2147
+ oauth: Oauth | undefined;
2148
+ discoveryNode: DiscoveryProvider;
2149
+ }>;
2150
+
2151
+ declare type SchemaConfig = {
2152
+ schema: {
2153
+ definitions: Record<string, {
2154
+ required: string[];
2155
+ properties: Record<string, {
2156
+ default: unknown;
2157
+ }>;
2158
+ } | {}>;
2159
+ };
2160
+ baseDefinition: string;
2161
+ validate?: (obj: Record<string, unknown>) => void;
2162
+ };
2163
+ declare type Schemas = {
2164
+ TrackSchema: SchemaConfig;
2165
+ UserSchema: SchemaConfig;
2166
+ };
2167
+
430
2168
  declare type Metadata = {
431
2169
  track_segments: unknown;
432
2170
  download?: {
@@ -686,4 +2424,6 @@ declare class SanityChecks {
686
2424
  async run(creatorNodeWhitelist: string[] | null): Promise<void>
687
2425
  }
688
2426
 
689
- export { CreatorNode, SanityChecks, Utils };
2427
+ declare const libs: any;
2428
+
2429
+ export { CreatorNode, SanityChecks, Utils, libs, sdk };