Skip to content

Commit

Permalink
chore: re-use parseLogArgs
Browse files Browse the repository at this point in the history
  • Loading branch information
yomarion committed Jun 25, 2021
1 parent d67027f commit 273a8f6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 14 deletions.
3 changes: 2 additions & 1 deletion packages/payment-detection/src/index.ts
Expand Up @@ -7,7 +7,7 @@ import * as Erc20PaymentNetwork from './erc20';
import * as EthPaymentNetwork from './eth';
import { initPaymentDetectionApiKeys, setProviderFactory, getDefaultProvider } from './provider';
import { getTheGraphClient, networkSupportsTheGraph } from './thegraph';
import { padAmountForChainlink, unpadAmountFromChainlink } from './utils';
import { parseLogArgs, padAmountForChainlink, unpadAmountFromChainlink } from './utils';
export type { TheGraphClient } from './thegraph';

export {
Expand All @@ -22,6 +22,7 @@ export {
getDefaultProvider,
getTheGraphClient,
networkSupportsTheGraph,
parseLogArgs,
padAmountForChainlink,
unpadAmountFromChainlink,
};
2 changes: 1 addition & 1 deletion packages/payment-detection/test/utils.test.ts
@@ -1,5 +1,5 @@
import { Currency } from '@requestnetwork/currency';
import { padAmountForChainlink, unpadAmountFromChainlink } from '../src/utils';
import { padAmountForChainlink, unpadAmountFromChainlink } from '../src';

describe('conversion: padding amounts for Chainlink', () => {
it('should throw on currencies not implemented in the library', () => {
Expand Down
13 changes: 1 addition & 12 deletions packages/toolbox/src/chainlinkConversionPathTools.ts
@@ -1,11 +1,10 @@
import { ethers } from 'ethers';
import { chainlinkConversionPath } from '@requestnetwork/smart-contracts';
import { getDefaultProvider } from '@requestnetwork/payment-detection';
import { getDefaultProvider, parseLogArgs } from '@requestnetwork/payment-detection';
import { ChainlinkConversionPath__factory } from '@requestnetwork/smart-contracts/types';
import { Currency } from '@requestnetwork/currency';
import { RequestLogicTypes } from '@requestnetwork/types';
import iso4217 from '@requestnetwork/currency/dist/iso4217';
import { LogDescription } from 'ethers/lib/utils';

export interface IOptions {
network?: string;
Expand All @@ -19,16 +18,6 @@ type AggregatorUpdatedArgs = {
_aggregator: string;
};

/**
* Converts the Log's args from array to an object with keys being the name of the arguments
*/
export const parseLogArgs = <T>({ args, eventFragment }: LogDescription): T => {
return args.reduce((prev, current, i) => {
prev[eventFragment.inputs[i].name] = current;
return prev;
}, {});
};

/**
* Retrieves a list of payment events from a payment reference, a destination address, a token address and a proxy contract
*/
Expand Down

0 comments on commit 273a8f6

Please sign in to comment.