Skip to content

Commit

Permalink
Rename SwapAsset.USDT to SwapAsset.USDT_MATIC
Browse files Browse the repository at this point in the history
Add doc comments to SwapAsset
  • Loading branch information
sisou committed Nov 1, 2024
1 parent 2482141 commit 908984b
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Erc20AssetAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export interface Web3Client {
endBlock?: number;
}

export class Erc20AssetAdapter implements AssetAdapter<SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT> {
export class Erc20AssetAdapter implements AssetAdapter<SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT_MATIC> {
private cancelCallback: ((reason: Error) => void) | null = null;
private stopped = false;

Expand Down
15 changes: 12 additions & 3 deletions src/IAssetAdapter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,30 @@ import { NimiqClient, TransactionDetails as NimiqTransactionDetails } from './Ni
export enum SwapAsset {
NIM = 'NIM',
BTC = 'BTC',
/**
* Legacy bridged USDC.e on Polygon.
*/
USDC = 'USDC',
/**
* Native USDC on Polygon.
*/
USDC_MATIC = 'USDC_MATIC',
USDT = 'USDT', // Alternatively USDT_MATIC
/**
* Bridged USDT on Polygon.
*/
USDT_MATIC = 'USDT_MATIC',
EUR = 'EUR',
}

export type Transaction<TAsset extends SwapAsset> = TAsset extends SwapAsset.NIM ? NimiqTransactionDetails
: TAsset extends SwapAsset.BTC ? BitcoinTransactionDetails
: TAsset extends SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT ? Erc20TransactionDetails
: TAsset extends SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT_MATIC ? Erc20TransactionDetails
: TAsset extends SwapAsset.EUR ? EuroHtlcDetails
: never;

export type Client<TAsset extends SwapAsset> = TAsset extends SwapAsset.NIM ? NimiqClient
: TAsset extends SwapAsset.BTC ? BitcoinClient
: TAsset extends SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT ? Web3Client
: TAsset extends SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT_MATIC ? Web3Client
: TAsset extends SwapAsset.EUR ? OasisClient
: never;

Expand Down
6 changes: 3 additions & 3 deletions src/SwapHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export type Contract<TAsset extends SwapAsset> = {
address: string,
data: TAsset extends SwapAsset.NIM ? string : never,
script: TAsset extends SwapAsset.BTC ? string : never,
contract: TAsset extends SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT ? string : never,
contract: TAsset extends SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT_MATIC ? string : never,
},
};

Expand Down Expand Up @@ -47,9 +47,9 @@ export class SwapHandler<FromAsset extends SwapAsset, ToAsset extends SwapAsset>
return new BitcoinAssetAdapter(client as Client<SwapAsset.BTC>) as AssetAdapter<SwapAsset>;
case SwapAsset.USDC:
case SwapAsset.USDC_MATIC:
case SwapAsset.USDT:
case SwapAsset.USDT_MATIC:
return new Erc20AssetAdapter(
client as Client<SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT>,
client as Client<SwapAsset.USDC | SwapAsset.USDC_MATIC | SwapAsset.USDT_MATIC>,
) as AssetAdapter<
SwapAsset
>;
Expand Down

0 comments on commit 908984b

Please sign in to comment.