zetrix-connect-wallet-sdk-test 1.0.2 → 1.0.3
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/lib/index.js +63 -13
- package/package.json +1 -1
package/lib/index.js
CHANGED
@@ -209,31 +209,81 @@ class ZetrixWalletConnect {
|
|
209
209
|
return this.zetrixWebView.authAndSignMessage(param)
|
210
210
|
} else {
|
211
211
|
return new Promise((resolve, reject) => {
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
212
|
+
let obj = {
|
213
|
+
linkTo: 'H5_' + sdkType.bindAndSignMessage,
|
214
|
+
type: 'H5_' + sdkType.bindAndSignMessage,
|
215
|
+
host: getWindowUrl(),
|
216
|
+
icon: getWindowICO(),
|
217
|
+
sessionId: createSessionId(),
|
218
|
+
source: isMobile() ? typeInfo.mobileSource : '',
|
219
|
+
message: param.message
|
220
|
+
}
|
221
|
+
|
222
|
+
this.walletSocket.h5Bind({
|
223
|
+
type: obj.type,
|
224
|
+
sessionId: obj.sessionId,
|
225
|
+
source: obj.source
|
226
|
+
}).then(res => {
|
227
|
+
closeQr()
|
228
|
+
if (res.code === 0) {
|
229
|
+
setAuthData(res.sessionId, res.data.address)
|
230
|
+
} else {
|
231
|
+
reject({
|
232
|
+
code: res.code,
|
233
|
+
message: res.message
|
234
|
+
})
|
224
235
|
}
|
236
|
+
|
225
237
|
this.signMessage(param).then(signRes => {
|
226
238
|
resolve({
|
227
239
|
code: 0,
|
228
240
|
data: {
|
241
|
+
sessionId: res.sessionId,
|
229
242
|
address: signRes.data.address,
|
230
243
|
publicKey: signRes.data.publicKey,
|
231
244
|
signData: signRes.data.signData
|
232
245
|
}
|
233
246
|
})
|
234
247
|
}).catch(signError => {
|
235
|
-
reject(
|
248
|
+
reject({
|
249
|
+
code: signError.code,
|
250
|
+
message: signError.message
|
251
|
+
})
|
236
252
|
})
|
253
|
+
}).catch(error => {
|
254
|
+
closeQr()
|
255
|
+
reject({
|
256
|
+
code: errorCode,
|
257
|
+
message: systemErrorInfo.abnormalOperation
|
258
|
+
})
|
259
|
+
})
|
260
|
+
|
261
|
+
if (this.isQrcode) {
|
262
|
+
this.authQr(obj).then(res => {
|
263
|
+
resolve(res)
|
264
|
+
})
|
265
|
+
} else {
|
266
|
+
this.linkTo.createHostParam(obj)
|
267
|
+
}
|
268
|
+
})
|
269
|
+
}
|
270
|
+
|
271
|
+
//////////////////////////////////////////////////////////////////////////////////
|
272
|
+
return new Promise((resolve, reject) => {
|
273
|
+
this.auth().then(authRes => {
|
274
|
+
let urlObj = {
|
275
|
+
linkTo: 'H5_' + sdkType.bindAndSignMessage,
|
276
|
+
type: 'H5_' + sdkType.bindAndSignMessage,
|
277
|
+
sessionId: createSessionId(),
|
278
|
+
host: getWindowUrl(),
|
279
|
+
icon: getWindowICO(),
|
280
|
+
message: param.message
|
281
|
+
}
|
282
|
+
|
283
|
+
if (!this.isQrcode) {
|
284
|
+
this.linkTo.createHostParam(urlObj)
|
285
|
+
}
|
286
|
+
|
237
287
|
}).catch(authError => {
|
238
288
|
reject(authError)
|
239
289
|
})
|
package/package.json
CHANGED