@onekeyfe/onekey-cosmos-provider 2.2.61 → 2.2.63

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.
@@ -40,6 +40,10 @@ export type CosmosRequest = {
40
40
  'signEthereum': (chainId: string, signer: string, data: string | Uint8Array, type: EthSignType) => Promise<string>;
41
41
  'getChainInfosWithoutEndpoints': () => Promise<ChainInfoWithoutEndpoints[]>;
42
42
  'getChainInfoWithoutEndpoints': (chainId: string) => Promise<ChainInfoWithoutEndpoints>;
43
+ 'getEnigmaPubKey': (chainId: string) => Promise<string>;
44
+ 'enigmaEncrypt': (chainId: string, contractCodeHash: string, msg: object) => Promise<string>;
45
+ 'enigmaDecrypt': (chainId: string, ciphertext: string, nonce: string) => Promise<string>;
46
+ 'enigmaGetTxEncryptionKey': (chainId: string, nonce: string) => Promise<string>;
43
47
  };
44
48
  export type PROVIDER_EVENTS_STRINGS = keyof typeof PROVIDER_EVENTS;
45
49
  export interface IProviderCosmos {
@@ -69,6 +73,16 @@ export interface IProviderCosmos {
69
73
  getOfflineSignerOnlyAmino(chainId: string): OfflineAminoSigner;
70
74
  getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;
71
75
  getChainInfosWithoutEndpoints(): Promise<ChainInfoWithoutEndpoints[]>;
76
+ getEnigmaUtils(chainId: string): {
77
+ getPubkey: () => Promise<Uint8Array>;
78
+ encrypt: (contractCodeHash: string, msg: object) => Promise<Uint8Array>;
79
+ decrypt: (ciphertext: Uint8Array, nonce: Uint8Array) => Promise<Uint8Array>;
80
+ getTxEncryptionKey: (nonce: Uint8Array) => Promise<Uint8Array>;
81
+ };
82
+ getEnigmaPubKey(chainId: string): Promise<Uint8Array>;
83
+ enigmaEncrypt(chainId: string, contractCodeHash: string, msg: object): Promise<Uint8Array>;
84
+ enigmaDecrypt(chainId: string, ciphertext: Uint8Array, nonce: Uint8Array): Promise<Uint8Array>;
85
+ getEnigmaTxEncryptionKey(chainId: string, nonce: Uint8Array): Promise<Uint8Array>;
72
86
  }
73
87
  export type OneKeySuiProviderProps = IInpageProviderConfig & {
74
88
  timeout?: number;
@@ -118,5 +132,15 @@ declare class ProviderCosmos extends ProviderCosmosBase implements IProviderCosm
118
132
  getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;
119
133
  getChainInfosWithoutEndpoints(): Promise<ChainInfoWithoutEndpoints[]>;
120
134
  getChainInfoWithoutEndpoints(chainId: string): Promise<ChainInfoWithoutEndpoints>;
135
+ getEnigmaPubKey(chainId: string): Promise<Uint8Array>;
136
+ enigmaEncrypt(chainId: string, contractCodeHash: string, msg: object): Promise<Uint8Array>;
137
+ enigmaDecrypt(chainId: string, ciphertext: Uint8Array, nonce: Uint8Array): Promise<Uint8Array>;
138
+ getEnigmaTxEncryptionKey(chainId: string, nonce: Uint8Array): Promise<Uint8Array>;
139
+ getEnigmaUtils(chainId: string): {
140
+ getPubkey: () => Promise<Uint8Array>;
141
+ encrypt: (contractCodeHash: string, msg: object) => Promise<Uint8Array>;
142
+ decrypt: (ciphertext: Uint8Array, nonce: Uint8Array) => Promise<Uint8Array>;
143
+ getTxEncryptionKey: (nonce: Uint8Array) => Promise<Uint8Array>;
144
+ };
121
145
  }
122
146
  export { ProviderCosmos };
@@ -325,5 +325,65 @@ class ProviderCosmos extends ProviderCosmosBase {
325
325
  });
326
326
  });
327
327
  }
328
+ getEnigmaPubKey(chainId) {
329
+ return __awaiter(this, void 0, void 0, function* () {
330
+ const hex = yield this._callBridge({
331
+ method: 'getEnigmaPubKey',
332
+ // @ts-expect-error
333
+ params: { chainId },
334
+ });
335
+ return hexToBytes(hex);
336
+ });
337
+ }
338
+ enigmaEncrypt(chainId, contractCodeHash, msg) {
339
+ return __awaiter(this, void 0, void 0, function* () {
340
+ const hex = yield this._callBridge({
341
+ method: 'enigmaEncrypt',
342
+ // @ts-expect-error
343
+ params: { chainId, contractCodeHash, msg },
344
+ });
345
+ return hexToBytes(hex);
346
+ });
347
+ }
348
+ enigmaDecrypt(chainId, ciphertext, nonce) {
349
+ return __awaiter(this, void 0, void 0, function* () {
350
+ const hex = yield this._callBridge({
351
+ method: 'enigmaDecrypt',
352
+ // @ts-expect-error
353
+ params: {
354
+ chainId,
355
+ ciphertext: bytesToHex(ciphertext),
356
+ nonce: bytesToHex(nonce),
357
+ },
358
+ });
359
+ return hexToBytes(hex);
360
+ });
361
+ }
362
+ getEnigmaTxEncryptionKey(chainId, nonce) {
363
+ return __awaiter(this, void 0, void 0, function* () {
364
+ const hex = yield this._callBridge({
365
+ method: 'enigmaGetTxEncryptionKey',
366
+ // @ts-expect-error
367
+ params: { chainId, nonce: bytesToHex(nonce) },
368
+ });
369
+ return hexToBytes(hex);
370
+ });
371
+ }
372
+ getEnigmaUtils(chainId) {
373
+ return {
374
+ getPubkey: () => __awaiter(this, void 0, void 0, function* () {
375
+ return this.getEnigmaPubKey(chainId);
376
+ }),
377
+ encrypt: (contractCodeHash, msg) => __awaiter(this, void 0, void 0, function* () {
378
+ return this.enigmaEncrypt(chainId, contractCodeHash, msg);
379
+ }),
380
+ decrypt: (ciphertext, nonce) => __awaiter(this, void 0, void 0, function* () {
381
+ return this.enigmaDecrypt(chainId, ciphertext, nonce);
382
+ }),
383
+ getTxEncryptionKey: (nonce) => __awaiter(this, void 0, void 0, function* () {
384
+ return this.getEnigmaTxEncryptionKey(chainId, nonce);
385
+ }),
386
+ };
387
+ }
328
388
  }
