Skip to content

Commit 85c58f9

Browse files
change to static method
Signed-off-by: rukmini-basu-da <[email protected]>
1 parent bd28bc8 commit 85c58f9

File tree

4 files changed

+18
-6
lines changed

4 files changed

+18
-6
lines changed

docs/wallet-integration-guide/examples/scripts/09-token-standard-allocation-localnet.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
localNetTokenStandardDefault,
77
createKeyPair,
88
localNetStaticConfig,
9+
LedgerController,
910
} from '@canton-network/wallet-sdk'
1011
import { pino } from 'pino'
1112
import { 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()
226227
const prepareUntil = new Date(now.getTime() + 60 * 60 * 1000).toISOString()
227228
const 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
)
265266
if (!otcTradeCid) throw new Error('OTCTrade not found for venue')

docs/wallet-integration-guide/examples/scripts/12-integration-extensions.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
createKeyPair,
88
localValidatorDefault,
99
localNetStaticConfig,
10+
LedgerController,
1011
} from '@canton-network/wallet-sdk'
1112
import path from 'path'
1213
import { 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

docs/wallet-integration-guide/examples/scripts/15-rewards-for-deposits.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {
88
localValidatorDefault,
99
localNetStaticConfig,
1010
signTransactionHash,
11+
LedgerController,
1112
} from '@canton-network/wallet-sdk'
1213
import path from 'path'
1314
import { 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

sdk/wallet-sdk/src/ledgerController.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
 (0)