@keplr-wallet/provider 0.9.4-rc.0 → 0.9.9-rc.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.
@@ -0,0 +1,133 @@
1
+ import { Message } from "@keplr-wallet/router";
2
+ import { ChainInfo, KeplrSignOptions, Key } from "@keplr-wallet/types";
3
+ import { AminoSignResponse, StdSignature, StdSignDoc } from "@cosmjs/launchpad";
4
+ export declare class EnableAccessMsg extends Message<void> {
5
+ readonly chainIds: string[];
6
+ static type(): string;
7
+ constructor(chainIds: string[]);
8
+ validateBasic(): void;
9
+ route(): string;
10
+ type(): string;
11
+ }
12
+ export declare class GetKeyMsg extends Message<Key> {
13
+ readonly chainId: string;
14
+ static type(): string;
15
+ constructor(chainId: string);
16
+ validateBasic(): void;
17
+ route(): string;
18
+ type(): string;
19
+ }
20
+ export declare class SuggestChainInfoMsg extends Message<void> {
21
+ readonly chainInfo: ChainInfo;
22
+ static type(): string;
23
+ constructor(chainInfo: ChainInfo);
24
+ validateBasic(): void;
25
+ route(): string;
26
+ type(): string;
27
+ }
28
+ export declare class SuggestTokenMsg extends Message<void> {
29
+ readonly chainId: string;
30
+ readonly contractAddress: string;
31
+ readonly viewingKey?: string | undefined;
32
+ static type(): string;
33
+ constructor(chainId: string, contractAddress: string, viewingKey?: string | undefined);
34
+ validateBasic(): void;
35
+ route(): string;
36
+ type(): string;
37
+ }
38
+ export declare class SendTxMsg extends Message<Uint8Array> {
39
+ readonly chainId: string;
40
+ readonly tx: unknown;
41
+ readonly mode: "async" | "sync" | "block";
42
+ static type(): string;
43
+ constructor(chainId: string, tx: unknown, mode: "async" | "sync" | "block");
44
+ validateBasic(): void;
45
+ route(): string;
46
+ type(): string;
47
+ }
48
+ export declare class GetSecret20ViewingKey extends Message<string> {
49
+ readonly chainId: string;
50
+ readonly contractAddress: string;
51
+ static type(): string;
52
+ constructor(chainId: string, contractAddress: string);
53
+ validateBasic(): void;
54
+ route(): string;
55
+ type(): string;
56
+ }
57
+ export declare class RequestSignAminoMsg extends Message<AminoSignResponse> {
58
+ readonly chainId: string;
59
+ readonly signer: string;
60
+ readonly signDoc: StdSignDoc;
61
+ readonly signOptions: KeplrSignOptions;
62
+ static type(): string;
63
+ constructor(chainId: string, signer: string, signDoc: StdSignDoc, signOptions?: KeplrSignOptions);
64
+ validateBasic(): void;
65
+ route(): string;
66
+ type(): string;
67
+ }
68
+ export declare class RequestSignDirectMsg extends Message<{
69
+ readonly signed: {
70
+ bodyBytes: Uint8Array;
71
+ authInfoBytes: Uint8Array;
72
+ chainId: string;
73
+ accountNumber: string;
74
+ };
75
+ readonly signature: StdSignature;
76
+ }> {
77
+ readonly chainId: string;
78
+ readonly signer: string;
79
+ readonly signDoc: {
80
+ bodyBytes?: Uint8Array | null;
81
+ authInfoBytes?: Uint8Array | null;
82
+ chainId?: string | null;
83
+ accountNumber?: string | null;
84
+ };
85
+ readonly signOptions: KeplrSignOptions;
86
+ static type(): string;
87
+ constructor(chainId: string, signer: string, signDoc: {
88
+ bodyBytes?: Uint8Array | null;
89
+ authInfoBytes?: Uint8Array | null;
90
+ chainId?: string | null;
91
+ accountNumber?: string | null;
92
+ }, signOptions?: KeplrSignOptions);
93
+ validateBasic(): void;
94
+ route(): string;
95
+ type(): string;
96
+ }
97
+ export declare class GetPubkeyMsg extends Message<Uint8Array> {
98
+ readonly chainId: string;
99
+ static type(): string;
100
+ constructor(chainId: string);
101
+ validateBasic(): void;
102
+ route(): string;
103
+ type(): string;
104
+ }
105
+ export declare class ReqeustEncryptMsg extends Message<Uint8Array> {
106
+ readonly chainId: string;
107
+ readonly contractCodeHash: string;
108
+ readonly msg: object;
109
+ static type(): string;
110
+ constructor(chainId: string, contractCodeHash: string, msg: object);
111
+ validateBasic(): void;
112
+ route(): string;
113
+ type(): string;
114
+ }
115
+ export declare class RequestDecryptMsg extends Message<Uint8Array> {
116
+ readonly chainId: string;
117
+ readonly cipherText: Uint8Array;
118
+ readonly nonce: Uint8Array;
119
+ static type(): string;
120
+ constructor(chainId: string, cipherText: Uint8Array, nonce: Uint8Array);
121
+ validateBasic(): void;
122
+ route(): string;
123
+ type(): string;
124
+ }
125
+ export declare class GetTxEncryptionKeyMsg extends Message<Uint8Array> {
126
+ readonly chainId: string;
127
+ readonly nonce: Uint8Array;
128
+ static type(): string;
129
+ constructor(chainId: string, nonce: Uint8Array);
130
+ validateBasic(): void;
131
+ route(): string;
132
+ type(): string;
133
+ }
@@ -0,0 +1,340 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetTxEncryptionKeyMsg = exports.RequestDecryptMsg = exports.ReqeustEncryptMsg = exports.GetPubkeyMsg = exports.RequestSignDirectMsg = exports.RequestSignAminoMsg = exports.GetSecret20ViewingKey = exports.SendTxMsg = exports.SuggestTokenMsg = exports.SuggestChainInfoMsg = exports.GetKeyMsg = exports.EnableAccessMsg = void 0;
4
+ const router_1 = require("@keplr-wallet/router");
5
+ class EnableAccessMsg extends router_1.Message {
6
+ constructor(chainIds) {
7
+ super();
8
+ this.chainIds = chainIds;
9
+ }
10
+ static type() {
11
+ return "enable-access";
12
+ }
13
+ validateBasic() {
14
+ if (!this.chainIds || this.chainIds.length === 0) {
15
+ throw new Error("chain id not set");
16
+ }
17
+ }
18
+ route() {
19
+ return "permission";
20
+ }
21
+ type() {
22
+ return EnableAccessMsg.type();
23
+ }
24
+ }
25
+ exports.EnableAccessMsg = EnableAccessMsg;
26
+ class GetKeyMsg extends router_1.Message {
27
+ constructor(chainId) {
28
+ super();
29
+ this.chainId = chainId;
30
+ }
31
+ static type() {
32
+ return "get-key";
33
+ }
34
+ validateBasic() {
35
+ if (!this.chainId) {
36
+ throw new Error("chain id not set");
37
+ }
38
+ }
39
+ route() {
40
+ return "keyring";
41
+ }
42
+ type() {
43
+ return GetKeyMsg.type();
44
+ }
45
+ }
46
+ exports.GetKeyMsg = GetKeyMsg;
47
+ class SuggestChainInfoMsg extends router_1.Message {
48
+ constructor(chainInfo) {
49
+ super();
50
+ this.chainInfo = chainInfo;
51
+ }
52
+ static type() {
53
+ return "suggest-chain-info";
54
+ }
55
+ validateBasic() {
56
+ if (!this.chainInfo) {
57
+ throw new Error("chain info not set");
58
+ }
59
+ }
60
+ route() {
61
+ return "chains";
62
+ }
63
+ type() {
64
+ return SuggestChainInfoMsg.type();
65
+ }
66
+ }
67
+ exports.SuggestChainInfoMsg = SuggestChainInfoMsg;
68
+ class SuggestTokenMsg extends router_1.Message {
69
+ constructor(chainId, contractAddress, viewingKey) {
70
+ super();
71
+ this.chainId = chainId;
72
+ this.contractAddress = contractAddress;
73
+ this.viewingKey = viewingKey;
74
+ }
75
+ static type() {
76
+ return "suggest-token";
77
+ }
78
+ validateBasic() {
79
+ if (!this.chainId) {
80
+ throw new Error("Chain id is empty");
81
+ }
82
+ if (!this.contractAddress) {
83
+ throw new Error("Contract address is empty");
84
+ }
85
+ }
86
+ route() {
87
+ return "tokens";
88
+ }
89
+ type() {
90
+ return SuggestTokenMsg.type();
91
+ }
92
+ }
93
+ exports.SuggestTokenMsg = SuggestTokenMsg;
94
+ // Return the tx hash
95
+ class SendTxMsg extends router_1.Message {
96
+ constructor(chainId, tx, mode) {
97
+ super();
98
+ this.chainId = chainId;
99
+ this.tx = tx;
100
+ this.mode = mode;
101
+ }
102
+ static type() {
103
+ return "send-tx-to-background";
104
+ }
105
+ validateBasic() {
106
+ if (!this.chainId) {
107
+ throw new Error("chain id is empty");
108
+ }
109
+ if (!this.tx) {
110
+ throw new Error("tx is empty");
111
+ }
112
+ if (!this.mode ||
113
+ (this.mode !== "sync" && this.mode !== "async" && this.mode !== "block")) {
114
+ throw new Error("invalid mode");
115
+ }
116
+ }
117
+ route() {
118
+ return "background-tx";
119
+ }
120
+ type() {
121
+ return SendTxMsg.type();
122
+ }
123
+ }
124
+ exports.SendTxMsg = SendTxMsg;
125
+ class GetSecret20ViewingKey extends router_1.Message {
126
+ constructor(chainId, contractAddress) {
127
+ super();
128
+ this.chainId = chainId;
129
+ this.contractAddress = contractAddress;
130
+ }
131
+ static type() {
132
+ return "get-secret20-viewing-key";
133
+ }
134
+ validateBasic() {
135
+ if (!this.chainId) {
136
+ throw new Error("Chain id is empty");
137
+ }
138
+ if (!this.contractAddress) {
139
+ throw new Error("Contract address is empty");
140
+ }
141
+ }
142
+ route() {
143
+ return "tokens";
144
+ }
145
+ type() {
146
+ return GetSecret20ViewingKey.type();
147
+ }
148
+ }
149
+ exports.GetSecret20ViewingKey = GetSecret20ViewingKey;
150
+ class RequestSignAminoMsg extends router_1.Message {
151
+ constructor(chainId, signer, signDoc, signOptions = {}) {
152
+ super();
153
+ this.chainId = chainId;
154
+ this.signer = signer;
155
+ this.signDoc = signDoc;
156
+ this.signOptions = signOptions;
157
+ }
158
+ static type() {
159
+ return "request-sign-amino";
160
+ }
161
+ validateBasic() {
162
+ if (!this.chainId) {
163
+ throw new Error("chain id not set");
164
+ }
165
+ if (!this.signer) {
166
+ throw new Error("signer not set");
167
+ }
168
+ // It is not important to check this on the client side as opposed to increasing the bundle size.
169
+ // Validate bech32 address.
170
+ // Bech32Address.validate(this.signer);
171
+ if (this.signDoc.chain_id !== this.chainId) {
172
+ throw new Error("Chain id in the message is not matched with the requested chain id");
173
+ }
174
+ if (!this.signOptions) {
175
+ throw new Error("Sign options are null");
176
+ }
177
+ }
178
+ route() {
179
+ return "keyring";
180
+ }
181
+ type() {
182
+ return RequestSignAminoMsg.type();
183
+ }
184
+ }
185
+ exports.RequestSignAminoMsg = RequestSignAminoMsg;
186
+ class RequestSignDirectMsg extends router_1.Message {
187
+ constructor(chainId, signer, signDoc, signOptions = {}) {
188
+ super();
189
+ this.chainId = chainId;
190
+ this.signer = signer;
191
+ this.signDoc = signDoc;
192
+ this.signOptions = signOptions;
193
+ }
194
+ static type() {
195
+ return "request-sign-direct";
196
+ }
197
+ validateBasic() {
198
+ if (!this.chainId) {
199
+ throw new Error("chain id not set");
200
+ }
201
+ if (!this.signer) {
202
+ throw new Error("signer not set");
203
+ }
204
+ // It is not important to check this on the client side as opposed to increasing the bundle size.
205
+ // Validate bech32 address.
206
+ // Bech32Address.validate(this.signer);
207
+ // const signDoc = cosmos.tx.v1beta1.SignDoc.create({
208
+ // bodyBytes: this.signDoc.bodyBytes,
209
+ // authInfoBytes: this.signDoc.authInfoBytes,
210
+ // chainId: this.signDoc.chainId,
211
+ // accountNumber: this.signDoc.accountNumber
212
+ // ? Long.fromString(this.signDoc.accountNumber)
213
+ // : undefined,
214
+ // });
215
+ //
216
+ // if (signDoc.chainId !== this.chainId) {
217
+ // throw new Error(
218
+ // "Chain id in the message is not matched with the requested chain id"
219
+ // );
220
+ // }
221
+ if (!this.signOptions) {
222
+ throw new Error("Sign options are null");
223
+ }
224
+ }
225
+ route() {
226
+ return "keyring";
227
+ }
228
+ type() {
229
+ return RequestSignDirectMsg.type();
230
+ }
231
+ }
232
+ exports.RequestSignDirectMsg = RequestSignDirectMsg;
233
+ class GetPubkeyMsg extends router_1.Message {
234
+ constructor(chainId) {
235
+ super();
236
+ this.chainId = chainId;
237
+ }
238
+ static type() {
239
+ return "get-pubkey-msg";
240
+ }
241
+ validateBasic() {
242
+ if (!this.chainId) {
243
+ throw new Error("chain id not set");
244
+ }
245
+ }
246
+ route() {
247
+ return "secret-wasm";
248
+ }
249
+ type() {
250
+ return GetPubkeyMsg.type();
251
+ }
252
+ }
253
+ exports.GetPubkeyMsg = GetPubkeyMsg;
254
+ class ReqeustEncryptMsg extends router_1.Message {
255
+ constructor(chainId, contractCodeHash,
256
+ // eslint-disable-next-line @typescript-eslint/ban-types
257
+ msg) {
258
+ super();
259
+ this.chainId = chainId;
260
+ this.contractCodeHash = contractCodeHash;
261
+ this.msg = msg;
262
+ }
263
+ static type() {
264
+ return "request-encrypt-msg";
265
+ }
266
+ validateBasic() {
267
+ if (!this.chainId) {
268
+ throw new Error("chain id not set");
269
+ }
270
+ if (!this.contractCodeHash) {
271
+ throw new Error("contract code hash not set");
272
+ }
273
+ if (!this.msg) {
274
+ throw new Error("msg not set");
275
+ }
276
+ }
277
+ route() {
278
+ return "secret-wasm";
279
+ }
280
+ type() {
281
+ return ReqeustEncryptMsg.type();
282
+ }
283
+ }
284
+ exports.ReqeustEncryptMsg = ReqeustEncryptMsg;
285
+ class RequestDecryptMsg extends router_1.Message {
286
+ constructor(chainId, cipherText, nonce) {
287
+ super();
288
+ this.chainId = chainId;
289
+ this.cipherText = cipherText;
290
+ this.nonce = nonce;
291
+ }
292
+ static type() {
293
+ return "request-decrypt-msg";
294
+ }
295
+ validateBasic() {
296
+ if (!this.chainId) {
297
+ throw new Error("chain id not set");
298
+ }
299
+ if (!this.cipherText || this.cipherText.length === 0) {
300
+ throw new Error("ciphertext not set");
301
+ }
302
+ if (!this.nonce || this.nonce.length === 0) {
303
+ throw new Error("nonce not set");
304
+ }
305
+ }
306
+ route() {
307
+ return "secret-wasm";
308
+ }
309
+ type() {
310
+ return RequestDecryptMsg.type();
311
+ }
312
+ }
313
+ exports.RequestDecryptMsg = RequestDecryptMsg;
314
+ class GetTxEncryptionKeyMsg extends router_1.Message {
315
+ constructor(chainId, nonce) {
316
+ super();
317
+ this.chainId = chainId;
318
+ this.nonce = nonce;
319
+ }
320
+ static type() {
321
+ return "get-tx-encryption-key-msg";
322
+ }
323
+ validateBasic() {
324
+ if (!this.chainId) {
325
+ throw new Error("chain id not set");
326
+ }
327
+ if (!this.nonce) {
328
+ // Nonce of zero length is permitted.
329
+ throw new Error("nonce is null");
330
+ }
331
+ }
332
+ route() {
333
+ return "secret-wasm";
334
+ }
335
+ type() {
336
+ return GetTxEncryptionKeyMsg.type();
337
+ }
338
+ }
339
+ exports.GetTxEncryptionKeyMsg = GetTxEncryptionKeyMsg;
340
+ //# sourceMappingURL=msgs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msgs.js","sourceRoot":"","sources":["../../src/types/msgs.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAI/C,MAAa,eAAgB,SAAQ,gBAAa;IAKhD,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QAHQ,YAAO,GAAP,OAAO,CAAQ;QACf,UAAK,GAAL,KAAK,CAAY;IAGnC,CAAC;IATM,MAAM,CAAC,IAAI;QAChB,OAAO,2BAA2B,CAAC;IACrC,CAAC;IASD,aAAa;QACX,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,kBAAkB,CAAC,CAAC;SACrC;QAED,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;YACf,qCAAqC;YACrC,MAAM,IAAI,KAAK,CAAC,eAAe,CAAC,CAAC;SAClC;IACH,CAAC;IAED,KAAK;QACH,OAAO,aAAa,CAAC;IACvB,CAAC;IAED,IAAI;QACF,OAAO,qBAAqB,CAAC,IAAI,EAAE,CAAC;IACtC,CAAC;CACF;AA9BD,sDA8BC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@keplr-wallet/provider",
3
- "version": "0.9.4-rc.0",
3
+ "version": "0.9.9-rc.0",
4
4
  "main": "build/index.js",