329
389
  export { ProviderCosmos };
@@ -331,5 +331,65 @@ class ProviderCosmos extends ProviderCosmosBase_1.ProviderCosmosBase {
331
331
  });
332
332
  });
333
333
  }
334
+ getEnigmaPubKey(chainId) {
335
+ return __awaiter(this, void 0, void 0, function* () {
336
+ const hex = yield this._callBridge({
337
+ method: 'getEnigmaPubKey',
338
+ // @ts-expect-error
339
+ params: { chainId },
340
+ });
341
+ return (0, cross_inpage_provider_core_1.hexToBytes)(hex);
342
+ });
343
+ }
344
+ enigmaEncrypt(chainId, contractCodeHash, msg) {
345
+ return __awaiter(this, void 0, void 0, function* () {
346
+ const hex = yield this._callBridge({
347
+ method: 'enigmaEncrypt',
348
+ // @ts-expect-error
349
+ params: { chainId, contractCodeHash, msg },
350
+ });
351
+ return (0, cross_inpage_provider_core_1.hexToBytes)(hex);
352
+ });
353
+ }
354
+ enigmaDecrypt(chainId, ciphertext, nonce) {
355
+ return __awaiter(this, void 0, void 0, function* () {
356
+ const hex = yield this._callBridge({
357
+ method: 'enigmaDecrypt',
358
+ // @ts-expect-error
359
+ params: {
360
+ chainId,
361
+ ciphertext: (0, cross_inpage_provider_core_1.bytesToHex)(ciphertext),
362
+ nonce: (0, cross_inpage_provider_core_1.bytesToHex)(nonce),
363
+ },
364
+ });
365
+ return (0, cross_inpage_provider_core_1.hexToBytes)(hex);
366
+ });
367
+ }
368
+ getEnigmaTxEncryptionKey(chainId, nonce) {
369
+ return __awaiter(this, void 0, void 0, function* () {
370
+ const hex = yield this._callBridge({
371
+ method: 'enigmaGetTxEncryptionKey',
372
+ // @ts-expect-error
373
+ params: { chainId, nonce: (0, cross_inpage_provider_core_1.bytesToHex)(nonce) },
374
+ });
375
+ return (0, cross_inpage_provider_core_1.hexToBytes)(hex);
376
+ });
377
+ }
378
+ getEnigmaUtils(chainId) {
379
+ return {
380
+ getPubkey: () => __awaiter(this, void 0, void 0, function* () {
381
+ return this.getEnigmaPubKey(chainId);
382
+ }),
383
+ encrypt: (contractCodeHash, msg) => __awaiter(this, void 0, void 0, function* () {
384
+ return this.enigmaEncrypt(chainId, contractCodeHash, msg);
385
+ }),
386
+ decrypt: (ciphertext, nonce) => __awaiter(this, void 0, void 0, function* () {
387
+ return this.enigmaDecrypt(chainId, ciphertext, nonce);
388
+ }),
389
+ getTxEncryptionKey: (nonce) => __awaiter(this, void 0, void 0, function* () {
390
+ return this.getEnigmaTxEncryptionKey(chainId, nonce);
391
+ }),
392
+ };
393
+ }
334
394
  }
335
395
  exports.ProviderCosmos = ProviderCosmos;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onekeyfe/onekey-cosmos-provider",
3
- "version": "2.2.61",
3
+ "version": "2.2.63",
4
4
  "keywords": [
5
5
  "cross-inpage-provider"
6
6
  ],
@@ -27,10 +27,10 @@
27
27
  "start": "tsc --watch"
28
28
  },
29
29
  "dependencies": {
30
- "@onekeyfe/cross-inpage-provider-core": "2.2.61",
31
- "@onekeyfe/cross-inpage-provider-errors": "2.2.61",
32
- "@onekeyfe/cross-inpage-provider-types": "2.2.61",
33
- "@onekeyfe/extension-bridge-injected": "2.2.61",
30
+ "@onekeyfe/cross-inpage-provider-core": "2.2.63",
31
+ "@onekeyfe/cross-inpage-provider-errors": "2.2.63",
32
+ "@onekeyfe/cross-inpage-provider-types": "2.2.63",
33
+ "@onekeyfe/extension-bridge-injected": "2.2.63",
34
34
  "eth-rpc-errors": "^4.0.3",
35
35
  "lodash-es": "^4.17.21",
36
36
  "long": "^4.0.0",
@@ -40,5 +40,5 @@
40
40
  "@types/lodash-es": "^4.17.12",
41
41
  "@types/long": "^4.0.0"
42
42
  },
43
- "gitHead": "1e98fecc19bda6cea42ecd616f3e432749f6dd0d"
43
+ "gitHead": "321fff7491b90508f1adb921307e01539a867152"
44
44
  }