zetrix-connect-wallet-sdk-test 1.0.1 → 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 -14
- package/package.json +1 -1
package/lib/index.js
CHANGED
@@ -209,35 +209,84 @@ class ZetrixWalletConnect {
|
|
209
209
|
return this.zetrixWebView.authAndSignMessage(param)
|
210
210
|
} else {
|
211
211
|
return new Promise((resolve, reject) => {
|
212
|
-
|
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
|
+
})
|
235
|
+
}
|
236
|
+
|
213
237
|
this.signMessage(param).then(signRes => {
|
214
238
|
resolve({
|
215
239
|
code: 0,
|
216
240
|
data: {
|
241
|
+
sessionId: res.sessionId,
|
217
242
|
address: signRes.data.address,
|
218
243
|
publicKey: signRes.data.publicKey,
|
219
244
|
signData: signRes.data.signData
|
220
245
|
}
|
221
246
|
})
|
222
247
|
}).catch(signError => {
|
223
|
-
reject(
|
248
|
+
reject({
|
249
|
+
code: signError.code,
|
250
|
+
message: signError.message
|
251
|
+
})
|
252
|
+
})
|
253
|
+
}).catch(error => {
|
254
|
+
closeQr()
|
255
|
+
reject({
|
256
|
+
code: errorCode,
|
257
|
+
message: systemErrorInfo.abnormalOperation
|
224
258
|
})
|
225
|
-
}).catch(authError => {
|
226
|
-
reject(authError)
|
227
259
|
})
|
228
260
|
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
235
|
-
message: param.message
|
261
|
+
if (this.isQrcode) {
|
262
|
+
this.authQr(obj).then(res => {
|
263
|
+
resolve(res)
|
264
|
+
})
|
265
|
+
} else {
|
266
|
+
this.linkTo.createHostParam(obj)
|
236
267
|
}
|
268
|
+
})
|
269
|
+
}
|
237
270
|
|
238
|
-
|
239
|
-
|
240
|
-
|
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
|
+
|
287
|
+
}).catch(authError => {
|
288
|
+
reject(authError)
|
289
|
+
})
|
241
290
|
})
|
242
291
|
}
|
243
292
|
}
|
package/package.json
CHANGED