@canton-network/wallet-gateway-remote 0.2.0 → 0.3.0

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.
@@ -1 +1 @@
1
- {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAO9D,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AAGzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA6B7B,eAAO,MAAM,cAAc,GACvB,YAAY,gBAAgB,EAC5B,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,SAAS,MAAM,EACf,UAAU,WAAW;;;;;;;;;;;CAiHxB,CAAA"}
1
+ {"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAO/E,OAAO,EAAE,KAAK,EAAE,MAAM,mCAAmC,CAAA;AAQzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAA;AAC5E,OAAO,EAAE,UAAU,IAAI,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AACpE,OAAO,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AA6B7B,eAAO,MAAM,cAAc,GACvB,YAAY,gBAAgB,EAC5B,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,SAAS,MAAM,EACf,UAAU,WAAW;;;;;;;;;;;CA6IxB,CAAA"}
@@ -1,8 +1,9 @@
1
1
  // Copyright (c) 2025 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // Disabled unused vars rule to allow for future implementations
4
+ import { assertConnected } from '@canton-network/core-wallet-auth';
4
5
  import buildController from './rpc-gen/index.js';
5
- import { LedgerClient } from '@canton-network/core-ledger-client';
6
+ import { LedgerClient, } from '@canton-network/core-ledger-client';
6
7
  import { v4 } from 'uuid';
7
8
  async function prepareSubmission(userId, partyId, synchronizerId, commands, ledgerClient, commandId) {
8
9
  const prepareParams = {
@@ -28,9 +29,26 @@ export const dappController = (kernelInfo, store, notificationService, _logger,
28
29
  userUrl: 'http://localhost:3002/login/',
29
30
  }),
30
31
  darsAvailable: async () => ({ dars: ['default-dar'] }),
31
- ledgerApi: async (params) => ({
32
- response: 'default-response',
33
- }),
32
+ ledgerApi: async (params) => {
33
+ const network = await store.getCurrentNetwork();
34
+ const ledgerClient = new LedgerClient(new URL(network.ledgerApi.baseUrl), assertConnected(context).accessToken, logger);
35
+ let result;
36
+ switch (params.requestMethod) {
37
+ case 'GET':
38
+ result = await ledgerClient.getWithRetry(params.resource);
39
+ break;
40
+ case 'POST':
41
+ result = await ledgerClient.postWithRetry(params.resource, params.body
42
+ ? JSON.parse(params.body)
43
+ : undefined);
44
+ break;
45
+ default:
46
+ throw new Error(`Unsupported request method: ${params.requestMethod}`);
47
+ }
48
+ return {
49
+ response: JSON.stringify(result),
50
+ };
51
+ },
34
52
  prepareExecute: async (params) => {
35
53
  const wallet = await store.getPrimaryWallet();
36
54
  const network = await store.getCurrentNetwork();
@@ -65,7 +65,7 @@ export const userController = (kernelInfo, store, notificationService, authConte
65
65
  },
66
66
  createWallet: async (params) => {
67
67
  logger.info(`Allocating party with params: ${JSON.stringify(params)}`);
68
- const userId = assertConnected(authContext);
68
+ const userId = assertConnected(authContext).userId;
69
69
  const notifier = notificationService.getNotifier(userId);
70
70
  const network = await store.getCurrentNetwork();
71
71
  if (network === undefined) {
@@ -140,7 +140,7 @@ export const userController = (kernelInfo, store, notificationService, authConte
140
140
  if (wallet === undefined) {
141
141
  throw new Error('No primary wallet found');
142
142
  }
143
- const userId = assertConnected(authContext);
143
+ const userId = assertConnected(authContext).userId;
144
144
  if (network === undefined) {
145
145
  throw new Error('No network session found');
146
146
  }
@@ -196,7 +196,7 @@ export const userController = (kernelInfo, store, notificationService, authConte
196
196
  if (transaction === undefined) {
197
197
  throw new Error('No transaction found');
198
198
  }
199
- const userId = assertConnected(authContext);
199
+ const userId = assertConnected(authContext).userId;
200
200
  if (network === undefined) {
201
201
  throw new Error('No network session found');
202
202
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canton-network/wallet-gateway-remote",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "A server-side Wallet Gateway implementation over HTTP",
5
5
  "main": "dist/index.js",
6
6
  "bin": {