-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: Token not showing on proposals with underlying token (#249)
* fix parseToken function * update version * add parseToken tests * Updating the changelog --------- Co-authored-by: Jør∂¡ <[email protected]>
- Loading branch information
1 parent
a7a6ab7
commit 06de92e
Showing
5 changed files
with
107 additions
and
4 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
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
78 changes: 78 additions & 0 deletions
78
modules/client/test/unit/tokenVoting-client /utils.test.ts
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,78 @@ | ||
import { TokenType } from "@aragon/sdk-client-common"; | ||
import { SubgraphContractType } from "../../../src/tokenVoting/internal/types"; | ||
import { parseToken } from "../../../src/tokenVoting/internal/utils"; | ||
|
||
describe("tokenVoting-client utils", () => { | ||
describe("parseToken", () => { | ||
it("should return ERC721", () => { | ||
const token = parseToken({ | ||
__typename: SubgraphContractType.ERC721, | ||
id: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
}); | ||
expect(token).toEqual({ | ||
address: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
type: TokenType.ERC721, | ||
}); | ||
}); | ||
it("should return ERC20", () => { | ||
const token = parseToken({ | ||
__typename: SubgraphContractType.ERC20, | ||
id: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
decimals: 18, | ||
}); | ||
expect(token).toEqual({ | ||
address: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
decimals: 18, | ||
type: TokenType.ERC20, | ||
}); | ||
}); | ||
it("should return ERC20Wrapper", () => { | ||
const token = parseToken({ | ||
__typename: SubgraphContractType.ERC20_WRAPPER, | ||
id: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
decimals: 18, | ||
underlyingToken: { | ||
__typename: SubgraphContractType.ERC20, | ||
id: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
decimals: 18, | ||
}, | ||
}); | ||
expect(token).toEqual({ | ||
address: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
decimals: 18, | ||
type: TokenType.ERC20, | ||
underlyingToken: { | ||
address: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
decimals: 18, | ||
type: TokenType.ERC20, | ||
}, | ||
}); | ||
}); | ||
it("should return null", () => { | ||
const token = parseToken({ | ||
// @ts-ignore | ||
__typename: "Other", | ||
id: "0x1234567890123456789012345678901234567890", | ||
name: "TestToken", | ||
symbol: "TT", | ||
}); | ||
expect(token).toEqual(null); | ||
}); | ||
}); | ||
}); |