@canton-network/core-ledger-client 0.5.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ledger-api-utils.d.ts +3 -2
- package/dist/ledger-api-utils.d.ts.map +1 -1
- package/dist/ledger-client.d.ts +3 -2
- package/dist/ledger-client.d.ts.map +1 -1
- package/dist/ledger-client.js +1 -1
- package/dist/token-standard-service.d.ts +8 -6
- package/dist/token-standard-service.d.ts.map +1 -1
- package/dist/token-standard-service.js +26 -14
- package/dist/topology-write-service.d.ts +4 -3
- package/dist/topology-write-service.d.ts.map +1 -1
- package/dist/topology-write-service.js +3 -1
- package/dist/txparse/parser.d.ts +2 -1
- package/dist/txparse/parser.d.ts.map +1 -1
- package/dist/txparse/parser.test.js +1 -1
- package/package.json +4 -3
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LedgerClient } from './ledger-client.js';
|
|
2
2
|
import { Holding, TransferInstructionView } from './txparse/types.js';
|
|
3
3
|
import { Types } from './ledger-client.js';
|
|
4
|
+
import { PartyId } from '@canton-network/core-types';
|
|
4
5
|
type TransactionFilter = Types['TransactionFilter'];
|
|
5
6
|
type CreatedEvent = Types['CreatedEvent'];
|
|
6
7
|
type ExercisedEvent = Types['ExercisedEvent'];
|
|
@@ -8,7 +9,7 @@ type ArchivedEvent = Types['ArchivedEvent'];
|
|
|
8
9
|
type ExerciseCommand = Types['ExerciseCommand'];
|
|
9
10
|
type JsInterfaceView = Types['JsInterfaceView'];
|
|
10
11
|
type DisclosedContract = Types['DisclosedContract'];
|
|
11
|
-
export declare function filtersByParty(party:
|
|
12
|
+
export declare function filtersByParty(party: PartyId, interfaceNames: string[], includeWildcard: boolean): TransactionFilter['filtersByParty'];
|
|
12
13
|
export declare function hasInterface(interfaceId: string, event: ExercisedEvent | ArchivedEvent): boolean;
|
|
13
14
|
export declare function getInterfaceView(createdEvent: CreatedEvent): JsInterfaceView | null;
|
|
14
15
|
export type KnownInterfaceView = {
|
|
@@ -37,7 +38,7 @@ export declare function getMetaKeyValue(key: string, meta: Meta): string | null;
|
|
|
37
38
|
* Otherwise, the display code has to do so, overloading the user with superfluous metadata entries.
|
|
38
39
|
*/
|
|
39
40
|
export declare function removeParsedMetaKeys(meta: Meta): Meta;
|
|
40
|
-
export declare function submitExerciseCommand(ledgerClient: LedgerClient, exerciseCommand: ExerciseCommand, disclosedContracts: DisclosedContract[], partyId:
|
|
41
|
+
export declare function submitExerciseCommand(ledgerClient: LedgerClient, exerciseCommand: ExerciseCommand, disclosedContracts: DisclosedContract[], partyId: PartyId, userId: string, publicKeyPath: string, privateKeyPath: string): Promise<Completion>;
|
|
41
42
|
export interface Completion {
|
|
42
43
|
updateId: string;
|
|
43
44
|
synchronizerId: string | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-api-utils.d.ts","sourceRoot":"","sources":["../src/ledger-api-utils.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"ledger-api-utils.d.ts","sourceRoot":"","sources":["../src/ledger-api-utils.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAA;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,KAAK,iBAAiB,GAAG,KAAK,CAAC,mBAAmB,CAAC,CAAA;AACnD,KAAK,YAAY,GAAG,KAAK,CAAC,cAAc,CAAC,CAAA;AACzC,KAAK,cAAc,GAAG,KAAK,CAAC,gBAAgB,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GAIG;AACH,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,CAQrD;AAED,wBAAsB,qBAAqB,CACvC,YAAY,EAAE,YAAY,EAC1B,eAAe,EAAE,eAAe,EAChC,kBAAkB,EAAE,iBAAiB,EAAE,EACvC,OAAO,EAAE,OAAO,EAChB,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,MAAM,EACrB,cAAc,EAAE,MAAM,GACvB,OAAO,CAAC,UAAU,CAAC,CA4ErB;AA2ED,MAAM,WAAW,UAAU;IACvB,QAAQ,EAAE,MAAM,CAAA;IAEhB,cAAc,EAAE,MAAM,GAAG,SAAS,CAAA;IAClC,UAAU,EAAE,MAAM,GAAG,SAAS,CAAA;CACjC"}
|
package/dist/ledger-client.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { components, paths } from './generated-clients/openapi-3.3.0-SNAPSHOT.js';
|
|
2
2
|
import { Logger } from 'pino';
|
|
3
|
+
import { PartyId } from '@canton-network/core-types';
|
|
3
4
|
export type Types = components['schemas'];
|
|
4
5
|
type PostEndpoint = {
|
|
5
6
|
[Pathname in keyof paths]: paths[Pathname] extends {
|
|
@@ -45,7 +46,7 @@ export type GetResponse<Path extends GetEndpoint> = paths[Path] extends {
|
|
|
45
46
|
export declare class LedgerClient {
|
|
46
47
|
private readonly client;
|
|
47
48
|
private readonly logger;
|
|
48
|
-
constructor(baseUrl:
|
|
49
|
+
constructor(baseUrl: URL, token: string, _logger: Logger);
|
|
49
50
|
post<Path extends PostEndpoint>(path: Path, body: PostRequest<Path>, params?: {
|
|
50
51
|
path?: Record<string, string>;
|
|
51
52
|
query?: Record<string, string>;
|
|
@@ -61,7 +62,7 @@ export declare class LedgerClient {
|
|
|
61
62
|
* @param partyId The ID of the party to grant rights for.
|
|
62
63
|
* @returns A promise that resolves when the rights have been granted.
|
|
63
64
|
*/
|
|
64
|
-
grantUserRights(userId: string, partyId:
|
|
65
|
+
grantUserRights(userId: string, partyId: PartyId): Promise<void>;
|
|
65
66
|
private valueOrError;
|
|
66
67
|
}
|
|
67
68
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ledger-client.d.ts","sourceRoot":"","sources":["../src/ledger-client.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,UAAU,EACV,KAAK,EACR,MAAM,+CAA+C,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"ledger-client.d.ts","sourceRoot":"","sources":["../src/ledger-client.ts"],"names":[],"mappings":"AAGA,OAAO,EACH,UAAU,EACV,KAAK,EACR,MAAM,+CAA+C,CAAA;AAEtD,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAC7B,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAEpD,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,SAAS,CAAC,CAAA;AAIzC,KAAK,YAAY,GAAG;KACf,QAAQ,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,QAAQ,CAAC,SAAS;QAC/C,IAAI,EAAE,OAAO,CAAA;KAChB,GACK,QAAQ,GACR,KAAK;CACd,CAAC,MAAM,KAAK,CAAC,CAAA;AAGd,MAAM,MAAM,WAAW,CAAC,IAAI,SAAS,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS;IACrE,IAAI,EAAE;QAAE,WAAW,EAAE;YAAE,OAAO,EAAE;gBAAE,kBAAkB,EAAE,MAAM,GAAG,CAAA;aAAE,CAAA;SAAE,CAAA;KAAE,CAAA;CACxE,GACK,GAAG,GACH,KAAK,CAAA;AAGX,MAAM,MAAM,YAAY,CAAC,IAAI,SAAS,YAAY,IAAI,KAAK,CAAC,IAAI,CAAC,SAAS;IACtE,IAAI,EAAE;QAAE,SAAS,EAAE;YAAE,GAAG,EAAE;gBAAE,OAAO,EAAE;oBAAE,kBAAkB,EAAE,MAAM,GAAG,CAAA;iBAAE,CAAA;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AAM,CAAC,CAAA;KACjC,GACF,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAQ7B;;;;;;OAMG;IACU,eAAe,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO;YAqD/C,YAAY;CAU7B"}
|
package/dist/ledger-client.js
CHANGED
|
@@ -7,7 +7,7 @@ export class LedgerClient {
|
|
|
7
7
|
constructor(baseUrl, token, _logger) {
|
|
8
8
|
this.logger = _logger.child({ component: 'LedgerClient' });
|
|
9
9
|
this.client = createClient({
|
|
10
|
-
baseUrl,
|
|
10
|
+
baseUrl: baseUrl.href,
|
|
11
11
|
fetch: async (url, options = {}) => {
|
|
12
12
|
return fetch(url, {
|
|
13
13
|
...options,
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import { Logger } from '@canton-network/core-types';
|
|
1
|
+
import { Logger, PartyId } from '@canton-network/core-types';
|
|
2
2
|
import { LedgerClient } from './ledger-client.js';
|
|
3
3
|
import { PrettyContract, ViewValue } from './txparse/types.js';
|
|
4
4
|
import type { PrettyTransactions } from './txparse/types.js';
|
|
5
5
|
import { Types } from './ledger-client.js';
|
|
6
|
+
import { ScanProxyClient } from '@canton-network/core-splice-client';
|
|
6
7
|
type ExerciseCommand = Types['ExerciseCommand'];
|
|
7
8
|
type DisclosedContract = Types['DisclosedContract'];
|
|
8
9
|
export declare class TokenStandardService {
|
|
9
10
|
private ledgerClient;
|
|
11
|
+
private scanProxyClient;
|
|
10
12
|
private readonly logger;
|
|
11
|
-
constructor(ledgerClient: LedgerClient, logger: Logger);
|
|
12
|
-
private
|
|
13
|
+
constructor(ledgerClient: LedgerClient, scanProxyClient: ScanProxyClient, logger: Logger);
|
|
14
|
+
private getTokenStandardClient;
|
|
13
15
|
createAcceptTransferInstruction(transferInstructionCid: string, transferFactoryRegistryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
14
16
|
getInstrumentAdmin(transferFactoryRegistryUrl: string): Promise<string | undefined>;
|
|
15
17
|
createRejectTransferInstruction(transferInstructionCid: string, transferFactoryRegistryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
16
|
-
listContractsByInterface<T = ViewValue>(interfaceId: string, partyId:
|
|
17
|
-
listHoldingTransactions(partyId:
|
|
18
|
-
createTransfer(sender:
|
|
18
|
+
listContractsByInterface<T = ViewValue>(interfaceId: string, partyId: PartyId): Promise<PrettyContract<T>[]>;
|
|
19
|
+
listHoldingTransactions(partyId: PartyId, afterOffset?: string, beforeOffset?: string): Promise<PrettyTransactions>;
|
|
20
|
+
createTransfer(sender: PartyId, receiver: PartyId, amount: string, instrumentAdmin: PartyId, // TODO (#907): replace with registry call
|
|
19
21
|
instrumentId: string, transferFactoryRegistryUrl: string, memo?: string, meta?: Record<string, unknown>): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
20
22
|
createTap(receiver: string, amount: string, instrumentAdmin: string, // TODO (#907): replace with registry call
|
|
21
23
|
instrumentId: string, transferFactoryRegistryUrl: string): Promise<[ExerciseCommand, DisclosedContract[]]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-standard-service.d.ts","sourceRoot":"","sources":["../src/token-standard-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;
|
|
1
|
+
{"version":3,"file":"token-standard-service.d.ts","sourceRoot":"","sources":["../src/token-standard-service.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAC5D,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AAYjD,OAAO,EACH,cAAc,EAEd,SAAS,EACZ,MAAM,oBAAoB,CAAA;AAE3B,OAAO,KAAK,EAAE,kBAAkB,EAAe,MAAM,oBAAoB,CAAA;AACzE,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC1C,OAAO,EAAE,eAAe,EAAE,MAAM,oCAAoC,CA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AAO,CAAC,CAAC,eAAe,EAAE,iBAAiB,EAAE,CAAC,CAAC;IAqF5C,SAAS,CACX,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,EAAE,0CAA0C;IACnE,YAAY,EAAE,MAAM,EACpB,0BAA0B,EAAE,MAAM,GACnC,OAAO,CAAC,CAAC,eAAe,EAAE,iBAAiB,EAAE,CAAC,CAAC;YA8EpC,oBAAoB;IAkDlC,OAAO,CAAC,gBAAgB;CAc3B"}
|
|
@@ -8,17 +8,19 @@ import { renderTransaction, } from './txparse/types.js';
|
|
|
8
8
|
const MEMO_KEY = 'splice.lfdecentralizedtrust.org/reason';
|
|
9
9
|
export class TokenStandardService {
|
|
10
10
|
ledgerClient;
|
|
11
|
+
scanProxyClient;
|
|
11
12
|
logger;
|
|
12
|
-
constructor(ledgerClient, logger) {
|
|
13
|
+
constructor(ledgerClient, scanProxyClient, logger) {
|
|
13
14
|
this.ledgerClient = ledgerClient;
|
|
15
|
+
this.scanProxyClient = scanProxyClient;
|
|
14
16
|
this.logger = logger;
|
|
15
17
|
}
|
|
16
|
-
|
|
18
|
+
getTokenStandardClient(registryUrl) {
|
|
17
19
|
return new TokenStandardClient(registryUrl, this.logger, undefined);
|
|
18
20
|
}
|
|
19
21
|
async createAcceptTransferInstruction(transferInstructionCid, transferFactoryRegistryUrl) {
|
|
20
22
|
try {
|
|
21
|
-
const client = this.
|
|
23
|
+
const client = this.getTokenStandardClient(transferFactoryRegistryUrl);
|
|
22
24
|
const choiceContext = await client.post('/registry/transfer-instruction/v1/{transferInstructionId}/choice-contexts/accept', {}, {
|
|
23
25
|
path: {
|
|
24
26
|
transferInstructionId: transferInstructionCid,
|
|
@@ -43,13 +45,13 @@ export class TokenStandardService {
|
|
|
43
45
|
}
|
|
44
46
|
}
|
|
45
47
|
async getInstrumentAdmin(transferFactoryRegistryUrl) {
|
|
46
|
-
const client = this.
|
|
48
|
+
const client = this.getTokenStandardClient(transferFactoryRegistryUrl);
|
|
47
49
|
const info = await client.get('/registry/metadata/v1/info');
|
|
48
50
|
return info.adminId;
|
|
49
51
|
}
|
|
50
52
|
async createRejectTransferInstruction(transferInstructionCid, transferFactoryRegistryUrl) {
|
|
51
53
|
try {
|
|
52
|
-
const client = this.
|
|
54
|
+
const client = this.getTokenStandardClient(transferFactoryRegistryUrl);
|
|
53
55
|
const choiceContext = await client.post('/registry/transfer-instruction/v1/{transferInstructionId}/choice-contexts/reject', {}, {
|
|
54
56
|
path: {
|
|
55
57
|
transferInstructionId: transferInstructionCid,
|
|
@@ -173,7 +175,7 @@ export class TokenStandardService {
|
|
|
173
175
|
},
|
|
174
176
|
};
|
|
175
177
|
this.logger.debug('Creating transfer factory...');
|
|
176
|
-
const transferFactory = await this.
|
|
178
|
+
const transferFactory = await this.getTokenStandardClient(transferFactoryRegistryUrl).post('/registry/transfer-instruction/v1/transfer-factory', {
|
|
177
179
|
choiceArguments: choiceArgs,
|
|
178
180
|
});
|
|
179
181
|
this.logger.debug(transferFactory, 'Transfer factory created');
|
|
@@ -197,7 +199,6 @@ export class TokenStandardService {
|
|
|
197
199
|
}
|
|
198
200
|
async createTap(receiver, amount, instrumentAdmin, // TODO (#907): replace with registry call
|
|
199
201
|
instrumentId, transferFactoryRegistryUrl) {
|
|
200
|
-
// TODO: replace with correct scan lookup
|
|
201
202
|
const now = new Date();
|
|
202
203
|
const tomorrow = new Date(now);
|
|
203
204
|
tomorrow.setDate(tomorrow.getDate() + 1);
|
|
@@ -219,27 +220,38 @@ export class TokenStandardService {
|
|
|
219
220
|
meta: { values: {} },
|
|
220
221
|
},
|
|
221
222
|
};
|
|
222
|
-
const transferFactory = await this.
|
|
223
|
+
const transferFactory = await this.getTokenStandardClient(transferFactoryRegistryUrl).post('/registry/transfer-instruction/v1/transfer-factory', {
|
|
223
224
|
choiceArguments: choiceArgs,
|
|
224
225
|
});
|
|
225
226
|
const disclosedContracts = transferFactory.choiceContext.disclosedContracts;
|
|
226
|
-
const amuletRules =
|
|
227
|
+
const amuletRules = await this.scanProxyClient.getAmuletRules();
|
|
228
|
+
const openMiningRounds = await this.scanProxyClient.getOpenMiningRounds();
|
|
227
229
|
if (!amuletRules) {
|
|
228
230
|
throw new Error('AmuletRules contract not found');
|
|
229
231
|
}
|
|
230
|
-
|
|
231
|
-
if (!openMiningRounds) {
|
|
232
|
+
if (!(Array.isArray(openMiningRounds) && openMiningRounds.length)) {
|
|
232
233
|
throw new Error('OpenMiningRound contract not found');
|
|
233
234
|
}
|
|
235
|
+
const nowForOpenMiningRounds = Date.now();
|
|
236
|
+
const latestOpenMiningRound = openMiningRounds.findLast((openMiningRound) => {
|
|
237
|
+
const { opensAt, targetClosesAt } = openMiningRound.payload;
|
|
238
|
+
const opensAtMs = Number(new Date(opensAt));
|
|
239
|
+
const targetClosesAtMs = Number(new Date(targetClosesAt));
|
|
240
|
+
return (opensAtMs <= nowForOpenMiningRounds &&
|
|
241
|
+
targetClosesAtMs > nowForOpenMiningRounds);
|
|
242
|
+
});
|
|
243
|
+
if (!latestOpenMiningRound) {
|
|
244
|
+
throw new Error('OpenMiningRound active at current moment not found');
|
|
245
|
+
}
|
|
234
246
|
return [
|
|
235
247
|
{
|
|
236
|
-
templateId: amuletRules.
|
|
237
|
-
contractId: amuletRules.
|
|
248
|
+
templateId: amuletRules.template_id,
|
|
249
|
+
contractId: amuletRules.contract_id,
|
|
238
250
|
choice: 'AmuletRules_DevNet_Tap',
|
|
239
251
|
choiceArgument: {
|
|
240
252
|
receiver: receiver,
|
|
241
253
|
amount: amount,
|
|
242
|
-
openRound:
|
|
254
|
+
openRound: latestOpenMiningRound.contract_id,
|
|
243
255
|
},
|
|
244
256
|
},
|
|
245
257
|
disclosedContracts,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LedgerClient } from './ledger-client.js';
|
|
2
2
|
import { SigningPublicKey, SignedTopologyTransaction, GenerateTransactionsResponse } from '@canton-network/core-ledger-proto';
|
|
3
|
+
import { PartyId } from '@canton-network/core-types';
|
|
3
4
|
export declare class TopologyWriteService {
|
|
4
5
|
private userAdminToken;
|
|
5
6
|
private topologyClient;
|
|
@@ -11,10 +12,10 @@ export declare class TopologyWriteService {
|
|
|
11
12
|
static createFingerprintFromKey: (publicKey: SigningPublicKey | string) => string;
|
|
12
13
|
static toSignedTopologyTransaction(txHashes: Buffer<ArrayBuffer>[], serializedTransaction: Uint8Array<ArrayBufferLike>, signature: string, namespace: string): SignedTopologyTransaction;
|
|
13
14
|
private generateTransactionsRequest;
|
|
14
|
-
submitExternalPartyTopology(signedTopologyTxs: SignedTopologyTransaction[], partyId:
|
|
15
|
-
generateTransactions(publicKey: string, partyId:
|
|
15
|
+
submitExternalPartyTopology(signedTopologyTxs: SignedTopologyTransaction[], partyId: PartyId): Promise<void>;
|
|
16
|
+
generateTransactions(publicKey: string, partyId: PartyId): Promise<GenerateTransactionsResponse>;
|
|
16
17
|
private addTransactions;
|
|
17
|
-
waitForPartyToParticipantProposal(partyId:
|
|
18
|
+
waitForPartyToParticipantProposal(partyId: PartyId): Promise<Uint8Array | undefined>;
|
|
18
19
|
private authorizePartyToParticipant;
|
|
19
20
|
}
|
|
20
21
|
//# sourceMappingURL=topology-write-service.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"topology-write-service.d.ts","sourceRoot":"","sources":["../src/topology-write-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAIH,gBAAgB,EAahB,yBAAyB,EASzB,4BAA4B,EAK/B,MAAM,mCAAmC,CAAA;
|
|
1
|
+
{"version":3,"file":"topology-write-service.d.ts","sourceRoot":"","sources":["../src/topology-write-service.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAIH,gBAAgB,EAahB,yBAAyB,EASzB,4BAA4B,EAK/B,MAAM,mCAAmC,CAAA;AAI1C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AA6BpD,qBAAa,oBAAoB;IAUzB,OAAO,CAAC,cAAc;IAT1B,OAAO,CAAC,cAAc,CAAmC;IACzD,OAAO,CAAC,mBAAmB,CAAkC;IAC7D,OAAO,CAAC,YAAY,CAAc;IAElC,OAAO,CAAC,KAAK,CAAS;gBAGlB,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACZ,cAAc,EAAE,MAAM,EAC9B,YAAY,EAAE,YAAY;IAuB9B,MAAM,CAAC,aAAa,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM;IAgC9C,MAAM,CAAC,wBAAwB,GAC3B,WAAW,gBAAgB,GAAG,MAAM,KACrC,MAAM,CAeR;IAED,MAAM,CAAC,2BAA2B,CAC9B,QAAQ,EAAE,MAAM,CAAC,WAAW,CAAC,EAAE,EAC/B,qBAAqB,EAAE,UAAU,CAAC,eAAe,CAAC,EAClD,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,GAClB,yBAAyB;IAqB5B,OAAO,CAAC,2BAA2B;IAiE7B,2BAA2B,CAC7B,iBAAiB,EAAE,yBAAyB,EAAE,EAC9C,OAAO,EAAE,OAAO;IAMd,oBAAoB,CACtB,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,4BAA4B,CAAC;YAuB1B,eAAe;IAgBvB,iCAAiC,CACnC,OAAO,EAAE,OAAO,GACjB,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;YAkCpB,2BAA2B;CAwB5C"}
|
|
@@ -68,7 +68,9 @@ export class TopologyWriteService {
|
|
|
68
68
|
]);
|
|
69
69
|
}
|
|
70
70
|
// 55 is the hash purpose for multi topology transaction hashes
|
|
71
|
-
|
|
71
|
+
const predefineHashPurpose = computeSha256CantonHash(55, concatenatedHashes);
|
|
72
|
+
//convert to base64
|
|
73
|
+
return Buffer.from(predefineHashPurpose, 'hex').toString('base64');
|
|
72
74
|
}
|
|
73
75
|
static createFingerprintFromKey = (publicKey) => {
|
|
74
76
|
let key;
|
package/dist/txparse/parser.d.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { Transaction } from './types.js';
|
|
2
2
|
import { components } from '../generated-clients/openapi-3.3.0-SNAPSHOT';
|
|
3
3
|
import { LedgerClient } from '../ledger-client';
|
|
4
|
+
import { PartyId } from '@canton-network/core-types';
|
|
4
5
|
type JsTransaction = components['schemas']['JsTransaction'];
|
|
5
6
|
export declare class TransactionParser {
|
|
6
7
|
private readonly ledgerClient;
|
|
7
8
|
private readonly partyId;
|
|
8
9
|
private readonly transaction;
|
|
9
|
-
constructor(transaction: JsTransaction, ledgerClient: LedgerClient, partyId:
|
|
10
|
+
constructor(transaction: JsTransaction, ledgerClient: LedgerClient, partyId: PartyId);
|
|
10
11
|
parseTransaction(): Promise<Transaction>;
|
|
11
12
|
private parseEvents;
|
|
12
13
|
private parseRawCreate;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/txparse/parser.ts"],"names":[],"mappings":"AAuBA,OAAO,EAOH,WAAW,EAId,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"parser.d.ts","sourceRoot":"","sources":["../../src/txparse/parser.ts"],"names":[],"mappings":"AAuBA,OAAO,EAOH,WAAW,EAId,MAAM,YAAY,CAAA;AAEnB,OAAO,EAAE,UAAU,EAAE,MAAM,6CAA6C,CAAA;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAA;AAE/C,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AAMpD,KAAK,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAA;AAI3D,qBAAa,iBAAiB;IAC1B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAc;IAC3C,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAS;IACjC,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAe;gBAGvC,WAAW,EAAE,aAAa,EAC1B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,OAAO;IAOd,gBAAgB,IAAI,OAAO,CAAC,WAAW,CAAC;YAYhC,WAAW;IAyDzB,OAAO,CAAC,cAAc;YAkBR,eAAe;IA4B7B,OAAO,CAAC,aAAa;YA4FP,aAAa;YAgFb,cAAc;YAsBd,aAAa;YAuFb,eAAe;YAmCf,oCAAoC;YA4DpC,UAAU;YAsBV,WAAW;YAuGX,mBAAmB;CA6CpC"}
|
|
@@ -32,7 +32,7 @@ describe('TransactionParser', () => {
|
|
|
32
32
|
jest.clearAllMocks();
|
|
33
33
|
});
|
|
34
34
|
it('returns transaction header and no events when input has no events', async () => {
|
|
35
|
-
const partyId = 'Alice';
|
|
35
|
+
const partyId = 'Alice::122000';
|
|
36
36
|
const tx = {
|
|
37
37
|
updateId: 'update-1',
|
|
38
38
|
offset: 42,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@canton-network/core-ledger-client",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provides a TypeScript Canton Network ledger client, generated by the OpenAPI spec",
|
|
6
6
|
"repository": "github:hyperledger-labs/splice-wallet-kernel",
|
|
@@ -29,8 +29,9 @@
|
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@canton-network/core-ledger-proto": "^0.3.0",
|
|
32
|
-
"@canton-network/core-
|
|
33
|
-
"@canton-network/core-
|
|
32
|
+
"@canton-network/core-splice-client": "^0.5.0",
|
|
33
|
+
"@canton-network/core-token-standard": "^0.4.1",
|
|
34
|
+
"@canton-network/core-types": "^0.3.1",
|
|
34
35
|
"@grpc/grpc-js": "^1.13.4",
|
|
35
36
|
"@protobuf-ts/grpc-transport": "^2.11.1",
|
|
36
37
|
"@protobuf-ts/runtime": "^2.11.1",
|