mirror of
https://github.com/semaphore-protocol/semaphore.git
synced 2026-01-09 14:48:12 -05:00
Allow injecting existing PublicClient into SemaphoreViem (#1006)
* refactor: allow injecting existing PublicClient into SemaphoreViem * fix: remove comment
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Chain, Transport } from "viem"
|
||||
import { Chain, PublicClient, Transport } from "viem"
|
||||
|
||||
export type EthersNetwork =
|
||||
| "mainnet"
|
||||
@@ -65,4 +65,5 @@ export type ViemOptions = {
|
||||
transport?: Transport // Transport from viem
|
||||
chain?: Chain // Chain from viem
|
||||
apiKey?: string
|
||||
publicClient?: PublicClient
|
||||
}
|
||||
|
||||
@@ -117,7 +117,6 @@ export default class SemaphoreViem {
|
||||
throw new Error(`Network '${networkOrEthereumURL}' needs a Semaphore contract address`)
|
||||
}
|
||||
|
||||
// Create the public client
|
||||
let transport: Transport
|
||||
|
||||
if (options.transport) {
|
||||
@@ -131,10 +130,12 @@ export default class SemaphoreViem {
|
||||
this._options = options
|
||||
|
||||
// Create the public client
|
||||
this._client = createPublicClient({
|
||||
transport,
|
||||
chain: options.chain as Chain
|
||||
})
|
||||
this._client =
|
||||
options.publicClient ??
|
||||
createPublicClient({
|
||||
transport,
|
||||
chain: options.chain as Chain
|
||||
})
|
||||
|
||||
// Create the contract instance
|
||||
this._contract = getContract({
|
||||
|
||||
Reference in New Issue
Block a user