@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,112 @@
|
|
|
1
|
+
import { Utils } from '../../utils'
|
|
2
|
+
import { GovernedContractClient } from '../contracts/GovernedContractClient'
|
|
3
|
+
|
|
4
|
+
export class ServiceTypeManagerClient extends GovernedContractClient {
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* @param serviceType Type of service to set the version, either `discovery-node` or `content-node`
|
|
8
|
+
* @param serviceVersion Version string to set on chain
|
|
9
|
+
* @param privateKey Optional privateKey to pass along to web3Manager sendTransaction
|
|
10
|
+
* @param dryRun Optional parameter to return the generated parameters without sending tx
|
|
11
|
+
* @returns comma-separated String of serviceType and serviceVersion if dryRun; else response from web3Manager.sendTransaction
|
|
12
|
+
*/
|
|
13
|
+
async setServiceVersion(
|
|
14
|
+
serviceType: string,
|
|
15
|
+
serviceVersion: string,
|
|
16
|
+
privateKey: string | null = null,
|
|
17
|
+
dryRun = false
|
|
18
|
+
) {
|
|
19
|
+
const method = await this.getGovernedMethod(
|
|
20
|
+
'setServiceVersion',
|
|
21
|
+
Utils.utf8ToHex(serviceType),
|
|
22
|
+
Utils.utf8ToHex(serviceVersion)
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
if (dryRun) {
|
|
26
|
+
return `${Utils.utf8ToHex(serviceType)},${Utils.utf8ToHex(
|
|
27
|
+
serviceVersion
|
|
28
|
+
)}`
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
return await this.web3Manager.sendTransaction(
|
|
32
|
+
method,
|
|
33
|
+
await this.governanceClient.getAddress(),
|
|
34
|
+
privateKey
|
|
35
|
+
)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async addServiceType(
|
|
39
|
+
serviceType: string,
|
|
40
|
+
serviceTypeMin: string,
|
|
41
|
+
serviceTypeMax: string,
|
|
42
|
+
privateKey: string | null = null
|
|
43
|
+
) {
|
|
44
|
+
const method = await this.getGovernedMethod(
|
|
45
|
+
'addServiceType',
|
|
46
|
+
Utils.utf8ToHex(serviceType),
|
|
47
|
+
serviceTypeMin,
|
|
48
|
+
serviceTypeMax
|
|
49
|
+
)
|
|
50
|
+
|
|
51
|
+
return await this.web3Manager.sendTransaction(
|
|
52
|
+
method,
|
|
53
|
+
await this.governanceClient.getAddress(),
|
|
54
|
+
privateKey
|
|
55
|
+
)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async getValidServiceTypes() {
|
|
59
|
+
const method = await this.getMethod('getValidServiceTypes')
|
|
60
|
+
const types: string[] = await method.call()
|
|
61
|
+
return types.map((t) => Utils.hexToUtf8(t))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async getCurrentVersion(serviceType: string) {
|
|
65
|
+
const method = await this.getMethod(
|
|
66
|
+
'getCurrentVersion',
|
|
67
|
+
Utils.utf8ToHex(serviceType)
|
|
68
|
+
)
|
|
69
|
+
const hexVersion = await method.call()
|
|
70
|
+
return Utils.hexToUtf8(hexVersion)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
async getVersion(serviceType: string, serviceTypeIndex: number) {
|
|
74
|
+
const serviceTypeBytes32 = Utils.utf8ToHex(serviceType)
|
|
75
|
+
const method = await this.getMethod(
|
|
76
|
+
'getVersion',
|
|
77
|
+
serviceTypeBytes32,
|
|
78
|
+
serviceTypeIndex
|
|
79
|
+
)
|
|
80
|
+
const version = await method.call()
|
|
81
|
+
return Utils.hexToUtf8(version)
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async getNumberOfVersions(serviceType: string) {
|
|
85
|
+
const method = await this.getMethod(
|
|
86
|
+
'getNumberOfVersions',
|
|
87
|
+
Utils.utf8ToHex(serviceType)
|
|
88
|
+
)
|
|
89
|
+
return parseInt(await method.call())
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* @notice Add a new service type
|
|
94
|
+
* @returns {
|
|
95
|
+
* isValid: Is the types type is isValid
|
|
96
|
+
* minStake: minimum stake for service type
|
|
97
|
+
* maxStake: minimum stake for service type
|
|
98
|
+
* }
|
|
99
|
+
*/
|
|
100
|
+
async getServiceTypeInfo(serviceType: string) {
|
|
101
|
+
const method = await this.getMethod(
|
|
102
|
+
'getServiceTypeInfo',
|
|
103
|
+
Utils.utf8ToHex(serviceType)
|
|
104
|
+
)
|
|
105
|
+
const response = await method.call()
|
|
106
|
+
return {
|
|
107
|
+
isValid: response[0],
|
|
108
|
+
minStake: Utils.toBN(response[1]),
|
|
109
|
+
maxStake: Utils.toBN(response[2])
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type { ContractABI, Logger } from '../../utils'
|
|
2
|
+
import { ContractClient, GetRegistryAddress } from '../contracts/ContractClient'
|
|
3
|
+
import type { EthWeb3Manager } from '../ethWeb3Manager'
|
|
4
|
+
import type { AudiusTokenClient } from './AudiusTokenClient'
|
|
5
|
+
import type BN from 'bn.js'
|
|
6
|
+
|
|
7
|
+
export class StakingProxyClient extends ContractClient {
|
|
8
|
+
audiusTokenClient: AudiusTokenClient
|
|
9
|
+
toBN: (value: string | number) => BN
|
|
10
|
+
|
|
11
|
+
constructor(
|
|
12
|
+
ethWeb3Manager: EthWeb3Manager,
|
|
13
|
+
contractABI: ContractABI['abi'],
|
|
14
|
+
contractRegistryKey: string,
|
|
15
|
+
getRegistryAddress: GetRegistryAddress,
|
|
16
|
+
audiusTokenClient: AudiusTokenClient,
|
|
17
|
+
logger: Logger = console
|
|
18
|
+
) {
|
|
19
|
+
super(
|
|
20
|
+
ethWeb3Manager,
|
|
21
|
+
contractABI,
|
|
22
|
+
contractRegistryKey,
|
|
23
|
+
getRegistryAddress,
|
|
24
|
+
logger
|
|
25
|
+
)
|
|
26
|
+
this.audiusTokenClient = audiusTokenClient
|
|
27
|
+
this.toBN = ethWeb3Manager.getWeb3().utils.toBN
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async token() {
|
|
31
|
+
const method = await this.getMethod('token')
|
|
32
|
+
return method.call()
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
async totalStaked() {
|
|
36
|
+
const method = await this.getMethod('totalStaked')
|
|
37
|
+
return this.toBN(await method.call())
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
async supportsHistory() {
|
|
41
|
+
const method = await this.getMethod('supportsHistory')
|
|
42
|
+
return method.call()
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async totalStakedFor(account: string) {
|
|
46
|
+
const method = await this.getMethod('totalStakedFor', account)
|
|
47
|
+
return this.toBN(await method.call())
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
async totalStakedForAt(account: string, blockNumber: string) {
|
|
51
|
+
const method = await this.getMethod(
|
|
52
|
+
'totalStakedForAt',
|
|
53
|
+
account,
|
|
54
|
+
blockNumber
|
|
55
|
+
)
|
|
56
|
+
return this.toBN(await method.call())
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
async totalStakedAt(blockNumber: number) {
|
|
60
|
+
const method = await this.getMethod('totalStakedAt', blockNumber)
|
|
61
|
+
return this.toBN(await method.call())
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async isStaker(account: string) {
|
|
65
|
+
const method = await this.getMethod('isStaker', account)
|
|
66
|
+
return method.call()
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
async getDelegateManagerAddress() {
|
|
70
|
+
const method = await this.getMethod('getDelegateManagerAddress')
|
|
71
|
+
return method.call()
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
async getClaimsManagerAddress() {
|
|
75
|
+
const method = await this.getMethod('getClaimsManagerAddress')
|
|
76
|
+
return method.call()
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
async getServiceProviderFactoryAddress() {
|
|
80
|
+
const method = await this.getMethod('getServiceProviderFactoryAddress')
|
|
81
|
+
return method.call()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
async getGovernanceAddress() {
|
|
85
|
+
const method = await this.getMethod('getGovernanceAddress')
|
|
86
|
+
return method.call()
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async getLastClaimedBlockForUser() {
|
|
90
|
+
const method = await this.getMethod(
|
|
91
|
+
'lastClaimedFor',
|
|
92
|
+
this.web3Manager.getWalletAddress()
|
|
93
|
+
)
|
|
94
|
+
const tx = await method.call()
|
|
95
|
+
return tx
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { GovernedContractClient } from '../contracts/GovernedContractClient'
|
|
2
|
+
|
|
3
|
+
export class TrustedNotifierManagerClient extends GovernedContractClient {
|
|
4
|
+
/**
|
|
5
|
+
* Register Trusted Notifier with specified fields (wallet, endpoint, email)
|
|
6
|
+
* @notice Only callable by Governance contract
|
|
7
|
+
* @notice All fields must be unique and non-falsey
|
|
8
|
+
* @notice New Trusted Notifier is assigned an auto-incremented integer ID
|
|
9
|
+
* @returns Newly assigned integer ID
|
|
10
|
+
*/
|
|
11
|
+
async registerNotifier(
|
|
12
|
+
wallet: string,
|
|
13
|
+
endpoint: string,
|
|
14
|
+
email: string,
|
|
15
|
+
privateKey: string | null = null
|
|
16
|
+
) {
|
|
17
|
+
const method = await this.getGovernedMethod(
|
|
18
|
+
'registerNotifier',
|
|
19
|
+
wallet,
|
|
20
|
+
endpoint,
|
|
21
|
+
email
|
|
22
|
+
)
|
|
23
|
+
return await this.web3Manager.sendTransaction(
|
|
24
|
+
method,
|
|
25
|
+
await this.governanceClient.getAddress(),
|
|
26
|
+
privateKey
|
|
27
|
+
)
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Deregister Trusted Notifier associated with wallet
|
|
32
|
+
* @notice Only callable by Governance contract or wallet
|
|
33
|
+
* @returns ID of deregistered Trusted Notifier
|
|
34
|
+
*/
|
|
35
|
+
async deregisterNotifier(wallet: string, privateKey: string | null = null) {
|
|
36
|
+
const method = await this.getGovernedMethod('deregisterNotifier', wallet)
|
|
37
|
+
return await this.web3Manager.sendTransaction(
|
|
38
|
+
method,
|
|
39
|
+
await this.governanceClient.getAddress(),
|
|
40
|
+
privateKey
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async getLatestNotifierID() {
|
|
45
|
+
const method = await this.getMethod('getLatestNotifierID')
|
|
46
|
+
const ID = await method.call()
|
|
47
|
+
return parseInt(ID)
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Returns all TrustedNotifier info associated with ID
|
|
52
|
+
*/
|
|
53
|
+
async getNotifierForID(ID: string) {
|
|
54
|
+
const method = await this.getMethod('getNotifierForID', ID)
|
|
55
|
+
const notifierInfo = await method.call()
|
|
56
|
+
return {
|
|
57
|
+
wallet: notifierInfo.wallet,
|
|
58
|
+
endpoint: notifierInfo.endpoint.replace(/\/$/, ''),
|
|
59
|
+
email: notifierInfo.email.replace(/\/$/, '')
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Returns all TrustedNotifier info associated with wallet
|
|
65
|
+
*/
|
|
66
|
+
async getNotifierForWallet(wallet: string) {
|
|
67
|
+
const method = await this.getMethod('getNotifierForWallet', wallet)
|
|
68
|
+
const notifierInfo = await method.call()
|
|
69
|
+
return {
|
|
70
|
+
ID: notifierInfo.ID,
|
|
71
|
+
endpoint: notifierInfo.endpoint.replace(/\/$/, ''),
|
|
72
|
+
email: notifierInfo.email.replace(/\/$/, '')
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* Returns all TrustedNotifier info associated with endpoint
|
|
78
|
+
*/
|
|
79
|
+
async getNotifierForEndpoint(endpoint: string) {
|
|
80
|
+
const method = await this.getMethod('getNotifierForEndpoint', endpoint)
|
|
81
|
+
const notifierInfo = await method.call()
|
|
82
|
+
return {
|
|
83
|
+
ID: notifierInfo.ID,
|
|
84
|
+
wallet: notifierInfo.wallet,
|
|
85
|
+
email: notifierInfo.email.replace(/\/$/, '')
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/**
|
|
90
|
+
* Returns all TrustedNotifier info associated with email
|
|
91
|
+
*/
|
|
92
|
+
async getNotifierForEmail(email: string) {
|
|
93
|
+
const method = await this.getMethod('getNotifierForEmail', email)
|
|
94
|
+
const notifierInfo = await method.call()
|
|
95
|
+
return {
|
|
96
|
+
ID: notifierInfo.ID,
|
|
97
|
+
wallet: notifierInfo.wallet,
|
|
98
|
+
endpoint: notifierInfo.endpoint.replace(/\/$/, '')
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import type Web3 from 'web3'
|
|
2
|
+
import type { ContractABI } from '../../utils'
|
|
3
|
+
import type { EthWeb3Manager } from '../ethWeb3Manager'
|
|
4
|
+
import type { AudiusTokenClient } from './AudiusTokenClient'
|
|
5
|
+
import type { Contract } from 'web3-eth-contract'
|
|
6
|
+
import type BN from 'bn.js'
|
|
7
|
+
|
|
8
|
+
export class WormholeClient {
|
|
9
|
+
ethWeb3Manager: EthWeb3Manager
|
|
10
|
+
contractABI: ContractABI['abi']
|
|
11
|
+
contractAddress: string
|
|
12
|
+
web3: Web3
|
|
13
|
+
audiusTokenClient: AudiusTokenClient
|
|
14
|
+
WormholeContract: Contract
|
|
15
|
+
|
|
16
|
+
constructor(
|
|
17
|
+
ethWeb3Manager: EthWeb3Manager,
|
|
18
|
+
contractABI: ContractABI['abi'],
|
|
19
|
+
contractAddress: string,
|
|
20
|
+
audiusTokenClient: AudiusTokenClient
|
|
21
|
+
) {
|
|
22
|
+
this.ethWeb3Manager = ethWeb3Manager
|
|
23
|
+
this.contractABI = contractABI
|
|
24
|
+
this.contractAddress = contractAddress
|
|
25
|
+
|
|
26
|
+
this.web3 = this.ethWeb3Manager.getWeb3()
|
|
27
|
+
this.audiusTokenClient = audiusTokenClient
|
|
28
|
+
this.WormholeContract = new this.web3.eth.Contract(
|
|
29
|
+
this.contractABI,
|
|
30
|
+
this.contractAddress
|
|
31
|
+
)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Get the name of the contract
|
|
35
|
+
async nonces(wallet: string) {
|
|
36
|
+
// Pass along a unique param so the nonce value is always not cached
|
|
37
|
+
const nonce = await this.WormholeContract.methods.nonces(wallet).call({
|
|
38
|
+
_audiusBustCache: Date.now()
|
|
39
|
+
})
|
|
40
|
+
const number = this.web3.utils.toBN(nonce).toNumber()
|
|
41
|
+
return number
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/* ------- SETTERS ------- */
|
|
45
|
+
|
|
46
|
+
async initialize(fromAcct: string, wormholeAddress: string, relayer: string) {
|
|
47
|
+
const method = this.WormholeContract.methods.initialize(
|
|
48
|
+
this.audiusTokenClient.contractAddress,
|
|
49
|
+
wormholeAddress
|
|
50
|
+
)
|
|
51
|
+
|
|
52
|
+
const tx = await this.ethWeb3Manager.relayTransaction(
|
|
53
|
+
method,
|
|
54
|
+
this.contractAddress,
|
|
55
|
+
fromAcct,
|
|
56
|
+
relayer,
|
|
57
|
+
/* retries */ 0
|
|
58
|
+
)
|
|
59
|
+
return { txReceipt: tx }
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Transfers in eth from the user's wallet to the wormhole contract and
|
|
64
|
+
* specifies a solana wallet to realized the tokens in SOL
|
|
65
|
+
*/
|
|
66
|
+
async transferTokens(
|
|
67
|
+
fromAcct: string,
|
|
68
|
+
amount: BN,
|
|
69
|
+
chainId: number,
|
|
70
|
+
solanaAccount: string,
|
|
71
|
+
arbiterFee: string,
|
|
72
|
+
deadline: string,
|
|
73
|
+
signedDigest: { v: string; r: string; s: string },
|
|
74
|
+
relayer: string
|
|
75
|
+
) {
|
|
76
|
+
const method = this.WormholeContract.methods.transferTokens(
|
|
77
|
+
fromAcct,
|
|
78
|
+
amount,
|
|
79
|
+
chainId,
|
|
80
|
+
solanaAccount,
|
|
81
|
+
arbiterFee,
|
|
82
|
+
deadline,
|
|
83
|
+
signedDigest.v,
|
|
84
|
+
signedDigest.r,
|
|
85
|
+
signedDigest.s
|
|
86
|
+
)
|
|
87
|
+
const tx = await this.ethWeb3Manager.relayTransaction(
|
|
88
|
+
method,
|
|
89
|
+
this.contractAddress,
|
|
90
|
+
fromAcct,
|
|
91
|
+
relayer,
|
|
92
|
+
/* retries */ 0,
|
|
93
|
+
null
|
|
94
|
+
)
|
|
95
|
+
return tx
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EthContracts'
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import Web3 from '../../web3'
|
|
2
|
+
import type Web3Type from 'web3'
|
|
3
|
+
import { MultiProvider, estimateGas, ContractMethod, Maybe } from '../../utils'
|
|
4
|
+
import { Transaction as EthereumTx } from 'ethereumjs-tx'
|
|
5
|
+
import retry from 'async-retry'
|
|
6
|
+
import type { IdentityService, RelayTransaction } from '../identity'
|
|
7
|
+
import type { Hedgehog } from '@audius/hedgehog'
|
|
8
|
+
import type { AxiosError } from 'axios'
|
|
9
|
+
import type Wallet from 'ethereumjs-wallet'
|
|
10
|
+
import type { TransactionReceipt } from 'web3-core'
|
|
11
|
+
|
|
12
|
+
const MIN_GAS_PRICE = Math.pow(10, 9) // 1 GWei, ETH minimum allowed gas price
|
|
13
|
+
const HIGH_GAS_PRICE = 250 * MIN_GAS_PRICE // 250 GWei
|
|
14
|
+
const DEFAULT_GAS_PRICE = 100 * MIN_GAS_PRICE // 100 Gwei is a reasonably average gas price
|
|
15
|
+
const MAX_GAS_LIMIT = 5000000 // We've seen prod tx's take up to 4M. Set to the highest we've observed + a buffer
|
|
16
|
+
|
|
17
|
+
export type EthWeb3Config = {
|
|
18
|
+
ownerWallet: Wallet | string
|
|
19
|
+
providers: string[]
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
type EthWeb3ManagerConfig = {
|
|
23
|
+
web3Config: EthWeb3Config
|
|
24
|
+
identityService: IdentityService
|
|
25
|
+
hedgehog?: Hedgehog
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** Singleton state-manager for Audius Eth Contracts */
|
|
29
|
+
export class EthWeb3Manager {
|
|
30
|
+
web3Config: EthWeb3Config
|
|
31
|
+
web3: Web3Type
|
|
32
|
+
identityService: IdentityService
|
|
33
|
+
hedgehog?: Hedgehog
|
|
34
|
+
ownerWallet: Maybe<Wallet | string>
|
|
35
|
+
|
|
36
|
+
constructor({ web3Config, identityService, hedgehog }: EthWeb3ManagerConfig) {
|
|
37
|
+
if (!web3Config) throw new Error('web3Config object not passed in')
|
|
38
|
+
if (!web3Config.providers)
|
|
39
|
+
throw new Error('missing web3Config property: providers')
|
|
40
|
+
|
|
41
|
+
// MultiProvider implements a web3 provider with fallback.
|
|
42
|
+
const provider = new MultiProvider(web3Config.providers)
|
|
43
|
+
|
|
44
|
+
this.web3Config = web3Config
|
|
45
|
+
this.web3 = new Web3(provider)
|
|
46
|
+
this.identityService = identityService
|
|
47
|
+
this.hedgehog = hedgehog
|
|
48
|
+
|
|
49
|
+
// Hedgehog might not exist (in the case of @audius/sdk)
|
|
50
|
+
if (this.hedgehog) {
|
|
51
|
+
if (this.web3Config.ownerWallet) {
|
|
52
|
+
this.ownerWallet = this.web3Config.ownerWallet
|
|
53
|
+
} else {
|
|
54
|
+
const storedWallet = this.hedgehog.getWallet()
|
|
55
|
+
if (storedWallet) {
|
|
56
|
+
this.ownerWallet = storedWallet
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
getWeb3() {
|
|
63
|
+
return this.web3
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
getWalletAddress() {
|
|
67
|
+
if (this.ownerWallet) {
|
|
68
|
+
// @ts-expect-error TODO extend ethereum-js-wallet to include toLowerCase
|
|
69
|
+
return this.ownerWallet.toLowerCase()
|
|
70
|
+
}
|
|
71
|
+
throw new Error('Owner wallet not set')
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Signs provided string data (should be timestamped).
|
|
76
|
+
*/
|
|
77
|
+
async sign(data: string) {
|
|
78
|
+
// @ts-expect-error TODO: sign expected to take a password as 3rd argument
|
|
79
|
+
return await this.web3.eth.personal.sign(
|
|
80
|
+
this.web3.utils.fromUtf8(data),
|
|
81
|
+
this.getWalletAddress()
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
async sendTransaction(
|
|
86
|
+
contractMethod: ContractMethod,
|
|
87
|
+
contractAddress: string | null = null,
|
|
88
|
+
privateKey: string | null = null,
|
|
89
|
+
txRetries = 5,
|
|
90
|
+
txGasLimit: number | null = null
|
|
91
|
+
): Promise<TransactionReceipt> {
|
|
92
|
+
const gasLimit =
|
|
93
|
+
txGasLimit ??
|
|
94
|
+
(await estimateGas({
|
|
95
|
+
method: contractMethod,
|
|
96
|
+
from: this.ownerWallet,
|
|
97
|
+
gasLimitMaximum: MAX_GAS_LIMIT
|
|
98
|
+
}))
|
|
99
|
+
if (contractAddress && privateKey) {
|
|
100
|
+
let gasPrice = parseInt(await this.web3.eth.getGasPrice())
|
|
101
|
+
if (isNaN(gasPrice) || gasPrice > HIGH_GAS_PRICE) {
|
|
102
|
+
gasPrice = DEFAULT_GAS_PRICE
|
|
103
|
+
} else if (gasPrice === 0) {
|
|
104
|
+
// If the gas is zero, the txn will likely never get mined.
|
|
105
|
+
gasPrice = MIN_GAS_PRICE
|
|
106
|
+
}
|
|
107
|
+
const gasPriceStr = '0x' + gasPrice.toString(16)
|
|
108
|
+
|
|
109
|
+
const privateKeyBuffer = Buffer.from(privateKey, 'hex')
|
|
110
|
+
const walletAddress = this.getWalletAddress()
|
|
111
|
+
const txCount = await this.web3.eth.getTransactionCount(walletAddress)
|
|
112
|
+
const encodedABI = contractMethod.encodeABI()
|
|
113
|
+
const txParams = {
|
|
114
|
+
nonce: this.web3.utils.toHex(txCount),
|
|
115
|
+
gasPrice: gasPriceStr,
|
|
116
|
+
gasLimit,
|
|
117
|
+
data: encodedABI,
|
|
118
|
+
to: contractAddress,
|
|
119
|
+
value: '0x00'
|
|
120
|
+
}
|
|
121
|
+
const tx = new EthereumTx(txParams)
|
|
122
|
+
tx.sign(privateKeyBuffer)
|
|
123
|
+
const signedTx = '0x' + tx.serialize().toString('hex')
|
|
124
|
+
|
|
125
|
+
// Send the tx with retries
|
|
126
|
+
const response = await retry(
|
|
127
|
+
async () => {
|
|
128
|
+
return await this.web3.eth.sendSignedTransaction(signedTx)
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
// Retry function 5x by default
|
|
132
|
+
// 1st retry delay = 500ms, 2nd = 1500ms, 3rd...nth retry = 4000 ms (capped)
|
|
133
|
+
minTimeout: 500,
|
|
134
|
+
maxTimeout: 4000,
|
|
135
|
+
factor: 3,
|
|
136
|
+
retries: txRetries,
|
|
137
|
+
onRetry: (err) => {
|
|
138
|
+
if (err) {
|
|
139
|
+
console.log(
|
|
140
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- TODO
|
|
141
|
+
`libs ethWeb3Manager transaction send retry error : ${err}`
|
|
142
|
+
)
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
)
|
|
147
|
+
|
|
148
|
+
return response
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
const gasPrice = parseInt(await this.web3.eth.getGasPrice())
|
|
152
|
+
return await contractMethod.send({
|
|
153
|
+
from: this.ownerWallet,
|
|
154
|
+
gas: gasLimit,
|
|
155
|
+
gasPrice: gasPrice
|
|
156
|
+
})
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Relays an eth transaction via the identity service with retries
|
|
161
|
+
* The relay pays for the transaction fee on behalf of the user
|
|
162
|
+
* The gas Limit is estimated if not provided
|
|
163
|
+
*/
|
|
164
|
+
async relayTransaction(
|
|
165
|
+
contractMethod: ContractMethod,
|
|
166
|
+
contractAddress: string,
|
|
167
|
+
ownerWallet: Wallet | string,
|
|
168
|
+
relayerWallet?: Wallet | string,
|
|
169
|
+
txRetries = 5,
|
|
170
|
+
txGasLimit: number | null = null
|
|
171
|
+
): Promise<Maybe<RelayTransaction['resp']>> {
|
|
172
|
+
const encodedABI = contractMethod.encodeABI()
|
|
173
|
+
const gasLimit =
|
|
174
|
+
txGasLimit ??
|
|
175
|
+
(await estimateGas({
|
|
176
|
+
from: relayerWallet,
|
|
177
|
+
method: contractMethod,
|
|
178
|
+
gasLimitMaximum: MAX_GAS_LIMIT
|
|
179
|
+
}))
|
|
180
|
+
|
|
181
|
+
const response = await retry<Maybe<RelayTransaction>>(
|
|
182
|
+
async (bail) => {
|
|
183
|
+
try {
|
|
184
|
+
const attempt = await this.identityService.ethRelay(
|
|
185
|
+
contractAddress,
|
|
186
|
+
ownerWallet,
|
|
187
|
+
encodedABI,
|
|
188
|
+
gasLimit.toString()
|
|
189
|
+
)
|
|
190
|
+
return attempt
|
|
191
|
+
} catch (e) {
|
|
192
|
+
const error = e as AxiosError
|
|
193
|
+
if (error.response?.status === 429) {
|
|
194
|
+
// Don't retry in the case we are getting rate limited
|
|
195
|
+
bail(new Error('Please wait before trying again'))
|
|
196
|
+
return
|
|
197
|
+
}
|
|
198
|
+
// Trigger a retry
|
|
199
|
+
throw error
|
|
200
|
+
}
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
// Retry function 5x by default
|
|
204
|
+
// 1st retry delay = 500ms, 2nd = 1500ms, 3rd...nth retry = 4000 ms (capped)
|
|
205
|
+
minTimeout: 500,
|
|
206
|
+
maxTimeout: 4000,
|
|
207
|
+
factor: 3,
|
|
208
|
+
retries: txRetries,
|
|
209
|
+
onRetry: (err) => {
|
|
210
|
+
if (err) {
|
|
211
|
+
console.log(
|
|
212
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string -- TODO
|
|
213
|
+
`libs ethWeb3Manager transaction relay retry error : ${err}`
|
|
214
|
+
)
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
)
|
|
219
|
+
return response?.resp
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
async getRelayMethodParams(
|
|
223
|
+
contractAddress: string,
|
|
224
|
+
contractMethod: ContractMethod,
|
|
225
|
+
relayerWallet: Wallet
|
|
226
|
+
) {
|
|
227
|
+
const encodedABI = contractMethod.encodeABI()
|
|
228
|
+
const gasLimit = await estimateGas({
|
|
229
|
+
from: relayerWallet,
|
|
230
|
+
method: contractMethod,
|
|
231
|
+
gasLimitMaximum: HIGH_GAS_PRICE
|
|
232
|
+
})
|
|
233
|
+
return {
|
|
234
|
+
contractAddress,
|
|
235
|
+
encodedABI,
|
|
236
|
+
gasLimit
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './EthWeb3Manager'
|