@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.
Files changed (278) hide show
  1. package/.eslintrc +38 -0
  2. package/.prettierrc.js +1 -0
  3. package/.python-version +1 -0
  4. package/Dockerfile +15 -0
  5. package/README.md +3 -0
  6. package/babel.config.js +3 -0
  7. package/data-contracts/ABIs/AdminUpgradeabilityProxy.json +132 -0
  8. package/data-contracts/ABIs/BaseAdminUpgradeabilityProxy.json +113 -0
  9. package/data-contracts/ABIs/BaseUpgradeabilityProxy.json +22 -0
  10. package/data-contracts/ABIs/DiscoveryProviderFactory.json +189 -0
  11. package/data-contracts/ABIs/DiscoveryProviderFactoryInterface.json +61 -0
  12. package/data-contracts/ABIs/DiscoveryProviderStorage.json +205 -0
  13. package/data-contracts/ABIs/DiscoveryProviderStorageInterface.json +65 -0
  14. package/data-contracts/ABIs/ECDSA.json +4 -0
  15. package/data-contracts/ABIs/IPLDBlacklistFactory.json +168 -0
  16. package/data-contracts/ABIs/Initializable.json +4 -0
  17. package/data-contracts/ABIs/Migrations.json +67 -0
  18. package/data-contracts/ABIs/OpenZeppelinUpgradesAddress.json +4 -0
  19. package/data-contracts/ABIs/Ownable.json +79 -0
  20. package/data-contracts/ABIs/PlaylistFactory.json +669 -0
  21. package/data-contracts/ABIs/PlaylistFactoryInterface.json +42 -0
  22. package/data-contracts/ABIs/PlaylistStorage.json +250 -0
  23. package/data-contracts/ABIs/PlaylistStorageInterface.json +129 -0
  24. package/data-contracts/ABIs/Proxy.json +10 -0
  25. package/data-contracts/ABIs/Registry.json +240 -0
  26. package/data-contracts/ABIs/RegistryContract.json +102 -0
  27. package/data-contracts/ABIs/RegistryContractInterface.json +28 -0
  28. package/data-contracts/ABIs/RegistryInterface.json +66 -0
  29. package/data-contracts/ABIs/SigningLogic.json +43 -0
  30. package/data-contracts/ABIs/SigningLogicInitializable.json +46 -0
  31. package/data-contracts/ABIs/SocialFeatureFactory.json +460 -0
  32. package/data-contracts/ABIs/SocialFeatureStorage.json +225 -0
  33. package/data-contracts/ABIs/SocialFeatureStorageInterface.json +123 -0
  34. package/data-contracts/ABIs/TestContract.json +135 -0
  35. package/data-contracts/ABIs/TestContractInterface.json +19 -0
  36. package/data-contracts/ABIs/TestContractWithStorage.json +165 -0
  37. package/data-contracts/ABIs/TestContractWithStorageInterface.json +24 -0
  38. package/data-contracts/ABIs/TestStorage.json +144 -0
  39. package/data-contracts/ABIs/TestStorageInterface.json +42 -0
  40. package/data-contracts/ABIs/TestUserReplicaSetManager.json +432 -0
  41. package/data-contracts/ABIs/TrackFactory.json +391 -0
  42. package/data-contracts/ABIs/TrackFactoryInterface.json +73 -0
  43. package/data-contracts/ABIs/TrackStorage.json +223 -0
  44. package/data-contracts/ABIs/TrackStorageInterface.json +121 -0
  45. package/data-contracts/ABIs/UpgradeabilityProxy.json +37 -0
  46. package/data-contracts/ABIs/UserFactory.json +657 -0
  47. package/data-contracts/ABIs/UserFactoryInterface.json +65 -0
  48. package/data-contracts/ABIs/UserLibraryFactory.json +334 -0
  49. package/data-contracts/ABIs/UserReplicaSetManager.json +418 -0
  50. package/data-contracts/ABIs/UserStorage.json +233 -0
  51. package/data-contracts/ABIs/UserStorageInterface.json +93 -0
  52. package/data-contracts/signatureSchemas.ts +1236 -0
  53. package/dist/core.d.ts +446 -0
  54. package/dist/core.js +769 -0
  55. package/dist/core.js.map +1 -0
  56. package/dist/index.d.ts +689 -0
  57. package/dist/index.js +72850 -0
  58. package/dist/index.js.map +1 -0
  59. package/eth-contracts/ABIs/Address.json +4 -0
  60. package/eth-contracts/ABIs/AudiusAdminUpgradeabilityProxy.json +105 -0
  61. package/eth-contracts/ABIs/AudiusClaimDistributor.json +4968 -0
  62. package/eth-contracts/ABIs/AudiusToken.json +724 -0
  63. package/eth-contracts/ABIs/BaseUpgradeabilityProxy.json +23 -0
  64. package/eth-contracts/ABIs/Checkpointing.json +4 -0
  65. package/eth-contracts/ABIs/ClaimsManager.json +539 -0
  66. package/eth-contracts/ABIs/Context.json +11 -0
  67. package/eth-contracts/ABIs/DelegateManager.json +989 -0
  68. package/eth-contracts/ABIs/DelegateManagerV2.json +1049 -0
  69. package/eth-contracts/ABIs/DelegateManagerV2Bad.json +1049 -0
  70. package/eth-contracts/ABIs/ERC20.json +252 -0
  71. package/eth-contracts/ABIs/ERC20Burnable.json +287 -0
  72. package/eth-contracts/ABIs/ERC20Detailed.json +270 -0
  73. package/eth-contracts/ABIs/ERC20Mintable.json +364 -0
  74. package/eth-contracts/ABIs/ERC20Pausable.json +397 -0
  75. package/eth-contracts/ABIs/EthRewardsManager.json +174 -0
  76. package/eth-contracts/ABIs/Governance.json +938 -0
  77. package/eth-contracts/ABIs/GovernanceUpgraded.json +953 -0
  78. package/eth-contracts/ABIs/GovernanceV2.json +938 -0
  79. package/eth-contracts/ABIs/IERC20.json +200 -0
  80. package/eth-contracts/ABIs/Initializable.json +4 -0
  81. package/eth-contracts/ABIs/InitializableV2.json +14 -0
  82. package/eth-contracts/ABIs/Migrations.json +71 -0
  83. package/eth-contracts/ABIs/MinterRole.json +91 -0
  84. package/eth-contracts/ABIs/MockAccount.json +62 -0
  85. package/eth-contracts/ABIs/MockDelegateManager.json +55 -0
  86. package/eth-contracts/ABIs/MockStakingCaller.json +259 -0
  87. package/eth-contracts/ABIs/MockWormhole.json +106 -0
  88. package/eth-contracts/ABIs/OpenZeppelinUpgradesAddress.json +4 -0
  89. package/eth-contracts/ABIs/Ownable.json +93 -0
  90. package/eth-contracts/ABIs/Pausable.json +150 -0
  91. package/eth-contracts/ABIs/PauserRole.json +91 -0
  92. package/eth-contracts/ABIs/Proxy.json +10 -0
  93. package/eth-contracts/ABIs/Registry.json +288 -0
  94. package/eth-contracts/ABIs/Roles.json +4 -0
  95. package/eth-contracts/ABIs/SafeERC20.json +4 -0
  96. package/eth-contracts/ABIs/SafeMath.json +4 -0
  97. package/eth-contracts/ABIs/ServiceProviderFactory.json +1153 -0
  98. package/eth-contracts/ABIs/ServiceTypeManager.json +337 -0
  99. package/eth-contracts/ABIs/Staking.json +555 -0
  100. package/eth-contracts/ABIs/StakingUpgraded.json +570 -0
  101. package/eth-contracts/ABIs/TestContract.json +44 -0
  102. package/eth-contracts/ABIs/TrustedNotifierManager.json +265 -0
  103. package/eth-contracts/ABIs/Uint256Helpers.json +4 -0
  104. package/eth-contracts/ABIs/UpgradeabilityProxy.json +40 -0
  105. package/eth-contracts/ABIs/Wormhole.json +45 -0
  106. package/eth-contracts/ABIs/WormholeClient.json +155 -0
  107. package/examples/file.mp3 +0 -0
  108. package/examples/initAudiusLibs.js +86 -0
  109. package/examples/initializeVersions.js +95 -0
  110. package/examples/pic.jpg +0 -0
  111. package/initScripts/configureLocalDiscProv.js +167 -0
  112. package/initScripts/helpers/claim.js +43 -0
  113. package/initScripts/helpers/distributeTokens.js +24 -0
  114. package/initScripts/helpers/spRegistration.js +138 -0
  115. package/initScripts/helpers/utils.js +34 -0
  116. package/initScripts/helpers/version.js +93 -0
  117. package/initScripts/local.js +617 -0
  118. package/initScripts/mainnet.js +131 -0
  119. package/initScripts/manageProdRelayerWallets.js +191 -0
  120. package/package.json +125 -0
  121. package/rollup.config.js +164 -0
  122. package/scripts/AudiusClaimDistributor.json +4968 -0
  123. package/scripts/Wormhole.json +155 -0
  124. package/scripts/addCIDToIpldBlacklist.js +124 -0
  125. package/scripts/circleci-test.sh +53 -0
  126. package/scripts/communityRewards/transferCommunityRewardsToSolana.js +222 -0
  127. package/scripts/ipfs.sh +58 -0
  128. package/scripts/migrate_contracts.sh +25 -0
  129. package/scripts/reset.sh +65 -0
  130. package/scripts/test.sh +77 -0
  131. package/src/api/account.js +670 -0
  132. package/src/api/base.js +122 -0
  133. package/src/api/file.js +168 -0
  134. package/src/api/playlist.js +328 -0
  135. package/src/api/rewards.d.ts +4 -0
  136. package/src/api/rewards.js +682 -0
  137. package/src/api/serviceProvider.js +154 -0
  138. package/src/api/track.js +604 -0
  139. package/src/api/user.js +888 -0
  140. package/src/api/user.test.js +172 -0
  141. package/src/constants.ts +7 -0
  142. package/src/core.ts +3 -0
  143. package/src/index.js +6 -0
  144. package/src/libs.d.ts +3 -0
  145. package/src/libs.js +619 -0
  146. package/src/sanityChecks/addSecondaries.js +40 -0
  147. package/src/sanityChecks/assignReplicaSetIfNecessary.js +10 -0
  148. package/src/sanityChecks/index.d.ts +9 -0
  149. package/src/sanityChecks/index.js +31 -0
  150. package/src/sanityChecks/isCreator.js +73 -0
  151. package/src/sanityChecks/needsRecoveryEmail.js +20 -0
  152. package/src/sanityChecks/rolloverNodes.js +74 -0
  153. package/src/sanityChecks/sanitizeNodes.js +24 -0
  154. package/src/sanityChecks/syncNodes.js +28 -0
  155. package/src/sdk/constants.ts +10 -0
  156. package/src/sdk/index.ts +1 -0
  157. package/src/sdk/oauth/Oauth.ts +265 -0
  158. package/src/sdk/oauth/index.ts +1 -0
  159. package/src/sdk/sdk.ts +102 -0
  160. package/src/service-selection/ServiceSelection.test.ts +320 -0
  161. package/src/service-selection/ServiceSelection.ts +460 -0
  162. package/src/service-selection/constants.ts +14 -0
  163. package/src/service-selection/index.ts +1 -0
  164. package/src/services/ABIDecoder/AudiusABIDecoder.ts +71 -0
  165. package/src/services/ABIDecoder/index.ts +1 -0
  166. package/src/services/comstock/Comstock.ts +39 -0
  167. package/src/services/comstock/index.ts +1 -0
  168. package/src/services/contracts/ContractClient.ts +227 -0
  169. package/src/services/contracts/GovernedContractClient.ts +53 -0
  170. package/src/services/contracts/ProviderSelection.ts +42 -0
  171. package/src/services/creatorNode/CreatorNode.ts +1065 -0
  172. package/src/services/creatorNode/CreatorNodeSelection.test.ts +997 -0
  173. package/src/services/creatorNode/CreatorNodeSelection.ts +488 -0
  174. package/src/services/creatorNode/constants.ts +10 -0
  175. package/src/services/creatorNode/index.ts +2 -0
  176. package/src/services/dataContracts/AudiusContracts.ts +234 -0
  177. package/src/services/dataContracts/IPLDBlacklistFactoryClient.ts +73 -0
  178. package/src/services/dataContracts/PlaylistFactoryClient.ts +370 -0
  179. package/src/services/dataContracts/RegistryClient.ts +95 -0
  180. package/src/services/dataContracts/SocialFeatureFactoryClient.ts +196 -0
  181. package/src/services/dataContracts/TrackFactoryClient.ts +131 -0
  182. package/src/services/dataContracts/UserFactoryClient.ts +351 -0
  183. package/src/services/dataContracts/UserLibraryFactoryClient.ts +115 -0
  184. package/src/services/dataContracts/UserReplicaSetManagerClient.ts +206 -0
  185. package/src/services/dataContracts/index.ts +1 -0
  186. package/src/services/discoveryProvider/DiscoveryProvider.ts +1168 -0
  187. package/src/services/discoveryProvider/DiscoveryProviderSelection.test.ts +536 -0
  188. package/src/services/discoveryProvider/DiscoveryProviderSelection.ts +383 -0
  189. package/src/services/discoveryProvider/constants.ts +13 -0
  190. package/src/services/discoveryProvider/index.ts +1 -0
  191. package/src/services/discoveryProvider/requests.ts +629 -0
  192. package/src/services/ethContracts/AudiusTokenClient.ts +163 -0
  193. package/src/services/ethContracts/ClaimDistributionClient.ts +45 -0
  194. package/src/services/ethContracts/ClaimsManagerClient.ts +102 -0
  195. package/src/services/ethContracts/DelegateManagerClient.ts +480 -0
  196. package/src/services/ethContracts/EthContracts.ts +359 -0
  197. package/src/services/ethContracts/EthRewardsManagerClient.ts +33 -0
  198. package/src/services/ethContracts/GovernanceClient.ts +451 -0
  199. package/src/services/ethContracts/RegistryClient.ts +33 -0
  200. package/src/services/ethContracts/ServiceProviderFactoryClient.ts +691 -0
  201. package/src/services/ethContracts/ServiceTypeManagerClient.ts +112 -0
  202. package/src/services/ethContracts/StakingProxyClient.ts +97 -0
  203. package/src/services/ethContracts/TrustedNotifierManagerClient.ts +101 -0
  204. package/src/services/ethContracts/WormholeClient.ts +97 -0
  205. package/src/services/ethContracts/index.ts +1 -0
  206. package/src/services/ethWeb3Manager/EthWeb3Manager.ts +239 -0
  207. package/src/services/ethWeb3Manager/index.ts +1 -0
  208. package/src/services/hedgehog/Hedgehog.ts +96 -0
  209. package/src/services/hedgehog/index.ts +1 -0
  210. package/src/services/identity/IdentityService.ts +551 -0
  211. package/src/services/identity/index.ts +1 -0
  212. package/src/services/identity/requests.ts +65 -0
  213. package/src/services/schemaValidator/SchemaValidator.ts +105 -0
  214. package/src/services/schemaValidator/index.ts +1 -0
  215. package/src/services/schemaValidator/schemas/trackSchema.json +267 -0
  216. package/src/services/schemaValidator/schemas/userSchema.json +230 -0
  217. package/src/services/solanaAudiusData/errors.ts +20 -0
  218. package/src/services/solanaAudiusData/index.ts +1189 -0
  219. package/src/services/solanaWeb3Manager/errors.js +101 -0
  220. package/src/services/solanaWeb3Manager/index.d.ts +46 -0
  221. package/src/services/solanaWeb3Manager/index.js +655 -0
  222. package/src/services/solanaWeb3Manager/padBNToUint8Array.ts +7 -0
  223. package/src/services/solanaWeb3Manager/rewards.js +941 -0
  224. package/src/services/solanaWeb3Manager/rewardsAttester.ts +1093 -0
  225. package/src/services/solanaWeb3Manager/tokenAccount.js +149 -0
  226. package/src/services/solanaWeb3Manager/transactionHandler.js +345 -0
  227. package/src/services/solanaWeb3Manager/transfer.js +272 -0
  228. package/src/services/solanaWeb3Manager/userBank.js +160 -0
  229. package/src/services/solanaWeb3Manager/utils.d.ts +31 -0
  230. package/src/services/solanaWeb3Manager/utils.js +163 -0
  231. package/src/services/solanaWeb3Manager/wAudio.js +28 -0
  232. package/src/services/solanaWeb3Manager/wAudio.test.js +30 -0
  233. package/src/services/web3Manager/Web3Config.ts +14 -0
  234. package/src/services/web3Manager/Web3Manager.ts +360 -0
  235. package/src/services/web3Manager/XMLHttpRequest.ts +11 -0
  236. package/src/services/web3Manager/index.ts +2 -0
  237. package/src/services/wormhole/index.js +424 -0
  238. package/src/types.ts +8 -0
  239. package/src/userStateManager.ts +53 -0
  240. package/src/utils/apiSigning.ts +51 -0
  241. package/src/utils/captcha.ts +97 -0
  242. package/src/utils/estimateGas.ts +64 -0
  243. package/src/utils/fileHasher.ts +278 -0
  244. package/src/utils/importContractABI.d.ts +9 -0
  245. package/src/utils/importContractABI.js +19 -0
  246. package/src/utils/index.ts +11 -0
  247. package/src/utils/multiProvider.ts +72 -0
  248. package/src/utils/network.test.ts +127 -0
  249. package/src/utils/network.ts +308 -0
  250. package/src/utils/promiseFight.test.ts +87 -0
  251. package/src/utils/promiseFight.ts +36 -0
  252. package/src/utils/signatures.ts +139 -0
  253. package/src/utils/types.ts +34 -0
  254. package/src/utils/utils.test.ts +36 -0
  255. package/src/utils/utils.ts +235 -0
  256. package/src/utils/uuid.ts +14 -0
  257. package/src/web3.d.ts +9 -0
  258. package/src/web3.js +8 -0
  259. package/tests/assets/static_image.png +0 -0
  260. package/tests/assets/static_text.txt +1 -0
  261. package/tests/audiusTokenClientTest.js +37 -0
  262. package/tests/creatorNodeTest.js +19 -0
  263. package/tests/fileHasherTest.js +125 -0
  264. package/tests/governanceTest.js +382 -0
  265. package/tests/helpers.js +105 -0
  266. package/tests/index.js +14 -0
  267. package/tests/playlistClientTest.js +157 -0
  268. package/tests/providerSelectionTest.js +241 -0
  269. package/tests/registryClientTest.js +19 -0
  270. package/tests/rewardsAttesterTest.js +373 -0
  271. package/tests/serviceTypeManagerClientTest.js +33 -0
  272. package/tests/socialFeatureClientTest.js +79 -0
  273. package/tests/stakingTest.js +302 -0
  274. package/tests/trackClientTest.js +86 -0
  275. package/tests/userClientTest.js +121 -0
  276. package/tsconfig.json +10 -0
  277. package/types/@audius-hedgehog/index.d.ts +39 -0
  278. package/types/abi-decoder/index.d.ts +41 -0
