{"id":19423187,"url":"https://github.com/make-software/ces-go-parser","last_synced_at":"2025-04-24T16:30:48.228Z","repository":{"id":169075751,"uuid":"644606262","full_name":"make-software/ces-go-parser","owner":"make-software","description":"The Golang library for parsing Casper Event Standard events","archived":false,"fork":false,"pushed_at":"2024-10-03T12:08:46.000Z","size":295,"stargazers_count":4,"open_issues_count":1,"forks_count":2,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-03T07:21:54.810Z","etag":null,"topics":["blockchain","casper-network","golang","parser"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/make-software.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-05-23T21:58:39.000Z","updated_at":"2024-10-03T12:08:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"3ae15961-8ae9-4a26-83f9-b3935592d5b8","html_url":"https://github.com/make-software/ces-go-parser","commit_stats":null,"previous_names":["make-software/ces-go-parser"],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fces-go-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fces-go-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fces-go-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/make-software%2Fces-go-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/make-software","download_url":"https://codeload.github.com/make-software/ces-go-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250663544,"owners_count":21467366,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["blockchain","casper-network","golang","parser"],"created_at":"2024-11-10T13:37:09.228Z","updated_at":"2025-04-24T16:30:47.789Z","avatar_url":"https://github.com/make-software.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CES Go Parser\n\n`ces-go-parser` parses contract-level events that follow\nthe [Casper Event Standard](https://github.com/make-software/casper-event-standard).\n\nThe library is built on top of the `casper-go-sdk` and operates on types defined by the SDK.\n\n## Install\n\n```bash\ngo get github.com/make-software/ces-go-parser/v2\n```\n\n## Usage\n\nHere is an example of parsing CES events using `ces-go-parser` from a real Testnet deploy loaded\nwith `casper-go-sdk`:\n\n```go\npackage main\n\nimport (\n\t\"context\"\n\t\"fmt\"\n\t\"net/http\"\n\n\t\"github.com/make-software/casper-go-sdk/v2/casper\"\n\n\t\"github.com/make-software/ces-go-parser/v2\"\n)\n\nfunc main() {\n\ttestnetNodeAddress := \"\u003cput testnet node address here\u003e\"\n\trpcClient := casper.NewRPCClient(casper.NewRPCHandler(testnetNodeAddress, http.DefaultClient))\n\n\tctx := context.Background()\n\tdeployResult, err := rpcClient.GetDeploy(ctx, \"c1bb9ae27877f5ecf4ef71307e7ee3c403bcace065565c3645b81ec0a9bc8978\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tcontractHash, err := casper.NewHash(\"0640eb43bd95d5c88b799862bc9fb42d7a241f1a8aae5deaa03170a27ee8eeaa\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tparser, err := ces.NewParser(rpcClient, []casper.Hash{contractHash})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tparseResults, err := parser.ParseExecutionResults(deployResult.ExecutionResults.ExecutionResult)\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\tfor _, result := range parseResults {\n\t\tif result.Error != nil {\n\t\t\tpanic(err)\n\t\t}\n\t\tfmt.Println(result.Event)\n\t}\n}\n```\n\n## Migration to Casper 2.0.0 (Condor)\n\nCasper 2.0.0 introduces changes in the API that aren't backward compatible with Casper 1.x.\n\nTo use CES Go Parser with Casper 2.0.0 you need to the version `v2` of the parser:\n\n```go\n    \"github.com/make-software/ces-go-parser/v2\"\n```\n\nIf you want to use the same version of the parser for both Casper 1.x and Casper 2.x, you'll need to use the\nsoft-migration constructor that requires you to specify the network version you are currently running on:\n\n```go\n    parser, err := ces.NewParserWithVersion(rpcClient, []casper.Hash{contractHash}, ces.Casper1x)\n    if err != nil {\n        panic(err)\n    }\n```\n\nYou can also use a parser to process events emitted by `AddressableEntity` smart contracts.\n\nCurrently, this functionality is only available in the `rc4` branch of the network, and while it will not be used in future versions, the core functionality will remain the same as in Casper1.x\n\n```go\n    parser, err := ces.NewParserWithVersion(rpcClient, []casper.Hash{contractHash}, ces.Casper2xRC4)\n    if err != nil {\n        panic(err)\n    }\n```\n\n### Breaking changes\n\nIn CES Go Parser 2.0.0, the `LoadContractMetadataWithoutSchema` function accepts a list of `NamedKeys`\nand `ContractPackageHash` instead of `casper.Contract` it accepted previously:\n\n```go\n    contractMetadata, err := LoadContractMetadataWithoutSchema(contractPackageHash, addressableEntity.NamedKeys)\n    if err != nil {\n        return nil, err\n    }\n```\n\n## API\n\nGo CES Parser provides several public types and functions:\n\n- [`Parser`](#Parser)\n    - [`NewParser`](#NewParser)\n    - [`Parser.ParseExecutionResults`](#ParseExecutionResults)\n    - [`Parser.FetchContractSchemasBytes`](#FetchContractSchemasBytes)\n- [`NewSchemasFromBytes`](#NewSchemasFromBytes)\n- [`EventData`](#EventData)\n- [`Event`](#Event)\n    - [`ParseEventNameAndData`](#ParseEventNameAndData)\n- [`ParseResult`](#ParseResult)\n- [`Schemas`](#Schemas)\n- [`SchemaData`](#SchemaData)\n\n### `Parser`\n\nParser that accepts a list of observed contracts and provides possibility to parse CES events out of deploy execution\nresults\n\n#### `NewParser`\n\n`NewParser` constructor that accepts `casper-go-sdk` client:\n\n| Argument          | Type               | Description                                |\n|-------------------|--------------------|--------------------------------------------|\n| `casperRPCClient` | `casper.RPCClient` | Instance of the `casper-go-sdk` RPC client |\n| `contracts`       | `[]casper.Hash`    | List of the observed contract hashes       |\n\n**Example**\n\n```go\npackage main\n\nimport (\n\t\"net/http\"\n\n\t\"github.com/make-software/casper-go-sdk/v2/casper\"\n\n\t\"github.com/make-software/ces-go-parser/v2\"\n)\n\nfunc main() {\n\trpcClient := casper.NewRPCClient(casper.NewRPCHandler(\"http://localhost:11101/rpc\", http.DefaultClient))\n\tcontractHash, err := casper.NewHash(\"e7062b42c9a22002fa3cd216debd605b7056ad180efb3c99555676f1a1e801e5\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\tparser, err := ces.NewParser(rpcClient, []casper.Hash{contractHash})\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\t_ = parser\n}\n```\n\n#### `ParseExecutionResults`\n\n`ParseExecutionResults` method that accepts deploy execution results and returns `[]ces.ParseResult`:\n\n| Argument           | Type                      | Description                                                                      |                                           \n|--------------------|---------------------------|----------------------------------------------------------------------------------|\n| `executionResults` | `casper.ExecutionResults` | Deploy execution results provided as the corresponding type from `casper-go-sdk` |\n\n#### `FetchContractSchemasBytes`\n\n`FetchContractSchemasBytes` method that accepts contract hash and return bytes representation of stored schema:\n\n| Argument       | Type          | Description                             |                                           \n|----------------|---------------|-----------------------------------------|\n| `contractHash` | `casper.Hash` | Contract hash schema want to be fetched |\n\n### `NewSchemasFromBytes`\n\n`NewSchemasFromBytes` constructor that accepts raw CES schema bytes stored under the contract `__events_schema` URef and\nreturns `ces.Schemas`:\n\n| Argument     | Type     | Description                |         \n|--------------|----------|----------------------------|\n| `rawSchemas` | `[]byte` | Raw contract schemas bytes |\n\n### `ParseEventNameAndData`\n\nFunction that accepts raw event bytes and contract event schemas and returns `ParseResult`:\n\n| Argument  | Type          | Description                  |            \n|-----------|---------------|------------------------------|\n| `event`   | `string`      | Raw event bytes in hex       |\n| `schemas` | `ces.Schemas` | The list of contract schemas |\n\n**Example**\n\n```\nschemas, err := ces.NewSchemasFromBytes(rawSchemas)\nrawEvent  := BytesFromString(\"some real example here\")\n\neventData, err := ces.ParseEvent(rawEvent, schemas)\n```\n\n### `EventData`\n\nValue-object that represents an event data:\n\n| Property | Type                        | Description |\n|----------|-----------------------------|-------------|\n| `Name`   | `string`                    | Event name  |\n| `Data`   | `map[string]casper.CLValue` | Event Data  |\n\n### `Event`\n\nValue-object that represents an event:\n\n| Property              | Type                          | Description               |\n|-----------------------|-------------------------------|---------------------------|\n| `Name`                | `string`                      | Event Name                |\n| `EventData`           | [`ces.EventData`](#EventData) | EventData                 |\n| `ContractHash`        | `casper.Hash`                 | Event ContractHash        |\n| `ContractPackageHash` | `casper.Hash`                 | Event ContractPackageHash |\n| `TransformID`         | `uint`                        | Event TransformID         |\n| `EventID`             | `uint`                        | EventID                   |\n\n### `ParseResult`\n\nValue-object that represents a parse result. Contains error representing weather parsing was successful or not.\n\n| Property | Type                  | Description        |\n|----------|-----------------------|--------------------|\n| `Error`  | `error`               | Parse result error |\n| `Event`  | [`ces.Event`](#Event) | ces Event          |\n\n### `SchemaData`\n\nSchemaData is - value-object that represents an schema item.\n\n| Property    | Type            | Description       |\n|-------------|-----------------|-------------------|\n| `ParamName` | `string`        | Name of the param |\n| `ParamType` | `casper.CLType` | casper CLType     |\n\n### `Schemas`\n\nSchemas represent a map of event name and list of SchemaData.\n\n## Tests\n\nTo run unit tests for the library, make sure you are in the root of the library:\n\n```bash\ngo test ./...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmake-software%2Fces-go-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmake-software%2Fces-go-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmake-software%2Fces-go-parser/lists"}