File tree Expand file tree Collapse file tree 4 files changed +18
-6
lines changed
docs/wallet-integration-guide/examples/scripts Expand file tree Collapse file tree 4 files changed +18
-6
lines changed Original file line number Diff line number Diff line change 66 localNetTokenStandardDefault ,
77 createKeyPair ,
88 localNetStaticConfig ,
9+ LedgerController ,
910} from '@canton-network/wallet-sdk'
1011import { pino } from 'pino'
1112import { v4 } from 'uuid'
@@ -185,7 +186,7 @@ const activeTradeProposals = await sdk.userLedger?.activeContracts({
185186 filterByParty : true ,
186187} )
187188
188- const otcpCid = sdk . userLedger ? .getActiveContractCid (
189+ const otcpCid = LedgerController . getActiveContractCid (
189190 activeTradeProposals ?. [ 0 ] ?. contractEntry !
190191)
191192
@@ -226,7 +227,7 @@ const now = new Date()
226227const prepareUntil = new Date ( now . getTime ( ) + 60 * 60 * 1000 ) . toISOString ( )
227228const settleBefore = new Date ( now . getTime ( ) + 2 * 60 * 60 * 1000 ) . toISOString ( )
228229
229- const otcpCid2 = sdk . userLedger ? .getActiveContractCid (
230+ const otcpCid2 = LedgerController . getActiveContractCid (
230231 activeTradeProposals2 ?. [ 0 ] ?. contractEntry !
231232)
232233
@@ -259,7 +260,7 @@ const otcTrades = await sdk.userLedger!.activeContracts({
259260 filterByParty : true ,
260261} )
261262
262- const otcTradeCid = sdk . userLedger ? .getActiveContractCid (
263+ const otcTradeCid = LedgerController . getActiveContractCid (
263264 otcTrades ?. [ 0 ] ?. contractEntry
264265)
265266if ( ! otcTradeCid ) throw new Error ( 'OTCTrade not found for venue' )
Original file line number Diff line number Diff line change 77 createKeyPair ,
88 localValidatorDefault ,
99 localNetStaticConfig ,
10+ LedgerController ,
1011} from '@canton-network/wallet-sdk'
1112import path from 'path'
1213import { pino } from 'pino'
@@ -180,7 +181,7 @@ const activeContractsForDelegateProxy = await sdk.userLedger?.activeContracts({
180181 ] ,
181182} )
182183
183- const proxyCid = sdk . userLedger ? .getActiveContractCid (
184+ const proxyCid = LedgerController . getActiveContractCid (
184185 activeContractsForDelegateProxy ! [ 0 ] . contractEntry
185186)
186187
Original file line number Diff line number Diff line change 88 localValidatorDefault ,
99 localNetStaticConfig ,
1010 signTransactionHash ,
11+ LedgerController ,
1112} from '@canton-network/wallet-sdk'
1213import path from 'path'
1314import { pino } from 'pino'
@@ -233,7 +234,7 @@ const activeContractsForDelegateProxy = await sdk.userLedger?.activeContracts({
233234 ] ,
234235} )
235236
236- const proxyCid = sdk . userLedger ? .getActiveContractCid (
237+ const proxyCid = LedgerController . getActiveContractCid (
237238 activeContractsForDelegateProxy ! [ 0 ] . contractEntry
238239)
239240
Original file line number Diff line number Diff line change @@ -194,7 +194,16 @@ export class LedgerController {
194194 )
195195 }
196196
197- getActiveContractCid ( entry : JSContractEntry ) {
197+ /**
198+ * For a contract there could be multiple contract_entry-s in the entire snapshot. These together define
199+ * the state of one contract in the snapshot.
200+ * A contract_entry is included in the result, if and only if there is at least one stakeholder party of the contract
201+ * that is hosted on the synchronizer at the time of the event and the party satisfies the
202+ * ``TransactionFilter`` in the query.
203+ * This function extracts the contractId from a contractEntry is if it's an ActiveContract
204+ * @param For
205+ */
206+ static getActiveContractCid ( entry : JSContractEntry ) {
198207 if ( 'JsActiveContract' in entry ) {
199208 return entry . JsActiveContract . createdEvent . contractId
200209 }
You can’t perform that action at this time.
0 commit comments