Is there a reason why the Interface Daml.Finance.Interface.Instrument.Bond.FloatingRate.Instrument and the rest of Bond instrument interfaces do not provide a choice GetView like for instance Daml.Finance.Interface.Instrument.Token.Instrument or Daml.Finance.Interface.Instrument.Equity.Instrument?
No, there is no reason for that. I think we should add a GetView choice to each instrument interface to be consistent. I have opened a ticket where we can track this.
It’s worth noting that each instrument has a GetView from the Base.Instrument, but this won’t provide access to all of the contract’s data.
The purpose of the GetView choice is to allow a party, say Alice, to get the view of a contract, without necessarily being a stakeholder of the contract. This can be useful in situations where someone needs access to reference data, but shouldn’t be a stakeholder of the contract. For example, if publicParty is an observer of an instrumentCid, and Alice has readAs rights of publicParty, she can get the view by running:
submitMulti [alice] [publicParty] do
exerciseCmd instrumentCid GetView with actor = alice
Without a GetView choice, Alice could try to get the data by a fetch or fetchByKey. However, fetch instrumentCid is not an option for Alice since the submitting party must be a stakeholder. Similarly, Alice cannot use fetchByKey without authorization from at least one stakeholder of the contract. Therefore, the GetView choice provides a more accessible way for parties to obtain view-only access to a contract’s data.