Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/advanced-logic/src/extensions/abstract-extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import Utils from '@requestnetwork/utils';
export abstract class AbstractExtension<TCreationParameters> {
protected actions: ExtensionTypes.SupportedActions;

public constructor(
public extensionType: ExtensionTypes.TYPE,
public extensionId: ExtensionTypes.ID,
public currentVersion: string,
protected constructor(
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Constructors on abstract classes be protected

public readonly extensionType: ExtensionTypes.TYPE,
public readonly extensionId: ExtensionTypes.ID,
public readonly currentVersion: string,
) {
this.actions = {};
}
Expand Down
4 changes: 2 additions & 2 deletions packages/advanced-logic/src/extensions/content-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export default class ContentDataExtension<
TCreationParameters extends ExtensionTypes.ContentData.ICreationParameters = ExtensionTypes.ContentData.ICreationParameters,
> extends AbstractExtension<TCreationParameters> {
public constructor(
public extensionId: ExtensionTypes.ID = ExtensionTypes.ID.CONTENT_DATA,
public currentVersion: string = CURRENT_VERSION,
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID.CONTENT_DATA,
public readonly currentVersion: string = CURRENT_VERSION,
) {
super(ExtensionTypes.TYPE.CONTENT_DATA, extensionId, currentVersion);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ import DeclarativePaymentNetwork from './declarative';
export default abstract class AddressBasedPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnAddressBased.ICreationParameters = ExtensionTypes.PnAddressBased.ICreationParameters,
> extends DeclarativePaymentNetwork<TCreationParameters> {
public constructor(
public extensionId: ExtensionTypes.ID,
public currentVersion: string,
public supportedNetworks: string[],
public supportedCurrencyType: RequestLogicTypes.CURRENCY,
protected constructor(
public readonly extensionId: ExtensionTypes.ID,
public readonly currentVersion: string,
public readonly supportedNetworks: string[],
public readonly supportedCurrencyType: RequestLogicTypes.CURRENCY,
) {
super(extensionId, currentVersion);
this.actions = {
Expand All @@ -29,7 +29,7 @@ export default abstract class AddressBasedPaymentNetwork<
/**
* Creates the extensionsData for address based payment networks
*
* @param extensions extensions parameters to create
* @param creationParameters extensions parameters to create
*
* @returns IExtensionCreationAction the extensionsData to be stored in the request
*/
Expand Down Expand Up @@ -58,7 +58,7 @@ export default abstract class AddressBasedPaymentNetwork<
/**
* Creates the extensionsData to add a payment address
*
* @param extensions extensions parameters to create
* @param addPaymentAddressParameters extensions parameters to create
*
* @returns IAction the extensionsData to be stored in the request
*/
Expand All @@ -82,7 +82,7 @@ export default abstract class AddressBasedPaymentNetwork<
/**
* Creates the extensionsData to add a refund address
*
* @param extensions extensions parameters to create
* @param addRefundAddressParameters extensions parameters to create
*
* @returns IAction the extensionsData to be stored in the request
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ const CURRENT_VERSION = '0.1.0';

export default class AnyToErc20ProxyPaymentNetwork extends Erc20FeeProxyPaymentNetwork {
public constructor(
private currencyManager: ICurrencyManager,
extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ANY_TO_ERC20_PROXY,
currentVersion: string = CURRENT_VERSION,
private readonly currencyManager: ICurrencyManager,
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ANY_TO_ERC20_PROXY,
public readonly currentVersion: string = CURRENT_VERSION,
) {
super(
extensionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ const CURRENT_VERSION = '0.2.0';
export default class AnyToEthProxyPaymentNetwork extends EthereumFeeProxyPaymentNetwork {
public constructor(
private currencyManager: ICurrencyManager,
extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ANY_TO_ETH_PROXY,
currentVersion: string = CURRENT_VERSION,
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ANY_TO_ETH_PROXY,
public readonly currentVersion: string = CURRENT_VERSION,
) {
super(extensionId, currentVersion, conversionSupportedNetworks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import { InvalidPaymentAddressError } from './address-based';

export default abstract class AnyToNativeTokenPaymentNetwork extends FeeReferenceBasedPaymentNetwork {
public constructor(
extensionId: ExtensionTypes.ID,
currentVersion: string,
supportedNetworks: string[],
protected constructor(
public readonly extensionId: ExtensionTypes.ID,
public readonly currentVersion: string,
public readonly supportedNetworks: string[],
) {
super(extensionId, currentVersion, supportedNetworks, RequestLogicTypes.CURRENCY.ETH);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ const supportedNetworks = ['aurora', 'aurora-testnet'];
export default class AnyToNearPaymentNetwork extends AnyToNativeTokenPaymentNetwork {
public constructor(
private currencyManager: ICurrencyManager,
extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ANY_TO_NATIVE_TOKEN,
currentVersion: string = CURRENT_VERSION,
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ANY_TO_NATIVE_TOKEN,
public readonly currentVersion: string = CURRENT_VERSION,
) {
super(extensionId, currentVersion, supportedNetworks);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ const BITCOIN_NETWORK = 'mainnet';
*/
export default class BitcoinAddressBasedPaymentNetwork extends AddressBasedPaymentNetwork {
public constructor(
public extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_BITCOIN_ADDRESS_BASED,
public currentVersion: string = CURRENT_VERSION,
public supportedNetworks: string[] = [BITCOIN_NETWORK],
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_BITCOIN_ADDRESS_BASED,
public readonly currentVersion: string = CURRENT_VERSION,
public readonly supportedNetworks: string[] = [BITCOIN_NETWORK],
) {
super(extensionId, currentVersion, supportedNetworks, RequestLogicTypes.CURRENCY.BTC);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ export default class DeclarativePaymentNetwork<
TCreationParameters extends ExtensionTypes.PnAnyDeclarative.ICreationParameters = ExtensionTypes.PnAnyDeclarative.ICreationParameters,
> extends AbstractExtension<TCreationParameters> {
public constructor(
public extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ANY_DECLARATIVE,
public currentVersion: string = CURRENT_VERSION,
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ANY_DECLARATIVE,
public readonly currentVersion: string = CURRENT_VERSION,
) {
super(ExtensionTypes.TYPE.PAYMENT_NETWORK, extensionId, currentVersion);
this.actions = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import AddressBasedPaymentNetwork from '../address-based';
import EvmBasedPaymentNetwork from '../evm-based';

const CURRENT_VERSION = '0.1.0';

const supportedNetworks = ['mainnet', 'rinkeby', 'private', 'goerli'];

/**
* Implementation of the payment network to pay in ERC20 tokens based on an Ethereum address
* With this extension one request can have two dedicated Ethereum addresses (one for payment and one for refund)
* Every ERC20 ethereum transaction, using the request currency ERC20, that reaches these addresses will be interpreted as payment or refund.
* Important: the addresses must be exclusive to the request
*/
export default class Erc20AddressBasedPaymentNetwork extends AddressBasedPaymentNetwork {
export default class Erc20AddressBasedPaymentNetwork
extends AddressBasedPaymentNetwork
implements EvmBasedPaymentNetwork
{
public constructor() {
super(
ExtensionTypes.ID.PAYMENT_NETWORK_ERC20_ADDRESS_BASED,
CURRENT_VERSION,
supportedNetworks,
EvmBasedPaymentNetwork.EVM_NETWORKS,
RequestLogicTypes.CURRENCY.ERC20,
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,35 +1,23 @@
import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import { FeeReferenceBasedPaymentNetwork } from '../fee-reference-based';
import EvmBasedPaymentNetwork from '../evm-based';

const CURRENT_VERSION = '0.2.0';

/**
* Implementation of the payment network to pay in ERC20, including third-party fees payment, based on a reference provided to a proxy contract.
*/
export default class Erc20FeeProxyPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnFeeReferenceBased.ICreationParameters = ExtensionTypes.PnFeeReferenceBased.ICreationParameters,
> extends FeeReferenceBasedPaymentNetwork<TCreationParameters> {
TCreationParameters extends ExtensionTypes.PnFeeReferenceBased.ICreationParameters = ExtensionTypes.PnFeeReferenceBased.ICreationParameters,
>
extends FeeReferenceBasedPaymentNetwork<TCreationParameters>
implements EvmBasedPaymentNetwork
{
public constructor(
extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ERC20_FEE_PROXY_CONTRACT,
currentVersion: string = CURRENT_VERSION,
public supportedNetworks: string[] = [
'mainnet',
'rinkeby',
'goerli',
'private',
'matic',
'mumbai',
'celo',
'alfajores',
'fuse',
'bsctest',
'bsc',
'xdai',
'fantom',
'arbitrum-rinkeby',
'arbitrum-one',
'avalanche',
],
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ERC20_FEE_PROXY_CONTRACT,
public readonly currentVersion: string = CURRENT_VERSION,
public readonly supportedNetworks: string[] = EvmBasedPaymentNetwork.EVM_NETWORKS,
public supportedCurrencyType: RequestLogicTypes.CURRENCY = RequestLogicTypes.CURRENCY.ERC20,
) {
super(extensionId, currentVersion, supportedNetworks, supportedCurrencyType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import ReferenceBasedPaymentNetwork from '../reference-based';
import EvmBasedPaymentNetwork from '../evm-based';

const CURRENT_VERSION = '0.1.0';

/**
* Implementation of the payment network to pay in ERC20 based on a reference provided to a proxy contract.
*/
export default class Erc20ProxyPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnReferenceBased.ICreationParameters = ExtensionTypes.PnReferenceBased.ICreationParameters,
> extends ReferenceBasedPaymentNetwork<TCreationParameters> {
TCreationParameters extends ExtensionTypes.PnReferenceBased.ICreationParameters = ExtensionTypes.PnReferenceBased.ICreationParameters,
>
extends ReferenceBasedPaymentNetwork<TCreationParameters>
implements EvmBasedPaymentNetwork
{
public constructor(
public extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ERC20_PROXY_CONTRACT,
public currentVersion: string = CURRENT_VERSION,
public supportedNetworks: string[] = ['mainnet', 'rinkeby', 'goerli', 'private'],
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ERC20_PROXY_CONTRACT,
public readonly currentVersion: string = CURRENT_VERSION,
public readonly supportedNetworks: string[] = EvmBasedPaymentNetwork.EVM_NETWORKS,
public supportedCurrencyType: RequestLogicTypes.CURRENCY = RequestLogicTypes.CURRENCY.ERC20,
) {
super(extensionId, currentVersion, supportedNetworks, supportedCurrencyType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import { ExtensionTypes, RequestLogicTypes, TypesUtils } from '@requestnetwork/types';
import ReferenceBasedPaymentNetwork from '../reference-based';
import Utils from '@requestnetwork/utils';
import EvmBasedPaymentNetwork from '../evm-based';
const CURRENT_VERSION = '0.1.0';

/**
* Implementation of the payment network to pay in ERC777, including third-party fees payment, based on a reference provided to a proxy contract.
*/
export default class Erc777StreamPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnStreamReferenceBased.ICreationParameters = ExtensionTypes.PnStreamReferenceBased.ICreationParameters,
> extends ReferenceBasedPaymentNetwork<TCreationParameters> {
TCreationParameters extends ExtensionTypes.PnStreamReferenceBased.ICreationParameters = ExtensionTypes.PnStreamReferenceBased.ICreationParameters,
>
extends ReferenceBasedPaymentNetwork<TCreationParameters>
implements EvmBasedPaymentNetwork
{
public constructor(
extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ERC777_STREAM,
currentVersion: string = CURRENT_VERSION,
public supportedNetworks: string[] = [
'matic',
'xdai',
'mumbai',
'rinkeby',
'goerli',
'arbitrum-rinkeby',
],
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ERC777_STREAM,
public readonly currentVersion: string = CURRENT_VERSION,
public readonly supportedNetworks: string[] = EvmBasedPaymentNetwork.EVM_NETWORKS,
Copy link
Contributor

Choose a reason for hiding this comment

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

@alexandre-abrioux ERC777 is not supported on all networks, most importantly mainnet is not supported

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@KolevDarko I took a different approach in the end as advised by Benji. I'm working on it here: #950

public supportedCurrencyType: RequestLogicTypes.CURRENCY = RequestLogicTypes.CURRENCY.ERC777,
) {
super(extensionId, currentVersion, supportedNetworks, supportedCurrencyType);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import { FeeReferenceBasedPaymentNetwork } from '../fee-reference-based';
import EvmBasedPaymentNetwork from '../evm-based';

const CURRENT_VERSION = '0.2.0';

/**
* Implementation of the payment network to pay in Ethereum, including third-party fees payment, based on a reference provided to a proxy contract.
*/
export default class EthereumFeeProxyPaymentNetwork<
TCreationParameters extends ExtensionTypes.PnFeeReferenceBased.ICreationParameters = ExtensionTypes.PnFeeReferenceBased.ICreationParameters,
> extends FeeReferenceBasedPaymentNetwork<TCreationParameters> {
TCreationParameters extends ExtensionTypes.PnFeeReferenceBased.ICreationParameters = ExtensionTypes.PnFeeReferenceBased.ICreationParameters,
>
extends FeeReferenceBasedPaymentNetwork<TCreationParameters>
implements EvmBasedPaymentNetwork
{
public constructor(
extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ETH_FEE_PROXY_CONTRACT,
currentVersion: string = CURRENT_VERSION,
public supportedNetworks: string[] = ['mainnet', 'rinkeby', 'goerli', 'private'],
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ETH_FEE_PROXY_CONTRACT,
public readonly currentVersion: string = CURRENT_VERSION,
public readonly supportedNetworks: string[] = EvmBasedPaymentNetwork.EVM_NETWORKS,
) {
super(extensionId, currentVersion, supportedNetworks, RequestLogicTypes.CURRENCY.ETH);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,33 +1,27 @@
import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types';
import ReferenceBasedPaymentNetwork from '../reference-based';
import EvmBasedPaymentNetwork from '../evm-based';

const CURRENT_VERSION = '0.3.0';
const supportedNetworks = [
'mainnet',
'rinkeby',
'goerli',
'xdai',
'sokol',
'fuse',
'matic',
'celo',
'fantom',
'bsctest',
'bsc',
'arbitrum-rinkeby',
'arbitrum-one',
'avalanche',
];

/**
* Implementation of the payment network to pay in native token
* FIXME: rename into EVMNativePaymentNetwork
*/
export default class EthInputPaymentNetwork extends ReferenceBasedPaymentNetwork {
export default class EthInputPaymentNetwork
extends ReferenceBasedPaymentNetwork
implements EvmBasedPaymentNetwork
{
public constructor(
extensionId: ExtensionTypes.ID = ExtensionTypes.ID.PAYMENT_NETWORK_ETH_INPUT_DATA,
currentVersion: string = CURRENT_VERSION,
public readonly extensionId: ExtensionTypes.ID = ExtensionTypes.ID
.PAYMENT_NETWORK_ETH_INPUT_DATA,
public readonly currentVersion: string = CURRENT_VERSION,
) {
super(extensionId, currentVersion, supportedNetworks, RequestLogicTypes.CURRENCY.ETH);
super(
extensionId,
currentVersion,
EvmBasedPaymentNetwork.EVM_NETWORKS,
RequestLogicTypes.CURRENCY.ETH,
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
export default abstract class EvmBasedPaymentNetwork {
static EVM_NETWORKS = [
'alfajores',
'arbitrum-one',
'arbitrum-rinkeby',
'avalanche',
'bsc',
'bsctest',
'celo',
'fantom',
'fuse',
'goerli',
'mainnet',
'matic',
'mumbai',
'private',
'rinkeby',
'sokol',
'xdai',
];
}
Loading