Skip to content

Commit

Permalink
Merge branch 'fix/btach-conversion-capped' into chore/payment-process…
Browse files Browse the repository at this point in the history
…or-batch-fee-usd-limited
  • Loading branch information
olivier7delf committed Oct 19, 2022
2 parents d215a6a + 9436290 commit 6de03f6
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 18 deletions.
2 changes: 1 addition & 1 deletion packages/payment-detection/src/thegraph/info-retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export class TheGraphInfoRetriever {
'feeAmountInCrypto',
'maxRateTimespan',
),
String,
(val) => (val !== null ? String(val) : undefined),
),
// Make sure the checksum is right for addresses.
...mapValues(pick(payment, 'from', 'feeAddress', 'tokenAddress'), (str, key) =>
Expand Down
28 changes: 27 additions & 1 deletion packages/payment-detection/test/erc20/fee-proxy-contract.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,11 @@ describe('api/erc20/fee-proxy-contract', () => {
txHash: '0x456d67cba236778e91a901e97c71684e82317dc2679d1b5c6bfa6d420d636b7d',
gasUsed: '73152',
gasPrice: '12709127644',
timestamp: 1666002347,
amountInCrypto: null,
feeAddress: '0x35d0e078755cd84d3e0656caab417dee1d7939c7',
feeAmountInCrypto: null,
maxRateTimespan: null,
},
].filter((x) => x.reference.toLowerCase() === reference.toLowerCase()),
escrowEvents: [],
Expand All @@ -434,8 +439,29 @@ describe('api/erc20/fee-proxy-contract', () => {
}),
});

const { balance, error } = await erc20FeeProxyContract.getBalance(mockRequest);
const { balance, error, events } = await erc20FeeProxyContract.getBalance(mockRequest);
expect(error).toBeUndefined();
expect(balance).toBe('168040800000000000000000');
expect(events).toMatchObject([
{
amount: '168040800000000000000000',
name: 'payment',
parameters: {
amountInCrypto: undefined,
block: 15767215,
feeAddress: '0x35d0e078755Cd84D3E0656cAaB417Dee1d7939c7',
feeAmount: '13386000000000000000',
feeAmountInCrypto: undefined,
from: '0x15339d48Fbe31E349A507FD6d48Eb01c45Fdc79A',
gasPrice: '12709127644',
gasUsed: '73152',
maxRateTimespan: undefined,
to: '0x6c9E04997000d6A8a353951231923d776d4Cdff2',
tokenAddress: '0x967da4048cD07aB37855c090aAF366e4ce1b9F48',
txHash: '0x456d67cba236778e91a901e97c71684e82317dc2679d1b5c6bfa6d420d636b7d',
},
timestamp: 1666002347,
},
]);
});
});
2 changes: 1 addition & 1 deletion packages/payment-detection/test/near/near-native.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ describe('Near payments detection', () => {
expect(events).toHaveLength(1);

expect(events[0].amount).toBe('1000000000000000000000000');
expect(events[0].timestamp).toBe(1631788427230);
expect(events[0].timestamp).toBe(1631788427);
expect(events[0].parameters?.receiptId).toBe('FYVnCvJFoNtK7LE2uAdTFfReFMGiCUHMczLsvEni1Cpf');
expect(events[0].parameters?.txHash).toBeUndefined();
expect(events[0].parameters?.block).toBe(47891257);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,21 @@ contract BatchConversionPayments is BatchNoConversionPayments {
* @param _paymentNativeProxy The native payment proxy address to use.
* @param _paymentErc20ConversionProxy The ERC20 Conversion payment proxy address to use.
* @param _paymentNativeConversionFeeProxy The native Conversion payment proxy address to use.
* @param _chainlinkConversionPathAddress The address of the conversion path contract.
* @param _chainlinkConversionPath The address of the conversion path contract.
* @param _owner Owner of the contract.
*/
constructor(
address _paymentErc20Proxy,
address _paymentNativeProxy,
address _paymentErc20ConversionProxy,
address _paymentNativeConversionFeeProxy,
address _chainlinkConversionPathAddress,
address _chainlinkConversionPath,
address _owner
)
BatchNoConversionPayments(
_paymentErc20Proxy,
_paymentNativeProxy,
_chainlinkConversionPathAddress,
_chainlinkConversionPath,
_owner
)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,18 +77,18 @@ contract BatchNoConversionPayments is Ownable {
/**
* @param _paymentErc20Proxy The address to the ERC20 fee payment proxy to use.
* @param _paymentNativeProxy The address to the Native fee payment proxy to use.
* @param _chainlinkConversionPathAddress The address of the conversion path contract.
* @param _chainlinkConversionPath The address of the conversion path contract.
* @param _owner Owner of the contract.
*/
constructor(
address _paymentErc20Proxy,
address _paymentNativeProxy,
address _chainlinkConversionPathAddress,
address _chainlinkConversionPath,
address _owner
) {
paymentErc20Proxy = IERC20FeeProxy(_paymentErc20Proxy);
paymentNativeProxy = IEthereumFeeProxy(_paymentNativeProxy);
chainlinkConversionPath = ChainlinkConversionPath(_chainlinkConversionPathAddress);
chainlinkConversionPath = ChainlinkConversionPath(_chainlinkConversionPath);
transferOwnership(_owner);
batchFee = 0;
}
Expand Down Expand Up @@ -562,10 +562,10 @@ contract BatchNoConversionPayments is Ownable {

/**
* @notice Update the conversion path contract used to fetch conversions.
* @param _chainlinkConversionPathAddress The address of the conversion path contract.
* @param _chainlinkConversionPath The address of the conversion path contract.
*/
function setConversionPathAddress(address _chainlinkConversionPathAddress) external onlyOwner {
chainlinkConversionPath = ChainlinkConversionPath(_chainlinkConversionPathAddress);
function setChainlinkConversionPath(address _chainlinkConversionPath) external onlyOwner {
chainlinkConversionPath = ChainlinkConversionPath(_chainlinkConversionPath);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
{
"internalType": "address",
"name": "_chainlinkConversionPathAddress",
"name": "_chainlinkConversionPath",
"type": "address"
},
{
Expand Down Expand Up @@ -648,11 +648,11 @@
"inputs": [
{
"internalType": "address",
"name": "_chainlinkConversionPathAddress",
"name": "_chainlinkConversionPath",
"type": "address"
}
],
"name": "setConversionPathAddress",
"name": "setChainlinkConversionPath",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
},
{
"internalType": "address",
"name": "_chainlinkConversionPathAddress",
"name": "_chainlinkConversionPath",
"type": "address"
},
{
Expand Down Expand Up @@ -408,11 +408,11 @@
"inputs": [
{
"internalType": "address",
"name": "_chainlinkConversionPathAddress",
"name": "_chainlinkConversionPath",
"type": "address"
}
],
"name": "setConversionPathAddress",
"name": "setChainlinkConversionPath",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function"
Expand Down

0 comments on commit 6de03f6

Please sign in to comment.