@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,234 @@
|
|
|
1
|
+
import { Utils, Logger } from '../../utils'
|
|
2
|
+
|
|
3
|
+
// load classes wrapping contracts
|
|
4
|
+
import { RegistryClient } from './RegistryClient'
|
|
5
|
+
import { UserFactoryClient } from './UserFactoryClient'
|
|
6
|
+
import { TrackFactoryClient } from './TrackFactoryClient'
|
|
7
|
+
import { SocialFeatureFactoryClient } from './SocialFeatureFactoryClient'
|
|
8
|
+
import { PlaylistFactoryClient } from './PlaylistFactoryClient'
|
|
9
|
+
import { UserLibraryFactoryClient } from './UserLibraryFactoryClient'
|
|
10
|
+
import { IPLDBlacklistFactoryClient } from './IPLDBlacklistFactoryClient'
|
|
11
|
+
import { UserReplicaSetManagerClient } from './UserReplicaSetManagerClient'
|
|
12
|
+
import type { Web3Manager } from '../web3Manager'
|
|
13
|
+
import type { ContractClient } from '../contracts/ContractClient'
|
|
14
|
+
|
|
15
|
+
// Make sure the json file exists before importing because it could silently fail
|
|
16
|
+
// import data contract ABI's
|
|
17
|
+
const RegistryABI = Utils.importDataContractABI('Registry.json').abi
|
|
18
|
+
const UserFactoryABI = Utils.importDataContractABI('UserFactory.json').abi
|
|
19
|
+
const TrackFactoryABI = Utils.importDataContractABI('TrackFactory.json').abi
|
|
20
|
+
const SocialFeatureFactoryABI = Utils.importDataContractABI(
|
|
21
|
+
'SocialFeatureFactory.json'
|
|
22
|
+
).abi
|
|
23
|
+
const PlaylistFactoryABI = Utils.importDataContractABI(
|
|
24
|
+
'PlaylistFactory.json'
|
|
25
|
+
).abi
|
|
26
|
+
const UserLibraryFactoryABI = Utils.importDataContractABI(
|
|
27
|
+
'UserLibraryFactory.json'
|
|
28
|
+
).abi
|
|
29
|
+
const IPLDBlacklistFactoryABI = Utils.importDataContractABI(
|
|
30
|
+
'IPLDBlacklistFactory.json'
|
|
31
|
+
).abi
|
|
32
|
+
const UserReplicaSetManagerABI = Utils.importDataContractABI(
|
|
33
|
+
'UserReplicaSetManager.json'
|
|
34
|
+
).abi
|
|
35
|
+
|
|
36
|
+
// define contract registry keys
|
|
37
|
+
const UserFactoryRegistryKey = 'UserFactory'
|
|
38
|
+
const TrackFactoryRegistryKey = 'TrackFactory'
|
|
39
|
+
const SocialFeatureFactoryRegistryKey = 'SocialFeatureFactory'
|
|
40
|
+
const PlaylistFactoryRegistryKey = 'PlaylistFactory'
|
|
41
|
+
const UserLibraryFactoryRegistryKey = 'UserLibraryFactory'
|
|
42
|
+
const IPLDBlacklistFactoryRegistryKey = 'IPLDBlacklistFactory'
|
|
43
|
+
const UserReplicaSetManagerRegistryKey = 'UserReplicaSetManager'
|
|
44
|
+
|
|
45
|
+
export class AudiusContracts {
|
|
46
|
+
web3Manager: Web3Manager
|
|
47
|
+
registryAddress: string
|
|
48
|
+
isServer: boolean
|
|
49
|
+
logger: Logger
|
|
50
|
+
RegistryClient: RegistryClient
|
|
51
|
+
UserFactoryClient: UserFactoryClient
|
|
52
|
+
TrackFactoryClient: TrackFactoryClient
|
|
53
|
+
SocialFeatureFactoryClient: SocialFeatureFactoryClient
|
|
54
|
+
PlaylistFactoryClient: PlaylistFactoryClient
|
|
55
|
+
UserLibraryFactoryClient: UserLibraryFactoryClient
|
|
56
|
+
IPLDBlacklistFactoryClient: IPLDBlacklistFactoryClient
|
|
57
|
+
contractClients: ContractClient[]
|
|
58
|
+
UserReplicaSetManagerClient: UserReplicaSetManagerClient | undefined | null
|
|
59
|
+
contracts: Record<string, string> | undefined
|
|
60
|
+
contractAddresses: Record<string, string> | undefined
|
|
61
|
+
|
|
62
|
+
constructor(
|
|
63
|
+
web3Manager: Web3Manager,
|
|
64
|
+
registryAddress: string,
|
|
65
|
+
isServer: boolean,
|
|
66
|
+
logger = console
|
|
67
|
+
) {
|
|
68
|
+
this.web3Manager = web3Manager
|
|
69
|
+
this.registryAddress = registryAddress
|
|
70
|
+
this.isServer = isServer
|
|
71
|
+
this.logger = logger
|
|
72
|
+
|
|
73
|
+
this.RegistryClient = new RegistryClient(
|
|
74
|
+
this.web3Manager,
|
|
75
|
+
RegistryABI,
|
|
76
|
+
this.registryAddress
|
|
77
|
+
)
|
|
78
|
+
this.getRegistryAddressForContract =
|
|
79
|
+
this.getRegistryAddressForContract.bind(this)
|
|
80
|
+
|
|
81
|
+
this.UserFactoryClient = new UserFactoryClient(
|
|
82
|
+
this.web3Manager,
|
|
83
|
+
UserFactoryABI,
|
|
84
|
+
UserFactoryRegistryKey,
|
|
85
|
+
this.getRegistryAddressForContract,
|
|
86
|
+
this.logger
|
|
87
|
+
)
|
|
88
|
+
|
|
89
|
+
this.TrackFactoryClient = new TrackFactoryClient(
|
|
90
|
+
this.web3Manager,
|
|
91
|
+
TrackFactoryABI,
|
|
92
|
+
TrackFactoryRegistryKey,
|
|
93
|
+
this.getRegistryAddressForContract,
|
|
94
|
+
this.logger
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
this.SocialFeatureFactoryClient = new SocialFeatureFactoryClient(
|
|
98
|
+
this.web3Manager,
|
|
99
|
+
SocialFeatureFactoryABI,
|
|
100
|
+
SocialFeatureFactoryRegistryKey,
|
|
101
|
+
this.getRegistryAddressForContract,
|
|
102
|
+
this.logger
|
|
103
|
+
)
|
|
104
|
+
|
|
105
|
+
this.PlaylistFactoryClient = new PlaylistFactoryClient(
|
|
106
|
+
this.web3Manager,
|
|
107
|
+
PlaylistFactoryABI,
|
|
108
|
+
PlaylistFactoryRegistryKey,
|
|
109
|
+
this.getRegistryAddressForContract,
|
|
110
|
+
this.logger
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
this.UserLibraryFactoryClient = new UserLibraryFactoryClient(
|
|
114
|
+
this.web3Manager,
|
|
115
|
+
UserLibraryFactoryABI,
|
|
116
|
+
UserLibraryFactoryRegistryKey,
|
|
117
|
+
this.getRegistryAddressForContract,
|
|
118
|
+
this.logger
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
this.IPLDBlacklistFactoryClient = new IPLDBlacklistFactoryClient(
|
|
122
|
+
this.web3Manager,
|
|
123
|
+
IPLDBlacklistFactoryABI,
|
|
124
|
+
IPLDBlacklistFactoryRegistryKey,
|
|
125
|
+
this.getRegistryAddressForContract,
|
|
126
|
+
this.logger
|
|
127
|
+
)
|
|
128
|
+
|
|
129
|
+
this.contractClients = [
|
|
130
|
+
this.UserFactoryClient,
|
|
131
|
+
this.TrackFactoryClient,
|
|
132
|
+
this.SocialFeatureFactoryClient,
|
|
133
|
+
this.PlaylistFactoryClient,
|
|
134
|
+
this.UserLibraryFactoryClient,
|
|
135
|
+
this.IPLDBlacklistFactoryClient
|
|
136
|
+
]
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
async init() {
|
|
140
|
+
if (this.isServer) {
|
|
141
|
+
await Promise.all(
|
|
142
|
+
this.contractClients.map(async (client) => await client.init())
|
|
143
|
+
)
|
|
144
|
+
await this.initUserReplicaSetManagerClient()
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Special case initialization flow for UserReplicaSetManagerClient backwards compatibility
|
|
149
|
+
// Until the contract is deployed and added to the data contract registry, replica set
|
|
150
|
+
// operations will flow through the existing UserFactory
|
|
151
|
+
async initUserReplicaSetManagerClient() {
|
|
152
|
+
try {
|
|
153
|
+
if (
|
|
154
|
+
this.UserReplicaSetManagerClient &&
|
|
155
|
+
this.UserReplicaSetManagerClient._contractAddress !==
|
|
156
|
+
'0x0000000000000000000000000000000000000000'
|
|
157
|
+
) {
|
|
158
|
+
return
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
this.UserReplicaSetManagerClient = new UserReplicaSetManagerClient(
|
|
162
|
+
this.web3Manager,
|
|
163
|
+
UserReplicaSetManagerABI,
|
|
164
|
+
UserReplicaSetManagerRegistryKey,
|
|
165
|
+
this.getRegistryAddressForContract,
|
|
166
|
+
this.logger
|
|
167
|
+
)
|
|
168
|
+
await this.UserReplicaSetManagerClient.init()
|
|
169
|
+
if (
|
|
170
|
+
this.UserReplicaSetManagerClient._contractAddress ===
|
|
171
|
+
'0x0000000000000000000000000000000000000000'
|
|
172
|
+
) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
`Failed retrieve address for ${this.UserReplicaSetManagerClient.contractRegistryKey}`
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
const seedComplete =
|
|
178
|
+
await this.UserReplicaSetManagerClient.getSeedComplete()
|
|
179
|
+
if (!seedComplete) {
|
|
180
|
+
throw new Error('UserReplicaSetManager pending seed operation')
|
|
181
|
+
}
|
|
182
|
+
} catch (e) {
|
|
183
|
+
// Nullify failed attempt to initialize
|
|
184
|
+
console.log(
|
|
185
|
+
`Failed to initialize UserReplicaSetManagerClient with error ${
|
|
186
|
+
(e as Error).message
|
|
187
|
+
}`
|
|
188
|
+
)
|
|
189
|
+
this.UserReplicaSetManagerClient = null
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/* ------- CONTRACT META-FUNCTIONS ------- */
|
|
194
|
+
|
|
195
|
+
/**
|
|
196
|
+
* Retrieves contract address from Registry by key, caching previously retrieved data.
|
|
197
|
+
* Refreshes cache if cached value is empty or zero address.
|
|
198
|
+
* Value is empty during first time call, and zero if call is made before contract is deployed,
|
|
199
|
+
* since Registry sets default value of all contract keys to zero address if not registered.
|
|
200
|
+
* @param contractName registry key of contract
|
|
201
|
+
*/
|
|
202
|
+
async getRegistryAddressForContract(contractName: string) {
|
|
203
|
+
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Object_initializer#Computed_property_names
|
|
204
|
+
this.contracts = this.contracts ?? { [this.registryAddress]: 'registry' }
|
|
205
|
+
this.contractAddresses = this.contractAddresses ?? {
|
|
206
|
+
registry: this.registryAddress
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
if (
|
|
210
|
+
!this.contractAddresses[contractName] ||
|
|
211
|
+
Utils.isZeroAddress(this.contractAddresses[contractName] as string)
|
|
212
|
+
) {
|
|
213
|
+
const address = (await this.RegistryClient.getContract(
|
|
214
|
+
contractName
|
|
215
|
+
)) as string
|
|
216
|
+
this.contracts[address] = contractName
|
|
217
|
+
this.contractAddresses[contractName] = address
|
|
218
|
+
}
|
|
219
|
+
return this.contractAddresses[contractName] as string
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async getRegistryContractForAddress(address: string) {
|
|
223
|
+
if (!this.contracts) {
|
|
224
|
+
throw new Error('No contracts found. Have you called init() yet?')
|
|
225
|
+
}
|
|
226
|
+
const contractRegistryKey = this.contracts[address]
|
|
227
|
+
if (!contractRegistryKey) {
|
|
228
|
+
throw new Error(
|
|
229
|
+
`No registry contract found for contract address ${address}`
|
|
230
|
+
)
|
|
231
|
+
}
|
|
232
|
+
return contractRegistryKey
|
|
233
|
+
}
|
|
234
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { ContractClient } from '../contracts/ContractClient'
|
|
2
|
+
import * as signatureSchemas from '../../../data-contracts/signatureSchemas'
|
|
3
|
+
import sigUtil, { EIP712TypedData } from 'eth-sig-util'
|
|
4
|
+
import { Buffer as SafeBuffer } from 'safe-buffer'
|
|
5
|
+
import type { Web3Manager } from '../web3Manager'
|
|
6
|
+
|
|
7
|
+
type GeneratorFn = (
|
|
8
|
+
chainId: number,
|
|
9
|
+
contractAddress: string,
|
|
10
|
+
multihashDigest: string,
|
|
11
|
+
nonce: string
|
|
12
|
+
) => EIP712TypedData
|
|
13
|
+
|
|
14
|
+
export class IPLDBlacklistFactoryClient extends ContractClient {
|
|
15
|
+
async addIPLDToBlacklist(multihashDigest: string, privateKey = null) {
|
|
16
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
17
|
+
signatureSchemas.generators.addIPLDToBlacklistRequestData,
|
|
18
|
+
multihashDigest,
|
|
19
|
+
privateKey
|
|
20
|
+
)
|
|
21
|
+
const method = await this.getMethod(
|
|
22
|
+
'addIPLDToBlacklist',
|
|
23
|
+
multihashDigest,
|
|
24
|
+
nonce,
|
|
25
|
+
sig
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
const receipt = await method.send({
|
|
29
|
+
from: this.web3Manager.getWalletAddress(),
|
|
30
|
+
gas: 200000
|
|
31
|
+
})
|
|
32
|
+
return receipt
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* ------- HELPERS ------- */
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Gets a nonce and generates a signature for the given function. Private key is optional and
|
|
39
|
+
* will use that private key to create the signature. Otherwise the web3Manager private key
|
|
40
|
+
* will be used.
|
|
41
|
+
* @param generatorFn signature scheme object function
|
|
42
|
+
* @param multihashDigest blockchain userId
|
|
43
|
+
* @param privateKey optional. if this is passed in, the signature will be from
|
|
44
|
+
* this private key. the type is a 64 character hex string
|
|
45
|
+
*/
|
|
46
|
+
async getUpdateNonceAndSig(
|
|
47
|
+
generatorFn: GeneratorFn,
|
|
48
|
+
multihashDigest: string,
|
|
49
|
+
privateKey: string | null
|
|
50
|
+
) {
|
|
51
|
+
const nonce = signatureSchemas.getNonce()
|
|
52
|
+
const chainId = await this.getEthNetId()
|
|
53
|
+
const contractAddress = await this.getAddress()
|
|
54
|
+
const signatureData = generatorFn(
|
|
55
|
+
chainId,
|
|
56
|
+
contractAddress,
|
|
57
|
+
multihashDigest,
|
|
58
|
+
nonce
|
|
59
|
+
)
|
|
60
|
+
let sig
|
|
61
|
+
if (privateKey) {
|
|
62
|
+
sig = sigUtil.signTypedData(
|
|
63
|
+
SafeBuffer.from(privateKey, 'hex') as unknown as Buffer,
|
|
64
|
+
{
|
|
65
|
+
data: signatureData
|
|
66
|
+
}
|
|
67
|
+
)
|
|
68
|
+
} else {
|
|
69
|
+
sig = await (this.web3Manager as Web3Manager).signTypedData(signatureData)
|
|
70
|
+
}
|
|
71
|
+
return [nonce, sig]
|
|
72
|
+
}
|
|
73
|
+
}
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
import { ContractClient } from '../contracts/ContractClient'
|
|
2
|
+
import * as signatureSchemas from '../../../data-contracts/signatureSchemas'
|
|
3
|
+
import type { Web3Manager } from '../web3Manager'
|
|
4
|
+
|
|
5
|
+
const MAX_PLAYLIST_LENGTH = 199
|
|
6
|
+
|
|
7
|
+
export class PlaylistFactoryClient extends ContractClient {
|
|
8
|
+
override web3Manager!: Web3Manager
|
|
9
|
+
/* ------- SETTERS ------- */
|
|
10
|
+
|
|
11
|
+
async createPlaylist(
|
|
12
|
+
userId: number,
|
|
13
|
+
playlistName: string,
|
|
14
|
+
isPrivate: boolean,
|
|
15
|
+
isAlbum: boolean,
|
|
16
|
+
trackIds: number[]
|
|
17
|
+
) {
|
|
18
|
+
if (!Array.isArray(trackIds) || trackIds.length > MAX_PLAYLIST_LENGTH) {
|
|
19
|
+
throw new Error(
|
|
20
|
+
`Cannot create playlist - trackIds must be array with length <= ${MAX_PLAYLIST_LENGTH}`
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const nonce = signatureSchemas.getNonce()
|
|
25
|
+
const chainId = await this.getEthNetId()
|
|
26
|
+
const contractAddress = await this.getAddress()
|
|
27
|
+
const trackIdsHash = this.web3Manager
|
|
28
|
+
.getWeb3()
|
|
29
|
+
.utils.soliditySha3(
|
|
30
|
+
this.web3Manager.getWeb3().eth.abi.encodeParameter('uint[]', trackIds)
|
|
31
|
+
)
|
|
32
|
+
const signatureData =
|
|
33
|
+
signatureSchemas.generators.getCreatePlaylistRequestData(
|
|
34
|
+
chainId,
|
|
35
|
+
contractAddress,
|
|
36
|
+
userId,
|
|
37
|
+
playlistName,
|
|
38
|
+
isPrivate,
|
|
39
|
+
isAlbum,
|
|
40
|
+
trackIdsHash,
|
|
41
|
+
nonce
|
|
42
|
+
)
|
|
43
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
44
|
+
|
|
45
|
+
const method = await this.getMethod(
|
|
46
|
+
'createPlaylist',
|
|
47
|
+
userId,
|
|
48
|
+
playlistName,
|
|
49
|
+
isPrivate,
|
|
50
|
+
isAlbum,
|
|
51
|
+
trackIds,
|
|
52
|
+
nonce,
|
|
53
|
+
sig
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
57
|
+
method,
|
|
58
|
+
this.contractRegistryKey,
|
|
59
|
+
contractAddress
|
|
60
|
+
)
|
|
61
|
+
return {
|
|
62
|
+
playlistId: parseInt(
|
|
63
|
+
tx.events?.['PlaylistCreated']?.returnValues._playlistId,
|
|
64
|
+
10
|
|
65
|
+
),
|
|
66
|
+
txReceipt: tx
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async deletePlaylist(playlistId: number) {
|
|
71
|
+
const nonce = signatureSchemas.getNonce()
|
|
72
|
+
const chainId = await this.getEthNetId()
|
|
73
|
+
const contractAddress = await this.getAddress()
|
|
74
|
+
const signatureData =
|
|
75
|
+
signatureSchemas.generators.getDeletePlaylistRequestData(
|
|
76
|
+
chainId,
|
|
77
|
+
contractAddress,
|
|
78
|
+
playlistId,
|
|
79
|
+
nonce
|
|
80
|
+
)
|
|
81
|
+
|
|
82
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
83
|
+
const method = await this.getMethod(
|
|
84
|
+
'deletePlaylist',
|
|
85
|
+
playlistId,
|
|
86
|
+
nonce,
|
|
87
|
+
sig
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
91
|
+
method,
|
|
92
|
+
this.contractRegistryKey,
|
|
93
|
+
contractAddress
|
|
94
|
+
)
|
|
95
|
+
return {
|
|
96
|
+
playlistId: parseInt(
|
|
97
|
+
tx.events?.['PlaylistDeleted']?.returnValues._playlistId,
|
|
98
|
+
10
|
|
99
|
+
),
|
|
100
|
+
txReceipt: tx
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
async addPlaylistTrack(playlistId: number, addedTrackId: number) {
|
|
105
|
+
const nonce = signatureSchemas.getNonce()
|
|
106
|
+
const chainId = await this.getEthNetId()
|
|
107
|
+
const contractAddress = await this.getAddress()
|
|
108
|
+
const signatureData =
|
|
109
|
+
signatureSchemas.generators.getAddPlaylistTrackRequestData(
|
|
110
|
+
chainId,
|
|
111
|
+
contractAddress,
|
|
112
|
+
playlistId,
|
|
113
|
+
addedTrackId,
|
|
114
|
+
nonce
|
|
115
|
+
)
|
|
116
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
117
|
+
|
|
118
|
+
const method = await this.getMethod(
|
|
119
|
+
'addPlaylistTrack',
|
|
120
|
+
playlistId,
|
|
121
|
+
addedTrackId,
|
|
122
|
+
nonce,
|
|
123
|
+
sig
|
|
124
|
+
)
|
|
125
|
+
|
|
126
|
+
return await this.web3Manager.sendTransaction(
|
|
127
|
+
method,
|
|
128
|
+
this.contractRegistryKey,
|
|
129
|
+
contractAddress
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
async deletePlaylistTrack(
|
|
134
|
+
playlistId: number,
|
|
135
|
+
deletedTrackId: number,
|
|
136
|
+
deletedPlaylistTimestamp: number,
|
|
137
|
+
retries: number
|
|
138
|
+
) {
|
|
139
|
+
const nonce = signatureSchemas.getNonce()
|
|
140
|
+
const chainId = await this.getEthNetId()
|
|
141
|
+
const contractAddress = await this.getAddress()
|
|
142
|
+
const signatureData =
|
|
143
|
+
signatureSchemas.generators.getDeletePlaylistTrackRequestData(
|
|
144
|
+
chainId,
|
|
145
|
+
contractAddress,
|
|
146
|
+
playlistId,
|
|
147
|
+
deletedTrackId,
|
|
148
|
+
deletedPlaylistTimestamp,
|
|
149
|
+
nonce
|
|
150
|
+
)
|
|
151
|
+
|
|
152
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
153
|
+
const method = await this.getMethod(
|
|
154
|
+
'deletePlaylistTrack',
|
|
155
|
+
playlistId,
|
|
156
|
+
deletedTrackId,
|
|
157
|
+
deletedPlaylistTimestamp,
|
|
158
|
+
nonce,
|
|
159
|
+
sig
|
|
160
|
+
)
|
|
161
|
+
|
|
162
|
+
return await this.web3Manager.sendTransaction(
|
|
163
|
+
method,
|
|
164
|
+
this.contractRegistryKey,
|
|
165
|
+
contractAddress,
|
|
166
|
+
retries
|
|
167
|
+
)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
async orderPlaylistTracks(
|
|
171
|
+
playlistId: number,
|
|
172
|
+
trackIds: number[],
|
|
173
|
+
retries: number
|
|
174
|
+
) {
|
|
175
|
+
const nonce = signatureSchemas.getNonce()
|
|
176
|
+
const chainId = await this.getEthNetId()
|
|
177
|
+
const contractAddress = await this.getAddress()
|
|
178
|
+
const trackIdsHash = this.web3Manager
|
|
179
|
+
.getWeb3()
|
|
180
|
+
.utils.soliditySha3(
|
|
181
|
+
this.web3Manager.getWeb3().eth.abi.encodeParameter('uint[]', trackIds)
|
|
182
|
+
)
|
|
183
|
+
const signatureData =
|
|
184
|
+
signatureSchemas.generators.getOrderPlaylistTracksRequestData(
|
|
185
|
+
chainId,
|
|
186
|
+
contractAddress,
|
|
187
|
+
playlistId,
|
|
188
|
+
trackIdsHash,
|
|
189
|
+
nonce
|
|
190
|
+
)
|
|
191
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
192
|
+
|
|
193
|
+
const method = await this.getMethod(
|
|
194
|
+
'orderPlaylistTracks',
|
|
195
|
+
playlistId,
|
|
196
|
+
trackIds,
|
|
197
|
+
nonce,
|
|
198
|
+
sig
|
|
199
|
+
)
|
|
200
|
+
|
|
201
|
+
return await this.web3Manager.sendTransaction(
|
|
202
|
+
method, // contractMethod
|
|
203
|
+
this.contractRegistryKey,
|
|
204
|
+
contractAddress,
|
|
205
|
+
retries
|
|
206
|
+
)
|
|
207
|
+
}
|
|
208
|
+
|
|
209
|
+
async updatePlaylistPrivacy(
|
|
210
|
+
playlistId: number,
|
|
211
|
+
updatedPlaylistPrivacy: string
|
|
212
|
+
) {
|
|
213
|
+
const nonce = signatureSchemas.getNonce()
|
|
214
|
+
const chainId = await this.getEthNetId()
|
|
215
|
+
const contractAddress = await this.getAddress()
|
|
216
|
+
const signatureData =
|
|
217
|
+
signatureSchemas.generators.getUpdatePlaylistPrivacyRequestData(
|
|
218
|
+
chainId,
|
|
219
|
+
contractAddress,
|
|
220
|
+
playlistId,
|
|
221
|
+
updatedPlaylistPrivacy,
|
|
222
|
+
nonce
|
|
223
|
+
)
|
|
224
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
225
|
+
|
|
226
|
+
const method = await this.getMethod(
|
|
227
|
+
'updatePlaylistPrivacy',
|
|
228
|
+
playlistId,
|
|
229
|
+
updatedPlaylistPrivacy,
|
|
230
|
+
nonce,
|
|
231
|
+
sig
|
|
232
|
+
)
|
|
233
|
+
|
|
234
|
+
return await this.web3Manager.sendTransaction(
|
|
235
|
+
method,
|
|
236
|
+
this.contractRegistryKey,
|
|
237
|
+
contractAddress
|
|
238
|
+
)
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
async updatePlaylistName(playlistId: number, updatedPlaylistName: string) {
|
|
242
|
+
const nonce = signatureSchemas.getNonce()
|
|
243
|
+
const chainId = await this.getEthNetId()
|
|
244
|
+
const contractAddress = await this.getAddress()
|
|
245
|
+
const signatureData =
|
|
246
|
+
signatureSchemas.generators.getUpdatePlaylistNameRequestData(
|
|
247
|
+
chainId,
|
|
248
|
+
contractAddress,
|
|
249
|
+
playlistId,
|
|
250
|
+
updatedPlaylistName,
|
|
251
|
+
nonce
|
|
252
|
+
)
|
|
253
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
254
|
+
|
|
255
|
+
const method = await this.getMethod(
|
|
256
|
+
'updatePlaylistName',
|
|
257
|
+
playlistId,
|
|
258
|
+
updatedPlaylistName,
|
|
259
|
+
nonce,
|
|
260
|
+
sig
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
return await this.web3Manager.sendTransaction(
|
|
264
|
+
method,
|
|
265
|
+
this.contractRegistryKey,
|
|
266
|
+
contractAddress
|
|
267
|
+
)
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
async updatePlaylistCoverPhoto(
|
|
271
|
+
playlistId: number,
|
|
272
|
+
updatedPlaylistImageMultihashDigest: string
|
|
273
|
+
) {
|
|
274
|
+
const nonce = signatureSchemas.getNonce()
|
|
275
|
+
const chainId = await this.getEthNetId()
|
|
276
|
+
const contractAddress = await this.getAddress()
|
|
277
|
+
const signatureData =
|
|
278
|
+
signatureSchemas.generators.getUpdatePlaylistCoverPhotoRequestData(
|
|
279
|
+
chainId,
|
|
280
|
+
contractAddress,
|
|
281
|
+
playlistId,
|
|
282
|
+
updatedPlaylistImageMultihashDigest,
|
|
283
|
+
nonce
|
|
284
|
+
)
|
|
285
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
286
|
+
|
|
287
|
+
const method = await this.getMethod(
|
|
288
|
+
'updatePlaylistCoverPhoto',
|
|
289
|
+
playlistId,
|
|
290
|
+
updatedPlaylistImageMultihashDigest,
|
|
291
|
+
nonce,
|
|
292
|
+
sig
|
|
293
|
+
)
|
|
294
|
+
|
|
295
|
+
return await this.web3Manager.sendTransaction(
|
|
296
|
+
method,
|
|
297
|
+
this.contractRegistryKey,
|
|
298
|
+
contractAddress
|
|
299
|
+
)
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
async updatePlaylistDescription(
|
|
303
|
+
playlistId: number,
|
|
304
|
+
updatedPlaylistDescription: string
|
|
305
|
+
) {
|
|
306
|
+
const nonce = signatureSchemas.getNonce()
|
|
307
|
+
const chainId = await this.getEthNetId()
|
|
308
|
+
const contractAddress = await this.getAddress()
|
|
309
|
+
const signatureData =
|
|
310
|
+
signatureSchemas.generators.getUpdatePlaylistDescriptionRequestData(
|
|
311
|
+
chainId,
|
|
312
|
+
contractAddress,
|
|
313
|
+
playlistId,
|
|
314
|
+
updatedPlaylistDescription,
|
|
315
|
+
nonce
|
|
316
|
+
)
|
|
317
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
318
|
+
const method = await this.getMethod(
|
|
319
|
+
'updatePlaylistDescription',
|
|
320
|
+
playlistId,
|
|
321
|
+
updatedPlaylistDescription,
|
|
322
|
+
nonce,
|
|
323
|
+
sig
|
|
324
|
+
)
|
|
325
|
+
|
|
326
|
+
return await this.web3Manager.sendTransaction(
|
|
327
|
+
method,
|
|
328
|
+
this.contractRegistryKey,
|
|
329
|
+
contractAddress
|
|
330
|
+
)
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
async updatePlaylistUPC(playlistId: number, updatedPlaylistUPC: string) {
|
|
334
|
+
const nonce = signatureSchemas.getNonce()
|
|
335
|
+
const chainId = await this.getEthNetId()
|
|
336
|
+
const contractAddress = await this.getAddress()
|
|
337
|
+
const signatureData =
|
|
338
|
+
signatureSchemas.generators.getUpdatePlaylistUPCRequestData(
|
|
339
|
+
chainId,
|
|
340
|
+
contractAddress,
|
|
341
|
+
playlistId,
|
|
342
|
+
this.web3Manager.getWeb3().utils.utf8ToHex(updatedPlaylistUPC),
|
|
343
|
+
nonce
|
|
344
|
+
)
|
|
345
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
346
|
+
const method = await this.getMethod(
|
|
347
|
+
'updatePlaylistUPC',
|
|
348
|
+
playlistId,
|
|
349
|
+
this.web3Manager.getWeb3().utils.utf8ToHex(updatedPlaylistUPC),
|
|
350
|
+
nonce,
|
|
351
|
+
sig
|
|
352
|
+
)
|
|
353
|
+
|
|
354
|
+
return await this.web3Manager.sendTransaction(
|
|
355
|
+
method,
|
|
356
|
+
this.contractRegistryKey,
|
|
357
|
+
contractAddress
|
|
358
|
+
)
|
|
359
|
+
}
|
|
360
|
+
|
|
361
|
+
async isTrackInPlaylist(playlistId: number, trackId: number) {
|
|
362
|
+
const method = await this.getMethod(
|
|
363
|
+
'isTrackInPlaylist',
|
|
364
|
+
playlistId,
|
|
365
|
+
trackId
|
|
366
|
+
)
|
|
367
|
+
const result = await method.call()
|
|
368
|
+
return result
|
|
369
|
+
}
|
|
370
|
+
}
|