Creating a type map on the front end

Joao_Freitas
Thu, 04 Apr 2024 15:02:33 +0000
App Development

Hi

on my frontend code i have a choice that i need to exercise that has one argument that is of a type Map.
I am making use of @daml/types at version 2.8.0
My code is similar to the following short example:

import * as damlTypes from "@daml/types"

const ledger = useLedger();

function handleExercise(value: string) {

 let myMap = damlTypes.emptyMap<string, string>()
 myMap.set("myKey", value);

ledger.exercise(MyChoice, contractId, { config:myMap })
}

This code works - by this i mean that the Typescript doesn’t complain of the type check on the argument- , but the set property of empytMap is not setting the key or the value on the Map created. The type of the config property on the argument is the following Map<string, string>

Any help on how to create a Map<string, string> would be appreciated.
Thank you in advance.

5 posts - 3 participants