Skip to content

Request SDK - Make IConversionSettings.currency optional #1629

@MantisClone

Description

@MantisClone

Problem

Calling prepareBatchConversionPaymentTransaction() with options: IRequestPaymentOptions with conversion?: IConversionSettings; without currency: RequestLogicTypes.ICurrency; throws a TypeError, even though the function still works without it.

Possible Solutions

Options:

  1. Make the currency property of the IConversionSettings type optional.
  2. Adjust the input type of prepareBatchConversionPaymentTransaction().

Reference

/**
* Prepares a transaction to pay a batch of requests with an ERC20 currency
* that can be different from the request currency (eg. fiat).
* It can be used with a Multisig contract.
* @param enrichedRequests List of EnrichedRequests to pay.
* @param options It contains 3 paramaters required to prepare a batch payments:
* - conversion: It must contains the currencyManager.
* - skipFeeUSDLimit: It checks the value of batchFeeAmountUSDLimit of the batch proxy deployed.
* Setting the value to true skips the USD fee limit, and reduces gas consumption.
* - version: The version of the batch conversion proxy.
*/
export function prepareBatchConversionPaymentTransaction(
enrichedRequests: EnrichedRequest[],
options: IRequestPaymentOptions,
): IPreparedTransaction {
const encodedTx = encodePayBatchConversionRequest(
enrichedRequests,
options.skipFeeUSDLimit,
options.conversion,
);
const value = getBatchTxValue(enrichedRequests);
const proxyAddress = getBatchConversionProxyAddress(enrichedRequests[0].request, options.version);
return {
data: encodedTx,
to: proxyAddress,
value,
};
}

export interface IConversionSettings {
/** should be a valid currency type and accepted token value */
currency: RequestLogicTypes.ICurrency;
/** maximum number of tokens to be spent when the conversion is made */
maxToSpend?: BigNumberish;
/** a currency manager to access currencies property, like decimals */
currencyManager?: CurrencyTypes.ICurrencyManager;
/** maximum time in seconds of how old chainlink rate can be used, default is zero for infinitely old */
maxRateAge?: number;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    Status

    🎫 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions