@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,105 @@
|
|
|
1
|
+
import { validate } from 'jsonschema'
|
|
2
|
+
|
|
3
|
+
import TrackSchema from './schemas/trackSchema.json'
|
|
4
|
+
import UserSchema from './schemas/userSchema.json'
|
|
5
|
+
|
|
6
|
+
export const trackSchemaType = 'TrackSchema'
|
|
7
|
+
export const userSchemaType = 'UserSchema'
|
|
8
|
+
|
|
9
|
+
type SchemaConfig = {
|
|
10
|
+
schema: {
|
|
11
|
+
definitions: Record<
|
|
12
|
+
string,
|
|
13
|
+
| { required: string[]; properties: Record<string, { default: unknown }> }
|
|
14
|
+
| {}
|
|
15
|
+
>
|
|
16
|
+
}
|
|
17
|
+
baseDefinition: string
|
|
18
|
+
validate?: (obj: Record<string, unknown>) => void
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
type SchemaType = typeof trackSchemaType | typeof userSchemaType
|
|
22
|
+
|
|
23
|
+
export type Schemas = {
|
|
24
|
+
TrackSchema: SchemaConfig
|
|
25
|
+
UserSchema: SchemaConfig
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export class SchemaValidator {
|
|
29
|
+
schemas: Schemas | undefined
|
|
30
|
+
|
|
31
|
+
init() {
|
|
32
|
+
/**
|
|
33
|
+
* Fully formed schemas object looks like the below
|
|
34
|
+
* {
|
|
35
|
+
* 'TrackSchema': {
|
|
36
|
+
* schema: <schemaJSON>,
|
|
37
|
+
* baseDefinition: 'String', //name of base definition property in schema
|
|
38
|
+
* validate: function // returns error if not validated correctly, otherwise null
|
|
39
|
+
* },
|
|
40
|
+
* 'UserSchema': ...
|
|
41
|
+
* }
|
|
42
|
+
*
|
|
43
|
+
* validate works like this `this.UserSchema.validate(userObj)`
|
|
44
|
+
*/
|
|
45
|
+
this.schemas = {
|
|
46
|
+
[trackSchemaType]: {
|
|
47
|
+
schema: TrackSchema,
|
|
48
|
+
baseDefinition: 'Track'
|
|
49
|
+
},
|
|
50
|
+
[userSchemaType]: {
|
|
51
|
+
schema: UserSchema,
|
|
52
|
+
baseDefinition: 'User'
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
for (const schemaType in this.schemas) {
|
|
57
|
+
const typedSchemaType = schemaType as SchemaType
|
|
58
|
+
this.schemas[typedSchemaType].validate = (
|
|
59
|
+
obj: Record<string, unknown>
|
|
60
|
+
) => {
|
|
61
|
+
this.addMissingFields(obj, typedSchemaType)
|
|
62
|
+
|
|
63
|
+
const result = validate(obj, this.schemas?.[typedSchemaType].schema)
|
|
64
|
+
if (result.errors.length > 0)
|
|
65
|
+
throw new Error(
|
|
66
|
+
`${schemaType} validation failed with errors: ${JSON.stringify(
|
|
67
|
+
result.errors
|
|
68
|
+
)}`
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getSchemas() {
|
|
75
|
+
return this.schemas
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
addMissingFields(obj: Record<string, unknown>, schemaType: SchemaType) {
|
|
79
|
+
if (!this.schemas) {
|
|
80
|
+
return
|
|
81
|
+
}
|
|
82
|
+
// schema is the entire imporoted schema, including all the definitions for JSON fields
|
|
83
|
+
const { schema, baseDefinition } = this.schemas[schemaType]
|
|
84
|
+
// schemaTypeObj is only the subset of the schema with only one definition for main schema type
|
|
85
|
+
const schemaTypeObj = schema.definitions[baseDefinition]
|
|
86
|
+
// iterate through every required property, ensuring it exists or setting a default value
|
|
87
|
+
if (schemaTypeObj && 'required' in schemaTypeObj) {
|
|
88
|
+
schemaTypeObj.required.forEach((req) => {
|
|
89
|
+
if (!Object.prototype.hasOwnProperty.call(obj, req)) {
|
|
90
|
+
if (
|
|
91
|
+
Object.prototype.hasOwnProperty.call(
|
|
92
|
+
schemaTypeObj.properties[req],
|
|
93
|
+
'default'
|
|
94
|
+
)
|
|
95
|
+
) {
|
|
96
|
+
obj[req] = schemaTypeObj.properties[req]?.default
|
|
97
|
+
} else
|
|
98
|
+
throw new Error(
|
|
99
|
+
`Could not set default value for missing field ${req}`
|
|
100
|
+
)
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './SchemaValidator'
|
|
@@ -0,0 +1,267 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$ref": "#/definitions/Track",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"Track": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": true,
|
|
8
|
+
"$comment": "Additional properties enabled because the data return by discovery providers may contain other properties like blockhash, is_current, which are not strictly part of the metadata.",
|
|
9
|
+
"properties": {
|
|
10
|
+
"title": {
|
|
11
|
+
"type": "string",
|
|
12
|
+
"default": null
|
|
13
|
+
},
|
|
14
|
+
"length": {
|
|
15
|
+
"type": ["integer", "null"],
|
|
16
|
+
"default": null
|
|
17
|
+
},
|
|
18
|
+
"cover_art": {
|
|
19
|
+
"type": ["string", "null"],
|
|
20
|
+
"default": null,
|
|
21
|
+
"$ref": "#/definitions/CID"
|
|
22
|
+
},
|
|
23
|
+
"cover_art_sizes": {
|
|
24
|
+
"$comment": "type can be null if attached as a stem",
|
|
25
|
+
"type": ["string", "null"],
|
|
26
|
+
"default": null,
|
|
27
|
+
"$ref": "#/definitions/CID"
|
|
28
|
+
},
|
|
29
|
+
"tags": {
|
|
30
|
+
"type": ["string", "null"],
|
|
31
|
+
"default": null
|
|
32
|
+
},
|
|
33
|
+
"genre": {
|
|
34
|
+
"$comment": "genre can be null if attached as a stem",
|
|
35
|
+
"type": ["string", "null"],
|
|
36
|
+
"default": null
|
|
37
|
+
},
|
|
38
|
+
"mood": {
|
|
39
|
+
"type": ["string", "null"],
|
|
40
|
+
"default": null
|
|
41
|
+
},
|
|
42
|
+
"credits_splits": {
|
|
43
|
+
"type": ["string", "null"],
|
|
44
|
+
"default": null
|
|
45
|
+
},
|
|
46
|
+
"create_date": {
|
|
47
|
+
"type": ["string", "null"],
|
|
48
|
+
"default": null
|
|
49
|
+
},
|
|
50
|
+
"release_date": {
|
|
51
|
+
"type": ["string", "null"],
|
|
52
|
+
"default": null
|
|
53
|
+
},
|
|
54
|
+
"file_type": {
|
|
55
|
+
"type": ["string", "null"],
|
|
56
|
+
"default": null
|
|
57
|
+
},
|
|
58
|
+
"description": {
|
|
59
|
+
"type": ["string", "null"],
|
|
60
|
+
"default": null
|
|
61
|
+
},
|
|
62
|
+
"license": {
|
|
63
|
+
"type": ["string", "null"],
|
|
64
|
+
"default": null
|
|
65
|
+
},
|
|
66
|
+
"isrc": {
|
|
67
|
+
"type": ["string", "null"],
|
|
68
|
+
"default": null
|
|
69
|
+
},
|
|
70
|
+
"iswc": {
|
|
71
|
+
"type": ["string", "null"],
|
|
72
|
+
"default": null
|
|
73
|
+
},
|
|
74
|
+
"track_segments": {
|
|
75
|
+
"type": "array",
|
|
76
|
+
"minItems": 1,
|
|
77
|
+
"items": {
|
|
78
|
+
"$ref": "#/definitions/TrackSegment"
|
|
79
|
+
},
|
|
80
|
+
"default": [],
|
|
81
|
+
"$comment": "default set to empty array to unblock stalling indexing. if set to null, discprov db will reject because of not-NULL constraint"
|
|
82
|
+
},
|
|
83
|
+
"is_unlisted": {
|
|
84
|
+
"type": "boolean",
|
|
85
|
+
"default": false
|
|
86
|
+
},
|
|
87
|
+
"field_visibility": {
|
|
88
|
+
"type": "object",
|
|
89
|
+
"$ref": "#/definitions/FieldVisibility",
|
|
90
|
+
"default": {
|
|
91
|
+
"mood": true,
|
|
92
|
+
"tags": true,
|
|
93
|
+
"genre": true,
|
|
94
|
+
"share": true,
|
|
95
|
+
"play_count": true,
|
|
96
|
+
"remixes": true
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
"download": {
|
|
100
|
+
"type": ["object", "null"],
|
|
101
|
+
"$ref": "#/definitions/Download",
|
|
102
|
+
"default": {
|
|
103
|
+
"cid": null,
|
|
104
|
+
"is_downloadable": false,
|
|
105
|
+
"requires_follow": false
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
"stem_of": {
|
|
109
|
+
"type": ["object", "null"],
|
|
110
|
+
"$ref": "#/definitions/StemOf",
|
|
111
|
+
"default": null
|
|
112
|
+
},
|
|
113
|
+
"remix_of": {
|
|
114
|
+
"type": ["object", "null"],
|
|
115
|
+
"$ref": "#/definitions/RemixOf",
|
|
116
|
+
"default": null
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"required": [
|
|
120
|
+
"cover_art",
|
|
121
|
+
"cover_art_sizes",
|
|
122
|
+
"create_date",
|
|
123
|
+
"credits_splits",
|
|
124
|
+
"description",
|
|
125
|
+
"download",
|
|
126
|
+
"field_visibility",
|
|
127
|
+
"file_type",
|
|
128
|
+
"genre",
|
|
129
|
+
"is_unlisted",
|
|
130
|
+
"isrc",
|
|
131
|
+
"iswc",
|
|
132
|
+
"length",
|
|
133
|
+
"license",
|
|
134
|
+
"mood",
|
|
135
|
+
"release_date",
|
|
136
|
+
"remix_of",
|
|
137
|
+
"stem_of",
|
|
138
|
+
"tags",
|
|
139
|
+
"title",
|
|
140
|
+
"track_segments"
|
|
141
|
+
],
|
|
142
|
+
"title": "Track"
|
|
143
|
+
},
|
|
144
|
+
"RemixOf": {
|
|
145
|
+
"type": ["object", "null"],
|
|
146
|
+
"additionalProperties": false,
|
|
147
|
+
"properties": {
|
|
148
|
+
"tracks": {
|
|
149
|
+
"type": "array",
|
|
150
|
+
"minItems": 1,
|
|
151
|
+
"items": {
|
|
152
|
+
"$ref": "#/definitions/TrackElement"
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
},
|
|
156
|
+
"required": [
|
|
157
|
+
"tracks"
|
|
158
|
+
],
|
|
159
|
+
"title": "RemixOf"
|
|
160
|
+
},
|
|
161
|
+
"TrackElement": {
|
|
162
|
+
"type": "object",
|
|
163
|
+
"additionalProperties": false,
|
|
164
|
+
"properties": {
|
|
165
|
+
"parent_track_id": {
|
|
166
|
+
"type": "integer"
|
|
167
|
+
}
|
|
168
|
+
},
|
|
169
|
+
"required": [
|
|
170
|
+
"parent_track_id"
|
|
171
|
+
],
|
|
172
|
+
"title": "TrackElement"
|
|
173
|
+
},
|
|
174
|
+
"Download": {
|
|
175
|
+
"type": ["object", "null"],
|
|
176
|
+
"additionalProperties": false,
|
|
177
|
+
"properties": {
|
|
178
|
+
"cid": {
|
|
179
|
+
"type": ["string", "null"],
|
|
180
|
+
"$ref": "#/definitions/CID"
|
|
181
|
+
},
|
|
182
|
+
"is_downloadable": {
|
|
183
|
+
"type": "boolean"
|
|
184
|
+
},
|
|
185
|
+
"requires_follow": {
|
|
186
|
+
"type": "boolean"
|
|
187
|
+
}
|
|
188
|
+
},
|
|
189
|
+
"required": [
|
|
190
|
+
"cid",
|
|
191
|
+
"is_downloadable",
|
|
192
|
+
"requires_follow"
|
|
193
|
+
],
|
|
194
|
+
"title": "Download"
|
|
195
|
+
},
|
|
196
|
+
"FieldVisibility": {
|
|
197
|
+
"type": "object",
|
|
198
|
+
"additionalProperties": false,
|
|
199
|
+
"properties": {
|
|
200
|
+
"mood": {
|
|
201
|
+
"type": "boolean"
|
|
202
|
+
},
|
|
203
|
+
"tags": {
|
|
204
|
+
"type": "boolean"
|
|
205
|
+
},
|
|
206
|
+
"genre": {
|
|
207
|
+
"type": "boolean"
|
|
208
|
+
},
|
|
209
|
+
"share": {
|
|
210
|
+
"type": "boolean"
|
|
211
|
+
},
|
|
212
|
+
"play_count": {
|
|
213
|
+
"type": "boolean"
|
|
214
|
+
},
|
|
215
|
+
"remixes": {
|
|
216
|
+
"type": "boolean"
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
"required": [
|
|
220
|
+
],
|
|
221
|
+
"$comment": "No required fields for FieldVisibility because it causes backwards compatibility issues. If we added a new property, we don't want old records to fail if all properties are not specified(and overwrite the values with the defaults), but we also don't want to set new properties especially on the discovery provider because then we'd be writing properties not present in the metadata written on chain.",
|
|
222
|
+
"title": "FieldVisibility"
|
|
223
|
+
},
|
|
224
|
+
"StemOf": {
|
|
225
|
+
"type": ["object", "null"],
|
|
226
|
+
"additionalProperties": false,
|
|
227
|
+
"properties": {
|
|
228
|
+
"category": {
|
|
229
|
+
"type": "string"
|
|
230
|
+
},
|
|
231
|
+
"parent_track_id": {
|
|
232
|
+
"type": "integer"
|
|
233
|
+
}
|
|
234
|
+
},
|
|
235
|
+
"required": [
|
|
236
|
+
"category",
|
|
237
|
+
"parent_track_id"
|
|
238
|
+
],
|
|
239
|
+
"title": "StemOf"
|
|
240
|
+
},
|
|
241
|
+
"TrackSegment": {
|
|
242
|
+
"type": "object",
|
|
243
|
+
"additionalProperties": false,
|
|
244
|
+
"properties": {
|
|
245
|
+
"duration": {
|
|
246
|
+
"type": "number"
|
|
247
|
+
},
|
|
248
|
+
"multihash": {
|
|
249
|
+
"type": "string",
|
|
250
|
+
"$ref": "#/definitions/CID"
|
|
251
|
+
}
|
|
252
|
+
},
|
|
253
|
+
"required": [
|
|
254
|
+
"duration",
|
|
255
|
+
"multihash"
|
|
256
|
+
],
|
|
257
|
+
"title": "TrackSegment"
|
|
258
|
+
},
|
|
259
|
+
"CID": {
|
|
260
|
+
"type": ["string", "null"],
|
|
261
|
+
"minLength": 46,
|
|
262
|
+
"maxLength": 46,
|
|
263
|
+
"pattern": "^Qm[a-zA-Z0-9]{44}$",
|
|
264
|
+
"title": "CID"
|
|
265
|
+
}
|
|
266
|
+
}
|
|
267
|
+
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$ref": "#/definitions/User",
|
|
4
|
+
"definitions": {
|
|
5
|
+
"User": {
|
|
6
|
+
"type": "object",
|
|
7
|
+
"additionalProperties": true,
|
|
8
|
+
"properties": {
|
|
9
|
+
"name": {
|
|
10
|
+
"type": ["string", "null"],
|
|
11
|
+
"default": null
|
|
12
|
+
},
|
|
13
|
+
"profile_picture": {
|
|
14
|
+
"type": ["string", "null"],
|
|
15
|
+
"default": null,
|
|
16
|
+
"$ref": "#/definitions/CID"
|
|
17
|
+
},
|
|
18
|
+
"profile_picture_sizes": {
|
|
19
|
+
"type": ["string", "null"],
|
|
20
|
+
"default": null,
|
|
21
|
+
"$ref": "#/definitions/CID"
|
|
22
|
+
},
|
|
23
|
+
"cover_photo": {
|
|
24
|
+
"type": ["string", "null"],
|
|
25
|
+
"default": null,
|
|
26
|
+
"$ref": "#/definitions/CID"
|
|
27
|
+
},
|
|
28
|
+
"cover_photo_sizes": {
|
|
29
|
+
"type": ["string", "null"],
|
|
30
|
+
"default": null,
|
|
31
|
+
"$ref": "#/definitions/CID"
|
|
32
|
+
},
|
|
33
|
+
"bio": {
|
|
34
|
+
"type": ["string", "null"],
|
|
35
|
+
"default": null
|
|
36
|
+
},
|
|
37
|
+
"location": {
|
|
38
|
+
"type": ["string", "null"],
|
|
39
|
+
"default": null
|
|
40
|
+
},
|
|
41
|
+
"associated_wallets": {
|
|
42
|
+
"$ref": "#/definitions/AssociatedWallets"
|
|
43
|
+
},
|
|
44
|
+
"associated_sol_wallets": {
|
|
45
|
+
"$ref": "#/definitions/AssociatedSOLWallets"
|
|
46
|
+
},
|
|
47
|
+
"collectibles": {
|
|
48
|
+
"$ref": "#/definitions/Collectibles"
|
|
49
|
+
},
|
|
50
|
+
"playlist_library": {
|
|
51
|
+
"$ref": "#/definitions/PlaylistLibrary"
|
|
52
|
+
},
|
|
53
|
+
"events": {
|
|
54
|
+
"$ref": "#/definitions/Events"
|
|
55
|
+
},
|
|
56
|
+
"is_deactivated": {
|
|
57
|
+
"type": "boolean",
|
|
58
|
+
"default": false
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
"required": [
|
|
62
|
+
"bio",
|
|
63
|
+
"cover_photo",
|
|
64
|
+
"cover_photo_sizes",
|
|
65
|
+
"location",
|
|
66
|
+
"name",
|
|
67
|
+
"profile_picture",
|
|
68
|
+
"profile_picture_sizes"
|
|
69
|
+
],
|
|
70
|
+
"title": "User"
|
|
71
|
+
},
|
|
72
|
+
"CID": {
|
|
73
|
+
"type": ["string", "null"],
|
|
74
|
+
"minLength": 46,
|
|
75
|
+
"maxLength": 46,
|
|
76
|
+
"pattern": "^Qm[a-zA-Z0-9]{44}$",
|
|
77
|
+
"title": "CID"
|
|
78
|
+
},
|
|
79
|
+
"AssociatedWallets": {
|
|
80
|
+
"type": ["object", "null"],
|
|
81
|
+
"default": null,
|
|
82
|
+
"patternProperties": {
|
|
83
|
+
"^0x[a-fA-F0-9]{40}$": { "$ref": "#/definitions/WalletMetadata" }
|
|
84
|
+
},
|
|
85
|
+
"additionalProperties": false,
|
|
86
|
+
"properties": {},
|
|
87
|
+
"required": [],
|
|
88
|
+
"$comment": "",
|
|
89
|
+
"title": "AssociatedWallets"
|
|
90
|
+
},
|
|
91
|
+
"AssociatedSOLWallets": {
|
|
92
|
+
"type": ["object", "null"],
|
|
93
|
+
"default": null,
|
|
94
|
+
"patternProperties": {
|
|
95
|
+
"^[a-zA-Z0-9]{44}$": { "$ref": "#/definitions/WalletMetadata" }
|
|
96
|
+
},
|
|
97
|
+
"additionalProperties": false,
|
|
98
|
+
"properties": {},
|
|
99
|
+
"required": [],
|
|
100
|
+
"$comment": "",
|
|
101
|
+
"title": "AssociatedSOLWallets"
|
|
102
|
+
},
|
|
103
|
+
"WalletMetadata": {
|
|
104
|
+
"type": ["object"],
|
|
105
|
+
"additionalProperties": true,
|
|
106
|
+
"properties": {
|
|
107
|
+
"signature": {
|
|
108
|
+
"type": "string"
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"required": ["signature"],
|
|
112
|
+
"$comment": "",
|
|
113
|
+
"title": "WalletMetadata"
|
|
114
|
+
},
|
|
115
|
+
"Collectible": {
|
|
116
|
+
"type": "object",
|
|
117
|
+
"additionalProperties": false
|
|
118
|
+
},
|
|
119
|
+
"Collectibles": {
|
|
120
|
+
"type": ["object", "null"],
|
|
121
|
+
"default": null,
|
|
122
|
+
"additionalProperties": {
|
|
123
|
+
"$ref": "#/definitions/Collectible"
|
|
124
|
+
},
|
|
125
|
+
"properties": {
|
|
126
|
+
"order": {
|
|
127
|
+
"type": "array",
|
|
128
|
+
"items": {
|
|
129
|
+
"type": "string"
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
"required": [
|
|
134
|
+
"order"
|
|
135
|
+
]
|
|
136
|
+
},
|
|
137
|
+
"PlaylistIdentifier": {
|
|
138
|
+
"properties": {
|
|
139
|
+
"type": {
|
|
140
|
+
"type": "string",
|
|
141
|
+
"const": "playlist"
|
|
142
|
+
},
|
|
143
|
+
"playlist_id": {
|
|
144
|
+
"type": "integer"
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
},
|
|
149
|
+
"ExplorePlaylistIdentifier": {
|
|
150
|
+
"properties": {
|
|
151
|
+
"type": {
|
|
152
|
+
"type": "string",
|
|
153
|
+
"const": "explore_playlist"
|
|
154
|
+
},
|
|
155
|
+
"playlist_id": {
|
|
156
|
+
"type": "string",
|
|
157
|
+
"pattern": "^[a-zA-Z \/-?]+$"
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
},
|
|
161
|
+
"PlaylistLibraryIdentifier": {
|
|
162
|
+
"oneOf": [
|
|
163
|
+
{
|
|
164
|
+
"$ref": "#/definitions/PlaylistIdentifier"
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
"$ref": "#/definitions/ExplorePlaylistIdentifier"
|
|
168
|
+
}
|
|
169
|
+
]
|
|
170
|
+
},
|
|
171
|
+
"PlaylistLibraryFolder": {
|
|
172
|
+
"properties": {
|
|
173
|
+
"type": {
|
|
174
|
+
"type": "string",
|
|
175
|
+
"const": "folder"
|
|
176
|
+
},
|
|
177
|
+
"id": {
|
|
178
|
+
"type": "string"
|
|
179
|
+
},
|
|
180
|
+
"name": {
|
|
181
|
+
"type": "string"
|
|
182
|
+
},
|
|
183
|
+
"contents": {
|
|
184
|
+
"type": "array",
|
|
185
|
+
"items": {
|
|
186
|
+
"oneOf": [
|
|
187
|
+
{
|
|
188
|
+
"$ref": "#/definitions/PlaylistLibraryFolder"
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
"$ref": "#/definitions/PlaylistLibraryIdentifier"
|
|
192
|
+
}
|
|
193
|
+
]
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
"PlaylistLibrary": {
|
|
199
|
+
"type": ["object", "null"],
|
|
200
|
+
"default": null,
|
|
201
|
+
"properties": {
|
|
202
|
+
"contents": {
|
|
203
|
+
"type": "array",
|
|
204
|
+
"items": {
|
|
205
|
+
"oneOf": [
|
|
206
|
+
{
|
|
207
|
+
"$ref": "#/definitions/PlaylistLibraryFolder"
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
"$ref": "#/definitions/PlaylistLibraryIdentifier"
|
|
211
|
+
}
|
|
212
|
+
]
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
"Events": {
|
|
218
|
+
"type": ["object", "null"],
|
|
219
|
+
"default": null,
|
|
220
|
+
"properties": {
|
|
221
|
+
"referrer": {
|
|
222
|
+
"type": "integer"
|
|
223
|
+
},
|
|
224
|
+
"is_mobile_user": {
|
|
225
|
+
"type": "boolean"
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ProgramError } from '@project-serum/anchor'
|
|
2
|
+
import * as AudiusData from '@audius/anchor-audius-data'
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* All errors returned by Anchor Audius Data
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
export const CustomAudiusDataErrors = new Map(
|
|
9
|
+
AudiusData.idl.errors.map(({ code, msg }) => [code, msg])
|
|
10
|
+
)
|
|
11
|
+
export const audiusDataErrorMapping = {
|
|
12
|
+
fromErrorCode: (errorCode: number) => {
|
|
13
|
+
const programError = ProgramError.parse(
|
|
14
|
+
`"Custom":${errorCode.toString()}}`,
|
|
15
|
+
CustomAudiusDataErrors
|
|
16
|
+
)
|
|
17
|
+
if (programError === null) return 'UNKNOWN'
|
|
18
|
+
return programError.msg
|
|
19
|
+
}
|
|
20
|
+
}
|