Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added more data type support #10

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,28 @@ export interface MessageTypes {
[additionalProperties: string]: MessageTypeProperty[];
}

// these types, basically solidity native types will not be passed through further function for encoding
// they will be encoded straight away
const basicEncodableTypes = [
'address',
'bool',
'string',
'int',
'uint',
'int8',
'uint8',
'int16',
'uint16',
'int256',
'uint256',
'bytes32',
'bytes16',
'bytes8',
'bytes4',
'bytes2',
'bytes1',
];

/**
* This is the message format used for `signTypeData`, for all versions
* except `V1`.
Expand Down Expand Up @@ -137,7 +159,6 @@ function generatePacketHashGetters (types, typeName, fields, packetHashGetters =
}

function getEncodedValueFor (field) {
const basicEncodableTypes = ['address', 'bool', 'bytes32', 'int', 'uint', 'uint256', 'string'];
const hashedTypes = ['bytes'];
if (basicEncodableTypes.includes(field.type)) {
return `_input.${field.name}`;
Expand Down