5
5
  "author": "chainapsis",
6
6
  "license": "Apache-2.0",
@@ -17,17 +17,13 @@
17
17
  "lint-fix": "eslint --fix \"src/**/*\" && prettier --write \"src/**/*\""
18
18
  },
19
19
  "dependencies": {
20
- "@cosmjs/encoding": "^0.24.0-alpha.25",
21
20
  "@cosmjs/launchpad": "^0.24.0-alpha.25",
22
21
  "@cosmjs/proto-signing": "^0.24.0-alpha.25",
23
- "@keplr-wallet/background": "^0.9.4-rc.0",
24
- "@keplr-wallet/cosmos": "^0.9.4-rc.0",
25
- "@keplr-wallet/router": "^0.9.0",
26
- "@keplr-wallet/types": "^0.9.4-rc.0",
27
- "@keplr-wallet/unit": "^0.9.4-rc.0",
28
- "buffer": "^6.0.3",
22
+ "@keplr-wallet/router": "^0.9.6",
23
+ "@keplr-wallet/types": "^0.9.9-rc.0",
29
24
  "deepmerge": "^4.2.2",
30
- "secretjs": "^0.16.0"
25
+ "long": "^4.0.0",
26
+ "secretjs": "^0.17.0"
31
27
  },
32
- "gitHead": "bd36b3afb6b291546b6c901280ef2295dabecd60"
28
+ "gitHead": "2aac30ca0637e5f1f4fb4699565ab5b1cc6bdb70"
33
29
  }
