Skip to content

Commit

Permalink
Infura auth updated
Browse files Browse the repository at this point in the history
  • Loading branch information
Tameki committed Jan 7, 2020
1 parent ae944d4 commit 6c73b3a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class MainViewModel: ViewModel() {
wethAdapter = Erc20Adapter(App.instance, ethereumKit, "Wrapped Eth", "WETH", wethAddress, decimals)
tokenAdapter = Erc20Adapter(App.instance, ethereumKit, "Tameki Coin V2", "TMKv2", tokenAddress, decimals)

val providerMode = ZrxKit.RpcProviderMode.Infura(infuraCredentials.secretKey)
val providerMode = ZrxKit.RpcProviderMode.Infura(infuraCredentials.projectId, infuraCredentials.secretKey)

zrxKit = ZrxKit.getInstance(relayers, privateKey, providerMode, zrxKitNetworkType, gasInfoProvider)

Expand Down
11 changes: 7 additions & 4 deletions zrxkit/src/main/java/com/fridaytech/zrxkit/ZrxKit.kt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ZrxKit private constructor(
val credentials = Credentials.create(ECKeyPair.create(privateKey))

val providerUrl = when(rpcProviderMode) {
is RpcProviderMode.Infura -> networkType.getInfuraUrl(rpcProviderMode.projectSecret)
is RpcProviderMode.Infura -> networkType.getInfuraUrl(rpcProviderMode.projectId)
is RpcProviderMode.Node -> rpcProviderMode.nodeUrl
}

Expand Down Expand Up @@ -115,13 +115,16 @@ class ZrxKit private constructor(
"kovan"
);

fun getInfuraUrl(projectSecret: String): String {
return "https://$subdomain.infura.io/$projectSecret"
fun getInfuraUrl(projectId: String): String {
return "https://$subdomain.infura.io/v3/$projectId"
}
}

sealed class RpcProviderMode {
class Infura(val projectSecret: String) : RpcProviderMode()
class Infura(
val projectId: String,
val projectSecret: String
) : RpcProviderMode()
class Node(val nodeUrl: String) : RpcProviderMode()
}

Expand Down

0 comments on commit 6c73b3a

Please sign in to comment.