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

Parse array values when interacting with contracts #228

Merged
merged 5 commits into from
Jul 17, 2024
Merged
Show file tree
Hide file tree
Changes from 3 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
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
{
"name": "rsk-explorer",
"version": "2.0.0",
"version": "2.0.1",
"private": true,
"description": "Rsk explorer client",
"author": "emi <[email protected]>",
"scripts": {
"dev:mainnet": "env-cmd -f .env.mainnet npx vue-cli-service serve",
"dev:testnet": "env-cmd -f .env.testnet npx vue-cli-service serve",
"dev:staging": "env-cmd -f .env.staging npx vue-cli-service serve",
"dev:local": "env-cmd -f .env.local npx vue-cli-service serve",
"dev-with-tracking:mainnet": "env-cmd -f .env.mainnet npx vue-cli-service serve src/main.with.tracking.js",
"dev-with-tracking:testnet": "env-cmd -f .env.testnet npx vue-cli-service serve src/main.with.tracking.js",
"dev-with-tracking:staging": "env-cmd -f .env.staging npx vue-cli-service serve src/main.with.tracking.js",
"dev-with-tracking:local": "env-cmd -f .env.local npx vue-cli-service serve src/main.with.tracking.js",
"build:mainnet": "env-cmd -f .env.mainnet npx vue-cli-service build --modern",
"build:testnet": "env-cmd -f .env.testnet npx vue-cli-service build --modern",
"build:staging": "env-cmd -f .env.staging npx vue-cli-service build --modern",
"build:local": "env-cmd -f .env.local npx vue-cli-service build --modern",
"build-with-tracking:mainnet": "env-cmd -f .env.mainnet npx vue-cli-service build src/main.with.tracking.js --modern",
"build-with-tracking:testnet": "env-cmd -f .env.testnet npx vue-cli-service build src/main.with.tracking.js --modern",
"build-with-tracking:staging": "env-cmd -f .env.staging npx vue-cli-service build src/main.with.tracking.js --modern",
"build-with-tracking:local": "env-cmd -f .env.local npx vue-cli-service build src/main.with.tracking.js --modern",
"test:unit": "npx vue-cli-service test:unit",
"test:e2e": "npx vue-cli-service test:e2e",
"lint": "npx vue-cli-service lint",
Expand Down
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
Loading