这是我能够获取所有模板数据的示例代码。
PackageCatalog 包含所有 templateID 的 JSON
templateId: { packageId: 'my-package-id', moduleName: 'SomeModule', entityName: 'SomeTemplate' },
const ledger = require('@digitalasset/daml-ledger');
const templateIds = require('../config/PackageCatalog.json')
const connect = util.promisify(ledger.DamlLedgerClient.connect.bind(ledger.DamlLedgerClient))
const client = await connect({ host: ' host id of your like localhost or some ip', port: 'your sandbox port number' })
const tmplt_Test = templateIds['Main.Test.Testuno:Testtemp']
const filtersByParty = {}
filtersByParty['Party Data you want to fetch'] = { inclusive: { templateIds: [tmplt_Test] } };
const GetTransactionsRequest = {
begin: { offsetType: 'boundary', boundary: ledger.LedgerOffsetBoundaryValue.BEGIN },
filter: { filtersByParty: filtersByParty }
};
let getAllTransactionData = client.transactionClient.getTransactions(GetTransactionsRequest);
getAllTransactionData.on('data', response => {
console.log(" \n\n response :::: " + JSON.stringify(response))
for (let transaction of response.transactions) {
let events = transaction.eventsById;
for (let eventId in events) {
}
}
})