Hi everyone,
I am trying to create a PublicLedger component for one project of mine.
I am using the following code:
export const PublicLedger = ({ children }: { children: React.ReactNode }) => {
//FETCH public party and token
const publicParty = usePublicParty()
let pubParty: string
let pubToken: string
console.log('publicParty', publicParty)
const publicToken = usePublicToken()?.token
console.log('publicToken', publicToken)
if (publicParty !== undefined) {
pubParty = publicParty
}
if (publicToken !== undefined) {
pubToken = publicToken
}
const [party] = useState(() =>
isLocalDev ? computeLocalCreds('Public').party : pubParty
)
const [token] = useState(() =>
isLocalDev ? computeLocalCreds('Public').token : pubToken
)
return (
<DamlLedger party={party} token={token}>
{children}
</DamlLedger>
)
}
It works fine locally, but when I try to use it on a ledger deployed on DAMLHub the useLedger hook returns me a ledger with the token undefined and I can´t query using the public party.
<PublicLedger>
<SomeComponent>
</PublicLedger>
function SomeComponent() {
const ledger = useLedger()
console.log('ledger', ledger) //here we get the token property as undefined
const { contracts, loading } = useQuery(SomeTemplate)
console.log('Contracts', contracts) //Retrieves empty array []
return <div>...</div>
}
Is there any workaround or alternative that i may use?
Thanks in advance