Skip to content

Commit

Permalink
Fix for processing json strings in non-string fields
Browse files Browse the repository at this point in the history
  • Loading branch information
aaroncox committed Feb 24, 2019
1 parent 1231366 commit f8f43f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/shared/components/Contract/Interface/Form/Action.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import React, { Component } from 'react';
import { translate } from 'react-i18next';
import { Button, Divider, Form, Header, Message } from 'semantic-ui-react';
import { attempt, isError } from 'lodash';

import GlobalTransactionModal from '../../../Global/Transaction/Modal';
import GlobalFormFieldGeneric from '../../../Global/Form/Field/Generic';
Expand Down Expand Up @@ -35,6 +36,7 @@ class ContractInterfaceFormAction extends Component<Props> {
if (type === 'array') {
fieldType = 'array';
}

switch (fieldType) {
case 'int': {
return parseInt(value, 10);
Expand All @@ -45,7 +47,13 @@ class ContractInterfaceFormAction extends Component<Props> {
case 'array': {
return value;
}
case 'string': {
return String(value);
}
default: {
if (!isError(attempt(JSON.parse, value))) {
return JSON.parse(value);
}
return String(value);
}
}
Expand Down
3 changes: 3 additions & 0 deletions app/shared/utils/EOS/Contract.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ export default class EOSContract {
if (field && field.type in this.typeMap) {
return this.typeMap[field.type];
}
if (field && field.type) {
return field.type;
}
return 'string';
}

Expand Down

0 comments on commit f8f43f8

Please sign in to comment.