I have following code so far.
import { useSubstrateState } from './../substrate-lib'
import { web3FromSource } from '@polkadot/extension-dapp'
const { api, currentAccount } = useSubstrateState()
const getFromAcct = async () => {
const {
address,
meta: { source, isInjected },
} = currentAccount
if (!isInjected) {
return [currentAccount]
}
const injector = await web3FromSource(source)
return [address, { signer: injector.signer }]
}
And transaction as:
const fromAcct = await getFromAcct()
const unsub = await txExecute
.signAndSend(...fromAcct, ({ status, events }) => {
txResHandler(status, events)
})
.catch(txErrHandler)
But it doesn't call the polkadot extension.
It gives error Cannot destructure property 'address' of 'currentAccount' as it is null.