package/src/core.ts CHANGED
@@ -2,6 +2,7 @@ import {
2
2
  ChainInfo,
3
3
  Keplr as IKeplr,
4
4
  KeplrIntereactionOptions,
5
+ KeplrMode,
5
6
  KeplrSignOptions,
6
7
  Key,
7
8
  } from "@keplr-wallet/types";
@@ -26,8 +27,7 @@ import {
26
27
  ReqeustEncryptMsg,
27
28
  RequestDecryptMsg,
28
29
  GetTxEncryptionKeyMsg,
29
- } from "@keplr-wallet/background";
30
- import { cosmos } from "@keplr-wallet/cosmos";
30
+ } from "./types";
31
31
  import { SecretUtils } from "secretjs/types/enigmautils";
32
32
 
33
33
  import { KeplrEnigmaUtils } from "./enigma";
@@ -35,6 +35,7 @@ import { DirectSignResponse, OfflineDirectSigner } from "@cosmjs/proto-signing";
35
35
 
36
36
  import { CosmJSOfflineSigner, CosmJSOfflineSignerOnlyAmino } from "./cosmjs";
37
37
  import deepmerge from "deepmerge";
38
+ import Long from "long";
38
39
 
39
40
  export class Keplr implements IKeplr {
40
41
  protected enigmaUtils: Map<string, SecretUtils> = new Map();
@@ -43,6 +44,7 @@ export class Keplr implements IKeplr {
43
44
 
44
45
  constructor(
45
46
  public readonly version: string,
47
+ public readonly mode: KeplrMode,
46
48
  protected readonly requester: MessageRequester
47
49
  ) {}
48
50
 
@@ -94,19 +96,36 @@ export class Keplr implements IKeplr {
94
96
  async signDirect(
95
97
  chainId: string,
96
98
  signer: string,
97
- signDoc: cosmos.tx.v1beta1.ISignDoc,
99
+ signDoc: {
100
+ bodyBytes?: Uint8Array | null;
101
+ authInfoBytes?: Uint8Array | null;
102
+ chainId?: string | null;
103
+ accountNumber?: Long | null;
104
+ },
98
105
  signOptions: KeplrSignOptions = {}
99
106
  ): Promise<DirectSignResponse> {
100
107
  const msg = new RequestSignDirectMsg(
101
108
  chainId,
102
109
  signer,
103
- cosmos.tx.v1beta1.SignDoc.encode(signDoc).finish(),
110
+ {
111
+ bodyBytes: signDoc.bodyBytes,
112
+ authInfoBytes: signDoc.authInfoBytes,
113
+ chainId: signDoc.chainId,
114
+ accountNumber: signDoc.accountNumber
115
+ ? signDoc.accountNumber.toString()
116
+ : null,
117
+ },
104
118
  deepmerge(this.defaultOptions.sign ?? {}, signOptions)
105
119
  );
106
120
  const response = await this.requester.sendMessage(BACKGROUND_PORT, msg);
107
121
 
108
122
  return {
109
- signed: cosmos.tx.v1beta1.SignDoc.decode(response.signedBytes),
123
+ signed: {
124
+ bodyBytes: response.signed.bodyBytes,
125
+ authInfoBytes: response.signed.authInfoBytes,
126
+ chainId: response.signed.chainId,
127
+ accountNumber: Long.fromString(response.signed.accountNumber),
128
+ },
110
129
  signature: response.signature,
111
130
  };
112
131
  }
package/src/cosmjs.ts CHANGED
@@ -5,9 +5,9 @@ import {
5
5
  StdSignDoc,
6
6
  } from "@cosmjs/launchpad";
7
7
  import { Keplr } from "@keplr-wallet/types";
8
- import { cosmos } from "@keplr-wallet/cosmos";
9
8
  import { OfflineDirectSigner } from "@cosmjs/proto-signing";
10
9
  import { DirectSignResponse } from "@cosmjs/proto-signing/build/signer";
10
+ import { SignDoc } from "@cosmjs/proto-signing/build/codec/cosmos/tx/v1beta1/tx";
11
11
 
12
12
  export class CosmJSOfflineSignerOnlyAmino implements OfflineSigner {
13
13
  constructor(
@@ -66,7 +66,7 @@ export class CosmJSOfflineSigner
66
66
 
67
67
  async signDirect(
68
68
  signerAddress: string,
69
- signDoc: cosmos.tx.v1beta1.ISignDoc
69
+ signDoc: SignDoc
70
70
  ): Promise<DirectSignResponse> {
71
71
  if (this.chainId !== signDoc.chainId) {
72
72
  throw new Error("Unmatched chain id with the offline signer");
package/src/index.ts CHANGED
@@ -2,4 +2,3 @@ export * from "./core";
2
2
  export * from "./cosmjs";
3
3
  export * from "./enigma";
4
4
  export * from "./inject";
5
- export * from "./mock";