@audius/sdk 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.js +11 -13
- package/dist/browser.js.map +1 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +24 -79
- package/dist/index.js.map +1 -1
- package/dist/legacy.d.ts +3 -3
- package/dist/legacy.js +24 -79
- package/dist/legacy.js.map +1 -1
- package/dist/types.d.ts +3 -3
- package/examples/initAudiusLibs.js +3 -4
- package/examples/initializeVersions.js +21 -9
- package/initScripts/mainnet.js +37 -14
- package/package.json +1 -1
- package/src/libs.js +20 -71
- package/src/sdk/oauth/Oauth.ts +3 -3
- package/src/sdk/sdk.ts +2 -2
- package/src/services/ethWeb3Manager/EthWeb3Manager.ts +7 -9
- package/tests/governanceTest.js +1 -1
- package/tests/helpers.js +1 -1
- package/tests/providerSelectionTest.js +3 -3
- package/tests/stakingTest.js +1 -1
package/dist/types.d.ts
CHANGED
|
@@ -2111,12 +2111,12 @@ declare type ButtonOptions = {
|
|
|
2111
2111
|
fullWidth: boolean;
|
|
2112
2112
|
};
|
|
2113
2113
|
declare type OauthConfig = {
|
|
2114
|
-
appName
|
|
2114
|
+
appName: string;
|
|
2115
2115
|
discoveryProvider: DiscoveryProvider;
|
|
2116
2116
|
};
|
|
2117
2117
|
declare class Oauth {
|
|
2118
2118
|
discoveryProvider: DiscoveryProvider;
|
|
2119
|
-
appName: string
|
|
2119
|
+
appName: string;
|
|
2120
2120
|
activePopupWindow: null | Window;
|
|
2121
2121
|
popupCheckInterval: NodeJS.Timer | null;
|
|
2122
2122
|
loginSuccessCallback: LoginSuccessCallback | null;
|
|
@@ -2145,7 +2145,7 @@ declare type SdkConfig = {
|
|
|
2145
2145
|
/**
|
|
2146
2146
|
* The Audius SDK
|
|
2147
2147
|
*/
|
|
2148
|
-
declare const sdk: (config
|
|
2148
|
+
declare const sdk: (config: SdkConfig) => Promise<{
|
|
2149
2149
|
oauth: Oauth | undefined;
|
|
2150
2150
|
discoveryNode: DiscoveryProvider;
|
|
2151
2151
|
}>;
|
|
@@ -43,9 +43,9 @@ async function initAudiusLibs(
|
|
|
43
43
|
ethWeb3ProviderEndpoint,
|
|
44
44
|
ethWallet
|
|
45
45
|
),
|
|
46
|
-
discoveryProviderConfig:
|
|
47
|
-
new Set(['http://docker.for.mac.localhost:5000'])
|
|
48
|
-
|
|
46
|
+
discoveryProviderConfig: {
|
|
47
|
+
whitelist: new Set(['http://docker.for.mac.localhost:5000'])
|
|
48
|
+
},
|
|
49
49
|
isServer,
|
|
50
50
|
isDebug
|
|
51
51
|
}
|
|
@@ -63,7 +63,6 @@ async function initAudiusLibs(
|
|
|
63
63
|
ethContractsConfig.ownerWallet
|
|
64
64
|
),
|
|
65
65
|
creatorNodeConfig: AudiusLibs.configCreatorNode(creatorNodeEndpoint),
|
|
66
|
-
discoveryProviderConfig: AudiusLibs.configDiscoveryProvider(),
|
|
67
66
|
identityServiceConfig: AudiusLibs.configIdentityService(
|
|
68
67
|
identityServiceEndpoint
|
|
69
68
|
),
|
|
@@ -2,7 +2,8 @@ const Web3 = require('../src/web3')
|
|
|
2
2
|
const AudiusLibs = require('../src/index')
|
|
3
3
|
const serviceTypeList = ['discovery-node', 'content-node']
|
|
4
4
|
const dataWeb3ProviderEndpoint = 'https://sokol.poa.network:443'
|
|
5
|
-
const ethWeb3ProviderEndpoint =
|
|
5
|
+
const ethWeb3ProviderEndpoint =
|
|
6
|
+
'https://ropsten.infura.io/v3/c569c6faf4f14d15a49d0044e7ddd668'
|
|
6
7
|
const dataRegistryAddress = '0x09033761774Fe45F40A47191DdF873F18B62DE05'
|
|
7
8
|
const ethRegistryAddress = '0xB631ABAA63a26311366411b2025F0cAca00DE27F'
|
|
8
9
|
const ethTokenAddress = '0xF8e679Aa54361467B12c7394BFF57Eb890f6d934'
|
|
@@ -10,7 +11,7 @@ let latestVersionStr = '0.1.0'
|
|
|
10
11
|
|
|
11
12
|
const isServer = true
|
|
12
13
|
|
|
13
|
-
const getEnv = env => {
|
|
14
|
+
const getEnv = (env) => {
|
|
14
15
|
const value = process.env[env]
|
|
15
16
|
if (typeof value === 'undefined') {
|
|
16
17
|
console.log(`${env} has not been set.`)
|
|
@@ -25,7 +26,7 @@ const getEnv = env => {
|
|
|
25
26
|
export AUDIUS_OWNER_WALLET=
|
|
26
27
|
* */
|
|
27
28
|
|
|
28
|
-
async function initializeVersionServiceProviderContracts
|
|
29
|
+
async function initializeVersionServiceProviderContracts() {
|
|
29
30
|
let audiusLibsConfig
|
|
30
31
|
let privateKey = getEnv('AUDIUS_PRIVATE_KEY')
|
|
31
32
|
let ownerWallet = getEnv('AUDIUS_OWNER_WALLET')
|
|
@@ -36,7 +37,9 @@ async function initializeVersionServiceProviderContracts () {
|
|
|
36
37
|
console.log(privateKey)
|
|
37
38
|
console.log(ownerWallet)
|
|
38
39
|
|
|
39
|
-
const dataWeb3 = new Web3(
|
|
40
|
+
const dataWeb3 = new Web3(
|
|
41
|
+
new Web3.providers.HttpProvider(dataWeb3ProviderEndpoint)
|
|
42
|
+
)
|
|
40
43
|
let web3DataContractConfig = {
|
|
41
44
|
registryAddress: dataRegistryAddress,
|
|
42
45
|
useExternalWeb3: true,
|
|
@@ -46,7 +49,9 @@ async function initializeVersionServiceProviderContracts () {
|
|
|
46
49
|
}
|
|
47
50
|
}
|
|
48
51
|
|
|
49
|
-
const ethWeb3 = new Web3(
|
|
52
|
+
const ethWeb3 = new Web3(
|
|
53
|
+
new Web3.providers.HttpProvider(ethWeb3ProviderEndpoint)
|
|
54
|
+
)
|
|
50
55
|
audiusLibsConfig = {
|
|
51
56
|
web3Config: web3DataContractConfig,
|
|
52
57
|
ethWeb3Config: AudiusLibs.configEthWeb3(
|
|
@@ -55,7 +60,6 @@ async function initializeVersionServiceProviderContracts () {
|
|
|
55
60
|
ethWeb3,
|
|
56
61
|
ownerWallet
|
|
57
62
|
),
|
|
58
|
-
discoveryProviderConfig: AudiusLibs.configDiscoveryProvider(),
|
|
59
63
|
isServer: isServer
|
|
60
64
|
}
|
|
61
65
|
let audiusLibs = new AudiusLibs(audiusLibsConfig)
|
|
@@ -84,9 +88,17 @@ async function initializeVersionServiceProviderContracts () {
|
|
|
84
88
|
}
|
|
85
89
|
*/
|
|
86
90
|
for (const serviceType of serviceTypeList) {
|
|
87
|
-
let versionTx =
|
|
88
|
-
|
|
89
|
-
|
|
91
|
+
let versionTx =
|
|
92
|
+
await audiusLibs.ethContracts.ServiceTypeManagerClient.getCurrentVersion(
|
|
93
|
+
serviceType
|
|
94
|
+
)
|
|
95
|
+
let numVersionsTx =
|
|
96
|
+
await audiusLibs.ethContracts.ServiceTypeManagerClient.getNumberOfVersions(
|
|
97
|
+
serviceType
|
|
98
|
+
)
|
|
99
|
+
console.log(
|
|
100
|
+
`${serviceType} | current version: ${versionTx} | number of versions : ${numVersionsTx}`
|
|
101
|
+
)
|
|
90
102
|
}
|
|
91
103
|
|
|
92
104
|
console.log('/----version init---')
|
package/initScripts/mainnet.js
CHANGED
|
@@ -34,29 +34,47 @@ const run = async () => {
|
|
|
34
34
|
const versionStr = args[5]
|
|
35
35
|
let dryRun = true
|
|
36
36
|
// if args[6] is defined and the value is either bool or string false, set dryRun to false
|
|
37
|
-
if (args[6] &&
|
|
37
|
+
if (args[6] && ['false', false].includes(args[6])) {
|
|
38
38
|
dryRun = false
|
|
39
39
|
}
|
|
40
40
|
if (!serviceType || !versionStr) {
|
|
41
|
-
throw new Error(
|
|
41
|
+
throw new Error(
|
|
42
|
+
'missing arguments - format: node mainnet.js setversion <serviceType> <versionStr>'
|
|
43
|
+
)
|
|
42
44
|
}
|
|
43
|
-
await setServiceVersion(
|
|
45
|
+
await setServiceVersion(
|
|
46
|
+
audiusLibs,
|
|
47
|
+
serviceType,
|
|
48
|
+
versionStr,
|
|
49
|
+
privateKey,
|
|
50
|
+
dryRun
|
|
51
|
+
)
|
|
44
52
|
break
|
|
45
53
|
case 'addservicetype':
|
|
46
54
|
const newServiceType = args[4]
|
|
47
55
|
const serviceTypeMin = args[5]
|
|
48
56
|
const serviceTypeMax = args[6]
|
|
49
57
|
if (!newServiceType || !serviceTypeMin || !serviceTypeMax) {
|
|
50
|
-
throw new Error(
|
|
58
|
+
throw new Error(
|
|
59
|
+
'missing arguments - format: node mainnet.js addservicetype <serviceType> <serviceTypeMin> <serviceTypeMax>'
|
|
60
|
+
)
|
|
51
61
|
}
|
|
52
|
-
await addServiceType(
|
|
62
|
+
await addServiceType(
|
|
63
|
+
audiusLibs,
|
|
64
|
+
newServiceType,
|
|
65
|
+
serviceTypeMin,
|
|
66
|
+
serviceTypeMax,
|
|
67
|
+
privateKey
|
|
68
|
+
)
|
|
53
69
|
break
|
|
54
70
|
case 'getclaim':
|
|
55
71
|
await getClaimInfo(audiusLibs)
|
|
56
72
|
break
|
|
57
73
|
case 'fundclaim':
|
|
58
74
|
if (!args[4]) {
|
|
59
|
-
throw new Error(
|
|
75
|
+
throw new Error(
|
|
76
|
+
'missing argument - format: node mainnet.js fundclaim <amountOfAuds>'
|
|
77
|
+
)
|
|
60
78
|
}
|
|
61
79
|
|
|
62
80
|
const amountOfAuds = args[4]
|
|
@@ -77,7 +95,7 @@ const run = async () => {
|
|
|
77
95
|
|
|
78
96
|
run()
|
|
79
97
|
|
|
80
|
-
function getLibsConfig
|
|
98
|
+
function getLibsConfig(config, privateKey, ownerWallet) {
|
|
81
99
|
let audiusLibsConfig
|
|
82
100
|
if (!privateKey || !ownerWallet) {
|
|
83
101
|
throw new Error('Missing private key or owner wallet')
|
|
@@ -86,7 +104,9 @@ function getLibsConfig (config, privateKey, ownerWallet) {
|
|
|
86
104
|
console.log(privateKey)
|
|
87
105
|
console.log(ownerWallet)
|
|
88
106
|
|
|
89
|
-
const dataWeb3 = new Web3(
|
|
107
|
+
const dataWeb3 = new Web3(
|
|
108
|
+
new Web3.providers.HttpProvider(config.dataWeb3ProviderEndpoint)
|
|
109
|
+
)
|
|
90
110
|
const web3DataContractConfig = {
|
|
91
111
|
registryAddress: config.dataRegistryAddress,
|
|
92
112
|
useExternalWeb3: true,
|
|
@@ -96,7 +116,9 @@ function getLibsConfig (config, privateKey, ownerWallet) {
|
|
|
96
116
|
}
|
|
97
117
|
}
|
|
98
118
|
|
|
99
|
-
const ethWeb3 = new Web3(
|
|
119
|
+
const ethWeb3 = new Web3(
|
|
120
|
+
new Web3.providers.HttpProvider(config.ethWeb3ProviderEndpoint)
|
|
121
|
+
)
|
|
100
122
|
audiusLibsConfig = {
|
|
101
123
|
web3Config: web3DataContractConfig,
|
|
102
124
|
ethWeb3Config: AudiusLibs.configEthWeb3(
|
|
@@ -105,20 +127,19 @@ function getLibsConfig (config, privateKey, ownerWallet) {
|
|
|
105
127
|
ethWeb3,
|
|
106
128
|
ownerWallet
|
|
107
129
|
),
|
|
108
|
-
discoveryProviderConfig: AudiusLibs.configDiscoveryProvider(),
|
|
109
130
|
isServer: isServer
|
|
110
131
|
}
|
|
111
132
|
return audiusLibsConfig
|
|
112
133
|
}
|
|
113
134
|
|
|
114
|
-
async function getAudiusLibs
|
|
135
|
+
async function getAudiusLibs(config, privateKey, ownerWallet) {
|
|
115
136
|
const audiusLibsConfig = getLibsConfig(config, privateKey, ownerWallet)
|
|
116
137
|
const audiusLibs = new AudiusLibs(audiusLibsConfig)
|
|
117
138
|
await audiusLibs.init()
|
|
118
139
|
return audiusLibs
|
|
119
140
|
}
|
|
120
141
|
|
|
121
|
-
function _getEnv
|
|
142
|
+
function _getEnv(env) {
|
|
122
143
|
const value = process.env[env]
|
|
123
144
|
if (typeof value === 'undefined') {
|
|
124
145
|
throw new Error(`${env} has not been set.`)
|
|
@@ -126,6 +147,8 @@ function _getEnv (env) {
|
|
|
126
147
|
return value
|
|
127
148
|
}
|
|
128
149
|
|
|
129
|
-
function _throwArgError
|
|
130
|
-
throw new Error(
|
|
150
|
+
function _throwArgError() {
|
|
151
|
+
throw new Error(
|
|
152
|
+
'missing argument - format: node mainnet.js <configFilePath> [setversion, fundclaim, getclaim, stakeinfo] [additional options]'
|
|
153
|
+
)
|
|
131
154
|
}
|
package/package.json
CHANGED
package/src/libs.js
CHANGED
|
@@ -5,7 +5,7 @@ const { SolanaAudiusData } = require('./services/solanaAudiusData/index')
|
|
|
5
5
|
const { Web3Manager } = require('./services/web3Manager')
|
|
6
6
|
const { EthContracts } = require('./services/ethContracts')
|
|
7
7
|
const SolanaWeb3Manager = require('./services/solanaWeb3Manager/index')
|
|
8
|
-
const { AudiusContracts } = require('./services/dataContracts
|
|
8
|
+
const { AudiusContracts } = require('./services/dataContracts')
|
|
9
9
|
const { IdentityService } = require('./services/identity')
|
|
10
10
|
const { Comstock } = require('./services/comstock')
|
|
11
11
|
const { Hedgehog } = require('./services/hedgehog')
|
|
@@ -34,50 +34,12 @@ const {
|
|
|
34
34
|
RewardsAttester
|
|
35
35
|
} = require('./services/solanaWeb3Manager/rewardsAttester')
|
|
36
36
|
class AudiusLibs {
|
|
37
|
-
/**
|
|
38
|
-
* Configures a discovery provider wrapper
|
|
39
|
-
* @param {Set<string>?} whitelist whether or not to include only specified nodes (default no whitelist)
|
|
40
|
-
* @param {Set<string>?} blacklist whether or not to exclude specified nodes (default no blacklist)
|
|
41
|
-
* @param {number?} reselectTimeout timeout to clear locally cached discovery providers
|
|
42
|
-
* @param {(selection: string) => void?} selectionCallback invoked with the select discovery provider
|
|
43
|
-
* @param {object?} monitoringCallbacks callbacks to be invoked with metrics from requests sent to a service
|
|
44
|
-
* @param {function} monitoringCallbacks.request
|
|
45
|
-
* @param {function} monitoringCallbacks.healthCheck
|
|
46
|
-
* @param {number?} selectionRequestTimeout the amount of time (ms) an individual request should take before reselecting
|
|
47
|
-
* @param {number?} selectionRequestRetries the number of retries to a given discovery node we make before reselecting
|
|
48
|
-
* @param {number?} unhealthySlotDiffPlays the number of slots we would consider a discovery node unhealthy
|
|
49
|
-
* @param {number?} unhealthyBlockDiff the number of missed blocks after which we would consider a discovery node unhealthy
|
|
50
|
-
*/
|
|
51
|
-
static configDiscoveryProvider(
|
|
52
|
-
whitelist = null,
|
|
53
|
-
blacklist = null,
|
|
54
|
-
reselectTimeout = null,
|
|
55
|
-
selectionCallback = null,
|
|
56
|
-
monitoringCallbacks = {},
|
|
57
|
-
selectionRequestTimeout = null,
|
|
58
|
-
selectionRequestRetries = null,
|
|
59
|
-
unhealthySlotDiffPlays = null,
|
|
60
|
-
unhealthyBlockDiff = null
|
|
61
|
-
) {
|
|
62
|
-
return {
|
|
63
|
-
whitelist,
|
|
64
|
-
blacklist,
|
|
65
|
-
reselectTimeout,
|
|
66
|
-
selectionCallback,
|
|
67
|
-
monitoringCallbacks,
|
|
68
|
-
selectionRequestTimeout,
|
|
69
|
-
selectionRequestRetries,
|
|
70
|
-
unhealthySlotDiffPlays,
|
|
71
|
-
unhealthyBlockDiff
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
37
|
/**
|
|
76
38
|
* Configures an identity service wrapper
|
|
77
39
|
* @param {string} url
|
|
78
40
|
* @param {boolean?} useHedgehogLocalStorage whether or not to read hedgehog entropy in local storage
|
|
79
41
|
*/
|
|
80
|
-
static configIdentityService(url, useHedgehogLocalStorage = true) {
|
|
42
|
+
static configIdentityService (url, useHedgehogLocalStorage = true) {
|
|
81
43
|
return { url, useHedgehogLocalStorage }
|
|
82
44
|
}
|
|
83
45
|
|
|
@@ -85,7 +47,7 @@ class AudiusLibs {
|
|
|
85
47
|
* Configures an identity service wrapper
|
|
86
48
|
* @param {string} url
|
|
87
49
|
*/
|
|
88
|
-
static configComstock(url) {
|
|
50
|
+
static configComstock (url) {
|
|
89
51
|
return { url }
|
|
90
52
|
}
|
|
91
53
|
|
|
@@ -100,7 +62,7 @@ class AudiusLibs {
|
|
|
100
62
|
* @param {function} monitoringCallbacks.request
|
|
101
63
|
* @param {function} monitoringCallbacks.healthCheck
|
|
102
64
|
*/
|
|
103
|
-
static configCreatorNode(
|
|
65
|
+
static configCreatorNode (
|
|
104
66
|
fallbackUrl,
|
|
105
67
|
lazyConnect = false,
|
|
106
68
|
passList = null,
|
|
@@ -124,7 +86,7 @@ class AudiusLibs {
|
|
|
124
86
|
* @param {?string} walletOverride wallet address to force use instead of the first wallet on the provided web3
|
|
125
87
|
* @param {?number} walletIndex if using a wallet returned from web3, pick the wallet at this index
|
|
126
88
|
*/
|
|
127
|
-
static async configExternalWeb3(
|
|
89
|
+
static async configExternalWeb3 (
|
|
128
90
|
registryAddress,
|
|
129
91
|
web3Provider,
|
|
130
92
|
networkId,
|
|
@@ -150,7 +112,7 @@ class AudiusLibs {
|
|
|
150
112
|
* @param {string} registryAddress
|
|
151
113
|
* @param {string | Web3 | Array<string>} providers web3 provider endpoint(s)
|
|
152
114
|
*/
|
|
153
|
-
static configInternalWeb3(registryAddress, providers, privateKey) {
|
|
115
|
+
static configInternalWeb3 (registryAddress, providers, privateKey) {
|
|
154
116
|
let providerList
|
|
155
117
|
if (typeof providers === 'string') {
|
|
156
118
|
providerList = providers.split(',')
|
|
@@ -183,7 +145,7 @@ class AudiusLibs {
|
|
|
183
145
|
* @param {string?} claimDistributionContractAddress
|
|
184
146
|
* @param {string?} wormholeContractAddress
|
|
185
147
|
*/
|
|
186
|
-
static configEthWeb3(
|
|
148
|
+
static configEthWeb3 (
|
|
187
149
|
tokenAddress,
|
|
188
150
|
registryAddress,
|
|
189
151
|
providers,
|
|
@@ -223,7 +185,7 @@ class AudiusLibs {
|
|
|
223
185
|
* @param {string} config.ethBridgeAddress
|
|
224
186
|
* @param {string} config.ethTokenBridgeAddress
|
|
225
187
|
*/
|
|
226
|
-
static configWormhole({
|
|
188
|
+
static configWormhole ({
|
|
227
189
|
rpcHosts,
|
|
228
190
|
solBridgeAddress,
|
|
229
191
|
solTokenBridgeAddress,
|
|
@@ -267,7 +229,7 @@ class AudiusLibs {
|
|
|
267
229
|
* @param {PublicKey|string} audiusDataProgramId program ID for the audius-data Anchor program
|
|
268
230
|
* @param {Idl} audiusDataIdl IDL for the audius-data Anchor program.
|
|
269
231
|
*/
|
|
270
|
-
static configSolanaWeb3({
|
|
232
|
+
static configSolanaWeb3 ({
|
|
271
233
|
solanaClusterEndpoint,
|
|
272
234
|
mintAddress,
|
|
273
235
|
solanaTokenAddress,
|
|
@@ -319,7 +281,7 @@ class AudiusLibs {
|
|
|
319
281
|
* @param {string} config.programId Program ID of the audius data program
|
|
320
282
|
* @param {string} config.adminAccount Public Key of admin account
|
|
321
283
|
*/
|
|
322
|
-
static configSolanaAudiusData({ programId, adminAccount }) {
|
|
284
|
+
static configSolanaAudiusData ({ programId, adminAccount }) {
|
|
323
285
|
return {
|
|
324
286
|
programId,
|
|
325
287
|
adminAccount
|
|
@@ -331,12 +293,12 @@ class AudiusLibs {
|
|
|
331
293
|
* Unless default-valued, all configs are optional.
|
|
332
294
|
* @example
|
|
333
295
|
* const audius = AudiusLibs({
|
|
334
|
-
* discoveryProviderConfig:
|
|
296
|
+
* discoveryProviderConfig: {},
|
|
335
297
|
* creatorNodeConfig: configCreatorNode('https://my-creator.node')
|
|
336
298
|
* })
|
|
337
299
|
* await audius.init()
|
|
338
300
|
*/
|
|
339
|
-
constructor({
|
|
301
|
+
constructor ({
|
|
340
302
|
web3Config,
|
|
341
303
|
ethWeb3Config,
|
|
342
304
|
solanaWeb3Config,
|
|
@@ -405,7 +367,7 @@ class AudiusLibs {
|
|
|
405
367
|
}
|
|
406
368
|
|
|
407
369
|
/** Init services based on presence of a relevant config. */
|
|
408
|
-
async init() {
|
|
370
|
+
async init () {
|
|
409
371
|
this.userStateManager = new UserStateManager()
|
|
410
372
|
// Config external web3 is an async function, so await it here in case it needs to be
|
|
411
373
|
this.web3Config = await this.web3Config
|
|
@@ -523,26 +485,13 @@ class AudiusLibs {
|
|
|
523
485
|
}
|
|
524
486
|
|
|
525
487
|
/** Discovery Provider */
|
|
526
|
-
|
|
527
|
-
this.
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
reselectTimeout: this.discoveryProviderConfig.reselectTimeout,
|
|
534
|
-
selectionCallback: this.discoveryProviderConfig.selectionCallback,
|
|
535
|
-
monitoringCallbacks: this.discoveryProviderConfig.monitoringCallbacks,
|
|
536
|
-
selectionRequestTimeout:
|
|
537
|
-
this.discoveryProviderConfig.selectionRequestTimeout,
|
|
538
|
-
selectionRequestRetries:
|
|
539
|
-
this.discoveryProviderConfig.selectionRequestRetries,
|
|
540
|
-
unhealthySlothDiffPlays:
|
|
541
|
-
this.discoveryProviderConfig.unhealthySlotDiffPlays,
|
|
542
|
-
unhealthBlockDiff: this.discoveryProviderConfig.unhealthyBlockDiff
|
|
543
|
-
})
|
|
544
|
-
await this.discoveryProvider.init()
|
|
545
|
-
}
|
|
488
|
+
this.discoveryProvider = new DiscoveryProvider({
|
|
489
|
+
userStateManager: this.userStateManager,
|
|
490
|
+
ethContracts: this.ethContracts,
|
|
491
|
+
web3Manager: this.web3Manager,
|
|
492
|
+
...this.discoveryProviderConfig
|
|
493
|
+
})
|
|
494
|
+
await this.discoveryProvider.init()
|
|
546
495
|
|
|
547
496
|
/** Creator Node */
|
|
548
497
|
if (this.creatorNodeConfig) {
|
package/src/sdk/oauth/Oauth.ts
CHANGED
|
@@ -105,13 +105,13 @@ const OAUTH_URL = 'https://audius.co/oauth/auth'
|
|
|
105
105
|
const CSRF_TOKEN_KEY = 'audiusOauthState'
|
|
106
106
|
|
|
107
107
|
type OauthConfig = {
|
|
108
|
-
appName
|
|
108
|
+
appName: string
|
|
109
109
|
discoveryProvider: DiscoveryProvider
|
|
110
110
|
}
|
|
111
111
|
|
|
112
112
|
export class Oauth {
|
|
113
113
|
discoveryProvider: DiscoveryProvider
|
|
114
|
-
appName: string
|
|
114
|
+
appName: string
|
|
115
115
|
activePopupWindow: null | Window
|
|
116
116
|
popupCheckInterval: NodeJS.Timer | null
|
|
117
117
|
loginSuccessCallback: LoginSuccessCallback | null
|
|
@@ -125,7 +125,7 @@ export class Oauth {
|
|
|
125
125
|
)
|
|
126
126
|
}
|
|
127
127
|
this.discoveryProvider = discoveryProvider
|
|
128
|
-
this.appName = appName
|
|
128
|
+
this.appName = appName
|
|
129
129
|
this.activePopupWindow = null
|
|
130
130
|
this.loginSuccessCallback = null
|
|
131
131
|
this.loginErrorCallback = null
|
package/src/sdk/sdk.ts
CHANGED
|
@@ -34,14 +34,14 @@ type SdkConfig = {
|
|
|
34
34
|
/**
|
|
35
35
|
* The Audius SDK
|
|
36
36
|
*/
|
|
37
|
-
export const sdk = async (config
|
|
37
|
+
export const sdk = async (config: SdkConfig) => {
|
|
38
38
|
const {
|
|
39
39
|
appName,
|
|
40
40
|
discoveryNodeConfig,
|
|
41
41
|
ethContractsConfig,
|
|
42
42
|
ethWeb3Config,
|
|
43
43
|
identityServiceConfig
|
|
44
|
-
} = config
|
|
44
|
+
} = config
|
|
45
45
|
|
|
46
46
|
/** Initialize services */
|
|
47
47
|
|
|
@@ -46,15 +46,13 @@ export class EthWeb3Manager {
|
|
|
46
46
|
this.identityService = identityService
|
|
47
47
|
this.hedgehog = hedgehog
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
this.ownerWallet = storedWallet
|
|
57
|
-
}
|
|
49
|
+
if (this.web3Config.ownerWallet) {
|
|
50
|
+
this.ownerWallet = this.web3Config.ownerWallet
|
|
51
|
+
} else if (this.hedgehog) {
|
|
52
|
+
// Hedgehog might not exist (in the case of @audius/sdk)
|
|
53
|
+
const storedWallet = this.hedgehog.getWallet()
|
|
54
|
+
if (storedWallet) {
|
|
55
|
+
this.ownerWallet = storedWallet
|
|
58
56
|
}
|
|
59
57
|
}
|
|
60
58
|
}
|
package/tests/governanceTest.js
CHANGED
|
@@ -5,7 +5,7 @@ const nock = require('nock')
|
|
|
5
5
|
const { Vote } = require('../src/services/ethContracts/GovernanceClient')
|
|
6
6
|
const time = require('@openzeppelin/test-helpers/src/time')
|
|
7
7
|
const { initializeLibConfig } = require('./helpers')
|
|
8
|
-
const AudiusLibs = require('../src')
|
|
8
|
+
const AudiusLibs = require('../src/libs')
|
|
9
9
|
|
|
10
10
|
const { audiusInstance: audius0, getRandomLocalhost } = helpers
|
|
11
11
|
|
package/tests/helpers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const nock = require('nock')
|
|
2
2
|
|
|
3
3
|
const Web3 = require('../src/web3')
|
|
4
|
-
const AudiusLibs = require('../src/
|
|
4
|
+
const AudiusLibs = require('../src/libs')
|
|
5
5
|
const dataContractsConfig = require('../data-contracts/config.json')
|
|
6
6
|
const ethContractsConfig = require('../eth-contracts/config.json')
|
|
7
7
|
|
|
@@ -211,7 +211,7 @@ function createContractClientWithInternalWeb3() {
|
|
|
211
211
|
web3ProviderEndpoints: gateways
|
|
212
212
|
}
|
|
213
213
|
}
|
|
214
|
-
const web3Manager = new Web3Manager()
|
|
214
|
+
const web3Manager = new Web3Manager({})
|
|
215
215
|
web3Manager.web3 = createWeb3Obj('https://audius.poa.network')
|
|
216
216
|
web3Manager.web3Config = web3Config
|
|
217
217
|
return createContractClient(web3Manager)
|
|
@@ -224,7 +224,7 @@ function createContractClientWithExternalWeb3() {
|
|
|
224
224
|
web3ProviderEndpoints: gateways
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
|
-
const web3Manager = new Web3Manager()
|
|
227
|
+
const web3Manager = new Web3Manager({})
|
|
228
228
|
web3Manager.web3 = createWeb3Obj('https://audius.poa.network')
|
|
229
229
|
web3Manager.web3Config = web3Config
|
|
230
230
|
return createContractClient(web3Manager)
|
|
@@ -235,7 +235,7 @@ function createContractClientWithEthWeb3Manager() {
|
|
|
235
235
|
providers: ['https://audius.eth.network'],
|
|
236
236
|
ownerWallet: '0xwallet'
|
|
237
237
|
}
|
|
238
|
-
const ethWeb3Manager = new EthWeb3Manager(web3Config)
|
|
238
|
+
const ethWeb3Manager = new EthWeb3Manager({ web3Config })
|
|
239
239
|
ethWeb3Manager.web3 = createWeb3Obj('https://eth.network')
|
|
240
240
|
return createContractClient(ethWeb3Manager)
|
|
241
241
|
}
|
package/tests/stakingTest.js
CHANGED
|
@@ -7,7 +7,7 @@ const { time } = require('@openzeppelin/test-helpers')
|
|
|
7
7
|
const { getRandomLocalhost, audiusInstance: audius0 } = helpers
|
|
8
8
|
const initializeLibConfig = helpers.initializeLibConfig
|
|
9
9
|
const ethContractsConfig = require('../eth-contracts/config.json')
|
|
10
|
-
const AudiusLibs = require('../src/
|
|
10
|
+
const AudiusLibs = require('../src/libs');
|
|
11
11
|
const { convertAudsToWeiBN } = require('../initScripts/helpers/utils');
|
|
12
12
|
const { initial } = require('lodash')
|
|
13
13
|
const { deregisterSPEndpoint } = require('./helpers')
|