{"version":3,"file":"fetchConfig.mjs","sources":["../../../../../src/plugins/spotInstrumentModule/operations/fetchConfig.ts"],"sourcesContent":["import {\n  Operation,\n  OperationHandler,\n  OperationScope,\n  useOperation,\n} from '../../../types';\nimport { Convergence } from '../../../Convergence';\nimport { SpotInstrumentConfig, toSpotInstrumentConfig } from '../models';\nimport { toSpotInstrumentConfigAccount } from '../accounts';\n\nconst Key = 'FetchSpotInstrumentConfig' as const;\n\nexport const fetchSpotInstrumentConfigOperation =\n  useOperation<FetchSpotInstrumentConfigOperation>(Key);\n\n/**\n * @group Operations\n * @category Types\n */\nexport type FetchSpotInstrumentConfigOperation = Operation<\n  typeof Key,\n  FetchSpotInstrumentConfigInput,\n  FetchSpotInstrumentConfigOutput\n>;\n\n/**\n * @group Operations\n * @category Inputs\n */\nexport type FetchSpotInstrumentConfigInput = {} | undefined;\n\n/**\n * @group Operations\n * @category Outputs\n */\nexport type FetchSpotInstrumentConfigOutput = SpotInstrumentConfig;\n\n/**\n * @group Operations\n * @category Handlers\n */\nexport const fetchSpotInstrumentConfigOperationHandler: OperationHandler<FetchSpotInstrumentConfigOperation> =\n  {\n    handle: async (\n      _operation: FetchSpotInstrumentConfigOperation,\n      cvg: Convergence,\n      scope: OperationScope\n    ): Promise<FetchSpotInstrumentConfigOutput> => {\n      const { commitment } = scope;\n\n      const configAddress = cvg.spotInstrument().pdas().config();\n      const account = await cvg.rpc().getAccount(configAddress, commitment);\n      const configAccount = toSpotInstrumentConfigAccount(account);\n\n      return toSpotInstrumentConfig(configAccount);\n    },\n  };\n"],"names":["Key","fetchSpotInstrumentConfigOperation","useOperation","fetchSpotInstrumentConfigOperationHandler","handle","_handle","_asyncToGenerator","_regeneratorRuntime","mark","_callee","_operation","cvg","scope","commitment","configAddress","account","configAccount","wrap","_callee$","_context","prev","next","spotInstrument","pdas","config","rpc","getAccount","sent","toSpotInstrumentConfigAccount","abrupt","toSpotInstrumentConfig","stop","_x","_x2","_x3","apply","arguments"],"mappings":";;;;;A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