@@ -0,0 +1,79 @@
1
+ const assert = require('assert')
2
+ let helpers = require('./helpers')
3
+ let { Utils } = require('../src/utils')
4
+
5
+ let audiusInstance = helpers.audiusInstance
6
+
7
+ before(async function () {
8
+ await audiusInstance.init()
9
+ })
10
+
11
+ it('Should add + delete track repost', async function () {
12
+ // add creator
13
+ const handle = 'sid' + Math.floor(Math.random() * 10000000)
14
+ const creatorId = (await audiusInstance.contracts.UserFactoryClient.addUser(handle)).userId
15
+ assert.ok(creatorId && Number.isInteger(creatorId), 'invalid creatorId')
16
+
17
+ // add track
18
+ const cid = helpers.constants.trackMetadataCID
19
+ const trackMultihashDecoded = Utils.decodeMultihash(cid)
20
+ const { trackId } = await audiusInstance.contracts.TrackFactoryClient.addTrack(
21
+ creatorId,
22
+ trackMultihashDecoded.digest,
23
+ trackMultihashDecoded.hashFn,
24
+ trackMultihashDecoded.size
25
+ )
26
+ assert.ok(trackId && Number.isInteger(trackId), 'invalid trackId')
27
+ const track = await audiusInstance.contracts.TrackFactoryClient.getTrack(trackId)
28
+ assert.strictEqual(track.multihashDigest, trackMultihashDecoded.digest, 'Unexpected track multihash digest')
29
+
30
+ // add track repost
31
+ const addTrackRepostTx = await audiusInstance.contracts.SocialFeatureFactoryClient.addTrackRepost(creatorId, trackId)
32
+ assert.ok('TrackRepostAdded' in addTrackRepostTx.events, 'Did not find TrackRepostAdded event in transaction')
33
+
34
+ // delete track repost
35
+ const deleteTrackRepostTx = await audiusInstance.contracts.SocialFeatureFactoryClient.deleteTrackRepost(creatorId, trackId)
36
+ assert.ok('TrackRepostDeleted' in deleteTrackRepostTx.events, 'Did not find TrackRepostDeleted event in transaction')
37
+ })
38
+
39
+ it('Should add + delete playlist repost', async function () {
40
+ // add creator
41
+ const handle = 'sid' + Math.floor(Math.random() * 10000000)
42
+ const creatorId = (await audiusInstance.contracts.UserFactoryClient.addUser(handle)).userId
43
+ assert.ok(creatorId && Number.isInteger(creatorId), 'invalid creatorId')
44
+
45
+ // add playlist
46
+ const { playlistId } = await audiusInstance.contracts.PlaylistFactoryClient.createPlaylist(
47
+ creatorId,
48
+ 'initialPlaylistName',
49
+ false,
50
+ false,
51
+ [])
52
+ assert.ok(playlistId && Number.isInteger(playlistId), 'invalid playlistId')
53
+
54
+ // add playlist repost
55
+ const addPlaylistRepostTx = await audiusInstance.contracts.SocialFeatureFactoryClient.addPlaylistRepost(creatorId, playlistId)
56
+ assert.ok('PlaylistRepostAdded' in addPlaylistRepostTx.events, 'Did not find PlaylistRepostAdded event in transaction')
57
+
58
+ // delete playlist repost
59
+ const deletePlaylistRepostTx = await audiusInstance.contracts.SocialFeatureFactoryClient.deletePlaylistRepost(creatorId, playlistId)
60
+ assert.ok('PlaylistRepostDeleted' in deletePlaylistRepostTx.events, 'Did not find PlaylistRepostDeleted event in transaction')
61
+ })
62
+
63
+ it('Should add + delete user follow', async function () {
64
+ // add 2 users
65
+ const handle1 = '2sid_' + Math.floor(Math.random() + 10000000)
66
+ const handle2 = '3sid_' + Math.floor(Math.random() + 10000000)
67
+ const userId1 = (await audiusInstance.contracts.UserFactoryClient.addUser(handle1)).userId
68
+ const userId2 = (await audiusInstance.contracts.UserFactoryClient.addUser(handle2)).userId
69
+ assert.ok(userId1 && Number.isInteger(userId1), 'invalid userId')
70
+ assert.ok(userId2 && Number.isInteger(userId2), 'invalid userId')
71
+
72
+ // add user follow
73
+ const addUserFollowTx = await audiusInstance.contracts.SocialFeatureFactoryClient.addUserFollow(userId1, userId2)
74
+ assert.ok('UserFollowAdded' in addUserFollowTx.events, 'Did not find UserFollowAdded event in transaction')
75
+
76
+ // delete user follow
77
+ const deleteUserFollowTx = await audiusInstance.contracts.SocialFeatureFactoryClient.deleteUserFollow(userId1, userId2)
78
+ assert.ok('UserFollowDeleted' in deleteUserFollowTx.events, 'Did not find UserFollowDeleted event in transaction')
79
+ })
@@ -0,0 +1,302 @@
1
+ const assert = require('assert')
2
+ const nock = require('nock')
3
+ const helpers = require('./helpers')
4
+ const { time } = require('@openzeppelin/test-helpers')
5
+
6
+ // const audiusConfig = helpers.audiusLibsConfig
7
+ const { getRandomLocalhost, audiusInstance: audius0 } = helpers
8
+ const initializeLibConfig = helpers.initializeLibConfig
9
+ const ethContractsConfig = require('../eth-contracts/config.json')
10
+ const AudiusLibs = require('../src/index');
11
+ const { convertAudsToWeiBN } = require('../initScripts/helpers/utils');
12
+ const { initial } = require('lodash')
13
+ const { deregisterSPEndpoint } = require('./helpers')
14
+
15
+ let token
16
+ let ownerWallet
17
+ let accounts
18
+ let audius1
19
+ let audius2
20
+ let sp1
21
+ let sp2
22
+
23
+ const assertThrows = async (blockOrPromise, expectedErrorCode, expectedReason) => {
24
+ try {
25
+ (typeof blockOrPromise === 'function') ? await blockOrPromise() : await blockOrPromise
26
+ } catch (error) {
27
+ assert(error.message.search(expectedErrorCode) > -1, `Expected error code "${expectedErrorCode}" but failed with "${error}" instead.`)
28
+ return error
29
+ }
30
+ // assert.fail() for some reason does not have its error string printed 🤷
31
+ assert(false, `Expected "${expectedErrorCode}"${expectedReason ? ` (with reason: "${expectedReason}")` : ''} but it did not fail`)
32
+ }
33
+
34
+ const assertRevert = async (blockOrPromise, expectedReason) => {
35
+ const error = await assertThrows(blockOrPromise, 'revert', expectedReason)
36
+ if (!expectedReason) {
37
+ return
38
+ }
39
+ const expectedMsgFound = error.message.indexOf(expectedReason) >= 0
40
+ assert.equal(expectedMsgFound, true, 'Expected revert reason not found')
41
+ }
42
+
43
+ describe('Staking tests', () => {
44
+ let testServiceType = 'discovery-provider'
45
+
46
+ before(async function () {
47
+ await audius0.init()
48
+ token = audius0.ethContracts.AudiusTokenClient
49
+ accounts = await audius0.ethWeb3Manager.getWeb3().eth.getAccounts()
50
+
51
+ // Set lockup durations to a small number so we can reach it
52
+ // in a reasonable test time
53
+ await audius0.ethContracts.GovernanceClient.setVotingPeriod(1)
54
+ await audius0.ethContracts.GovernanceClient.setExecutionDelay(0)
55
+ await audius0.ethContracts.ServiceProviderFactoryClient.updateDecreaseStakeLockupDuration(10)
56
+ await audius0.ethContracts.DelegateManagerClient.updateUndelegateLockupDuration(10)
57
+
58
+ ownerWallet = accounts[0]
59
+ sp1 = accounts[1]
60
+ sp2 = accounts[2]
61
+
62
+ // Initialize more lib instances
63
+ let libsConfig1 = await initializeLibConfig(sp1)
64
+ assert(
65
+ ethContractsConfig.ownerWallet !== libsConfig1.ownerWallet,
66
+ 'New wallet addr')
67
+ audius1 = new AudiusLibs(libsConfig1)
68
+ await audius1.init()
69
+
70
+ let libsConfig2 = await initializeLibConfig(accounts[2])
71
+ assert(
72
+ ethContractsConfig.ownerWallet !== libsConfig2.ownerWallet,
73
+ 'New wallet addr')
74
+ audius2 = new AudiusLibs(libsConfig2)
75
+ await audius2.init()
76
+
77
+ // Refund test accounts
78
+ await token.transfer(sp1, convertAudsToWeiBN(audius1.ethWeb3Manager.getWeb3(), 2000000))
79
+ await token.transfer(sp2, convertAudsToWeiBN(audius1.ethWeb3Manager.getWeb3(), 2000000))
80
+
81
+ })
82
+
83
+ it('initial staking contract state', async function () {
84
+ let tokenAddr = await audius0.ethContracts.StakingProxyClient.token()
85
+ assert(token.contractAddress, tokenAddr, 'Expect correct token address from staking proxy')
86
+ let supportsHistory = await audius0.ethContracts.StakingProxyClient.supportsHistory()
87
+ assert.equal(supportsHistory, true, 'History support required')
88
+ assert.equal(await audius0.ethContracts.StakingProxyClient.totalStaked(), 0, 'Expect no stake on init')
89
+ })
90
+
91
+ describe('Registration', () => {
92
+ let initialSPBalance
93
+ let testEndpt
94
+ let testEndpt2
95
+ let initialStake
96
+ let defaultStake
97
+
98
+ beforeEach(async () => {
99
+
100
+ // Clear any accounts registered w/the audius1 account
101
+ initialSPBalance = await token.balanceOf(sp1)
102
+ testEndpt = getRandomLocalhost()
103
+
104
+ let path = '/version'
105
+ let response = {
106
+ service: testServiceType,
107
+ version : '0.0.1'
108
+ }
109
+
110
+ if (testServiceType === 'discovery-provider') {
111
+ path = '/health_check'
112
+ response = {data: {...response}}
113
+ }
114
+
115
+ nock(testEndpt)
116
+ .get(path)
117
+ .reply(200, response)
118
+
119
+ // Cache stake amount prior to register
120
+ initialStake = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
121
+ defaultStake = convertAudsToWeiBN(audius1.ethWeb3Manager.getWeb3(), 210000)
122
+
123
+ // Register
124
+ let tx = await audius1.ethContracts.ServiceProviderFactoryClient.register(
125
+ testServiceType,
126
+ testEndpt,
127
+ defaultStake
128
+ )
129
+ })
130
+
131
+ afterEach(async () => {
132
+ await deregisterSPEndpoint(audius1, sp1, testServiceType)
133
+ })
134
+
135
+ it('register service provider + stake', async function () {
136
+ const newBalance = await token.balanceOf(sp1)
137
+ const expectedNewBalance = initialSPBalance.sub(defaultStake)
138
+ assert(
139
+ newBalance.eq(expectedNewBalance),
140
+ 'Expect decrease in bal'
141
+ )
142
+
143
+ const staked = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
144
+ const expectedStaked = initialStake.add(defaultStake)
145
+ assert(
146
+ staked.eq(expectedStaked),
147
+ 'Expect increase in stake'
148
+ )
149
+ })
150
+
151
+ it('increases service provider stake', async function () {
152
+ let preIncreaseBalance = await token.balanceOf(sp1)
153
+ let preIncreaseStake = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
154
+ let tx = await audius1.ethContracts.ServiceProviderFactoryClient.increaseStake(defaultStake)
155
+
156
+ const newBalance = await token.balanceOf(sp1)
157
+ const expectedBalance = preIncreaseBalance.sub(defaultStake)
158
+ assert(
159
+ newBalance.eq(expectedBalance),
160
+ 'Expect decrease in balance'
161
+ )
162
+ const totalStaked = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
163
+ const expectedStaked = preIncreaseStake.add(defaultStake)
164
+ assert(
165
+ totalStaked.eq(expectedStaked),
166
+ 'Expect increase in stake'
167
+ )
168
+
169
+ // Confirm revert occurred for incorrect owner
170
+ assertRevert(
171
+ audius2.ethContracts.ServiceProviderFactoryClient.increaseStake(
172
+ defaultStake
173
+ ),
174
+ 'incorrect owner'
175
+ )
176
+ })
177
+
178
+ it('decreases service provider stake', async () => {
179
+ const preDecreaseBal = await token.balanceOf(sp1)
180
+ const preDecreaseStake = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
181
+
182
+ const decreaseAmount = audius1.ethWeb3Manager.getWeb3().utils.toBN(10000)
183
+
184
+ const lockupExpiryBlock = await audius1.ethContracts.ServiceProviderFactoryClient.requestDecreaseStake(
185
+ decreaseAmount
186
+ )
187
+ await time.advanceBlockTo(lockupExpiryBlock)
188
+
189
+ await audius1.ethContracts.ServiceProviderFactoryClient.decreaseStake(
190
+ lockupExpiryBlock
191
+ )
192
+
193
+ const newBalance = await token.balanceOf(sp1)
194
+ const expectedBalance = preDecreaseBal.add(decreaseAmount)
195
+ assert(
196
+ newBalance.eq(expectedBalance),
197
+ 'Expect increase in balance'
198
+ )
199
+
200
+ const totalStaked = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
201
+ const expectedStaked = preDecreaseStake.sub(decreaseAmount)
202
+ assert(
203
+ totalStaked.eq(expectedStaked),
204
+ 'Expect decrease in stake'
205
+ )
206
+
207
+ assertRevert(
208
+ audius2.ethContracts.ServiceProviderFactoryClient.decreaseStake(
209
+ decreaseAmount
210
+ ),
211
+ 'incorrect owner'
212
+ )
213
+
214
+ const currentStake = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
215
+ // Configure amount greater than current stake to try and decrease
216
+ const increaseAmt = audius1.ethWeb3Manager.getWeb3().utils.toBN(10)
217
+ const invalidDecreaseAmount = currentStake.add(increaseAmt)
218
+ assertRevert(
219
+ audius1.ethContracts.ServiceProviderFactoryClient.decreaseStake(
220
+ invalidDecreaseAmount
221
+ ),
222
+ 'subtraction overflow'
223
+ )
224
+ })
225
+ })
226
+
227
+ describe('Deregistration', () => {
228
+ beforeEach(async () => {
229
+
230
+ // Clear any accounts registered w/the audius1 account
231
+ initialSPBalance = await token.balanceOf(sp1)
232
+ testEndpt = getRandomLocalhost()
233
+
234
+ let path = '/version'
235
+ let response = {
236
+ service: testServiceType,
237
+ version : '0.0.1'
238
+ }
239
+
240
+ if (testServiceType === 'discovery-provider') {
241
+ path = '/health_check'
242
+ response = {data: {...response}}
243
+ }
244
+
245
+ nock(testEndpt)
246
+ .get(path)
247
+ .reply(200, response)
248
+
249
+ // Cache stake amount prior to register
250
+ initialStake = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
251
+ defaultStake = convertAudsToWeiBN(audius1.ethWeb3Manager.getWeb3(), 210000)
252
+
253
+ // Register
254
+ let tx = await audius1.ethContracts.ServiceProviderFactoryClient.register(
255
+ testServiceType,
256
+ testEndpt,
257
+ defaultStake
258
+ )
259
+ })
260
+
261
+ it('deregisters service provider + recover stake', async function () {
262
+ const initialBalance = await token.balanceOf(sp1)
263
+ const preDeregisterStake = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
264
+
265
+ nock(testEndpt)
266
+ .get('/version')
267
+ .reply(200, {
268
+ service: testServiceType,
269
+ version: '0.0.1'
270
+ })
271
+
272
+ const tx = await audius1.ethContracts.ServiceProviderFactoryClient.deregister(
273
+ testServiceType,
274
+ testEndpt
275
+ )
276
+
277
+ const lockupExpiryBlock = await audius1.ethContracts.ServiceProviderFactoryClient.getLockupExpiry(
278
+ audius1.ethWeb3Manager.getWalletAddress()
279
+ )
280
+
281
+ await time.advanceBlockTo(lockupExpiryBlock)
282
+
283
+ await audius1.ethContracts.ServiceProviderFactoryClient.decreaseStake(
284
+ lockupExpiryBlock
285
+ )
286
+
287
+ const newBalance = await token.balanceOf(sp1)
288
+ const expectedBalance = initialBalance.add(preDeregisterStake)
289
+ assert(
290
+ newBalance.eq(expectedBalance),
291
+ 'Expect stake returned after deregistration'
292
+ )
293
+
294
+ const totalStaked = await audius1.ethContracts.StakingProxyClient.totalStakedFor(sp1)
295
+ const expectedStaked = preDeregisterStake.sub(defaultStake)
296
+ assert(
297
+ totalStaked.isZero(),
298
+ 'Expect decrease in stake after deregistration'
299
+ )
300
+ })
301
+ })
302
+ })
@@ -0,0 +1,86 @@
1
+ const assert = require('assert')
2
+ let helpers = require('./helpers')
3
+ let { Utils } = require('../src/utils')
4
+
5
+ let audiusInstance = helpers.audiusInstance
6
+
7
+ let trackMultihashDecoded = Utils.decodeMultihash(helpers.constants.trackMetadataCID)
8
+ let trackMultihashDecoded2 = Utils.decodeMultihash(helpers.constants.trackMetadataCID2)
9
+
10
+ let creatorId1
11
+ let creatorId2
12
+ let trackId1
13
+ let trackId2
14
+
15
+ before(async function () {
16
+ await audiusInstance.init()
17
+ })
18
+
19
+ it('should call getTrack on invalid value and return empty', async function () {
20
+ let track = await audiusInstance.contracts.TrackFactoryClient.getTrack(0)
21
+ assert.strictEqual(track.multihashDigest, helpers.constants['0x0'])
22
+ })
23
+
24
+ it('should call addTrack', async function () {
25
+ // Add creator so we have creatorId
26
+ let handle = 'dheeraj' + Math.floor(Math.random() * 10000000)
27
+
28
+ creatorId1 = (await audiusInstance.contracts.UserFactoryClient.addUser(handle)).userId
29
+
30
+ if (creatorId1 && Number.isInteger(creatorId1)) {
31
+ trackId1 = (await audiusInstance.contracts.TrackFactoryClient.addTrack(
32
+ creatorId1,
33
+ trackMultihashDecoded.digest,
34
+ trackMultihashDecoded.hashFn,
35
+ trackMultihashDecoded.size
36
+ )).trackId
37
+ let track = await audiusInstance.contracts.TrackFactoryClient.getTrack(trackId1)
38
+ assert.strictEqual(track.multihashDigest, trackMultihashDecoded.digest)
39
+ } else throw new Error('creatorId is not a valid integer')
40
+ })
41
+
42
+ it('should call updateTrack', async function () {
43
+ // Add creator so we have creatorId
44
+ const handle = 'skippy' + Math.floor(Math.random() * 10000000)
45
+
46
+ creatorId2 = (await audiusInstance.contracts.UserFactoryClient.addUser(handle)).userId
47
+
48
+ if (creatorId2 && Number.isInteger(creatorId2)) {
49
+ // add track
50
+ trackId1 = (await audiusInstance.contracts.TrackFactoryClient.addTrack(
51
+ creatorId2,
52
+ trackMultihashDecoded.digest,
53
+ trackMultihashDecoded.hashFn,
54
+ trackMultihashDecoded.size
55
+ )).trackId
56
+ let track = await audiusInstance.contracts.TrackFactoryClient.getTrack(trackId1)
57
+ assert.strictEqual(track.multihashDigest, trackMultihashDecoded.digest)
58
+
59
+ // update track
60
+ await audiusInstance.contracts.TrackFactoryClient.updateTrack(
61
+ trackId1,
62
+ creatorId2,
63
+ trackMultihashDecoded2.digest,
64
+ trackMultihashDecoded2.hashFn,
65
+ trackMultihashDecoded2.size
66
+ )
67
+ track = await audiusInstance.contracts.TrackFactoryClient.getTrack(trackId1)
68
+ assert.strictEqual(track.multihashDigest, trackMultihashDecoded2.digest)
69
+ } else throw new Error('creatorId is not a valid integer')
70
+ })
71
+
72
+ it('should call deleteTrack', async function () {
73
+ // add track
74
+ trackId2 = (await audiusInstance.contracts.TrackFactoryClient.addTrack(
75
+ creatorId2,
76
+ trackMultihashDecoded.digest,
77
+ trackMultihashDecoded.hashFn,
78
+ trackMultihashDecoded.size
79
+ )).trackId
80
+ let track = await audiusInstance.contracts.TrackFactoryClient.getTrack(trackId2)
81
+ assert.strictEqual(track.multihashDigest, trackMultihashDecoded.digest)
82
+
83
+ // delete track
84
+ let { trackId } = await audiusInstance.contracts.TrackFactoryClient.deleteTrack(trackId2)
85
+ assert.strictEqual(trackId, trackId2)
86
+ })
@@ -0,0 +1,121 @@
1
+ const assert = require('assert')
2
+ let helpers = require('./helpers')
3
+ let { Utils } = require('../src/utils')
4
+
5
+ let audiusInstance = helpers.audiusInstance
6
+ let handle = 'handle' + Math.floor(Math.random() * 1000000)
7
+
8
+ before(async function () {
9
+ await audiusInstance.init()
10
+ })
11
+
12
+ it('should call getUser on invalid value and verify blockchain is empty', async function () {
13
+ let creator = await audiusInstance.contracts.UserFactoryClient.getUser(0)
14
+ assert.strictEqual(creator.wallet, '0x0000000000000000000000000000000000000000')
15
+ })
16
+
17
+ it('should verify handle is valid', async function () {
18
+ let handleIsValid = await audiusInstance.contracts.UserFactoryClient.handleIsValid(handle)
19
+ assert.strictEqual(handleIsValid, true, 'Handle is valid')
20
+ })
21
+
22
+ it('should call addUser and verify new creator', async function () {
23
+ let metadata = {
24
+ 'wallet': helpers.constants.wallet,
25
+ 'is_creator': true,
26
+ 'name': 'Creator Name' + Math.floor(Math.random() * 1000000),
27
+ 'handle': handle,
28
+ 'profile_picture': helpers.constants.trackMetadataCID,
29
+ 'cover_photo': helpers.constants.trackMetadataCID,
30
+ 'bio': 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.',
31
+ 'location': 'San Francisco',
32
+ 'creator_node_endpoint': helpers.constants.creatorNodeURL1,
33
+ 'is_verified': false
34
+ }
35
+
36
+ const addUserResp = await audiusInstance.contracts.UserFactoryClient.addUser(metadata.handle)
37
+ const userId = addUserResp.userId
38
+ const creator = await audiusInstance.contracts.UserFactoryClient.getUser(userId)
39
+ const creatorMetadataMultihashDecoded = Utils.decodeMultihash(helpers.constants.creatorMetadataCID)
40
+ const profilePictureMultihashDecoded = Utils.decodeMultihash(metadata.profile_picture)
41
+ const coverPhotoMultihashDecoded = Utils.decodeMultihash(metadata.cover_photo)
42
+
43
+ assert.strictEqual(metadata.handle, Utils.hexToUtf8(creator.handle))
44
+
45
+ const updateMultihashResp = await audiusInstance.contracts.UserFactoryClient.updateMultihash(
46
+ userId, creatorMetadataMultihashDecoded.digest
47
+ )
48
+ assert.strictEqual(
49
+ updateMultihashResp.multihashDigest,
50
+ creatorMetadataMultihashDecoded.digest,
51
+ `Transaction failed - ${creatorMetadataMultihashDecoded.digest}`
52
+ )
53
+
54
+ const updateNameResp = await audiusInstance.contracts.UserFactoryClient.updateName(
55
+ userId, metadata.name
56
+ )
57
+ assert.deepStrictEqual(
58
+ updateNameResp.name,
59
+ metadata.name,
60
+ `Transaction failed - ${metadata.name}`
61
+ )
62
+
63
+ const updateLocationResp = await audiusInstance.contracts.UserFactoryClient.updateLocation(
64
+ userId, metadata.location
65
+ )
66
+ assert.deepStrictEqual(
67
+ updateLocationResp.location,
68
+ metadata.location,
69
+ `Transaction failed - ${metadata.location}`
70
+ )
71
+
72
+ const updateBioResp = await audiusInstance.contracts.UserFactoryClient.updateBio(
73
+ userId, metadata.bio
74
+ )
75
+ assert.deepStrictEqual(
76
+ updateBioResp.bio,
77
+ metadata.bio,
78
+ `Transaction failed - ${metadata.bio}`
79
+ )
80
+
81
+ const updateProfilePhotoResp = await audiusInstance.contracts.UserFactoryClient.updateProfilePhoto(
82
+ userId, profilePictureMultihashDecoded.digest
83
+ )
84
+ assert.deepStrictEqual(
85
+ updateProfilePhotoResp.profilePhotoMultihashDigest,
86
+ profilePictureMultihashDecoded.digest,
87
+ `Transaction failed - ${profilePictureMultihashDecoded.digest}`
88
+ )
89
+
90
+ const updateCoverPhotoResp = await audiusInstance.contracts.UserFactoryClient.updateCoverPhoto(
91
+ userId, coverPhotoMultihashDecoded.digest
92
+ )
93
+ assert.deepStrictEqual(
94
+ updateCoverPhotoResp.coverPhotoMultihashDigest,
95
+ coverPhotoMultihashDecoded.digest,
96
+ `Transaction failed - ${coverPhotoMultihashDecoded.digest}`
97
+ )
98
+
99
+ const updateIsCreatorResp = await audiusInstance.contracts.UserFactoryClient.updateIsCreator(
100
+ userId, metadata.is_creator
101
+ )
102
+ assert.deepStrictEqual(
103
+ updateIsCreatorResp.isCreator,
104
+ metadata.is_creator,
105
+ `Transaction failed - ${metadata.is_creator}`
106
+ )
107
+
108
+ const updateCreatorNodeEndpointResp = await audiusInstance.contracts.UserFactoryClient.updateCreatorNodeEndpoint(
109
+ userId, metadata.creator_node_endpoint
110
+ )
111
+ assert.deepStrictEqual(
112
+ updateCreatorNodeEndpointResp.creatorNodeEndpoint,
113
+ metadata.creator_node_endpoint,
114
+ `Transaction failed - ${metadata.creator_node_endpoint}`
115
+ )
116
+ })
117
+
118
+ it('should verify handle is not valid', async function () {
119
+ let handleIsValid = await audiusInstance.contracts.UserFactoryClient.handleIsValid(handle)
120
+ assert.strictEqual(handleIsValid, false, 'Handle is not valid')
121
+ })
package/tsconfig.json ADDED
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "@tsconfig/node16-strictest/tsconfig.json",
3
+ "compilerOptions": {
4
+ "lib": ["es2021", "dom"],
5
+ "checkJs": false,
6
+ "resolveJsonModule": true,
7
+ "typeRoots": ["./types", "./node_modules/@types"],
8
+ "exactOptionalPropertyTypes": false
9
+ }
10
+ }
@@ -0,0 +1,39 @@
1
+ /* eslint-disable @typescript-eslint/no-extraneous-class */
2
+ declare module '@audius/hedgehog' {
3
+ import type { IdentityService } from '../../src/services/identity'
4
+ import type Wallet from 'ethereumjs-wallet'
5
+
6
+ type RecoveryInfo = {
7
+ login: string
8
+ host: string
9
+ }
10
+
11
+ export class Hedgehog {
12
+ wallet: Wallet
13
+ getFn: IdentityService['getFn']
14
+ setAuthFn: IdentityService['setAuthFn']
15
+ setUserFn: IdentityService['setUserFn']
16
+ identityService: IdentityService
17
+ constructor(
18
+ getFn: IdentityService['getFn'],
19
+ setAuthFn: IdentityService['setAuthFn'],
20
+ setUserFn: IdentityService['setUserFn'],
21
+ useLocalStorage: boolean
22
+ ): void
23
+ async login(email: string, password: string): Promise<Wallet>
24
+ async generateRecoveryInfo(): Promise<RecoveryInfo>
25
+ getWallet(): Wallet
26
+ async createWalletObj(passwordEntropy: string): Promise<Wallet>
27
+ }
28
+
29
+ export class WalletManager {
30
+ static async createAuthLookupKey(email: string, password: string)
31
+ static async decryptCipherTextAndRetrieveWallet(
32
+ password: string,
33
+ iv: string,
34
+ cipherText: string
35
+ ): Promise<{ walletObj: Wallet; entropy: string }>
36
+ static async getEntropyFromLocalStorage(): Promise<string>
37
+ static setEntropyInLocalStorage(entropy: string): void
38
+ }
39
+ }
@@ -0,0 +1,41 @@
1
+ declare module 'abi-decoder' {
2
+ import { Log } from 'web3-core'
3
+ import { AbiItem } from 'web3-utils'
4
+
5
+ export interface Input {
6
+ [index: string]: any
7
+ name: string
8
+ type: string
9
+ indexed?: boolean
10
+ }
11
+
12
+ export interface Output {
13
+ [index: string]: any
14
+ name: string
15
+ type: string
16
+ }
17
+
18
+ export interface Param {
19
+ name: string
20
+ type: string
21
+ value: string
22
+ }
23
+
24
+ export interface DecodedLog {
25
+ address: string
26
+ name: string
27
+ events: Param[]
28
+ }
29
+
30
+ export interface DecodedMethod {
31
+ name: string
32
+ params: Param[]
33
+ }
34
+
35
+ export function getABIs(): AbiItem[]
36
+ export function addABI(abi: AbiItem[]): void
37
+ export function getMethodIDs(): { [index: string]: AbiItem }
38
+ export function decodeMethod(input: string): DecodedMethod
39
+ export function decodeLogs(input: Log[]): DecodedLog
40
+ export function removeABI(abi: AbiItem[]): void
41
+ }