Daml finance Effect.I and ElectionEffect : Accessing the amount in UI

This is a daml finance related query. In the current implementation. ElectionEffect uses the interface Effect and Effect interface doesn’t have the field amount in its view, which is though present in the ElectionEffect.

  1. Is this intentional design, if so what is the reason
  2. For my purpose I need to access the amount in UI, is there a way to do it,
    2.1 Do you have some function similar to fromInterface in daml, but for UI/React
    2.2 I tried directly to streamquery ElectionEffect to the UI, but I am not able to import it, do i need to change anything manually on package-lock.json to fix this?
    2.3 I thought of some temporary workaround like embed the amount information in description or create a separate template to capture this.

Hi @Ashok_Raj,

This is intentional:

  • the ElectionEffect can be claimed only by presenting a Holding of a specified amount, so that you cannot exercise 1000 units of an option instrument and then claim 2000 of them
  • the amount field is specific to the election workflow implementation, hence it is not used in the Effect interface, which is more generic

I believe we do not have such functions. @georg would you confirm my understanding?

You might need to add it as a dependency, if e.g. your UI only depends on the package containing the Effect interface but not the package containing the implementation.

Matteo

1 Like

Hi Matteo,

Thanks for the answers,

  1. Regarding the point 3., I tried adding it as a dependency in package.json, but its still not being detected, when i try to import it in the UI Code. It will be helpful to understand how and where to update this dependency.

  2. I have taken a different approach and added a service choice to split the holding and is able to pass the new split holding cid to the claim effect, but i observed that the claim effect is again fetching the instrument holdings and again splitting it to the required amount rather than using the holding cid, i provided. I am doing private equity usecase, and there is one instrument and a single holder has three position of the same instrument with three different custodian. So, even though am passing a holding cid corresponding to the right amount held at custodian3, when the holder does claim effect, its fetching a holding held at custodian1 and trying to apply the effect there. I am assuming this is happening because, the code is expecting a single custodian usecase and is fetching the holding based on the instrument id. Is there a way to override this behaviour?

Hi Ashok,

I would expect this to work after adding the package as a dependency in your package.json and running npm install again. Happy to have a look at the code.

As discussed offline, this might be due to a buggy implementation of the getFungible function used in the UI when allocating a holding.

Matteo

Here is a PR to fix the behaviour of the getFungible function → Fix holding choice for settlement by matteolimberto-da · Pull Request #101 · digital-asset/daml-finance-app · GitHub