@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,351 @@
|
|
|
1
|
+
import { ContractClient } from '../contracts/ContractClient'
|
|
2
|
+
import * as signatureSchemas from '../../../data-contracts/signatureSchemas'
|
|
3
|
+
import type { UserUpdateRequestFn } from '../../../data-contracts/signatureSchemas'
|
|
4
|
+
import { Utils } from '../../utils'
|
|
5
|
+
import sigUtil from 'eth-sig-util'
|
|
6
|
+
import { Buffer as SafeBuffer } from 'safe-buffer'
|
|
7
|
+
import type { Web3Manager } from '../web3Manager'
|
|
8
|
+
|
|
9
|
+
export class UserFactoryClient extends ContractClient {
|
|
10
|
+
override web3Manager!: Web3Manager
|
|
11
|
+
/* ------- GETTERS ------- */
|
|
12
|
+
|
|
13
|
+
async getUser(userId: number) {
|
|
14
|
+
const method = await this.getMethod('getUser', userId)
|
|
15
|
+
return method.call()
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** valid = does not exist and meets handle requirements (defined on chain) */
|
|
19
|
+
async handleIsValid(handle: string) {
|
|
20
|
+
const method = await this.getMethod(
|
|
21
|
+
'handleIsValid',
|
|
22
|
+
Utils.utf8ToHex(handle)
|
|
23
|
+
)
|
|
24
|
+
return method.call()
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/* ------- SETTERS ------- */
|
|
28
|
+
|
|
29
|
+
async addUser(handle: string) {
|
|
30
|
+
Utils.checkStrLen(handle, 16)
|
|
31
|
+
|
|
32
|
+
const nonce = signatureSchemas.getNonce()
|
|
33
|
+
const chainId = await this.getEthNetId()
|
|
34
|
+
const contractAddress = await this.getAddress()
|
|
35
|
+
const signatureData = signatureSchemas.generators.getAddUserRequestData(
|
|
36
|
+
chainId,
|
|
37
|
+
contractAddress,
|
|
38
|
+
handle,
|
|
39
|
+
nonce
|
|
40
|
+
)
|
|
41
|
+
|
|
42
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
43
|
+
const method = await this.getMethod(
|
|
44
|
+
'addUser',
|
|
45
|
+
this.web3Manager.getWalletAddress(),
|
|
46
|
+
Utils.utf8ToHex(handle),
|
|
47
|
+
nonce,
|
|
48
|
+
sig
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
52
|
+
method,
|
|
53
|
+
this.contractRegistryKey,
|
|
54
|
+
contractAddress
|
|
55
|
+
)
|
|
56
|
+
return {
|
|
57
|
+
txReceipt: tx,
|
|
58
|
+
userId: parseInt(tx.events?.['AddUser']?.returnValues._userId, 10)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async updateMultihash(userId: number, multihashDigest: string) {
|
|
63
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
64
|
+
signatureSchemas.generators.getUpdateUserMultihashRequestData,
|
|
65
|
+
userId,
|
|
66
|
+
multihashDigest
|
|
67
|
+
)
|
|
68
|
+
const method = await this.getMethod(
|
|
69
|
+
'updateMultihash',
|
|
70
|
+
userId,
|
|
71
|
+
multihashDigest,
|
|
72
|
+
nonce,
|
|
73
|
+
sig
|
|
74
|
+
)
|
|
75
|
+
const contractAddress = await this.getAddress()
|
|
76
|
+
|
|
77
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
78
|
+
method,
|
|
79
|
+
this.contractRegistryKey,
|
|
80
|
+
contractAddress
|
|
81
|
+
)
|
|
82
|
+
return {
|
|
83
|
+
txReceipt: tx,
|
|
84
|
+
multihashDigest:
|
|
85
|
+
tx.events?.['UpdateMultihash']?.returnValues._multihashDigest
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async updateName(userId: number, name: string) {
|
|
90
|
+
Utils.checkStrLen(name, 32)
|
|
91
|
+
|
|
92
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
93
|
+
signatureSchemas.generators.getUpdateUserNameRequestData,
|
|
94
|
+
userId,
|
|
95
|
+
name
|
|
96
|
+
)
|
|
97
|
+
const method = await this.getMethod(
|
|
98
|
+
'updateName',
|
|
99
|
+
userId,
|
|
100
|
+
Utils.utf8ToHex(name),
|
|
101
|
+
nonce,
|
|
102
|
+
sig
|
|
103
|
+
)
|
|
104
|
+
const contractAddress = await this.getAddress()
|
|
105
|
+
|
|
106
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
107
|
+
method,
|
|
108
|
+
this.contractRegistryKey,
|
|
109
|
+
contractAddress
|
|
110
|
+
)
|
|
111
|
+
return {
|
|
112
|
+
txReceipt: tx,
|
|
113
|
+
name: Utils.hexToUtf8(tx.events?.['UpdateName']?.returnValues._name)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async updateLocation(userId: number, location: string) {
|
|
118
|
+
const maxLength = 32
|
|
119
|
+
Utils.checkStrLen(location, maxLength, /* minLen */ 0)
|
|
120
|
+
|
|
121
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
122
|
+
signatureSchemas.generators.getUpdateUserLocationRequestData,
|
|
123
|
+
userId,
|
|
124
|
+
location
|
|
125
|
+
)
|
|
126
|
+
const method = await this.getMethod(
|
|
127
|
+
'updateLocation',
|
|
128
|
+
userId,
|
|
129
|
+
Utils.padRight(Utils.utf8ToHex(location), maxLength * 2),
|
|
130
|
+
nonce,
|
|
131
|
+
sig
|
|
132
|
+
)
|
|
133
|
+
const contractAddress = await this.getAddress()
|
|
134
|
+
|
|
135
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
136
|
+
method,
|
|
137
|
+
this.contractRegistryKey,
|
|
138
|
+
contractAddress
|
|
139
|
+
)
|
|
140
|
+
return {
|
|
141
|
+
txReceipt: tx,
|
|
142
|
+
location: Utils.hexToUtf8(
|
|
143
|
+
tx.events?.['UpdateLocation']?.returnValues._location
|
|
144
|
+
)
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
async updateBio(userId: number, bio: string) {
|
|
149
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
150
|
+
signatureSchemas.generators.getUpdateUserBioRequestData,
|
|
151
|
+
userId,
|
|
152
|
+
bio
|
|
153
|
+
)
|
|
154
|
+
const method = await this.getMethod('updateBio', userId, bio, nonce, sig)
|
|
155
|
+
const contractAddress = await this.getAddress()
|
|
156
|
+
|
|
157
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
158
|
+
method,
|
|
159
|
+
this.contractRegistryKey,
|
|
160
|
+
contractAddress
|
|
161
|
+
)
|
|
162
|
+
return {
|
|
163
|
+
txReceipt: tx,
|
|
164
|
+
bio: tx.events?.['UpdateBio']?.returnValues._bio
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
async updateProfilePhoto(
|
|
169
|
+
userId: number,
|
|
170
|
+
profilePhotoMultihashDigest: string
|
|
171
|
+
) {
|
|
172
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
173
|
+
signatureSchemas.generators.getUpdateUserProfilePhotoRequestData,
|
|
174
|
+
userId,
|
|
175
|
+
profilePhotoMultihashDigest
|
|
176
|
+
)
|
|
177
|
+
const method = await this.getMethod(
|
|
178
|
+
'updateProfilePhoto',
|
|
179
|
+
userId,
|
|
180
|
+
profilePhotoMultihashDigest,
|
|
181
|
+
nonce,
|
|
182
|
+
sig
|
|
183
|
+
)
|
|
184
|
+
const contractAddress = await this.getAddress()
|
|
185
|
+
|
|
186
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
187
|
+
method,
|
|
188
|
+
this.contractRegistryKey,
|
|
189
|
+
contractAddress
|
|
190
|
+
)
|
|
191
|
+
return {
|
|
192
|
+
txReceipt: tx,
|
|
193
|
+
profilePhotoMultihashDigest:
|
|
194
|
+
tx.events?.['UpdateProfilePhoto']?.returnValues._profilePhotoDigest
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
async updateCoverPhoto(userId: number, coverPhotoMultihashDigest: string) {
|
|
199
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
200
|
+
signatureSchemas.generators.getUpdateUserCoverPhotoRequestData,
|
|
201
|
+
userId,
|
|
202
|
+
coverPhotoMultihashDigest
|
|
203
|
+
)
|
|
204
|
+
const method = await this.getMethod(
|
|
205
|
+
'updateCoverPhoto',
|
|
206
|
+
userId,
|
|
207
|
+
coverPhotoMultihashDigest,
|
|
208
|
+
nonce,
|
|
209
|
+
sig
|
|
210
|
+
)
|
|
211
|
+
const contractAddress = await this.getAddress()
|
|
212
|
+
|
|
213
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
214
|
+
method,
|
|
215
|
+
this.contractRegistryKey,
|
|
216
|
+
contractAddress
|
|
217
|
+
)
|
|
218
|
+
return {
|
|
219
|
+
txReceipt: tx,
|
|
220
|
+
coverPhotoMultihashDigest:
|
|
221
|
+
tx.events?.['UpdateCoverPhoto']?.returnValues._coverPhotoDigest
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
async updateIsCreator(userId: number, isCreator: boolean) {
|
|
226
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
227
|
+
signatureSchemas.generators.getUpdateUserCreatorRequestData,
|
|
228
|
+
userId,
|
|
229
|
+
isCreator
|
|
230
|
+
)
|
|
231
|
+
const method = await this.getMethod(
|
|
232
|
+
'updateIsCreator',
|
|
233
|
+
userId,
|
|
234
|
+
isCreator,
|
|
235
|
+
nonce,
|
|
236
|
+
sig
|
|
237
|
+
)
|
|
238
|
+
const contractAddress = await this.getAddress()
|
|
239
|
+
|
|
240
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
241
|
+
method,
|
|
242
|
+
this.contractRegistryKey,
|
|
243
|
+
contractAddress
|
|
244
|
+
)
|
|
245
|
+
return {
|
|
246
|
+
txReceipt: tx,
|
|
247
|
+
isCreator: tx.events?.['UpdateIsCreator']?.returnValues._isCreator
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* This function is called from the identity service, not from the client. As a result,
|
|
253
|
+
* the return properties are different. The web3 sendTransaction() function isn't called, rather
|
|
254
|
+
* the encodedABI and contract address are returned, and the identity service can relay it
|
|
255
|
+
* to the chain on behalf of the user
|
|
256
|
+
* @param userId blockchain userId
|
|
257
|
+
* @param isVerified
|
|
258
|
+
* @param privateKey 64 character hex string
|
|
259
|
+
*/
|
|
260
|
+
async updateIsVerified(
|
|
261
|
+
userId: number,
|
|
262
|
+
isVerified: boolean,
|
|
263
|
+
privateKey: string
|
|
264
|
+
) {
|
|
265
|
+
const contractAddress = await this.getAddress()
|
|
266
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
267
|
+
signatureSchemas.generators.getUpdateUserVerifiedRequestData,
|
|
268
|
+
userId,
|
|
269
|
+
isVerified,
|
|
270
|
+
privateKey
|
|
271
|
+
)
|
|
272
|
+
const method = await this.getMethod(
|
|
273
|
+
'updateIsVerified',
|
|
274
|
+
userId,
|
|
275
|
+
isVerified,
|
|
276
|
+
nonce,
|
|
277
|
+
sig
|
|
278
|
+
)
|
|
279
|
+
|
|
280
|
+
return [method.encodeABI(), contractAddress]
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
async updateCreatorNodeEndpoint(userId: number, creatorNodeEndpoint: string) {
|
|
284
|
+
const [nonce, sig] = await this.getUpdateNonceAndSig(
|
|
285
|
+
signatureSchemas.generators.getUpdateUserCreatorNodeRequestData,
|
|
286
|
+
userId,
|
|
287
|
+
creatorNodeEndpoint
|
|
288
|
+
)
|
|
289
|
+
const method = await this.getMethod(
|
|
290
|
+
'updateCreatorNodeEndpoint',
|
|
291
|
+
userId,
|
|
292
|
+
creatorNodeEndpoint,
|
|
293
|
+
nonce,
|
|
294
|
+
sig
|
|
295
|
+
)
|
|
296
|
+
const contractAddress = await this.getAddress()
|
|
297
|
+
|
|
298
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
299
|
+
method,
|
|
300
|
+
this.contractRegistryKey,
|
|
301
|
+
contractAddress
|
|
302
|
+
)
|
|
303
|
+
return {
|
|
304
|
+
txReceipt: tx,
|
|
305
|
+
creatorNodeEndpoint:
|
|
306
|
+
tx.events?.['UpdateCreatorNodeEndpoint']?.returnValues
|
|
307
|
+
._creatorNodeEndpoint
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
/* ------- HELPERS ------- */
|
|
312
|
+
|
|
313
|
+
/**
|
|
314
|
+
* Gets a nonce and generates a signature for the given function. Private key is optional and
|
|
315
|
+
* will use that private key to create the signature. Otherwise the web3Manager private key
|
|
316
|
+
* will be used.
|
|
317
|
+
* @param generatorFn signature scheme object function
|
|
318
|
+
* @param userId blockchain userId
|
|
319
|
+
* @param newValue new value to set
|
|
320
|
+
* @param privateKey 64 character hex string
|
|
321
|
+
*/
|
|
322
|
+
async getUpdateNonceAndSig(
|
|
323
|
+
generatorFn: UserUpdateRequestFn,
|
|
324
|
+
userId: number,
|
|
325
|
+
newValue: unknown,
|
|
326
|
+
privateKey?: string
|
|
327
|
+
) {
|
|
328
|
+
const nonce = signatureSchemas.getNonce()
|
|
329
|
+
const chainId = await this.getEthNetId()
|
|
330
|
+
const contractAddress = await this.getAddress()
|
|
331
|
+
const signatureData = generatorFn(
|
|
332
|
+
chainId,
|
|
333
|
+
contractAddress,
|
|
334
|
+
userId,
|
|
335
|
+
newValue,
|
|
336
|
+
nonce
|
|
337
|
+
)
|
|
338
|
+
let sig
|
|
339
|
+
if (privateKey) {
|
|
340
|
+
sig = sigUtil.signTypedData(
|
|
341
|
+
SafeBuffer.from(privateKey, 'hex') as unknown as Buffer,
|
|
342
|
+
{
|
|
343
|
+
data: signatureData
|
|
344
|
+
}
|
|
345
|
+
)
|
|
346
|
+
} else {
|
|
347
|
+
sig = await this.web3Manager.signTypedData(signatureData)
|
|
348
|
+
}
|
|
349
|
+
return [nonce, sig]
|
|
350
|
+
}
|
|
351
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { ContractClient } from '../contracts/ContractClient'
|
|
2
|
+
import * as signatureSchemas from '../../../data-contracts/signatureSchemas'
|
|
3
|
+
import type { Web3Manager } from '../web3Manager'
|
|
4
|
+
|
|
5
|
+
export class UserLibraryFactoryClient extends ContractClient {
|
|
6
|
+
override web3Manager!: Web3Manager
|
|
7
|
+
/* ------- SETTERS ------- */
|
|
8
|
+
|
|
9
|
+
async addTrackSave(userId: number, trackId: number) {
|
|
10
|
+
const nonce = signatureSchemas.getNonce()
|
|
11
|
+
const chainId = await this.getEthNetId()
|
|
12
|
+
const contractAddress = await this.getAddress()
|
|
13
|
+
const signatureData = signatureSchemas.generators.getTrackSaveRequestData(
|
|
14
|
+
chainId,
|
|
15
|
+
contractAddress,
|
|
16
|
+
userId,
|
|
17
|
+
trackId,
|
|
18
|
+
nonce
|
|
19
|
+
)
|
|
20
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
21
|
+
const contractMethod = await this.getMethod(
|
|
22
|
+
'addTrackSave',
|
|
23
|
+
userId,
|
|
24
|
+
trackId,
|
|
25
|
+
nonce,
|
|
26
|
+
sig
|
|
27
|
+
)
|
|
28
|
+
return await this.web3Manager.sendTransaction(
|
|
29
|
+
contractMethod,
|
|
30
|
+
this.contractRegistryKey,
|
|
31
|
+
contractAddress
|
|
32
|
+
)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async deleteTrackSave(userId: number, trackId: number) {
|
|
36
|
+
const nonce = signatureSchemas.getNonce()
|
|
37
|
+
const chainId = await this.getEthNetId()
|
|
38
|
+
const contractAddress = await this.getAddress()
|
|
39
|
+
const signatureData =
|
|
40
|
+
signatureSchemas.generators.getDeleteTrackSaveRequestData(
|
|
41
|
+
chainId,
|
|
42
|
+
contractAddress,
|
|
43
|
+
userId,
|
|
44
|
+
trackId,
|
|
45
|
+
nonce
|
|
46
|
+
)
|
|
47
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
48
|
+
const contractMethod = await this.getMethod(
|
|
49
|
+
'deleteTrackSave',
|
|
50
|
+
userId,
|
|
51
|
+
trackId,
|
|
52
|
+
nonce,
|
|
53
|
+
sig
|
|
54
|
+
)
|
|
55
|
+
return await this.web3Manager.sendTransaction(
|
|
56
|
+
contractMethod,
|
|
57
|
+
this.contractRegistryKey,
|
|
58
|
+
contractAddress
|
|
59
|
+
)
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
async addPlaylistSave(userId: number, playlistId: number) {
|
|
63
|
+
const nonce = signatureSchemas.getNonce()
|
|
64
|
+
const chainId = await this.getEthNetId()
|
|
65
|
+
const contractAddress = await this.getAddress()
|
|
66
|
+
const signatureData =
|
|
67
|
+
signatureSchemas.generators.getPlaylistSaveRequestData(
|
|
68
|
+
chainId,
|
|
69
|
+
contractAddress,
|
|
70
|
+
userId,
|
|
71
|
+
playlistId,
|
|
72
|
+
nonce
|
|
73
|
+
)
|
|
74
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
75
|
+
const contractMethod = await this.getMethod(
|
|
76
|
+
'addPlaylistSave',
|
|
77
|
+
userId,
|
|
78
|
+
playlistId,
|
|
79
|
+
nonce,
|
|
80
|
+
sig
|
|
81
|
+
)
|
|
82
|
+
return await this.web3Manager.sendTransaction(
|
|
83
|
+
contractMethod,
|
|
84
|
+
this.contractRegistryKey,
|
|
85
|
+
contractAddress
|
|
86
|
+
)
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async deletePlaylistSave(userId: number, playlistId: number) {
|
|
90
|
+
const nonce = signatureSchemas.getNonce()
|
|
91
|
+
const chainId = await this.getEthNetId()
|
|
92
|
+
const contractAddress = await this.getAddress()
|
|
93
|
+
const signatureData =
|
|
94
|
+
signatureSchemas.generators.getDeletePlaylistSaveRequestData(
|
|
95
|
+
chainId,
|
|
96
|
+
contractAddress,
|
|
97
|
+
userId,
|
|
98
|
+
playlistId,
|
|
99
|
+
nonce
|
|
100
|
+
)
|
|
101
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
102
|
+
const contractMethod = await this.getMethod(
|
|
103
|
+
'deletePlaylistSave',
|
|
104
|
+
userId,
|
|
105
|
+
playlistId,
|
|
106
|
+
nonce,
|
|
107
|
+
sig
|
|
108
|
+
)
|
|
109
|
+
return await this.web3Manager.sendTransaction(
|
|
110
|
+
contractMethod,
|
|
111
|
+
this.contractRegistryKey,
|
|
112
|
+
contractAddress
|
|
113
|
+
)
|
|
114
|
+
}
|
|
115
|
+
}
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { ContractClient } from '../contracts/ContractClient'
|
|
2
|
+
import * as signatureSchemas from '../../../data-contracts/signatureSchemas'
|
|
3
|
+
import type { Web3Manager } from '../web3Manager'
|
|
4
|
+
|
|
5
|
+
export class UserReplicaSetManagerClient extends ContractClient {
|
|
6
|
+
override web3Manager!: Web3Manager
|
|
7
|
+
/**
|
|
8
|
+
* Update a user's replica set on the UserReplicaSetManager contract
|
|
9
|
+
* Callable by user wallet, or any node within the user's replica set
|
|
10
|
+
* @param userId
|
|
11
|
+
* @param primary
|
|
12
|
+
* @param secondaries
|
|
13
|
+
*/
|
|
14
|
+
async updateReplicaSet(
|
|
15
|
+
userId: number,
|
|
16
|
+
primary: number,
|
|
17
|
+
secondaries: number[]
|
|
18
|
+
) {
|
|
19
|
+
const existingReplicaSetInfo = await this.getUserReplicaSet(userId)
|
|
20
|
+
return await this._updateReplicaSet(
|
|
21
|
+
userId,
|
|
22
|
+
primary,
|
|
23
|
+
secondaries,
|
|
24
|
+
existingReplicaSetInfo.primaryId,
|
|
25
|
+
existingReplicaSetInfo.secondaryIds
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Add a new content node to the L2 layer of the protocol
|
|
31
|
+
* Requires signatures from 3 existing nodes on the UserReplicaSetManager contract
|
|
32
|
+
* @param cnodeId
|
|
33
|
+
* @param cnodeOwnerWallets - [0] = incoming delegateOwnerWallet, [1] = incoming ownerWallet
|
|
34
|
+
* @param proposerSpIds
|
|
35
|
+
* @param proposerNonces
|
|
36
|
+
* @param proposer1Sig
|
|
37
|
+
* @param proposer2Sig
|
|
38
|
+
* @param proposer3Sig
|
|
39
|
+
*/
|
|
40
|
+
async addOrUpdateContentNode(
|
|
41
|
+
cnodeId: number,
|
|
42
|
+
cnodeOwnerWallets: string[],
|
|
43
|
+
proposerSpIds: number[],
|
|
44
|
+
proposerNonces: string[],
|
|
45
|
+
proposer1Sig: string,
|
|
46
|
+
proposer2Sig: string,
|
|
47
|
+
proposer3Sig: string
|
|
48
|
+
) {
|
|
49
|
+
const contractAddress = await this.getAddress()
|
|
50
|
+
const method = await this.getMethod(
|
|
51
|
+
'addOrUpdateContentNode',
|
|
52
|
+
cnodeId,
|
|
53
|
+
cnodeOwnerWallets,
|
|
54
|
+
proposerSpIds,
|
|
55
|
+
proposerNonces,
|
|
56
|
+
proposer1Sig,
|
|
57
|
+
proposer2Sig,
|
|
58
|
+
proposer3Sig
|
|
59
|
+
)
|
|
60
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
61
|
+
method,
|
|
62
|
+
this.contractRegistryKey,
|
|
63
|
+
contractAddress
|
|
64
|
+
)
|
|
65
|
+
return tx
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Generate the relevant data required to propose a new content node
|
|
70
|
+
* Each incoming node requires 3 distinct signatures in order to be added
|
|
71
|
+
* This function will be used by content nodes
|
|
72
|
+
*/
|
|
73
|
+
async getProposeAddOrUpdateContentNodeRequestData(
|
|
74
|
+
cnodeId: number,
|
|
75
|
+
cnodeDelegateWallet: string,
|
|
76
|
+
cnodeOwnerWallet: string,
|
|
77
|
+
proposerSpId: number
|
|
78
|
+
) {
|
|
79
|
+
const chainId = await this.getEthNetId()
|
|
80
|
+
const contractAddress = await this.getAddress()
|
|
81
|
+
const nonce = signatureSchemas.getNonce()
|
|
82
|
+
const signatureData =
|
|
83
|
+
signatureSchemas.generators.getProposeAddOrUpdateContentNodeRequestData(
|
|
84
|
+
chainId,
|
|
85
|
+
contractAddress,
|
|
86
|
+
cnodeId,
|
|
87
|
+
cnodeDelegateWallet,
|
|
88
|
+
cnodeOwnerWallet,
|
|
89
|
+
proposerSpId,
|
|
90
|
+
nonce
|
|
91
|
+
)
|
|
92
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
93
|
+
return {
|
|
94
|
+
nonce,
|
|
95
|
+
signatureData,
|
|
96
|
+
sig
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Returns replica set for requested user at requested blocknumber
|
|
102
|
+
* @param userId
|
|
103
|
+
* @returns replica set info with schema { primaryId: int, secondaryIds: number[] }
|
|
104
|
+
*/
|
|
105
|
+
async getUserReplicaSet(userId: number) {
|
|
106
|
+
const method = await this.getMethod('getUserReplicaSet', userId)
|
|
107
|
+
const currentWallet = this.web3Manager.getWalletAddress()
|
|
108
|
+
const resp: { primaryId: string; secondaryIds: string[] } =
|
|
109
|
+
await method.call({ from: currentWallet })
|
|
110
|
+
return {
|
|
111
|
+
primaryId: parseInt(resp.primaryId),
|
|
112
|
+
secondaryIds: resp.secondaryIds.map((x) => parseInt(x))
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Returns replica set for requested user at requested blocknumber
|
|
118
|
+
* @notice will error if web3 cannot find data for requested blocknumber
|
|
119
|
+
* @returns replica set info with schema { primaryId: int, secondaryIds: int[] }
|
|
120
|
+
*/
|
|
121
|
+
async getUserReplicaSetAtBlockNumber(userId: number, blockNumber: number) {
|
|
122
|
+
const method = await this.getMethod('getUserReplicaSet', userId)
|
|
123
|
+
const currentWallet = this.web3Manager.getWalletAddress()
|
|
124
|
+
const resp: { primaryId: string; secondaryIds: string[] } =
|
|
125
|
+
await method.call({ from: currentWallet }, blockNumber)
|
|
126
|
+
return {
|
|
127
|
+
primaryId: parseInt(resp.primaryId),
|
|
128
|
+
secondaryIds: resp.secondaryIds.map((x) => parseInt(x))
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Return the current ownerWallet and delegateOwnerWallet for a given spID
|
|
134
|
+
*/
|
|
135
|
+
async getContentNodeWallets(spId: number) {
|
|
136
|
+
const method = await this.getMethod('getContentNodeWallets', spId)
|
|
137
|
+
const currentWallet = this.web3Manager.getWalletAddress()
|
|
138
|
+
return method.call({ from: currentWallet })
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Return boolean indicating status of URSM seed operation
|
|
143
|
+
* Prior to seed, no replica sets can be written
|
|
144
|
+
*/
|
|
145
|
+
async getSeedComplete() {
|
|
146
|
+
const method = await this.getMethod('getSeedComplete')
|
|
147
|
+
const currentWallet = this.web3Manager.getWalletAddress()
|
|
148
|
+
return method.call({ from: currentWallet })
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Submit update transaction to UserReplicaSetManager to modify a user's replica set
|
|
153
|
+
* Can be sent by user's wallet, or any content node in the replica set
|
|
154
|
+
* @param userId
|
|
155
|
+
* @param primary
|
|
156
|
+
* @param secondaries
|
|
157
|
+
* @param oldPrimary
|
|
158
|
+
* @param oldSecondaries
|
|
159
|
+
*/
|
|
160
|
+
async _updateReplicaSet(
|
|
161
|
+
userId: number,
|
|
162
|
+
primary: number,
|
|
163
|
+
secondaries: number[],
|
|
164
|
+
oldPrimary: number,
|
|
165
|
+
oldSecondaries: number[]
|
|
166
|
+
) {
|
|
167
|
+
const contractAddress = await this.getAddress()
|
|
168
|
+
const nonce = signatureSchemas.getNonce()
|
|
169
|
+
const chainId = await this.getEthNetId()
|
|
170
|
+
const web3 = this.web3Manager.getWeb3()
|
|
171
|
+
const secondariesHash = web3.utils.soliditySha3(
|
|
172
|
+
web3.eth.abi.encodeParameter('uint[]', secondaries)
|
|
173
|
+
)
|
|
174
|
+
const oldSecondariesHash = web3.utils.soliditySha3(
|
|
175
|
+
web3.eth.abi.encodeParameter('uint[]', oldSecondaries)
|
|
176
|
+
)
|
|
177
|
+
const signatureData =
|
|
178
|
+
signatureSchemas.generators.getUpdateReplicaSetRequestData(
|
|
179
|
+
chainId,
|
|
180
|
+
contractAddress,
|
|
181
|
+
userId,
|
|
182
|
+
primary,
|
|
183
|
+
secondariesHash,
|
|
184
|
+
oldPrimary,
|
|
185
|
+
oldSecondariesHash,
|
|
186
|
+
nonce
|
|
187
|
+
)
|
|
188
|
+
const sig = await this.web3Manager.signTypedData(signatureData)
|
|
189
|
+
const method = await this.getMethod(
|
|
190
|
+
'updateReplicaSet',
|
|
191
|
+
userId,
|
|
192
|
+
primary,
|
|
193
|
+
secondaries,
|
|
194
|
+
oldPrimary,
|
|
195
|
+
oldSecondaries,
|
|
196
|
+
nonce,
|
|
197
|
+
sig
|
|
198
|
+
)
|
|
199
|
+
const tx = await this.web3Manager.sendTransaction(
|
|
200
|
+
method,
|
|
201
|
+
this.contractRegistryKey,
|
|
202
|
+
contractAddress
|
|
203
|
+
)
|
|
204
|
+
return tx
|
|
205
|
+
}
|
|
206
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './AudiusContracts'
|