question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JavaScript Libs ContractId type conversion regression

See original GitHub issue

A forum user pointed out a regression when upgrading the da-marketplace app from Connect 1.7 to 1.10.

It looks like there used to be a successful type inference from string to ContractId<AssetDeposit> in https://github.com/digital-asset/da-marketplace/blob/master/ui/src/components/Broker/BrokerOrders.tsx#L163. However, this now fails.

A workaround is to manually cast the string:

    const handleAcceptBrokerOrderFill = async () => {
        const key = wrapDamlTuple([props.cdata.broker, props.cdata.brokerOrderId])
        const cid = depositCid as ContractId<AssetDeposit>
        const args = { depositCid: cid }
        await ledger.exerciseByKey(BrokerOrder.BrokerOrder_Fill, key, args);
        setDepositCid('');
    }

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
cocreaturecommented, Mar 8, 2021

I’d got for ContractId<AssetDeposit> | undefined but yeah something along those lines.

0reactions
bame-dacommented, Mar 8, 2021

Thanks for the detective work. Makes perfect sense. I guess the correct solution would be to type the state properly:

    const [ brokerOrderId, setBrokerOrderId ] = useState<ContractId<AssetDeposit> | null>(null);
Read more comments on GitHub >

github_iconTop Results From Across the Web

Coercion and Type Conversion in JavaScript
As the name implies, type conversion is the process of converting a value from one type to another. Values in JavaScript can be...
Read more >
Regression libraries for NodeJS
ML.js contains a number of different regressions, including linear, polynomial, multivariate and logistic. Documentation is good, and there is a ...
Read more >
Type Regression Testing to Detect Breaking Changes in Node ...
The type checker in Java detects type-related breaking changes, but not semantic ones. Our goal is to provide a mechanism that can similarly...
Read more >
Data Type Conversion In JavaScript
It will convert them automatically and provide you with some result. That means JavaScript coerces data types to be converted when they need...
Read more >
JS-quantities - GitHub Pages
JavaScript library for quantity calculation and unit conversion. ... Qty.getKinds(); // => Array of names of every well-known kind of units ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found