From 35d0c5aa9f5bc5ba4a75f793d193dddff0d02987 Mon Sep 17 00:00:00 2001 From: Nicolas Vargas Date: Tue, 16 Jul 2024 15:30:28 -0300 Subject: [PATCH 1/5] chore: update version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 1251d3d..6fad240 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rsk-explorer", - "version": "2.0.0", + "version": "2.0.1", "private": true, "description": "Rsk explorer client", "author": "emi ", From 7126125f44e7a56eba6783b56577f866f5483249 Mon Sep 17 00:00:00 2001 From: Nicolas Vargas Date: Tue, 16 Jul 2024 15:30:57 -0300 Subject: [PATCH 2/5] chore: add local env script commands --- package.json | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/package.json b/package.json index 6fad240..dd4793a 100644 --- a/package.json +++ b/package.json @@ -8,14 +8,19 @@ "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", From effd3dd18c4018d1ab3875d578fc51af8c5e1c01 Mon Sep 17 00:00:00 2001 From: Nicolas Vargas Date: Tue, 16 Jul 2024 15:31:17 -0300 Subject: [PATCH 3/5] fix: parse array values when interacting with contracts --- src/components/ContractInteraction.vue | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/components/ContractInteraction.vue b/src/components/ContractInteraction.vue index b053394..1d6b6bd 100644 --- a/src/components/ContractInteraction.vue +++ b/src/components/ContractInteraction.vue @@ -343,6 +343,7 @@ export default { this.validateInputs(inputs, method) + // TODO: abstract inputs formatter method.inputs.forEach((input, index) => { const { type } = input @@ -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]) } }) @@ -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 @@ -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]) } }) From 1d2054ef2a4f16b05eebd1138839cf4bb42561af Mon Sep 17 00:00:00 2001 From: Nicolas Vargas Date: Wed, 17 Jul 2024 11:53:41 -0300 Subject: [PATCH 4/5] fix: remove rpc api statement in network name until support for rpc api is added --- src/jsonRpcProvider.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/jsonRpcProvider.js b/src/jsonRpcProvider.js index 44e1330..2e0ad9f 100644 --- a/src/jsonRpcProvider.js +++ b/src/jsonRpcProvider.js @@ -6,7 +6,7 @@ if (!['mainnet', 'testnet'].includes(envNetwork)) throw new Error(`Invalid env n export const rskNetworks = { mainnet: { - chainName: 'Rootstock Mainnet - RPC API', + chainName: 'Rootstock Mainnet', chainId: '0x1e', // 30 nativeCurrency: { name: 'Smart Bitcoin', @@ -22,7 +22,7 @@ export const rskNetworks = { ] }, testnet: { - chainName: 'Rootstock Testnet - RPC API', + chainName: 'Rootstock Testnet', chainId: '0x1f', // 31 nativeCurrency: { name: 'Test Smart Bitcoin', From e5009bc749cd9821cbc271a4b77106adc05f780a Mon Sep 17 00:00:00 2001 From: Nicolas Vargas Date: Wed, 17 Jul 2024 13:07:15 -0300 Subject: [PATCH 5/5] fix: validate arrays before json parsing --- src/components/ContractInteraction.vue | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/components/ContractInteraction.vue b/src/components/ContractInteraction.vue index 1d6b6bd..b67517e 100644 --- a/src/components/ContractInteraction.vue +++ b/src/components/ContractInteraction.vue @@ -354,7 +354,7 @@ export default { } else if (type.startsWith('uint') || type.startsWith('int')) { args[index] = this.formatBigNumber(args[index]) } else if (type.includes('[]')) { - args[index] = JSON.parse(args[index]) + args[index] = this.parseArrayFromString(args[index]) } }) @@ -393,7 +393,7 @@ export default { } 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]) + args[index] = this.parseArrayFromString(args[index]) } }) @@ -419,6 +419,11 @@ export default { this.$set(method.interactionData, 'requested', false) }, + parseArrayFromString (str) { + if (!str.startsWith('[') || !str.endsWith(']')) throw new Error('Value must be a valid array') + + return JSON.parse(str) + }, validateInputs (inputs, method) { const nonEmptyInputs = inputs.filter(input => input !== '' && input !== undefined && input !== null)