Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend pasing logic with addressable entity #10

Merged
merged 4 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 43 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ with `casper-go-sdk`:
package main

import (
"context"
"fmt"
"net/http"
"context"
"fmt"
"net/http"

"github.com/make-software/casper-go-sdk/v2/casper"
"github.com/make-software/casper-go-sdk/v2/casper"

"github.com/make-software/ces-go-parser/v2"
"github.com/make-software/ces-go-parser/v2"
)

func main() {
Expand All @@ -49,7 +49,7 @@ func main() {
panic(err)
}

parseResults, err := parser.ParseExecutionResults(deployResult.ExecutionResults.ExecutionResult)
parseResults, err := parser.ParseExecutionResults(deployResult.ExecutionResults.ExecutionResult)
if err != nil {
panic(err)
}
Expand All @@ -62,6 +62,43 @@ func main() {
}
```

## Migrating from 1.5.x to 2.x

To upgrade to `ces-go-parser` version `2.x`, you need to update the parser version in your `go.mod` file and adjust all
import paths in your project.

Specifically, append `/v2` to the import path, for example, update:
```go
"github.com/make-software/ces-go-parser"
```

to:

```go
"github.com/make-software/ces-go-parser/v2"
```

In version `2.x`, `ces-go-parser` supports event parsing from smart contracts defined as `AddressableEntity` on the network, leveraging the [GO SDK V2](https://github.com/make-software/casper-go-sdk/releases/tag/v2.0.2-beta1).
By default, the parser will attempt to load smart contracts as `AddressableEntity`.

If you need to use the new parser version with a `1.5.x` network, you can utilize the `NewParserWithVersion` constructor
to specify the version, preventing an extra network calls to read the smart contract as an `AddressableEntity`.

```go
parser, err := ces.NewParserWithVersion(rpcClient, []casper.Hash{contractHash}, ces.NetworkVersionV1)
if err != nil {
panic(err)
}
```

### Breaking changes

The public interface of the `ces-go-parser` remains almost the same.

There is only one interface change:

- `func LoadContractMetadataWithoutSchema` accept list of `NamedKeys` and ContractPackageHash instead of `casper.Contract`

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's make it more user-oriented.

Migration to Casper 2.0.0 (Condor)

Casper 2.0.0 introduces changes in the API that aren't backward compatible with Casper 1.x. To use CES Go Parser with Casper 2.0.0 you need to the the version v2 of the parser:

    "github.com/make-software/ces-go-parser/v2"

If 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 soft-migration constructor that requires you to specify the network version you are currently running on:

 	parser, err := ces.NewParserWithVersion(rpcClient, []casper.Hash{contractHash}, ces.CasperVersion1x)
 	if err != nil {
 		panic(err)
 	}

Breaking changes

In CES Go Parser 2.0.0, the LoadContractMetadataWithoutSchema function accepts a list of NamedKeys and ContractPackageHash instead of casper.Contract it accepted previously:

// @todo Example here

## API

Go CES Parser provides several public types and functions:
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ require (
github.com/golang/mock v1.6.0
github.com/make-software/casper-go-sdk/v2 v2.0.1-beta1.0.20240725075941-fdac8c4ae070
github.com/stretchr/testify v1.8.2
golang.org/x/sync v0.6.0
)

require (
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.6.0 h1:5BMeUDZ7vkXGfEr1x9B4bRcTH4lpkTkpdh0T/J+qjbQ=
golang.org/x/sync v0.6.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
Loading
Loading