@hairy/ether-lib 1.10.0 → 1.12.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.
package/dist/index.cjs CHANGED
@@ -34,7 +34,6 @@ __export(index_exports, {
34
34
  Errors: () => Errors,
35
35
  formatEther: () => formatEther,
36
36
  idprefix: () => idprefix,
37
- subscribeForTransaction: () => subscribeForTransaction,
38
37
  wait: () => wait
39
38
  });
40
39
  module.exports = __toCommonJS(index_exports);
@@ -86,24 +85,8 @@ function formatEther(value = "0", options = {}) {
86
85
  }
87
86
 
88
87
  // src/wait.ts
89
- var import_ethers3 = require("ethers");
90
88
  var import_mitt = __toESM(require("mitt"), 1);
91
89
  var emitter = (0, import_mitt.default)();
92
- for (const Response of [import_ethers3.TransactionResponse, import_ethers3.ContractTransactionResponse]) {
93
- const waitForTransaction = Response.prototype.wait;
94
- Response.prototype._wait = waitForTransaction;
95
- Response.prototype.wait = async function(...args) {
96
- try {
97
- emitter.emit("before");
98
- const receipt = await waitForTransaction.call(this, ...args);
99
- emitter.emit("after", receipt);
100
- return receipt;
101
- } catch (error) {
102
- emitter.emit("error", error);
103
- throw error;
104
- }
105
- };
106
- }
107
90
  async function wait(transaction) {
108
91
  try {
109
92
  emitter.emit("before");
@@ -115,17 +98,17 @@ async function wait(transaction) {
115
98
  emitter.emit("after", receipt);
116
99
  return receipt;
117
100
  } catch (error) {
101
+ emitter.emit("after", null);
118
102
  emitter.emit("error", error);
119
103
  throw error;
120
104
  }
121
105
  }
122
- var subscribeForTransaction = emitter.on.bind(emitter);
106
+ wait.subscribe = emitter.on.bind(emitter);
123
107
  // Annotate the CommonJS export names for ESM import in node:
124
108
  0 && (module.exports = {
125
109
  Bignumber,
126
110
  Errors,
127
111
  formatEther,
128
112
  idprefix,
129
- subscribeForTransaction,
130
113
  wait
131
114
  });
package/dist/index.d.ts CHANGED
@@ -39,17 +39,19 @@ declare function formatEther(value?: Numberish, options?: FormatEtherOptions): s
39
39
 
40
40
  type GenericTransactionResponse = TransactionResponse | ContractTransactionResponse | Promise<TransactionResponse | ContractTransactionResponse> | (() => TransactionResponse | ContractTransactionResponse) | (() => Promise<TransactionResponse | ContractTransactionResponse>);
41
41
  declare function wait(transaction: GenericTransactionResponse): Promise<any>;
42
- declare const subscribeForTransaction: {
43
- <Key extends "before" | "after" | "error">(type: Key, handler: mitt.Handler<{
44
- before: void;
45
- after: TransactionReceipt | null;
46
- error: Error;
47
- }[Key]>): void;
48
- (type: "*", handler: mitt.WildcardHandler<{
49
- before: void;
50
- after: TransactionReceipt | null;
51
- error: Error;
52
- }>): void;
53
- };
42
+ declare namespace wait {
43
+ var subscribe: {
44
+ <Key extends "before" | "after" | "error">(type: Key, handler: mitt.Handler<{
45
+ before: void;
46
+ after: TransactionReceipt | null;
47
+ error: Error;
48
+ }[Key]>): void;
49
+ (type: "*", handler: mitt.WildcardHandler<{
50
+ before: void;
51
+ after: TransactionReceipt | null;
52
+ error: Error;
53
+ }>): void;
54
+ };
55
+ }
54
56
 
55
- export { Errors, type FormatEtherOptions, type GenericTransactionResponse, formatEther, idprefix, subscribeForTransaction, wait };
57
+ export { Errors, type FormatEtherOptions, type GenericTransactionResponse, formatEther, idprefix, wait };
@@ -148,9 +148,6 @@
148
148
  });
