-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
7c57a51
chore(tsconfig): specify included files during dev
alexandre-abrioux c3f980c
WIP
alexandre-abrioux 9e7a533
WIP
alexandre-abrioux 0396371
WIP
alexandre-abrioux 40aa6ba
WIP
alexandre-abrioux a71afe7
fix any-to-near tests
alexandre-abrioux b627be7
move near to subdir
alexandre-abrioux 37c3813
fix tests
alexandre-abrioux 3f1a377
fix tests
alexandre-abrioux ac8ea1b
better types
alexandre-abrioux 30827dd
WIP
alexandre-abrioux 74251c9
merge master
alexandre-abrioux b472611
fix tests
alexandre-abrioux d7cbe70
fix tests
alexandre-abrioux 981d21b
fix tests
alexandre-abrioux 5bf88cb
add NETWORK const
alexandre-abrioux d436294
review update
alexandre-abrioux 9d018a1
Merge remote-tracking branch 'origin/master' into pn-check-contract-d…
alexandre-abrioux 203ef8f
fix after merge
alexandre-abrioux 08b65f9
fix after merge
alexandre-abrioux aef7c7f
fix aurora test
alexandre-abrioux 58c1457
fix type
alexandre-abrioux f947d6b
fix type
alexandre-abrioux 68e59df
Merge remote-tracking branch 'origin/master' into pn-check-contract-d…
alexandre-abrioux b3916ca
abstract protected constructor
alexandre-abrioux e57b267
fixes https://github.com/RequestNetwork/requestNetwork/pull/950#discu…
alexandre-abrioux 8675519
add warn for ERC20InfoRetriever
alexandre-abrioux 8b49ce1
Merge branch 'master' into pn-check-contract-deployed
alexandre-abrioux e57154b
fixes https://github.com/RequestNetwork/requestNetwork/pull/950#discu…
alexandre-abrioux File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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
Contributor
Author
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 | ||
| */ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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( | ||
|
Contributor
Author
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 { | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.