@audius/sdk 0.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc +38 -0
- package/.prettierrc.js +1 -0
- package/.python-version +1 -0
- package/Dockerfile +15 -0
- package/README.md +3 -0
- package/babel.config.js +3 -0
- package/data-contracts/ABIs/AdminUpgradeabilityProxy.json +132 -0
- package/data-contracts/ABIs/BaseAdminUpgradeabilityProxy.json +113 -0
- package/data-contracts/ABIs/BaseUpgradeabilityProxy.json +22 -0
- package/data-contracts/ABIs/DiscoveryProviderFactory.json +189 -0
- package/data-contracts/ABIs/DiscoveryProviderFactoryInterface.json +61 -0
- package/data-contracts/ABIs/DiscoveryProviderStorage.json +205 -0
- package/data-contracts/ABIs/DiscoveryProviderStorageInterface.json +65 -0
- package/data-contracts/ABIs/ECDSA.json +4 -0
- package/data-contracts/ABIs/IPLDBlacklistFactory.json +168 -0
- package/data-contracts/ABIs/Initializable.json +4 -0
- package/data-contracts/ABIs/Migrations.json +67 -0
- package/data-contracts/ABIs/OpenZeppelinUpgradesAddress.json +4 -0
- package/data-contracts/ABIs/Ownable.json +79 -0
- package/data-contracts/ABIs/PlaylistFactory.json +669 -0
- package/data-contracts/ABIs/PlaylistFactoryInterface.json +42 -0
- package/data-contracts/ABIs/PlaylistStorage.json +250 -0
- package/data-contracts/ABIs/PlaylistStorageInterface.json +129 -0
- package/data-contracts/ABIs/Proxy.json +10 -0
- package/data-contracts/ABIs/Registry.json +240 -0
- package/data-contracts/ABIs/RegistryContract.json +102 -0
- package/data-contracts/ABIs/RegistryContractInterface.json +28 -0
- package/data-contracts/ABIs/RegistryInterface.json +66 -0
- package/data-contracts/ABIs/SigningLogic.json +43 -0
- package/data-contracts/ABIs/SigningLogicInitializable.json +46 -0
- package/data-contracts/ABIs/SocialFeatureFactory.json +460 -0
- package/data-contracts/ABIs/SocialFeatureStorage.json +225 -0
- package/data-contracts/ABIs/SocialFeatureStorageInterface.json +123 -0
- package/data-contracts/ABIs/TestContract.json +135 -0
- package/data-contracts/ABIs/TestContractInterface.json +19 -0
- package/data-contracts/ABIs/TestContractWithStorage.json +165 -0
- package/data-contracts/ABIs/TestContractWithStorageInterface.json +24 -0
- package/data-contracts/ABIs/TestStorage.json +144 -0
- package/data-contracts/ABIs/TestStorageInterface.json +42 -0
- package/data-contracts/ABIs/TestUserReplicaSetManager.json +432 -0
- package/data-contracts/ABIs/TrackFactory.json +391 -0
- package/data-contracts/ABIs/TrackFactoryInterface.json +73 -0
- package/data-contracts/ABIs/TrackStorage.json +223 -0
- package/data-contracts/ABIs/TrackStorageInterface.json +121 -0
- package/data-contracts/ABIs/UpgradeabilityProxy.json +37 -0
- package/data-contracts/ABIs/UserFactory.json +657 -0
- package/data-contracts/ABIs/UserFactoryInterface.json +65 -0
- package/data-contracts/ABIs/UserLibraryFactory.json +334 -0
- package/data-contracts/ABIs/UserReplicaSetManager.json +418 -0
- package/data-contracts/ABIs/UserStorage.json +233 -0
- package/data-contracts/ABIs/UserStorageInterface.json +93 -0
- package/data-contracts/signatureSchemas.ts +1236 -0
- package/dist/core.d.ts +446 -0
- package/dist/core.js +769 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +689 -0
- package/dist/index.js +72850 -0
- package/dist/index.js.map +1 -0
- package/eth-contracts/ABIs/Address.json +4 -0
- package/eth-contracts/ABIs/AudiusAdminUpgradeabilityProxy.json +105 -0
- package/eth-contracts/ABIs/AudiusClaimDistributor.json +4968 -0
- package/eth-contracts/ABIs/AudiusToken.json +724 -0
- package/eth-contracts/ABIs/BaseUpgradeabilityProxy.json +23 -0
- package/eth-contracts/ABIs/Checkpointing.json +4 -0
- package/eth-contracts/ABIs/ClaimsManager.json +539 -0
- package/eth-contracts/ABIs/Context.json +11 -0
- package/eth-contracts/ABIs/DelegateManager.json +989 -0
- package/eth-contracts/ABIs/DelegateManagerV2.json +1049 -0
- package/eth-contracts/ABIs/DelegateManagerV2Bad.json +1049 -0
- package/eth-contracts/ABIs/ERC20.json +252 -0
- package/eth-contracts/ABIs/ERC20Burnable.json +287 -0
- package/eth-contracts/ABIs/ERC20Detailed.json +270 -0
- package/eth-contracts/ABIs/ERC20Mintable.json +364 -0
- package/eth-contracts/ABIs/ERC20Pausable.json +397 -0
- package/eth-contracts/ABIs/EthRewardsManager.json +174 -0
- package/eth-contracts/ABIs/Governance.json +938 -0
- package/eth-contracts/ABIs/GovernanceUpgraded.json +953 -0
- package/eth-contracts/ABIs/GovernanceV2.json +938 -0
- package/eth-contracts/ABIs/IERC20.json +200 -0
- package/eth-contracts/ABIs/Initializable.json +4 -0
- package/eth-contracts/ABIs/InitializableV2.json +14 -0
- package/eth-contracts/ABIs/Migrations.json +71 -0
- package/eth-contracts/ABIs/MinterRole.json +91 -0
- package/eth-contracts/ABIs/MockAccount.json +62 -0
- package/eth-contracts/ABIs/MockDelegateManager.json +55 -0
- package/eth-contracts/ABIs/MockStakingCaller.json +259 -0
- package/eth-contracts/ABIs/MockWormhole.json +106 -0
- package/eth-contracts/ABIs/OpenZeppelinUpgradesAddress.json +4 -0
- package/eth-contracts/ABIs/Ownable.json +93 -0
- package/eth-contracts/ABIs/Pausable.json +150 -0
- package/eth-contracts/ABIs/PauserRole.json +91 -0
- package/eth-contracts/ABIs/Proxy.json +10 -0
- package/eth-contracts/ABIs/Registry.json +288 -0
- package/eth-contracts/ABIs/Roles.json +4 -0
- package/eth-contracts/ABIs/SafeERC20.json +4 -0
- package/eth-contracts/ABIs/SafeMath.json +4 -0
- package/eth-contracts/ABIs/ServiceProviderFactory.json +1153 -0
- package/eth-contracts/ABIs/ServiceTypeManager.json +337 -0
- package/eth-contracts/ABIs/Staking.json +555 -0
- package/eth-contracts/ABIs/StakingUpgraded.json +570 -0
- package/eth-contracts/ABIs/TestContract.json +44 -0
- package/eth-contracts/ABIs/TrustedNotifierManager.json +265 -0
- package/eth-contracts/ABIs/Uint256Helpers.json +4 -0
- package/eth-contracts/ABIs/UpgradeabilityProxy.json +40 -0
- package/eth-contracts/ABIs/Wormhole.json +45 -0
- package/eth-contracts/ABIs/WormholeClient.json +155 -0
- package/examples/file.mp3 +0 -0
- package/examples/initAudiusLibs.js +86 -0
- package/examples/initializeVersions.js +95 -0
- package/examples/pic.jpg +0 -0
- package/initScripts/configureLocalDiscProv.js +167 -0
- package/initScripts/helpers/claim.js +43 -0
- package/initScripts/helpers/distributeTokens.js +24 -0
- package/initScripts/helpers/spRegistration.js +138 -0
- package/initScripts/helpers/utils.js +34 -0
- package/initScripts/helpers/version.js +93 -0
- package/initScripts/local.js +617 -0
- package/initScripts/mainnet.js +131 -0
- package/initScripts/manageProdRelayerWallets.js +191 -0
- package/package.json +125 -0
- package/rollup.config.js +164 -0
- package/scripts/AudiusClaimDistributor.json +4968 -0
- package/scripts/Wormhole.json +155 -0
- package/scripts/addCIDToIpldBlacklist.js +124 -0
- package/scripts/circleci-test.sh +53 -0
- package/scripts/communityRewards/transferCommunityRewardsToSolana.js +222 -0
- package/scripts/ipfs.sh +58 -0
- package/scripts/migrate_contracts.sh +25 -0
- package/scripts/reset.sh +65 -0
- package/scripts/test.sh +77 -0
- package/src/api/account.js +670 -0
- package/src/api/base.js +122 -0
- package/src/api/file.js +168 -0
- package/src/api/playlist.js +328 -0
- package/src/api/rewards.d.ts +4 -0
- package/src/api/rewards.js +682 -0
- package/src/api/serviceProvider.js +154 -0
- package/src/api/track.js +604 -0
- package/src/api/user.js +888 -0
- package/src/api/user.test.js +172 -0
- package/src/constants.ts +7 -0
- package/src/core.ts +3 -0
- package/src/index.js +6 -0
- package/src/libs.d.ts +3 -0
- package/src/libs.js +619 -0
- package/src/sanityChecks/addSecondaries.js +40 -0
- package/src/sanityChecks/assignReplicaSetIfNecessary.js +10 -0
- package/src/sanityChecks/index.d.ts +9 -0
- package/src/sanityChecks/index.js +31 -0
- package/src/sanityChecks/isCreator.js +73 -0
- package/src/sanityChecks/needsRecoveryEmail.js +20 -0
- package/src/sanityChecks/rolloverNodes.js +74 -0
- package/src/sanityChecks/sanitizeNodes.js +24 -0
- package/src/sanityChecks/syncNodes.js +28 -0
- package/src/sdk/constants.ts +10 -0
- package/src/sdk/index.ts +1 -0
- package/src/sdk/oauth/Oauth.ts +265 -0
- package/src/sdk/oauth/index.ts +1 -0
- package/src/sdk/sdk.ts +102 -0
- package/src/service-selection/ServiceSelection.test.ts +320 -0
- package/src/service-selection/ServiceSelection.ts +460 -0
- package/src/service-selection/constants.ts +14 -0
- package/src/service-selection/index.ts +1 -0
- package/src/services/ABIDecoder/AudiusABIDecoder.ts +71 -0
- package/src/services/ABIDecoder/index.ts +1 -0
- package/src/services/comstock/Comstock.ts +39 -0
- package/src/services/comstock/index.ts +1 -0
- package/src/services/contracts/ContractClient.ts +227 -0
- package/src/services/contracts/GovernedContractClient.ts +53 -0
- package/src/services/contracts/ProviderSelection.ts +42 -0
- package/src/services/creatorNode/CreatorNode.ts +1065 -0
- package/src/services/creatorNode/CreatorNodeSelection.test.ts +997 -0
- package/src/services/creatorNode/CreatorNodeSelection.ts +488 -0
- package/src/services/creatorNode/constants.ts +10 -0
- package/src/services/creatorNode/index.ts +2 -0
- package/src/services/dataContracts/AudiusContracts.ts +234 -0
- package/src/services/dataContracts/IPLDBlacklistFactoryClient.ts +73 -0
- package/src/services/dataContracts/PlaylistFactoryClient.ts +370 -0
- package/src/services/dataContracts/RegistryClient.ts +95 -0
- package/src/services/dataContracts/SocialFeatureFactoryClient.ts +196 -0
- package/src/services/dataContracts/TrackFactoryClient.ts +131 -0
- package/src/services/dataContracts/UserFactoryClient.ts +351 -0
- package/src/services/dataContracts/UserLibraryFactoryClient.ts +115 -0
- package/src/services/dataContracts/UserReplicaSetManagerClient.ts +206 -0
- package/src/services/dataContracts/index.ts +1 -0
- package/src/services/discoveryProvider/DiscoveryProvider.ts +1168 -0
- package/src/services/discoveryProvider/DiscoveryProviderSelection.test.ts +536 -0
- package/src/services/discoveryProvider/DiscoveryProviderSelection.ts +383 -0
- package/src/services/discoveryProvider/constants.ts +13 -0
- package/src/services/discoveryProvider/index.ts +1 -0
- package/src/services/discoveryProvider/requests.ts +629 -0
- package/src/services/ethContracts/AudiusTokenClient.ts +163 -0
- package/src/services/ethContracts/ClaimDistributionClient.ts +45 -0
- package/src/services/ethContracts/ClaimsManagerClient.ts +102 -0
- package/src/services/ethContracts/DelegateManagerClient.ts +480 -0
- package/src/services/ethContracts/EthContracts.ts +359 -0
- package/src/services/ethContracts/EthRewardsManagerClient.ts +33 -0
- package/src/services/ethContracts/GovernanceClient.ts +451 -0
- package/src/services/ethContracts/RegistryClient.ts +33 -0
- package/src/services/ethContracts/ServiceProviderFactoryClient.ts +691 -0
- package/src/services/ethContracts/ServiceTypeManagerClient.ts +112 -0
- package/src/services/ethContracts/StakingProxyClient.ts +97 -0
- package/src/services/ethContracts/TrustedNotifierManagerClient.ts +101 -0
- package/src/services/ethContracts/WormholeClient.ts +97 -0
- package/src/services/ethContracts/index.ts +1 -0
- package/src/services/ethWeb3Manager/EthWeb3Manager.ts +239 -0
- package/src/services/ethWeb3Manager/index.ts +1 -0
- package/src/services/hedgehog/Hedgehog.ts +96 -0
- package/src/services/hedgehog/index.ts +1 -0
- package/src/services/identity/IdentityService.ts +551 -0
- package/src/services/identity/index.ts +1 -0
- package/src/services/identity/requests.ts +65 -0
- package/src/services/schemaValidator/SchemaValidator.ts +105 -0
- package/src/services/schemaValidator/index.ts +1 -0
- package/src/services/schemaValidator/schemas/trackSchema.json +267 -0
- package/src/services/schemaValidator/schemas/userSchema.json +230 -0
- package/src/services/solanaAudiusData/errors.ts +20 -0
- package/src/services/solanaAudiusData/index.ts +1189 -0
- package/src/services/solanaWeb3Manager/errors.js +101 -0
- package/src/services/solanaWeb3Manager/index.d.ts +46 -0
- package/src/services/solanaWeb3Manager/index.js +655 -0
- package/src/services/solanaWeb3Manager/padBNToUint8Array.ts +7 -0
- package/src/services/solanaWeb3Manager/rewards.js +941 -0
- package/src/services/solanaWeb3Manager/rewardsAttester.ts +1093 -0
- package/src/services/solanaWeb3Manager/tokenAccount.js +149 -0
- package/src/services/solanaWeb3Manager/transactionHandler.js +345 -0
- package/src/services/solanaWeb3Manager/transfer.js +272 -0
- package/src/services/solanaWeb3Manager/userBank.js +160 -0
- package/src/services/solanaWeb3Manager/utils.d.ts +31 -0
- package/src/services/solanaWeb3Manager/utils.js +163 -0
- package/src/services/solanaWeb3Manager/wAudio.js +28 -0
- package/src/services/solanaWeb3Manager/wAudio.test.js +30 -0
- package/src/services/web3Manager/Web3Config.ts +14 -0
- package/src/services/web3Manager/Web3Manager.ts +360 -0
- package/src/services/web3Manager/XMLHttpRequest.ts +11 -0
- package/src/services/web3Manager/index.ts +2 -0
- package/src/services/wormhole/index.js +424 -0
- package/src/types.ts +8 -0
- package/src/userStateManager.ts +53 -0
- package/src/utils/apiSigning.ts +51 -0
- package/src/utils/captcha.ts +97 -0
- package/src/utils/estimateGas.ts +64 -0
- package/src/utils/fileHasher.ts +278 -0
- package/src/utils/importContractABI.d.ts +9 -0
- package/src/utils/importContractABI.js +19 -0
- package/src/utils/index.ts +11 -0
- package/src/utils/multiProvider.ts +72 -0
- package/src/utils/network.test.ts +127 -0
- package/src/utils/network.ts +308 -0
- package/src/utils/promiseFight.test.ts +87 -0
- package/src/utils/promiseFight.ts +36 -0
- package/src/utils/signatures.ts +139 -0
- package/src/utils/types.ts +34 -0
- package/src/utils/utils.test.ts +36 -0
- package/src/utils/utils.ts +235 -0
- package/src/utils/uuid.ts +14 -0
- package/src/web3.d.ts +9 -0
- package/src/web3.js +8 -0
- package/tests/assets/static_image.png +0 -0
- package/tests/assets/static_text.txt +1 -0
- package/tests/audiusTokenClientTest.js +37 -0
- package/tests/creatorNodeTest.js +19 -0
- package/tests/fileHasherTest.js +125 -0
- package/tests/governanceTest.js +382 -0
- package/tests/helpers.js +105 -0
- package/tests/index.js +14 -0
- package/tests/playlistClientTest.js +157 -0
- package/tests/providerSelectionTest.js +241 -0
- package/tests/registryClientTest.js +19 -0
- package/tests/rewardsAttesterTest.js +373 -0
- package/tests/serviceTypeManagerClientTest.js +33 -0
- package/tests/socialFeatureClientTest.js +79 -0
- package/tests/stakingTest.js +302 -0
- package/tests/trackClientTest.js +86 -0
- package/tests/userClientTest.js +121 -0
- package/tsconfig.json +10 -0
- package/types/@audius-hedgehog/index.d.ts +39 -0
- package/types/abi-decoder/index.d.ts +41 -0
|
@@ -0,0 +1,691 @@
|
|
|
1
|
+
// TODO: a lot of extra parseInt's that result in incorrect (as unknown as string) typecasting
|
|
2
|
+
|
|
3
|
+
import { ContractABI, Logger, Utils } from '../../utils'
|
|
4
|
+
import { GovernedContractClient } from '../contracts/GovernedContractClient'
|
|
5
|
+
import axios, { AxiosRequestConfig } from 'axios'
|
|
6
|
+
import { range } from 'lodash'
|
|
7
|
+
import type { EthWeb3Manager } from '../ethWeb3Manager'
|
|
8
|
+
import type { GetRegistryAddress } from '../contracts/ContractClient'
|
|
9
|
+
import type { AudiusTokenClient } from './AudiusTokenClient'
|
|
10
|
+
import type { StakingProxyClient } from './StakingProxyClient'
|
|
11
|
+
import type { GovernanceClient } from './GovernanceClient'
|
|
12
|
+
import urlJoin from 'proper-url-join'
|
|
13
|
+
import type BN from 'bn.js'
|
|
14
|
+
|
|
15
|
+
type GetEvent = {
|
|
16
|
+
serviceType: string
|
|
17
|
+
owner: string
|
|
18
|
+
queryStartBlock: number
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type Filter = { _owner?: string; _serviceType?: string }
|
|
22
|
+
|
|
23
|
+
export class ServiceProviderFactoryClient extends GovernedContractClient {
|
|
24
|
+
audiusTokenClient: AudiusTokenClient
|
|
25
|
+
stakingProxyClient: StakingProxyClient
|
|
26
|
+
isDebug: boolean
|
|
27
|
+
|
|
28
|
+
constructor(
|
|
29
|
+
ethWeb3Manager: EthWeb3Manager,
|
|
30
|
+
contractABI: ContractABI['abi'],
|
|
31
|
+
contractRegistryKey: string,
|
|
32
|
+
getRegistryAddress: GetRegistryAddress,
|
|
33
|
+
audiusTokenClient: AudiusTokenClient,
|
|
34
|
+
stakingProxyClient: StakingProxyClient,
|
|
35
|
+
governanceClient: GovernanceClient,
|
|
36
|
+
logger: Logger = console,
|
|
37
|
+
isDebug = false
|
|
38
|
+
) {
|
|
39
|
+
super(
|
|
40
|
+
ethWeb3Manager,
|
|
41
|
+
contractABI,
|
|
42
|
+
contractRegistryKey,
|
|
43
|
+
getRegistryAddress,
|
|
44
|
+
governanceClient,
|
|
45
|
+
logger
|
|
46
|
+
)
|
|
47
|
+
this.audiusTokenClient = audiusTokenClient
|
|
48
|
+
this.stakingProxyClient = stakingProxyClient
|
|
49
|
+
this.isDebug = isDebug
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async registerWithDelegate(
|
|
53
|
+
serviceType: string,
|
|
54
|
+
endpoint: string,
|
|
55
|
+
amount: number | string | BN,
|
|
56
|
+
delegateOwnerWallet: string
|
|
57
|
+
) {
|
|
58
|
+
const sanitizedEndpoint = endpoint.replace(/\/$/, '')
|
|
59
|
+
|
|
60
|
+
if (!this.isDebug && !Utils.isHttps(sanitizedEndpoint)) {
|
|
61
|
+
throw new Error('Domain name not using https protocol!')
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
if (!this.isDebug && !Utils.isFQDN(sanitizedEndpoint)) {
|
|
65
|
+
throw new Error('Not a fully qualified domain name!')
|
|
66
|
+
}
|
|
67
|
+
if (!Number.isInteger(amount) && !Utils.isBN(amount as string)) {
|
|
68
|
+
throw new Error('Invalid amount')
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const requestUrl = urlJoin(sanitizedEndpoint, 'health_check')
|
|
72
|
+
const axiosRequestObj: AxiosRequestConfig = {
|
|
73
|
+
url: requestUrl,
|
|
74
|
+
method: 'get',
|
|
75
|
+
timeout: 1000
|
|
76
|
+
}
|
|
77
|
+
const resp = await axios(axiosRequestObj)
|
|
78
|
+
const endpointServiceType = resp.data.data.service
|
|
79
|
+
|
|
80
|
+
if (serviceType !== endpointServiceType) {
|
|
81
|
+
throw new Error(
|
|
82
|
+
'Attempting to register endpoint with mismatched service type'
|
|
83
|
+
)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Approve token transfer operation
|
|
87
|
+
const contractAddress = await this.stakingProxyClient.getAddress()
|
|
88
|
+
const tx0 = await this.audiusTokenClient.approve(
|
|
89
|
+
contractAddress,
|
|
90
|
+
amount as BN
|
|
91
|
+
)
|
|
92
|
+
|
|
93
|
+
// Register and stake
|
|
94
|
+
const method = await this.getMethod(
|
|
95
|
+
'register',
|
|
96
|
+
Utils.utf8ToHex(serviceType),
|
|
97
|
+
sanitizedEndpoint,
|
|
98
|
+
amount,
|
|
99
|
+
delegateOwnerWallet
|
|
100
|
+
)
|
|
101
|
+
// @ts-expect-error TODO: this seems incorrect
|
|
102
|
+
const tx = await this.web3Manager.sendTransaction(method, 1000000)
|
|
103
|
+
const returnValues = tx.events?.['RegisteredServiceProvider']?.returnValues
|
|
104
|
+
return {
|
|
105
|
+
txReceipt: tx,
|
|
106
|
+
spID: parseInt(returnValues._spID),
|
|
107
|
+
serviceType: Utils.hexToUtf8(returnValues._serviceType),
|
|
108
|
+
owner: returnValues._owner,
|
|
109
|
+
endpoint: returnValues._endpoint,
|
|
110
|
+
tokenApproveReceipt: tx0
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async register(serviceType: string, endpoint: string, amount: BN) {
|
|
115
|
+
return await this.registerWithDelegate(
|
|
116
|
+
serviceType,
|
|
117
|
+
endpoint,
|
|
118
|
+
amount,
|
|
119
|
+
this.web3Manager.getWalletAddress()
|
|
120
|
+
)
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
async getRegisteredServiceProviderEvents({
|
|
124
|
+
serviceType,
|
|
125
|
+
owner,
|
|
126
|
+
queryStartBlock = 0
|
|
127
|
+
}: GetEvent) {
|
|
128
|
+
const contract = await this.getContract()
|
|
129
|
+
const filter: Filter = {}
|
|
130
|
+
if (owner) {
|
|
131
|
+
filter._owner = owner
|
|
132
|
+
}
|
|
133
|
+
if (serviceType) {
|
|
134
|
+
filter._serviceType = serviceType
|
|
135
|
+
}
|
|
136
|
+
const events = await contract.getPastEvents('RegisteredServiceProvider', {
|
|
137
|
+
fromBlock: queryStartBlock,
|
|
138
|
+
filter
|
|
139
|
+
})
|
|
140
|
+
|
|
141
|
+
return events.map((event) => ({
|
|
142
|
+
blockNumber: parseInt(event.blockNumber as unknown as string),
|
|
143
|
+
spID: parseInt(event.returnValues['_spID']),
|
|
144
|
+
serviceType: Utils.hexToUtf8(event.returnValues['_serviceType']),
|
|
145
|
+
owner: event.returnValues['_owner'],
|
|
146
|
+
endpoint: event.returnValues['_endpoint'],
|
|
147
|
+
stakeAmount: Utils.toBN(event.returnValues['_stakeAmout'])
|
|
148
|
+
}))
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
async getDeregisteredServiceProviderEvents({
|
|
152
|
+
serviceType,
|
|
153
|
+
owner,
|
|
154
|
+
queryStartBlock = 0
|
|
155
|
+
}: GetEvent) {
|
|
156
|
+
const contract = await this.getContract()
|
|
157
|
+
const filter: Filter = {}
|
|
158
|
+
if (owner) {
|
|
159
|
+
filter._owner = owner
|
|
160
|
+
}
|
|
161
|
+
if (serviceType) {
|
|
162
|
+
filter._serviceType = serviceType
|
|
163
|
+
}
|
|
164
|
+
const events = await contract.getPastEvents('DeregisteredServiceProvider', {
|
|
165
|
+
fromBlock: queryStartBlock,
|
|
166
|
+
filter
|
|
167
|
+
})
|
|
168
|
+
return events.map((event) => ({
|
|
169
|
+
blockNumber: parseInt(event.blockNumber as unknown as string),
|
|
170
|
+
spID: parseInt(event.returnValues['_spID']),
|
|
171
|
+
serviceType: Utils.hexToUtf8(event.returnValues['_serviceType']),
|
|
172
|
+
owner: event.returnValues['_owner'],
|
|
173
|
+
endpoint: event.returnValues['_endpoint'],
|
|
174
|
+
stakeAmount: Utils.toBN(event.returnValues['_stakeAmount'])
|
|
175
|
+
}))
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
async getIncreasedStakeEvents({
|
|
179
|
+
owner,
|
|
180
|
+
queryStartBlock = 0
|
|
181
|
+
}: {
|
|
182
|
+
owner: string
|
|
183
|
+
queryStartBlock: number
|
|
184
|
+
}) {
|
|
185
|
+
const contract = await this.getContract()
|
|
186
|
+
const events = await contract.getPastEvents('IncreasedStake', {
|
|
187
|
+
fromBlock: queryStartBlock,
|
|
188
|
+
filter: {
|
|
189
|
+
_owner: owner
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
return events.map((event) => ({
|
|
193
|
+
blockNumber: parseInt(event.blockNumber as unknown as string),
|
|
194
|
+
owner: event.returnValues['_owner'],
|
|
195
|
+
increaseAmount: Utils.toBN(event.returnValues['_increaseAmount']),
|
|
196
|
+
newStakeAmount: Utils.toBN(event.returnValues['_newStakeAmount'])
|
|
197
|
+
}))
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async getDecreasedStakeEvaluatedEvents({
|
|
201
|
+
owner,
|
|
202
|
+
queryStartBlock = 0
|
|
203
|
+
}: {
|
|
204
|
+
owner: string
|
|
205
|
+
queryStartBlock: number
|
|
206
|
+
}) {
|
|
207
|
+
const contract = await this.getContract()
|
|
208
|
+
const events = await contract.getPastEvents(
|
|
209
|
+
'DecreaseStakeRequestEvaluated',
|
|
210
|
+
{
|
|
211
|
+
fromBlock: queryStartBlock,
|
|
212
|
+
filter: {
|
|
213
|
+
_owner: owner
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
)
|
|
217
|
+
return events.map((event) => ({
|
|
218
|
+
blockNumber: parseInt(event.blockNumber as unknown as string),
|
|
219
|
+
owner: event.returnValues['_owner'],
|
|
220
|
+
decreaseAmount: Utils.toBN(event.returnValues['_decreaseAmount']),
|
|
221
|
+
newStakeAmount: Utils.toBN(event.returnValues['_newStakeAmount'])
|
|
222
|
+
}))
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async getDecreasedStakeRequestedEvents({
|
|
226
|
+
owner,
|
|
227
|
+
queryStartBlock = 0
|
|
228
|
+
}: {
|
|
229
|
+
owner: string
|
|
230
|
+
queryStartBlock: number
|
|
231
|
+
}) {
|
|
232
|
+
const contract = await this.getContract()
|
|
233
|
+
const events = await contract.getPastEvents('DecreaseStakeRequested', {
|
|
234
|
+
fromBlock: queryStartBlock,
|
|
235
|
+
filter: {
|
|
236
|
+
_owner: owner
|
|
237
|
+
}
|
|
238
|
+
})
|
|
239
|
+
return events.map((event) => ({
|
|
240
|
+
blockNumber: parseInt(event.blockNumber as unknown as string),
|
|
241
|
+
owner: event.returnValues['_owner'],
|
|
242
|
+
decreaseAmount: Utils.toBN(event.returnValues['_decreaseAmount']),
|
|
243
|
+
lockupExpiryBlock: parseInt(event.returnValues['_lockupExpiryBlock'])
|
|
244
|
+
}))
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
async getDecreasedStakeCancelledEvents({
|
|
248
|
+
owner,
|
|
249
|
+
queryStartBlock = 0
|
|
250
|
+
}: {
|
|
251
|
+
owner: string
|
|
252
|
+
queryStartBlock: number
|
|
253
|
+
}) {
|
|
254
|
+
const contract = await this.getContract()
|
|
255
|
+
const events = await contract.getPastEvents(
|
|
256
|
+
'DecreaseStakeRequestCancelled',
|
|
257
|
+
{
|
|
258
|
+
fromBlock: queryStartBlock,
|
|
259
|
+
filter: {
|
|
260
|
+
_owner: owner
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
)
|
|
264
|
+
return events.map((event) => ({
|
|
265
|
+
blockNumber: parseInt(event.blockNumber as unknown as string),
|
|
266
|
+
owner: event.returnValues['_owner'],
|
|
267
|
+
decreaseAmount: Utils.toBN(event.returnValues['_decreaseAmount']),
|
|
268
|
+
lockupExpiryBlock: parseInt(event.returnValues['_lockupExpiryBlock'])
|
|
269
|
+
}))
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
// Get the deregistered service's most recent endpoint and delegate owner wallet
|
|
273
|
+
async getDeregisteredService({
|
|
274
|
+
serviceType,
|
|
275
|
+
spID,
|
|
276
|
+
queryStartBlock = 0
|
|
277
|
+
}: {
|
|
278
|
+
serviceType: string
|
|
279
|
+
spID: string
|
|
280
|
+
queryStartBlock: number
|
|
281
|
+
}) {
|
|
282
|
+
const contract = await this.getContract()
|
|
283
|
+
const service: {
|
|
284
|
+
endpoint: string
|
|
285
|
+
delegateOwnerWallet: string
|
|
286
|
+
owner?: string
|
|
287
|
+
} = { endpoint: '', delegateOwnerWallet: '' }
|
|
288
|
+
const registerEvents = await contract.getPastEvents(
|
|
289
|
+
'RegisteredServiceProvider',
|
|
290
|
+
{
|
|
291
|
+
fromBlock: queryStartBlock,
|
|
292
|
+
filter: {
|
|
293
|
+
_spID: spID,
|
|
294
|
+
_serviceType: Utils.utf8ToHex(serviceType)
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
)
|
|
298
|
+
|
|
299
|
+
if (registerEvents.length > 0) {
|
|
300
|
+
const { _endpoint, _owner } = registerEvents[registerEvents.length - 1]
|
|
301
|
+
?.returnValues as { _endpoint: string; _owner: string }
|
|
302
|
+
service.endpoint = _endpoint
|
|
303
|
+
service.owner = _owner
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const endpointUpdateEvents = await contract.getPastEvents(
|
|
307
|
+
'EndpointUpdated',
|
|
308
|
+
{
|
|
309
|
+
fromBlock: queryStartBlock,
|
|
310
|
+
filter: {
|
|
311
|
+
_spID: spID,
|
|
312
|
+
_serviceType: Utils.utf8ToHex(serviceType)
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
if (endpointUpdateEvents.length > 0) {
|
|
318
|
+
const { _newEndpoint } = endpointUpdateEvents[
|
|
319
|
+
endpointUpdateEvents.length - 1
|
|
320
|
+
]?.returnValues as { _newEndpoint: string }
|
|
321
|
+
service.endpoint = _newEndpoint
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
const walletEvents = await contract.getPastEvents(
|
|
325
|
+
'DelegateOwnerWalletUpdated',
|
|
326
|
+
{
|
|
327
|
+
fromBlock: queryStartBlock,
|
|
328
|
+
filter: {
|
|
329
|
+
_spID: spID,
|
|
330
|
+
_serviceType: Utils.utf8ToHex(serviceType)
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
)
|
|
334
|
+
|
|
335
|
+
if (walletEvents.length > 0) {
|
|
336
|
+
const { _updatedWallet } = walletEvents[walletEvents.length - 1]
|
|
337
|
+
?.returnValues as { _updatedWallet: string }
|
|
338
|
+
service.delegateOwnerWallet = _updatedWallet
|
|
339
|
+
}
|
|
340
|
+
|
|
341
|
+
return service
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
async increaseStake(amount: BN) {
|
|
345
|
+
const contractAddress = await this.stakingProxyClient.getAddress()
|
|
346
|
+
const tx0 = await this.audiusTokenClient.approve(contractAddress, amount)
|
|
347
|
+
const method = await this.getMethod('increaseStake', amount)
|
|
348
|
+
// @ts-expect-error TODO: sendTransaction's signature seems pretty different
|
|
349
|
+
const tx = await this.web3Manager.sendTransaction(method, 1000000)
|
|
350
|
+
return {
|
|
351
|
+
txReceipt: tx,
|
|
352
|
+
tokenApproveReceipt: tx0
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Makes a request to decrease stake
|
|
358
|
+
* @param amount
|
|
359
|
+
* @returns decrease stake lockup expiry block
|
|
360
|
+
*/
|
|
361
|
+
async requestDecreaseStake(amount: BN) {
|
|
362
|
+
const requestDecreaseMethod = await this.getMethod(
|
|
363
|
+
'requestDecreaseStake',
|
|
364
|
+
amount
|
|
365
|
+
)
|
|
366
|
+
await this.web3Manager.sendTransaction(
|
|
367
|
+
requestDecreaseMethod,
|
|
368
|
+
// @ts-expect-error TODO: sendTransaction's signature seems pretty different
|
|
369
|
+
1000000
|
|
370
|
+
)
|
|
371
|
+
|
|
372
|
+
const account = this.web3Manager.getWalletAddress()
|
|
373
|
+
const lockupExpiryBlock = await this.getLockupExpiry(account)
|
|
374
|
+
return parseInt(lockupExpiryBlock as unknown as string)
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Gets the pending decrease stake request for a given account
|
|
379
|
+
* @param account wallet address to fetch for
|
|
380
|
+
*/
|
|
381
|
+
async getPendingDecreaseStakeRequest(account: string) {
|
|
382
|
+
const requestInfoMethod = await this.getMethod(
|
|
383
|
+
'getPendingDecreaseStakeRequest',
|
|
384
|
+
account
|
|
385
|
+
)
|
|
386
|
+
const { amount, lockupExpiryBlock } = await requestInfoMethod.call()
|
|
387
|
+
return {
|
|
388
|
+
amount: Utils.toBN(amount),
|
|
389
|
+
lockupExpiryBlock: parseInt(lockupExpiryBlock)
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/**
|
|
394
|
+
* Gets the pending decrease stake lockup duration
|
|
395
|
+
*/
|
|
396
|
+
async getDecreaseStakeLockupDuration() {
|
|
397
|
+
const requestInfoMethod = await this.getMethod(
|
|
398
|
+
'getDecreaseStakeLockupDuration'
|
|
399
|
+
)
|
|
400
|
+
const info = await requestInfoMethod.call()
|
|
401
|
+
return parseInt(info)
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
/**
|
|
405
|
+
* Gets the deployer cut lockup duration
|
|
406
|
+
*/
|
|
407
|
+
async getDeployerCutLockupDuration() {
|
|
408
|
+
const requestInfoMethod = await this.getMethod(
|
|
409
|
+
'getDeployerCutLockupDuration'
|
|
410
|
+
)
|
|
411
|
+
const info = await requestInfoMethod.call()
|
|
412
|
+
return parseInt(info)
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
/**
|
|
416
|
+
* Cancels the pending decrease stake request
|
|
417
|
+
* @param account wallet address to cancel request for
|
|
418
|
+
*/
|
|
419
|
+
async cancelDecreaseStakeRequest(account: string) {
|
|
420
|
+
const requestCancelDecreaseMethod = await this.getMethod(
|
|
421
|
+
'cancelDecreaseStakeRequest',
|
|
422
|
+
account
|
|
423
|
+
)
|
|
424
|
+
await this.web3Manager.sendTransaction(
|
|
425
|
+
requestCancelDecreaseMethod,
|
|
426
|
+
// @ts-expect-error TODO: double check sendTransaction
|
|
427
|
+
1000000
|
|
428
|
+
)
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
/**
|
|
432
|
+
* Fetches the pending decrease stake lockup expiry block for a user
|
|
433
|
+
* @param account wallet address to fetch for
|
|
434
|
+
*/
|
|
435
|
+
async getLockupExpiry(account: string) {
|
|
436
|
+
const { lockupExpiryBlock } = await this.getPendingDecreaseStakeRequest(
|
|
437
|
+
account
|
|
438
|
+
)
|
|
439
|
+
return parseInt(lockupExpiryBlock as unknown as string)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
async decreaseStake() {
|
|
443
|
+
const method = await this.getMethod('decreaseStake')
|
|
444
|
+
// @ts-expect-error TODO: double check sendTransaction
|
|
445
|
+
const tx = await this.web3Manager.sendTransaction(method, 1000000)
|
|
446
|
+
|
|
447
|
+
return {
|
|
448
|
+
txReceipt: tx
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
/**
|
|
453
|
+
* Deregisters a service
|
|
454
|
+
* @param serviceType
|
|
455
|
+
* @param endpoint
|
|
456
|
+
*/
|
|
457
|
+
async deregister(serviceType: string, endpoint: string) {
|
|
458
|
+
const method = await this.getMethod(
|
|
459
|
+
'deregister',
|
|
460
|
+
Utils.utf8ToHex(serviceType),
|
|
461
|
+
endpoint
|
|
462
|
+
)
|
|
463
|
+
const tx = await this.web3Manager.sendTransaction(method)
|
|
464
|
+
const returnValues =
|
|
465
|
+
tx.events?.['DeregisteredServiceProvider']?.returnValues
|
|
466
|
+
|
|
467
|
+
return {
|
|
468
|
+
txReceipt: tx,
|
|
469
|
+
spID: parseInt(returnValues._spID),
|
|
470
|
+
serviceType: Utils.hexToUtf8(returnValues._serviceType),
|
|
471
|
+
owner: returnValues._owner,
|
|
472
|
+
endpoint: returnValues._endpoint
|
|
473
|
+
}
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
async getTotalServiceTypeProviders(serviceType: string) {
|
|
477
|
+
const method = await this.getMethod(
|
|
478
|
+
'getTotalServiceTypeProviders',
|
|
479
|
+
Utils.utf8ToHex(serviceType)
|
|
480
|
+
)
|
|
481
|
+
const count = await method.call()
|
|
482
|
+
return parseInt(count)
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async getServiceProviderIdFromEndpoint(endpoint: string) {
|
|
486
|
+
const method = await this.getMethod(
|
|
487
|
+
'getServiceProviderIdFromEndpoint',
|
|
488
|
+
endpoint
|
|
489
|
+
)
|
|
490
|
+
const info = await method.call()
|
|
491
|
+
return parseInt(info)
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
// TODO: Remove this method after all consumers are using
|
|
495
|
+
// `getServiceEndpointInfo` directly
|
|
496
|
+
async getServiceProviderInfo(serviceType: string, serviceId: number) {
|
|
497
|
+
return await this.getServiceEndpointInfo(serviceType, serviceId)
|
|
498
|
+
}
|
|
499
|
+
|
|
500
|
+
async getServiceEndpointInfo(serviceType: string, serviceId: number) {
|
|
501
|
+
const method = await this.getMethod(
|
|
502
|
+
'getServiceEndpointInfo',
|
|
503
|
+
Utils.utf8ToHex(serviceType),
|
|
504
|
+
serviceId
|
|
505
|
+
)
|
|
506
|
+
const info = await method.call()
|
|
507
|
+
return {
|
|
508
|
+
owner: info.owner,
|
|
509
|
+
endpoint: info.endpoint.replace(/\/$/, ''),
|
|
510
|
+
spID: parseInt(serviceId as unknown as string),
|
|
511
|
+
type: serviceType,
|
|
512
|
+
blockNumber: parseInt(info.blockNumber),
|
|
513
|
+
delegateOwnerWallet: info.delegateOwnerWallet
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
async getServiceProviderInfoFromEndpoint(endpoint: string) {
|
|
518
|
+
const requestUrl = urlJoin(endpoint, 'health_check')
|
|
519
|
+
const axiosRequestObj: AxiosRequestConfig = {
|
|
520
|
+
url: requestUrl,
|
|
521
|
+
method: 'get',
|
|
522
|
+
timeout: 1000
|
|
523
|
+
}
|
|
524
|
+
|
|
525
|
+
const resp = await axios(axiosRequestObj)
|
|
526
|
+
const serviceType = resp.data.data.service
|
|
527
|
+
|
|
528
|
+
const serviceProviderId = await this.getServiceProviderIdFromEndpoint(
|
|
529
|
+
endpoint
|
|
530
|
+
)
|
|
531
|
+
const info = await this.getServiceEndpointInfo(
|
|
532
|
+
serviceType,
|
|
533
|
+
serviceProviderId
|
|
534
|
+
)
|
|
535
|
+
return info
|
|
536
|
+
}
|
|
537
|
+
|
|
538
|
+
async getServiceProviderIdsFromAddress(
|
|
539
|
+
ownerAddress: string,
|
|
540
|
+
serviceType: string
|
|
541
|
+
) {
|
|
542
|
+
const method = await this.getMethod(
|
|
543
|
+
'getServiceProviderIdsFromAddress',
|
|
544
|
+
ownerAddress,
|
|
545
|
+
Utils.utf8ToHex(serviceType)
|
|
546
|
+
)
|
|
547
|
+
const info: string[] = await method.call()
|
|
548
|
+
return info.map((id) => parseInt(id))
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
async getServiceProviderIdFromAddress(
|
|
552
|
+
ownerAddress: string,
|
|
553
|
+
serviceType: string
|
|
554
|
+
) {
|
|
555
|
+
const infos = await this.getServiceProviderIdsFromAddress(
|
|
556
|
+
ownerAddress,
|
|
557
|
+
serviceType
|
|
558
|
+
)
|
|
559
|
+
return infos[0] as number
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
async getServiceEndpointInfoFromAddress(
|
|
563
|
+
ownerAddress: string,
|
|
564
|
+
serviceType: string
|
|
565
|
+
) {
|
|
566
|
+
const spId = await this.getServiceProviderIdFromAddress(
|
|
567
|
+
ownerAddress,
|
|
568
|
+
serviceType
|
|
569
|
+
)
|
|
570
|
+
|
|
571
|
+
// cast this as an array for backwards compatibility because everything expects an array
|
|
572
|
+
const spInfo = [await this.getServiceEndpointInfo(serviceType, spId)]
|
|
573
|
+
return spInfo
|
|
574
|
+
}
|
|
575
|
+
|
|
576
|
+
/**
|
|
577
|
+
* Returns all service providers of requested `serviceType`
|
|
578
|
+
* Returns array of objects with schema { blockNumber, delegateOwnerWallet, endpoint, owner, spID, type }
|
|
579
|
+
*/
|
|
580
|
+
async getServiceProviderList(serviceType: string) {
|
|
581
|
+
const numberOfProviders = await this.getTotalServiceTypeProviders(
|
|
582
|
+
serviceType
|
|
583
|
+
)
|
|
584
|
+
|
|
585
|
+
const providerList = await Promise.all(
|
|
586
|
+
range(1, numberOfProviders + 1).map(
|
|
587
|
+
async (i) => await this.getServiceEndpointInfo(serviceType, i)
|
|
588
|
+
)
|
|
589
|
+
)
|
|
590
|
+
return providerList.filter((provider) => provider.endpoint !== '')
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
async updateDecreaseStakeLockupDuration(duration: string) {
|
|
594
|
+
const method = await this.getGovernedMethod(
|
|
595
|
+
'updateDecreaseStakeLockupDuration',
|
|
596
|
+
duration
|
|
597
|
+
)
|
|
598
|
+
return await this.web3Manager.sendTransaction(method)
|
|
599
|
+
}
|
|
600
|
+
|
|
601
|
+
async getServiceProviderDetails(serviceProviderAddress: string) {
|
|
602
|
+
const method = await this.getMethod(
|
|
603
|
+
'getServiceProviderDetails',
|
|
604
|
+
serviceProviderAddress
|
|
605
|
+
)
|
|
606
|
+
const info = await method.call()
|
|
607
|
+
return {
|
|
608
|
+
deployerCut: parseInt(info.deployerCut),
|
|
609
|
+
deployerStake: Utils.toBN(info.deployerStake),
|
|
610
|
+
maxAccountStake: Utils.toBN(info.maxAccountStake),
|
|
611
|
+
minAccountStake: Utils.toBN(info.minAccountStake),
|
|
612
|
+
numberOfEndpoints: parseInt(info.numberOfEndpoints),
|
|
613
|
+
validBounds: info.validBounds
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
|
|
617
|
+
async updateDelegateOwnerWallet(
|
|
618
|
+
serviceType: string,
|
|
619
|
+
endpoint: string,
|
|
620
|
+
updatedDelegateOwnerWallet: string
|
|
621
|
+
) {
|
|
622
|
+
const method = await this.getMethod(
|
|
623
|
+
'updateDelegateOwnerWallet',
|
|
624
|
+
Utils.utf8ToHex(serviceType),
|
|
625
|
+
endpoint,
|
|
626
|
+
updatedDelegateOwnerWallet
|
|
627
|
+
)
|
|
628
|
+
|
|
629
|
+
const tx = await this.web3Manager.sendTransaction(method)
|
|
630
|
+
return tx
|
|
631
|
+
}
|
|
632
|
+
|
|
633
|
+
async updateEndpoint(
|
|
634
|
+
serviceType: string,
|
|
635
|
+
oldEndpoint: string,
|
|
636
|
+
newEndpoint: string
|
|
637
|
+
) {
|
|
638
|
+
const method = await this.getMethod(
|
|
639
|
+
'updateEndpoint',
|
|
640
|
+
Utils.utf8ToHex(serviceType),
|
|
641
|
+
oldEndpoint,
|
|
642
|
+
newEndpoint
|
|
643
|
+
)
|
|
644
|
+
const tx = await this.web3Manager.sendTransaction(method)
|
|
645
|
+
return tx
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
async requestUpdateDeployerCut(ownerAddress: string, deployerCut: string) {
|
|
649
|
+
const method = await this.getMethod(
|
|
650
|
+
'requestUpdateDeployerCut',
|
|
651
|
+
ownerAddress,
|
|
652
|
+
deployerCut
|
|
653
|
+
)
|
|
654
|
+
const tx = await this.web3Manager.sendTransaction(method)
|
|
655
|
+
return tx
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
async getPendingUpdateDeployerCutRequest(ownerAddress: string) {
|
|
659
|
+
const method = await this.getMethod(
|
|
660
|
+
'getPendingUpdateDeployerCutRequest',
|
|
661
|
+
ownerAddress
|
|
662
|
+
)
|
|
663
|
+
const { lockupExpiryBlock, newDeployerCut } = await method.call()
|
|
664
|
+
return {
|
|
665
|
+
lockupExpiryBlock: parseInt(lockupExpiryBlock),
|
|
666
|
+
newDeployerCut: parseInt(newDeployerCut)
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
async cancelUpdateDeployerCut(ownerAddress: string) {
|
|
671
|
+
const method = await this.getMethod('cancelUpdateDeployerCut', ownerAddress)
|
|
672
|
+
const tx = await this.web3Manager.sendTransaction(method)
|
|
673
|
+
return tx
|
|
674
|
+
}
|
|
675
|
+
|
|
676
|
+
async updateDeployerCut(ownerAddress: string) {
|
|
677
|
+
const method = await this.getMethod('updateDeployerCut', ownerAddress)
|
|
678
|
+
const tx = await this.web3Manager.sendTransaction(method)
|
|
679
|
+
return tx
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
async updateServiceProviderStake(ownerAddress: string, newAmount: string) {
|
|
683
|
+
const method = await this.getMethod(
|
|
684
|
+
'updateServiceProviderStake',
|
|
685
|
+
ownerAddress,
|
|
686
|
+
newAmount
|
|
687
|
+
)
|
|
688
|
+
const tx = await this.web3Manager.sendTransaction(method)
|
|
689
|
+
return tx
|
|
690
|
+
}
|
|
691
|
+
}
|