Skip to content
This repository was archived by the owner on Aug 12, 2023. It is now read-only.

Commit 11a3426

Browse files
authored
Add ERC-1155 support (#342)
1 parent f62efd7 commit 11a3426

4 files changed

Lines changed: 11 additions & 0 deletions

File tree

src/app/routes/v1/tokens.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ const validatePeriod = require('../../middleware/validate-period');
1313
const TOKEN_TYPE_MAP = {
1414
[TOKEN_TYPE.ERC20]: 'erc-20',
1515
[TOKEN_TYPE.ERC721]: 'erc-721',
16+
[TOKEN_TYPE.ERC1155]: 'erc-1155',
1617
};
1718

1819
const TOKEN_TYPE_REVERSE_MAP = {
1920
'erc-20': TOKEN_TYPE.ERC20,
2021
'erc-721': TOKEN_TYPE.ERC721,
22+
'erc-1155': TOKEN_TYPE.ERC1155,
2123
};
2224

2325
const validTokenTypes = _.values(TOKEN_TYPE_MAP);

src/constants.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ module.exports = {
1818
TOKEN_TYPE: {
1919
ERC20: 0,
2020
ERC721: 1,
21+
ERC1155: 2,
2122
},
2223
TRADER_TYPE: {
2324
MAKER: 0,

src/tokens/format-token-type.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ const formatTokenType = tokenType => {
1010
return 'erc-20';
1111
case TOKEN_TYPE.ERC721:
1212
return 'erc-721';
13+
case TOKEN_TYPE.ERC1155:
14+
return 'erc-1155';
1315
default:
1416
throw new Error(`Unrecognised token type: ${tokenType}`);
1517
}

src/tokens/format-token-type.test.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,12 @@ describe('formatTokenType', () => {
2020
expect(formatted).toBe('erc-721');
2121
});
2222

23+
it('should format ERC-1155 token type', () => {
24+
const formatted = formatTokenType(TOKEN_TYPE.ERC1155);
25+
26+
expect(formatted).toBe('erc-1155');
27+
});
28+
2329
it('should throw an error when formatting unknown token type', () => {
2430
expect(() => {
2531
formatTokenType(999);

0 commit comments

Comments
 (0)