@canton-network/wallet-gateway-remote 0.17.3 → 0.19.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.
- package/README.md +37 -0
- package/dist/config/Config.d.ts +19 -15
- package/dist/config/Config.d.ts.map +1 -1
- package/dist/config/Config.js +7 -3
- package/dist/config/Config.test.js +8 -8
- package/dist/config/ConfigUtils.js +6 -6
- package/dist/dapp-api/controller.d.ts +7 -6
- package/dist/dapp-api/controller.d.ts.map +1 -1
- package/dist/dapp-api/controller.js +75 -50
- package/dist/dapp-api/rpc-gen/index.d.ts +21 -18
- package/dist/dapp-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/dapp-api/rpc-gen/index.js +7 -6
- package/dist/dapp-api/rpc-gen/typings.d.ts +69 -101
- package/dist/dapp-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/dapp-api/server.d.ts.map +1 -1
- package/dist/dapp-api/server.js +52 -45
- package/dist/dapp-api/server.test.js +1 -5
- package/dist/example-config.d.ts +3 -0
- package/dist/example-config.d.ts.map +1 -1
- package/dist/example-config.js +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -1
- package/dist/init.d.ts.map +1 -1
- package/dist/init.js +52 -5
- package/dist/ledger/wallet-sync-service.d.ts.map +1 -1
- package/dist/ledger/wallet-sync-service.js +30 -20
- package/dist/ledger/wallet-sync-service.test.js +339 -0
- package/dist/middleware/jwtAuth.d.ts.map +1 -1
- package/dist/middleware/jwtAuth.js +3 -1
- package/dist/user-api/controller.d.ts +3 -1
- package/dist/user-api/controller.d.ts.map +1 -1
- package/dist/user-api/controller.js +128 -47
- package/dist/user-api/rpc-gen/index.d.ts +6 -0
- package/dist/user-api/rpc-gen/index.d.ts.map +1 -1
- package/dist/user-api/rpc-gen/index.js +2 -0
- package/dist/user-api/rpc-gen/typings.d.ts +37 -24
- package/dist/user-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/user-api/server.d.ts +1 -1
- package/dist/user-api/server.d.ts.map +1 -1
- package/dist/user-api/server.js +2 -2
- package/dist/user-api/server.test.js +1 -1
- package/dist/utils.d.ts +0 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/web/frontend/404/index.html +2 -3
- package/dist/web/frontend/approve/index.html +4 -5
- package/dist/web/frontend/assets/404-BQsvObfu.js +8 -0
- package/dist/web/frontend/assets/approve-BLORPbEM.js +17 -0
- package/dist/web/frontend/assets/{callback-B-wmBVDs.js → callback-C7kRcm3U.js} +1 -1
- package/dist/web/frontend/assets/index-DPbaEEZi.js +1722 -0
- package/dist/web/frontend/assets/{decode-CLJkuAIr.js → index-NP2zGQqX.js} +1 -1
- package/dist/web/frontend/assets/login-p5H_f9In.js +7 -0
- package/dist/web/frontend/assets/settings-89wZp5vZ.js +37 -0
- package/dist/web/frontend/assets/{state-CziDYJOu.js → state-TjGUBiUh.js} +1 -1
- package/dist/web/frontend/assets/transactions-BnROcA2_.js +28 -0
- package/dist/web/frontend/assets/wallets-TPeR2lS2.js +63 -0
- package/dist/web/frontend/callback/index.html +2 -3
- package/dist/web/frontend/index.html +1 -2
- package/dist/web/frontend/login/index.html +3 -4
- package/dist/web/frontend/settings/index.html +3 -4
- package/dist/web/frontend/transactions/index.html +4 -5
- package/dist/web/frontend/wallets/index.html +3 -4
- package/package.json +26 -21
- package/dist/web/frontend/assets/404-C5sXhYIJ.js +0 -16
- package/dist/web/frontend/assets/approve-DLsPdBvo.js +0 -227
- package/dist/web/frontend/assets/index-CxDOwxiY.css +0 -1
- package/dist/web/frontend/assets/index-Dfw8gEND.js +0 -1158
- package/dist/web/frontend/assets/login-BiJNU2kh.js +0 -186
- package/dist/web/frontend/assets/settings-B8ayu_0I.js +0 -28
- package/dist/web/frontend/assets/transactions-D2Yx5LYD.js +0 -140
- package/dist/web/frontend/assets/wallets-nCed0fPk.js +0 -266
package/README.md
CHANGED
|
@@ -51,3 +51,40 @@ The JSON-RPC API specs from `api-specs/` are generated into strongly-typed metho
|
|
|
51
51
|
2. Place the `fireblocks_secret.key` file at the path `/splice-wallet-kernel/wallet-gateway/remote`
|
|
52
52
|
|
|
53
53
|
3. Create a file named `fireblocks_api.key` at the path `/splice-wallet-kernel/wallet-gateway/remote` and insert your Fireblocks API key into it (get it from `API User (ID)` column in fireblocks api users table). Make sure file doesn't end with new line character.
|
|
54
|
+
|
|
55
|
+
## Postgres connection
|
|
56
|
+
|
|
57
|
+
To create a Postgres database you need to:
|
|
58
|
+
|
|
59
|
+
1. Start Postgres in Docker using:
|
|
60
|
+
|
|
61
|
+
```shell
|
|
62
|
+
$ docker run --network=host --name some-postgres -e POSTGRES_PASSWORD=postgres -d postgres
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
2. In the file `splice-wallet-kernel/wallet-gateway/test/config.json`, specify the connection settings for both databases (store and signingStore). The connection should look like this (it is important that `store.connection.database !== signingStore.connection.database !== 'postgres'`):
|
|
66
|
+
|
|
67
|
+
```json
|
|
68
|
+
{
|
|
69
|
+
"store": {
|
|
70
|
+
"connection": {
|
|
71
|
+
"type": "postgres",
|
|
72
|
+
"password": "postgres",
|
|
73
|
+
"port": 5432,
|
|
74
|
+
"user": "postgres",
|
|
75
|
+
"host": "0.0.0.0",
|
|
76
|
+
"database": "wallet_store"
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
"signingStore": {
|
|
80
|
+
"connection": {
|
|
81
|
+
"type": "postgres",
|
|
82
|
+
"password": "postgres",
|
|
83
|
+
"port": 5432,
|
|
84
|
+
"user": "postgres",
|
|
85
|
+
"host": "0.0.0.0",
|
|
86
|
+
"database": "signing_store"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
package/dist/config/Config.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ export declare const serverConfigSchema: z.ZodObject<{
|
|
|
13
13
|
tls: z.ZodOptional<z.ZodBoolean>;
|
|
14
14
|
requestSizeLimit: z.ZodDefault<z.ZodString>;
|
|
15
15
|
requestRateLimit: z.ZodDefault<z.ZodNumber>;
|
|
16
|
+
admin: z.ZodOptional<z.ZodString>;
|
|
16
17
|
}, z.core.$strip>;
|
|
17
18
|
export declare const configSchema: z.ZodObject<{
|
|
18
19
|
kernel: z.ZodObject<{
|
|
@@ -29,6 +30,7 @@ export declare const configSchema: z.ZodObject<{
|
|
|
29
30
|
tls: z.ZodOptional<z.ZodBoolean>;
|
|
30
31
|
requestSizeLimit: z.ZodDefault<z.ZodString>;
|
|
31
32
|
requestRateLimit: z.ZodDefault<z.ZodNumber>;
|
|
33
|
+
admin: z.ZodOptional<z.ZodString>;
|
|
32
34
|
}, z.core.$strip>>;
|
|
33
35
|
store: z.ZodObject<{
|
|
34
36
|
connection: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
@@ -44,6 +46,23 @@ export declare const configSchema: z.ZodObject<{
|
|
|
44
46
|
password: z.ZodString;
|
|
45
47
|
database: z.ZodString;
|
|
46
48
|
}, z.core.$strip>], "type">;
|
|
49
|
+
}, z.core.$strip>;
|
|
50
|
+
signingStore: z.ZodObject<{
|
|
51
|
+
connection: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
52
|
+
type: z.ZodLiteral<"memory">;
|
|
53
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
54
|
+
type: z.ZodLiteral<"sqlite">;
|
|
55
|
+
database: z.ZodString;
|
|
56
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
57
|
+
type: z.ZodLiteral<"postgres">;
|
|
58
|
+
host: z.ZodString;
|
|
59
|
+
port: z.ZodNumber;
|
|
60
|
+
user: z.ZodString;
|
|
61
|
+
password: z.ZodString;
|
|
62
|
+
database: z.ZodString;
|
|
63
|
+
}, z.core.$strip>], "type">;
|
|
64
|
+
}, z.core.$strip>;
|
|
65
|
+
bootstrap: z.ZodObject<{
|
|
47
66
|
idps: z.ZodArray<z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
48
67
|
id: z.ZodString;
|
|
49
68
|
type: z.ZodLiteral<"self_signed">;
|
|
@@ -103,21 +122,6 @@ export declare const configSchema: z.ZodObject<{
|
|
|
103
122
|
}, z.core.$strip>], "method">>;
|
|
104
123
|
}, z.core.$strip>>;
|
|
105
124
|
}, z.core.$strip>;
|
|
106
|
-
signingStore: z.ZodObject<{
|
|
107
|
-
connection: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
108
|
-
type: z.ZodLiteral<"memory">;
|
|
109
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
110
|
-
type: z.ZodLiteral<"sqlite">;
|
|
111
|
-
database: z.ZodString;
|
|
112
|
-
}, z.core.$strip>, z.ZodObject<{
|
|
113
|
-
type: z.ZodLiteral<"postgres">;
|
|
114
|
-
host: z.ZodString;
|
|
115
|
-
port: z.ZodNumber;
|
|
116
|
-
user: z.ZodString;
|
|
117
|
-
password: z.ZodString;
|
|
118
|
-
database: z.ZodString;
|
|
119
|
-
}, z.core.$strip>], "type">;
|
|
120
|
-
}, z.core.$strip>;
|
|
121
125
|
}, z.core.$strip>;
|
|
122
126
|
export type KernelInfo = z.infer<typeof kernelInfoSchema>;
|
|
123
127
|
export type ServerConfig = z.infer<typeof serverConfigSchema>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/config/Config.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Config.d.ts","sourceRoot":"","sources":["../../src/config/Config.ts"],"names":[],"mappings":"AAQA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,eAAO,MAAM,gBAAgB;;;;iBAY3B,CAAA;AAEF,eAAO,MAAM,kBAAkB;;;;;;;;;;iBA0C7B,CAAA;AAEF,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAMvB,CAAA;AAEF,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAA;AACzD,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAA;AAC7D,MAAM,MAAM,MAAM,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,CAAA"}
|
package/dist/config/Config.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Copyright (c) 2025-2026 Digital Asset (Switzerland) GmbH and/or its affiliates. All rights reserved.
|
|
2
2
|
// SPDX-License-Identifier: Apache-2.0
|
|
3
|
-
import { storeConfigSchema } from '@canton-network/core-wallet-store';
|
|
3
|
+
import { storeConfigSchema, bootstrapConfigSchema, } from '@canton-network/core-wallet-store';
|
|
4
4
|
import { storeConfigSchema as signingStoreConfigSchema } from '@canton-network/core-signing-store-sql';
|
|
5
5
|
import { z } from 'zod';
|
|
6
6
|
export const kernelInfoSchema = z.object({
|
|
@@ -44,8 +44,11 @@ export const serverConfigSchema = z.object({
|
|
|
44
44
|
requestSizeLimit: z.string().default('1mb').meta({
|
|
45
45
|
description: 'The maximum size of incoming requests. Defaults to 1mb.',
|
|
46
46
|
}),
|
|
47
|
-
requestRateLimit: z.number().default(
|
|
48
|
-
description: 'The maximum number of requests per minute from a single IP address. Defaults to
|
|
47
|
+
requestRateLimit: z.number().default(10000).meta({
|
|
48
|
+
description: 'The maximum number of requests per minute from a single IP address. Defaults to 10000.',
|
|
49
|
+
}),
|
|
50
|
+
admin: z.string().optional().meta({
|
|
51
|
+
description: 'The JWT claim (e.g. "sub") identifying the admin user. If set, requests with a matching claim will be granted admin privileges.',
|
|
49
52
|
}),
|
|
50
53
|
});
|
|
51
54
|
export const configSchema = z.object({
|
|
@@ -53,4 +56,5 @@ export const configSchema = z.object({
|
|
|
53
56
|
server: z.preprocess((val) => val ?? {}, serverConfigSchema),
|
|
54
57
|
store: storeConfigSchema,
|
|
55
58
|
signingStore: signingStoreConfigSchema,
|
|
59
|
+
bootstrap: bootstrapConfigSchema,
|
|
56
60
|
});
|
|
@@ -4,13 +4,13 @@ import { expect, test } from '@jest/globals';
|
|
|
4
4
|
import { ConfigUtils } from './ConfigUtils.js';
|
|
5
5
|
test('config from json file', async () => {
|
|
6
6
|
const resp = ConfigUtils.loadConfigFile('../test/config.json');
|
|
7
|
-
expect(resp.
|
|
8
|
-
expect(resp.
|
|
9
|
-
expect(resp.
|
|
10
|
-
expect(resp.
|
|
11
|
-
expect(resp.
|
|
12
|
-
expect(resp.
|
|
13
|
-
if (resp.
|
|
14
|
-
expect(resp.
|
|
7
|
+
expect(resp.bootstrap.networks[0].name).toBe('Local (OAuth IDP)');
|
|
8
|
+
expect(resp.bootstrap.networks[0].ledgerApi.baseUrl).toBe('http://127.0.0.1:5003');
|
|
9
|
+
expect(resp.bootstrap.networks[0].auth.clientId).toBe('operator');
|
|
10
|
+
expect(resp.bootstrap.networks[0].auth.scope).toBe('openid daml_ledger_api offline_access');
|
|
11
|
+
expect(resp.bootstrap.networks[0].auth.method).toBe('authorization_code');
|
|
12
|
+
expect(resp.bootstrap.networks[2].auth.method).toBe('client_credentials');
|
|
13
|
+
if (resp.bootstrap.networks[2].auth.method === 'client_credentials') {
|
|
14
|
+
expect(resp.bootstrap.networks[2].auth.audience).toBe('https://daml.com/jwt/aud/participant/participant1::1220d44fc1c3ba0b5bdf7b956ee71bc94ebe2d23258dc268fdf0824fbaeff2c61424');
|
|
15
15
|
}
|
|
16
16
|
});
|
|
@@ -15,11 +15,11 @@ export class ConfigUtils {
|
|
|
15
15
|
* 3. Each Network's identityProviderId maps to an existing IDP (in config)
|
|
16
16
|
* 4. Each Network's auth method is compatible with its IDP type
|
|
17
17
|
*/
|
|
18
|
-
const duplicateIdpId = hasDuplicateElement(config.
|
|
18
|
+
const duplicateIdpId = hasDuplicateElement(config.bootstrap.idps.map((idp) => idp.id));
|
|
19
19
|
if (duplicateIdpId) {
|
|
20
20
|
throw new Error(`Non-unique IDP IDs found in config file: ${duplicateIdpId}`);
|
|
21
21
|
}
|
|
22
|
-
const duplicateNetworkId = hasDuplicateElement(config.
|
|
22
|
+
const duplicateNetworkId = hasDuplicateElement(config.bootstrap.networks.map((network) => network.id));
|
|
23
23
|
if (duplicateNetworkId) {
|
|
24
24
|
throw new Error(`Non-unique Network IDs found in config file: ${duplicateNetworkId}`);
|
|
25
25
|
}
|
|
@@ -48,8 +48,8 @@ function hasDuplicateElement(list) {
|
|
|
48
48
|
return duplicate;
|
|
49
49
|
}
|
|
50
50
|
function validateNetworkToIdpMapping(config) {
|
|
51
|
-
for (const network of config.
|
|
52
|
-
const idp = config.
|
|
51
|
+
for (const network of config.bootstrap.networks) {
|
|
52
|
+
const idp = config.bootstrap.idps.find((idp) => idp.id === network.identityProviderId);
|
|
53
53
|
if (typeof idp === 'undefined') {
|
|
54
54
|
return { networkId: network.id, idpId: network.identityProviderId };
|
|
55
55
|
}
|
|
@@ -60,8 +60,8 @@ const SUPPORTED_IDP_METHODS = {
|
|
|
60
60
|
oauth: ['authorization_code', 'client_credentials'],
|
|
61
61
|
};
|
|
62
62
|
function validateNetworkAuthMethods(config) {
|
|
63
|
-
for (const network of config.
|
|
64
|
-
const idp = config.
|
|
63
|
+
for (const network of config.bootstrap.networks) {
|
|
64
|
+
const idp = config.bootstrap.idps.find((idp) => idp.id === network.identityProviderId);
|
|
65
65
|
if (!SUPPORTED_IDP_METHODS[idp.type].includes(network.auth.method)) {
|
|
66
66
|
return {
|
|
67
67
|
networkId: network.id,
|
|
@@ -7,14 +7,15 @@ export declare const dappController: (kernelInfo: KernelInfoConfig, dappUrl: str
|
|
|
7
7
|
status: import("./rpc-gen/typings.js").Status;
|
|
8
8
|
connect: import("./rpc-gen/typings.js").Connect;
|
|
9
9
|
disconnect: import("./rpc-gen/typings.js").Disconnect;
|
|
10
|
-
|
|
11
|
-
prepareReturn: import("./rpc-gen/typings.js").PrepareReturn;
|
|
10
|
+
getActiveNetwork: import("./rpc-gen/typings.js").GetActiveNetwork;
|
|
12
11
|
prepareExecute: import("./rpc-gen/typings.js").PrepareExecute;
|
|
12
|
+
signMessage: import("./rpc-gen/typings.js").SignMessage;
|
|
13
13
|
ledgerApi: import("./rpc-gen/typings.js").LedgerApi;
|
|
14
|
-
|
|
14
|
+
connected: import("./rpc-gen/typings.js").Connected;
|
|
15
15
|
onStatusChanged: import("./rpc-gen/typings.js").OnStatusChanged;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
accountsChanged: import("./rpc-gen/typings.js").AccountsChanged;
|
|
17
|
+
getPrimaryAccount: import("./rpc-gen/typings.js").GetPrimaryAccount;
|
|
18
|
+
listAccounts: import("./rpc-gen/typings.js").ListAccounts;
|
|
19
|
+
txChanged: import("./rpc-gen/typings.js").TxChanged;
|
|
19
20
|
};
|
|
20
21
|
//# sourceMappingURL=controller.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,WAAW,EAAE,MAAM,kCAAkC,CAAA;
|
|
1
|
+
{"version":3,"file":"controller.d.ts","sourceRoot":"","sources":["../../src/dapp-api/controller.ts"],"names":[],"mappings":"AAGA,OAAO,EAAmB,WAAW,EAAE,MAAM,kCAAkC,CAAA;AAW/E,OAAO,EAAE,KAAK,EAAe,MAAM,mCAAmC,CAAA;AAQtE,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;AAG7B,eAAO,MAAM,cAAc,GACvB,YAAY,gBAAgB,EAC5B,SAAS,MAAM,EACf,SAAS,MAAM,EACf,OAAO,KAAK,EACZ,qBAAqB,mBAAmB,EACxC,SAAS,MAAM,EACf,QAAQ,MAAM,GAAG,IAAI,EACrB,UAAU,WAAW;;;;;;;;;;;;;;CAwQxB,CAAA"}
|
|
@@ -11,14 +11,13 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
11
11
|
connect: async () => {
|
|
12
12
|
if (!context || !(await store.getSession())) {
|
|
13
13
|
return {
|
|
14
|
-
kernel: kernelInfo,
|
|
15
14
|
isConnected: false,
|
|
16
15
|
isNetworkConnected: false,
|
|
17
16
|
networkReason: 'Unauthenticated',
|
|
18
17
|
userUrl: `${userUrl}/login/`,
|
|
19
18
|
};
|
|
20
19
|
}
|
|
21
|
-
const session = await store.getSession()
|
|
20
|
+
// const session = await store.getSession()
|
|
22
21
|
const network = await store.getCurrentNetwork();
|
|
23
22
|
const ledgerClient = new LedgerClient({
|
|
24
23
|
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
@@ -27,24 +26,36 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
27
26
|
accessToken: context.accessToken,
|
|
28
27
|
});
|
|
29
28
|
const status = await networkStatus(ledgerClient);
|
|
30
|
-
|
|
31
|
-
|
|
29
|
+
const notifier = notificationService.getNotifier(context.userId);
|
|
30
|
+
const provider = {
|
|
31
|
+
id: kernelInfo.id,
|
|
32
|
+
version: 'TODO',
|
|
33
|
+
providerType: kernelInfo.clientType,
|
|
34
|
+
url: dappUrl,
|
|
35
|
+
userUrl: `${userUrl}/login/`,
|
|
36
|
+
};
|
|
37
|
+
const connection = {
|
|
32
38
|
isConnected: true,
|
|
39
|
+
reason: 'OK',
|
|
33
40
|
isNetworkConnected: status.isConnected,
|
|
34
41
|
networkReason: status.reason ? status.reason : 'OK',
|
|
42
|
+
userUrl: `${userUrl}/login/`,
|
|
43
|
+
};
|
|
44
|
+
const statusEvent = {
|
|
45
|
+
provider,
|
|
46
|
+
connection,
|
|
35
47
|
network: {
|
|
36
48
|
networkId: network.id,
|
|
37
|
-
ledgerApi:
|
|
38
|
-
|
|
39
|
-
},
|
|
49
|
+
ledgerApi: network.ledgerApi.baseUrl,
|
|
50
|
+
accessToken: context.accessToken,
|
|
40
51
|
},
|
|
41
52
|
session: {
|
|
42
|
-
id: session?.id,
|
|
43
53
|
accessToken: context.accessToken,
|
|
44
54
|
userId: context.userId,
|
|
45
55
|
},
|
|
46
|
-
userUrl: `${userUrl}/login/`,
|
|
47
56
|
};
|
|
57
|
+
notifier.emit('statusChanged', statusEvent);
|
|
58
|
+
return connection;
|
|
48
59
|
},
|
|
49
60
|
disconnect: async () => {
|
|
50
61
|
if (!context) {
|
|
@@ -54,16 +65,22 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
54
65
|
const notifier = notificationService.getNotifier(context.userId);
|
|
55
66
|
await store.removeSession();
|
|
56
67
|
notifier.emit('statusChanged', {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
68
|
+
provider: {
|
|
69
|
+
id: kernelInfo.id,
|
|
70
|
+
providerType: kernelInfo.clientType,
|
|
71
|
+
url: dappUrl,
|
|
72
|
+
userUrl: `${userUrl}/login/`,
|
|
73
|
+
},
|
|
74
|
+
connection: {
|
|
75
|
+
isConnected: false,
|
|
76
|
+
reason: 'disconnect',
|
|
77
|
+
isNetworkConnected: false,
|
|
78
|
+
networkReason: 'disconnect',
|
|
79
|
+
},
|
|
62
80
|
});
|
|
63
81
|
}
|
|
64
82
|
return null;
|
|
65
83
|
},
|
|
66
|
-
darsAvailable: async () => ({ dars: ['default-dar'] }),
|
|
67
84
|
ledgerApi: async (params) => {
|
|
68
85
|
const network = await store.getCurrentNetwork();
|
|
69
86
|
const ledgerClient = new LedgerClient({
|
|
@@ -135,33 +152,27 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
135
152
|
}, 'prepared transaction traffic estimation');
|
|
136
153
|
store.setTransaction(transaction);
|
|
137
154
|
return {
|
|
138
|
-
|
|
155
|
+
// closeafteraction query param flag makes approving or deleting tx close the popup
|
|
156
|
+
userUrl: `${userUrl}/approve/index.html?commandId=${commandId}&closeafteraction`,
|
|
139
157
|
};
|
|
140
158
|
},
|
|
141
|
-
prepareReturn: async (params) => {
|
|
142
|
-
const wallet = await store.getPrimaryWallet();
|
|
143
|
-
const network = await store.getCurrentNetwork();
|
|
144
|
-
if (context === undefined) {
|
|
145
|
-
throw new Error('Unauthenticated context');
|
|
146
|
-
}
|
|
147
|
-
if (wallet === undefined) {
|
|
148
|
-
throw new Error('No primary wallet found');
|
|
149
|
-
}
|
|
150
|
-
const ledgerClient = new LedgerClient({
|
|
151
|
-
baseUrl: new URL(network.ledgerApi.baseUrl),
|
|
152
|
-
logger,
|
|
153
|
-
isAdmin: false,
|
|
154
|
-
accessToken: context.accessToken,
|
|
155
|
-
});
|
|
156
|
-
return prepareSubmission(context.userId, wallet.partyId, network.synchronizerId, params, ledgerClient);
|
|
157
|
-
},
|
|
158
159
|
status: async () => {
|
|
160
|
+
const provider = {
|
|
161
|
+
id: kernelInfo.id,
|
|
162
|
+
version: 'TODO',
|
|
163
|
+
providerType: kernelInfo.clientType,
|
|
164
|
+
url: dappUrl,
|
|
165
|
+
userUrl: `${userUrl}/login/`,
|
|
166
|
+
};
|
|
159
167
|
if (!context || !(await store.getSession())) {
|
|
160
168
|
return {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
169
|
+
provider: provider,
|
|
170
|
+
connection: {
|
|
171
|
+
isConnected: false,
|
|
172
|
+
reason: 'Unauthenticated',
|
|
173
|
+
isNetworkConnected: false,
|
|
174
|
+
networkReason: 'Unauthenticated',
|
|
175
|
+
},
|
|
165
176
|
};
|
|
166
177
|
}
|
|
167
178
|
const session = await store.getSession();
|
|
@@ -174,15 +185,17 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
174
185
|
});
|
|
175
186
|
const status = await networkStatus(ledgerClient);
|
|
176
187
|
return {
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
188
|
+
provider: provider,
|
|
189
|
+
connection: {
|
|
190
|
+
isConnected: true,
|
|
191
|
+
reason: 'OK',
|
|
192
|
+
isNetworkConnected: status.isConnected,
|
|
193
|
+
networkReason: status.reason ? status.reason : 'OK',
|
|
194
|
+
},
|
|
181
195
|
network: {
|
|
182
196
|
networkId: network.id,
|
|
183
|
-
ledgerApi:
|
|
184
|
-
|
|
185
|
-
},
|
|
197
|
+
ledgerApi: network.ledgerApi.baseUrl,
|
|
198
|
+
accessToken: context.accessToken,
|
|
186
199
|
},
|
|
187
200
|
session: {
|
|
188
201
|
id: session?.id,
|
|
@@ -192,22 +205,34 @@ export const dappController = (kernelInfo, dappUrl, userUrl, store, notification
|
|
|
192
205
|
userUrl: `${userUrl}/login/`,
|
|
193
206
|
};
|
|
194
207
|
},
|
|
195
|
-
|
|
208
|
+
connected: async () => {
|
|
196
209
|
throw new Error('Only for events.');
|
|
197
210
|
},
|
|
198
211
|
onStatusChanged: async () => {
|
|
199
212
|
throw new Error('Only for events.');
|
|
200
213
|
},
|
|
201
|
-
|
|
214
|
+
accountsChanged: async () => {
|
|
202
215
|
throw new Error('Only for events.');
|
|
203
216
|
},
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
return wallets;
|
|
217
|
+
listAccounts: async () => {
|
|
218
|
+
return await store.getWallets();
|
|
207
219
|
},
|
|
208
|
-
|
|
220
|
+
txChanged: async () => {
|
|
209
221
|
throw new Error('Only for events.');
|
|
210
222
|
},
|
|
223
|
+
getActiveNetwork: function () {
|
|
224
|
+
throw new Error('Function not implemented.');
|
|
225
|
+
},
|
|
226
|
+
signMessage: function () {
|
|
227
|
+
throw new Error('Function not implemented.');
|
|
228
|
+
},
|
|
229
|
+
getPrimaryAccount: async function () {
|
|
230
|
+
const wallet = await store.getPrimaryWallet();
|
|
231
|
+
if (!wallet) {
|
|
232
|
+
throw new Error('No primary wallet found');
|
|
233
|
+
}
|
|
234
|
+
return wallet;
|
|
235
|
+
},
|
|
211
236
|
});
|
|
212
237
|
};
|
|
213
238
|
async function prepareSubmission(userId, partyId, synchronizerId, params, ledgerClient) {
|
|
@@ -1,42 +1,45 @@
|
|
|
1
1
|
import { Status } from './typings.js';
|
|
2
2
|
import { Connect } from './typings.js';
|
|
3
3
|
import { Disconnect } from './typings.js';
|
|
4
|
-
import {
|
|
5
|
-
import { PrepareReturn } from './typings.js';
|
|
4
|
+
import { GetActiveNetwork } from './typings.js';
|
|
6
5
|
import { PrepareExecute } from './typings.js';
|
|
6
|
+
import { SignMessage } from './typings.js';
|
|
7
7
|
import { LedgerApi } from './typings.js';
|
|
8
|
-
import {
|
|
8
|
+
import { Connected } from './typings.js';
|
|
9
9
|
import { OnStatusChanged } from './typings.js';
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
10
|
+
import { AccountsChanged } from './typings.js';
|
|
11
|
+
import { GetPrimaryAccount } from './typings.js';
|
|
12
|
+
import { ListAccounts } from './typings.js';
|
|
13
|
+
import { TxChanged } from './typings.js';
|
|
13
14
|
export type Methods = {
|
|
14
15
|
status: Status;
|
|
15
16
|
connect: Connect;
|
|
16
17
|
disconnect: Disconnect;
|
|
17
|
-
|
|
18
|
-
prepareReturn: PrepareReturn;
|
|
18
|
+
getActiveNetwork: GetActiveNetwork;
|
|
19
19
|
prepareExecute: PrepareExecute;
|
|
20
|
+
signMessage: SignMessage;
|
|
20
21
|
ledgerApi: LedgerApi;
|
|
21
|
-
|
|
22
|
+
connected: Connected;
|
|
22
23
|
onStatusChanged: OnStatusChanged;
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
accountsChanged: AccountsChanged;
|
|
25
|
+
getPrimaryAccount: GetPrimaryAccount;
|
|
26
|
+
listAccounts: ListAccounts;
|
|
27
|
+
txChanged: TxChanged;
|
|
26
28
|
};
|
|
27
29
|
declare function buildController(methods: Methods): {
|
|
28
30
|
status: Status;
|
|
29
31
|
connect: Connect;
|
|
30
32
|
disconnect: Disconnect;
|
|
31
|
-
|
|
32
|
-
prepareReturn: PrepareReturn;
|
|
33
|
+
getActiveNetwork: GetActiveNetwork;
|
|
33
34
|
prepareExecute: PrepareExecute;
|
|
35
|
+
signMessage: SignMessage;
|
|
34
36
|
ledgerApi: LedgerApi;
|
|
35
|
-
|
|
37
|
+
connected: Connected;
|
|
36
38
|
onStatusChanged: OnStatusChanged;
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
39
|
+
accountsChanged: AccountsChanged;
|
|
40
|
+
getPrimaryAccount: GetPrimaryAccount;
|
|
41
|
+
listAccounts: ListAccounts;
|
|
42
|
+
txChanged: TxChanged;
|
|
40
43
|
};
|
|
41
44
|
export default buildController;
|
|
42
45
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dapp-api/rpc-gen/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/dapp-api/rpc-gen/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAA;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAA;AACtC,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAA;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AACxC,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,eAAe,EAAE,MAAM,cAAc,CAAA;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAA;AAExC,MAAM,MAAM,OAAO,GAAG;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,UAAU,EAAE,UAAU,CAAA;IACtB,gBAAgB,EAAE,gBAAgB,CAAA;IAClC,cAAc,EAAE,cAAc,CAAA;IAC9B,WAAW,EAAE,WAAW,CAAA;IACxB,SAAS,EAAE,SAAS,CAAA;IACpB,SAAS,EAAE,SAAS,CAAA;IACpB,eAAe,EAAE,eAAe,CAAA;IAChC,eAAe,EAAE,eAAe,CAAA;IAChC,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,YAAY,EAAE,YAAY,CAAA;IAC1B,SAAS,EAAE,SAAS,CAAA;CACvB,CAAA;AAED,iBAAS,eAAe,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;;;;EAgBxC;AAED,eAAe,eAAe,CAAA"}
|
|
@@ -5,15 +5,16 @@ function buildController(methods) {
|
|
|
5
5
|
status: methods.status,
|
|
6
6
|
connect: methods.connect,
|
|
7
7
|
disconnect: methods.disconnect,
|
|
8
|
-
|
|
9
|
-
prepareReturn: methods.prepareReturn,
|
|
8
|
+
getActiveNetwork: methods.getActiveNetwork,
|
|
10
9
|
prepareExecute: methods.prepareExecute,
|
|
10
|
+
signMessage: methods.signMessage,
|
|
11
11
|
ledgerApi: methods.ledgerApi,
|
|
12
|
-
|
|
12
|
+
connected: methods.connected,
|
|
13
13
|
onStatusChanged: methods.onStatusChanged,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
accountsChanged: methods.accountsChanged,
|
|
15
|
+
getPrimaryAccount: methods.getPrimaryAccount,
|
|
16
|
+
listAccounts: methods.listAccounts,
|
|
17
|
+
txChanged: methods.txChanged,
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
export default buildController;
|