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

Remove staking target requirement #18

Merged
merged 2 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
11 changes: 9 additions & 2 deletions .github/workflows/test.yaml → .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Go Test
name: CI

on:
push:
Expand All @@ -12,7 +12,8 @@ permissions:
contents: read

jobs:
test:
ci:
name: ci
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -25,5 +26,11 @@ jobs:
- name: Build
run: go build -v ./...

- name: Lint
uses: golangci/golangci-lint-action@v4
with:
version: v1.54.2
args: --timeout=3m

- name: Test
uses: robherley/go-test-action@v0
28 changes: 0 additions & 28 deletions .github/workflows/lint.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Version 🔖

on:
push:
branches:
- main
paths:
- '.version'

concurrency: ${{ github.workflow }}-${{ github.ref }}

jobs:
release:
runs-on: ubuntu-latest
environment: release
permissions:
contents: write
id-token: write

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Get version from .version file
id: release_version
run: echo "VERSION=$(cat .version")" >> $GITHUB_OUTPUT

- name: Check if tag exists
id: check_tag
run: |
git fetch --tags
if git rev-parse "v${{ steps.release_version.outputs.VERSION }}" >/dev/null 2>&1; then
echo "::set-output name=EXISTS::true"
fi

- name: Create Release
if: steps.check_tag.outputs.EXISTS != 'true'
uses: softprops/action-gh-release@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: v${{ steps.release_version.outputs.VERSION }}
name: Release v${{ steps.release_version.outputs.VERSION }}
draft: false
prerelease: false
generate_release_notes: true
make_latest: true
1 change: 1 addition & 0 deletions .version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
0.5.0
78 changes: 76 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ func main() {
Parameters: &api.EthereumKilnStakingParameters_StakeParameters{
StakeParameters: &api.EthereumKilnStakeParameters{
StakerAddress: "0xdb816889F2a7362EF242E5a717dfD5B38Ae849FE",
IntegratorContractAddress: "0xA55416de5DE61A0AC1aa8970a280E04388B1dE4b",
Amount: &api.Amount{
Value: "20",
Currency: "ETH",
Expand All @@ -91,7 +90,82 @@ func main() {
<summary>Output</summary>

```text
2024/03/28 11:43:49 Workflow created: projects/62376b2f-3f24-42c9-9025-d576a3c06d6f/workflows/ffbf9b45-c57b-49cb-a4d5-fdab66d8cb25
2024/03/28 11:43:49 Workflow created: workflows/ffbf9b45-c57b-49cb-a4d5-fdab66d8cb25
```

</details>

### Stake SOL :diamond_shape_with_a_dot_inside:

This code sample creates an SOL staking workflow. View the full code sample [here](examples/solana/create-workflow/main.go)

<details open>
<summary>Code Sample</summary>

```golang
// examples/solana/create-workflow/main.go
package main

import (
"context"
"log"

"github.com/coinbase/staking-client-library-go/auth"
"github.com/coinbase/staking-client-library-go/client"
"github.com/coinbase/staking-client-library-go/client/options"
api "github.com/coinbase/staking-client-library-go/gen/go/coinbase/staking/orchestration/v1"
)

func main() {
ctx := context.Background()

// Loads the API key from the default location.
apiKey, err := auth.NewAPIKey(auth.WithLoadAPIKeyFromFile(true))
if err != nil {
log.Fatalf("error loading API key: %s", err.Error())
}

// Creates the Coinbase Staking API client.
stakingClient, err := client.New(ctx, options.WithAPIKey(apiKey))
if err != nil {
log.Fatalf("error instantiating staking client: %s", err.Error())
}

req := &api.CreateWorkflowRequest{
Workflow: &api.Workflow{
Action: "protocols/solana/networks/devnet/actions/stake",
StakingParameters: &api.Workflow_SolanaStakingParameters{
SolanaStakingParameters: &api.SolanaStakingParameters{
Parameters: &api.SolanaStakingParameters_StakeParameters{
StakeParameters: &api.SolanaStakeParameters{
WalletAddress: walletAddress,
Amount: &api.Amount{
Value: amount,
Currency: currency,
},
},
},
},
},
},
}

workflow, err := stakingClient.Orchestration.CreateWorkflow(ctx, req)
if err != nil {
log.Fatalf("couldn't create workflow: %s", err.Error())
}

log.Printf("Workflow created: %s", workflow.Name)
}
```

</details>

<details>
<summary>Output</summary>

```text
2024/03/28 11:43:49 Workflow created: workflows/6bd9fd82-8b9d-4a49-9039-f95bb850a7a2
```

</details>
Expand Down
10 changes: 4 additions & 6 deletions examples/ethereum/create-and-process-workflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,9 @@ const (
privateKey = ""

// TODO: Replace with your staker addresses and amount.
stakerAddress = ""
integratorContractAddress = "0xA55416de5DE61A0AC1aa8970a280E04388B1dE4b"
amount = "11"
currency = "ETH"
stakerAddress = ""
amount = "11"
currency = "ETH"
)

// An example function to demonstrate how to use the staking client libraries.
Expand Down Expand Up @@ -59,8 +58,7 @@ func main() {
EthereumKilnStakingParameters: &api.EthereumKilnStakingParameters{
Parameters: &api.EthereumKilnStakingParameters_StakeParameters{
StakeParameters: &api.EthereumKilnStakeParameters{
StakerAddress: stakerAddress,
IntegratorContractAddress: integratorContractAddress,
StakerAddress: stakerAddress,
Amount: &api.Amount{
Value: amount,
Currency: currency,
Expand Down
12 changes: 9 additions & 3 deletions examples/ethereum/create-workflow/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import (
"context"
"log"

"google.golang.org/protobuf/encoding/protojson"

"github.com/coinbase/staking-client-library-go/auth"
"github.com/coinbase/staking-client-library-go/client"
"github.com/coinbase/staking-client-library-go/client/options"
Expand Down Expand Up @@ -36,8 +38,7 @@ func main() {
EthereumKilnStakingParameters: &api.EthereumKilnStakingParameters{
Parameters: &api.EthereumKilnStakingParameters_StakeParameters{
StakeParameters: &api.EthereumKilnStakeParameters{
StakerAddress: "0xdb816889F2a7362EF242E5a717dfD5B38Ae849FE",
IntegratorContractAddress: "0xA55416de5DE61A0AC1aa8970a280E04388B1dE4b",
StakerAddress: "0xdb816889F2a7362EF242E5a717dfD5B38Ae849FE",
Amount: &api.Amount{
Value: "20",
Currency: "ETH",
Expand All @@ -54,5 +55,10 @@ func main() {
log.Fatalf("couldn't create workflow: %s", err.Error())
}

log.Printf("Workflow created: %s", workflow.Name)
marshaled, err := protojson.MarshalOptions{Indent: " ", Multiline: true}.Marshal(workflow)
if err != nil {
log.Fatalf("error marshaling reward: %s", err.Error())
}

log.Printf("Workflow created: \n%s", marshaled)
}
Loading