Skip to content

Commit

Permalink
from YMA review
Browse files Browse the repository at this point in the history
  • Loading branch information
vrolland committed May 12, 2021
1 parent 9dc7704 commit c95a471
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 17 deletions.
Expand Up @@ -6,11 +6,6 @@ const CURRENT_VERSION = '0.1.0';

/**
* Implementation of the payment network to pay in ERC20, including third-party fees payment, based on a reference provided to a proxy contract.
* With this extension, one request can have three Ethereum addresses (one for payment, one for fees payment, and one for refund)
* Every ERC20 ethereum transaction that reaches these addresses through the proxy contract and has the correct reference will be interpreted as a payment or a refund.
* The value to give as input data is the last 8 bytes of a salted hash of the requestId and the address: `last8Bytes(hash(requestId + salt + address))`:
* The salt should have at least 8 bytes of randomness. A way to generate it is:
* `Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16) + Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16)`
*/
export default class Erc20FeeProxyPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnFeeReferenceBased.ICreationParameters = ExtensionTypes.PnFeeReferenceBased.ICreationParameters
Expand Down
Expand Up @@ -8,11 +8,6 @@ import * as walletAddressValidator from 'wallet-address-validator';

/**
* Implementation of the payment network to pay in ERC20 based on a reference provided to a proxy contract.
* With this extension, one request can have two Ethereum addresses (one for payment and one for refund) and a specific value to give as input data
* Every ERC20 ethereum transaction that reaches these addresses through the proxy contract and has the correct reference will be interpreted as a payment or a refund.
* The value to give as input data is the last 8 bytes of a salted hash of the requestId and the address: `last8Bytes(hash(requestId + salt + address))`:
* The salt should have at least 8 bytes of randomness. A way to generate it is:
* `Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16) + Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16)`
*/
export default class Erc20ProxyPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnReferenceBased.ICreationParameters = ExtensionTypes.PnReferenceBased.ICreationParameters
Expand Down
Expand Up @@ -9,11 +9,6 @@ const supportedNetworks = ['mainnet', 'rinkeby'];

/**
* Implementation of the payment network to pay in ETH based on input data.
* With this extension, one request can have two Ethereum addresses (one for payment and one for refund) and a specific value to give as input data
* Every ETH ethereum transaction that reaches these addresses and has the correct input data will be interpreted as a payment or a refund.
* The value to give as input data is the last 8 bytes of a salted hash of the requestId and the address: `last8Bytes(hash(requestId + salt + address))`:
* The salt should have at least 8 bytes of randomness. A way to generate it is:
* `Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16) + Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16)`
*/
export default class EthInputPaymentNetwork extends ReferenceBasedPaymentNetwork {
public constructor(
Expand Down
Expand Up @@ -6,7 +6,11 @@ const eightHexRegex = /[0-9a-f]{16,}/;

/**
* Core of the reference based payment networks
* This module is called by the reference based payment networks to avoid code redundancy
* Abstract implementation of the payment network to pay with a reference
* With this extension, one request can have two addresses (one for payment and one for refund) and a specific value to give as input data
* The value to give as input data is the last 8 bytes of a salted hash of the requestId and the address: `last8Bytes(hash(requestId + salt + address))`:
* The salt should have at least 8 bytes of randomness. A way to generate it is:
* `Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16) + Math.floor(Math.random() * Math.pow(2, 4 * 8)).toString(16)`
*/
export default abstract class ReferenceBasedPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnReferenceBased.ICreationParameters = ExtensionTypes.PnReferenceBased.ICreationParameters
Expand Down
Expand Up @@ -721,7 +721,7 @@ describe('extensions/payment-network/erc20/any-to-erc20-fee-proxy-contract', ()

it('cannot applyActionToExtensions of addFee with fee amount not valid', () => {
const testnetPaymentAddress = Utils.deepCopy(DataConversionERC20FeeAddData.actionAddFee);
testnetPaymentAddress.parameters.feeAmount = DataConversionERC20FeeAddData.invalidAddress;
testnetPaymentAddress.parameters.feeAmount = "invalid amount";
expect(() => {
anyToErc20Proxy.applyActionToExtension(
DataConversionERC20FeeCreate.requestStateCreatedEmpty.extensions,
Expand Down

0 comments on commit c95a471

Please sign in to comment.