Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: processor for ERC20FeeProxy on Near #1096

Merged
merged 7 commits into from
Apr 13, 2023

Conversation

yomarion
Copy link
Member

@yomarion yomarion commented Apr 7, 2023

Description of the changes

feat: payment-processor method for paying an ERC20FeeProxy request on Near, by sending fungible tokens to a proxy contract.

chore: deployment address for mainnet.

@coveralls
Copy link

coveralls commented Apr 7, 2023

Coverage Status

Coverage: 87.342% (-0.2%) from 87.584% when pulling 67e119e on feat/payment-processor-near-ft into 1a5618b on master.

@@ -77,8 +77,8 @@ export function encodeSwapToPayAnyToErc20Request(
signerOrProvider: providers.Provider | Signer = getProvider(),
options: IRequestPaymentOptions,
): string {
const conversionSettings = options?.conversion;
const swapSettings = options?.swap;
const conversionSettings = options.conversion;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related, these arguments are not optional anymore.

@@ -107,7 +106,7 @@ export function getRequestPaymentValues(request: ClientTypes.IRequestData): {
expectedStartDate,
tokensAccepted,
maxRateTimespan,
network,
network: network ?? request.currencyInfo.network,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not related but it looks obvious and convenient.

@yomarion yomarion marked this pull request as ready for review April 12, 2023 16:41
@yomarion yomarion removed the request for review from kevindavee April 12, 2023 16:42
);
}
const proxyAddress = erc20FeeProxyArtifact.getAddress(network, 'near');
if (!(await isReceiverReady(walletConnection, request.currencyInfo.value, proxyAddress))) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just to make it clear, everytime we support a new ERC20 on near, we will have to fund our proxy contract with at least MIN_STORAGE_FOR_FUNGIBLE of this token, correct ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leoslr Yes, that's correct. I plan to check how other dapps do, especially, our contract should probably handle the storage in the same transaction, in a future version. cc @alexandre-abrioux

packages/payment-processor/src/payment/utils-near.ts Outdated Show resolved Hide resolved
return balance.gte(amount);
});
}
if (token.type === RequestLogicTypes.CURRENCY.ERC20) {
Copy link
Contributor

@leoslr leoslr Apr 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this case, shouldn't we also check the account solvency in native currency for:

  • The transaction costs (not sure how this works on Near)
  • The mandatory deposit of 1 yoctoNEAR

If you add the condition, having the associated test would be nice

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a very good point, I did not think of that. The wallet UX is quite good when it comes to lack of NEAR (for both fees and deposit), so I think it's OK to let it handle this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

* @param tokenAddress
* @param paymentAddress
*/
export const storageDeposit = async (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not directly related to this PR, but if the payee does not have the required storage deposit, how do we plan to handle this on the FE.
Is it the payer who will have to perform an additional transaction to send the storage deposit amount to the payee's account, and then perform the actual payment ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So that's a key question I haven't answered yet. I should check how other dapps do. I think we should assume that the payer pays for this storage in this case (and we should thus increase the transaction deposit).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@alexandre-abrioux alexandre-abrioux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@leoslr had good comments/questions, I'm also interested in those. Apart from that, approved 👌

@yomarion yomarion enabled auto-merge (squash) April 13, 2023 15:01
@yomarion yomarion merged commit ccc0bd4 into master Apr 13, 2023
@yomarion yomarion deleted the feat/payment-processor-near-ft branch April 13, 2023 15:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants