From 29af3c2c20b4b9ff75cbb4262ab24941043eb09d Mon Sep 17 00:00:00 2001 From: halaprix Date: Tue, 13 Feb 2024 10:19:54 +0100 Subject: [PATCH] fix: format --- packages/automation/src/abi-coding.ts | 14 ++++++++---- packages/automation/src/mapping.ts | 31 ++++++++++++++++----------- 2 files changed, 29 insertions(+), 16 deletions(-) diff --git a/packages/automation/src/abi-coding.ts b/packages/automation/src/abi-coding.ts index 205fe23..38aa7be 100644 --- a/packages/automation/src/abi-coding.ts +++ b/packages/automation/src/abi-coding.ts @@ -23,7 +23,10 @@ export function decodeTriggerDataByType(type: CommandContractType, data: string) return utils.defaultAbiCoder.decode(paramTypes, data); } -export function decodeOffchainTriggerDataByType(type: CommandContractType, data: string): utils.Result { +export function decodeOffchainTriggerDataByType( + type: CommandContractType, + data: string, +): utils.Result { const paramTypes = getOffchainDataDefinitionForCommandType(type); return utils.defaultAbiCoder.decode(paramTypes, data); } @@ -90,7 +93,7 @@ export function decodeOffchainTriggerDataByTriggerTypeAsJson( ): utils.Result { const type = triggerTypeToCommandContractTypeMap[triggerType]; const arr: any[] = decodeOffchainTriggerDataByType(type, data) as any[]; - const offchainDataType = commandOffchainDataTypeJsonMapping[type] + const offchainDataType = commandOffchainDataTypeJsonMapping[type]; if (!offchainDataType) { throw new Error(`No offchain data mapping for type ${type}`); } @@ -123,7 +126,10 @@ export function encodeTriggerDataByTriggerType( return utils.defaultAbiCoder.encode(paramTypes, values); } -export function encodeOffchainTriggerDataByType(type: CommandContractType, values: readonly any[]): string { +export function encodeOffchainTriggerDataByType( + type: CommandContractType, + values: readonly any[], +): string { const paramTypes = getOffchainDataDefinitionForCommandType(type); return utils.defaultAbiCoder.encode(paramTypes, values); } @@ -135,4 +141,4 @@ export function encodeTriggerOffchainDataByTriggerType( const commandType = triggerTypeToCommandContractTypeMap[triggerType]; const paramTypes = getOffchainDataDefinitionForCommandType(commandType); return utils.defaultAbiCoder.encode(paramTypes, values); -} \ No newline at end of file +} diff --git a/packages/automation/src/mapping.ts b/packages/automation/src/mapping.ts index 84ff23d..10f6b52 100644 --- a/packages/automation/src/mapping.ts +++ b/packages/automation/src/mapping.ts @@ -154,7 +154,7 @@ export const commandTypeJsonMapping: Record = { 'debtOracle', 'debtAddedRoundId', 'trailingDistance', - 'closeToCollateral' + 'closeToCollateral', ], }; export const commandOffchainDataTypeJsonMapping: Partial> = { @@ -415,7 +415,10 @@ export const defaultCommandTypeMapping: Record> = { +export const defaultCommandOffchainDataTypeMapping: Partial> = { [CommandContractType.DmaAaveTrailingStopLossCommandV2]: [ 'uint80', // collateralMaxPriceRoundId 'uint80', // debtClosestPriceRoundId @@ -463,13 +466,15 @@ export function getDefinitionForCommandType(type: CommandContractType): ParamDef * @returns The offchain data definition for the command type. * @throws Error if the command type is unknown. */ -export function getOffchainDataDefinitionForCommandType(type: Partial): ParamDefinition { - const offchainDataType = defaultCommandOffchainDataTypeMapping[type] +export function getOffchainDataDefinitionForCommandType( + type: Partial, +): ParamDefinition { + const offchainDataType = defaultCommandOffchainDataTypeMapping[type]; if (!offchainDataType) { throw new Error( - `Unknown command type ${type}. Supported types: ${Object.keys(defaultCommandOffchainDataTypeMapping).join( - ', ', - )}.`, + `Unknown command type ${type}. Supported types: ${Object.keys( + defaultCommandOffchainDataTypeMapping, + ).join(', ')}.`, ); } @@ -482,14 +487,16 @@ export function getOffchainDataDefinitionForCommandType(type: Partial): ParamDefinition { +export function getOffchainDataDefinitionForTriggerType( + triggerType: Partial, +): ParamDefinition { const type = triggerTypeToCommandContractTypeMap[triggerType]; - const offchainDataType = defaultCommandOffchainDataTypeMapping[type] + const offchainDataType = defaultCommandOffchainDataTypeMapping[type]; if (!offchainDataType) { throw new Error( - `Unknown command type ${type}. Supported types: ${Object.keys(defaultCommandOffchainDataTypeMapping).join( - ', ', - )}.`, + `Unknown command type ${type}. Supported types: ${Object.keys( + defaultCommandOffchainDataTypeMapping, + ).join(', ')}.`, ); }