149
149
  }
150
150
 
151
- // src/wait.ts
152
- var import_ethers3 = __toESM(require_ethers(), 1);
153
-
154
151
  // ../../node_modules/.pnpm/mitt@3.0.1/node_modules/mitt/dist/mitt.mjs
155
152
  function mitt_default(n) {
156
153
  return { all: n = n || /* @__PURE__ */ new Map(), on: function(t, e) {
@@ -171,21 +168,6 @@
171
168
 
172
169
  // src/wait.ts
173
170
  var emitter = mitt_default();
174
- for (const Response of [import_ethers3.TransactionResponse, import_ethers3.ContractTransactionResponse]) {
175
- const waitForTransaction = Response.prototype.wait;
176
- Response.prototype._wait = waitForTransaction;
177
- Response.prototype.wait = async function(...args) {
178
- try {
179
- emitter.emit("before");
180
- const receipt = await waitForTransaction.call(this, ...args);
181
- emitter.emit("after", receipt);
182
- return receipt;
183
- } catch (error) {
184
- emitter.emit("error", error);
185
- throw error;
186
- }
187
- };
188
- }
189
171
  async function wait(transaction) {
190
172
  try {
191
173
  emitter.emit("before");
@@ -197,9 +179,10 @@
197
179
  emitter.emit("after", receipt);
198
180
  return receipt;
199
181
  } catch (error) {
182
+ emitter.emit("after", null);
200
183
  emitter.emit("error", error);
201
184
  throw error;
202
185
  }
203
186
  }
204
- var subscribeForTransaction = emitter.on.bind(emitter);
187
+ wait.subscribe = emitter.on.bind(emitter);
205
188
  })();
package/dist/index.js CHANGED
@@ -45,24 +45,8 @@ function formatEther(value = "0", options = {}) {
45
45
  }
46
46
 
47
47
  // src/wait.ts
48
- import { ContractTransactionResponse, TransactionResponse } from "ethers";
49
48
  import mitt from "mitt";
50
49
  var emitter = mitt();
51
- for (const Response of [TransactionResponse, ContractTransactionResponse]) {
52
- const waitForTransaction = Response.prototype.wait;
53
- Response.prototype._wait = waitForTransaction;
54
- Response.prototype.wait = async function(...args) {
55
- try {
56
- emitter.emit("before");
57
- const receipt = await waitForTransaction.call(this, ...args);
58
- emitter.emit("after", receipt);
59
- return receipt;
60
- } catch (error) {
61
- emitter.emit("error", error);
62
- throw error;
63
- }
64
- };
65
- }
66
50
  async function wait(transaction) {
67
51
  try {
68
52
  emitter.emit("before");
@@ -74,16 +58,16 @@ async function wait(transaction) {
74
58
  emitter.emit("after", receipt);
75
59
  return receipt;
76
60
  } catch (error) {
61
+ emitter.emit("after", null);
77
62
  emitter.emit("error", error);
78
63
  throw error;
79
64
  }
80
65
  }
81
- var subscribeForTransaction = emitter.on.bind(emitter);
66
+ wait.subscribe = emitter.on.bind(emitter);
82
67
  export {
83
68
  Bignumber,
84
69
  Errors,
85
70
  formatEther,
86
71
  idprefix,
87
- subscribeForTransaction,
88
72
  wait
89
73
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hairy/ether-lib",
3
3
  "type": "module",
4
- "version": "1.10.0",
4
+ "version": "1.12.0",
5
5
  "description": "Library for ether",
6
6
  "author": "Hairyf <wwu710632@gmail.com>",
7
7
  "license": "MIT",
@@ -26,7 +26,7 @@
26
26
  },
27
27
  "dependencies": {
28
28
  "mitt": "^3.0.1",
29
- "@hairy/utils": "1.10.0"
29
+ "@hairy/utils": "1.12.0"
30
30
  },
31
31
  "devDependencies": {
32
32
  "ethers": "^6"