Skip to content

Commit

Permalink
fix build
Browse files Browse the repository at this point in the history
  • Loading branch information
marc-aurele-besner committed Jul 4, 2024
1 parent 2aa6067 commit a87479d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 30 deletions.
Binary file removed .yarn/install-state.gz
Binary file not shown.
42 changes: 12 additions & 30 deletions packages/auto-utils/src/api.ts
Original file line number Diff line number Diff line change
@@ -1,50 +1,32 @@
import { ApiPromise as PolkadotApiPromise, WsProvider } from '@polkadot/api'
import { ApiPromise, WsProvider } from '@polkadot/api'
import { getNetworkDomainRpcUrls, getNetworkRpcUrls } from './network'
import type { ApiPromise } from './types/api'
import type { DomainInput, NetworkInput } from './types/network'

let provider: WsProvider | null = null
let apiInstance: ApiPromise | null = null

let domainProvider: WsProvider | null = null
let apiDomainInstance: ApiPromise | null = null

export const activate = async (input?: NetworkInput): Promise<ApiPromise> => {
// Get the first rpc urls for the network
const rpcUrl = getNetworkRpcUrls(input)
// Create the provider
provider = new WsProvider(rpcUrl[0])
const provider = new WsProvider(rpcUrl[0])
// Create the API instance
apiInstance = await PolkadotApiPromise.create({ provider })
const api = await ApiPromise.create({ provider })
await api.isReady

return apiInstance
return api
}

export const activateDomain = async (input: DomainInput): Promise<ApiPromise> => {
// Get the first rpc urls for the network
const rpcUrl = getNetworkDomainRpcUrls(input)
// Create the provider
domainProvider = new WsProvider(rpcUrl[0])
const provider = new WsProvider(rpcUrl[0])
// Create the API instance
apiDomainInstance = await PolkadotApiPromise.create({ provider: domainProvider })

return apiDomainInstance
}
const api = await ApiPromise.create({ provider })
await api.isReady

export const disconnect = async (): Promise<void> => {
// Disconnect the API instance and the provider if they exist
if (apiInstance) {
await apiInstance.disconnect()
apiInstance = null
provider = null
}
return api
}

export const disconnectDomain = async (): Promise<void> => {
// Disconnect the API instance and the provider if they exist
if (apiDomainInstance) {
await apiDomainInstance.disconnect()
apiDomainInstance = null
domainProvider = null
}
export const disconnect = async (api: ApiPromise): Promise<void> => {
// Disconnect the API instance and the provider
await api.disconnect()
}

0 comments on commit a87479d

Please sign in to comment.