Closed Nzenou closed 1 year ago
hello @Nzenou 🙋♂️
thank you for pointing this out!
you're right the submitted transaction hash is not returned by submitTxBlocking
; we will definitively improve this in our upcoming release.
in the meanwhile here is a work around available right now:
Transfer
eventimport { getKeyringFromSeed } from "./account"
import { balancesTransferTx } from "./balance"
import { initializeApi, signTxHex, submitTxHex } from "./blockchain"
const main = async () => {
await initializeApi()
const keyring = await getKeyringFromSeed(SEED)
const rawTxHash = await balancesTransferTx(TO_ADDRESS, 1)
const signedTxHash = await signTxHex(keyring, rawTxHash)
const txHash = await submitTxHex(signedTxHash)
console.log(txHash)
}
Transfer
event dataimport type { ISubmittableResult } from "@polkadot/types/types"
import { getKeyringFromSeed } from "./account"
import { balancesTransferTx } from "./balance"
import { BlockInfo, ConditionalVariable, getRawApi, initializeApi, signTxHex, submitTxHex } from "./blockchain"
import { BalancesTransferEvent, BlockchainEvent, BlockchainEvents } from "./events"
const main = async () => {
await initializeApi()
const api = getRawApi()
const keyring = await getKeyringFromSeed(SEED)
const conVar = new ConditionalVariable(500)
const chainEvents: BlockchainEvents = new BlockchainEvents([])
const blockInfo = new BlockInfo()
const callback = async ({ events, status }: ISubmittableResult) => {
if (status.isInBlock) {
chainEvents.inner = events.map((eventRecord) => BlockchainEvent.fromEvent(eventRecord.event))
const blockHash = status.asInBlock.toString()
const blockData = await api.rpc.chain.getBlock(blockHash)
blockInfo.blockHash = blockHash
blockInfo.block = blockData.block
conVar.notify()
}
}
const rawTxHash = await balancesTransferTx(TO_ADDRESS, 1)
const signedTxHash = await signTxHex(keyring, rawTxHash)
const txHash = await submitTxHex(signedTxHash, callback)
await conVar.wait()
const transferEvent = chainEvents.findEventOrThrow(BalancesTransferEvent)
console.log({ chainEvents, blockInfo, transferEvent, txHash })
}
Note - I destructured submitTxBlocking with the full flow: tx creation, tx signing and tx submit
Describe the bug
Hello,
I am using the code below, to transfer Caps for customers the only problem is that the hash that I receive is not working on the Ternoa explorer, I have no results when I search with the hash of the transaction, but I can find the transaction by searching with my wallet address and looking for it in Extrinsics section.
Is it possible to get a workaround to directly have the good hash?
Thanks in advance
To reproduce
use the submitTxHash
Expected behavior
receive a hash that is not recognized
Screenshots
Desktop (please complete the following information)
No response
Smartphone (please complete the following information)
No response
Additional context
No response