diff --git a/biome.json b/biome.json new file mode 100644 index 00000000..ab0a1f73 --- /dev/null +++ b/biome.json @@ -0,0 +1,17 @@ +{ + "$schema": "https://biomejs.dev/schemas/1.6.1/schema.json", + "linter": { + "enabled": true, + "rules": { + "suspicious": { + "noExplicitAny": "off" + }, + "performance": { + "noDelete": "off" + }, + "style": { + "useImportType": "off" + } + } + } +} diff --git a/jest.config.cjs b/jest.config.cjs index 924c0550..08b57014 100644 --- a/jest.config.cjs +++ b/jest.config.cjs @@ -12,7 +12,7 @@ module.exports = { moduleNameMapper: { '@/(.*)$': '/src/$1', }, - modulePaths: [''], + // modulePaths: [''], verbose: true, testEnvironmentOptions: { customExportConditions: ['node', 'node-addons'], diff --git a/package.json b/package.json index 82a64b22..fa8d7372 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "vite --mode development", "build": "vue-tsc --noEmit && vite build", - "build:cloudflare": "yarn lint:js && yarn lint:css && yarn lint:format && yarn lint:types && yarn test:unit && yarn build", + "build:cloudflare": "yarn lint:js && yarn lint:css && yarn lint:format && yarn lint:types && yarn test && yarn build", "preview": "vite preview", "test": "jest", "lint": "npm-run-all --aggregate-output --continue-on-error --parallel 'lint:*!(fix)'", @@ -23,14 +23,14 @@ "@lukso/lsp-smart-contracts": "0.14.0", "@lukso/web3-onboard-config": "1.1.2", "@pinata/sdk": "^2.1.0", - "@tsndr/cloudflare-worker-jwt": "^2.3.2", + "@tsndr/cloudflare-worker-jwt": "^2.5.3", "@types/isomorphic-fetch": "^0.0.39", "@walletconnect/ethereum-provider": "2.10.1", "@walletconnect/sign-client": "2.10.1", "@walletconnect/types": "2.10.1", "@walletconnect/utils": "2.10.1", - "@web3-onboard/core": "^2.21.0", - "@web3-onboard/injected-wallets": "^2.10.5", + "@web3-onboard/core": "^2.21.3", + "@web3-onboard/injected-wallets": "^2.10.13", "@web3modal/ethereum": "2.7.1", "@web3modal/standalone": "2.4.3", "bulma": "0.9.4", @@ -40,11 +40,12 @@ "https-browserify": "1.0.0", "isomorphic-fetch": "^3.0.0", "siwe": "1.1.6", - "vue": "^3.3.4", + "tslib": "^2.6.2", + "vue": "^3.4.21", "vue-router": "4.2.4", "wagmi": "^1.3.9", - "web3": "1.10.2", - "web3-eth-contract": "1.10.2" + "web3": "1.10.4", + "web3-eth-contract": "1.10.4" }, "devDependencies": { "@depay/web3-mock": "^14.17.0", @@ -54,8 +55,8 @@ "@types/jest": "28.1.8", "@typescript-eslint/eslint-plugin": "6.6.0", "@typescript-eslint/parser": "^6.6.0", - "@vitejs/plugin-vue": "^4.3.4", - "@vue/compiler-sfc": "3.3.4", + "@vitejs/plugin-vue": "^5.0.4", + "@vue/compiler-sfc": "3.4.21", "@vue/vue3-jest": "28.1.0", "eslint": "8.49.0", "eslint-config-prettier": "9.0.0", @@ -76,11 +77,11 @@ "stylelint-config-recommended-vue": "1.5.0", "stylelint-config-standard-scss": "10.0.0", "ts-jest": "28.0.8", - "typescript": "^5.2.2", + "typescript": "^5.4.3", "util": "0.12.5", "vite": "^4.4.9", "vue-loader": "17.2.2", - "vue-tsc": "^1.8.10" + "vue-tsc": "^2.0.7" }, "lint-staged": { "*.{ts,js,vue}": [ diff --git a/src/components/endpoints/SendTransaction.vue b/src/components/endpoints/SendTransaction.vue index 3112c011..a25cfc58 100644 --- a/src/components/endpoints/SendTransaction.vue +++ b/src/components/endpoints/SendTransaction.vue @@ -26,11 +26,16 @@ const { getBalance, estimateGas, defaultMaxPriorityFeePerGas, + executeCall, } = useWeb3Connection() const data = ref('') const hasData = ref(false) const isPending = ref(false) +const callResults = ref(null) +const resultFormat = reactive<{ item: MethodSelect }>({ + item: { label: 'results' }, +}) const methods: MethodSelect[] = [ { @@ -319,20 +324,22 @@ const estimate = async () => { transaction = { ...transaction, data: data.value } } - try { - isPending.value = true - const gas = await estimateGas(transaction) - setNotification(`Estimated gas ${gas}`) - params.items[5].value = gas - setState('balance', await getBalance(from)) - } catch (error) { - setNotification((error as unknown as Error).message, 'danger') - } finally { - isPending.value = false - } + isPending.value = true + Promise.all([estimateGas(transaction), getBalance(from)]) + .then(([gas, balance]) => { + setNotification(`Estimated gas ${gas}`) + params.items[5].value = gas + setState('balance', balance) + }) + .catch(error => { + setNotification((error as unknown as Error).message, 'danger') + }) + .finally(() => { + isPending.value = false + }) } -const send = async () => { +const send = () => { clearNotification() const from = makeValue(params.items[0]) @@ -348,19 +355,52 @@ const send = async () => { if (hasData.value) { transaction = { ...transaction, data: data.value } } + isPending.value = true + callResults.value = null + Promise.all([sendTransaction(transaction), getBalance(from)]) + .then(([, balance]) => { + setNotification('The transaction was successful') + setState('balance', balance) + }) + .catch(error => { + setNotification((error as unknown as Error).message, 'danger') + }) + .finally(() => { + isPending.value = false + }) +} - try { - isPending.value = true - await sendTransaction(transaction) - setNotification('The transaction was successful') - setState('balance', await getBalance(from)) - } catch (error) { - setNotification((error as unknown as Error).message, 'danger') - } finally { - isPending.value = false +const rawCall = () => { + clearNotification() + + const from = makeValue(params.items[0]) + console.log('from', from, params.items) + let transaction = { + from, + to: makeValue(params.items[1]), + value: makeValue(params.items[2]), + } as TransactionConfig + if (hasData.value) { + transaction = { ...transaction, data: data.value } } -} + console.log(transaction) + + isPending.value = true + callResults.value = null + Promise.all([executeCall(transaction), getBalance(from)]) + .then(([result, balance]) => { + callResults.value = result + setNotification('Call executed successfully.') + setState('balance', balance) + }) + .catch(error => { + setNotification((error as unknown as Error).message, 'danger') + }) + .finally(() => { + isPending.value = false + }) +} const method = reactive<{ item: MethodSelect }>({ item: methods[0] }) const params = reactive<{ items: MethodType[] }>({ items: [ @@ -390,14 +430,14 @@ const params = reactive<{ items: MethodType[] }>({ }) const selectMethod = (e: Event) => { - const value = parseInt((e.target as HTMLInputElement).value, 10) + const value = Number.parseInt((e.target as HTMLInputElement).value, 10) const { to, amount, ...item } = value >= methods.length ? items.items[value - methods.length] : methods[value] - Object.entries(item).forEach(([key, val]) => { + for (const [key, val] of Object.entries(item)) { ;(method.item as any)[key] = val - }) + } params.items = params.items.map((param, index) => { if (index === 1) { if ( @@ -412,10 +452,10 @@ const selectMethod = (e: Event) => { }) method.item.call = item.call hasData.value = item.call != null - if (to != undefined) { + if (to != null) { params.items[1].value = to } - if (amount != undefined) { + if (amount != null) { params.items[2].value = amount } defaultMaxPriorityFeePerGas().then(value => { @@ -424,6 +464,7 @@ const selectMethod = (e: Event) => { } const handleData = (e?: string) => { + console.log(e) if (data.value !== e || '') { data.value = e || '' } @@ -477,7 +518,7 @@ const hasRemove = computed(() => {