@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,155 @@
|
|
|
1
|
+
{
|
|
2
|
+
"contractName": "Wormhole",
|
|
3
|
+
"abi": [
|
|
4
|
+
{
|
|
5
|
+
"constant": true,
|
|
6
|
+
"inputs": [],
|
|
7
|
+
"name": "DOMAIN_SEPARATOR",
|
|
8
|
+
"outputs": [
|
|
9
|
+
{
|
|
10
|
+
"internalType": "bytes32",
|
|
11
|
+
"name": "",
|
|
12
|
+
"type": "bytes32"
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
"payable": false,
|
|
16
|
+
"stateMutability": "view",
|
|
17
|
+
"type": "function"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"constant": true,
|
|
21
|
+
"inputs": [],
|
|
22
|
+
"name": "LOCK_ASSETS_TYPEHASH",
|
|
23
|
+
"outputs": [
|
|
24
|
+
{
|
|
25
|
+
"internalType": "bytes32",
|
|
26
|
+
"name": "",
|
|
27
|
+
"type": "bytes32"
|
|
28
|
+
}
|
|
29
|
+
],
|
|
30
|
+
"payable": false,
|
|
31
|
+
"stateMutability": "view",
|
|
32
|
+
"type": "function"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"constant": false,
|
|
36
|
+
"inputs": [
|
|
37
|
+
{
|
|
38
|
+
"internalType": "address",
|
|
39
|
+
"name": "_tokenAddress",
|
|
40
|
+
"type": "address"
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"internalType": "address",
|
|
44
|
+
"name": "_wormholeAddress",
|
|
45
|
+
"type": "address"
|
|
46
|
+
}
|
|
47
|
+
],
|
|
48
|
+
"name": "initialize",
|
|
49
|
+
"outputs": [],
|
|
50
|
+
"payable": false,
|
|
51
|
+
"stateMutability": "nonpayable",
|
|
52
|
+
"type": "function"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"constant": false,
|
|
56
|
+
"inputs": [],
|
|
57
|
+
"name": "initialize",
|
|
58
|
+
"outputs": [],
|
|
59
|
+
"payable": false,
|
|
60
|
+
"stateMutability": "nonpayable",
|
|
61
|
+
"type": "function"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"constant": false,
|
|
65
|
+
"inputs": [
|
|
66
|
+
{
|
|
67
|
+
"internalType": "address",
|
|
68
|
+
"name": "from",
|
|
69
|
+
"type": "address"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
"internalType": "uint256",
|
|
73
|
+
"name": "amount",
|
|
74
|
+
"type": "uint256"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"internalType": "bytes32",
|
|
78
|
+
"name": "recipient",
|
|
79
|
+
"type": "bytes32"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"internalType": "uint8",
|
|
83
|
+
"name": "targetChain",
|
|
84
|
+
"type": "uint8"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"internalType": "bool",
|
|
88
|
+
"name": "refundDust",
|
|
89
|
+
"type": "bool"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"internalType": "uint256",
|
|
93
|
+
"name": "deadline",
|
|
94
|
+
"type": "uint256"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
"internalType": "uint8",
|
|
98
|
+
"name": "v",
|
|
99
|
+
"type": "uint8"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"internalType": "bytes32",
|
|
103
|
+
"name": "r",
|
|
104
|
+
"type": "bytes32"
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"internalType": "bytes32",
|
|
108
|
+
"name": "s",
|
|
109
|
+
"type": "bytes32"
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
"name": "lockAssets",
|
|
113
|
+
"outputs": [],
|
|
114
|
+
"payable": false,
|
|
115
|
+
"stateMutability": "nonpayable",
|
|
116
|
+
"type": "function"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
"constant": true,
|
|
120
|
+
"inputs": [
|
|
121
|
+
{
|
|
122
|
+
"internalType": "address",
|
|
123
|
+
"name": "",
|
|
124
|
+
"type": "address"
|
|
125
|
+
}
|
|
126
|
+
],
|
|
127
|
+
"name": "nonces",
|
|
128
|
+
"outputs": [
|
|
129
|
+
{
|
|
130
|
+
"internalType": "uint32",
|
|
131
|
+
"name": "",
|
|
132
|
+
"type": "uint32"
|
|
133
|
+
}
|
|
134
|
+
],
|
|
135
|
+
"payable": false,
|
|
136
|
+
"stateMutability": "view",
|
|
137
|
+
"type": "function"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"constant": true,
|
|
141
|
+
"inputs": [],
|
|
142
|
+
"name": "token",
|
|
143
|
+
"outputs": [
|
|
144
|
+
{
|
|
145
|
+
"internalType": "address",
|
|
146
|
+
"name": "",
|
|
147
|
+
"type": "address"
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
"payable": false,
|
|
151
|
+
"stateMutability": "view",
|
|
152
|
+
"type": "function"
|
|
153
|
+
}
|
|
154
|
+
]
|
|
155
|
+
}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
const { getDataContractAccounts } = require('../initScripts/helpers/utils')
|
|
2
|
+
const contractConfig = require('../../contracts/contract-config.js')
|
|
3
|
+
const AudiusLibs = require('../src')
|
|
4
|
+
const { initializeLibConfig } = require('../tests/helpers')
|
|
5
|
+
const Utils = require('../src/utils')
|
|
6
|
+
|
|
7
|
+
const networks = new Set([
|
|
8
|
+
'development',
|
|
9
|
+
'test_local'
|
|
10
|
+
// disable mainnet keys for now
|
|
11
|
+
/* 'audius_private',
|
|
12
|
+
'poa_mainnet',
|
|
13
|
+
'poa_sokol' */
|
|
14
|
+
])
|
|
15
|
+
|
|
16
|
+
let config
|
|
17
|
+
|
|
18
|
+
// node addCIDToIpldBlacklist.js <env> <cid>
|
|
19
|
+
// From libs root:
|
|
20
|
+
// node scripts/addCIDToIpldBlacklist.js development QmSH5gJPHg9xLzV823ty8BSGyHNP6ty22bgLsv5MLY3kBq
|
|
21
|
+
|
|
22
|
+
async function run () {
|
|
23
|
+
try {
|
|
24
|
+
const { network, cid } = parseArgs()
|
|
25
|
+
const decodedCID = decodeCID(cid)
|
|
26
|
+
config = contractConfig[network]
|
|
27
|
+
// note: can extract private key here if necessary
|
|
28
|
+
const { BLACKLISTER_PUBLIC_KEY } = await getBlacklisterKeys(network)
|
|
29
|
+
const audiusLibs = await createAndInitLibs(BLACKLISTER_PUBLIC_KEY)
|
|
30
|
+
const ipldTxReceipt = await addIPLDTxToChain(audiusLibs, decodedCID.digest)
|
|
31
|
+
|
|
32
|
+
console.log(`Successfully added ${cid} to chain! \nIpld Tx Receipt:`)
|
|
33
|
+
console.log(ipldTxReceipt)
|
|
34
|
+
|
|
35
|
+
console.log(
|
|
36
|
+
'\nYou might need to wait a full 60s cycle for your CID to be added to the IPLD blacklist table!'
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
// manually check ipld blacklist table to see if CID was added
|
|
40
|
+
// NOTE: might need to wait ~60s
|
|
41
|
+
} catch (e) {
|
|
42
|
+
console.error(e.message)
|
|
43
|
+
if (e.message.includes('Incorrect script usage')) {
|
|
44
|
+
console.log('Available environments are:')
|
|
45
|
+
console.log(networks)
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// get appropriate args from CLI
|
|
51
|
+
function parseArgs () {
|
|
52
|
+
const args = process.argv.slice(2)
|
|
53
|
+
const network = args[0]
|
|
54
|
+
const cid = args[1]
|
|
55
|
+
|
|
56
|
+
// check appropriate CLI usage
|
|
57
|
+
if (!network || !cid || !networks.has(network)) {
|
|
58
|
+
let errorMessage = `Incorrect script usage for input env (${network}) and (cid) ${cid}.`
|
|
59
|
+
errorMessage += "\nPlease follow the structure 'node addCIDToIpldBlacklist.js <env> <cid>'"
|
|
60
|
+
throw new Error(errorMessage)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return { network, cid }
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// transform CID into a readable digest
|
|
67
|
+
function decodeCID (cid) {
|
|
68
|
+
let decodedCID
|
|
69
|
+
try {
|
|
70
|
+
decodedCID = Utils.decodeMultihash(cid)
|
|
71
|
+
} catch (e) {
|
|
72
|
+
throw new Error(`Error with decoding input CID ${cid}: ${e}`)
|
|
73
|
+
}
|
|
74
|
+
return decodedCID
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// get key according to environmnet
|
|
78
|
+
async function getBlacklisterKeys (network) {
|
|
79
|
+
let BLACKLISTER_PUBLIC_KEY
|
|
80
|
+
let BLACKLISTER_PRIVATE_KEY = null // what would this be for mainnet?
|
|
81
|
+
|
|
82
|
+
// if local dev, grab priv/pub keys from local ganache chain
|
|
83
|
+
// else, grab key from config
|
|
84
|
+
// NOTE: for local dev, wallet[0] is unlocked and does not require a private key
|
|
85
|
+
if (network === 'development' || network === 'test_local') {
|
|
86
|
+
const ganacheContractsAccounts = await getDataContractAccounts()
|
|
87
|
+
const keyPairs = ganacheContractsAccounts.private_keys
|
|
88
|
+
BLACKLISTER_PUBLIC_KEY = Object.keys(keyPairs)[0]
|
|
89
|
+
BLACKLISTER_PRIVATE_KEY = keyPairs[BLACKLISTER_PUBLIC_KEY]
|
|
90
|
+
} else {
|
|
91
|
+
BLACKLISTER_PUBLIC_KEY = config.blacklisterAddress
|
|
92
|
+
}
|
|
93
|
+
return { BLACKLISTER_PUBLIC_KEY, BLACKLISTER_PRIVATE_KEY }
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// init libs with blacklister public address
|
|
97
|
+
async function createAndInitLibs (blacklisterPublicKey) {
|
|
98
|
+
let audiusLibs
|
|
99
|
+
try {
|
|
100
|
+
const libsConfig = await initializeLibConfig(blacklisterPublicKey)
|
|
101
|
+
audiusLibs = new AudiusLibs(libsConfig)
|
|
102
|
+
await audiusLibs.init()
|
|
103
|
+
} catch (e) {
|
|
104
|
+
throw new Error(`Error with initializing libs: ${e}`)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return audiusLibs
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
// add cid to ipld blacklist
|
|
111
|
+
async function addIPLDTxToChain (audiusLibs, digest) {
|
|
112
|
+
let ipldTxReceipt
|
|
113
|
+
try {
|
|
114
|
+
ipldTxReceipt = await audiusLibs.contracts.IPLDBlacklistFactoryClient.addIPLDToBlacklist(
|
|
115
|
+
digest
|
|
116
|
+
)
|
|
117
|
+
} catch (e) {
|
|
118
|
+
throw new Error(`Error with adding IPLD blacklist txn: ${e}`)
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
return ipldTxReceipt
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
run()
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
set -e
|
|
3
|
+
|
|
4
|
+
<<COMMENT
|
|
5
|
+
CircleCI Specific Test Script
|
|
6
|
+
Removes dependency on docker container, assumes ports 8545 & 8546 are exposed
|
|
7
|
+
COMMENT
|
|
8
|
+
|
|
9
|
+
##### INIT DATA CONTRACTS #####
|
|
10
|
+
|
|
11
|
+
if [ -d "../contracts" ]; then
|
|
12
|
+
echo "Audius contracts repo is present"
|
|
13
|
+
cd ../contracts/
|
|
14
|
+
else
|
|
15
|
+
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
|
|
16
|
+
exit 1
|
|
17
|
+
fi
|
|
18
|
+
|
|
19
|
+
rm -rf ./build/
|
|
20
|
+
npm run truffle-migrate
|
|
21
|
+
|
|
22
|
+
##### INIT ETH CONTRACTS #####
|
|
23
|
+
|
|
24
|
+
if [ -d "../eth-contracts" ]; then
|
|
25
|
+
echo "Audius eth-contracts repo is present"
|
|
26
|
+
cd ../eth-contracts/
|
|
27
|
+
else
|
|
28
|
+
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
|
|
29
|
+
exit 1
|
|
30
|
+
fi
|
|
31
|
+
|
|
32
|
+
rm -rf ./build/
|
|
33
|
+
npm run truffle-migrate
|
|
34
|
+
|
|
35
|
+
#### RUN TESTS #####
|
|
36
|
+
|
|
37
|
+
cd ../libs/
|
|
38
|
+
|
|
39
|
+
# Migrate data & eth contracts
|
|
40
|
+
# - Copy contracts build dir + create config files
|
|
41
|
+
# - Data contracts config: registry contract & owner wallet addresses
|
|
42
|
+
# - Eth contracts config: AudiusToken contract address
|
|
43
|
+
sh ./scripts/migrate_contracts.sh
|
|
44
|
+
|
|
45
|
+
# Run unit tests
|
|
46
|
+
npm run test:unit
|
|
47
|
+
|
|
48
|
+
# run tests
|
|
49
|
+
printf '\nSTART tests:\n\n'
|
|
50
|
+
node_modules/.bin/ts-mocha tests/index.js
|
|
51
|
+
|
|
52
|
+
# run linter
|
|
53
|
+
npm run lint
|
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Script that has no internal dependencies outside of web3, solanaWeb3, certusOne SDK to initialize and transfer
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
const axios = require('axios')
|
|
6
|
+
const Web3 = require('web3')
|
|
7
|
+
const solanaWeb3 = require('@solana/web3.js')
|
|
8
|
+
const { Keypair } = solanaWeb3
|
|
9
|
+
const {
|
|
10
|
+
getSignedVAA,
|
|
11
|
+
getEmitterAddressEth,
|
|
12
|
+
parseSequenceFromLogEth,
|
|
13
|
+
redeemOnSolana,
|
|
14
|
+
postVaaSolana,
|
|
15
|
+
CHAIN_ID_ETH
|
|
16
|
+
} = require('@certusone/wormhole-sdk')
|
|
17
|
+
const { setDefaultWasm } = require('@certusone/wormhole-sdk/lib/cjs/solana/wasm.js')
|
|
18
|
+
const EthRewardManagerABI = require('../../eth-contracts/ABIs/EthRewardsManager.json').abi
|
|
19
|
+
|
|
20
|
+
const { grpc } = require('@improbable-eng/grpc-web')
|
|
21
|
+
const { NodeHttpTransport } = require('@improbable-eng/grpc-web-node-http-transport')
|
|
22
|
+
|
|
23
|
+
// Without this, we get the error:
|
|
24
|
+
// "This environment's XHR implementation cannot support binary transfer."
|
|
25
|
+
grpc.setDefaultTransport(NodeHttpTransport())
|
|
26
|
+
|
|
27
|
+
setDefaultWasm('node')
|
|
28
|
+
|
|
29
|
+
// Please provide an eth RPC provider endpoint here
|
|
30
|
+
// For example https://mainnet.infura.io/v3/<your-key-here>
|
|
31
|
+
const ETH_PROVIDER = process.env.ethProvider
|
|
32
|
+
const SOLANA_CLUSTER_ENDPOINT = 'https://audius.rpcpool.com/'
|
|
33
|
+
const ETH_BRIDGE_ADDRESS = '0x98f3c9e6E3fAce36bAAd05FE09d375Ef1464288B'
|
|
34
|
+
const SOL_BRIDGE_ADDRESS = 'worm2ZoG2kUd4vFXhvjh93UUH596ayRfgQ2MgjNMTth'
|
|
35
|
+
const ETH_TOKEN_BRIDGE_ADDRESS = '0x3ee18B2214AFF97000D974cf647E7C347E8fa585'
|
|
36
|
+
const SOL_TOKEN_BRIDGE_ADDRESS = 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb'
|
|
37
|
+
|
|
38
|
+
// https://github.com/certusone/wormhole/blob/7f5740754b8d722c42310be086dc21efa7ed8c83/bridge_ui/src/utils/consts.ts#L150
|
|
39
|
+
const WORMHOLE_RPC_HOSTS = [
|
|
40
|
+
'https://wormhole-v2-mainnet-api.certus.one',
|
|
41
|
+
'https://wormhole.inotel.ro',
|
|
42
|
+
'https://wormhole-v2-mainnet-api.mcf.rocks',
|
|
43
|
+
'https://wormhole-v2-mainnet-api.chainlayer.network',
|
|
44
|
+
'https://wormhole-v2-mainnet-api.staking.fund',
|
|
45
|
+
'https://wormhole-v2-mainnet-api.chainlayer.network'
|
|
46
|
+
]
|
|
47
|
+
|
|
48
|
+
const connection = new solanaWeb3.Connection(SOLANA_CLUSTER_ENDPOINT)
|
|
49
|
+
|
|
50
|
+
// num attempts and delay between attempts to find transaction receipt
|
|
51
|
+
const NUM_RETRIES_RECEIPT = 5
|
|
52
|
+
const RETRY_DELAY_MS_RECEIPT = 1000
|
|
53
|
+
|
|
54
|
+
// num attempts and delay between attempts to find requested VAA
|
|
55
|
+
// stop if not found after 5 minutes (60 * 5000ms)
|
|
56
|
+
const NUM_RETRIES_VAA = 60
|
|
57
|
+
const RETRY_DELAY_MS_VAA = 5000
|
|
58
|
+
|
|
59
|
+
const ETH_REWARD_MANAGER_ADDRESS = '0x5aa6B99A2B461bA8E97207740f0A689C5C39C3b0'
|
|
60
|
+
const TEST_PRIVATE_KEY = process.env.testPrivateKey
|
|
61
|
+
const FEE_PAYER_SECRET_KEY = process.env.feePayerAddress
|
|
62
|
+
|
|
63
|
+
const feePayerSecretKey = Uint8Array.from(JSON.parse(FEE_PAYER_SECRET_KEY))
|
|
64
|
+
const feePayerKeypair = Keypair.fromSecretKey(feePayerSecretKey)
|
|
65
|
+
const feePayerPublicKey = feePayerKeypair.publicKey
|
|
66
|
+
const feePayerAddress = feePayerPublicKey.toString()
|
|
67
|
+
|
|
68
|
+
const web3 = new Web3(ETH_PROVIDER)
|
|
69
|
+
// ethereum address that executes the transfer to solana transaction
|
|
70
|
+
const ethAccount = web3.eth.accounts.wallet.add(TEST_PRIVATE_KEY)
|
|
71
|
+
|
|
72
|
+
const arbiterFee = 0
|
|
73
|
+
const nonce = 2 // this is just some random number atm
|
|
74
|
+
|
|
75
|
+
async function getGasPrice () {
|
|
76
|
+
try {
|
|
77
|
+
const gasPrices = await axios.get(
|
|
78
|
+
'https://ethgasstation.info/json/ethgasAPI.json'
|
|
79
|
+
)
|
|
80
|
+
return web3.utils.toWei((gasPrices.data.fastest / 10).toString(), 'gwei')
|
|
81
|
+
} catch (err) {
|
|
82
|
+
console.error(
|
|
83
|
+
`Got ${err} when trying to fetch gas from ethgasstation.info, falling back web3's gas estimation`
|
|
84
|
+
)
|
|
85
|
+
return (await web3.eth.getGasPrice()).toString()
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// "Fetch the signedVAA from the Wormhole Network (this may require retries while you wait for confirmation)"
|
|
90
|
+
// https://github.com/certusone/wormhole/blob/c824a996360103eb2147bc43f7b0f7e3b989bdf5/sdk/js/src/rpc/getSignedVAAWithRetry.ts#L3
|
|
91
|
+
const getSignedVAAWithRetry = async function (
|
|
92
|
+
hosts,
|
|
93
|
+
emitterChain,
|
|
94
|
+
emitterAddress,
|
|
95
|
+
sequence,
|
|
96
|
+
extraGrpcOpts = {},
|
|
97
|
+
retryTimeout = RETRY_DELAY_MS_VAA,
|
|
98
|
+
retryAttempts = NUM_RETRIES_VAA
|
|
99
|
+
) {
|
|
100
|
+
let currentWormholeRpcHost = -1
|
|
101
|
+
const getNextRpcHost = () => ++currentWormholeRpcHost % hosts.length
|
|
102
|
+
let result
|
|
103
|
+
let attempts = 0
|
|
104
|
+
while (!result) {
|
|
105
|
+
attempts++
|
|
106
|
+
console.log(`transferCommunityRewardsToSolana.js | getSignedVAAWithRetry | attempt # ${attempts}`)
|
|
107
|
+
await new Promise((resolve) => setTimeout(resolve, retryTimeout))
|
|
108
|
+
try {
|
|
109
|
+
result = await getSignedVAA(
|
|
110
|
+
hosts[getNextRpcHost()],
|
|
111
|
+
emitterChain,
|
|
112
|
+
emitterAddress,
|
|
113
|
+
sequence,
|
|
114
|
+
extraGrpcOpts
|
|
115
|
+
)
|
|
116
|
+
} catch (e) {
|
|
117
|
+
if (retryAttempts !== undefined && attempts >= retryAttempts) {
|
|
118
|
+
throw e
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
return result
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const getReceipt = async (txHash, numRetries) => {
|
|
126
|
+
console.log(`transferCommunityRewardsToSolana.js | getReceipt | txHash ${txHash} | ${numRetries} retries left`)
|
|
127
|
+
if (numRetries <= 0) {
|
|
128
|
+
return null
|
|
129
|
+
}
|
|
130
|
+
const txReceipt = await web3.eth.getTransactionReceipt(txHash)
|
|
131
|
+
if (!txReceipt) {
|
|
132
|
+
await new Promise(resolve => setTimeout(resolve, RETRY_DELAY_MS_RECEIPT))
|
|
133
|
+
return getReceipt(numRetries - 1)
|
|
134
|
+
}
|
|
135
|
+
return txReceipt
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
async function run () {
|
|
139
|
+
try {
|
|
140
|
+
const gasPrice = await getGasPrice()
|
|
141
|
+
console.log({ gasPrice })
|
|
142
|
+
|
|
143
|
+
const ethRewardsManagerContract = new web3.eth.Contract(
|
|
144
|
+
EthRewardManagerABI,
|
|
145
|
+
ETH_REWARD_MANAGER_ADDRESS
|
|
146
|
+
)
|
|
147
|
+
// transfer eth rewards manager funds to solana via wormhole
|
|
148
|
+
// recipient is defined in the eth rewards manager contract
|
|
149
|
+
const txResp = await ethRewardsManagerContract.methods.transferToSolana(
|
|
150
|
+
arbiterFee,
|
|
151
|
+
nonce
|
|
152
|
+
).send({
|
|
153
|
+
from: ethAccount.address,
|
|
154
|
+
gas: 200000, // should this be dynamic?
|
|
155
|
+
gasPrice
|
|
156
|
+
})
|
|
157
|
+
console.log({ txResp })
|
|
158
|
+
|
|
159
|
+
const txHash = txResp.transactionHash
|
|
160
|
+
console.log({ txHash })
|
|
161
|
+
|
|
162
|
+
const txReceipt = await getReceipt(txHash, NUM_RETRIES_RECEIPT)
|
|
163
|
+
console.log({ txReceipt })
|
|
164
|
+
if (!txReceipt) {
|
|
165
|
+
return
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const sequence = parseSequenceFromLogEth(txReceipt, ETH_BRIDGE_ADDRESS)
|
|
169
|
+
const emitterAddress = getEmitterAddressEth(ETH_TOKEN_BRIDGE_ADDRESS)
|
|
170
|
+
console.log({ sequence, emitterAddress })
|
|
171
|
+
|
|
172
|
+
// Attest and transfer, aka
|
|
173
|
+
// Fetch and post the signed VAA bytes for our transaction
|
|
174
|
+
// Then redeem on solana
|
|
175
|
+
const { vaaBytes } = await getSignedVAAWithRetry(
|
|
176
|
+
WORMHOLE_RPC_HOSTS,
|
|
177
|
+
CHAIN_ID_ETH,
|
|
178
|
+
emitterAddress,
|
|
179
|
+
sequence
|
|
180
|
+
)
|
|
181
|
+
console.log({ vaaBytes })
|
|
182
|
+
|
|
183
|
+
const signTransaction = async (transaction) => {
|
|
184
|
+
transaction.partialSign(feePayerKeypair)
|
|
185
|
+
return transaction
|
|
186
|
+
}
|
|
187
|
+
await postVaaSolana(
|
|
188
|
+
connection,
|
|
189
|
+
signTransaction,
|
|
190
|
+
SOL_BRIDGE_ADDRESS,
|
|
191
|
+
feePayerAddress,
|
|
192
|
+
vaaBytes
|
|
193
|
+
)
|
|
194
|
+
const transaction = await redeemOnSolana(
|
|
195
|
+
connection,
|
|
196
|
+
SOL_BRIDGE_ADDRESS,
|
|
197
|
+
SOL_TOKEN_BRIDGE_ADDRESS,
|
|
198
|
+
feePayerAddress,
|
|
199
|
+
vaaBytes
|
|
200
|
+
)
|
|
201
|
+
console.log({ transaction })
|
|
202
|
+
|
|
203
|
+
const signed = await signTransaction(transaction)
|
|
204
|
+
console.log({ signed })
|
|
205
|
+
|
|
206
|
+
const txid = await connection.sendRawTransaction(signed.serialize())
|
|
207
|
+
console.log({ txid })
|
|
208
|
+
|
|
209
|
+
await connection.confirmTransaction(txid)
|
|
210
|
+
console.log('Success!')
|
|
211
|
+
} catch (e) {
|
|
212
|
+
console.error(e)
|
|
213
|
+
console.log(`Error: ${e.message}`)
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
if (require && require.main === module) {
|
|
217
|
+
run()
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
module.exports = {
|
|
221
|
+
transferCommunityRewardsToSolana: run
|
|
222
|
+
}
|
package/scripts/ipfs.sh
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
API_PORT=6001
|
|
4
|
+
SWARM_PORT=6002
|
|
5
|
+
CONTAINER_NAME=local_ipfs_node
|
|
6
|
+
IPFS_RELEASE_VERSION=ipfs/go-ipfs:v0.8.0
|
|
7
|
+
|
|
8
|
+
if [[ "$1" =~ ^up|down$ ]]; then
|
|
9
|
+
echo "Local ipfs operations:"
|
|
10
|
+
else
|
|
11
|
+
echo "Must be a valid command - ./scripts/ipfs.sh <up|down>"
|
|
12
|
+
exit 1
|
|
13
|
+
fi
|
|
14
|
+
|
|
15
|
+
if [[ "$1" == 'up' ]]; then
|
|
16
|
+
if [[ -z "$2" ]]; then
|
|
17
|
+
echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort> <gatewayPort (optional)>"
|
|
18
|
+
exit 1
|
|
19
|
+
else
|
|
20
|
+
CONTAINER_NAME=$2
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
if [[ -z "$3" ]]; then
|
|
24
|
+
echo "Using default apiPort - $API_PORT"
|
|
25
|
+
echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort> <gatewayPort (optional)>"
|
|
26
|
+
else
|
|
27
|
+
API_PORT=$3
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
if [[ -z "$4" ]]; then
|
|
31
|
+
echo "Using default swarmPort - $SWARM_PORT"
|
|
32
|
+
echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort> <gatewayPort (optional)>"
|
|
33
|
+
else
|
|
34
|
+
SWARM_PORT=$4
|
|
35
|
+
fi
|
|
36
|
+
|
|
37
|
+
# Pull image
|
|
38
|
+
docker pull $IPFS_RELEASE_VERSION
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
if [[ -z "$5" ]]; then
|
|
42
|
+
docker run -d --name $CONTAINER_NAME -p 127.0.0.1:$API_PORT:5001 -p 127.0.0.1:$SWARM_PORT:4001 --network=audius_dev $IPFS_RELEASE_VERSION daemon
|
|
43
|
+
else
|
|
44
|
+
GATEWAY_PORT=$5
|
|
45
|
+
docker run -d --name $CONTAINER_NAME -p 127.0.0.1:$API_PORT:5001 -p 127.0.0.1:$SWARM_PORT:4001 -p 127.0.0.1:$GATEWAY_PORT:8080 --network=audius_dev $IPFS_RELEASE_VERSION daemon
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
elif [[ "$1" == 'down' ]]; then
|
|
49
|
+
if [[ -z "$2" ]]; then
|
|
50
|
+
echo "Format - ./scripts/ipfs.sh up <serviceName> <apiPort> <swarmPort> <gatewayPort (optional)>"
|
|
51
|
+
exit 1
|
|
52
|
+
else
|
|
53
|
+
CONTAINER_NAME=$2
|
|
54
|
+
fi
|
|
55
|
+
docker stop $CONTAINER_NAME
|
|
56
|
+
docker rm $CONTAINER_NAME
|
|
57
|
+
fi
|
|
58
|
+
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# COPY DATA CONTRACTS
|
|
2
|
+
if [ -d "../contracts/build/contracts" ]
|
|
3
|
+
then
|
|
4
|
+
echo "Audius contracts repo is present"
|
|
5
|
+
cd ../contracts/
|
|
6
|
+
echo "Writing contracts config files"
|
|
7
|
+
node_modules/.bin/truffle exec scripts/migrate-contracts.js
|
|
8
|
+
else
|
|
9
|
+
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
|
|
10
|
+
exit 1
|
|
11
|
+
fi
|
|
12
|
+
|
|
13
|
+
# COPY ETH CONTRACTS
|
|
14
|
+
if [ -d "../eth-contracts/build/contracts" ]
|
|
15
|
+
then
|
|
16
|
+
echo "Audius eth-contracts repo is present"
|
|
17
|
+
cd ../eth-contracts/
|
|
18
|
+
echo "Writing eth-contracts config files"
|
|
19
|
+
node_modules/.bin/truffle exec scripts/migrate-contracts.js
|
|
20
|
+
cp ../libs/scripts/AudiusClaimDistributor.json ../libs/eth-contracts/ABIs/AudiusClaimDistributor.json
|
|
21
|
+
cp ../libs/scripts/Wormhole.json ../libs/eth-contracts/ABIs/Wormhole.json
|
|
22
|
+
else
|
|
23
|
+
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
|
|
24
|
+
exit 1
|
|
25
|
+
fi
|
package/scripts/reset.sh
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
|
|
3
|
+
set -e
|
|
4
|
+
set -o xtrace
|
|
5
|
+
|
|
6
|
+
##### INIT DATA CONTRACTS #####
|
|
7
|
+
|
|
8
|
+
if [ -d "../contracts" ]
|
|
9
|
+
then
|
|
10
|
+
echo "Audius contracts repo is present"
|
|
11
|
+
cd ../contracts/
|
|
12
|
+
else
|
|
13
|
+
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
|
|
14
|
+
exit 1
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
rm -rf ./build/
|
|
18
|
+
|
|
19
|
+
# not problematic for this to fail
|
|
20
|
+
set +e
|
|
21
|
+
npm run ganache-q
|
|
22
|
+
set -e
|
|
23
|
+
|
|
24
|
+
npm run ganache
|
|
25
|
+
npm run truffle-migrate
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
##### INIT ETH CONTRACTS #####
|
|
29
|
+
|
|
30
|
+
if [ -d "../eth-contracts" ]
|
|
31
|
+
then
|
|
32
|
+
echo "Audius eth-contracts repo is present"
|
|
33
|
+
cd ../eth-contracts/
|
|
34
|
+
else
|
|
35
|
+
echo "INCORRECT REPOSITORY STRUCTURE. PLEASE FOLLOW README"
|
|
36
|
+
exit 1
|
|
37
|
+
fi
|
|
38
|
+
|
|
39
|
+
rm -rf ./build/
|
|
40
|
+
|
|
41
|
+
# not problematic for this to fail
|
|
42
|
+
set +e
|
|
43
|
+
npm run ganache-q
|
|
44
|
+
set -e
|
|
45
|
+
|
|
46
|
+
npm run ganache
|
|
47
|
+
npm run truffle-migrate
|
|
48
|
+
|
|
49
|
+
cd ../libs/
|
|
50
|
+
|
|
51
|
+
# Migrate data & eth contracts
|
|
52
|
+
# - Copy contracts build dir + create config files
|
|
53
|
+
# - Data contracts config: registry contract & owner wallet addresses
|
|
54
|
+
# - Eth contracts config: AudiusToken contract, registry contract and owner wallet addresses
|
|
55
|
+
sh ./scripts/migrate_contracts.sh
|
|
56
|
+
|
|
57
|
+
#### RUN TESTS #####
|
|
58
|
+
|
|
59
|
+
# printf '\nSTART tests:\n\n'
|
|
60
|
+
#./node_modules/.bin/mocha tests/index.js
|
|
61
|
+
|
|
62
|
+
# run linter
|
|
63
|
+
# node_modules/.bin/standard
|
|
64
|
+
|
|
65
|
+
# intentionally does not bring down containers
|