burner-wallet / burner-wallet-2

A modular, extendable Burner Wallet
MIT License
87 stars 36 forks source link

Fix exchange Bridge estimate methods types #25

Closed patitonar closed 4 years ago

patitonar commented 4 years ago

While using the changes introduced in https://github.com/burner-wallet/burner-wallet-2/pull/24 I found that by not providing explicitly the types to the methods estimateXtoY in Bridge class that extends Pair, the wrong types were generated.

These are the types generated for estimateAtoB and estimateBtoA in Pair.

export interface EstimateReturn {
    estimate: string;
    estimateInfo?: null | string;
}

estimateAtoB(value: ValueTypes): Promise<EstimateReturn>;
estimateBtoA(value: ValueTypes): Promise<EstimateReturn>;

And these are the generated in Bridge

estimateAtoB(value: ValueTypes): Promise<{
        estimate: string;
        estimateInfo: null;
    }>;
estimateBtoA(value: ValueTypes): Promise<{
    estimate: string;
    estimateInfo: null;
}>;

This produces errors when trying to return string values for estimateInfo in classes that extend Bridge.

Type '(value: ValueTypes) => Promise<EstimateReturn>' is not assignable to type '(value: ValueTypes) => Promise<{ estimate: string; estimateInfo: null; }>'.

To fix this, this PR specifies the returned values types also in Bridge