-
Notifications
You must be signed in to change notification settings - Fork 91
feat: improve payment network types #1355
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ import { generate8randomBytes } from '@requestnetwork/utils'; | |
| * Abstract class to extend to get the payment balance of conversion requests | ||
| */ | ||
| export abstract class AnyToAnyDetector< | ||
| TExtension extends ExtensionTypes.PnFeeReferenceBased.IFeeReferenceBased, | ||
| TExtension extends ExtensionTypes.PnFeeReferenceBased.IFeeReferenceBased<any>, | ||
|
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. there are a few |
||
| TPaymentEventParameters extends Partial<ExtensionTypes.PnFeeReferenceBased.IAddFeeParameters>, | ||
| > extends FeeReferenceBasedDetector<TExtension, TPaymentEventParameters> { | ||
| /** | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ export type IAnyToERC20 = PnAnyToAnyConversion.IConversionReferenceBased<ICreati | |
|
|
||
| /** Parameters for the creation action */ | ||
| export interface ICreationParameters extends PnAnyToAnyConversion.ICreationParameters { | ||
| network?: EvmChainName; | ||
| // FIXME: should be mandatory according to AnyToErc20ProxyPaymentNetwork createCreationAction() logic | ||
| acceptedTokens?: string[]; | ||
| network: EvmChainName; | ||
| acceptedTokens: string[]; | ||
|
Comment on lines
+9
to
+10
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. match what's expected by the PN! 🎉 |
||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,7 +1,10 @@ | ||
| import { ChainName } from '../currency-types'; | ||
| import * as PnAnyToAnyConversion from './pn-any-to-any-conversion-types'; | ||
|
|
||
| /** Any to ETH reference-based payment network extension interface */ | ||
| export type IAnyToEth = PnAnyToAnyConversion.IConversionReferenceBased; | ||
| export type IAnyToEth = PnAnyToAnyConversion.IConversionReferenceBased<ICreationParameters>; | ||
|
|
||
| /** Parameters for the creation action */ | ||
| export type ICreationParameters = PnAnyToAnyConversion.ICreationParameters; | ||
| export type ICreationParameters = Omit<PnAnyToAnyConversion.ICreationParameters, 'network'> & { | ||
| network: ChainName; | ||
|
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. network is mandatory for AnyToEth |
||
| }; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,16 +2,17 @@ import { IIdentity } from './identity-types'; | |
| import * as RequestLogic from './request-logic-types'; | ||
| import * as ExtensionTypes from './extension-types'; | ||
| import { ICreationParameters } from './extensions/pn-any-declarative-types'; | ||
| import { ICreationParameters as ICreationParametersAnyToAny } from './extensions/pn-any-to-any-conversion-types'; | ||
| import { EvmChainName } from './currency-types'; | ||
|
|
||
| /** Interface for payment network extensions state and interpretation */ | ||
| export interface IPaymentNetwork< | ||
| TEventParameters extends GenericEventParameters = GenericEventParameters, | ||
| TCreationParameters = any, | ||
| > { | ||
| paymentNetworkId: ExtensionTypes.PAYMENT_NETWORK_ID; | ||
| extension: ExtensionTypes.IExtension; | ||
| createExtensionsDataForCreation: (paymentNetworkCreationParameters: any) => Promise<any>; | ||
| createExtensionsDataForCreation: ( | ||
| paymentNetworkCreationParameters: TCreationParameters, | ||
| ) => Promise<ExtensionTypes.IAction<any>>; | ||
|
Comment on lines
+14
to
+15
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. slightly more precise... |
||
| createExtensionsDataForAddRefundInformation: (parameters: any) => any; | ||
| createExtensionsDataForAddPaymentInformation: (parameters: any) => any; | ||
| getBalance(request: RequestLogic.IRequest): Promise<IBalanceWithEvents<TEventParameters>>; | ||
|
|
@@ -34,12 +35,6 @@ export interface IFeeReferenceBasedCreationParameters extends IReferenceBasedCre | |
| feeAmount?: string; | ||
| } | ||
|
|
||
| /** Parameters to create a request with "any to erc20" payment network */ | ||
| export interface IAnyToErc20CreationParameters extends ICreationParametersAnyToAny { | ||
| acceptedTokens?: string[]; | ||
| network?: EvmChainName; | ||
| } | ||
|
|
||
| /** | ||
| * Interface to create a payment network | ||
| * @deprecated Use `PaymentNetworkCreateParameters` type instead | ||
|
|
@@ -51,17 +46,27 @@ export interface IPaymentNetworkCreateParameters<T = any> { | |
|
|
||
| export type PaymentNetworkCreateParameters = | ||
|
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. the "complexity" of the type prevented usage of Extract
Contributor
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. Arg, I remembered struggling with this. |
||
| | { | ||
| id: | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_PROXY_CONTRACT | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.NATIVE_TOKEN; | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_PROXY_CONTRACT; | ||
| parameters: ExtensionTypes.PnReferenceBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.ETH_INPUT_DATA; | ||
| parameters: ExtensionTypes.PnReferenceBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_FEE_PROXY_CONTRACT | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.ETH_FEE_PROXY_CONTRACT | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_TRANSFERABLE_RECEIVABLE; | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.NATIVE_TOKEN; | ||
| parameters: ExtensionTypes.PnReferenceBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_FEE_PROXY_CONTRACT; | ||
| parameters: ExtensionTypes.PnFeeReferenceBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.ETH_FEE_PROXY_CONTRACT; | ||
| parameters: ExtensionTypes.PnFeeReferenceBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_TRANSFERABLE_RECEIVABLE; | ||
| parameters: ExtensionTypes.PnFeeReferenceBased.ICreationParameters; | ||
| } | ||
| | { | ||
|
|
@@ -85,10 +90,15 @@ export type PaymentNetworkCreateParameters = | |
| parameters: ExtensionTypes.PnStreamReferenceBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.BITCOIN_ADDRESS_BASED | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.TESTNET_BITCOIN_ADDRESS_BASED | ||
| | ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED; | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.BITCOIN_ADDRESS_BASED; | ||
| parameters: ExtensionTypes.PnAddressBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.TESTNET_BITCOIN_ADDRESS_BASED; | ||
| parameters: ExtensionTypes.PnAddressBased.ICreationParameters; | ||
| } | ||
| | { | ||
| id: ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_ADDRESS_BASED; | ||
| parameters: ExtensionTypes.PnAddressBased.ICreationParameters; | ||
| }; | ||
|
|
||
|
|
||
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.
just a change in error message to make it clearer