|
14 | 14 | // You should have received a copy of the GNU Lesser General Public License |
15 | 15 | // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>. |
16 | 16 |
|
17 | | -// package js is a collection of tracers written in javascript. |
| 17 | +// Package js is a collection of tracers written in javascript. |
18 | 18 | package js |
19 | 19 |
|
20 | 20 | import ( |
21 | 21 | "encoding/json" |
22 | 22 | "errors" |
23 | 23 | "fmt" |
| 24 | + "io/fs" |
24 | 25 | "math/big" |
25 | 26 | "strings" |
26 | 27 | "sync/atomic" |
@@ -51,9 +52,23 @@ var assetTracers = make(map[string]string) |
51 | 52 |
|
52 | 53 | // init retrieves the JavaScript transaction tracers included in go-ethereum. |
53 | 54 | func init() { |
54 | | - for _, file := range tracers.AssetNames() { |
55 | | - name := camel(strings.TrimSuffix(file, ".js")) |
56 | | - assetTracers[name] = string(tracers.MustAsset(file)) |
| 55 | + err := fs.WalkDir(tracers.FS, ".", func(path string, d fs.DirEntry, err error) error { |
| 56 | + if err != nil { |
| 57 | + return err |
| 58 | + } |
| 59 | + if d.IsDir() { |
| 60 | + return nil |
| 61 | + } |
| 62 | + b, err := fs.ReadFile(tracers.FS, path) |
| 63 | + if err != nil { |
| 64 | + return err |
| 65 | + } |
| 66 | + name := camel(strings.TrimSuffix(path, ".js")) |
| 67 | + assetTracers[name] = string(b) |
| 68 | + return nil |
| 69 | + }) |
| 70 | + if err != nil { |
| 71 | + panic(err) |
57 | 72 | } |
58 | 73 | tracers2.RegisterLookup(true, newJsTracer) |
59 | 74 | } |
@@ -685,7 +700,7 @@ func (jst *jsTracer) CaptureTxStart(gasLimit uint64) { |
685 | 700 | jst.gasLimit = gasLimit |
686 | 701 | } |
687 | 702 |
|
688 | | -// CaptureTxStart implements the Tracer interface and is invoked at the end of |
| 703 | +// CaptureTxEnd implements the Tracer interface and is invoked at the end of |
689 | 704 | // transaction processing. |
690 | 705 | func (*jsTracer) CaptureTxEnd(restGas uint64) {} |
691 | 706 |
|
|
0 commit comments