Skip to content

Commit

Permalink
fix: parse array values when interacting with contracts
Browse files Browse the repository at this point in the history
  • Loading branch information
nicov-iov committed Jul 16, 2024
1 parent 7126125 commit effd3dd
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/components/ContractInteraction.vue
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ export default {
this.validateInputs(inputs, method)
// TODO: abstract inputs formatter
method.inputs.forEach((input, index) => {
const { type } = input
Expand All @@ -352,6 +353,8 @@ export default {
throw new Error('Invalid boolean input (possible values: true, false, 1, 0)')
} else if (type.startsWith('uint') || type.startsWith('int')) {
args[index] = this.formatBigNumber(args[index])
} else if (type.includes('[]')) {
args[index] = JSON.parse(args[index])
}
})
Expand Down Expand Up @@ -380,6 +383,7 @@ export default {
const contract = this.getReadOnlyContractInstance()
const args = inputs
// TODO: abstract inputs formatter
method.inputs.forEach((input, index) => {
const { type } = input
Expand All @@ -388,6 +392,8 @@ export default {
args[index] = this.normalizeAddress(args[index])
} else if (type === 'bool') {
if (!this.isValidBoolean(args[index])) throw new Error('Invalid boolean input (possible values: true, false, 1, 0)')
} else if (type.includes('[]')) {
args[index] = JSON.parse(args[index])
}
})
Expand Down

0 comments on commit effd3dd

Please sign in to comment.