@console-wallet/dapp-sdk 2.0.3 → 2.1.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/CHANGELOG.md +34 -0
- package/README.md +2 -2
- package/dist/cjs/api/client.api.js +1 -1
- package/dist/cjs/api/client.api.js.map +1 -1
- package/dist/cjs/helpers/handleResponse.helper.js +0 -1
- package/dist/cjs/helpers/handleResponse.helper.js.map +1 -1
- package/dist/cjs/openapi.json +2284 -0
- package/dist/cjs/requests/connect.js +3 -8
- package/dist/cjs/requests/connect.js.map +1 -1
- package/dist/cjs/services/wc-service/wc-service.d.ts +29 -1
- package/dist/cjs/services/wc-service/wc-service.js +40 -9
- package/dist/cjs/services/wc-service/wc-service.js.map +1 -1
- package/dist/esm/api/client.api.js +1 -1
- package/dist/esm/api/client.api.js.map +1 -1
- package/dist/esm/helpers/handleResponse.helper.js +0 -1
- package/dist/esm/helpers/handleResponse.helper.js.map +1 -1
- package/dist/esm/openapi.json +2284 -0
- package/dist/esm/requests/connect.js +3 -8
- package/dist/esm/requests/connect.js.map +1 -1
- package/dist/esm/services/wc-service/wc-service.d.ts +29 -1
- package/dist/esm/services/wc-service/wc-service.js +40 -9
- package/dist/esm/services/wc-service/wc-service.js.map +1 -1
- package/package.json +4 -4
|
@@ -25,7 +25,6 @@ const browserFunction = async ({ name, icon }) => new Promise((resolve, reject)
|
|
|
25
25
|
if (isExpectedResponse(event, id, `${type}_RESPONSE`)) {
|
|
26
26
|
window.removeEventListener('message', handleResponse);
|
|
27
27
|
if (event.data.error) {
|
|
28
|
-
console.log('🚀 ~ file: connect.ts:37 ~ event.data.error:', event.data.error);
|
|
29
28
|
reject(event.data.error);
|
|
30
29
|
}
|
|
31
30
|
else {
|
|
@@ -49,7 +48,7 @@ const browserFunction = async ({ name, icon }) => new Promise((resolve, reject)
|
|
|
49
48
|
handleRequest();
|
|
50
49
|
});
|
|
51
50
|
});
|
|
52
|
-
const mobileFunction = async ({ name, icon, target = '
|
|
51
|
+
const mobileFunction = async ({ name, icon, target = 'local', }) => new Promise((resolve, reject) => {
|
|
53
52
|
const handleRequest = () => {
|
|
54
53
|
const id = crypto.randomUUID();
|
|
55
54
|
wcSessionService
|
|
@@ -65,10 +64,7 @@ const mobileFunction = async ({ name, icon, target = 'combined', }) => new Promi
|
|
|
65
64
|
.then(() => {
|
|
66
65
|
handlePrepareWC();
|
|
67
66
|
wcSessionService.addSubscriber(id, (message) => {
|
|
68
|
-
console.log('🚀 ~ file: connect.ts:88 ~ response:', message);
|
|
69
67
|
const response = JSON.parse(message.serializedPayload);
|
|
70
|
-
console.log('🚀 ~ file: connect.ts:90 ~ response:', response);
|
|
71
|
-
console.log('🚀 ~ file: connect.ts:91 ~ isExpectedMobileResponse:', isExpectedMobileResponse(response, id, `${type}_RESPONSE`));
|
|
72
68
|
if (isExpectedMobileResponse(response, id, `${type}_RESPONSE`)) {
|
|
73
69
|
if (response.error) {
|
|
74
70
|
reject(response.error);
|
|
@@ -80,6 +76,7 @@ const mobileFunction = async ({ name, icon, target = 'combined', }) => new Promi
|
|
|
80
76
|
}
|
|
81
77
|
});
|
|
82
78
|
});
|
|
79
|
+
// TODO: add catch with request to extension if target === 'combined'
|
|
83
80
|
};
|
|
84
81
|
isConnected()
|
|
85
82
|
.then((isConnectedResponse) => {
|
|
@@ -106,10 +103,8 @@ const mobileFunction = async ({ name, icon, target = 'combined', }) => new Promi
|
|
|
106
103
|
* @example
|
|
107
104
|
* await connect({ name: 'Canton Demo', icon: 'https://example.com/icon.png' });
|
|
108
105
|
*/
|
|
109
|
-
export const connect = async ({ name, icon, target = '
|
|
106
|
+
export const connect = async ({ name, icon, target = 'local' }) => {
|
|
110
107
|
const deviceInfo = getDeviceInfo();
|
|
111
|
-
console.log('🚀 ~ file: connect.ts:130 ~ deviceInfo:', deviceInfo);
|
|
112
|
-
alert(JSON.stringify(deviceInfo));
|
|
113
108
|
if (target === 'local') {
|
|
114
109
|
await browserFunction({ name, icon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AAQ,EAAE;QACvB,OAAO,MAAM,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;KACrD;IAED,MAAM,oBAAoB,GAAG,MAAM,0BAA0B,EAAE,CAAC;IAEhE,IAAI,oBAAoB,CAAC,MAAM,KAAK,cAAc,IAAI,UAAU,CAAC,QAAQ,EAAE;QACzE,OAAO,MAAM,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;KACrD;SAAM;QACL,OAAO,MAAM,eAAe,CAAC;YAC3B,cAAc,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,cAAc,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;YACxE,eAAe,EAAE,KAAK,IAAI,EAAE,CAAC,MAAM,eAAe,CAAC,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;SAC3E,CAAC,CAAC;KACJ;AACH,CAAC,CAAC"}
|
|
@@ -10,10 +10,28 @@ declare class WcSessionService {
|
|
|
10
10
|
*/
|
|
11
11
|
get session(): string | null;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Initializes the session communication.
|
|
14
|
+
* Creates a new session, sends a connection request, and handles the UI for connecting
|
|
15
|
+
* (QR code for desktop, deep link for mobile).
|
|
16
|
+
*
|
|
17
|
+
* @param data - The connection request data.
|
|
18
|
+
* @returns The session ID.
|
|
14
19
|
*/
|
|
15
20
|
init(data: ConnectRequest & CommonDataFieldsRequest): Promise<string>;
|
|
21
|
+
/**
|
|
22
|
+
* Sends a message to the current session.
|
|
23
|
+
*
|
|
24
|
+
* @param serializedPayload - The serialized payload of the message.
|
|
25
|
+
* @param type - The type of the request (e.g., CONNECT, SIGN_MESSAGE).
|
|
26
|
+
* @param messageId - The unique ID of the message.
|
|
27
|
+
*/
|
|
16
28
|
sendMessage(serializedPayload: string, type: PUBLIC_REQUESTS, messageId: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Terminates a session by its ID.
|
|
31
|
+
* Closes the session on the server and clears it from local storage.
|
|
32
|
+
*
|
|
33
|
+
* @param id - The session ID to terminate.
|
|
34
|
+
*/
|
|
17
35
|
terminateSession(id: string): Promise<void>;
|
|
18
36
|
/**
|
|
19
37
|
* Initializes the service by loading the session from IndexedDB.
|
|
@@ -28,7 +46,17 @@ declare class WcSessionService {
|
|
|
28
46
|
* Clears the session from both memory and IndexedDB.
|
|
29
47
|
*/
|
|
30
48
|
clearSession(): Promise<void>;
|
|
49
|
+
/**
|
|
50
|
+
* Adds a subscriber to listen for messages.
|
|
51
|
+
*
|
|
52
|
+
* @param id - The message ID or trigger type to subscribe to.
|
|
53
|
+
* @param callback - The function to call when a message is received.
|
|
54
|
+
*/
|
|
31
55
|
addSubscriber(id: string, callback: (message: GetWebPayloadForMobileResponseDTO, id: string, type: string) => void): void;
|
|
56
|
+
/**
|
|
57
|
+
* Starts polling for new messages from the server.
|
|
58
|
+
* Uses a polling interval to fetch messages and notifies subscribers.
|
|
59
|
+
*/
|
|
32
60
|
startPolling(): void;
|
|
33
61
|
}
|
|
34
62
|
export declare const wcSessionService: WcSessionService;
|
|
@@ -7,6 +7,7 @@ import { api } from '../../api';
|
|
|
7
7
|
import { EIP_1474_ERROR, EIP_1474_ERROR_ENUM, PUBLIC_REQUESTS, } from '../../types';
|
|
8
8
|
import { getDeviceInfo } from '../../helpers/mobile-check.helper';
|
|
9
9
|
import { MOBILE_DEEP_LINK_CONNECT } from '../../constants';
|
|
10
|
+
const POLLING_INTERVAL = 5000;
|
|
10
11
|
class WcSessionService {
|
|
11
12
|
_session = null;
|
|
12
13
|
_subscribers = {};
|
|
@@ -19,7 +20,12 @@ class WcSessionService {
|
|
|
19
20
|
return this._session;
|
|
20
21
|
}
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* Initializes the session communication.
|
|
24
|
+
* Creates a new session, sends a connection request, and handles the UI for connecting
|
|
25
|
+
* (QR code for desktop, deep link for mobile).
|
|
26
|
+
*
|
|
27
|
+
* @param data - The connection request data.
|
|
28
|
+
* @returns The session ID.
|
|
23
29
|
*/
|
|
24
30
|
async init(data) {
|
|
25
31
|
const sessionRequest = await api.wc.qrSessionWebControllerCreateSdkSession();
|
|
@@ -31,7 +37,6 @@ class WcSessionService {
|
|
|
31
37
|
});
|
|
32
38
|
const { isMobile, isAndroid, isIOS } = getDeviceInfo();
|
|
33
39
|
if (isMobile && isAndroid) {
|
|
34
|
-
console.log(1);
|
|
35
40
|
await this.setSession(newSession);
|
|
36
41
|
await this.getStoredSession();
|
|
37
42
|
window.location.href = `${MOBILE_DEEP_LINK_CONNECT}${newSession}`;
|
|
@@ -88,6 +93,13 @@ class WcSessionService {
|
|
|
88
93
|
await this.getStoredSession();
|
|
89
94
|
return newSession;
|
|
90
95
|
}
|
|
96
|
+
/**
|
|
97
|
+
* Sends a message to the current session.
|
|
98
|
+
*
|
|
99
|
+
* @param serializedPayload - The serialized payload of the message.
|
|
100
|
+
* @param type - The type of the request (e.g., CONNECT, SIGN_MESSAGE).
|
|
101
|
+
* @param messageId - The unique ID of the message.
|
|
102
|
+
*/
|
|
91
103
|
async sendMessage(serializedPayload, type, messageId) {
|
|
92
104
|
await api.wc.qrSessionWebControllerCreateSessionMessage(this.session || '', {
|
|
93
105
|
method: type,
|
|
@@ -95,6 +107,12 @@ class WcSessionService {
|
|
|
95
107
|
serializedPayload,
|
|
96
108
|
});
|
|
97
109
|
}
|
|
110
|
+
/**
|
|
111
|
+
* Terminates a session by its ID.
|
|
112
|
+
* Closes the session on the server and clears it from local storage.
|
|
113
|
+
*
|
|
114
|
+
* @param id - The session ID to terminate.
|
|
115
|
+
*/
|
|
98
116
|
async terminateSession(id) {
|
|
99
117
|
try {
|
|
100
118
|
await api.wc.qrSessionWebControllerCloseSession(id);
|
|
@@ -108,6 +126,15 @@ class WcSessionService {
|
|
|
108
126
|
catch {
|
|
109
127
|
//
|
|
110
128
|
}
|
|
129
|
+
try {
|
|
130
|
+
if (this._interval !== null) {
|
|
131
|
+
clearInterval(this._interval);
|
|
132
|
+
this._interval = null;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
//
|
|
137
|
+
}
|
|
111
138
|
}
|
|
112
139
|
/**
|
|
113
140
|
* Initializes the service by loading the session from IndexedDB.
|
|
@@ -133,6 +160,12 @@ class WcSessionService {
|
|
|
133
160
|
this._session = null;
|
|
134
161
|
await removeWcSessionDbData(WC_SESSION_DB_KEYS.SESSION_ID);
|
|
135
162
|
}
|
|
163
|
+
/**
|
|
164
|
+
* Adds a subscriber to listen for messages.
|
|
165
|
+
*
|
|
166
|
+
* @param id - The message ID or trigger type to subscribe to.
|
|
167
|
+
* @param callback - The function to call when a message is received.
|
|
168
|
+
*/
|
|
136
169
|
addSubscriber(id, callback) {
|
|
137
170
|
if (id.endsWith('_TRIGGER')) {
|
|
138
171
|
this._triggerSubscribers[id] = [...(this._triggerSubscribers[id] || []), callback];
|
|
@@ -141,6 +174,10 @@ class WcSessionService {
|
|
|
141
174
|
this._subscribers[id] = callback;
|
|
142
175
|
}
|
|
143
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Starts polling for new messages from the server.
|
|
179
|
+
* Uses a polling interval to fetch messages and notifies subscribers.
|
|
180
|
+
*/
|
|
144
181
|
// TODO: change short polling to long polling or use websockets
|
|
145
182
|
startPolling() {
|
|
146
183
|
if (this._interval !== null) {
|
|
@@ -151,11 +188,9 @@ class WcSessionService {
|
|
|
151
188
|
const response = await api.wc.qrSessionWebControllerGetAllMessages(this.session || '');
|
|
152
189
|
const messages = response.messages;
|
|
153
190
|
messages.map((messageData) => {
|
|
154
|
-
console.log('🚀 ~ file: wc-service.ts:205 ~ messageData:', messageData, messageData.serializedPayload);
|
|
155
191
|
const message = JSON.parse(messageData.serializedPayload);
|
|
156
192
|
const isTriggered = messageData.method.endsWith('_TRIGGER');
|
|
157
193
|
const id = isTriggered ? messageData.method : message.id;
|
|
158
|
-
console.log('🚀 ~ file: wc-service.ts:217 ~ this._subscribers[id]:', this._subscribers[id], this._subscribers, id);
|
|
159
194
|
if (isTriggered) {
|
|
160
195
|
for (const trigger of this._triggerSubscribers[id] || []) {
|
|
161
196
|
trigger(messageData, id, messageData.method);
|
|
@@ -169,16 +204,12 @@ class WcSessionService {
|
|
|
169
204
|
});
|
|
170
205
|
}
|
|
171
206
|
catch (e) {
|
|
172
|
-
console.log('🚀 ~ file: wc-service.ts:228 ~ e:', e);
|
|
173
207
|
this.terminateSession(this.session || '');
|
|
174
|
-
if (this._interval !== null) {
|
|
175
|
-
clearInterval(this._interval);
|
|
176
|
-
}
|
|
177
208
|
}
|
|
178
209
|
};
|
|
179
210
|
//NOTE: to start polling immediately
|
|
180
211
|
request();
|
|
181
|
-
this._interval = setInterval(request,
|
|
212
|
+
this._interval = setInterval(request, POLLING_INTERVAL);
|
|
182
213
|
}
|
|
183
214
|
}
|
|
184
215
|
export const wcSessionService = new WcSessionService();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wc-service.js","sourceRoot":"","sources":["../../../../src/services/wc-service/wc-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,UAAU,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAGL,cAAc,EACd,mBAAmB,EACnB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,gBAAgB;IACZ,QAAQ,GAAkB,IAAI,CAAC;IAC/B,YAAY,GAEhB,EAAE,CAAC;IACC,mBAAmB,GAMvB,EAAE,CAAC;IACC,SAAS,GAAkB,IAAI,CAAC;IAExC;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED
|
|
1
|
+
{"version":3,"file":"wc-service.js","sourceRoot":"","sources":["../../../../src/services/wc-service/wc-service.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,SAAS,MAAM,8BAA8B,CAAC;AACrD,OAAO,UAAU,MAAM,mCAAmC,CAAC;AAC3D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAChC,OAAO,EAGL,cAAc,EACd,mBAAmB,EACnB,eAAe,GAChB,MAAM,aAAa,CAAC;AAErB,OAAO,EAAE,aAAa,EAAE,MAAM,mCAAmC,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,gBAAgB,GAAG,IAAI,CAAC;AAE9B,MAAM,gBAAgB;IACZ,QAAQ,GAAkB,IAAI,CAAC;IAC/B,YAAY,GAEhB,EAAE,CAAC;IACC,mBAAmB,GAMvB,EAAE,CAAC;IACC,SAAS,GAAkB,IAAI,CAAC;IAExC;;OAEG;IACH,IAAI,OAAO;QACT,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,IAAI,CAAC,IAA8C;QACvD,MAAM,cAAc,GAAG,MAAM,GAAG,CAAC,EAAE,CAAC,sCAAsC,EAAE,CAAC;QAE7E,MAAM,UAAU,GAAG,cAAc,CAAC,SAAS,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4
|
"description": "",
|
|
5
5
|
"main": "./dist/cjs/index.js",
|
|
6
6
|
"module": "./dist/esm/index.js",
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
},
|
|
14
14
|
"scripts": {
|
|
15
15
|
"audit": "audit-ci --config .audit-ci.json",
|
|
16
|
-
"build": "yarn build:esm && yarn build:cjs && yarn copy:assets",
|
|
16
|
+
"build": "yarn build:esm && yarn build:cjs && yarn copy:assets && yarn generate:openapi && yarn copy:openapi",
|
|
17
17
|
"build:esm": "tsc",
|
|
18
18
|
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
|
|
19
19
|
"copy:assets": "cp src/styles.css dist/esm/styles.css && cp src/styles.css dist/cjs/styles.css && cp -R src/assets dist/esm/assets && cp -R src/assets dist/cjs/assets",
|
|
20
|
+
"copy:openapi": "cp openapi.json dist/esm/openapi.json && cp openapi.json dist/cjs/openapi.json",
|
|
20
21
|
"watch": "npm-run-all -p watch:esm watch:cjs",
|
|
21
22
|
"watch:esm": "tsc -w",
|
|
22
23
|
"watch:cjs": "tsc --module commonjs --outDir dist/cjs -w",
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"prettier": "prettier --write \"{src,tests,example/src}/**/*.{js,ts,jsx,tsx}\"",
|
|
25
26
|
"prepare": "npm run build",
|
|
26
27
|
"prepublishOnly": "npm run prettier && npm run lint",
|
|
28
|
+
"generate:openapi": "npx ts-json-schema-generator --path 'src/types/index.ts' --type '*' --out 'schemas.json' && node generate-openapi.js",
|
|
27
29
|
"api-indexer:codegen": "swagger-typescript-api generate --unwrap-response-data --sort-types --sort-routes --axios -p https://devnet.ccview.io/api/v1/api-docs/openapi.json -o ./src/api -n generated-indexer-api.ts --api-class-name IndexerApi",
|
|
28
30
|
"api-wallet:codegen": "swagger-typescript-api generate --unwrap-response-data --sort-types --sort-routes --axios -p https://869-wallet-extension.dev.pixelplexlabs.com/api/v1/api-openapi.json -o ./src/api -n generated-wallet-api.ts --api-class-name WalletApi",
|
|
29
31
|
"api-wc:codegen": "swagger-typescript-api generate --unwrap-response-data --sort-types --sort-routes --axios -p https://869-wallet-extension.dev.pixelplexlabs.com/qr-api/v1/qr-openapi.json -o ./src/api -n generated-wc-api.ts --api-class-name WCApi"
|
|
@@ -42,8 +44,6 @@
|
|
|
42
44
|
"eslint-plugin-react": "^7.33.2",
|
|
43
45
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
44
46
|
"prettier": "^3.0.3",
|
|
45
|
-
"react": "^18.1.0",
|
|
46
|
-
"react-dom": "^18.2.0",
|
|
47
47
|
"typescript": "^4.7.3"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|