@onekeyfe/onekey-cosmos-provider 2.2.23 → 2.2.25
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.
|
@@ -106,7 +106,9 @@ declare class ProviderCosmos extends ProviderCosmosBase implements IProviderCosm
|
|
|
106
106
|
chainId?: string | null | undefined;
|
|
107
107
|
/** SignDoc accountNumber */
|
|
108
108
|
accountNumber?: Long | null | undefined;
|
|
109
|
-
}, signOptions?: KeplrSignOptions | undefined
|
|
109
|
+
}, signOptions?: KeplrSignOptions | undefined, customOptions?: {
|
|
110
|
+
typeLongToString?: boolean;
|
|
111
|
+
}): Promise<DirectSignResponse>;
|
|
110
112
|
sendTx(chainId: string, tx: Uint8Array, mode: BroadcastMode): Promise<Uint8Array>;
|
|
111
113
|
signArbitrary(chainId: string, signer: string, data: string | Uint8Array): Promise<StdSignature>;
|
|
112
114
|
verifyArbitrary(chainId: string, signer: string, data: string | Uint8Array, signature: StdSignature): Promise<boolean>;
|
|
@@ -12,8 +12,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
12
12
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
13
13
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
14
14
|
/* eslint-disable tsdoc/syntax */
|
|
15
|
-
import { bytesToHex, hexToBytes } from '@
|
|
16
|
-
import { checkWalletSwitchEnable } from '@onekeyfe/cross-inpage-provider-core';
|
|
15
|
+
import { bytesToHex, hexToBytes, checkWalletSwitchEnable } from '@onekeyfe/cross-inpage-provider-core';
|
|
17
16
|
import { getOrCreateExtInjectedJsBridge } from '@onekeyfe/extension-bridge-injected';
|
|
18
17
|
import { ProviderCosmosBase } from './ProviderCosmosBase';
|
|
19
18
|
// @ts-ignore
|
|
@@ -58,11 +57,14 @@ class ProviderCosmos extends ProviderCosmosBase {
|
|
|
58
57
|
const data = e.data;
|
|
59
58
|
if (!checkWalletSwitchEnable())
|
|
60
59
|
return;
|
|
61
|
-
|
|
60
|
+
const hasHandle = data && data.type && data.type.startsWith('proxy-request') && data.type !== 'proxy-request-response';
|
|
61
|
+
if (data && hasHandle && data.method) {
|
|
62
62
|
const method = data.method;
|
|
63
63
|
if (this[method]) {
|
|
64
64
|
const unwrapedArgs = JSONUint8Array.unwrap(data.args);
|
|
65
|
-
this[method](...unwrapedArgs
|
|
65
|
+
this[method](...unwrapedArgs, {
|
|
66
|
+
typeLongToString: true,
|
|
67
|
+
}).then((res) => {
|
|
66
68
|
window.postMessage({
|
|
67
69
|
type: 'proxy-request-response',
|
|
68
70
|
id: data.id,
|
|
@@ -210,9 +212,9 @@ class ProviderCosmos extends ProviderCosmosBase {
|
|
|
210
212
|
},
|
|
211
213
|
});
|
|
212
214
|
}
|
|
213
|
-
signDirect(chainId, signer, signDoc, signOptions) {
|
|
215
|
+
signDirect(chainId, signer, signDoc, signOptions, customOptions) {
|
|
214
216
|
return __awaiter(this, void 0, void 0, function* () {
|
|
215
|
-
var _a;
|
|
217
|
+
var _a, _b;
|
|
216
218
|
const res = yield this._callBridge({
|
|
217
219
|
method: 'signDirect',
|
|
218
220
|
// @ts-expect-error
|
|
@@ -234,7 +236,7 @@ class ProviderCosmos extends ProviderCosmosBase {
|
|
|
234
236
|
// @ts-expect-error
|
|
235
237
|
authInfoBytes: hexToBytes(res.signed.authInfoBytes),
|
|
236
238
|
// @ts-ignore
|
|
237
|
-
accountNumber: Long.fromString(res.signed.accountNumber),
|
|
239
|
+
accountNumber: (customOptions === null || customOptions === void 0 ? void 0 : customOptions.typeLongToString) ? (_b = res.signed.accountNumber) === null || _b === void 0 ? void 0 : _b.toString() : Long.fromString(res.signed.accountNumber),
|
|
238
240
|
chainId: res.signed.chainId,
|
|
239
241
|
} });
|
|
240
242
|
});
|
|
@@ -18,7 +18,6 @@ exports.ProviderCosmos = void 0;
|
|
|
18
18
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
19
19
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
20
20
|
/* eslint-disable tsdoc/syntax */
|
|
21
|
-
const utils_1 = require("@noble/hashes/utils");
|
|
22
21
|
const cross_inpage_provider_core_1 = require("@onekeyfe/cross-inpage-provider-core");
|
|
23
22
|
const extension_bridge_injected_1 = require("@onekeyfe/extension-bridge-injected");
|
|
24
23
|
const ProviderCosmosBase_1 = require("./ProviderCosmosBase");
|
|
@@ -64,11 +63,14 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
64
63
|
const data = e.data;
|
|
65
64
|
if (!(0, cross_inpage_provider_core_1.checkWalletSwitchEnable)())
|
|
66
65
|
return;
|
|
67
|
-
|
|
66
|
+
const hasHandle = data && data.type && data.type.startsWith('proxy-request') && data.type !== 'proxy-request-response';
|
|
67
|
+
if (data && hasHandle && data.method) {
|
|
68
68
|
const method = data.method;
|
|
69
69
|
if (this[method]) {
|
|
70
70
|
const unwrapedArgs = uint8_array_1.JSONUint8Array.unwrap(data.args);
|
|
71
|
-
this[method](...unwrapedArgs
|
|
71
|
+
this[method](...unwrapedArgs, {
|
|
72
|
+
typeLongToString: true,
|
|
73
|
+
}).then((res) => {
|
|
72
74
|
window.postMessage({
|
|
73
75
|
type: 'proxy-request-response',
|
|
74
76
|
id: data.id,
|
|
@@ -169,9 +171,9 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
169
171
|
});
|
|
170
172
|
return Object.assign(Object.assign({}, key), {
|
|
171
173
|
// @ts-expect-error
|
|
172
|
-
pubKey: (0,
|
|
174
|
+
pubKey: (0, cross_inpage_provider_core_1.hexToBytes)(key.pubKey),
|
|
173
175
|
// @ts-expect-error
|
|
174
|
-
address: (0,
|
|
176
|
+
address: (0, cross_inpage_provider_core_1.hexToBytes)(key.address) });
|
|
175
177
|
});
|
|
176
178
|
}
|
|
177
179
|
disconnect() {
|
|
@@ -189,9 +191,9 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
189
191
|
});
|
|
190
192
|
return Object.assign(Object.assign({}, key), {
|
|
191
193
|
// @ts-expect-error
|
|
192
|
-
pubKey: (0,
|
|
194
|
+
pubKey: (0, cross_inpage_provider_core_1.hexToBytes)(key.pubKey),
|
|
193
195
|
// @ts-expect-error
|
|
194
|
-
address: (0,
|
|
196
|
+
address: (0, cross_inpage_provider_core_1.hexToBytes)(key.address) });
|
|
195
197
|
});
|
|
196
198
|
}
|
|
197
199
|
ping() {
|
|
@@ -216,9 +218,9 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
216
218
|
},
|
|
217
219
|
});
|
|
218
220
|
}
|
|
219
|
-
signDirect(chainId, signer, signDoc, signOptions) {
|
|
221
|
+
signDirect(chainId, signer, signDoc, signOptions, customOptions) {
|
|
220
222
|
return __awaiter(this, void 0, void 0, function* () {
|
|
221
|
-
var _a;
|
|
223
|
+
var _a, _b;
|
|
222
224
|
const res = yield this._callBridge({
|
|
223
225
|
method: 'signDirect',
|
|
224
226
|
// @ts-expect-error
|
|
@@ -226,8 +228,8 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
226
228
|
chainId,
|
|
227
229
|
signer,
|
|
228
230
|
signDoc: {
|
|
229
|
-
bodyBytes: (signDoc === null || signDoc === void 0 ? void 0 : signDoc.bodyBytes) ? (0,
|
|
230
|
-
authInfoBytes: (signDoc === null || signDoc === void 0 ? void 0 : signDoc.authInfoBytes) ? (0,
|
|
231
|
+
bodyBytes: (signDoc === null || signDoc === void 0 ? void 0 : signDoc.bodyBytes) ? (0, cross_inpage_provider_core_1.bytesToHex)(signDoc === null || signDoc === void 0 ? void 0 : signDoc.bodyBytes) : null,
|
|
232
|
+
authInfoBytes: (signDoc === null || signDoc === void 0 ? void 0 : signDoc.authInfoBytes) ? (0, cross_inpage_provider_core_1.bytesToHex)(signDoc === null || signDoc === void 0 ? void 0 : signDoc.authInfoBytes) : null,
|
|
231
233
|
chainId: signDoc.chainId,
|
|
232
234
|
accountNumber: (_a = signDoc === null || signDoc === void 0 ? void 0 : signDoc.accountNumber) === null || _a === void 0 ? void 0 : _a.toString(),
|
|
233
235
|
},
|
|
@@ -236,11 +238,11 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
236
238
|
});
|
|
237
239
|
return Object.assign(Object.assign({}, res), { signed: {
|
|
238
240
|
// @ts-expect-error
|
|
239
|
-
bodyBytes: (0,
|
|
241
|
+
bodyBytes: (0, cross_inpage_provider_core_1.hexToBytes)(res.signed.bodyBytes),
|
|
240
242
|
// @ts-expect-error
|
|
241
|
-
authInfoBytes: (0,
|
|
243
|
+
authInfoBytes: (0, cross_inpage_provider_core_1.hexToBytes)(res.signed.authInfoBytes),
|
|
242
244
|
// @ts-ignore
|
|
243
|
-
accountNumber: long_1.default.fromString(res.signed.accountNumber),
|
|
245
|
+
accountNumber: (customOptions === null || customOptions === void 0 ? void 0 : customOptions.typeLongToString) ? (_b = res.signed.accountNumber) === null || _b === void 0 ? void 0 : _b.toString() : long_1.default.fromString(res.signed.accountNumber),
|
|
244
246
|
chainId: res.signed.chainId,
|
|
245
247
|
} });
|
|
246
248
|
});
|
|
@@ -252,15 +254,15 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
252
254
|
// @ts-expect-error
|
|
253
255
|
params: {
|
|
254
256
|
chainId,
|
|
255
|
-
tx: (0,
|
|
257
|
+
tx: (0, cross_inpage_provider_core_1.bytesToHex)(tx),
|
|
256
258
|
mode,
|
|
257
259
|
},
|
|
258
260
|
});
|
|
259
|
-
return (0,
|
|
261
|
+
return (0, cross_inpage_provider_core_1.hexToBytes)(res);
|
|
260
262
|
});
|
|
261
263
|
}
|
|
262
264
|
signArbitrary(chainId, signer, data) {
|
|
263
|
-
const newData = typeof data === 'string' ? data : (0,
|
|
265
|
+
const newData = typeof data === 'string' ? data : (0, cross_inpage_provider_core_1.bytesToHex)(data);
|
|
264
266
|
return this._callBridge({
|
|
265
267
|
method: 'signArbitrary',
|
|
266
268
|
// @ts-expect-error
|
|
@@ -278,7 +280,7 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
278
280
|
params: {
|
|
279
281
|
chainId,
|
|
280
282
|
signer,
|
|
281
|
-
data: typeof data === 'string' ? data : (0,
|
|
283
|
+
data: typeof data === 'string' ? data : (0, cross_inpage_provider_core_1.bytesToHex)(data),
|
|
282
284
|
signature,
|
|
283
285
|
},
|
|
284
286
|
});
|
|
@@ -291,11 +293,11 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
|
|
|
291
293
|
params: {
|
|
292
294
|
chainId,
|
|
293
295
|
signer,
|
|
294
|
-
data: typeof data === 'string' ? data : (0,
|
|
296
|
+
data: typeof data === 'string' ? data : (0, cross_inpage_provider_core_1.bytesToHex)(data),
|
|
295
297
|
type,
|
|
296
298
|
},
|
|
297
299
|
});
|
|
298
|
-
return (0,
|
|
300
|
+
return (0, cross_inpage_provider_core_1.hexToBytes)(res);
|
|
299
301
|
});
|
|
300
302
|
}
|
|
301
303
|
getOfflineSigner(chainId) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onekeyfe/onekey-cosmos-provider",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.25",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"cross-inpage-provider"
|
|
6
6
|
],
|
|
@@ -28,11 +28,10 @@
|
|
|
28
28
|
"start": "tsc --watch"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@
|
|
32
|
-
"@onekeyfe/cross-inpage-provider-
|
|
33
|
-
"@onekeyfe/cross-inpage-provider-
|
|
34
|
-
"@onekeyfe/
|
|
35
|
-
"@onekeyfe/extension-bridge-injected": "2.2.23",
|
|
31
|
+
"@onekeyfe/cross-inpage-provider-core": "2.2.25",
|
|
32
|
+
"@onekeyfe/cross-inpage-provider-errors": "2.2.25",
|
|
33
|
+
"@onekeyfe/cross-inpage-provider-types": "2.2.25",
|
|
34
|
+
"@onekeyfe/extension-bridge-injected": "2.2.25",
|
|
36
35
|
"eth-rpc-errors": "^4.0.3",
|
|
37
36
|
"lodash-es": "^4.17.21",
|
|
38
37
|
"long": "^4.0.0",
|
|
@@ -42,5 +41,5 @@
|
|
|
42
41
|
"@types/lodash-es": "^4.17.12",
|
|
43
42
|
"@types/long": "^4.0.0"
|
|
44
43
|
},
|
|
45
|
-
"gitHead": "
|
|
44
|
+
"gitHead": "b03afba95cb83e01062a2da65cdfdfb11a7a4dd1"
|
|
46
45
|
}
|