├── .github └── workflows │ └── typescript.yml ├── .gitignore ├── LICENSE ├── README.md ├── abis.go ├── abis_internal.go ├── blocks.go ├── blocks_internal.go ├── chunks.go ├── chunks_internal.go ├── config.go ├── config_internal.go ├── daemon.go ├── daemon_internal.go ├── explore.go ├── explore_internal.go ├── export.go ├── export_internal.go ├── globals.go ├── globals_test.go ├── go.mod ├── go.sum ├── init.go ├── init_internal.go ├── list.go ├── list_internal.go ├── logs.go ├── logs_internal.go ├── makefile ├── meta.go ├── monitors.go ├── monitors_internal.go ├── names.go ├── names_internal.go ├── parse.go ├── python ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── chifra.py ├── makefile ├── requirements.txt ├── src │ ├── __init__.py │ ├── _abis.py │ ├── _blocks.py │ ├── _chunks.py │ ├── _config.py │ ├── _export.py │ ├── _init.py │ ├── _list.py │ ├── _logs.py │ ├── _monitors.py │ ├── _names.py │ ├── _receipts.py │ ├── _slurp.py │ ├── _state.py │ ├── _status.py │ ├── _tokens.py │ ├── _traces.py │ ├── _transactions.py │ ├── _usage.py │ ├── _utils.py │ └── _when.py └── tests │ ├── __init__.py │ ├── data │ ├── block.yml │ ├── tv-info.yml │ └── when.yml │ └── test_chifra.py ├── receipts.go ├── receipts_internal.go ├── result.go ├── rpc.go ├── scrape.go ├── scrape_internal.go ├── services ├── service.go ├── service_api.go ├── service_control.go ├── service_ipfs.go ├── service_manager.go ├── service_monitor.go ├── service_scraper.go ├── service_scraper_report.go └── service_test.go ├── slurp.go ├── slurp_internal.go ├── sorts.go ├── state.go ├── state_internal.go ├── status.go ├── status_internal.go ├── tokens.go ├── tokens_internal.go ├── traces.go ├── traces_internal.go ├── transactions.go ├── transactions_internal.go ├── typescript ├── .editorconfig ├── .env.example ├── .eslintignore ├── .eslintrc.cjs ├── .npmignore ├── .npmrc ├── .prettierrc.cjs ├── README.md ├── makefile ├── package.json ├── src │ ├── index.ts │ ├── lib │ │ ├── api_callers.test.ts │ │ └── api_callers.ts │ ├── paths │ │ ├── abis.ts │ │ ├── blocks.ts │ │ ├── chunks.ts │ │ ├── config.ts │ │ ├── export.ts │ │ ├── index.ts │ │ ├── init.ts │ │ ├── list.ts │ │ ├── logs.ts │ │ ├── monitors.ts │ │ ├── names.ts │ │ ├── receipts.ts │ │ ├── slurp.ts │ │ ├── state.ts │ │ ├── status.ts │ │ ├── tokens.ts │ │ ├── traces.ts │ │ ├── transactions.ts │ │ └── when.ts │ └── types │ │ ├── abi.ts │ │ ├── appearance.ts │ │ ├── appearancetable.ts │ │ ├── basetypes.ts │ │ ├── block.ts │ │ ├── blockCount.ts │ │ ├── bounds.ts │ │ ├── cacheItem.ts │ │ ├── chain.ts │ │ ├── chunkAddress.ts │ │ ├── chunkBloom.ts │ │ ├── chunkIndex.ts │ │ ├── chunkPin.ts │ │ ├── chunkRecord.ts │ │ ├── chunkStats.ts │ │ ├── config.ts │ │ ├── count.ts │ │ ├── destination.ts │ │ ├── ethCall.ts │ │ ├── function.ts │ │ ├── index.ts │ │ ├── ipfsPin.ts │ │ ├── lightblock.ts │ │ ├── log.ts │ │ ├── manifest.ts │ │ ├── message.ts │ │ ├── monitor.ts │ │ ├── monitorClean.ts │ │ ├── name.ts │ │ ├── namedBlock.ts │ │ ├── parameter.ts │ │ ├── rangedates.ts │ │ ├── receipt.ts │ │ ├── reportCheck.ts │ │ ├── result.ts │ │ ├── slurp.ts │ │ ├── state.ts │ │ ├── statement.ts │ │ ├── status.ts │ │ ├── timestamp.ts │ │ ├── token.ts │ │ ├── trace.ts │ │ ├── traceAction.ts │ │ ├── traceCount.ts │ │ ├── traceFilter.ts │ │ ├── traceResult.ts │ │ ├── transaction.ts │ │ ├── transfer.ts │ │ ├── upgrades.ts │ │ └── withdrawal.ts ├── tsconfig.json └── yarn.lock ├── updater.go ├── updater_test.go ├── version.go ├── when.go └── when_internal.go /.github/workflows/typescript.yml: -------------------------------------------------------------------------------- 1 | name: TypeScript SDK CI 2 | 3 | permissions: 4 | contents: 'write' 5 | 6 | on: 7 | push: 8 | tags: 9 | - 'v*' 10 | 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | cancel-in-progress: true 14 | 15 | defaults: 16 | run: 17 | shell: bash 18 | working-directory: typescript 19 | 20 | env: 21 | CI: true 22 | # Enable debug logging for actions 23 | ACTIONS_RUNNER_DEBUG: true 24 | 25 | jobs: 26 | Publish: 27 | # run only on 'main' branch 28 | if: github.ref == 'refs/heads/main' 29 | strategy: 30 | matrix: 31 | node_version: ['lts/*'] 32 | os: ['ubuntu-latest'] 33 | runs-on: ${{ matrix.os }} 34 | 35 | steps: 36 | - name: Checkout 37 | uses: actions/checkout@v4 38 | 39 | - name: Setup Node.js 40 | uses: actions/setup-node@v4 41 | with: 42 | node-version: ${{ matrix.node_version }} 43 | cache: 'yarn' 44 | cache-dependency-path: 'typescript/yarn.lock' 45 | 46 | - name: Install Dependencies 47 | run: yarn install --frozen-lockfile 48 | 49 | - name: Bundle & Build 50 | run: yarn build 51 | 52 | - name: Publish to npm Registry 53 | env: 54 | NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 55 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 56 | run: yarn publish --access public --registry https://registry.npmjs.org 57 | 58 | - name: Add Token to .npmrc & Update package.json 59 | working-directory: typescript 60 | run: | 61 | # 62 | # Add token to .npmrc 63 | echo "//npm.pkg.github.com:_authToken=${{ secrets.GITHUB_TOKEN }}" > .npmrc 64 | # 65 | # Update 'github-package-registry' to 'registry' in package.json 66 | sed -i 's/github-package-registry/registry/g' package.json 67 | 68 | - name: Publish to GitHub Package Registry 69 | env: 70 | NPM_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 71 | NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} 72 | run: yarn publish --access public --registry https://npm.pkg.github.com 73 | 74 | 75 | # Generate GitHub Release Changelog 76 | Changelog: 77 | # make sure we're on 'main' branch 78 | if: github.ref == 'refs/heads/main' 79 | needs: [Publish] 80 | runs-on: ubuntu-latest 81 | steps: 82 | - name: Checkout 83 | uses: actions/checkout@v4 84 | with: 85 | fetch-depth: 0 86 | - name: Setup Node.js 87 | uses: actions/setup-node@v4 88 | with: 89 | node-version: 'lts/*' 90 | - name: Generate Changelog 91 | env: 92 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 93 | run: npx changelogithub 94 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # TrueBlocks SDKs 2 | 3 | [![Go Reference](https://pkg.go.dev/badge/github.com/TrueBlocks/trueblocks-sdk/v4.svg)](https://pkg.go.dev/github.com/TrueBlocks/trueblocks-sdk/v4) 4 | 5 | ## Table of Contents 6 | 7 | - [TrueBlocks SDKs](#trueblocks-sdks) 8 | - [Table of Contents](#table-of-contents) 9 | - [Introduction](#introduction) 10 | - [Documentation](#documentation) 11 | - [Contributing](#contributing) 12 | - [Contact](#contact) 13 | - [List of Contributors](#list-of-contributors) 14 | - [Deprecated SDKs](#deprecated-sdks) 15 | 16 | ## Introduction 17 | 18 | This repo holds auto-generated SDKs based on [TrueBlocks Core](https://github.com/TrueBlocks/trueblocks-core). Use it to build amazing local-first applications such as [TrueBlocks Browse](https://github.com/TrueBlocks/trueblocks-browse) (currently private). 19 | 20 | You are welcome to use the SDK, but it is currently pre-alpha. 21 | 22 | ## Documentation 23 | 24 | The SDK's [documentation is here](https://pkg.go.dev/github.com/TrueBlocks/trueblocks-sdk/v4). Also, see our website for the [more information](https://trueblocks.io/). 25 | 26 | ## Contributing 27 | 28 | We love contributors. Please see information about our [work flow](https://github.com/TrueBlocks/trueblocks-core/blob/develop/docs/BRANCHING.md) before proceeding. 29 | 30 | 1. Fork this repository into your own repo. 31 | 2. Create a branch: `git checkout -b `. 32 | 3. Make changes to your local branch and commit them to your forked repo: `git commit -m ''` 33 | 4. Push back to the original branch: `git push origin TrueBlocks/trueblocks-core` 34 | 5. Create the pull request. 35 | 36 | ## Contact 37 | 38 | If you have questions, comments, or complaints, please join the discussion on our discord server which is [linked from our website](https://trueblocks.io). 39 | 40 | ## List of Contributors 41 | 42 | Thanks to the following people who have contributed to this project: 43 | 44 | - [@tjayrush](https://github.com/tjayrush) 45 | - [@dszlachta](https://github.com/dszlachta) 46 | 47 | ## Deprecated SDKs 48 | 49 | In the past, we've supported two other SDKs, however, for the time being, they are deprecated. We intend to update them in the future. 50 | 51 | - [Typescript](./typescript/README.md) 52 | - [Python](./python/README.md) 53 | -------------------------------------------------------------------------------- /abis.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | 14 | "encoding/json" 15 | 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 19 | // EXISTING_CODE 20 | ) 21 | 22 | type AbisOptions struct { 23 | Addrs []string `json:"addrs,omitempty"` 24 | Known bool `json:"known,omitempty"` 25 | ProxyFor base.Address `json:"proxyFor,omitempty"` 26 | Hint []string `json:"hint,omitempty"` 27 | RenderCtx *output.RenderCtx `json:"-"` 28 | Globals 29 | } 30 | 31 | // String implements the stringer interface 32 | func (opts AbisOptions) String() string { 33 | bytes, _ := json.Marshal(opts) 34 | return string(bytes) 35 | } 36 | 37 | // Abis implements the chifra abis command. 38 | func (opts *AbisOptions) Abis() ([]types.Function, *types.MetaData, error) { 39 | in := opts.toInternal() 40 | return queryAbis[types.Function](in) 41 | } 42 | 43 | // AbisList implements the chifra abis --list command. 44 | func (opts *AbisOptions) AbisList() ([]types.Abi, *types.MetaData, error) { 45 | in := opts.toInternal() 46 | in.List = true 47 | return queryAbis[types.Abi](in) 48 | } 49 | 50 | // AbisDetails implements the chifra abis --details command. 51 | func (opts *AbisOptions) AbisDetails() ([]types.Function, *types.MetaData, error) { 52 | in := opts.toInternal() 53 | in.Details = true 54 | return queryAbis[types.Function](in) 55 | } 56 | 57 | // AbisCount implements the chifra abis --count command. 58 | func (opts *AbisOptions) AbisCount() ([]types.Count, *types.MetaData, error) { 59 | in := opts.toInternal() 60 | in.Count = true 61 | return queryAbis[types.Count](in) 62 | } 63 | 64 | // AbisFind implements the chifra abis --find command. 65 | func (opts *AbisOptions) AbisFind(val []string) ([]types.Function, *types.MetaData, error) { 66 | in := opts.toInternal() 67 | in.Find = val 68 | return queryAbis[types.Function](in) 69 | } 70 | 71 | // AbisEncode implements the chifra abis --encode command. 72 | func (opts *AbisOptions) AbisEncode(val string) ([]types.Function, *types.MetaData, error) { 73 | in := opts.toInternal() 74 | in.Encode = val 75 | return queryAbis[types.Function](in) 76 | } 77 | 78 | // No enums 79 | // EXISTING_CODE 80 | // EXISTING_CODE 81 | -------------------------------------------------------------------------------- /config.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | "fmt" 15 | "strings" 16 | 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 19 | // EXISTING_CODE 20 | ) 21 | 22 | type ConfigOptions struct { 23 | Mode ConfigMode `json:"mode,omitempty"` 24 | RenderCtx *output.RenderCtx `json:"-"` 25 | Globals 26 | } 27 | 28 | // String implements the stringer interface 29 | func (opts ConfigOptions) String() string { 30 | bytes, _ := json.Marshal(opts) 31 | return string(bytes) 32 | } 33 | 34 | // ConfigPaths implements the chifra config --paths command. 35 | func (opts *ConfigOptions) ConfigPaths() ([]types.CacheItem, *types.MetaData, error) { 36 | in := opts.toInternal() 37 | in.Paths = true 38 | return queryConfig[types.CacheItem](in) 39 | } 40 | 41 | // ConfigDump implements the chifra config --dump command. 42 | func (opts *ConfigOptions) ConfigDump() ([]types.Config, *types.MetaData, error) { 43 | in := opts.toInternal() 44 | in.Dump = true 45 | return queryConfig[types.Config](in) 46 | } 47 | 48 | type ConfigMode int 49 | 50 | const ( 51 | NoCOM ConfigMode = 0 52 | CMShow = 1 << iota 53 | CMEdit 54 | ) 55 | 56 | func (v ConfigMode) String() string { 57 | switch v { 58 | case NoCOM: 59 | return "none" 60 | } 61 | 62 | var m = map[ConfigMode]string{ 63 | CMShow: "show", 64 | CMEdit: "edit", 65 | } 66 | 67 | var ret []string 68 | for _, val := range []ConfigMode{CMShow, CMEdit} { 69 | if v&val != 0 { 70 | ret = append(ret, m[val]) 71 | } 72 | } 73 | 74 | return strings.Join(ret, ",") 75 | } 76 | 77 | func enumFromConfigMode(values []string) (ConfigMode, error) { 78 | if len(values) == 0 { 79 | return NoCOM, fmt.Errorf("no value provided for mode option") 80 | } 81 | 82 | var result ConfigMode 83 | for _, val := range values { 84 | switch val { 85 | case "show": 86 | result |= CMShow 87 | case "edit": 88 | result |= CMEdit 89 | default: 90 | return NoCOM, fmt.Errorf("unknown mode: %s", val) 91 | } 92 | } 93 | 94 | return result, nil 95 | } 96 | 97 | // EXISTING_CODE 98 | // EXISTING_CODE 99 | -------------------------------------------------------------------------------- /config_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | "strings" 18 | 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 20 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 21 | config "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 22 | // EXISTING_CODE 23 | ) 24 | 25 | type configOptionsInternal struct { 26 | Mode ConfigMode `json:"mode,omitempty"` 27 | Paths bool `json:"paths,omitempty"` 28 | Dump bool `json:"dump,omitempty"` 29 | RenderCtx *output.RenderCtx `json:"-"` 30 | Globals 31 | } 32 | 33 | // String implements the stringer interface 34 | func (opts *configOptionsInternal) String() string { 35 | bytes, _ := json.Marshal(opts) 36 | return string(bytes) 37 | } 38 | 39 | // ConfigBytes implements the chifra config command for the SDK. 40 | func (opts *configOptionsInternal) ConfigBytes(w io.Writer) error { 41 | values, err := structToValues(*opts) 42 | if err != nil { 43 | return fmt.Errorf("error converting config struct to URL values: %v", err) 44 | } 45 | 46 | if opts.RenderCtx == nil { 47 | opts.RenderCtx = output.NewRenderContext() 48 | } 49 | return config.Config(opts.RenderCtx, w, values) 50 | } 51 | 52 | // configParseFunc handles special cases such as structs and enums (if any). 53 | func configParseFunc(target any, key, value string) (bool, error) { 54 | _ = key 55 | _ = value 56 | var found bool 57 | opts, ok := target.(*configOptionsInternal) 58 | if !ok { 59 | return false, fmt.Errorf("parseFunc(config): target is not of correct type") 60 | } 61 | 62 | if key == "mode" { 63 | var err error 64 | values := strings.Split(value, ",") 65 | if opts.Mode, err = enumFromConfigMode(values); err != nil { 66 | return false, err 67 | } else { 68 | found = true 69 | } 70 | } 71 | 72 | // EXISTING_CODE 73 | // EXISTING_CODE 74 | 75 | return found, nil 76 | } 77 | 78 | // GetConfigOptions returns a filled-in options instance given a string array of arguments. 79 | func GetConfigOptions(args []string) (*configOptionsInternal, error) { 80 | var opts configOptionsInternal 81 | if err := assignValuesFromArgs(args, configParseFunc, &opts, &opts.Globals); err != nil { 82 | return nil, err 83 | } 84 | 85 | return &opts, nil 86 | } 87 | 88 | type configGeneric interface { 89 | types.CacheItem | 90 | types.Config 91 | } 92 | 93 | func queryConfig[T configGeneric](opts *configOptionsInternal) ([]T, *types.MetaData, error) { 94 | // EXISTING_CODE 95 | // EXISTING_CODE 96 | 97 | buffer := bytes.Buffer{} 98 | if err := opts.ConfigBytes(&buffer); err != nil { 99 | return nil, nil, err 100 | } 101 | 102 | str := buffer.String() 103 | // EXISTING_CODE 104 | // EXISTING_CODE 105 | 106 | var result Result[T] 107 | if err := json.Unmarshal([]byte(str), &result); err != nil { 108 | debugPrint(str, result, err) 109 | return nil, nil, err 110 | } else { 111 | return result.Data, &result.Meta, nil 112 | } 113 | } 114 | 115 | // toInternal converts the SDK options to the internal options format. 116 | func (opts *ConfigOptions) toInternal() *configOptionsInternal { 117 | return &configOptionsInternal{ 118 | Mode: opts.Mode, 119 | RenderCtx: opts.RenderCtx, 120 | Globals: opts.Globals, 121 | } 122 | } 123 | 124 | // EXISTING_CODE 125 | // EXISTING_CODE 126 | -------------------------------------------------------------------------------- /daemon.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | 14 | "encoding/json" 15 | "fmt" 16 | "strings" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | // EXISTING_CODE 20 | ) 21 | 22 | type DaemonOptions struct { 23 | Url string `json:"url,omitempty"` 24 | Api DaemonApi `json:"api,omitempty"` 25 | Scrape DaemonScrape `json:"scrape,omitempty"` 26 | Monitor bool `json:"monitor,omitempty"` 27 | Silent bool `json:"silent,omitempty"` 28 | RenderCtx *output.RenderCtx `json:"-"` 29 | Globals 30 | } 31 | 32 | // String implements the stringer interface 33 | func (opts DaemonOptions) String() string { 34 | bytes, _ := json.Marshal(opts) 35 | return string(bytes) 36 | } 37 | 38 | type DaemonApi int 39 | 40 | const ( 41 | NoDA DaemonApi = 0 42 | DAOff = 1 << iota 43 | DAOn 44 | ) 45 | 46 | func (v DaemonApi) String() string { 47 | switch v { 48 | case NoDA: 49 | return "none" 50 | } 51 | 52 | var m = map[DaemonApi]string{ 53 | DAOff: "off", 54 | DAOn: "on", 55 | } 56 | 57 | var ret []string 58 | for _, val := range []DaemonApi{DAOff, DAOn} { 59 | if v&val != 0 { 60 | ret = append(ret, m[val]) 61 | } 62 | } 63 | 64 | return strings.Join(ret, ",") 65 | } 66 | 67 | func enumFromDaemonApi(values []string) (DaemonApi, error) { 68 | if len(values) == 0 { 69 | return NoDA, fmt.Errorf("no value provided for api option") 70 | } 71 | 72 | var result DaemonApi 73 | for _, val := range values { 74 | switch val { 75 | case "off": 76 | result |= DAOff 77 | case "on": 78 | result |= DAOn 79 | default: 80 | return NoDA, fmt.Errorf("unknown api: %s", val) 81 | } 82 | } 83 | 84 | return result, nil 85 | } 86 | 87 | type DaemonScrape int 88 | 89 | const ( 90 | NoDS DaemonScrape = 0 91 | DSOff = 1 << iota 92 | DSBlooms 93 | DSIndex 94 | ) 95 | 96 | func (v DaemonScrape) String() string { 97 | switch v { 98 | case NoDS: 99 | return "none" 100 | } 101 | 102 | var m = map[DaemonScrape]string{ 103 | DSOff: "off", 104 | DSBlooms: "blooms", 105 | DSIndex: "index", 106 | } 107 | 108 | var ret []string 109 | for _, val := range []DaemonScrape{DSOff, DSBlooms, DSIndex} { 110 | if v&val != 0 { 111 | ret = append(ret, m[val]) 112 | } 113 | } 114 | 115 | return strings.Join(ret, ",") 116 | } 117 | 118 | func enumFromDaemonScrape(values []string) (DaemonScrape, error) { 119 | if len(values) == 0 { 120 | return NoDS, fmt.Errorf("no value provided for scrape option") 121 | } 122 | 123 | var result DaemonScrape 124 | for _, val := range values { 125 | switch val { 126 | case "off": 127 | result |= DSOff 128 | case "blooms": 129 | result |= DSBlooms 130 | case "index": 131 | result |= DSIndex 132 | default: 133 | return NoDS, fmt.Errorf("unknown scrape: %s", val) 134 | } 135 | } 136 | 137 | return result, nil 138 | } 139 | 140 | // EXISTING_CODE 141 | func (opts *DaemonOptions) ToInternal() *daemonOptionsInternal { 142 | return opts.toInternal() 143 | } 144 | 145 | // EXISTING_CODE 146 | -------------------------------------------------------------------------------- /daemon_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | "fmt" 15 | "io" 16 | "strings" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | daemon "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 20 | // EXISTING_CODE 21 | ) 22 | 23 | type daemonOptionsInternal struct { 24 | Url string `json:"url,omitempty"` 25 | Api DaemonApi `json:"api,omitempty"` 26 | Scrape DaemonScrape `json:"scrape,omitempty"` 27 | Monitor bool `json:"monitor,omitempty"` 28 | Silent bool `json:"silent,omitempty"` 29 | RenderCtx *output.RenderCtx `json:"-"` 30 | Globals 31 | } 32 | 33 | // String implements the stringer interface 34 | func (opts *daemonOptionsInternal) String() string { 35 | bytes, _ := json.Marshal(opts) 36 | return string(bytes) 37 | } 38 | 39 | // DaemonBytes implements the chifra daemon command for the SDK. 40 | func (opts *daemonOptionsInternal) DaemonBytes(w io.Writer) error { 41 | values, err := structToValues(*opts) 42 | if err != nil { 43 | return fmt.Errorf("error converting daemon struct to URL values: %v", err) 44 | } 45 | 46 | if opts.RenderCtx == nil { 47 | opts.RenderCtx = output.NewRenderContext() 48 | } 49 | return daemon.Daemon(opts.RenderCtx, w, values) 50 | } 51 | 52 | // daemonParseFunc handles special cases such as structs and enums (if any). 53 | func daemonParseFunc(target any, key, value string) (bool, error) { 54 | var found bool 55 | opts, ok := target.(*daemonOptionsInternal) 56 | if !ok { 57 | return false, fmt.Errorf("parseFunc(daemon): target is not of correct type") 58 | } 59 | 60 | if key == "api" { 61 | var err error 62 | values := strings.Split(value, ",") 63 | if opts.Api, err = enumFromDaemonApi(values); err != nil { 64 | return false, err 65 | } else { 66 | found = true 67 | } 68 | } 69 | if key == "scrape" { 70 | var err error 71 | values := strings.Split(value, ",") 72 | if opts.Scrape, err = enumFromDaemonScrape(values); err != nil { 73 | return false, err 74 | } else { 75 | found = true 76 | } 77 | } 78 | 79 | // EXISTING_CODE 80 | // EXISTING_CODE 81 | 82 | return found, nil 83 | } 84 | 85 | // GetDaemonOptions returns a filled-in options instance given a string array of arguments. 86 | func GetDaemonOptions(args []string) (*daemonOptionsInternal, error) { 87 | var opts daemonOptionsInternal 88 | if err := assignValuesFromArgs(args, daemonParseFunc, &opts, &opts.Globals); err != nil { 89 | return nil, err 90 | } 91 | 92 | return &opts, nil 93 | } 94 | 95 | // EXISTING_CODE 96 | func (opts *DaemonOptions) toInternal() *daemonOptionsInternal { 97 | return &daemonOptionsInternal{ 98 | Url: opts.Url, 99 | Api: opts.Api, 100 | Scrape: opts.Scrape, 101 | Monitor: opts.Monitor, 102 | Silent: opts.Silent, 103 | RenderCtx: opts.RenderCtx, 104 | Globals: opts.Globals, 105 | } 106 | } 107 | 108 | // EXISTING_CODE 109 | -------------------------------------------------------------------------------- /explore.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 17 | // EXISTING_CODE 18 | ) 19 | 20 | type ExploreOptions struct { 21 | Terms []string `json:"terms,omitempty"` 22 | NoOpen bool `json:"noOpen,omitempty"` 23 | Local bool `json:"local,omitempty"` 24 | Google bool `json:"google,omitempty"` 25 | Dalle bool `json:"dalle,omitempty"` 26 | RenderCtx *output.RenderCtx `json:"-"` 27 | Globals 28 | } 29 | 30 | // String implements the stringer interface 31 | func (opts ExploreOptions) String() string { 32 | bytes, _ := json.Marshal(opts) 33 | return string(bytes) 34 | } 35 | 36 | // Explore implements the chifra explore command. 37 | func (opts *ExploreOptions) Explore() ([]types.Destination, *types.MetaData, error) { 38 | in := opts.toInternal() 39 | return queryExplore[types.Destination](in) 40 | } 41 | 42 | // No enums 43 | // EXISTING_CODE 44 | // EXISTING_CODE 45 | -------------------------------------------------------------------------------- /explore_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 20 | explore "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 21 | // EXISTING_CODE 22 | ) 23 | 24 | type exploreOptionsInternal struct { 25 | Terms []string `json:"terms,omitempty"` 26 | NoOpen bool `json:"noOpen,omitempty"` 27 | Local bool `json:"local,omitempty"` 28 | Google bool `json:"google,omitempty"` 29 | Dalle bool `json:"dalle,omitempty"` 30 | RenderCtx *output.RenderCtx `json:"-"` 31 | Globals 32 | } 33 | 34 | // String implements the stringer interface 35 | func (opts *exploreOptionsInternal) String() string { 36 | bytes, _ := json.Marshal(opts) 37 | return string(bytes) 38 | } 39 | 40 | // ExploreBytes implements the chifra explore command for the SDK. 41 | func (opts *exploreOptionsInternal) ExploreBytes(w io.Writer) error { 42 | values, err := structToValues(*opts) 43 | if err != nil { 44 | return fmt.Errorf("error converting explore struct to URL values: %v", err) 45 | } 46 | 47 | if opts.RenderCtx == nil { 48 | opts.RenderCtx = output.NewRenderContext() 49 | } 50 | return explore.Explore(opts.RenderCtx, w, values) 51 | } 52 | 53 | // exploreParseFunc handles special cases such as structs and enums (if any). 54 | func exploreParseFunc(target any, key, value string) (bool, error) { 55 | _ = key 56 | _ = value 57 | var found bool 58 | _, ok := target.(*exploreOptionsInternal) 59 | if !ok { 60 | return false, fmt.Errorf("parseFunc(explore): target is not of correct type") 61 | } 62 | 63 | // No enums 64 | // EXISTING_CODE 65 | // EXISTING_CODE 66 | 67 | return found, nil 68 | } 69 | 70 | // GetExploreOptions returns a filled-in options instance given a string array of arguments. 71 | func GetExploreOptions(args []string) (*exploreOptionsInternal, error) { 72 | var opts exploreOptionsInternal 73 | if err := assignValuesFromArgs(args, exploreParseFunc, &opts, &opts.Globals); err != nil { 74 | return nil, err 75 | } 76 | 77 | return &opts, nil 78 | } 79 | 80 | type exploreGeneric interface { 81 | types.Destination 82 | } 83 | 84 | func queryExplore[T exploreGeneric](opts *exploreOptionsInternal) ([]T, *types.MetaData, error) { 85 | // EXISTING_CODE 86 | // EXISTING_CODE 87 | 88 | buffer := bytes.Buffer{} 89 | if err := opts.ExploreBytes(&buffer); err != nil { 90 | return nil, nil, err 91 | } 92 | 93 | str := buffer.String() 94 | // EXISTING_CODE 95 | // EXISTING_CODE 96 | 97 | var result Result[T] 98 | if err := json.Unmarshal([]byte(str), &result); err != nil { 99 | debugPrint(str, result, err) 100 | return nil, nil, err 101 | } else { 102 | return result.Data, &result.Meta, nil 103 | } 104 | } 105 | 106 | // toInternal converts the SDK options to the internal options format. 107 | func (opts *ExploreOptions) toInternal() *exploreOptionsInternal { 108 | return &exploreOptionsInternal{ 109 | Terms: opts.Terms, 110 | NoOpen: opts.NoOpen, 111 | Local: opts.Local, 112 | Google: opts.Google, 113 | Dalle: opts.Dalle, 114 | RenderCtx: opts.RenderCtx, 115 | Globals: opts.Globals, 116 | } 117 | } 118 | 119 | // EXISTING_CODE 120 | // EXISTING_CODE 121 | -------------------------------------------------------------------------------- /go.mod: -------------------------------------------------------------------------------- 1 | module github.com/TrueBlocks/trueblocks-sdk/v5 2 | 3 | // Go Version 4 | go 1.23.1 5 | 6 | require github.com/TrueBlocks/trueblocks-core/src/apps/chifra v0.0.0-20250522032357-ac554973976e 7 | 8 | require ( 9 | github.com/Microsoft/go-winio v0.6.2 // indirect 10 | github.com/alecthomas/participle/v2 v2.1.4 // indirect 11 | github.com/benbjohnson/clock v1.3.5 // indirect 12 | github.com/bits-and-blooms/bitset v1.22.0 // indirect 13 | github.com/blang/semver/v4 v4.0.0 // indirect 14 | github.com/bykof/gostradamus v1.1.2 // indirect 15 | github.com/consensys/bavard v0.1.30 // indirect 16 | github.com/consensys/gnark-crypto v0.17.0 // indirect 17 | github.com/crackcomm/go-gitignore v0.0.0-20241020182519-7843d2ba8fdf // indirect 18 | github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a // indirect 19 | github.com/crate-crypto/go-kzg-4844 v1.1.0 // indirect 20 | github.com/deckarep/golang-set/v2 v2.8.0 // indirect 21 | github.com/decred/dcrd/dcrec/secp256k1/v4 v4.4.0 // indirect 22 | github.com/dustin/go-humanize v1.0.1 // indirect 23 | github.com/ethereum/c-kzg-4844 v1.0.3 // indirect 24 | github.com/ethereum/go-ethereum v1.15.9 // indirect 25 | github.com/ethereum/go-verkle v0.2.2 // indirect 26 | github.com/fsnotify/fsnotify v1.9.0 // indirect 27 | github.com/go-ole/go-ole v1.3.0 // indirect 28 | github.com/gocarina/gocsv v0.0.0-20240520201108-78e41c74b4b1 // indirect 29 | github.com/google/uuid v1.6.0 // indirect 30 | github.com/gorilla/mux v1.8.1 // indirect 31 | github.com/gorilla/websocket v1.5.3 // indirect 32 | github.com/holiman/uint256 v1.3.2 // indirect 33 | github.com/inconshreveable/mousetrap v1.1.0 // indirect 34 | github.com/ipfs/boxo v0.29.1 // indirect 35 | github.com/ipfs/go-cid v0.5.0 // indirect 36 | github.com/ipfs/go-ipfs-api v0.7.0 // indirect 37 | github.com/klauspost/cpuid/v2 v2.2.10 // indirect 38 | github.com/libp2p/go-buffer-pool v0.1.0 // indirect 39 | github.com/libp2p/go-flow-metrics v0.2.0 // indirect 40 | github.com/libp2p/go-libp2p v0.41.1 // indirect 41 | github.com/minio/sha256-simd v1.0.1 // indirect 42 | github.com/mitchellh/go-homedir v1.1.0 // indirect 43 | github.com/mmcloughlin/addchain v0.4.0 // indirect 44 | github.com/mr-tron/base58 v1.2.0 // indirect 45 | github.com/multiformats/go-base32 v0.1.0 // indirect 46 | github.com/multiformats/go-base36 v0.2.0 // indirect 47 | github.com/multiformats/go-multiaddr v0.15.0 // indirect 48 | github.com/multiformats/go-multibase v0.2.0 // indirect 49 | github.com/multiformats/go-multicodec v0.9.0 // indirect 50 | github.com/multiformats/go-multihash v0.2.3 // indirect 51 | github.com/multiformats/go-multistream v0.6.0 // indirect 52 | github.com/multiformats/go-varint v0.0.7 // indirect 53 | github.com/panjf2000/ants/v2 v2.11.3 // indirect 54 | github.com/pelletier/go-toml/v2 v2.2.4 // indirect 55 | github.com/pkg/errors v0.9.1 // indirect 56 | github.com/shirou/gopsutil v3.21.11+incompatible // indirect 57 | github.com/spaolacci/murmur3 v1.1.0 // indirect 58 | github.com/spf13/cobra v1.9.1 // indirect 59 | github.com/spf13/pflag v1.0.6 // indirect 60 | github.com/supranational/blst v0.3.14 // indirect 61 | github.com/tklauser/go-sysconf v0.3.15 // indirect 62 | github.com/tklauser/numcpus v0.10.0 // indirect 63 | github.com/wealdtech/go-ens/v3 v3.6.0 // indirect 64 | github.com/wealdtech/go-multicodec v1.4.0 // indirect 65 | github.com/yusufpapurcu/wmi v1.2.4 // indirect 66 | golang.org/x/crypto v0.37.0 // indirect 67 | golang.org/x/exp v0.0.0-20250408133849-7e4ce0ab07d0 // indirect 68 | golang.org/x/net v0.39.0 // indirect 69 | golang.org/x/sync v0.13.0 // indirect 70 | golang.org/x/sys v0.32.0 // indirect 71 | golang.org/x/term v0.31.0 // indirect 72 | golang.org/x/text v0.24.0 // indirect 73 | golang.org/x/time v0.11.0 // indirect 74 | google.golang.org/protobuf v1.36.6 // indirect 75 | lukechampine.com/blake3 v1.4.1 // indirect 76 | rsc.io/tmplfunc v0.0.3 // indirect 77 | ) 78 | -------------------------------------------------------------------------------- /init.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 18 | // EXISTING_CODE 19 | ) 20 | 21 | type InitOptions struct { 22 | Publisher base.Address `json:"publisher,omitempty"` 23 | FirstBlock base.Blknum `json:"firstBlock,omitempty"` 24 | Sleep float64 `json:"sleep,omitempty"` 25 | RenderCtx *output.RenderCtx `json:"-"` 26 | Globals 27 | } 28 | 29 | // String implements the stringer interface 30 | func (opts InitOptions) String() string { 31 | bytes, _ := json.Marshal(opts) 32 | return string(bytes) 33 | } 34 | 35 | // InitAll implements the chifra init --all command. 36 | func (opts *InitOptions) InitAll() ([]types.Message, *types.MetaData, error) { 37 | in := opts.toInternal() 38 | in.All = true 39 | return queryInit[types.Message](in) 40 | } 41 | 42 | // InitExample implements the chifra init --example command. 43 | func (opts *InitOptions) InitExample(val string) ([]types.Message, *types.MetaData, error) { 44 | in := opts.toInternal() 45 | in.Example = val 46 | return queryInit[types.Message](in) 47 | } 48 | 49 | // InitDryRun implements the chifra init --dryrun command. 50 | func (opts *InitOptions) InitDryRun() ([]types.Message, *types.MetaData, error) { 51 | in := opts.toInternal() 52 | in.DryRun = true 53 | return queryInit[types.Message](in) 54 | } 55 | 56 | // No enums 57 | // EXISTING_CODE 58 | // Init implements the chifra init --all command. 59 | func (opts *InitOptions) Init() ([]types.Message, *types.MetaData, error) { 60 | in := opts.toInternal() 61 | return queryInit[types.Message](in) 62 | } 63 | 64 | // EXISTING_CODE 65 | -------------------------------------------------------------------------------- /init_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 20 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 21 | initPkg "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 22 | // EXISTING_CODE 23 | ) 24 | 25 | type initOptionsInternal struct { 26 | All bool `json:"all,omitempty"` 27 | Example string `json:"example,omitempty"` 28 | DryRun bool `json:"dryRun,omitempty"` 29 | Publisher base.Address `json:"publisher,omitempty"` 30 | FirstBlock base.Blknum `json:"firstBlock,omitempty"` 31 | Sleep float64 `json:"sleep,omitempty"` 32 | RenderCtx *output.RenderCtx `json:"-"` 33 | Globals 34 | } 35 | 36 | // String implements the stringer interface 37 | func (opts *initOptionsInternal) String() string { 38 | bytes, _ := json.Marshal(opts) 39 | return string(bytes) 40 | } 41 | 42 | // InitBytes implements the chifra init command for the SDK. 43 | func (opts *initOptionsInternal) InitBytes(w io.Writer) error { 44 | values, err := structToValues(*opts) 45 | if err != nil { 46 | return fmt.Errorf("error converting init struct to URL values: %v", err) 47 | } 48 | 49 | if opts.RenderCtx == nil { 50 | opts.RenderCtx = output.NewRenderContext() 51 | } 52 | return initPkg.Init(opts.RenderCtx, w, values) 53 | } 54 | 55 | // initParseFunc handles special cases such as structs and enums (if any). 56 | func initParseFunc(target any, key, value string) (bool, error) { 57 | _ = key 58 | _ = value 59 | var found bool 60 | _, ok := target.(*initOptionsInternal) 61 | if !ok { 62 | return false, fmt.Errorf("parseFunc(init): target is not of correct type") 63 | } 64 | 65 | // No enums 66 | // EXISTING_CODE 67 | // EXISTING_CODE 68 | 69 | return found, nil 70 | } 71 | 72 | // GetInitOptions returns a filled-in options instance given a string array of arguments. 73 | func GetInitOptions(args []string) (*initOptionsInternal, error) { 74 | var opts initOptionsInternal 75 | if err := assignValuesFromArgs(args, initParseFunc, &opts, &opts.Globals); err != nil { 76 | return nil, err 77 | } 78 | 79 | return &opts, nil 80 | } 81 | 82 | type initGeneric interface { 83 | types.Message 84 | } 85 | 86 | func queryInit[T initGeneric](opts *initOptionsInternal) ([]T, *types.MetaData, error) { 87 | // EXISTING_CODE 88 | // EXISTING_CODE 89 | 90 | buffer := bytes.Buffer{} 91 | if err := opts.InitBytes(&buffer); err != nil { 92 | return nil, nil, err 93 | } 94 | 95 | str := buffer.String() 96 | // EXISTING_CODE 97 | // EXISTING_CODE 98 | 99 | var result Result[T] 100 | if err := json.Unmarshal([]byte(str), &result); err != nil { 101 | debugPrint(str, result, err) 102 | return nil, nil, err 103 | } else { 104 | return result.Data, &result.Meta, nil 105 | } 106 | } 107 | 108 | // toInternal converts the SDK options to the internal options format. 109 | func (opts *InitOptions) toInternal() *initOptionsInternal { 110 | return &initOptionsInternal{ 111 | Publisher: opts.Publisher, 112 | FirstBlock: opts.FirstBlock, 113 | Sleep: opts.Sleep, 114 | RenderCtx: opts.RenderCtx, 115 | Globals: opts.Globals, 116 | } 117 | } 118 | 119 | // EXISTING_CODE 120 | // EXISTING_CODE 121 | -------------------------------------------------------------------------------- /list.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 18 | // EXISTING_CODE 19 | ) 20 | 21 | type ListOptions struct { 22 | Addrs []string `json:"addrs,omitempty"` 23 | NoZero bool `json:"noZero,omitempty"` 24 | Unripe bool `json:"unripe,omitempty"` 25 | Silent bool `json:"silent,omitempty"` 26 | FirstRecord uint64 `json:"firstRecord,omitempty"` 27 | MaxRecords uint64 `json:"maxRecords,omitempty"` 28 | Reversed bool `json:"reversed,omitempty"` 29 | Publisher base.Address `json:"publisher,omitempty"` 30 | FirstBlock base.Blknum `json:"firstBlock,omitempty"` 31 | LastBlock base.Blknum `json:"lastBlock,omitempty"` 32 | RenderCtx *output.RenderCtx `json:"-"` 33 | Globals 34 | } 35 | 36 | // String implements the stringer interface 37 | func (opts ListOptions) String() string { 38 | bytes, _ := json.Marshal(opts) 39 | return string(bytes) 40 | } 41 | 42 | // List implements the chifra list command. 43 | func (opts *ListOptions) List() ([]types.Appearance, *types.MetaData, error) { 44 | in := opts.toInternal() 45 | return queryList[types.Appearance](in) 46 | } 47 | 48 | // ListCount implements the chifra list --count command. 49 | func (opts *ListOptions) ListCount() ([]types.Monitor, *types.MetaData, error) { 50 | in := opts.toInternal() 51 | in.Count = true 52 | return queryList[types.Monitor](in) 53 | } 54 | 55 | // ListBounds implements the chifra list --bounds command. 56 | func (opts *ListOptions) ListBounds() ([]types.Bounds, *types.MetaData, error) { 57 | in := opts.toInternal() 58 | in.Bounds = true 59 | return queryList[types.Bounds](in) 60 | } 61 | 62 | // No enums 63 | // EXISTING_CODE 64 | // EXISTING_CODE 65 | -------------------------------------------------------------------------------- /logs.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 17 | // EXISTING_CODE 18 | ) 19 | 20 | type LogsOptions struct { 21 | TransactionIds []string `json:"transactions,omitempty"` 22 | Emitter []string `json:"emitter,omitempty"` 23 | Topic []string `json:"topic,omitempty"` 24 | Articulate bool `json:"articulate,omitempty"` 25 | RenderCtx *output.RenderCtx `json:"-"` 26 | Globals 27 | } 28 | 29 | // String implements the stringer interface 30 | func (opts LogsOptions) String() string { 31 | bytes, _ := json.Marshal(opts) 32 | return string(bytes) 33 | } 34 | 35 | // Logs implements the chifra logs command. 36 | func (opts *LogsOptions) Logs() ([]types.Log, *types.MetaData, error) { 37 | in := opts.toInternal() 38 | return queryLogs[types.Log](in) 39 | } 40 | 41 | // No enums 42 | // EXISTING_CODE 43 | // EXISTING_CODE 44 | -------------------------------------------------------------------------------- /logs_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 20 | logs "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 21 | // EXISTING_CODE 22 | ) 23 | 24 | type logsOptionsInternal struct { 25 | TransactionIds []string `json:"transactions,omitempty"` 26 | Emitter []string `json:"emitter,omitempty"` 27 | Topic []string `json:"topic,omitempty"` 28 | Articulate bool `json:"articulate,omitempty"` 29 | RenderCtx *output.RenderCtx `json:"-"` 30 | Globals 31 | } 32 | 33 | // String implements the stringer interface 34 | func (opts *logsOptionsInternal) String() string { 35 | bytes, _ := json.Marshal(opts) 36 | return string(bytes) 37 | } 38 | 39 | // LogsBytes implements the chifra logs command for the SDK. 40 | func (opts *logsOptionsInternal) LogsBytes(w io.Writer) error { 41 | values, err := structToValues(*opts) 42 | if err != nil { 43 | return fmt.Errorf("error converting logs struct to URL values: %v", err) 44 | } 45 | 46 | if opts.RenderCtx == nil { 47 | opts.RenderCtx = output.NewRenderContext() 48 | } 49 | return logs.Logs(opts.RenderCtx, w, values) 50 | } 51 | 52 | // logsParseFunc handles special cases such as structs and enums (if any). 53 | func logsParseFunc(target any, key, value string) (bool, error) { 54 | _ = key 55 | _ = value 56 | var found bool 57 | _, ok := target.(*logsOptionsInternal) 58 | if !ok { 59 | return false, fmt.Errorf("parseFunc(logs): target is not of correct type") 60 | } 61 | 62 | // No enums 63 | // EXISTING_CODE 64 | // EXISTING_CODE 65 | 66 | return found, nil 67 | } 68 | 69 | // GetLogsOptions returns a filled-in options instance given a string array of arguments. 70 | func GetLogsOptions(args []string) (*logsOptionsInternal, error) { 71 | var opts logsOptionsInternal 72 | if err := assignValuesFromArgs(args, logsParseFunc, &opts, &opts.Globals); err != nil { 73 | return nil, err 74 | } 75 | 76 | return &opts, nil 77 | } 78 | 79 | type logsGeneric interface { 80 | types.Log 81 | } 82 | 83 | func queryLogs[T logsGeneric](opts *logsOptionsInternal) ([]T, *types.MetaData, error) { 84 | // EXISTING_CODE 85 | // EXISTING_CODE 86 | 87 | buffer := bytes.Buffer{} 88 | if err := opts.LogsBytes(&buffer); err != nil { 89 | return nil, nil, err 90 | } 91 | 92 | str := buffer.String() 93 | // EXISTING_CODE 94 | str = convertObjectToArray("inputs", str) 95 | str = convertObjectToArray("outputs", str) 96 | // EXISTING_CODE 97 | 98 | var result Result[T] 99 | if err := json.Unmarshal([]byte(str), &result); err != nil { 100 | debugPrint(str, result, err) 101 | return nil, nil, err 102 | } else { 103 | return result.Data, &result.Meta, nil 104 | } 105 | } 106 | 107 | // toInternal converts the SDK options to the internal options format. 108 | func (opts *LogsOptions) toInternal() *logsOptionsInternal { 109 | return &logsOptionsInternal{ 110 | TransactionIds: opts.TransactionIds, 111 | Emitter: opts.Emitter, 112 | Topic: opts.Topic, 113 | Articulate: opts.Articulate, 114 | RenderCtx: opts.RenderCtx, 115 | Globals: opts.Globals, 116 | } 117 | } 118 | 119 | // EXISTING_CODE 120 | // EXISTING_CODE 121 | -------------------------------------------------------------------------------- /makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @cd ~/Development/trueblocks-core/build && make sdk 3 | @cd typescript && make 4 | @cd python && make 5 | 6 | publish: 7 | @cd typescript && yarn publish 8 | @cd python && make 9 | 10 | update: 11 | @go get github.com/TrueBlocks/trueblocks-core/src/apps/chifra@latest 12 | -------------------------------------------------------------------------------- /meta.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import ( 4 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 5 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 6 | ) 7 | 8 | func GetMetaData(chain string) (*types.MetaData, error) { 9 | unused := BlocksOptions{ 10 | BlockIds: []string{"1"}, 11 | Globals: Globals{Chain: chain}, 12 | } 13 | _, meta, err := unused.BlocksHashes() 14 | return meta, err 15 | } 16 | 17 | func MustGetMetaData(chain string) *types.MetaData { 18 | meta, _ := GetMetaData(chain) 19 | return meta 20 | } 21 | 22 | func GetLatestBlock(chain string) base.Blknum { 23 | meta, _ := GetMetaData(chain) 24 | return meta.Latest 25 | } 26 | -------------------------------------------------------------------------------- /monitors.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 17 | // EXISTING_CODE 18 | ) 19 | 20 | type MonitorsOptions struct { 21 | Addrs []string `json:"addrs,omitempty"` 22 | Delete bool `json:"delete,omitempty"` 23 | Undelete bool `json:"undelete,omitempty"` 24 | Remove bool `json:"remove,omitempty"` 25 | Staged bool `json:"staged,omitempty"` 26 | RenderCtx *output.RenderCtx `json:"-"` 27 | Globals 28 | } 29 | 30 | // String implements the stringer interface 31 | func (opts MonitorsOptions) String() string { 32 | bytes, _ := json.Marshal(opts) 33 | return string(bytes) 34 | } 35 | 36 | // Monitors implements the chifra monitors command. 37 | func (opts *MonitorsOptions) Monitors() ([]types.Message, *types.MetaData, error) { 38 | in := opts.toInternal() 39 | return queryMonitors[types.Message](in) 40 | } 41 | 42 | // MonitorsClean implements the chifra monitors --clean command. 43 | func (opts *MonitorsOptions) MonitorsClean() ([]types.MonitorClean, *types.MetaData, error) { 44 | in := opts.toInternal() 45 | in.Clean = true 46 | return queryMonitors[types.MonitorClean](in) 47 | } 48 | 49 | // MonitorsList implements the chifra monitors --list command. 50 | func (opts *MonitorsOptions) MonitorsList() ([]types.Monitor, *types.MetaData, error) { 51 | in := opts.toInternal() 52 | in.List = true 53 | return queryMonitors[types.Monitor](in) 54 | } 55 | 56 | // MonitorsCount implements the chifra monitors --count command. 57 | func (opts *MonitorsOptions) MonitorsCount() ([]types.Count, *types.MetaData, error) { 58 | in := opts.toInternal() 59 | in.Count = true 60 | return queryMonitors[types.Count](in) 61 | } 62 | 63 | // No enums 64 | // EXISTING_CODE 65 | // EXISTING_CODE 66 | -------------------------------------------------------------------------------- /monitors_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 20 | monitors "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 21 | // EXISTING_CODE 22 | ) 23 | 24 | type monitorsOptionsInternal struct { 25 | Addrs []string `json:"addrs,omitempty"` 26 | Delete bool `json:"delete,omitempty"` 27 | Undelete bool `json:"undelete,omitempty"` 28 | Remove bool `json:"remove,omitempty"` 29 | Clean bool `json:"clean,omitempty"` 30 | List bool `json:"list,omitempty"` 31 | Count bool `json:"count,omitempty"` 32 | Staged bool `json:"staged,omitempty"` 33 | RenderCtx *output.RenderCtx `json:"-"` 34 | Globals 35 | } 36 | 37 | // String implements the stringer interface 38 | func (opts *monitorsOptionsInternal) String() string { 39 | bytes, _ := json.Marshal(opts) 40 | return string(bytes) 41 | } 42 | 43 | // MonitorsBytes implements the chifra monitors command for the SDK. 44 | func (opts *monitorsOptionsInternal) MonitorsBytes(w io.Writer) error { 45 | values, err := structToValues(*opts) 46 | if err != nil { 47 | return fmt.Errorf("error converting monitors struct to URL values: %v", err) 48 | } 49 | 50 | if opts.RenderCtx == nil { 51 | opts.RenderCtx = output.NewRenderContext() 52 | } 53 | return monitors.Monitors(opts.RenderCtx, w, values) 54 | } 55 | 56 | // monitorsParseFunc handles special cases such as structs and enums (if any). 57 | func monitorsParseFunc(target any, key, value string) (bool, error) { 58 | _ = key 59 | _ = value 60 | var found bool 61 | _, ok := target.(*monitorsOptionsInternal) 62 | if !ok { 63 | return false, fmt.Errorf("parseFunc(monitors): target is not of correct type") 64 | } 65 | 66 | // No enums 67 | // EXISTING_CODE 68 | // EXISTING_CODE 69 | 70 | return found, nil 71 | } 72 | 73 | // GetMonitorsOptions returns a filled-in options instance given a string array of arguments. 74 | func GetMonitorsOptions(args []string) (*monitorsOptionsInternal, error) { 75 | var opts monitorsOptionsInternal 76 | if err := assignValuesFromArgs(args, monitorsParseFunc, &opts, &opts.Globals); err != nil { 77 | return nil, err 78 | } 79 | 80 | return &opts, nil 81 | } 82 | 83 | type monitorsGeneric interface { 84 | types.Message | 85 | types.MonitorClean | 86 | types.Monitor | 87 | types.Count 88 | } 89 | 90 | func queryMonitors[T monitorsGeneric](opts *monitorsOptionsInternal) ([]T, *types.MetaData, error) { 91 | // EXISTING_CODE 92 | // EXISTING_CODE 93 | 94 | buffer := bytes.Buffer{} 95 | if err := opts.MonitorsBytes(&buffer); err != nil { 96 | return nil, nil, err 97 | } 98 | 99 | str := buffer.String() 100 | // EXISTING_CODE 101 | // EXISTING_CODE 102 | 103 | var result Result[T] 104 | if err := json.Unmarshal([]byte(str), &result); err != nil { 105 | debugPrint(str, result, err) 106 | return nil, nil, err 107 | } else { 108 | return result.Data, &result.Meta, nil 109 | } 110 | } 111 | 112 | // toInternal converts the SDK options to the internal options format. 113 | func (opts *MonitorsOptions) toInternal() *monitorsOptionsInternal { 114 | return &monitorsOptionsInternal{ 115 | Addrs: opts.Addrs, 116 | Delete: opts.Delete, 117 | Undelete: opts.Undelete, 118 | Remove: opts.Remove, 119 | Staged: opts.Staged, 120 | RenderCtx: opts.RenderCtx, 121 | Globals: opts.Globals, 122 | } 123 | } 124 | 125 | // EXISTING_CODE 126 | // EXISTING_CODE 127 | -------------------------------------------------------------------------------- /python/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | # Contributor Code of Conduct 2 | 3 | ## Our Pledge 4 | 5 | In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. 6 | 7 | ## Our Standards 8 | 9 | Examples of behavior that contributes to creating a positive environment include: 10 | 11 | - Using welcoming and inclusive language 12 | - Being respectful of differing viewpoints and experiences 13 | - Gracefully accepting constructive criticism 14 | - Focusing on what is best for the community 15 | - Showing empathy towards other community members 16 | 17 | Examples of unacceptable behavior by participants include: 18 | 19 | - The use of sexualized language or imagery and unwelcome sexual attention or advances 20 | - Trolling, insulting/derogatory comments, and personal or political attacks 21 | - Public or private harassment 22 | - Publishing others' private information, such as a physical or electronic address, without explicit permission 23 | - Other conduct which could reasonably be considered inappropriate in a professional setting 24 | 25 | ## Our Responsibilities 26 | 27 | Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. 28 | 29 | Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. 30 | 31 | ## Scope 32 | 33 | This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. 34 | 35 | ## Enforcement 36 | 37 | Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at info@greathill.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. 38 | 39 | Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. 40 | 41 | ## Attribution 42 | 43 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] 44 | 45 | [homepage]: http://contributor-covenant.org 46 | [version]: http://contributor-covenant.org/version/1/4/ 47 | -------------------------------------------------------------------------------- /python/CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # How to contribute to TrueBlocks 2 | 3 | ## Commit and Branching Guidelines 4 | 5 | [Commit Message Guidelines](https://gist.github.com/robertpainsi/b632364184e70900af4ab688decf6f53) 6 | 7 | [Branching Conventions](https://github.com/TrueBlocks/trueblocks-core/blob/master/docs/BRANCHING.md) 8 | 9 | ## Did you find a bug? 10 | 11 | - **Do not open up a GitHub issue if the bug is a security vulnerability in TrueBlocks**. Contact through our website instead. 12 | - Search for previously reported [Issues](https://github.com/TrueBlocks/trueblocks-core/issues). If you find something, please add your comments. 13 | - If you don't find an existing issue, [open a new one](https://github.com/TrueBlocks/trueblocks-core/issues/new). 14 | 15 | ## Did you fix a bug? 16 | 17 | - Open a pull request with the patch. 18 | - Ensure the PR description clearly describes the problem and solution. Include the relevant issue number if applicable. 19 | - Before submitting, read [Contributing](http://github.com/TrueBlocks/trueblocks-core/CONTRIBUTING.md). Please use our coding and testing guidelines. 20 | 21 | ## Did you make a formatting or cosmetic change? 22 | 23 | - We use an automated formatters, therefore formatting-only changes will generally be closed without merging. 24 | 25 | ## Would do have a feature request? 26 | 27 | - Suggest your change by creating a [Feature Request](https://github.com/TrueBlocks/trueblocks-core/issues/new) and start writing code. 28 | 29 | ## Do you have questions about the source code? 30 | 31 | - Please join us in our [Discord server](https://discord.gg/zGh6PdN). 32 | 33 | Thanks! :heart: :heart: :heart: 34 | 35 | TrueBlocks Team 36 | -------------------------------------------------------------------------------- /python/README.md: -------------------------------------------------------------------------------- 1 | # TrueBlocks / Python SDK 2 | 3 | ## Introduction 4 | 5 | This is the Python SDK. 6 | -------------------------------------------------------------------------------- /python/chifra.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | import sys 4 | import pprint 5 | from src import chifra 6 | 7 | obj = chifra().dispatch() 8 | pprint.pprint(obj) 9 | -------------------------------------------------------------------------------- /python/makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @pwd 3 | -------------------------------------------------------------------------------- /python/requirements.txt: -------------------------------------------------------------------------------- 1 | requests==2.32.0 2 | vcrpy==4.2.1 3 | pytest==7.2.0 4 | -------------------------------------------------------------------------------- /python/src/__init__.py: -------------------------------------------------------------------------------- 1 | import os 2 | import requests 3 | import sys 4 | import logging 5 | 6 | session = requests.Session() 7 | session.params = {} 8 | 9 | class chifra(): 10 | def __init__(self): 11 | pass 12 | 13 | from ._usage import isValidCommand, usage 14 | from ._utils import toUrl 15 | 16 | from ._abis import abis 17 | from ._blocks import blocks 18 | from ._chunks import chunks 19 | from ._config import config 20 | # from ._daemon import daemon 21 | # from ._explore import explore 22 | from ._export import export 23 | from ._init import init 24 | from ._list import list 25 | from ._logs import logs 26 | from ._monitors import monitors 27 | from ._names import names 28 | from ._receipts import receipts 29 | from ._scrape import scrape 30 | from ._slurp import slurp 31 | from ._state import state 32 | from ._tokens import tokens 33 | from ._traces import traces 34 | from ._transactions import transactions 35 | from ._when import when 36 | 37 | def dispatch(self): 38 | # logging.getLogger().setLevel(logging.INFO) 39 | if self.isValidCommand() == False: 40 | self.usage("The first argument must be one of the valid commands.") 41 | 42 | response = "" 43 | match sys.argv[1]: 44 | case 'abis': 45 | return self.abis() 46 | case 'blocks': 47 | return self.blocks() 48 | case 'chunks': 49 | return self.chunks() 50 | case 'config': 51 | return self.config() 52 | case 'daemon': 53 | return self.daemon() 54 | case 'explore': 55 | return self.explore() 56 | case 'export': 57 | return self.export() 58 | case 'init': 59 | return self.init() 60 | case 'list': 61 | return self.list() 62 | case 'logs': 63 | return self.logs() 64 | case 'monitors': 65 | return self.monitors() 66 | case 'names': 67 | return self.names() 68 | case 'receipts': 69 | return self.receipts() 70 | case 'scrape': 71 | return self.scrape() 72 | case 'slurp': 73 | return self.slurp() 74 | case 'state': 75 | return self.state() 76 | case 'tokens': 77 | return self.tokens() 78 | case 'traces': 79 | return self.traces() 80 | case 'transactions': 81 | return self.transactions() 82 | case 'when': 83 | return self.when() 84 | 85 | def cmdLine(self): 86 | ret = "chifra" 87 | for i, arg in enumerate(sys.argv): 88 | if i > 0: 89 | ret += (" " + arg) 90 | return ret 91 | -------------------------------------------------------------------------------- /python/src/_abis.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | abisCmd = "abis" 12 | abisPos = "addrs" 13 | abisFmt = "json" 14 | abisOpts = { 15 | "known": {"hotkey": "-k", "type": "switch"}, 16 | "proxyFor": {"hotkey": "-r", "type": "flag"}, 17 | "list": {"hotkey": "-l", "type": "switch"}, 18 | "details": {"hotkey": "-d", "type": "switch"}, 19 | "count": {"hotkey": "-c", "type": "switch"}, 20 | "find": {"hotkey": "-f", "type": "flag"}, 21 | "hint": {"hotkey": "-n", "type": "flag"}, 22 | "encode": {"hotkey": "-e", "type": "flag"}, 23 | "chain": {"hotkey": "", "type": "flag"}, 24 | "noHeader": {"hotkey": "", "type": "switch"}, 25 | "cache": {"hotkey": "-o", "type": "switch"}, 26 | "decache": {"hotkey": "-D", "type": "switch"}, 27 | "fmt": {"hotkey": "-x", "type": "flag"}, 28 | } 29 | 30 | def abis(self): 31 | ret = self.toUrl(abisCmd, abisPos, abisFmt, abisOpts) 32 | url = 'http://localhost:8080/' + ret[1] 33 | if ret[0] == 'json': 34 | return session.get(url).json() 35 | return session.get(url).text 36 | -------------------------------------------------------------------------------- /python/src/_blocks.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | blocksCmd = "blocks" 12 | blocksPos = "blocks" 13 | blocksFmt = "json" 14 | blocksOpts = { 15 | "hashes": {"hotkey": "-e", "type": "switch"}, 16 | "uncles": {"hotkey": "-c", "type": "switch"}, 17 | "traces": {"hotkey": "-t", "type": "switch"}, 18 | "uniq": {"hotkey": "-u", "type": "switch"}, 19 | "flow": {"hotkey": "-f", "type": "flag"}, 20 | "logs": {"hotkey": "-l", "type": "switch"}, 21 | "emitter": {"hotkey": "-m", "type": "flag"}, 22 | "topic": {"hotkey": "-B", "type": "flag"}, 23 | "withdrawals": {"hotkey": "-i", "type": "switch"}, 24 | "articulate": {"hotkey": "-a", "type": "switch"}, 25 | "count": {"hotkey": "-U", "type": "switch"}, 26 | "cacheTxs": {"hotkey": "-X", "type": "switch"}, 27 | "cacheTraces": {"hotkey": "-R", "type": "switch"}, 28 | "chain": {"hotkey": "", "type": "flag"}, 29 | "noHeader": {"hotkey": "", "type": "switch"}, 30 | "cache": {"hotkey": "-o", "type": "switch"}, 31 | "decache": {"hotkey": "-D", "type": "switch"}, 32 | "ether": {"hotkey": "-H", "type": "switch"}, 33 | "fmt": {"hotkey": "-x", "type": "flag"}, 34 | } 35 | 36 | def blocks(self): 37 | ret = self.toUrl(blocksCmd, blocksPos, blocksFmt, blocksOpts) 38 | url = 'http://localhost:8080/' + ret[1] 39 | if ret[0] == 'json': 40 | return session.get(url).json() 41 | return session.get(url).text 42 | -------------------------------------------------------------------------------- /python/src/_chunks.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | chunksCmd = "chunks" 12 | chunksPos = "mode" 13 | chunksFmt = "json" 14 | chunksOpts = { 15 | "check": {"hotkey": "-c", "type": "switch"}, 16 | "pin": {"hotkey": "-i", "type": "switch"}, 17 | "publish": {"hotkey": "-p", "type": "switch"}, 18 | "remote": {"hotkey": "-r", "type": "switch"}, 19 | "belongs": {"hotkey": "-b", "type": "flag"}, 20 | "firstBlock": {"hotkey": "-F", "type": "flag"}, 21 | "lastBlock": {"hotkey": "-L", "type": "flag"}, 22 | "maxAddrs": {"hotkey": "-m", "type": "flag"}, 23 | "deep": {"hotkey": "-d", "type": "switch"}, 24 | "rewrite": {"hotkey": "-e", "type": "switch"}, 25 | "count": {"hotkey": "-U", "type": "switch"}, 26 | "sleep": {"hotkey": "-s", "type": "flag"}, 27 | "chain": {"hotkey": "", "type": "flag"}, 28 | "noHeader": {"hotkey": "", "type": "switch"}, 29 | "fmt": {"hotkey": "-x", "type": "flag"}, 30 | } 31 | 32 | def chunks(self): 33 | ret = self.toUrl(chunksCmd, chunksPos, chunksFmt, chunksOpts) 34 | url = 'http://localhost:8080/' + ret[1] 35 | if ret[0] == 'json': 36 | return session.get(url).json() 37 | return session.get(url).text 38 | -------------------------------------------------------------------------------- /python/src/_config.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | configCmd = "config" 12 | configPos = "mode" 13 | configFmt = "json" 14 | configOpts = { 15 | "paths": {"hotkey": "-a", "type": "switch"}, 16 | "dump": {"hotkey": "-d", "type": "switch"}, 17 | "chain": {"hotkey": "", "type": "flag"}, 18 | "noHeader": {"hotkey": "", "type": "switch"}, 19 | "fmt": {"hotkey": "-x", "type": "flag"}, 20 | } 21 | 22 | def config(self): 23 | ret = self.toUrl(configCmd, configPos, configFmt, configOpts) 24 | url = 'http://localhost:8080/' + ret[1] 25 | if ret[0] == 'json': 26 | return session.get(url).json() 27 | return session.get(url).text 28 | -------------------------------------------------------------------------------- /python/src/_export.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | exportCmd = "export" 12 | exportPos = "addrs" 13 | exportFmt = "json" 14 | exportOpts = { 15 | "appearances": {"hotkey": "-p", "type": "switch"}, 16 | "receipts": {"hotkey": "-r", "type": "switch"}, 17 | "logs": {"hotkey": "-l", "type": "switch"}, 18 | "traces": {"hotkey": "-t", "type": "switch"}, 19 | "neighbors": {"hotkey": "-n", "type": "switch"}, 20 | "statements": {"hotkey": "-A", "type": "switch"}, 21 | "transfers": {"hotkey": "-X", "type": "switch"}, 22 | "assets": {"hotkey": "-s", "type": "switch"}, 23 | "balances": {"hotkey": "-b", "type": "switch"}, 24 | "withdrawals": {"hotkey": "-i", "type": "switch"}, 25 | "articulate": {"hotkey": "-a", "type": "switch"}, 26 | "cacheTraces": {"hotkey": "-R", "type": "switch"}, 27 | "count": {"hotkey": "-U", "type": "switch"}, 28 | "firstRecord": {"hotkey": "-c", "type": "flag"}, 29 | "maxRecords": {"hotkey": "-e", "type": "flag"}, 30 | "relevant": {"hotkey": "-N", "type": "switch"}, 31 | "emitter": {"hotkey": "-m", "type": "flag"}, 32 | "topic": {"hotkey": "-B", "type": "flag"}, 33 | "nfts": {"hotkey": "-T", "type": "switch"}, 34 | "reverted": {"hotkey": "-V", "type": "switch"}, 35 | "asset": {"hotkey": "-P", "type": "flag"}, 36 | "flow": {"hotkey": "-f", "type": "flag"}, 37 | "factory": {"hotkey": "-y", "type": "switch"}, 38 | "unripe": {"hotkey": "-u", "type": "switch"}, 39 | "reversed": {"hotkey": "-E", "type": "switch"}, 40 | "noZero": {"hotkey": "-z", "type": "switch"}, 41 | "firstBlock": {"hotkey": "-F", "type": "flag"}, 42 | "lastBlock": {"hotkey": "-L", "type": "flag"}, 43 | "accounting": {"hotkey": "-C", "type": "switch"}, 44 | "chain": {"hotkey": "", "type": "flag"}, 45 | "noHeader": {"hotkey": "", "type": "switch"}, 46 | "cache": {"hotkey": "-o", "type": "switch"}, 47 | "decache": {"hotkey": "-D", "type": "switch"}, 48 | "ether": {"hotkey": "-H", "type": "switch"}, 49 | "fmt": {"hotkey": "-x", "type": "flag"}, 50 | } 51 | 52 | def export(self): 53 | ret = self.toUrl(exportCmd, exportPos, exportFmt, exportOpts) 54 | url = 'http://localhost:8080/' + ret[1] 55 | if ret[0] == 'json': 56 | return session.get(url).json() 57 | return session.get(url).text 58 | -------------------------------------------------------------------------------- /python/src/_init.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | initCmd = "init" 12 | initPos = "" 13 | initFmt = "json" 14 | initOpts = { 15 | "all": {"hotkey": "-a", "type": "switch"}, 16 | "example": {"hotkey": "-e", "type": "flag"}, 17 | "dryRun": {"hotkey": "-d", "type": "switch"}, 18 | "firstBlock": {"hotkey": "-F", "type": "flag"}, 19 | "sleep": {"hotkey": "-s", "type": "flag"}, 20 | "chain": {"hotkey": "", "type": "flag"}, 21 | } 22 | 23 | def init(self): 24 | ret = self.toUrl(initCmd, initPos, initFmt, initOpts) 25 | url = 'http://localhost:8080/' + ret[1] 26 | if ret[0] == 'json': 27 | return session.get(url).json() 28 | return session.get(url).text 29 | -------------------------------------------------------------------------------- /python/src/_list.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | listCmd = "list" 12 | listPos = "addrs" 13 | listFmt = "json" 14 | listOpts = { 15 | "count": {"hotkey": "-U", "type": "switch"}, 16 | "noZero": {"hotkey": "-z", "type": "switch"}, 17 | "bounds": {"hotkey": "-b", "type": "switch"}, 18 | "unripe": {"hotkey": "-u", "type": "switch"}, 19 | "silent": {"hotkey": "-s", "type": "switch"}, 20 | "firstRecord": {"hotkey": "-c", "type": "flag"}, 21 | "maxRecords": {"hotkey": "-e", "type": "flag"}, 22 | "reversed": {"hotkey": "-E", "type": "switch"}, 23 | "firstBlock": {"hotkey": "-F", "type": "flag"}, 24 | "lastBlock": {"hotkey": "-L", "type": "flag"}, 25 | "chain": {"hotkey": "", "type": "flag"}, 26 | "noHeader": {"hotkey": "", "type": "switch"}, 27 | "fmt": {"hotkey": "-x", "type": "flag"}, 28 | } 29 | 30 | def list(self): 31 | ret = self.toUrl(listCmd, listPos, listFmt, listOpts) 32 | url = 'http://localhost:8080/' + ret[1] 33 | if ret[0] == 'json': 34 | return session.get(url).json() 35 | return session.get(url).text 36 | -------------------------------------------------------------------------------- /python/src/_logs.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | logsCmd = "logs" 12 | logsPos = "transactions" 13 | logsFmt = "json" 14 | logsOpts = { 15 | "emitter": {"hotkey": "-m", "type": "flag"}, 16 | "topic": {"hotkey": "-B", "type": "flag"}, 17 | "articulate": {"hotkey": "-a", "type": "switch"}, 18 | "chain": {"hotkey": "", "type": "flag"}, 19 | "noHeader": {"hotkey": "", "type": "switch"}, 20 | "cache": {"hotkey": "-o", "type": "switch"}, 21 | "decache": {"hotkey": "-D", "type": "switch"}, 22 | "fmt": {"hotkey": "-x", "type": "flag"}, 23 | } 24 | 25 | def logs(self): 26 | ret = self.toUrl(logsCmd, logsPos, logsFmt, logsOpts) 27 | url = 'http://localhost:8080/' + ret[1] 28 | if ret[0] == 'json': 29 | return session.get(url).json() 30 | return session.get(url).text 31 | -------------------------------------------------------------------------------- /python/src/_monitors.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | monitorsCmd = "monitors" 12 | monitorsPos = "addrs" 13 | monitorsFmt = "json" 14 | monitorsOpts = { 15 | "delete": {"hotkey": "", "type": "switch"}, 16 | "undelete": {"hotkey": "", "type": "switch"}, 17 | "remove": {"hotkey": "", "type": "switch"}, 18 | "clean": {"hotkey": "-C", "type": "switch"}, 19 | "list": {"hotkey": "-l", "type": "switch"}, 20 | "count": {"hotkey": "-c", "type": "switch"}, 21 | "staged": {"hotkey": "-S", "type": "switch"}, 22 | "chain": {"hotkey": "", "type": "flag"}, 23 | "noHeader": {"hotkey": "", "type": "switch"}, 24 | "cache": {"hotkey": "-o", "type": "switch"}, 25 | "decache": {"hotkey": "-D", "type": "switch"}, 26 | "fmt": {"hotkey": "-x", "type": "flag"}, 27 | } 28 | 29 | def monitors(self): 30 | ret = self.toUrl(monitorsCmd, monitorsPos, monitorsFmt, monitorsOpts) 31 | url = 'http://localhost:8080/' + ret[1] 32 | if ret[0] == 'json': 33 | return session.get(url).json() 34 | return session.get(url).text 35 | -------------------------------------------------------------------------------- /python/src/_names.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | namesCmd = "names" 12 | namesPos = "terms" 13 | namesFmt = "json" 14 | namesOpts = { 15 | "expand": {"hotkey": "-e", "type": "switch"}, 16 | "matchCase": {"hotkey": "-m", "type": "switch"}, 17 | "all": {"hotkey": "-a", "type": "switch"}, 18 | "custom": {"hotkey": "-c", "type": "switch"}, 19 | "prefund": {"hotkey": "-p", "type": "switch"}, 20 | "addr": {"hotkey": "-s", "type": "switch"}, 21 | "tags": {"hotkey": "-g", "type": "switch"}, 22 | "clean": {"hotkey": "-C", "type": "switch"}, 23 | "regular": {"hotkey": "-r", "type": "switch"}, 24 | "dryRun": {"hotkey": "-d", "type": "switch"}, 25 | "autoname": {"hotkey": "-A", "type": "flag"}, 26 | "create": {"hotkey": "", "type": "switch"}, 27 | "update": {"hotkey": "", "type": "switch"}, 28 | "delete": {"hotkey": "", "type": "switch"}, 29 | "undelete": {"hotkey": "", "type": "switch"}, 30 | "remove": {"hotkey": "", "type": "switch"}, 31 | "chain": {"hotkey": "", "type": "flag"}, 32 | "noHeader": {"hotkey": "", "type": "switch"}, 33 | "fmt": {"hotkey": "-x", "type": "flag"}, 34 | } 35 | 36 | def names(self): 37 | ret = self.toUrl(namesCmd, namesPos, namesFmt, namesOpts) 38 | url = 'http://localhost:8080/' + ret[1] 39 | if ret[0] == 'json': 40 | return session.get(url).json() 41 | return session.get(url).text 42 | -------------------------------------------------------------------------------- /python/src/_receipts.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | receiptsCmd = "receipts" 12 | receiptsPos = "transactions" 13 | receiptsFmt = "json" 14 | receiptsOpts = { 15 | "articulate": {"hotkey": "-a", "type": "switch"}, 16 | "chain": {"hotkey": "", "type": "flag"}, 17 | "noHeader": {"hotkey": "", "type": "switch"}, 18 | "cache": {"hotkey": "-o", "type": "switch"}, 19 | "decache": {"hotkey": "-D", "type": "switch"}, 20 | "fmt": {"hotkey": "-x", "type": "flag"}, 21 | } 22 | 23 | def receipts(self): 24 | ret = self.toUrl(receiptsCmd, receiptsPos, receiptsFmt, receiptsOpts) 25 | url = 'http://localhost:8080/' + ret[1] 26 | if ret[0] == 'json': 27 | return session.get(url).json() 28 | return session.get(url).text 29 | -------------------------------------------------------------------------------- /python/src/_slurp.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | slurpCmd = "slurp" 12 | slurpPos = "addrs" 13 | slurpFmt = "json" 14 | slurpOpts = { 15 | "parts": {"hotkey": "-r", "type": "flag"}, 16 | "appearances": {"hotkey": "-p", "type": "switch"}, 17 | "articulate": {"hotkey": "-a", "type": "switch"}, 18 | "source": {"hotkey": "-S", "type": "flag"}, 19 | "count": {"hotkey": "-U", "type": "switch"}, 20 | "page": {"hotkey": "-g", "type": "flag"}, 21 | "pageId": {"hotkey": "", "type": "flag"}, 22 | "perPage": {"hotkey": "-P", "type": "flag"}, 23 | "sleep": {"hotkey": "-s", "type": "flag"}, 24 | "chain": {"hotkey": "", "type": "flag"}, 25 | "noHeader": {"hotkey": "", "type": "switch"}, 26 | "cache": {"hotkey": "-o", "type": "switch"}, 27 | "decache": {"hotkey": "-D", "type": "switch"}, 28 | "ether": {"hotkey": "-H", "type": "switch"}, 29 | "fmt": {"hotkey": "-x", "type": "flag"}, 30 | } 31 | 32 | def slurp(self): 33 | ret = self.toUrl(slurpCmd, slurpPos, slurpFmt, slurpOpts) 34 | url = 'http://localhost:8080/' + ret[1] 35 | if ret[0] == 'json': 36 | return session.get(url).json() 37 | return session.get(url).text 38 | -------------------------------------------------------------------------------- /python/src/_state.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | stateCmd = "state" 12 | statePos = "addrs" 13 | stateFmt = "json" 14 | stateOpts = { 15 | "parts": {"hotkey": "-p", "type": "flag"}, 16 | "changes": {"hotkey": "-c", "type": "switch"}, 17 | "noZero": {"hotkey": "-z", "type": "switch"}, 18 | "call": {"hotkey": "-l", "type": "switch"}, 19 | "calldata": {"hotkey": "-d", "type": "flag"}, 20 | "articulate": {"hotkey": "-a", "type": "switch"}, 21 | "proxyFor": {"hotkey": "-r", "type": "flag"}, 22 | "chain": {"hotkey": "", "type": "flag"}, 23 | "noHeader": {"hotkey": "", "type": "switch"}, 24 | "cache": {"hotkey": "-o", "type": "switch"}, 25 | "decache": {"hotkey": "-D", "type": "switch"}, 26 | "ether": {"hotkey": "-H", "type": "switch"}, 27 | "fmt": {"hotkey": "-x", "type": "flag"}, 28 | } 29 | 30 | def state(self): 31 | ret = self.toUrl(stateCmd, statePos, stateFmt, stateOpts) 32 | url = 'http://localhost:8080/' + ret[1] 33 | if ret[0] == 'json': 34 | return session.get(url).json() 35 | return session.get(url).text 36 | -------------------------------------------------------------------------------- /python/src/_status.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | statusCmd = "status" 12 | statusPos = "modes" 13 | statusFmt = "json" 14 | statusOpts = { 15 | "diagnose": {"hotkey": "-d", "type": "switch"}, 16 | "firstRecord": {"hotkey": "-c", "type": "flag"}, 17 | "maxRecords": {"hotkey": "-e", "type": "flag"}, 18 | "chains": {"hotkey": "-a", "type": "switch"}, 19 | "healthcheck": {"hotkey": "-k", "type": "switch"}, 20 | "chain": {"hotkey": "", "type": "flag"}, 21 | "noHeader": {"hotkey": "", "type": "switch"}, 22 | "fmt": {"hotkey": "-x", "type": "flag"}, 23 | } 24 | 25 | def status(self): 26 | ret = self.toUrl(statusCmd, statusPos, statusFmt, statusOpts) 27 | url = 'http://localhost:8080/' + ret[1] 28 | if ret[0] == 'json': 29 | return session.get(url).json() 30 | return session.get(url).text 31 | -------------------------------------------------------------------------------- /python/src/_tokens.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | tokensCmd = "tokens" 12 | tokensPos = "addrs" 13 | tokensFmt = "json" 14 | tokensOpts = { 15 | "parts": {"hotkey": "-p", "type": "flag"}, 16 | "byAcct": {"hotkey": "-b", "type": "switch"}, 17 | "changes": {"hotkey": "-c", "type": "switch"}, 18 | "noZero": {"hotkey": "-z", "type": "switch"}, 19 | "chain": {"hotkey": "", "type": "flag"}, 20 | "noHeader": {"hotkey": "", "type": "switch"}, 21 | "cache": {"hotkey": "-o", "type": "switch"}, 22 | "decache": {"hotkey": "-D", "type": "switch"}, 23 | "fmt": {"hotkey": "-x", "type": "flag"}, 24 | } 25 | 26 | def tokens(self): 27 | ret = self.toUrl(tokensCmd, tokensPos, tokensFmt, tokensOpts) 28 | url = 'http://localhost:8080/' + ret[1] 29 | if ret[0] == 'json': 30 | return session.get(url).json() 31 | return session.get(url).text 32 | -------------------------------------------------------------------------------- /python/src/_traces.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | tracesCmd = "traces" 12 | tracesPos = "transactions" 13 | tracesFmt = "json" 14 | tracesOpts = { 15 | "articulate": {"hotkey": "-a", "type": "switch"}, 16 | "filter": {"hotkey": "-f", "type": "flag"}, 17 | "count": {"hotkey": "-U", "type": "switch"}, 18 | "chain": {"hotkey": "", "type": "flag"}, 19 | "noHeader": {"hotkey": "", "type": "switch"}, 20 | "cache": {"hotkey": "-o", "type": "switch"}, 21 | "decache": {"hotkey": "-D", "type": "switch"}, 22 | "ether": {"hotkey": "-H", "type": "switch"}, 23 | "fmt": {"hotkey": "-x", "type": "flag"}, 24 | } 25 | 26 | def traces(self): 27 | ret = self.toUrl(tracesCmd, tracesPos, tracesFmt, tracesOpts) 28 | url = 'http://localhost:8080/' + ret[1] 29 | if ret[0] == 'json': 30 | return session.get(url).json() 31 | return session.get(url).text 32 | -------------------------------------------------------------------------------- /python/src/_transactions.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | transactionsCmd = "transactions" 12 | transactionsPos = "transactions" 13 | transactionsFmt = "json" 14 | transactionsOpts = { 15 | "articulate": {"hotkey": "-a", "type": "switch"}, 16 | "traces": {"hotkey": "-t", "type": "switch"}, 17 | "uniq": {"hotkey": "-u", "type": "switch"}, 18 | "flow": {"hotkey": "-f", "type": "flag"}, 19 | "logs": {"hotkey": "-l", "type": "switch"}, 20 | "emitter": {"hotkey": "-m", "type": "flag"}, 21 | "topic": {"hotkey": "-B", "type": "flag"}, 22 | "cacheTraces": {"hotkey": "-R", "type": "switch"}, 23 | "chain": {"hotkey": "", "type": "flag"}, 24 | "noHeader": {"hotkey": "", "type": "switch"}, 25 | "cache": {"hotkey": "-o", "type": "switch"}, 26 | "decache": {"hotkey": "-D", "type": "switch"}, 27 | "ether": {"hotkey": "-H", "type": "switch"}, 28 | "fmt": {"hotkey": "-x", "type": "flag"}, 29 | } 30 | 31 | def transactions(self): 32 | ret = self.toUrl(transactionsCmd, transactionsPos, transactionsFmt, transactionsOpts) 33 | url = 'http://localhost:8080/' + ret[1] 34 | if ret[0] == 'json': 35 | return session.get(url).json() 36 | return session.get(url).text 37 | -------------------------------------------------------------------------------- /python/src/_usage.py: -------------------------------------------------------------------------------- 1 | import sys, os 2 | 3 | from . import session 4 | 5 | def isValidCommand(self): 6 | if len(sys.argv) == 0: 7 | return False 8 | 9 | cmdMap = { 10 | "abis": True, 11 | "blocks": True, 12 | "chunks": True, 13 | "config": True, 14 | "daemon": True, 15 | "explore": True, 16 | "export": True, 17 | "init": True, 18 | "list": True, 19 | "logs": True, 20 | "monitors": True, 21 | "names": True, 22 | "receipts": True, 23 | "scrape": True, 24 | "slurp": True, 25 | "state": True, 26 | "tokens": True, 27 | "traces": True, 28 | "transactions": True, 29 | "when": True, 30 | } 31 | cmd = sys.argv[1] 32 | return cmd in cmdMap 33 | 34 | def usage(self, msg): 35 | print(msg) 36 | os.system("chifra --help") 37 | exit(1) -------------------------------------------------------------------------------- /python/src/_utils.py: -------------------------------------------------------------------------------- 1 | import os, sys, logging 2 | 3 | def toUrl(self, cmd, posName, defFmt, options): 4 | fmt = '' 5 | ret = '' 6 | skip = False 7 | for i, arg in enumerate(sys.argv): 8 | # logging.info("arg: " + arg) 9 | if i < 2: 10 | continue 11 | 12 | for key in options: 13 | if arg == options[key]["hotkey"]: 14 | arg = "--" + key 15 | 16 | if skip == True: 17 | skip = False 18 | continue 19 | 20 | val = '' 21 | option = arg.replace("-","") 22 | if option == "help": 23 | os.system("chifra " + cmd + " --help") 24 | 25 | # logging.info(option + ":") 26 | if options.keys().__contains__(option) == True: 27 | # logging.info(" hotKey: " + options[option]["hotkey"]) 28 | # logging.info(" type: " + options[option]["type"]) 29 | 30 | match options[option]["type"]: 31 | case 'switch': 32 | if len(ret) > 0: 33 | val += "&" 34 | val += option 35 | case 'flag': 36 | if len(sys.argv) > i+1: 37 | if len(ret) > 0: 38 | val += "&" 39 | val += arg.replace("-", "") + "=" + sys.argv[i+1] 40 | if option == "fmt": 41 | fmt = sys.argv[i+1] 42 | skip = True 43 | 44 | if val == "": 45 | if len(ret) > 0: 46 | val += "&" 47 | if arg.startswith("-") == True: 48 | val += arg.replace('-', '') 49 | else: 50 | val += posName + "=" + arg 51 | 52 | ret += val 53 | 54 | if fmt == '': 55 | fmt = defFmt 56 | if len(ret) > 0: 57 | ret += "&" 58 | ret += "fmt=" + fmt 59 | 60 | # logging.info("cmd: " + cmd) 61 | # logging.info("fmt: " + fmt) 62 | # logging.info("ret: " + ret) 63 | return fmt, cmd + "?" + ret 64 | -------------------------------------------------------------------------------- /python/src/_when.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | # Use of this source code is governed by a license that can 3 | # be found in the LICENSE file. 4 | 5 | """ 6 | This file was auto generated. DO NOT EDIT. 7 | """ 8 | 9 | from . import session 10 | 11 | whenCmd = "when" 12 | whenPos = "blocks" 13 | whenFmt = "json" 14 | whenOpts = { 15 | "list": {"hotkey": "-l", "type": "switch"}, 16 | "timestamps": {"hotkey": "-t", "type": "switch"}, 17 | "count": {"hotkey": "-U", "type": "switch"}, 18 | "repair": {"hotkey": "-r", "type": "switch"}, 19 | "check": {"hotkey": "-c", "type": "switch"}, 20 | "update": {"hotkey": "-u", "type": "switch"}, 21 | "deep": {"hotkey": "-d", "type": "switch"}, 22 | "chain": {"hotkey": "", "type": "flag"}, 23 | "noHeader": {"hotkey": "", "type": "switch"}, 24 | "cache": {"hotkey": "-o", "type": "switch"}, 25 | "decache": {"hotkey": "-D", "type": "switch"}, 26 | "fmt": {"hotkey": "-x", "type": "flag"}, 27 | } 28 | 29 | def when(self): 30 | ret = self.toUrl(whenCmd, whenPos, whenFmt, whenOpts) 31 | url = 'http://localhost:8080/' + ret[1] 32 | if ret[0] == 'json': 33 | return session.get(url).json() 34 | return session.get(url).text 35 | -------------------------------------------------------------------------------- /python/tests/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/TrueBlocks/trueblocks-sdk/14e0cc2d9f0d2a8eaa8482ba3da7c48a59a76419/python/tests/__init__.py -------------------------------------------------------------------------------- /python/tests/data/block.yml: -------------------------------------------------------------------------------- 1 | interactions: 2 | - request: 3 | body: null 4 | headers: 5 | Accept: 6 | - '*/*' 7 | Accept-Encoding: 8 | - gzip, deflate 9 | Connection: 10 | - keep-alive 11 | User-Agent: 12 | - python-requests/2.27.1 13 | method: GET 14 | uri: http://localhost:8080/blocks?blocks=1396 15 | response: 16 | body: 17 | string: "{ \"data\": [\n{\n \"gasLimit\": 5000,\n \"gasUsed\": 0,\n \"hash\": 18 | \"0xae3d243c312707a8ec19ed261161b55b81cc4b194aa0358d1f34eac2f8e004f8\",\n 19 | \ \"blockNumber\": 1396,\n \"parentHash\": \"0x39934ce035f203fa5eea208272716bbfdf4fb73f0128f20284365f123925fa7a\",\n 20 | \ \"miner\": \"0x9dfc0377058b7b9eb277421769b56df1395705f0\",\n \"difficulty\": 21 | 33729627254,\n \"finalized\": true,\n \"timestamp\": 1438272985,\n \"baseFeePerGas\": 22 | 0,\n \"transactions\": []\n}], \"meta\": {\"unripe\": 16037114,\"ripe\": 23 | 16037114,\"staging\": 16037114,\"finalized\": 16037114,\"client\": 16236032,\"chain\": 24 | \"mainnet\",\"clientId\": 1,\"networkId\": 1 } }" 25 | headers: 26 | Access-Control-Allow-Headers: 27 | - Origin, X-Requested-With, Content-Type, Accept 28 | Access-Control-Allow-Methods: 29 | - PUT, POST, GET, DELETE, OPTIONS 30 | Access-Control-Allow-Origin: 31 | - '*' 32 | Content-Length: 33 | - '577' 34 | Content-Type: 35 | - application/json; charset=UTF-8 36 | Date: 37 | - Wed, 21 Dec 2022 22:23:13 GMT 38 | status: 39 | code: 200 40 | message: OK 41 | version: 1 42 | -------------------------------------------------------------------------------- /python/tests/test_chifra.py: -------------------------------------------------------------------------------- 1 | import vcr 2 | from pytest import fixture 3 | from chifra import chifra 4 | 5 | @fixture 6 | def tv_keys(): 7 | # Responsible only for returning the test data 8 | return ['blockNumber', 'timestamp'] 9 | 10 | @vcr.use_cassette('tests/data/block.yml') 11 | def test_tv_info(tv_keys): 12 | """Tests an API call to get a TV show's info""" 13 | 14 | chifra = chifra(1396) 15 | response = chifra.info() 16 | 17 | assert isinstance(response, dict) 18 | assert response['id'] == 1396, "The ID should be in the response" 19 | assert set(tv_keys).issubset(response.keys()), "All keys should be in the response" 20 | 21 | @vcr.use_cassette('tests/data/when.yml') 22 | def test_tv_popular(tv_keys): 23 | """Tests an API call to get a popular tv shows""" 24 | 25 | response = chifra.blocks() 26 | 27 | assert isinstance(response, dict) 28 | assert isinstance(response['data'], list) 29 | assert isinstance(response['data'][0], dict) 30 | assert set(tv_keys).issubset(response['data'][0].keys()) 31 | -------------------------------------------------------------------------------- /receipts.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 17 | // EXISTING_CODE 18 | ) 19 | 20 | type ReceiptsOptions struct { 21 | TransactionIds []string `json:"transactions,omitempty"` 22 | Articulate bool `json:"articulate,omitempty"` 23 | RenderCtx *output.RenderCtx `json:"-"` 24 | Globals 25 | } 26 | 27 | // String implements the stringer interface 28 | func (opts ReceiptsOptions) String() string { 29 | bytes, _ := json.Marshal(opts) 30 | return string(bytes) 31 | } 32 | 33 | // Receipts implements the chifra receipts command. 34 | func (opts *ReceiptsOptions) Receipts() ([]types.Receipt, *types.MetaData, error) { 35 | in := opts.toInternal() 36 | return queryReceipts[types.Receipt](in) 37 | } 38 | 39 | // No enums 40 | // EXISTING_CODE 41 | // EXISTING_CODE 42 | -------------------------------------------------------------------------------- /receipts_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 20 | receipts "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 21 | // EXISTING_CODE 22 | ) 23 | 24 | type receiptsOptionsInternal struct { 25 | TransactionIds []string `json:"transactions,omitempty"` 26 | Articulate bool `json:"articulate,omitempty"` 27 | RenderCtx *output.RenderCtx `json:"-"` 28 | Globals 29 | } 30 | 31 | // String implements the stringer interface 32 | func (opts *receiptsOptionsInternal) String() string { 33 | bytes, _ := json.Marshal(opts) 34 | return string(bytes) 35 | } 36 | 37 | // ReceiptsBytes implements the chifra receipts command for the SDK. 38 | func (opts *receiptsOptionsInternal) ReceiptsBytes(w io.Writer) error { 39 | values, err := structToValues(*opts) 40 | if err != nil { 41 | return fmt.Errorf("error converting receipts struct to URL values: %v", err) 42 | } 43 | 44 | if opts.RenderCtx == nil { 45 | opts.RenderCtx = output.NewRenderContext() 46 | } 47 | return receipts.Receipts(opts.RenderCtx, w, values) 48 | } 49 | 50 | // receiptsParseFunc handles special cases such as structs and enums (if any). 51 | func receiptsParseFunc(target any, key, value string) (bool, error) { 52 | _ = key 53 | _ = value 54 | var found bool 55 | _, ok := target.(*receiptsOptionsInternal) 56 | if !ok { 57 | return false, fmt.Errorf("parseFunc(receipts): target is not of correct type") 58 | } 59 | 60 | // No enums 61 | // EXISTING_CODE 62 | // EXISTING_CODE 63 | 64 | return found, nil 65 | } 66 | 67 | // GetReceiptsOptions returns a filled-in options instance given a string array of arguments. 68 | func GetReceiptsOptions(args []string) (*receiptsOptionsInternal, error) { 69 | var opts receiptsOptionsInternal 70 | if err := assignValuesFromArgs(args, receiptsParseFunc, &opts, &opts.Globals); err != nil { 71 | return nil, err 72 | } 73 | 74 | return &opts, nil 75 | } 76 | 77 | type receiptsGeneric interface { 78 | types.Receipt 79 | } 80 | 81 | func queryReceipts[T receiptsGeneric](opts *receiptsOptionsInternal) ([]T, *types.MetaData, error) { 82 | // EXISTING_CODE 83 | // EXISTING_CODE 84 | 85 | buffer := bytes.Buffer{} 86 | if err := opts.ReceiptsBytes(&buffer); err != nil { 87 | return nil, nil, err 88 | } 89 | 90 | str := buffer.String() 91 | // EXISTING_CODE 92 | str = convertObjectToArray("inputs", str) 93 | str = convertObjectToArray("outputs", str) 94 | str = convertEmptyStrToZero("status", str) 95 | // EXISTING_CODE 96 | 97 | var result Result[T] 98 | if err := json.Unmarshal([]byte(str), &result); err != nil { 99 | debugPrint(str, result, err) 100 | return nil, nil, err 101 | } else { 102 | return result.Data, &result.Meta, nil 103 | } 104 | } 105 | 106 | // toInternal converts the SDK options to the internal options format. 107 | func (opts *ReceiptsOptions) toInternal() *receiptsOptionsInternal { 108 | return &receiptsOptionsInternal{ 109 | TransactionIds: opts.TransactionIds, 110 | Articulate: opts.Articulate, 111 | RenderCtx: opts.RenderCtx, 112 | Globals: opts.Globals, 113 | } 114 | } 115 | 116 | // EXISTING_CODE 117 | // EXISTING_CODE 118 | -------------------------------------------------------------------------------- /result.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 4 | 5 | type Result[T any] struct { 6 | Data []T `json:"data"` 7 | Meta types.MetaData `json:"meta"` 8 | } 9 | -------------------------------------------------------------------------------- /rpc.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/rpc" 4 | 5 | func PingRpc(providerUrl string) error { 6 | return rpc.PingRpc(providerUrl) 7 | } 8 | -------------------------------------------------------------------------------- /scrape.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 18 | // EXISTING_CODE 19 | ) 20 | 21 | type ScrapeOptions struct { 22 | BlockCnt uint64 `json:"blockCnt,omitempty"` 23 | Sleep float64 `json:"sleep,omitempty"` 24 | Publisher base.Address `json:"publisher,omitempty"` 25 | Notify bool `json:"notify,omitempty"` 26 | RenderCtx *output.RenderCtx `json:"-"` 27 | Globals 28 | } 29 | 30 | // String implements the stringer interface 31 | func (opts ScrapeOptions) String() string { 32 | bytes, _ := json.Marshal(opts) 33 | return string(bytes) 34 | } 35 | 36 | // ScrapeTouch implements the chifra scrape --touch command. 37 | func (opts *ScrapeOptions) ScrapeTouch(val base.Blknum) ([]types.Message, *types.MetaData, error) { 38 | in := opts.toInternal() 39 | in.Touch = val 40 | return queryScrape[types.Message](in) 41 | } 42 | 43 | // ScrapeRunCount implements the chifra scrape --runcount command. 44 | func (opts *ScrapeOptions) ScrapeRunCount(val uint64) ([]types.Message, *types.MetaData, error) { 45 | in := opts.toInternal() 46 | in.RunCount = val 47 | return queryScrape[types.Message](in) 48 | } 49 | 50 | // ScrapeDryRun implements the chifra scrape --dryrun command. 51 | func (opts *ScrapeOptions) ScrapeDryRun() ([]types.Message, *types.MetaData, error) { 52 | in := opts.toInternal() 53 | in.DryRun = true 54 | return queryScrape[types.Message](in) 55 | } 56 | 57 | // No enums 58 | // EXISTING_CODE 59 | func (opts *ScrapeOptions) ScrapeRunOnce() ([]types.Message, *types.MetaData, error) { 60 | return opts.ScrapeRunCount(1) 61 | } 62 | 63 | // EXISTING_CODE 64 | -------------------------------------------------------------------------------- /scrape_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 20 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 21 | scrape "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 22 | // EXISTING_CODE 23 | ) 24 | 25 | type scrapeOptionsInternal struct { 26 | BlockCnt uint64 `json:"blockCnt,omitempty"` 27 | Sleep float64 `json:"sleep,omitempty"` 28 | Publisher base.Address `json:"publisher,omitempty"` 29 | Touch base.Blknum `json:"touch,omitempty"` 30 | RunCount uint64 `json:"runCount,omitempty"` 31 | DryRun bool `json:"dryRun,omitempty"` 32 | Notify bool `json:"notify,omitempty"` 33 | RenderCtx *output.RenderCtx `json:"-"` 34 | Globals 35 | } 36 | 37 | // String implements the stringer interface 38 | func (opts *scrapeOptionsInternal) String() string { 39 | bytes, _ := json.Marshal(opts) 40 | return string(bytes) 41 | } 42 | 43 | // ScrapeBytes implements the chifra scrape command for the SDK. 44 | func (opts *scrapeOptionsInternal) ScrapeBytes(w io.Writer) error { 45 | values, err := structToValues(*opts) 46 | if err != nil { 47 | return fmt.Errorf("error converting scrape struct to URL values: %v", err) 48 | } 49 | 50 | if opts.RenderCtx == nil { 51 | opts.RenderCtx = output.NewRenderContext() 52 | } 53 | return scrape.Scrape(opts.RenderCtx, w, values) 54 | } 55 | 56 | // scrapeParseFunc handles special cases such as structs and enums (if any). 57 | func scrapeParseFunc(target any, key, value string) (bool, error) { 58 | _ = key 59 | _ = value 60 | var found bool 61 | _, ok := target.(*scrapeOptionsInternal) 62 | if !ok { 63 | return false, fmt.Errorf("parseFunc(scrape): target is not of correct type") 64 | } 65 | 66 | // No enums 67 | // EXISTING_CODE 68 | // EXISTING_CODE 69 | 70 | return found, nil 71 | } 72 | 73 | // GetScrapeOptions returns a filled-in options instance given a string array of arguments. 74 | func GetScrapeOptions(args []string) (*scrapeOptionsInternal, error) { 75 | var opts scrapeOptionsInternal 76 | if err := assignValuesFromArgs(args, scrapeParseFunc, &opts, &opts.Globals); err != nil { 77 | return nil, err 78 | } 79 | 80 | return &opts, nil 81 | } 82 | 83 | type scrapeGeneric interface { 84 | types.Message 85 | } 86 | 87 | func queryScrape[T scrapeGeneric](opts *scrapeOptionsInternal) ([]T, *types.MetaData, error) { 88 | // EXISTING_CODE 89 | // EXISTING_CODE 90 | 91 | buffer := bytes.Buffer{} 92 | if err := opts.ScrapeBytes(&buffer); err != nil { 93 | return nil, nil, err 94 | } 95 | 96 | str := buffer.String() 97 | // EXISTING_CODE 98 | // EXISTING_CODE 99 | 100 | var result Result[T] 101 | if err := json.Unmarshal([]byte(str), &result); err != nil { 102 | debugPrint(str, result, err) 103 | return nil, nil, err 104 | } else { 105 | return result.Data, &result.Meta, nil 106 | } 107 | } 108 | 109 | // toInternal converts the SDK options to the internal options format. 110 | func (opts *ScrapeOptions) toInternal() *scrapeOptionsInternal { 111 | return &scrapeOptionsInternal{ 112 | BlockCnt: opts.BlockCnt, 113 | Sleep: opts.Sleep, 114 | Publisher: opts.Publisher, 115 | Notify: opts.Notify, 116 | RenderCtx: opts.RenderCtx, 117 | Globals: opts.Globals, 118 | } 119 | } 120 | 121 | // EXISTING_CODE 122 | // EXISTING_CODE 123 | -------------------------------------------------------------------------------- /services/service.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "io" 5 | "log/slog" 6 | "net" 7 | "os" 8 | "strings" 9 | "time" 10 | ) 11 | 12 | type Servicer interface { 13 | Name() string 14 | Initialize() error 15 | Process(chan bool) error 16 | Cleanup() 17 | Logger() *slog.Logger 18 | } 19 | 20 | type Pauser interface { 21 | Servicer 22 | IsPaused() bool 23 | Pause() bool 24 | Unpause() bool 25 | } 26 | 27 | type ChildManager interface { 28 | Pauser 29 | HasChild() bool 30 | KillChild() bool 31 | RestartChild() bool 32 | } 33 | 34 | func StartService(svc Servicer, stopChan chan os.Signal) { 35 | go func() { 36 | logger := initializeLogger(svc.Logger()) 37 | logger.Info("Starting service", "name", svc.Name()) 38 | 39 | if err := svc.Initialize(); err != nil { 40 | logger.Error("Service initialization failed", "name", svc.Name(), "error", err) 41 | return 42 | } 43 | 44 | ready := make(chan bool) 45 | 46 | go func() { 47 | if err := svc.Process(ready); err != nil { 48 | logger.Error("Service process failed", "name", svc.Name(), "error", err) 49 | } 50 | }() 51 | 52 | readySignal := <-ready 53 | if !readySignal { 54 | logger.Error("Service did not start properly", "name", svc.Name()) 55 | return 56 | } 57 | 58 | logger.Info("Service started successfully", "name", svc.Name()) 59 | 60 | cleanupDone := make(chan bool, 1) 61 | handleSignals(svc, stopChan, cleanupDone) 62 | }() 63 | } 64 | 65 | func handleSignals(svc Servicer, stopChan chan os.Signal, cleanupDone chan bool) { 66 | logger := svc.Logger() 67 | firstSignal := true 68 | for { 69 | sig := <-stopChan 70 | logger.Info("Signal received", "signal", sig, "name", svc.Name()) 71 | if firstSignal { 72 | logger.Info("First signal received, initiating cleanup", "signal", sig, "name", svc.Name()) 73 | firstSignal = false 74 | go func() { 75 | svc.Cleanup() 76 | logger.Info("Cleanup completed", "name", svc.Name()) 77 | cleanupDone <- true 78 | }() 79 | <-cleanupDone 80 | logger.Info("Exiting gracefully after cleanup", "name", svc.Name()) 81 | os.Exit(0) 82 | } else { 83 | logger.Warn("Additional signal received during cleanup. Ignoring.", "signal", sig, "name", svc.Name()) 84 | } 85 | } 86 | } 87 | 88 | func initializeLogger(logger *slog.Logger) *slog.Logger { 89 | if logger == nil { 90 | return slog.New(slog.NewTextHandler(io.Discard, nil)) 91 | } 92 | return logger 93 | } 94 | 95 | func getApiUrl() string { 96 | apiPort := strings.ReplaceAll(os.Getenv("TB_API_PORT"), ":", "") 97 | if apiPort == "" { 98 | apiPort = findAvailablePort([]string{"8080", "8088", "9090", "9099"}) 99 | } 100 | return "localhost:" + apiPort 101 | } 102 | 103 | func findAvailablePort(preferred []string) string { 104 | for _, port := range preferred { 105 | if !isPortAvailable(port) { 106 | continue 107 | } 108 | return port 109 | } 110 | return "0" 111 | } 112 | 113 | var isPortAvailable = func(port string) bool { 114 | conn, err := net.DialTimeout("tcp", net.JoinHostPort("127.0.0.1", port), 2*time.Second) 115 | if err != nil { 116 | return true 117 | } 118 | conn.Close() 119 | return false 120 | } 121 | -------------------------------------------------------------------------------- /services/service_api.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "bytes" 5 | "context" 6 | "log/slog" 7 | 8 | sdk "github.com/TrueBlocks/trueblocks-sdk/v5" 9 | ) 10 | 11 | type ApiService struct { 12 | logger *slog.Logger 13 | apiUrl string 14 | ctx context.Context 15 | cancel context.CancelFunc 16 | } 17 | 18 | func NewApiService(logger *slog.Logger) *ApiService { 19 | ctx, cancel := context.WithCancel(context.Background()) 20 | return &ApiService{ 21 | logger: initializeLogger(logger), 22 | ctx: ctx, 23 | cancel: cancel, 24 | } 25 | } 26 | 27 | func (s *ApiService) Name() string { 28 | return "api" 29 | } 30 | 31 | func (s *ApiService) Initialize() error { 32 | s.apiUrl = getApiUrl() 33 | s.logger.Info("API service initialized.", "url", s.apiUrl) 34 | return nil 35 | } 36 | 37 | func (s *ApiService) Process(ready chan bool) error { 38 | s.logger.Info("API service Process() invoked.") 39 | 40 | go func() { 41 | ready <- true 42 | opts := sdk.DaemonOptions{ 43 | Silent: true, 44 | Url: s.apiUrl, 45 | } 46 | in := opts.ToInternal() 47 | 48 | daemonDone := make(chan error, 1) 49 | 50 | go func() { 51 | buffer := bytes.Buffer{} 52 | err := in.DaemonBytes(&buffer) 53 | if err != nil { 54 | s.logger.Error("Error running DaemonBytes", "error", err) 55 | } 56 | daemonDone <- err 57 | }() 58 | 59 | s.logger.Info("API service process running.") 60 | 61 | select { 62 | case <-s.ctx.Done(): 63 | s.logger.Info("API service process stopping due to context cancellation.") 64 | case err := <-daemonDone: 65 | s.logger.Error("DaemonBytes exited unexpectedly", "error", err) 66 | } 67 | }() 68 | 69 | return nil 70 | } 71 | 72 | func (s *ApiService) Cleanup() { 73 | s.logger.Info("API service cleanup started.") 74 | s.cancel() // Cancel the context to signal shutdown 75 | // for i := 0; i < 5; i++ { 76 | // s.logger.Info("Api service cleanup in progress.", "i", i) 77 | // time.Sleep(1 * time.Second) 78 | // } 79 | s.logger.Info("API service cleanup complete.") 80 | } 81 | 82 | func (s *ApiService) Logger() *slog.Logger { 83 | return s.logger 84 | } 85 | 86 | func (s *ApiService) ApiUrl() string { 87 | return s.apiUrl 88 | } 89 | -------------------------------------------------------------------------------- /services/service_control.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "context" 5 | "encoding/json" 6 | "log/slog" 7 | "net/http" 8 | ) 9 | 10 | type ControlService struct { 11 | logger *slog.Logger 12 | manager *ServiceManager 13 | server *http.Server 14 | listenAddr string 15 | port string 16 | ctx context.Context 17 | cancel context.CancelFunc 18 | } 19 | 20 | func NewControlService(logger *slog.Logger) *ControlService { 21 | port := findAvailablePort([]string{"8338", "8337", "8336", "8335"}) 22 | ctx, cancel := context.WithCancel(context.Background()) 23 | return &ControlService{ 24 | manager: nil, 25 | logger: logger, 26 | port: port, 27 | listenAddr: ":" + port, 28 | ctx: ctx, 29 | cancel: cancel, 30 | } 31 | } 32 | 33 | func (s *ControlService) Name() string { 34 | return "control" 35 | } 36 | 37 | func (s *ControlService) AttachServiceManager(manager *ServiceManager) { 38 | s.manager = manager 39 | } 40 | 41 | func (s *ControlService) Initialize() error { 42 | mux := http.NewServeMux() 43 | mux.HandleFunc("/status", s.handleIsPaused) 44 | mux.HandleFunc("/isPaused", s.handleIsPaused) 45 | mux.HandleFunc("/pause", s.handlePause) 46 | mux.HandleFunc("/unpause", s.handleUnpause) 47 | mux.HandleFunc("/", s.handleDefault) 48 | 49 | s.server = &http.Server{ 50 | Addr: s.listenAddr, 51 | Handler: mux, 52 | } 53 | 54 | return nil 55 | } 56 | 57 | func (s *ControlService) Process(ready chan bool) error { 58 | ready <- true 59 | 60 | s.logger.Info("Control Service starting", "address", s.listenAddr) 61 | if err := s.server.ListenAndServe(); err != nil && err != http.ErrServerClosed { 62 | return err 63 | } 64 | 65 | return nil 66 | } 67 | 68 | func (s *ControlService) Cleanup() { 69 | s.cancel() 70 | if s.server != nil { 71 | s.server.Close() 72 | } 73 | } 74 | 75 | func (s *ControlService) Logger() *slog.Logger { 76 | return s.logger 77 | } 78 | 79 | func (s *ControlService) handleDefault(w http.ResponseWriter, r *http.Request) { 80 | _ = r 81 | results := map[string]string{ 82 | "/status": "[name]", 83 | "/isPaused": "name", 84 | "/pause": "name", 85 | "/unpause": "name", 86 | } 87 | writeJSONResponse(w, results) 88 | } 89 | 90 | func (s *ControlService) handleIsPaused(w http.ResponseWriter, r *http.Request) { 91 | name := r.URL.Query().Get("name") 92 | results, err := s.manager.IsPaused(name) 93 | if err != nil { 94 | writeJSONErrorResponse(w, err.Error(), http.StatusBadRequest) 95 | return 96 | } 97 | writeJSONResponse(w, results) 98 | } 99 | 100 | func (s *ControlService) handlePause(w http.ResponseWriter, r *http.Request) { 101 | name := r.URL.Query().Get("name") 102 | results, err := s.manager.Pause(name) 103 | if err != nil { 104 | writeJSONErrorResponse(w, err.Error(), http.StatusBadRequest) 105 | return 106 | } 107 | writeJSONResponse(w, results) 108 | } 109 | 110 | func (s *ControlService) handleUnpause(w http.ResponseWriter, r *http.Request) { 111 | name := r.URL.Query().Get("name") 112 | results, err := s.manager.Unpause(name) 113 | if err != nil { 114 | writeJSONErrorResponse(w, err.Error(), http.StatusBadRequest) 115 | return 116 | } 117 | writeJSONResponse(w, results) 118 | } 119 | 120 | func writeJSONResponse(w http.ResponseWriter, data interface{}) { 121 | w.Header().Set("Content-Type", "application/json") 122 | _ = json.NewEncoder(w).Encode(data) 123 | } 124 | 125 | func writeJSONErrorResponse(w http.ResponseWriter, message string, status int) { 126 | w.Header().Set("Content-Type", "application/json") 127 | w.WriteHeader(status) 128 | _ = json.NewEncoder(w).Encode(map[string]string{"error": message}) 129 | } 130 | -------------------------------------------------------------------------------- /services/service_monitor.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "context" 5 | "log/slog" 6 | "strings" 7 | "time" 8 | ) 9 | 10 | type MonitorService struct { 11 | paused bool 12 | logger *slog.Logger 13 | ctx context.Context 14 | cancel context.CancelFunc 15 | } 16 | 17 | func NewMonitorService(logger *slog.Logger) *MonitorService { 18 | ctx, cancel := context.WithCancel(context.Background()) 19 | return &MonitorService{ 20 | logger: initializeLogger(logger), 21 | ctx: ctx, 22 | cancel: cancel, 23 | } 24 | } 25 | 26 | func (s *MonitorService) Name() string { 27 | return "monitor" 28 | } 29 | 30 | func (s *MonitorService) Initialize() error { 31 | s.logger.Info("Monitor service initialized.") 32 | return nil 33 | } 34 | 35 | func (s *MonitorService) Process(ready chan bool) error { 36 | s.logger.Info("Monitor service Process() invoked.") 37 | go func() { 38 | ready <- true 39 | for { 40 | select { 41 | case <-s.ctx.Done(): 42 | s.logger.Info("Monitor loop stopping.") 43 | return 44 | default: 45 | if s.IsPaused() { 46 | time.Sleep(1 * time.Second) 47 | continue 48 | } 49 | s.logger.Info("Monitor loop running." + strings.Repeat(" ", 80)) 50 | time.Sleep(3 * time.Second) 51 | } 52 | } 53 | }() 54 | return nil 55 | } 56 | 57 | func (s *MonitorService) IsPaused() bool { 58 | return s.paused 59 | } 60 | 61 | func (s *MonitorService) Pause() bool { 62 | s.paused = true 63 | return s.paused 64 | } 65 | 66 | func (s *MonitorService) Unpause() bool { 67 | s.paused = false 68 | return s.paused 69 | } 70 | 71 | func (s *MonitorService) Cleanup() { 72 | s.logger.Info("Monitor service cleanup started.") 73 | s.cancel() 74 | if !s.IsPaused() { 75 | for i := 0; i < 5; i++ { 76 | s.logger.Info("Monitor service cleanup in progress.", "i", i) 77 | time.Sleep(1 * time.Second) 78 | } 79 | } 80 | s.logger.Info("Monitor service cleanup complete.") 81 | } 82 | 83 | func (s *MonitorService) Logger() *slog.Logger { 84 | return s.logger 85 | } 86 | -------------------------------------------------------------------------------- /services/service_scraper_report.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "encoding/json" 5 | "fmt" 6 | "log/slog" 7 | "time" 8 | 9 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 10 | ) 11 | 12 | func reportScrape(logger *slog.Logger, report *scraperReport) { 13 | msg := fmt.Sprintf("behind (% 10.10s)...", report.Chain) 14 | if report.Staged < 30 { 15 | msg = fmt.Sprintf("atHead (% 10.10s)...", report.Chain) 16 | } 17 | logger.Info(msg, 18 | "head", report.Head, 19 | "unripe", -report.Unripe, 20 | "staged", -report.Staged, 21 | "finalized", -report.Finalized, 22 | "blockCnt", report.BlockCnt) 23 | } 24 | 25 | type scraperReport struct { 26 | Chain string `json:"chain"` 27 | BlockCnt int `json:"blockCnt"` 28 | Head int `json:"head"` 29 | Unripe int `json:"unripe"` 30 | Staged int `json:"staged"` 31 | Finalized int `json:"finalized"` 32 | Time string `json:"time"` 33 | } 34 | 35 | func (r *scraperReport) String() string { 36 | bytes, _ := json.Marshal(r) 37 | return string(bytes) 38 | } 39 | 40 | func reportScrapeRun(meta *types.MetaData, chain string, blockCnt int) *scraperReport { 41 | return &scraperReport{ 42 | Chain: chain, 43 | BlockCnt: blockCnt, 44 | Head: int(meta.Latest), 45 | Unripe: int(meta.Latest) - int(meta.Unripe), 46 | Staged: int(meta.Latest) - int(meta.Staging), 47 | Finalized: int(meta.Latest) - int(meta.Finalized), 48 | Time: time.Now().Format("01-02 15:04:05"), 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /services/service_test.go: -------------------------------------------------------------------------------- 1 | package services 2 | 3 | import ( 4 | "testing" 5 | ) 6 | 7 | func TestApiServiceInitialize(t *testing.T) { 8 | svc := NewApiService(nil) 9 | 10 | err := svc.Initialize() 11 | if err != nil { 12 | t.Fatalf("expected no error, got %v", err) 13 | } 14 | 15 | apiUrl := svc.ApiUrl() 16 | if apiUrl == "" { 17 | t.Fatalf("expected apiUrl to be set, got empty string") 18 | } 19 | 20 | // Optionally, validate the format of the URL 21 | if apiUrl[:10] != "localhost:" { 22 | t.Fatalf("expected apiUrl to start with 'localhost:', got %s", apiUrl) 23 | } 24 | } 25 | 26 | func TestIpfsServiceInitialize(t *testing.T) { 27 | originalIsPortAvailable := isPortAvailable 28 | isPortAvailable = func(port string) bool { 29 | return false // Simulate the port being unavailable (daemon running) 30 | } 31 | defer func() { isPortAvailable = originalIsPortAvailable }() 32 | 33 | svc := NewIpfsService(nil) 34 | 35 | err := svc.Initialize() 36 | if err != nil { 37 | t.Fatalf("expected no error, got %v", err) 38 | } 39 | 40 | if !svc.WasRunning() { 41 | t.Fatalf("expected wasRunning to be true when daemon is already running") 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /state.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | "fmt" 15 | "strings" 16 | 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 20 | // EXISTING_CODE 21 | ) 22 | 23 | type StateOptions struct { 24 | Addrs []string `json:"addrs,omitempty"` 25 | BlockIds []string `json:"blocks,omitempty"` 26 | Parts StateParts `json:"parts,omitempty"` 27 | Changes bool `json:"changes,omitempty"` 28 | NoZero bool `json:"noZero,omitempty"` 29 | Calldata string `json:"calldata,omitempty"` 30 | Articulate bool `json:"articulate,omitempty"` 31 | ProxyFor base.Address `json:"proxyFor,omitempty"` 32 | RenderCtx *output.RenderCtx `json:"-"` 33 | Globals 34 | } 35 | 36 | // String implements the stringer interface 37 | func (opts StateOptions) String() string { 38 | bytes, _ := json.Marshal(opts) 39 | return string(bytes) 40 | } 41 | 42 | // State implements the chifra state command. 43 | func (opts *StateOptions) State() ([]types.State, *types.MetaData, error) { 44 | in := opts.toInternal() 45 | return queryState[types.State](in) 46 | } 47 | 48 | // StateCall implements the chifra state --call command. 49 | func (opts *StateOptions) StateCall() ([]types.Result, *types.MetaData, error) { 50 | in := opts.toInternal() 51 | in.Call = true 52 | return queryState[types.Result](in) 53 | } 54 | 55 | // StateSend implements the chifra state --send command. 56 | func (opts *StateOptions) StateSend() ([]types.Result, *types.MetaData, error) { 57 | in := opts.toInternal() 58 | in.Send = true 59 | return queryState[types.Result](in) 60 | } 61 | 62 | type StateParts int 63 | 64 | const ( 65 | NoSTP StateParts = 0 66 | SPBalance = 1 << iota 67 | SPNonce 68 | SPCode 69 | SPProxy 70 | SPDeployed 71 | SPAccttype 72 | STPSome = SPBalance | SPProxy | SPDeployed | SPAccttype 73 | STPAll = SPBalance | SPNonce | SPCode | SPProxy | SPDeployed | SPAccttype 74 | ) 75 | 76 | func (v StateParts) String() string { 77 | switch v { 78 | case NoSTP: 79 | return "none" 80 | case STPSome: 81 | return "some" 82 | case STPAll: 83 | return "all" 84 | } 85 | 86 | var m = map[StateParts]string{ 87 | SPBalance: "balance", 88 | SPNonce: "nonce", 89 | SPCode: "code", 90 | SPProxy: "proxy", 91 | SPDeployed: "deployed", 92 | SPAccttype: "accttype", 93 | } 94 | 95 | var ret []string 96 | for _, val := range []StateParts{SPBalance, SPNonce, SPCode, SPProxy, SPDeployed, SPAccttype} { 97 | if v&val != 0 { 98 | ret = append(ret, m[val]) 99 | } 100 | } 101 | 102 | return strings.Join(ret, ",") 103 | } 104 | 105 | func enumFromStateParts(values []string) (StateParts, error) { 106 | if len(values) == 0 { 107 | return NoSTP, fmt.Errorf("no value provided for parts option") 108 | } 109 | 110 | if len(values) == 1 && values[0] == "all" { 111 | return STPAll, nil 112 | } else if len(values) == 1 && values[0] == "some" { 113 | return STPSome, nil 114 | } 115 | 116 | var result StateParts 117 | for _, val := range values { 118 | switch val { 119 | case "balance": 120 | result |= SPBalance 121 | case "nonce": 122 | result |= SPNonce 123 | case "code": 124 | result |= SPCode 125 | case "proxy": 126 | result |= SPProxy 127 | case "deployed": 128 | result |= SPDeployed 129 | case "accttype": 130 | result |= SPAccttype 131 | default: 132 | return NoSTP, fmt.Errorf("unknown parts: %s", val) 133 | } 134 | } 135 | 136 | return result, nil 137 | } 138 | 139 | // EXISTING_CODE 140 | // EXISTING_CODE 141 | -------------------------------------------------------------------------------- /status_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | 14 | "bytes" 15 | "encoding/json" 16 | "fmt" 17 | "io" 18 | "strings" 19 | 20 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 21 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 22 | status "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 23 | // EXISTING_CODE 24 | ) 25 | 26 | type statusOptionsInternal struct { 27 | Modes StatusModes `json:"modes,omitempty"` 28 | Diagnose bool `json:"diagnose,omitempty"` 29 | FirstRecord uint64 `json:"firstRecord,omitempty"` 30 | MaxRecords uint64 `json:"maxRecords,omitempty"` 31 | Chains bool `json:"chains,omitempty"` 32 | Healthcheck bool `json:"healthcheck,omitempty"` 33 | RenderCtx *output.RenderCtx `json:"-"` 34 | Globals 35 | } 36 | 37 | // String implements the stringer interface 38 | func (opts *statusOptionsInternal) String() string { 39 | bytes, _ := json.Marshal(opts) 40 | return string(bytes) 41 | } 42 | 43 | // StatusBytes implements the chifra status command for the SDK. 44 | func (opts *statusOptionsInternal) StatusBytes(w io.Writer) error { 45 | values, err := structToValues(*opts) 46 | if err != nil { 47 | return fmt.Errorf("error converting status struct to URL values: %v", err) 48 | } 49 | 50 | if opts.RenderCtx == nil { 51 | opts.RenderCtx = output.NewRenderContext() 52 | } 53 | return status.Status(opts.RenderCtx, w, values) 54 | } 55 | 56 | // statusParseFunc handles special cases such as structs and enums (if any). 57 | func statusParseFunc(target any, key, value string) (bool, error) { 58 | _ = key 59 | _ = value 60 | var found bool 61 | opts, ok := target.(*statusOptionsInternal) 62 | if !ok { 63 | return false, fmt.Errorf("parseFunc(status): target is not of correct type") 64 | } 65 | 66 | if key == "modes" { 67 | var err error 68 | values := strings.Split(value, ",") 69 | if opts.Modes, err = enumFromStatusModes(values); err != nil { 70 | return false, err 71 | } else { 72 | found = true 73 | } 74 | } 75 | 76 | // EXISTING_CODE 77 | // EXISTING_CODE 78 | 79 | return found, nil 80 | } 81 | 82 | // GetStatusOptions returns a filled-in options instance given a string array of arguments. 83 | func GetStatusOptions(args []string) (*statusOptionsInternal, error) { 84 | var opts statusOptionsInternal 85 | if err := assignValuesFromArgs(args, statusParseFunc, &opts, &opts.Globals); err != nil { 86 | return nil, err 87 | } 88 | 89 | return &opts, nil 90 | } 91 | 92 | type statusGeneric interface { 93 | types.Status 94 | } 95 | 96 | func queryStatus[T statusGeneric](opts *statusOptionsInternal) ([]T, *types.MetaData, error) { 97 | // EXISTING_CODE 98 | // EXISTING_CODE 99 | 100 | buffer := bytes.Buffer{} 101 | if err := opts.StatusBytes(&buffer); err != nil { 102 | return nil, nil, err 103 | } 104 | 105 | str := buffer.String() 106 | // EXISTING_CODE 107 | // EXISTING_CODE 108 | 109 | var result Result[T] 110 | if err := json.Unmarshal([]byte(str), &result); err != nil { 111 | debugPrint(str, result, err) 112 | return nil, nil, err 113 | } else { 114 | return result.Data, &result.Meta, nil 115 | } 116 | } 117 | 118 | // toInternal converts the SDK options to the internal options format. 119 | func (opts *StatusOptions) toInternal() *statusOptionsInternal { 120 | return &statusOptionsInternal{ 121 | FirstRecord: opts.FirstRecord, 122 | MaxRecords: opts.MaxRecords, 123 | Chains: opts.Chains, 124 | RenderCtx: opts.RenderCtx, 125 | Globals: opts.Globals, 126 | } 127 | } 128 | 129 | // EXISTING_CODE 130 | // EXISTING_CODE 131 | -------------------------------------------------------------------------------- /tokens.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | "fmt" 15 | "strings" 16 | 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 19 | // EXISTING_CODE 20 | ) 21 | 22 | type TokensOptions struct { 23 | Addrs []string `json:"addrs,omitempty"` 24 | BlockIds []string `json:"blocks,omitempty"` 25 | Parts TokensParts `json:"parts,omitempty"` 26 | ByAcct bool `json:"byAcct,omitempty"` 27 | Changes bool `json:"changes,omitempty"` 28 | NoZero bool `json:"noZero,omitempty"` 29 | RenderCtx *output.RenderCtx `json:"-"` 30 | Globals 31 | } 32 | 33 | // String implements the stringer interface 34 | func (opts TokensOptions) String() string { 35 | bytes, _ := json.Marshal(opts) 36 | return string(bytes) 37 | } 38 | 39 | // Tokens implements the chifra tokens command. 40 | func (opts *TokensOptions) Tokens() ([]types.Token, *types.MetaData, error) { 41 | in := opts.toInternal() 42 | return queryTokens[types.Token](in) 43 | } 44 | 45 | type TokensParts int 46 | 47 | const ( 48 | NoTP TokensParts = 0 49 | TPName = 1 << iota 50 | TPSymbol 51 | TPDecimals 52 | TPTotalSupply 53 | TPVersion 54 | TPSome = TPName | TPSymbol | TPDecimals | TPTotalSupply 55 | TPAll = TPName | TPSymbol | TPDecimals | TPTotalSupply | TPVersion 56 | ) 57 | 58 | func (v TokensParts) String() string { 59 | switch v { 60 | case NoTP: 61 | return "none" 62 | case TPSome: 63 | return "some" 64 | case TPAll: 65 | return "all" 66 | } 67 | 68 | var m = map[TokensParts]string{ 69 | TPName: "name", 70 | TPSymbol: "symbol", 71 | TPDecimals: "decimals", 72 | TPTotalSupply: "totalSupply", 73 | TPVersion: "version", 74 | } 75 | 76 | var ret []string 77 | for _, val := range []TokensParts{TPName, TPSymbol, TPDecimals, TPTotalSupply, TPVersion} { 78 | if v&val != 0 { 79 | ret = append(ret, m[val]) 80 | } 81 | } 82 | 83 | return strings.Join(ret, ",") 84 | } 85 | 86 | func enumFromTokensParts(values []string) (TokensParts, error) { 87 | if len(values) == 0 { 88 | return NoTP, fmt.Errorf("no value provided for parts option") 89 | } 90 | 91 | if len(values) == 1 && values[0] == "all" { 92 | return TPAll, nil 93 | } else if len(values) == 1 && values[0] == "some" { 94 | return TPSome, nil 95 | } 96 | 97 | var result TokensParts 98 | for _, val := range values { 99 | switch val { 100 | case "name": 101 | result |= TPName 102 | case "symbol": 103 | result |= TPSymbol 104 | case "decimals": 105 | result |= TPDecimals 106 | case "totalSupply": 107 | result |= TPTotalSupply 108 | case "version": 109 | result |= TPVersion 110 | default: 111 | return NoTP, fmt.Errorf("unknown parts: %s", val) 112 | } 113 | } 114 | 115 | return result, nil 116 | } 117 | 118 | // EXISTING_CODE 119 | // EXISTING_CODE 120 | -------------------------------------------------------------------------------- /tokens_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | "strings" 18 | 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 20 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 21 | tokens "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 22 | // EXISTING_CODE 23 | ) 24 | 25 | type tokensOptionsInternal struct { 26 | Addrs []string `json:"addrs,omitempty"` 27 | BlockIds []string `json:"blocks,omitempty"` 28 | Parts TokensParts `json:"parts,omitempty"` 29 | ByAcct bool `json:"byAcct,omitempty"` 30 | Changes bool `json:"changes,omitempty"` 31 | NoZero bool `json:"noZero,omitempty"` 32 | RenderCtx *output.RenderCtx `json:"-"` 33 | Globals 34 | } 35 | 36 | // String implements the stringer interface 37 | func (opts *tokensOptionsInternal) String() string { 38 | bytes, _ := json.Marshal(opts) 39 | return string(bytes) 40 | } 41 | 42 | // TokensBytes implements the chifra tokens command for the SDK. 43 | func (opts *tokensOptionsInternal) TokensBytes(w io.Writer) error { 44 | values, err := structToValues(*opts) 45 | if err != nil { 46 | return fmt.Errorf("error converting tokens struct to URL values: %v", err) 47 | } 48 | 49 | if opts.RenderCtx == nil { 50 | opts.RenderCtx = output.NewRenderContext() 51 | } 52 | return tokens.Tokens(opts.RenderCtx, w, values) 53 | } 54 | 55 | // tokensParseFunc handles special cases such as structs and enums (if any). 56 | func tokensParseFunc(target any, key, value string) (bool, error) { 57 | _ = key 58 | _ = value 59 | var found bool 60 | opts, ok := target.(*tokensOptionsInternal) 61 | if !ok { 62 | return false, fmt.Errorf("parseFunc(tokens): target is not of correct type") 63 | } 64 | 65 | if key == "parts" { 66 | var err error 67 | values := strings.Split(value, ",") 68 | if opts.Parts, err = enumFromTokensParts(values); err != nil { 69 | return false, err 70 | } else { 71 | found = true 72 | } 73 | } 74 | 75 | // EXISTING_CODE 76 | // EXISTING_CODE 77 | 78 | return found, nil 79 | } 80 | 81 | // GetTokensOptions returns a filled-in options instance given a string array of arguments. 82 | func GetTokensOptions(args []string) (*tokensOptionsInternal, error) { 83 | var opts tokensOptionsInternal 84 | if err := assignValuesFromArgs(args, tokensParseFunc, &opts, &opts.Globals); err != nil { 85 | return nil, err 86 | } 87 | 88 | return &opts, nil 89 | } 90 | 91 | type tokensGeneric interface { 92 | types.Token 93 | } 94 | 95 | func queryTokens[T tokensGeneric](opts *tokensOptionsInternal) ([]T, *types.MetaData, error) { 96 | // EXISTING_CODE 97 | // EXISTING_CODE 98 | 99 | buffer := bytes.Buffer{} 100 | if err := opts.TokensBytes(&buffer); err != nil { 101 | return nil, nil, err 102 | } 103 | 104 | str := buffer.String() 105 | // EXISTING_CODE 106 | // EXISTING_CODE 107 | 108 | var result Result[T] 109 | if err := json.Unmarshal([]byte(str), &result); err != nil { 110 | debugPrint(str, result, err) 111 | return nil, nil, err 112 | } else { 113 | return result.Data, &result.Meta, nil 114 | } 115 | } 116 | 117 | // toInternal converts the SDK options to the internal options format. 118 | func (opts *TokensOptions) toInternal() *tokensOptionsInternal { 119 | return &tokensOptionsInternal{ 120 | Addrs: opts.Addrs, 121 | BlockIds: opts.BlockIds, 122 | Parts: opts.Parts, 123 | ByAcct: opts.ByAcct, 124 | Changes: opts.Changes, 125 | NoZero: opts.NoZero, 126 | RenderCtx: opts.RenderCtx, 127 | Globals: opts.Globals, 128 | } 129 | } 130 | 131 | // EXISTING_CODE 132 | // EXISTING_CODE 133 | -------------------------------------------------------------------------------- /traces.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | 15 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 17 | // EXISTING_CODE 18 | ) 19 | 20 | type TracesOptions struct { 21 | TransactionIds []string `json:"transactions,omitempty"` 22 | Articulate bool `json:"articulate,omitempty"` 23 | Filter string `json:"filter,omitempty"` 24 | RenderCtx *output.RenderCtx `json:"-"` 25 | Globals 26 | } 27 | 28 | // String implements the stringer interface 29 | func (opts TracesOptions) String() string { 30 | bytes, _ := json.Marshal(opts) 31 | return string(bytes) 32 | } 33 | 34 | // Traces implements the chifra traces command. 35 | func (opts *TracesOptions) Traces() ([]types.Trace, *types.MetaData, error) { 36 | in := opts.toInternal() 37 | return queryTraces[types.Trace](in) 38 | } 39 | 40 | // TracesCount implements the chifra traces --count command. 41 | func (opts *TracesOptions) TracesCount() ([]types.TraceCount, *types.MetaData, error) { 42 | in := opts.toInternal() 43 | in.Count = true 44 | return queryTraces[types.TraceCount](in) 45 | } 46 | 47 | // No enums 48 | // EXISTING_CODE 49 | // EXISTING_CODE 50 | -------------------------------------------------------------------------------- /traces_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 20 | traces "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 21 | // EXISTING_CODE 22 | ) 23 | 24 | type tracesOptionsInternal struct { 25 | TransactionIds []string `json:"transactions,omitempty"` 26 | Articulate bool `json:"articulate,omitempty"` 27 | Filter string `json:"filter,omitempty"` 28 | Count bool `json:"count,omitempty"` 29 | RenderCtx *output.RenderCtx `json:"-"` 30 | Globals 31 | } 32 | 33 | // String implements the stringer interface 34 | func (opts *tracesOptionsInternal) String() string { 35 | bytes, _ := json.Marshal(opts) 36 | return string(bytes) 37 | } 38 | 39 | // TracesBytes implements the chifra traces command for the SDK. 40 | func (opts *tracesOptionsInternal) TracesBytes(w io.Writer) error { 41 | values, err := structToValues(*opts) 42 | if err != nil { 43 | return fmt.Errorf("error converting traces struct to URL values: %v", err) 44 | } 45 | 46 | if opts.RenderCtx == nil { 47 | opts.RenderCtx = output.NewRenderContext() 48 | } 49 | return traces.Traces(opts.RenderCtx, w, values) 50 | } 51 | 52 | // tracesParseFunc handles special cases such as structs and enums (if any). 53 | func tracesParseFunc(target any, key, value string) (bool, error) { 54 | _ = key 55 | _ = value 56 | var found bool 57 | _, ok := target.(*tracesOptionsInternal) 58 | if !ok { 59 | return false, fmt.Errorf("parseFunc(traces): target is not of correct type") 60 | } 61 | 62 | // No enums 63 | // EXISTING_CODE 64 | // EXISTING_CODE 65 | 66 | return found, nil 67 | } 68 | 69 | // GetTracesOptions returns a filled-in options instance given a string array of arguments. 70 | func GetTracesOptions(args []string) (*tracesOptionsInternal, error) { 71 | var opts tracesOptionsInternal 72 | if err := assignValuesFromArgs(args, tracesParseFunc, &opts, &opts.Globals); err != nil { 73 | return nil, err 74 | } 75 | 76 | return &opts, nil 77 | } 78 | 79 | type tracesGeneric interface { 80 | types.Trace | 81 | types.TraceCount 82 | } 83 | 84 | func queryTraces[T tracesGeneric](opts *tracesOptionsInternal) ([]T, *types.MetaData, error) { 85 | // EXISTING_CODE 86 | // EXISTING_CODE 87 | 88 | buffer := bytes.Buffer{} 89 | if err := opts.TracesBytes(&buffer); err != nil { 90 | return nil, nil, err 91 | } 92 | 93 | str := buffer.String() 94 | // EXISTING_CODE 95 | str = convertObjectToArray("inputs", str) 96 | str = convertObjectToArray("outputs", str) 97 | str = convertEmptyStrToZero("balance", str) 98 | str = convertEmptyStrToZero("value", str) 99 | // EXISTING_CODE 100 | 101 | var result Result[T] 102 | if err := json.Unmarshal([]byte(str), &result); err != nil { 103 | debugPrint(str, result, err) 104 | return nil, nil, err 105 | } else { 106 | return result.Data, &result.Meta, nil 107 | } 108 | } 109 | 110 | // toInternal converts the SDK options to the internal options format. 111 | func (opts *TracesOptions) toInternal() *tracesOptionsInternal { 112 | return &tracesOptionsInternal{ 113 | TransactionIds: opts.TransactionIds, 114 | Articulate: opts.Articulate, 115 | Filter: opts.Filter, 116 | RenderCtx: opts.RenderCtx, 117 | Globals: opts.Globals, 118 | } 119 | } 120 | 121 | // EXISTING_CODE 122 | // EXISTING_CODE 123 | -------------------------------------------------------------------------------- /transactions.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | "fmt" 15 | "strings" 16 | 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 19 | // EXISTING_CODE 20 | ) 21 | 22 | type TransactionsOptions struct { 23 | TransactionIds []string `json:"transactions,omitempty"` 24 | Articulate bool `json:"articulate,omitempty"` 25 | Flow TransactionsFlow `json:"flow,omitempty"` 26 | Emitter []string `json:"emitter,omitempty"` 27 | Topic []string `json:"topic,omitempty"` 28 | CacheTraces bool `json:"cacheTraces,omitempty"` 29 | RenderCtx *output.RenderCtx `json:"-"` 30 | Globals 31 | } 32 | 33 | // String implements the stringer interface 34 | func (opts TransactionsOptions) String() string { 35 | bytes, _ := json.Marshal(opts) 36 | return string(bytes) 37 | } 38 | 39 | // Transactions implements the chifra transactions command. 40 | func (opts *TransactionsOptions) Transactions() ([]types.Transaction, *types.MetaData, error) { 41 | in := opts.toInternal() 42 | return queryTransactions[types.Transaction](in) 43 | } 44 | 45 | // TransactionsTraces implements the chifra transactions --traces command. 46 | func (opts *TransactionsOptions) TransactionsTraces() ([]types.Trace, *types.MetaData, error) { 47 | in := opts.toInternal() 48 | in.Traces = true 49 | return queryTransactions[types.Trace](in) 50 | } 51 | 52 | // TransactionsUniq implements the chifra transactions --uniq command. 53 | func (opts *TransactionsOptions) TransactionsUniq() ([]types.Appearance, *types.MetaData, error) { 54 | in := opts.toInternal() 55 | in.Uniq = true 56 | return queryTransactions[types.Appearance](in) 57 | } 58 | 59 | // TransactionsLogs implements the chifra transactions --logs command. 60 | func (opts *TransactionsOptions) TransactionsLogs() ([]types.Log, *types.MetaData, error) { 61 | in := opts.toInternal() 62 | in.Logs = true 63 | return queryTransactions[types.Log](in) 64 | } 65 | 66 | type TransactionsFlow int 67 | 68 | const ( 69 | NoTF TransactionsFlow = 0 70 | TFFrom = 1 << iota 71 | TFTo 72 | ) 73 | 74 | func (v TransactionsFlow) String() string { 75 | switch v { 76 | case NoTF: 77 | return "none" 78 | } 79 | 80 | var m = map[TransactionsFlow]string{ 81 | TFFrom: "from", 82 | TFTo: "to", 83 | } 84 | 85 | var ret []string 86 | for _, val := range []TransactionsFlow{TFFrom, TFTo} { 87 | if v&val != 0 { 88 | ret = append(ret, m[val]) 89 | } 90 | } 91 | 92 | return strings.Join(ret, ",") 93 | } 94 | 95 | func enumFromTransactionsFlow(values []string) (TransactionsFlow, error) { 96 | if len(values) == 0 { 97 | return NoTF, fmt.Errorf("no value provided for flow option") 98 | } 99 | 100 | var result TransactionsFlow 101 | for _, val := range values { 102 | switch val { 103 | case "from": 104 | result |= TFFrom 105 | case "to": 106 | result |= TFTo 107 | default: 108 | return NoTF, fmt.Errorf("unknown flow: %s", val) 109 | } 110 | } 111 | 112 | return result, nil 113 | } 114 | 115 | // EXISTING_CODE 116 | // EXISTING_CODE 117 | -------------------------------------------------------------------------------- /typescript/.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [{src,scripts}/**.{ts,tsx,json,js,jsx}] 4 | end_of_line = lf 5 | charset = utf-8 6 | trim_trailing_whitespace = true 7 | insert_final_newline = true 8 | indent_style = space 9 | indent_size = 2 10 | 11 | [makefile] 12 | indent_style = tab 13 | 14 | -------------------------------------------------------------------------------- /typescript/.env.example: -------------------------------------------------------------------------------- 1 | CORE_URL="" -------------------------------------------------------------------------------- /typescript/.eslintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | .scratch -------------------------------------------------------------------------------- /typescript/.eslintrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('eslint').Linter.Config} */ 2 | module.exports = { 3 | root: true, 4 | parser: '@typescript-eslint/parser', 5 | parserOptions: { 6 | ecmaVersion: 'latest', 7 | sourceType: 'module', 8 | warnOnUnsupportedTypeScriptVersion: true, 9 | }, 10 | env: { node: true, browser: true }, 11 | reportUnusedDisableDirectives: true, 12 | extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'plugin:prettier/recommended'], 13 | plugins: ['@typescript-eslint', 'prettier'], 14 | rules: { 15 | quotes: ['warn', 'single'], 16 | 'array-element-newline': ['error', 'consistent'], 17 | 'object-curly-newline': 0, 18 | 'object-curly-spacing': ['warn', 'always'], 19 | '@typescript-eslint/consistent-type-imports': [ 20 | 'warn', 21 | { 22 | prefer: 'type-imports', 23 | fixStyle: 'inline-type-imports', 24 | }, 25 | ], 26 | 'prettier/prettier': [ 27 | 'warn', 28 | {}, 29 | { 30 | usePrettierrc: true, 31 | fileInfoOptions: { 32 | withNodeModules: true, 33 | }, 34 | }, 35 | ], 36 | 'no-mixed-operators': ['off'], 37 | 'no-multiple-empty-lines': ['off'], 38 | 'no-unexpected-multiline': ['off'], 39 | '@typescript-eslint/ban-ts-comment': ['off'], 40 | '@typescript-eslint/no-empty-interface': [ 41 | 'error', 42 | { 43 | allowSingleExtends: false, 44 | }, 45 | ], 46 | '@typescript-eslint/ban-types': [ 47 | 'warn', 48 | { 49 | types: { 50 | String: { 51 | message: 'Use string instead', 52 | fixWith: 'string', 53 | }, 54 | 55 | '{}': { 56 | message: 'Use object instead', 57 | fixWith: 'object', 58 | }, 59 | }, 60 | }, 61 | ], 62 | }, 63 | }; 64 | -------------------------------------------------------------------------------- /typescript/.npmignore: -------------------------------------------------------------------------------- 1 | src 2 | yarn.lock 3 | tsconfig.json 4 | .gitignore 5 | .github 6 | makefile 7 | -------------------------------------------------------------------------------- /typescript/.npmrc: -------------------------------------------------------------------------------- 1 | enable-pre-post-scripts=true 2 | auto-install-peers=true -------------------------------------------------------------------------------- /typescript/.prettierrc.cjs: -------------------------------------------------------------------------------- 1 | /** @type {import('prettier').Config} */ 2 | module.exports = { 3 | printWidth: 120, 4 | endOfLine: 'auto', 5 | arrowParens: 'avoid', 6 | bracketSpacing: true, 7 | singleQuote: true 8 | }; 9 | -------------------------------------------------------------------------------- /typescript/README.md: -------------------------------------------------------------------------------- 1 | # TrueBlocks / Typescript SDKs 2 | 3 | ## Introduction 4 | 5 | This is the Typescript SDK. 6 | -------------------------------------------------------------------------------- /typescript/makefile: -------------------------------------------------------------------------------- 1 | all: 2 | @yarn install 3 | @yarn build 4 | -------------------------------------------------------------------------------- /typescript/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "trueblocks-sdk", 3 | "version": "3.0.2", 4 | "license": "GPL-3.0-or-later", 5 | "description": "Use the TrueBlocks chifra interface in your apps", 6 | "main": "dist/index.js", 7 | "types": "dist/index.d.ts", 8 | "files": [ 9 | "/dist" 10 | ], 11 | "scripts": { 12 | "build": "rm -fR dist && node_modules/.bin/tsc", 13 | "test": "echo \"Error: no test specified\" && exit 1" 14 | }, 15 | "dependencies": { 16 | "typescript": "^4.9.4", 17 | "vitest": "^0.29.2" 18 | }, 19 | "devDependencies": { 20 | "@types/jest": "^29.2.4", 21 | "@types/node": "^18.11.16", 22 | "@types/react": "^18.0.26", 23 | "@typescript-eslint/eslint-plugin": "^5.46.1", 24 | "@typescript-eslint/parser": "^5.46.1", 25 | "eslint": "^8.30.0", 26 | "eslint-config-airbnb": "^18.2.1", 27 | "eslint-import-resolver-typescript": "^2.4.0", 28 | "eslint-plugin-import": "^2.22.1", 29 | "eslint-plugin-jsx-a11y": "^6.4.1", 30 | "eslint-plugin-react": "^7.22.0", 31 | "eslint-plugin-react-hooks": "^4.2.0", 32 | "eslint-plugin-simple-import-sort": "^7.0.0" 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /typescript/src/index.ts: -------------------------------------------------------------------------------- 1 | export * from './lib/api_callers'; 2 | export * from './paths'; 3 | export * from './types'; 4 | export function getVersion(): string { 5 | return 'TrueBlocks SDK v1.0.0-release'; 6 | } 7 | -------------------------------------------------------------------------------- /typescript/src/lib/api_callers.test.ts: -------------------------------------------------------------------------------- 1 | import * as Callers from './api_callers'; 2 | import { expect, beforeEach, describe, it } from 'vitest'; 3 | 4 | const baseUrl = `${process.env.CORE_URL}`; 5 | beforeEach(() => { 6 | Callers.setBaseUrl(baseUrl); 7 | // Callers.setFetch(global.fetch); 8 | }); 9 | 10 | describe('makeUrl', () => { 11 | it('returns correct URL when no params', () => { 12 | const expected = `${baseUrl}/hello`; 13 | const result = Callers.makeUrl('/hello'); 14 | expect(result).toBe(expected); 15 | }); 16 | it('returns correct URL when params', () => { 17 | const expected = `${baseUrl}/hello?a=1&b=string&c=true&d=false`; 18 | const result = Callers.makeUrl('/hello', { 19 | a: 1, 20 | b: 'string', 21 | c: true, 22 | d: false, 23 | }); 24 | expect(result).toBe(expected); 25 | }); 26 | }); 27 | -------------------------------------------------------------------------------- /typescript/src/lib/api_callers.ts: -------------------------------------------------------------------------------- 1 | export type ErrorResponse = { 2 | status: number, 3 | errors: string[], 4 | }; 5 | 6 | export type SuccessResponse = { 7 | data: DataType, 8 | meta: { 9 | unripe: number, 10 | ripe: number, 11 | staging: number, 12 | finalized: number, 13 | client: number 14 | }, 15 | }; 16 | 17 | export type AnyResponse = 18 | | ErrorResponse 19 | | SuccessResponse 20 | 21 | let baseUrl = `${process.env.CORE_URL}`; 22 | const fetchToUse = global.fetch; 23 | 24 | export function setBaseUrl(url: string) { 25 | baseUrl = url; 26 | } 27 | 28 | export function getBaseUrl() { 29 | return baseUrl; 30 | } 31 | 32 | export function makeUrl( 33 | endpoint: string, 34 | parameters: Record = {}, 35 | ) { 36 | const search = new URLSearchParams(Object.entries(parameters) 37 | .map(([key, value]) => [key, String(value)])); 38 | const endpointUrl = new URL(endpoint, baseUrl); 39 | 40 | endpointUrl.search = search.toString(); 41 | 42 | return endpointUrl.toString(); 43 | } 44 | 45 | export function fetchBody({ 46 | endpoint, 47 | method, 48 | parameters = {}, 49 | options = {}, 50 | }: { 51 | endpoint: string, 52 | method: string, 53 | parameters?: Parameters[1], 54 | options?: RequestInit, 55 | }) { 56 | const endpointUrl = makeUrl(endpoint, parameters); 57 | 58 | return fetchToUse(endpointUrl, { 59 | method, 60 | ...options, 61 | }); 62 | } 63 | 64 | export function fetch(args: Parameters[0]) { 65 | return fetchBody(args) 66 | .then((response) => response.json() as Promise>); 67 | } 68 | -------------------------------------------------------------------------------- /typescript/src/paths/abis.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { Abi, address, Count, Function } from '../types'; 13 | 14 | export function getAbis( 15 | parameters?: { 16 | addrs: address[]; 17 | known?: boolean; 18 | proxyFor?: address; 19 | list?: boolean; 20 | details?: boolean; 21 | count?: boolean; 22 | find?: string[]; 23 | hint?: string[]; 24 | encode?: string; 25 | fmt?: string; 26 | chain: string; 27 | noHeader?: boolean; 28 | cache?: boolean; 29 | decache?: boolean; 30 | }, 31 | options?: RequestInit, 32 | ) { 33 | return ApiCallers.fetch( 34 | { endpoint: '/abis', method: 'get', parameters, options }, 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /typescript/src/paths/blocks.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Appearance, blknum, Block, BlockCount, LightBlock, Log, topic, Trace, Withdrawal } from '../types'; 13 | 14 | export function getBlocks( 15 | parameters?: { 16 | blocks: blknum[]; 17 | hashes?: boolean; 18 | uncles?: boolean; 19 | traces?: boolean; 20 | uniq?: boolean; 21 | flow?: 'from' | 'to' | 'reward'; 22 | logs?: boolean; 23 | emitter?: address[]; 24 | topic?: topic[]; 25 | withdrawals?: boolean; 26 | articulate?: boolean; 27 | count?: boolean; 28 | cacheTxs?: boolean; 29 | cacheTraces?: boolean; 30 | fmt?: string; 31 | chain: string; 32 | noHeader?: boolean; 33 | cache?: boolean; 34 | decache?: boolean; 35 | ether?: boolean; 36 | }, 37 | options?: RequestInit, 38 | ) { 39 | return ApiCallers.fetch( 40 | { endpoint: '/blocks', method: 'get', parameters, options }, 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /typescript/src/paths/chunks.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, blknum, ChunkAddress, ChunkAppearance, ChunkBloom, ChunkIndex, ChunkManifest, ChunkPin, ChunkStats, Count, float64, Message, uint64 } from '../types'; 13 | 14 | export function getChunks( 15 | parameters?: { 16 | mode: 'manifest' | 'index' | 'blooms' | 'pins' | 'addresses' | 'appearances' | 'stats'; 17 | blocks?: blknum[]; 18 | check?: boolean; 19 | pin?: boolean; 20 | publish?: boolean; 21 | remote?: boolean; 22 | belongs?: address[]; 23 | firstBlock?: blknum; 24 | lastBlock?: blknum; 25 | maxAddrs?: uint64; 26 | deep?: boolean; 27 | rewrite?: boolean; 28 | count?: boolean; 29 | sleep?: float64; 30 | fmt?: string; 31 | chain: string; 32 | noHeader?: boolean; 33 | }, 34 | options?: RequestInit, 35 | ) { 36 | return ApiCallers.fetch( 37 | { endpoint: '/chunks', method: 'get', parameters, options }, 38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /typescript/src/paths/config.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { CacheItem, Config } from '../types'; 13 | 14 | export function getConfig( 15 | parameters?: { 16 | mode?: 'show' | 'edit'; 17 | paths?: boolean; 18 | dump?: boolean; 19 | fmt?: string; 20 | chain: string; 21 | noHeader?: boolean; 22 | }, 23 | options?: RequestInit, 24 | ) { 25 | return ApiCallers.fetch( 26 | { endpoint: '/config', method: 'get', parameters, options }, 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /typescript/src/paths/export.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Appearance, blknum, fourbyte, Log, Message, Monitor, Name, Receipt, State, Statement, topic, Trace, Transaction, Transfer, uint64, Withdrawal } from '../types'; 13 | 14 | export function getExport( 15 | parameters?: { 16 | addrs: address[]; 17 | topics?: topic[]; 18 | fourbytes?: fourbyte[]; 19 | appearances?: boolean; 20 | receipts?: boolean; 21 | logs?: boolean; 22 | traces?: boolean; 23 | neighbors?: boolean; 24 | statements?: boolean; 25 | transfers?: boolean; 26 | assets?: boolean; 27 | balances?: boolean; 28 | withdrawals?: boolean; 29 | articulate?: boolean; 30 | cacheTraces?: boolean; 31 | count?: boolean; 32 | firstRecord?: uint64; 33 | maxRecords?: uint64; 34 | relevant?: boolean; 35 | emitter?: address[]; 36 | topic?: topic[]; 37 | nfts?: boolean; 38 | reverted?: boolean; 39 | asset?: address[]; 40 | flow?: 'in' | 'out' | 'zero'; 41 | factory?: boolean; 42 | unripe?: boolean; 43 | reversed?: boolean; 44 | noZero?: boolean; 45 | firstBlock?: blknum; 46 | lastBlock?: blknum; 47 | accounting?: boolean; 48 | fmt?: string; 49 | chain: string; 50 | noHeader?: boolean; 51 | cache?: boolean; 52 | decache?: boolean; 53 | ether?: boolean; 54 | }, 55 | options?: RequestInit, 56 | ) { 57 | return ApiCallers.fetch( 58 | { endpoint: '/export', method: 'get', parameters, options }, 59 | ); 60 | } 61 | -------------------------------------------------------------------------------- /typescript/src/paths/index.ts: -------------------------------------------------------------------------------- 1 | export * from './abis'; 2 | export * from './blocks'; 3 | export * from './chunks'; 4 | export * from './config'; 5 | export * from './export'; 6 | export * from './init'; 7 | export * from './list'; 8 | export * from './logs'; 9 | export * from './monitors'; 10 | export * from './names'; 11 | export * from './receipts'; 12 | export * from './slurp'; 13 | export * from './state'; 14 | export * from './status'; 15 | export * from './tokens'; 16 | export * from './traces'; 17 | export * from './transactions'; 18 | export * from './when'; 19 | 20 | -------------------------------------------------------------------------------- /typescript/src/paths/init.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { blknum, float64, Message } from '../types'; 13 | 14 | export function getInit( 15 | parameters?: { 16 | all?: boolean; 17 | example?: string; 18 | dryRun?: boolean; 19 | firstBlock?: blknum; 20 | sleep?: float64; 21 | chain: string; 22 | }, 23 | options?: RequestInit, 24 | ) { 25 | return ApiCallers.fetch( 26 | { endpoint: '/init', method: 'get', parameters, options }, 27 | ); 28 | } 29 | -------------------------------------------------------------------------------- /typescript/src/paths/list.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Appearance, blknum, Bounds, Monitor, uint64 } from '../types'; 13 | 14 | export function getList( 15 | parameters?: { 16 | addrs: address[]; 17 | count?: boolean; 18 | noZero?: boolean; 19 | bounds?: boolean; 20 | unripe?: boolean; 21 | silent?: boolean; 22 | firstRecord?: uint64; 23 | maxRecords?: uint64; 24 | reversed?: boolean; 25 | firstBlock?: blknum; 26 | lastBlock?: blknum; 27 | fmt?: string; 28 | chain: string; 29 | noHeader?: boolean; 30 | }, 31 | options?: RequestInit, 32 | ) { 33 | return ApiCallers.fetch( 34 | { endpoint: '/list', method: 'get', parameters, options }, 35 | ); 36 | } 37 | -------------------------------------------------------------------------------- /typescript/src/paths/logs.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Log, topic, txId } from '../types'; 13 | 14 | export function getLogs( 15 | parameters?: { 16 | transactions: txId[]; 17 | emitter?: address[]; 18 | topic?: topic[]; 19 | articulate?: boolean; 20 | fmt?: string; 21 | chain: string; 22 | noHeader?: boolean; 23 | cache?: boolean; 24 | decache?: boolean; 25 | }, 26 | options?: RequestInit, 27 | ) { 28 | return ApiCallers.fetch( 29 | { endpoint: '/logs', method: 'get', parameters, options }, 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /typescript/src/paths/monitors.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Count, Message, Monitor, MonitorClean } from '../types'; 13 | 14 | export function getMonitors( 15 | parameters?: { 16 | addrs?: address[]; 17 | delete?: boolean; 18 | undelete?: boolean; 19 | remove?: boolean; 20 | clean?: boolean; 21 | list?: boolean; 22 | count?: boolean; 23 | staged?: boolean; 24 | fmt?: string; 25 | chain: string; 26 | noHeader?: boolean; 27 | cache?: boolean; 28 | decache?: boolean; 29 | }, 30 | options?: RequestInit, 31 | ) { 32 | return ApiCallers.fetch( 33 | { endpoint: '/monitors', method: 'get', parameters, options }, 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /typescript/src/paths/names.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Message, Name } from '../types'; 13 | 14 | export function getNames( 15 | parameters?: { 16 | terms: string[]; 17 | expand?: boolean; 18 | matchCase?: boolean; 19 | all?: boolean; 20 | custom?: boolean; 21 | prefund?: boolean; 22 | addr?: boolean; 23 | tags?: boolean; 24 | clean?: boolean; 25 | regular?: boolean; 26 | dryRun?: boolean; 27 | autoname?: address; 28 | create?: boolean; 29 | update?: boolean; 30 | delete?: boolean; 31 | undelete?: boolean; 32 | remove?: boolean; 33 | fmt?: string; 34 | chain: string; 35 | noHeader?: boolean; 36 | }, 37 | options?: RequestInit, 38 | ) { 39 | return ApiCallers.fetch( 40 | { endpoint: '/names', method: 'get', parameters, options }, 41 | ); 42 | } 43 | -------------------------------------------------------------------------------- /typescript/src/paths/receipts.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { Receipt, txId } from '../types'; 13 | 14 | export function getReceipts( 15 | parameters?: { 16 | transactions: txId[]; 17 | articulate?: boolean; 18 | fmt?: string; 19 | chain: string; 20 | noHeader?: boolean; 21 | cache?: boolean; 22 | decache?: boolean; 23 | }, 24 | options?: RequestInit, 25 | ) { 26 | return ApiCallers.fetch( 27 | { endpoint: '/receipts', method: 'get', parameters, options }, 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /typescript/src/paths/slurp.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Appearance, blknum, float64, Monitor, Slurp, uint64 } from '../types'; 13 | 14 | export function getSlurp( 15 | parameters?: { 16 | addrs: address[]; 17 | blocks?: blknum[]; 18 | parts?: string[]; 19 | appearances?: boolean; 20 | articulate?: boolean; 21 | source?: 'etherscan' | 'covalent' | 'alchemy'; 22 | count?: boolean; 23 | page?: uint64; 24 | pageId?: string; 25 | perPage?: uint64; 26 | sleep?: float64; 27 | fmt?: string; 28 | chain: string; 29 | noHeader?: boolean; 30 | cache?: boolean; 31 | decache?: boolean; 32 | ether?: boolean; 33 | }, 34 | options?: RequestInit, 35 | ) { 36 | return ApiCallers.fetch( 37 | { endpoint: '/slurp', method: 'get', parameters, options }, 38 | ); 39 | } 40 | -------------------------------------------------------------------------------- /typescript/src/paths/state.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, blknum, Result, State } from '../types'; 13 | 14 | export function getState( 15 | parameters?: { 16 | addrs: address[]; 17 | blocks?: blknum[]; 18 | parts?: string[]; 19 | changes?: boolean; 20 | noZero?: boolean; 21 | call?: boolean; 22 | calldata?: string; 23 | articulate?: boolean; 24 | proxyFor?: address; 25 | fmt?: string; 26 | chain: string; 27 | noHeader?: boolean; 28 | cache?: boolean; 29 | decache?: boolean; 30 | ether?: boolean; 31 | }, 32 | options?: RequestInit, 33 | ) { 34 | return ApiCallers.fetch( 35 | { endpoint: '/state', method: 'get', parameters, options }, 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /typescript/src/paths/status.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { Status, uint64 } from '../types'; 13 | 14 | export function getStatus( 15 | parameters?: { 16 | modes?: string[]; 17 | diagnose?: boolean; 18 | firstRecord?: uint64; 19 | maxRecords?: uint64; 20 | chains?: boolean; 21 | healthcheck?: boolean; 22 | fmt?: string; 23 | chain: string; 24 | noHeader?: boolean; 25 | }, 26 | options?: RequestInit, 27 | ) { 28 | return ApiCallers.fetch( 29 | { endpoint: '/status', method: 'get', parameters, options }, 30 | ); 31 | } 32 | -------------------------------------------------------------------------------- /typescript/src/paths/tokens.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, blknum, Token } from '../types'; 13 | 14 | export function getTokens( 15 | parameters?: { 16 | addrs: address[]; 17 | blocks?: blknum[]; 18 | parts?: string[]; 19 | byAcct?: boolean; 20 | changes?: boolean; 21 | noZero?: boolean; 22 | fmt?: string; 23 | chain: string; 24 | noHeader?: boolean; 25 | cache?: boolean; 26 | decache?: boolean; 27 | }, 28 | options?: RequestInit, 29 | ) { 30 | return ApiCallers.fetch( 31 | { endpoint: '/tokens', method: 'get', parameters, options }, 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /typescript/src/paths/traces.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { Trace, TraceCount, txId } from '../types'; 13 | 14 | export function getTraces( 15 | parameters?: { 16 | transactions: txId[]; 17 | articulate?: boolean; 18 | filter?: string; 19 | count?: boolean; 20 | fmt?: string; 21 | chain: string; 22 | noHeader?: boolean; 23 | cache?: boolean; 24 | decache?: boolean; 25 | ether?: boolean; 26 | }, 27 | options?: RequestInit, 28 | ) { 29 | return ApiCallers.fetch( 30 | { endpoint: '/traces', method: 'get', parameters, options }, 31 | ); 32 | } 33 | -------------------------------------------------------------------------------- /typescript/src/paths/transactions.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { address, Appearance, Log, topic, Trace, Transaction, txId } from '../types'; 13 | 14 | export function getTransactions( 15 | parameters?: { 16 | transactions: txId[]; 17 | articulate?: boolean; 18 | traces?: boolean; 19 | uniq?: boolean; 20 | flow?: 'from' | 'to'; 21 | logs?: boolean; 22 | emitter?: address[]; 23 | topic?: topic[]; 24 | cacheTraces?: boolean; 25 | fmt?: string; 26 | chain: string; 27 | noHeader?: boolean; 28 | cache?: boolean; 29 | decache?: boolean; 30 | ether?: boolean; 31 | }, 32 | options?: RequestInit, 33 | ) { 34 | return ApiCallers.fetch( 35 | { endpoint: '/transactions', method: 'get', parameters, options }, 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /typescript/src/paths/when.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import * as ApiCallers from '../lib/api_callers'; 12 | import { Count, NamedBlock, Timestamp } from '../types'; 13 | 14 | export function getWhen( 15 | parameters?: { 16 | blocks?: string[]; 17 | list?: boolean; 18 | timestamps?: boolean; 19 | count?: boolean; 20 | repair?: boolean; 21 | check?: boolean; 22 | update?: boolean; 23 | deep?: boolean; 24 | fmt?: string; 25 | chain: string; 26 | noHeader?: boolean; 27 | cache?: boolean; 28 | decache?: boolean; 29 | }, 30 | options?: RequestInit, 31 | ) { 32 | return ApiCallers.fetch( 33 | { endpoint: '/when', method: 'get', parameters, options }, 34 | ); 35 | } 36 | -------------------------------------------------------------------------------- /typescript/src/types/abi.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, Function, int64 } from '.'; 12 | 13 | export type Abi = { 14 | address: address; 15 | fileSize: int64; 16 | functions: Function[]; 17 | hasConstructor: boolean; 18 | hasFallback: boolean; 19 | isEmpty: boolean; 20 | isKnown: boolean; 21 | lastModDate: string; 22 | nEvents: int64; 23 | nFunctions: int64; 24 | name: string; 25 | path: string; 26 | }; 27 | -------------------------------------------------------------------------------- /typescript/src/types/appearance.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, datetime, timestamp, uint64 } from '.'; 12 | 13 | export type Appearance = { 14 | address: address; 15 | blockNumber: uint64; 16 | date?: datetime; 17 | reason?: string; 18 | timestamp: timestamp; 19 | traceIndex?: uint64; 20 | transactionIndex: uint64; 21 | }; 22 | -------------------------------------------------------------------------------- /typescript/src/types/appearancetable.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { AddrRecord, AppRecord } from '.'; 12 | 13 | export type AppearanceTable = { 14 | AddressRecord: AddrRecord; 15 | Appearances: AppRecord[]; 16 | }; 17 | -------------------------------------------------------------------------------- /typescript/src/types/basetypes.ts: -------------------------------------------------------------------------------- 1 | export type address = string; 2 | export type AddrRecord = any; 3 | export type AppRecord = any; 4 | export type blknum = number; 5 | export type blkrange = string; 6 | export type bytes = string; 7 | export type bytes32 = string; 8 | export type ChunkAppearance = any; 9 | export type ChunkManifest = any; 10 | export type datetime = string; 11 | export type float = number; 12 | export type float64 = number; 13 | export type fourbyte = string; 14 | export type gas = string; 15 | export type hash = string; 16 | export type int256 = string; 17 | export type int64 = number; 18 | export type ipfshash = string; 19 | export type lognum = number; 20 | export type StatePart = string; 21 | export type StorageSlot = any; 22 | export type timestamp = number; 23 | export type TokenType = number; 24 | export type topic = string; 25 | export type txId = string; 26 | export type txnum = number; 27 | export type uint256 = string; 28 | export type uint32 = number; 29 | export type uint64 = number; 30 | export type uint8 = number; 31 | export type wei = string; 32 | export type DestType = string; 33 | -------------------------------------------------------------------------------- /typescript/src/types/block.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, datetime, gas, hash, timestamp, Transaction, uint64, wei, Withdrawal } from '.'; 12 | 13 | export type Block = { 14 | author: address; 15 | baseFeePerGas: gas; 16 | blockNumber: blknum; 17 | date?: datetime; 18 | difficulty: uint64; 19 | extraData: string; 20 | gasLimit: gas; 21 | gasUsed: gas; 22 | hash: hash; 23 | logsBloom: string; 24 | miner: address; 25 | mixHash: string; 26 | nonce: uint64; 27 | parentHash: hash; 28 | receiptsRoot: hash; 29 | sha3Uncles: hash; 30 | size: uint64; 31 | stateRoot: hash; 32 | timestamp: timestamp; 33 | totalDifficulty: wei; 34 | transactions: Transaction[]; 35 | transactionsRoot: hash; 36 | uncles?: hash[]; 37 | withdrawals?: Withdrawal[]; 38 | }; 39 | -------------------------------------------------------------------------------- /typescript/src/types/blockCount.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blknum, datetime, timestamp, uint64 } from '.'; 12 | 13 | export type BlockCount = { 14 | addressCnt?: uint64; 15 | blockNumber: blknum; 16 | date?: datetime; 17 | logsCnt?: uint64; 18 | timestamp: timestamp; 19 | tracesCnt?: uint64; 20 | transactionsCnt: uint64; 21 | unclesCnt?: uint64; 22 | withdrawalsCnt?: uint64; 23 | }; 24 | -------------------------------------------------------------------------------- /typescript/src/types/bounds.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { Appearance, datetime, timestamp, uint64 } from '.'; 12 | 13 | export type Bounds = { 14 | count: uint64; 15 | firstApp: Appearance; 16 | firstDate?: datetime; 17 | firstTs: timestamp; 18 | latestApp: Appearance; 19 | latestDate?: datetime; 20 | latestTs: timestamp; 21 | }; 22 | -------------------------------------------------------------------------------- /typescript/src/types/cacheItem.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { int64, uint64 } from '.'; 12 | 13 | export type CacheItem = { 14 | items: any[]; 15 | lastCached?: string; 16 | nFiles: uint64; 17 | nFolders: uint64; 18 | path: string; 19 | sizeInBytes: int64; 20 | type: string; 21 | }; 22 | -------------------------------------------------------------------------------- /typescript/src/types/chain.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { uint64 } from '.'; 12 | 13 | export type Chain = { 14 | chain: string; 15 | chainId: uint64; 16 | ipfsGateway: string; 17 | localExplorer: string; 18 | remoteExplorer: string; 19 | rpcProvider: string; 20 | symbol: string; 21 | }; 22 | -------------------------------------------------------------------------------- /typescript/src/types/chunkAddress.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blkrange, RangeDates, uint64 } from '.'; 12 | 13 | export type ChunkAddress = { 14 | address: address; 15 | count: uint64; 16 | offset: uint64; 17 | range: blkrange; 18 | rangeDates?: RangeDates; 19 | }; 20 | -------------------------------------------------------------------------------- /typescript/src/types/chunkBloom.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blkrange, hash, RangeDates, uint64 } from '.'; 12 | 13 | export type ChunkBloom = { 14 | byteWidth: uint64; 15 | hash: hash; 16 | magic: string; 17 | nBlooms: uint64; 18 | nInserted: uint64; 19 | range: blkrange; 20 | rangeDates?: RangeDates; 21 | size: uint64; 22 | }; 23 | -------------------------------------------------------------------------------- /typescript/src/types/chunkIndex.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blkrange, hash, RangeDates, uint64 } from '.'; 12 | 13 | export type ChunkIndex = { 14 | hash: hash; 15 | magic: string; 16 | nAddresses: uint64; 17 | nAppearances: uint64; 18 | range: blkrange; 19 | rangeDates?: RangeDates; 20 | size: uint64; 21 | }; 22 | -------------------------------------------------------------------------------- /typescript/src/types/chunkPin.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { ipfshash } from '.'; 12 | 13 | export type ChunkPin = { 14 | chain: string; 15 | manifestHash: ipfshash; 16 | specHash: ipfshash; 17 | timestampHash: ipfshash; 18 | version: string; 19 | }; 20 | -------------------------------------------------------------------------------- /typescript/src/types/chunkRecord.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blkrange, int64, ipfshash, RangeDates } from '.'; 12 | 13 | export type ChunkRecord = { 14 | bloomHash: ipfshash; 15 | bloomSize: int64; 16 | indexHash: ipfshash; 17 | indexSize: int64; 18 | range: blkrange; 19 | rangeDates?: RangeDates; 20 | }; 21 | -------------------------------------------------------------------------------- /typescript/src/types/chunkStats.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blkrange, float64, RangeDates, uint64 } from '.'; 12 | 13 | export type ChunkStats = { 14 | addrsPerBlock: float64; 15 | appsPerAddr: float64; 16 | appsPerBlock: float64; 17 | bloomSz: uint64; 18 | chunkSz: uint64; 19 | nAddrs: uint64; 20 | nApps: uint64; 21 | nBlocks: uint64; 22 | nBlooms: uint64; 23 | range: blkrange; 24 | rangeDates?: RangeDates; 25 | ratio: float64; 26 | recWid: uint64; 27 | }; 28 | -------------------------------------------------------------------------------- /typescript/src/types/config.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { CacheItem, Chain } from '.'; 12 | 13 | export type Config = { 14 | cachePath?: string 15 | caches: CacheItem[] 16 | chain?: string 17 | chainConfig?: string 18 | clientVersion?: string 19 | chainId?: string 20 | hasEsKey?: boolean 21 | hasPinKey?: boolean 22 | indexPath?: string 23 | isApi?: boolean 24 | isArchive?: boolean 25 | isTesting?: boolean 26 | isTracing?: boolean 27 | isScraping?: boolean 28 | networkId?: string 29 | progress?: string 30 | rootConfig?: string 31 | rpcProvider?: string 32 | version?: string 33 | chains: Chain[] 34 | } 35 | -------------------------------------------------------------------------------- /typescript/src/types/count.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { uint64 } from '.'; 12 | 13 | export type Count = { 14 | count: uint64; 15 | }; 16 | -------------------------------------------------------------------------------- /typescript/src/types/destination.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { DestType } from '.'; 12 | 13 | export type Destination = { 14 | source: string; 15 | term: string; 16 | termType: DestType; 17 | url: string; 18 | }; 19 | -------------------------------------------------------------------------------- /typescript/src/types/ethCall.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum } from '.'; 12 | 13 | export type EthCall = { 14 | blockNumber: blknum 15 | address: address 16 | signature: string 17 | encoding: string 18 | bytes: string 19 | compressedResult: string 20 | deployed: blknum 21 | } 22 | -------------------------------------------------------------------------------- /typescript/src/types/function.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { Parameter } from '.'; 12 | 13 | export type Function = { 14 | anonymous?: boolean; 15 | constant?: boolean; 16 | encoding: string; 17 | inputs: Parameter[]; 18 | message?: string; 19 | name: string; 20 | outputs: Parameter[]; 21 | signature?: string; 22 | stateMutability?: string; 23 | type: string; 24 | }; 25 | -------------------------------------------------------------------------------- /typescript/src/types/index.ts: -------------------------------------------------------------------------------- 1 | export * from './abi'; 2 | export * from './appearance'; 3 | export * from './basetypes'; 4 | export * from './block'; 5 | export * from './blockCount'; 6 | export * from './bounds'; 7 | export * from './cacheItem'; 8 | export * from './chain'; 9 | export * from './chunkAddress'; 10 | export * from './chunkBloom'; 11 | export * from './chunkIndex'; 12 | export * from './chunkPin'; 13 | export * from './chunkRecord'; 14 | export * from './chunkStats'; 15 | export * from './config'; 16 | export * from './function'; 17 | export * from './ipfsPin'; 18 | export * from './lightblock'; 19 | export * from './log'; 20 | export * from './manifest'; 21 | export * from './message' 22 | export * from './monitor'; 23 | export * from './monitorClean'; 24 | export * from './name'; 25 | export * from './namedBlock'; 26 | export * from './parameter'; 27 | export * from "./rangedates"; 28 | export * from './receipt'; 29 | export * from './reportCheck'; 30 | export * from './result'; 31 | export * from './slurp'; 32 | export * from './state'; 33 | export * from './statement'; 34 | export * from './status'; 35 | export * from './timestamp'; 36 | export * from './count'; 37 | export * from './token'; 38 | export * from './trace'; 39 | export * from './traceAction'; 40 | export * from './traceCount'; 41 | export * from './traceFilter'; 42 | export * from './traceResult'; 43 | export * from './transaction'; 44 | export * from './upgrades'; 45 | export * from './withdrawal'; 46 | -------------------------------------------------------------------------------- /typescript/src/types/ipfsPin.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { int64, ipfshash } from '.'; 12 | 13 | export type IpfsPin = { 14 | cid: ipfshash; 15 | datePinned: string; 16 | fileName: string; 17 | size: int64; 18 | status: string; 19 | }; 20 | -------------------------------------------------------------------------------- /typescript/src/types/lightblock.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, datetime, gas, hash, timestamp, uint64, wei, Withdrawal } from '.'; 12 | 13 | export type LightBlock = { 14 | author: address; 15 | baseFeePerGas: gas; 16 | blockNumber: blknum; 17 | date?: datetime; 18 | difficulty: uint64; 19 | extraData: string; 20 | gasLimit: gas; 21 | gasUsed: gas; 22 | hash: hash; 23 | logsBloom: string; 24 | miner: address; 25 | mixHash: string; 26 | nonce: uint64; 27 | parentHash: hash; 28 | receiptsRoot: hash; 29 | sha3Uncles: hash; 30 | size: uint64; 31 | stateRoot: hash; 32 | timestamp: timestamp; 33 | totalDifficulty: wei; 34 | transactions: string[]; 35 | transactionsRoot: hash; 36 | uncles?: hash[]; 37 | withdrawals?: Withdrawal[]; 38 | }; 39 | -------------------------------------------------------------------------------- /typescript/src/types/log.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, bytes, datetime, Function, hash, lognum, timestamp, topic, txnum } from '.'; 12 | 13 | export type Log = { 14 | address: address; 15 | articulatedLog?: Function; 16 | blockHash: hash; 17 | blockNumber: blknum; 18 | compressedLog?: string; 19 | data?: bytes; 20 | date?: datetime; 21 | isNFT?: boolean; 22 | logIndex: lognum; 23 | timestamp?: timestamp; 24 | topics?: topic[]; 25 | transactionHash: hash; 26 | transactionIndex: txnum; 27 | }; 28 | -------------------------------------------------------------------------------- /typescript/src/types/manifest.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { ChunkRecord, ipfshash } from '.'; 12 | 13 | export type Manifest = { 14 | chain: string; 15 | chunks: ChunkRecord[]; 16 | specification: ipfshash; 17 | version: string; 18 | }; 19 | -------------------------------------------------------------------------------- /typescript/src/types/message.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { int64 } from '.'; 12 | 13 | export type Message = { 14 | msg?: string; 15 | num?: int64; 16 | }; 17 | -------------------------------------------------------------------------------- /typescript/src/types/monitor.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, int64, uint64 } from '.'; 12 | 13 | export type Monitor = { 14 | address: address; 15 | deleted: boolean; 16 | fileSize: int64; 17 | isEmpty: boolean; 18 | isStaged: boolean; 19 | lastScanned: uint64; 20 | nRecords: int64; 21 | name: string; 22 | }; 23 | -------------------------------------------------------------------------------- /typescript/src/types/monitorClean.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, int64 } from '.'; 12 | 13 | export type MonitorClean = { 14 | address: address; 15 | dups: int64; 16 | removed: boolean; 17 | sizeNow: int64; 18 | sizeThen: int64; 19 | staged: boolean; 20 | }; 21 | -------------------------------------------------------------------------------- /typescript/src/types/name.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, uint64 } from '.'; 12 | 13 | export type Name = { 14 | address: address; 15 | decimals: uint64; 16 | deleted?: boolean; 17 | isContract?: boolean; 18 | isCustom?: boolean; 19 | isErc20?: boolean; 20 | isErc721?: boolean; 21 | isPrefund?: boolean; 22 | name: string; 23 | source: string; 24 | symbol: string; 25 | tags: string; 26 | }; 27 | -------------------------------------------------------------------------------- /typescript/src/types/namedBlock.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blknum, datetime, timestamp } from '.'; 12 | 13 | export type NamedBlock = { 14 | blockNumber: blknum; 15 | component?: string; 16 | date?: datetime; 17 | description?: string; 18 | name?: string; 19 | timestamp: timestamp; 20 | }; 21 | -------------------------------------------------------------------------------- /typescript/src/types/parameter.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | export type Parameter = { 12 | components?: Parameter[]; 13 | indexed?: boolean; 14 | internalType?: string; 15 | name: string; 16 | strDefault?: string; 17 | type: string; 18 | value?: string; 19 | }; 20 | -------------------------------------------------------------------------------- /typescript/src/types/rangedates.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { datetime, timestamp } from '.'; 12 | 13 | export type RangeDates = { 14 | firstDate?: datetime; 15 | firstTs?: timestamp; 16 | lastDate?: datetime; 17 | lastTs?: timestamp; 18 | }; 19 | -------------------------------------------------------------------------------- /typescript/src/types/receipt.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, gas, hash, Log, txnum, uint64 } from '.'; 12 | 13 | export type Receipt = { 14 | blockHash?: hash; 15 | blockNumber: blknum; 16 | contractAddress?: address; 17 | cumulativeGasUsed?: gas; 18 | effectiveGasPrice?: gas; 19 | from?: address; 20 | gasUsed: gas; 21 | isError?: boolean; 22 | logs: Log[]; 23 | logsBloom?: string; 24 | status: uint64; 25 | to?: address; 26 | transactionHash: hash; 27 | transactionIndex: txnum; 28 | }; 29 | -------------------------------------------------------------------------------- /typescript/src/types/reportCheck.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { uint64 } from '.'; 12 | 13 | export type ReportCheck = { 14 | checkedCnt: uint64; 15 | failedCnt: uint64; 16 | msgStrings: string[]; 17 | passedCnt: uint64; 18 | reason: string; 19 | result: string; 20 | skippedCnt: uint64; 21 | visitedCnt: uint64; 22 | }; 23 | -------------------------------------------------------------------------------- /typescript/src/types/result.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, datetime, Function, timestamp } from '.'; 12 | 13 | export type Result = { 14 | address: address; 15 | articulatedOut: Function; 16 | blockNumber: blknum; 17 | date?: datetime; 18 | encodedArguments: string; 19 | encoding: string; 20 | name: string; 21 | signature: string; 22 | timestamp: timestamp; 23 | }; 24 | -------------------------------------------------------------------------------- /typescript/src/types/slurp.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, bytes, datetime, float64, Function, gas, hash, timestamp, txnum, uint64, wei } from '.'; 12 | 13 | export type Slurp = { 14 | address: address; 15 | amount: wei; 16 | articulatedTx: Function; 17 | blockHash: hash; 18 | blockNumber: blknum; 19 | compressedTx?: string; 20 | contractAddress: address; 21 | cumulativeGasUsed: string; 22 | date?: datetime; 23 | ether?: float64; 24 | from: address; 25 | functionName: string; 26 | gas: gas; 27 | gasPrice: gas; 28 | gasUsed: gas; 29 | hasToken: boolean; 30 | hash: hash; 31 | input: bytes; 32 | isError: boolean; 33 | methodId: string; 34 | nonce: uint64; 35 | timestamp: timestamp; 36 | to: address; 37 | transactionIndex: txnum; 38 | txReceiptStatus: string; 39 | validatorIndex: uint64; 40 | value: wei; 41 | withdrawalIndex: uint64; 42 | }; 43 | -------------------------------------------------------------------------------- /typescript/src/types/state.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, datetime, float64, StatePart, timestamp, uint64, wei } from '.'; 12 | 13 | export type State = { 14 | accountType: string; 15 | address: address; 16 | balance: wei; 17 | blockNumber: blknum; 18 | code: string; 19 | date?: datetime; 20 | deployed: blknum; 21 | ether?: float64; 22 | nonce: uint64; 23 | parts: StatePart; 24 | proxy: address; 25 | timestamp: timestamp; 26 | }; 27 | -------------------------------------------------------------------------------- /typescript/src/types/statement.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, datetime, float, hash, int256, lognum, timestamp, txnum, uint64 } from '.'; 12 | 13 | export type Statement = { 14 | accountedFor: address; 15 | amountIn?: int256; 16 | amountNet?: int256; 17 | amountOut?: int256; 18 | asset: address; 19 | begBal: int256; 20 | begBalDiff?: int256; 21 | blockNumber: blknum; 22 | correctAmountIn?: int256; 23 | correctAmountOut?: int256; 24 | correctBegBalIn?: int256; 25 | correctBegBalOut?: int256; 26 | correctEndBalIn?: int256; 27 | correctEndBalOut?: int256; 28 | correctingReasons?: string; 29 | date?: datetime; 30 | decimals: uint64; 31 | endBal: int256; 32 | endBalCalc?: int256; 33 | endBalDiff?: int256; 34 | gasOut?: int256; 35 | internalIn?: int256; 36 | internalOut?: int256; 37 | logIndex: lognum; 38 | minerBaseRewardIn?: int256; 39 | minerNephewRewardIn?: int256; 40 | minerTxFeeIn?: int256; 41 | minerUncleRewardIn?: int256; 42 | prefundIn?: int256; 43 | prevBal?: int256; 44 | priceSource: string; 45 | recipient: address; 46 | reconciled?: boolean; 47 | selfDestructIn?: int256; 48 | selfDestructOut?: int256; 49 | sender: address; 50 | spotPrice: float; 51 | symbol: string; 52 | timestamp: timestamp; 53 | totalIn?: int256; 54 | totalOut?: int256; 55 | transactionHash: hash; 56 | transactionIndex: txnum; 57 | }; 58 | -------------------------------------------------------------------------------- /typescript/src/types/status.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { CacheItem, Chain } from '.'; 12 | 13 | export type Status = { 14 | cachePath?: string; 15 | caches: CacheItem[]; 16 | chain?: string; 17 | chainConfig?: string; 18 | chainId?: string; 19 | chains: Chain[]; 20 | clientVersion?: string; 21 | hasEsKey?: boolean; 22 | hasPinKey?: boolean; 23 | indexPath?: string; 24 | isApi?: boolean; 25 | isArchive?: boolean; 26 | isScraping?: boolean; 27 | isTesting?: boolean; 28 | isTracing?: boolean; 29 | networkId?: string; 30 | progress?: string; 31 | rootConfig?: string; 32 | rpcProvider?: string; 33 | version?: string; 34 | }; 35 | -------------------------------------------------------------------------------- /typescript/src/types/timestamp.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blknum, datetime, int64, timestamp } from '.'; 12 | 13 | export type Timestamp = { 14 | blockNumber: blknum; 15 | date?: datetime; 16 | diff: int64; 17 | timestamp: timestamp; 18 | }; 19 | -------------------------------------------------------------------------------- /typescript/src/types/token.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, datetime, float, int256, timestamp, TokenType, txnum, uint64 } from '.'; 12 | 13 | export type Token = { 14 | address: address; 15 | balance: int256; 16 | balanceDec?: float; 17 | blockNumber: blknum; 18 | date?: datetime; 19 | decimals: uint64; 20 | diff?: int256; 21 | holder: address; 22 | name: string; 23 | priorBalance?: int256; 24 | symbol: string; 25 | timestamp: timestamp; 26 | totalSupply: int256; 27 | transactionIndex?: txnum; 28 | type: TokenType; 29 | }; 30 | -------------------------------------------------------------------------------- /typescript/src/types/trace.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blknum, datetime, Function, hash, timestamp, TraceAction, TraceResult, txnum, uint64 } from '.'; 12 | 13 | export type Trace = { 14 | action: TraceAction; 15 | articulatedTrace?: Function; 16 | blockHash: hash; 17 | blockNumber: blknum; 18 | compressedTrace?: string; 19 | date?: datetime; 20 | error?: string; 21 | result: TraceResult; 22 | subtraces: uint64; 23 | timestamp: timestamp; 24 | traceAddress: uint64[]; 25 | transactionHash: hash; 26 | transactionIndex: txnum; 27 | type?: string; 28 | }; 29 | -------------------------------------------------------------------------------- /typescript/src/types/traceAction.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, bytes, float64, gas, wei } from '.'; 12 | 13 | export type TraceAction = { 14 | address?: address; 15 | author?: address; 16 | balance?: wei; 17 | balanceEth?: float64; 18 | callType: string; 19 | ether?: float64; 20 | from: address; 21 | gas: gas; 22 | init?: string; 23 | input?: bytes; 24 | refundAddress?: address; 25 | rewardType?: string; 26 | selfDestructed?: address; 27 | to: address; 28 | value: wei; 29 | }; 30 | -------------------------------------------------------------------------------- /typescript/src/types/traceCount.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { blknum, datetime, hash, timestamp, txnum, uint64 } from '.'; 12 | 13 | export type TraceCount = { 14 | blockNumber: blknum; 15 | date?: datetime; 16 | timestamp: timestamp; 17 | tracesCnt: uint64; 18 | transactionHash: hash; 19 | transactionIndex: txnum; 20 | }; 21 | -------------------------------------------------------------------------------- /typescript/src/types/traceFilter.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, uint64 } from '.'; 12 | 13 | export type TraceFilter = { 14 | after?: uint64; 15 | count?: uint64; 16 | fromAddress?: address; 17 | fromBlock?: blknum; 18 | toAddress?: address; 19 | toBlock?: blknum; 20 | }; 21 | -------------------------------------------------------------------------------- /typescript/src/types/traceResult.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, bytes, gas } from '.'; 12 | 13 | export type TraceResult = { 14 | address?: address; 15 | code?: bytes; 16 | gasUsed?: gas; 17 | output?: bytes; 18 | }; 19 | -------------------------------------------------------------------------------- /typescript/src/types/transaction.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, bytes, datetime, float64, Function, gas, hash, Receipt, Statement, StorageSlot, timestamp, Trace, txnum, uint64, wei } from '.'; 12 | 13 | export type Transaction = { 14 | accessList: StorageSlot[]; 15 | articulatedTx: Function; 16 | blockHash: hash; 17 | blockNumber: blknum; 18 | chainId: string; 19 | compressedTx?: string; 20 | date?: datetime; 21 | ether?: float64; 22 | from: address; 23 | gas: gas; 24 | gasPrice: gas; 25 | gasUsed: gas; 26 | hasToken: boolean; 27 | hash: hash; 28 | input: bytes; 29 | isError: boolean; 30 | maxFeePerGas: gas; 31 | maxPriorityFeePerGas: gas; 32 | nonce: uint64; 33 | receipt: Receipt; 34 | statements?: Statement[]; 35 | timestamp: timestamp; 36 | to: address; 37 | traces: Trace[]; 38 | transactionIndex: txnum; 39 | type: string; 40 | value: wei; 41 | }; 42 | -------------------------------------------------------------------------------- /typescript/src/types/transfer.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, int256, Log, lognum, Transaction, txnum, uint64 } from '.'; 12 | 13 | export type Transfer = { 14 | amountIn?: int256; 15 | amountOut?: int256; 16 | asset: address; 17 | blockNumber: blknum; 18 | decimals: uint64; 19 | gasOut?: int256; 20 | holder: address; 21 | internalIn?: int256; 22 | internalOut?: int256; 23 | log?: Log; 24 | logIndex: lognum; 25 | minerBaseRewardIn?: int256; 26 | minerNephewRewardIn?: int256; 27 | minerTxFeeIn?: int256; 28 | minerUncleRewardIn?: int256; 29 | prefundIn?: int256; 30 | recipient: address; 31 | selfDestructIn?: int256; 32 | selfDestructOut?: int256; 33 | sender: address; 34 | transaction?: Transaction; 35 | transactionIndex: txnum; 36 | }; 37 | -------------------------------------------------------------------------------- /typescript/src/types/upgrades.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { ipfshash, uint64 } from '.'; 12 | 13 | export type CacheRecordUp = { 14 | range: string 15 | bloomHash: ipfshash 16 | indexHash: ipfshash 17 | bloomSize: uint64 18 | indexSize: uint64 19 | firstApp: uint64 20 | latestApp: uint64 21 | filename: string 22 | nApps: uint64 23 | nAppearance: uint64 24 | } 25 | -------------------------------------------------------------------------------- /typescript/src/types/withdrawal.ts: -------------------------------------------------------------------------------- 1 | /* eslint object-curly-newline: ["error", "never"] */ 2 | /* eslint max-len: ["error", 160] */ 3 | /* 4 | * Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 5 | * Use of this source code is governed by a license that can 6 | * be found in the LICENSE file. 7 | * 8 | * This file was auto generated. DO NOT EDIT. 9 | */ 10 | 11 | import { address, blknum, datetime, float64, timestamp, uint64, wei } from '.'; 12 | 13 | export type Withdrawal = { 14 | address: address; 15 | amount: wei; 16 | blockNumber: blknum; 17 | date?: datetime; 18 | ether?: float64; 19 | index: uint64; 20 | timestamp: timestamp; 21 | validatorIndex: uint64; 22 | }; 23 | -------------------------------------------------------------------------------- /typescript/tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compilerOptions": { 3 | /* https://www.typescriptlang.org/tsconfig */ 4 | "target": "ESNext", 5 | "module": "ESNext", 6 | "moduleResolution": "Node", 7 | "declaration": true, 8 | "outDir": "dist", 9 | "esModuleInterop": true, 10 | "forceConsistentCasingInFileNames": true, 11 | "strict": true, 12 | "skipLibCheck": true, 13 | "alwaysStrict": true, 14 | }, 15 | "exclude": [ 16 | "dist", 17 | "input", 18 | "generated_ts", 19 | "out", 20 | ".scratch" 21 | ] 22 | } -------------------------------------------------------------------------------- /version.go: -------------------------------------------------------------------------------- 1 | package sdk 2 | 3 | import "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/version" 4 | 5 | func Version() string { 6 | version := version.NewVersion(version.LibraryVersion) 7 | return version.String() 8 | } 9 | -------------------------------------------------------------------------------- /when.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "encoding/json" 14 | "fmt" 15 | 16 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 17 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 19 | // EXISTING_CODE 20 | ) 21 | 22 | type WhenOptions struct { 23 | BlockIds []string `json:"blocks,omitempty"` 24 | Truncate base.Blknum `json:"truncate,omitempty"` 25 | Repair bool `json:"repair,omitempty"` 26 | Check bool `json:"check,omitempty"` 27 | Update bool `json:"update,omitempty"` 28 | Deep bool `json:"deep,omitempty"` 29 | RenderCtx *output.RenderCtx `json:"-"` 30 | Globals 31 | } 32 | 33 | // String implements the stringer interface 34 | func (opts WhenOptions) String() string { 35 | bytes, _ := json.Marshal(opts) 36 | return string(bytes) 37 | } 38 | 39 | // When implements the chifra when command. 40 | func (opts *WhenOptions) When() ([]types.NamedBlock, *types.MetaData, error) { 41 | in := opts.toInternal() 42 | return queryWhen[types.NamedBlock](in) 43 | } 44 | 45 | // WhenList implements the chifra when --list command. 46 | func (opts *WhenOptions) WhenList() ([]types.NamedBlock, *types.MetaData, error) { 47 | in := opts.toInternal() 48 | in.List = true 49 | return queryWhen[types.NamedBlock](in) 50 | } 51 | 52 | // WhenTimestamps implements the chifra when --timestamps command. 53 | func (opts *WhenOptions) WhenTimestamps() ([]types.Timestamp, *types.MetaData, error) { 54 | in := opts.toInternal() 55 | in.Timestamps = true 56 | return queryWhen[types.Timestamp](in) 57 | } 58 | 59 | // WhenCount implements the chifra when --count command. 60 | func (opts *WhenOptions) WhenCount() ([]types.Count, *types.MetaData, error) { 61 | in := opts.toInternal() 62 | in.Count = true 63 | return queryWhen[types.Count](in) 64 | } 65 | 66 | // No enums 67 | // EXISTING_CODE 68 | func TsFromBlock(chain string, blockNum base.Blknum) (base.Timestamp, error) { 69 | whenOpts := WhenOptions{ 70 | BlockIds: []string{fmt.Sprintf("%d", blockNum)}, 71 | Globals: Globals{ 72 | Chain: chain, 73 | }, 74 | } 75 | 76 | var err error 77 | var when []types.NamedBlock 78 | if when, _, err = whenOpts.When(); err != nil { 79 | return 0, fmt.Errorf("error getting timestamp on chain %s: %w", chain, err) 80 | } 81 | 82 | return when[0].Timestamp, nil 83 | } 84 | 85 | // EXISTING_CODE 86 | -------------------------------------------------------------------------------- /when_internal.go: -------------------------------------------------------------------------------- 1 | // Copyright 2016, 2024 The TrueBlocks Authors. All rights reserved. 2 | // Use of this source code is governed by a license that can 3 | // be found in the LICENSE file. 4 | /* 5 | * Parts of this file were auto generated. Edit only those parts of 6 | * the code inside of 'EXISTING_CODE' tags. 7 | */ 8 | 9 | package sdk 10 | 11 | import ( 12 | // EXISTING_CODE 13 | "bytes" 14 | "encoding/json" 15 | "fmt" 16 | "io" 17 | 18 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/base" 19 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/output" 20 | "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/pkg/types" 21 | when "github.com/TrueBlocks/trueblocks-core/src/apps/chifra/sdk" 22 | // EXISTING_CODE 23 | ) 24 | 25 | type whenOptionsInternal struct { 26 | BlockIds []string `json:"blocks,omitempty"` 27 | List bool `json:"list,omitempty"` 28 | Timestamps bool `json:"timestamps,omitempty"` 29 | Count bool `json:"count,omitempty"` 30 | Truncate base.Blknum `json:"truncate,omitempty"` 31 | Repair bool `json:"repair,omitempty"` 32 | Check bool `json:"check,omitempty"` 33 | Update bool `json:"update,omitempty"` 34 | Deep bool `json:"deep,omitempty"` 35 | RenderCtx *output.RenderCtx `json:"-"` 36 | Globals 37 | } 38 | 39 | // String implements the stringer interface 40 | func (opts *whenOptionsInternal) String() string { 41 | bytes, _ := json.Marshal(opts) 42 | return string(bytes) 43 | } 44 | 45 | // WhenBytes implements the chifra when command for the SDK. 46 | func (opts *whenOptionsInternal) WhenBytes(w io.Writer) error { 47 | values, err := structToValues(*opts) 48 | if err != nil { 49 | return fmt.Errorf("error converting when struct to URL values: %v", err) 50 | } 51 | 52 | if opts.RenderCtx == nil { 53 | opts.RenderCtx = output.NewRenderContext() 54 | } 55 | return when.When(opts.RenderCtx, w, values) 56 | } 57 | 58 | // whenParseFunc handles special cases such as structs and enums (if any). 59 | func whenParseFunc(target any, key, value string) (bool, error) { 60 | _ = key 61 | _ = value 62 | var found bool 63 | _, ok := target.(*whenOptionsInternal) 64 | if !ok { 65 | return false, fmt.Errorf("parseFunc(when): target is not of correct type") 66 | } 67 | 68 | // No enums 69 | // EXISTING_CODE 70 | // EXISTING_CODE 71 | 72 | return found, nil 73 | } 74 | 75 | // GetWhenOptions returns a filled-in options instance given a string array of arguments. 76 | func GetWhenOptions(args []string) (*whenOptionsInternal, error) { 77 | var opts whenOptionsInternal 78 | if err := assignValuesFromArgs(args, whenParseFunc, &opts, &opts.Globals); err != nil { 79 | return nil, err 80 | } 81 | 82 | return &opts, nil 83 | } 84 | 85 | type whenGeneric interface { 86 | types.NamedBlock | 87 | types.Timestamp | 88 | types.Count 89 | } 90 | 91 | func queryWhen[T whenGeneric](opts *whenOptionsInternal) ([]T, *types.MetaData, error) { 92 | // EXISTING_CODE 93 | // EXISTING_CODE 94 | 95 | buffer := bytes.Buffer{} 96 | if err := opts.WhenBytes(&buffer); err != nil { 97 | return nil, nil, err 98 | } 99 | 100 | str := buffer.String() 101 | // EXISTING_CODE 102 | // EXISTING_CODE 103 | 104 | var result Result[T] 105 | if err := json.Unmarshal([]byte(str), &result); err != nil { 106 | debugPrint(str, result, err) 107 | return nil, nil, err 108 | } else { 109 | return result.Data, &result.Meta, nil 110 | } 111 | } 112 | 113 | // toInternal converts the SDK options to the internal options format. 114 | func (opts *WhenOptions) toInternal() *whenOptionsInternal { 115 | return &whenOptionsInternal{ 116 | BlockIds: opts.BlockIds, 117 | Truncate: opts.Truncate, 118 | Repair: opts.Repair, 119 | Check: opts.Check, 120 | Update: opts.Update, 121 | Deep: opts.Deep, 122 | RenderCtx: opts.RenderCtx, 123 | Globals: opts.Globals, 124 | } 125 | } 126 | 127 | // EXISTING_CODE 128 | // EXISTING_CODE 129 | --------------------------------------------------------------------------------