forked from sushiswap/sushiswap-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sushiswap#12 from grod220/serialize
feat: adding serialize method to CurrencyAmount
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { Token } from './Token' | ||
import { NativeCurrency } from '../entities/NativeCurrency' | ||
import { Currency } from '../entities/Currency' | ||
import { ChainId } from '../enums' | ||
|
||
describe('AbstractCurrency', () => { | ||
const ADDRESS_ONE = '0x0000000000000000000000000000000000000001' | ||
|
||
describe('#serialize', () => { | ||
it('renders string of address for Token', () => { | ||
const token = new Token(1, ADDRESS_ONE, 3) | ||
expect(token.serialize()).toEqual(ADDRESS_ONE) | ||
}) | ||
|
||
it('renders string of address for NativeCurrency', () => { | ||
class MoonBeam extends NativeCurrency { | ||
constructor(chainId: number) { | ||
super(chainId, 18) | ||
} | ||
equals(other: Currency): boolean { | ||
return other.isNative && other.chainId === this.chainId | ||
} | ||
get wrapped(): Token { | ||
return new Token(ChainId.MAINNET, ADDRESS_ONE, 18) | ||
} | ||
} | ||
expect(new MoonBeam(ChainId.MAINNET).serialize()).toEqual(ADDRESS_ONE) | ||
}) | ||
}) | ||
}) |
This file contains 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 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 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