Hi all!
I have a contract on a sandbox like in the screenshot below:
As you see the type of the contract is
Daml.Finance.Holding.Fungible:Fungible
Now I’m trying to construct the exact same DamlRecord in a Java application. Here is my code for Daml Record creation:
private static Map<String, Set<String>> observers = Collections.emptyMap();
...
InstrumentKey i = new InstrumentKey(depositoryPartyId.getValue(),issuerPartyId.getValue(), new Id("SecurityToken"), "1");
AccountKey a = new AccountKey(custodianPartyId.getValue(), primaryDealer1PartyId.getValue(), new Id(primaryDealer1PartyId.getValue()));
DamlOptional lock = DamlOptional.empty();
Decimal damlDecimal = new Decimal(BigDecimal.valueOf(50));
DamlGenMap observers = this.observers.entrySet().stream().collect(
DamlCollectors.toDamlGenMap(v$0 -> new Text(v$0.getKey()), v$0 -> v$0.getValue().toValue(v$1 -> new Party(v$1))));
return record(
field("instrument", i.toValue()),
field("account", a.toValue()),
field("amount", damlDecimal),
field("lock", lock),
field("observers", observers));
I use the library to “match” my daml record with the contract on the ledger. It works like this:
SANDBOX.getLedgerAdapter().getCreatedContractId(
observer, //partyId
Fungible.TEMPLATE_ID, //java codegen type
matcher, // daml record
Fungible.ContractId::new);
When I run this code I got an error:
java.util.concurrent.TimeoutException: Timed out while waiting for the correct message to be observed.
In other words he is saying that he cannot find a contract that matches my daml records.
Can you have a look at the code above that I use to construct daml record? Is it correct? I’m not sure that I construct Optional and DamlGenMap for empty observers correctly.
Thank you very much!