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

fix: Repair testing of widgets. #170

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"@erc725/erc725.js": "0.24.2",
"@lukso/lsp-factory.js": "^3.3.1",
"@lukso/lsp-smart-contracts": "^0.15.0",
"@lukso/up-provider": "^0.3.1",
"@lukso/up-provider": "^0.3.2",
"@lukso/web3-onboard-config": "1.1.2",
"@pinata/sdk": "^2.1.0",
"@types/isomorphic-fetch": "^0.0.39",
Expand Down
10 changes: 7 additions & 3 deletions src/Widget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ web3.value.eth
// Ignore error
errors.value.push(error)
})
contextAccounts.value = window.lukso?.contextAccounts || []
console.log('Context accounts:', contextAccounts.value)
window.lukso?.on('accountsChanged', (_accounts: (`0x${string}` | '')[]) => {
accounts.value = _accounts
})
Expand Down Expand Up @@ -68,11 +70,13 @@ watch(
}
)
function donate() {
web3.value?.eth.sendTransaction({
const obj = {
from: accounts.value[0],
to: accounts.value[1],
to: contextAccounts.value[0],
value: amount.value?.toString() || '0',
})
}
console.log('Donating', obj)
web3.value?.eth.sendTransaction(obj)
}
</script>

Expand Down
58 changes: 56 additions & 2 deletions src/views/GridIFrame.vue
Original file line number Diff line number Diff line change
@@ -1,13 +1,67 @@
<script setup lang="ts">
import Accounts from '@/components/endpoints/Accounts.vue'
import GridPanelDialog from '@/components/grid/GridPanelDialog.vue'
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import Notifications from '@/components/Notification.vue'
import { UPClientChannel, createUPProviderConnector } from '@lukso/up-provider'
import {
UPClientChannel,
UPProviderEndpoint,
createUPProviderConnector,
} from '@lukso/up-provider'
import useWeb3Connection from '@/compositions/useWeb3Connection'
import type EthereumProvider from '@walletconnect/ethereum-provider/dist/types/EthereumProvider'
import { NETWORKS } from '@/helpers/config'

const globalProvider = createUPProviderConnector()
globalProvider.on('channelCreated', () => {})

const { getProvider } = useWeb3Connection()

const chainChanged = (chainId_: string) => {
console.log('Chain changed:', chainId_)
if (!providerRef.value) {
return
}
const chainId = Number.parseInt(chainId_)
const network = Object.values(NETWORKS).find(
value => value.chainId === chainId
)
globalProvider.setupProvider(
providerRef.value as UPProviderEndpoint,
network?.http?.url ? [network.http.url] : []
)
}

const providerRef = ref<EthereumProvider | null>(null)

watch(
() => getProvider(),
async (provider, oldProvider) => {
if (provider === oldProvider) {
return
}
if (providerRef.value) {
providerRef.value.off('chainChanged', chainChanged)
}
providerRef.value = provider
if (provider) {
const chainId = Number.parseInt(
await provider.request({ method: 'eth_chainId' })
)
const network = Object.values(NETWORKS).find(
value => value.chainId === chainId
)
providerRef.value = provider
globalProvider.setupProvider(
provider as UPProviderEndpoint,
network?.http?.url ? [network.http.url] : []
)
providerRef.value.on('chainChanged', chainChanged)
}
},
{ immediate: true }
)

const base = ref<string>(import.meta.env.BASE_URL || '/')

const frame1Channel = ref<UPClientChannel | null>(null)
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2503,9 +2503,9 @@ __metadata:
languageName: node
linkType: hard

"@lukso/up-provider@npm:^0.3.1":
version: 0.3.1
resolution: "@lukso/up-provider@npm:0.3.1"
"@lukso/up-provider@npm:^0.3.2":
version: 0.3.2
resolution: "@lukso/up-provider@npm:0.3.2"
dependencies:
"@mixer/postmessage-rpc": ^1.1.4
"@types/debug": ^4.1.12
Expand All @@ -2516,7 +2516,7 @@ __metadata:
lit: ^3.2.1
pauseable: ^0.3.2
uuid: ^11.0.3
checksum: 162e11e3fa2b13ce459dc36cca94c208668c2eb66800aeba973b1d56f2ba9128a94a5bba71fa182798fac3e60b5799142f8af444625490ea001053c2d8d12dba
checksum: 4a6ee0024fc91c07e7c11fb88bf35ae9f92af28b4cc24757d27e8ab1feec3b199ed04e0dde1ad8a4eee77cf4ab0ef0fc20489093008aaba7bcb754f75d8f5ba0
languageName: node
linkType: hard

Expand Down Expand Up @@ -16536,7 +16536,7 @@ __metadata:
"@erc725/erc725.js": 0.24.2
"@lukso/lsp-factory.js": ^3.3.1
"@lukso/lsp-smart-contracts": ^0.15.0
"@lukso/up-provider": ^0.3.1
"@lukso/up-provider": ^0.3.2
"@lukso/web3-onboard-config": 1.1.2
"@pinata/sdk": ^2.1.0
"@testing-library/jest-dom": 6.4.2
Expand Down
Loading