Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 91
refactor: check for contract deployment before creating pn#950
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
7c57a51c3f980c9e7a533039637140aa6baa71afe7b627be737c38133f1a377ac8ea1b30827dd74251c9b472611d7cbe70981d21b5bf88cbd4362949d018a1203ef8f08b65f9aef7c7f58c1457f947d6b68e59dfb3916cae57b26786755198b49ce1e57154bFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -9,11 +9,8 @@ const CURRENT_VERSION = '0.1.0'; | ||
| 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, | ||
| ) { | ||
| super(ExtensionTypes.TYPE.CONTENT_DATA, extensionId, currentVersion); | ||
| public constructor() { | ||
| super(ExtensionTypes.TYPE.CONTENT_DATA, ExtensionTypes.ID.CONTENT_DATA, CURRENT_VERSION); | ||
Comment on lines
-12
to
+13
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Type of change made for classes that never get extended | ||
| } | ||
| /** | ||
| @@ -40,7 +37,6 @@ export default class ContentDataExtension< | ||
| * Applies a creation | ||
| * | ||
| * @param extensionAction action to apply | ||
| * @param timestamp | ||
| * | ||
| * @returns state of the extension created | ||
| */ | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,38 +1,34 @@ | ||
| import { FeeReferenceBasedPaymentNetwork } from './fee-reference-based'; | ||
| import { ExtensionTypes, RequestLogicTypes } from '@requestnetwork/types'; | ||
| import { InvalidPaymentAddressError } from './address-based'; | ||
| import { InvalidPaymentAddressError, UnsupportedNetworkError } from './address-based'; | ||
| export default abstract class AnyToNativeTokenPaymentNetwork extends FeeReferenceBasedPaymentNetwork { | ||
| public constructor( | ||
| protected constructor( | ||
ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. abstract class constructors should be protected | ||
| extensionId: ExtensionTypes.ID, | ||
| currentVersion: string, | ||
| supportedNetworks: string[], | ||
| public readonly supportedNetworks: string[], | ||
| ) { | ||
| super(extensionId, currentVersion, supportedNetworks, RequestLogicTypes.CURRENCY.ETH); | ||
| super(extensionId, currentVersion, RequestLogicTypes.CURRENCY.ETH); | ||
| } | ||
| public createCreationAction( | ||
| creationParameters: ExtensionTypes.PnAnyToAnyConversion.ICreationParameters, | ||
| ): ExtensionTypes.IAction<ExtensionTypes.PnAnyToAnyConversion.ICreationParameters> { | ||
| const network = creationParameters.network; | ||
| this.throwIfInvalidNetwork(network); | ||
| if ( | ||
| creationParameters.paymentAddress && | ||
| !this.isValidAddress(creationParameters.paymentAddress, network) | ||
| !this.isValidAddress(creationParameters.paymentAddress) | ||
| ) { | ||
| throw new InvalidPaymentAddressError(creationParameters.paymentAddress); | ||
| } | ||
| if ( | ||
| creationParameters.refundAddress && | ||
| !this.isValidAddress(creationParameters.refundAddress, network) | ||
| !this.isValidAddress(creationParameters.refundAddress) | ||
| ) { | ||
| throw new InvalidPaymentAddressError(creationParameters.refundAddress, 'refundAddress'); | ||
| } | ||
| if ( | ||
| creationParameters.feeAddress && | ||
| !this.isValidAddress(creationParameters.feeAddress, network) | ||
| ) { | ||
| if (creationParameters.feeAddress && !this.isValidAddress(creationParameters.feeAddress)) { | ||
| throw new InvalidPaymentAddressError(creationParameters.feeAddress, 'feeAddress'); | ||
| } | ||
| if (creationParameters.maxRateTimespan && creationParameters.maxRateTimespan < 0) { | ||
| @@ -42,7 +38,18 @@ export default abstract class AnyToNativeTokenPaymentNetwork extends FeeReferenc | ||
| } | ||
| // eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
| protected abstract isValidAddress(_address: string, _networkName?: string): boolean; | ||
| protected isValidAddress(_address: string): boolean { | ||
| throw new Error( | ||
| `Default implementation of isValidAddress() does not support native tokens. Please override this method.`, | ||
| ); | ||
| } | ||
| protected throwIfInvalidNetwork(network?: string): asserts network is string { | ||
| super.throwIfInvalidNetwork(network); | ||
| if (this.supportedNetworks && !this.supportedNetworks.includes(network)) { | ||
| throw new UnsupportedNetworkError(network, this.supportedNetworks); | ||
| } | ||
| } | ||
| } | ||
| export class InvalidMaxRateTimespanError extends Error { | ||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we go down that line, can we add
anyToEthProxyandfeeProxyContractEthto these 2 generic PNs? And deprecate the "separate" use of these extensions? It does not add anything while we just have Near.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree! We should deprecate
any-to-eth-proxyand instead useany-to-native-token. Not sure however thateth-fee-proxy-contractandnative-tokenare compatible as the latest doesn't support fees as far as I know. I'll keep this PR a refactor without changing payment networks, but let's keep this in mind for the next steps.