forked from Scaffold-Stark/scaffold-stark-2
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Eduardo
committed
Apr 15, 2024
1 parent
c3ff555
commit 02b8c73
Showing
1 changed file
with
15 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,24 @@ | ||
import scaffoldConfig from "~~/scaffold.config"; | ||
import {jsonRpcProvider, publicProvider, starknetChainId} from "@starknet-react/core"; | ||
import { | ||
jsonRpcProvider, | ||
publicProvider, | ||
starknetChainId, | ||
} from "@starknet-react/core"; | ||
import * as chains from "@starknet-react/chains"; | ||
|
||
const containsDevnet = (networks: readonly chains.Chain[]) => { | ||
return networks.filter(it => it.id == chains.devnet.id).length > 0 | ||
} | ||
return networks.filter((it) => it.id == chains.devnet.id).length > 0; | ||
}; | ||
|
||
const provider = | ||
scaffoldConfig.rpcProviderUrl == "" || containsDevnet(scaffoldConfig.targetNetworks) | ||
scaffoldConfig.rpcProviderUrl == "" || | ||
containsDevnet(scaffoldConfig.targetNetworks) | ||
? publicProvider() | ||
: jsonRpcProvider({ | ||
rpc: () => ({ | ||
nodeUrl: scaffoldConfig.rpcProviderUrl, | ||
chainId: starknetChainId(scaffoldConfig.targetNetworks[0].id), | ||
}), | ||
}); | ||
rpc: () => ({ | ||
nodeUrl: scaffoldConfig.rpcProviderUrl, | ||
chainId: starknetChainId(scaffoldConfig.targetNetworks[0].id), | ||
}), | ||
}); | ||
|
||
export default provider; | ||
export default provider; |