Skip to content

Commit

Permalink
remove mingo ops side effects
Browse files Browse the repository at this point in the history
  • Loading branch information
mfornos committed Jun 14, 2024
1 parent 1964926 commit 9c9e1af
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 3 deletions.
4 changes: 4 additions & 0 deletions packages/core/src/apis/substrate-apis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { logger } from '@polkadot/util'
import { Observable, map, shareReplay } from 'rxjs'

import type { ApiNames, Configuration } from '../configuration/index.js'
import { installOperators } from '../subjects/mingo-ops.js'

const l = logger('oc-substrate-apis')

Expand Down Expand Up @@ -71,6 +72,9 @@ export class SubstrateApis<C extends Configuration = Configuration, N extends Ap
constructor(config: C) {
l.debug('Initialize Substrate APIs')

// Installs mingo operators if needed
installOperators()

Object.entries(config).forEach(([name, options]) => {
const { provider } = options

Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,6 @@ export { Smoldot } from './client/index.js'
export * as config from './configuration/index.js'
export * as converters from './converters/index.js'
export * as types from './types/index.js'

import { installOperators } from './subjects/mingo-ops.js'
export const mingo = { installOperators }
4 changes: 4 additions & 0 deletions packages/core/src/subjects/query.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// Copyright 2023-2024 SO/DA zone
// SPDX-License-Identifier: Apache-2.0

import { installOperators } from './mingo-ops.js'
import { ControlQuery } from './query.js'

const testAddress = '1a1LcBX6hGPKg5aQ6DXZpAHCCzWjckhea4sz3P1PvL3oc4F'

describe('control query', () => {
beforeAll(() => {
installOperators()
})
it('should filter out dispatch errors', () => {
const q = ControlQuery.from({
dispatchError: { $eq: undefined },
Expand Down
3 changes: 0 additions & 3 deletions packages/core/src/subjects/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ import { Query } from 'mingo'
import { RawObject } from 'mingo/types'
import { installOperators } from './mingo-ops.js'

// Installs mingo operators if needed
installOperators()

export type Criteria = RawObject

/**
Expand Down

0 comments on commit 9c9e1af

Please sign in to comment.