diff --git a/src/contracts/typeGenerator.test.ts b/src/contracts/typeGenerator.test.ts index 0bf6954..e90a7f7 100644 --- a/src/contracts/typeGenerator.test.ts +++ b/src/contracts/typeGenerator.test.ts @@ -3,9 +3,21 @@ import { mapParameterType } from './typeGenerator'; -const validTypes = ['string','bool','name'] +/** + * Big Number Types + * @desc Javascript only supports number, so CPP integer types need to be mapped accordingly + */ +const numberTypes = [ + 'int8','int16','int32','int64','int128','int256', + 'uint8','uint16','uint32','uint64','uint128','uint256', + 'uint8_t','uint16_t','uint32_t','uint64_t','uint128_t','uint256_t' +]; -const numberTypes = ['uint8','uint16','uint32','uint64','uint128','uint256']; +/** + * EOS Name Types + * @desc Name types are typically a string or uint64_t and typically represent an identity on the EOS blockchain + */ +const stringNumberTypes = ['name','action_name','scope_name','account_name','permission_name','table_name']; describe("type generator", () => { @@ -20,8 +32,14 @@ describe("type generator", () => { }); context('eos types', () => { - it(`should map 'name' to 'string|number'`, () => { - assert.equal(mapParameterType('name'), 'string|number', `'name' type should map to 'string' or 'number'`) + + it(`should map name types to 'string|number'`, () => { + stringNumberTypes.map(type => + assert.equal(mapParameterType(type), 'string|number', `'${type}' type should map to 'string' or 'number'`)) + }); + + it(`should map 'checksum' to 'string'`, () => { + assert.equal(mapParameterType('checksum'), 'string', `'checksum' type should map to 'string'`) }); }); diff --git a/src/contracts/typeMap.ts b/src/contracts/typeMap.ts index 44f916a..0ee8454 100644 --- a/src/contracts/typeMap.ts +++ b/src/contracts/typeMap.ts @@ -13,6 +13,13 @@ const types:TypeMapping = { 'string':'string', 'bool':'boolean', 'name':'string|number', + 'action_name':'string|number', + 'scope_name':'string|number', + 'account_name':'string|number', + 'permission_name':'string|number', + 'table_name':'string|number', + 'checksum':'string', + 'checksum256':'string', 'int8':'number', 'int16':'number', 'int32':'number',