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

thiagodeev/rpcv08-websocket #651

Merged
merged 45 commits into from
Feb 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
2d3dcce
Update go.mod to include gorilla/websocket and enhance RPC provider w…
thiagodeev Dec 24, 2024
418db12
Enhance NewWebsocketProvider with cookie support in provider.go
thiagodeev Jan 3, 2025
1247764
Added new errors
thiagodeev Jan 6, 2025
f7f342f
Refactor RPC client and enhance WebSocket support
thiagodeev Jan 7, 2025
6d54e5a
adds remaining test data and improves tests, and adapt subscribe meth…
thiagodeev Jan 8, 2025
f188b94
Enhance Starknet WebSocket support and subscription handling
thiagodeev Jan 8, 2025
71d5a4e
improves newHeads method and WS close message
thiagodeev Jan 10, 2025
05d7e90
Enhance Starknet compatibility and testing framework
thiagodeev Jan 10, 2025
c73bfce
Fixes linter and test errors
thiagodeev Jan 13, 2025
76d01c8
draft implementation of subscribeEvents
thiagodeev Jan 14, 2025
f678b3f
client adaptation and functional version of subscribeEvents
thiagodeev Jan 14, 2025
245dbac
Implement SubscribeEvents functionality in WebSocket provider with en…
thiagodeev Jan 15, 2025
094d21f
finish subscribeEvents tests
thiagodeev Jan 15, 2025
d01082f
add starknet-spec updates
thiagodeev Jan 16, 2025
f386d32
Finish subscribeTransactionStatus
thiagodeev Jan 16, 2025
4d61a71
Implement SubscribePendingTransactions
thiagodeev Jan 22, 2025
67c1eb7
revert mistake in the account_test.go file
thiagodeev Jan 22, 2025
6c22c90
improve SubscribeNewHeads param
thiagodeev Jan 22, 2025
c5c147f
improve SubscribeEvents method
thiagodeev Jan 22, 2025
8f99018
Add SubscribePendingTransactions tests
thiagodeev Jan 22, 2025
087ed79
Add support for Reorg notifications
thiagodeev Jan 23, 2025
e3bc2d1
add TestUnsubscribe
thiagodeev Jan 24, 2025
8b908c5
Create WebsocketProvider interface
thiagodeev Jan 30, 2025
a0dd75a
Remove some TODO comments
thiagodeev Jan 30, 2025
ecfe19f
Reorg ws methods alphabetically
thiagodeev Jan 30, 2025
838bd82
Improve ws methods description
thiagodeev Jan 30, 2025
35023f8
Add WebSocket example with detailed usage and README update
thiagodeev Jan 30, 2025
359fc44
Merge branch 'v0.8.0' into thiagodeev/rpcv08-websocket
thiagodeev Jan 30, 2025
2457999
Update README with WebSocket example documentation
thiagodeev Jan 30, 2025
9bae8fb
Update CI workflow to build WebSocket and typedData projects
thiagodeev Jan 30, 2025
956df89
Remove HexToFeltNoErr
thiagodeev Jan 30, 2025
4beb3ff
Refactor WebSocket subscription types with SubscriptionBlockID and re…
thiagodeev Jan 30, 2025
3dc8e5f
Fix PR review comments
thiagodeev Jan 30, 2025
4cf22d8
Improve TestSubscribeEvents testcase description and fix PR comment
thiagodeev Jan 30, 2025
03ba2e3
Fix SubscribeTransactionStatus with new Juno update
thiagodeev Jan 31, 2025
cb50e23
New 'is_reverted' field from spec update
thiagodeev Jan 31, 2025
ddb9962
Update 'subscription_id' handling
thiagodeev Feb 11, 2025
018c234
Compare error with the expected one in TestSubscribePendingTransactions
thiagodeev Feb 11, 2025
c88e506
Add TestReorgEvents placeholder
thiagodeev Feb 11, 2025
abfd00e
Replace INTEGRATION_BASE to HTTP_PROVIDER_URL, and add WS_PROVIDER_UR…
thiagodeev Feb 11, 2025
501aece
change 'beforeEach' func to validate ws tests
thiagodeev Feb 24, 2025
0e90d77
fix ws tests error in 'devnet' env
thiagodeev Feb 24, 2025
24dde9a
Fix ws tests when running in other envs
thiagodeev Feb 24, 2025
e8178c6
Fix TestSubscribePendingTransactions test and types
thiagodeev Feb 24, 2025
6010852
Rename env in github actions
thiagodeev Feb 24, 2025
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
16 changes: 12 additions & 4 deletions .github/workflows/main_ci_check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
run: cd rpc && go test -timeout 600s -v -env devnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "http://localhost:5050/"
HTTP_PROVIDER_URL: "http://localhost:5050/"

# Test rpc on mock
- name: Test RPC with mocks
Expand All @@ -43,31 +43,39 @@ jobs:
run: cd rpc && go test -timeout 1200s -v -env testnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://free-rpc.nethermind.io/sepolia-juno"
HTTP_PROVIDER_URL: ${{ secrets.TESTNET_HTTP_PROVIDER_URL}}
WS_PROVIDER_URL: ${{ secrets.TESTNET_WS_PROVIDER_URL }}

# Test rpc on mainnet
- name: Test RPC with mainnet
run: echo "Skip for now - need public endpoint that follows rpc spec"
#run: cd rpc && go test -timeout 600s -v -env mainnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://free-rpc.nethermind.io/mainnet-juno"
HTTP_PROVIDER_URL: ${{ secrets.MAINNET_HTTP_PROVIDER_URL}}
WS_PROVIDER_URL: ${{ secrets.MAINNET_WS_PROVIDER_URL }}

# Test Account on devnet
- name: Test Account on devnet
run: cd account && go test -timeout 600s -v -env devnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "http://localhost:5050"
HTTP_PROVIDER_URL: "http://localhost:5050"

# Test Account on mock
- name: Test Account with mocks
run: cd account && go test -v . -env mock

# Test client on mock
- name: Test client with mocks
run: cd client && go test -v

# Build examples
- name: Build examples
run: |
cd examples/deployAccount && go build
cd ../simpleCall && go build
cd ../simpleInvoke && go build
cd ../deployContractUDC && go build
cd ../typedData && go build
cd ../websocket && go build
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ jobs:
run: go test -timeout 600s -v -env devnet -run "^(TestRPC|TestGeneral)" .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "http://localhost:5050/"
HTTP_PROVIDER_URL: "http://localhost:5050/"
2 changes: 1 addition & 1 deletion .github/workflows/test_account.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: cd account && go test -timeout 600s -v -env devnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "http://localhost:5050"
HTTP_PROVIDER_URL: "http://localhost:5050"

# Test Account on mock
- name: Test Account with mocks
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test_rpc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ jobs:
run: cd rpc && go test -timeout 600s -v -env devnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "http://localhost:5050/"
HTTP_PROVIDER_URL: "http://localhost:5050/"

# Test rpc on mock
- name: Test RPC with mocks
Expand All @@ -46,12 +46,14 @@ jobs:
#run: cd rpc && go test -timeout 1200s -v -env testnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://free-rpc.nethermind.io/sepolia-juno"
HTTP_PROVIDER_URL: ${{ secrets.TESTNET_HTTP_PROVIDER_URL}}
WS_PROVIDER_URL: ${{ secrets.TESTNET_WS_PROVIDER_URL }}

# Test rpc on mainnet
- name: Test RPC with mainnet
run: echo "Skip for now - need public endpoint that follows rpc spec"
#run: cd rpc && go test -timeout 600s -v -env mainnet .
env:
TESTNET_ACCOUNT_PRIVATE_KEY: ${{ secrets.TESTNET_ACCOUNT_PRIVATE_KEY }}
INTEGRATION_BASE: "https://free-rpc.nethermind.io/mainnet-juno"
HTTP_PROVIDER_URL: ${{ secrets.MAINNET_HTTP_PROVIDER_URL}}
WS_PROVIDER_URL: ${{ secrets.MAINNET_WS_PROVIDER_URL }}
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ operations on the wallets. The package has excellent documentation for a smooth
- [invoke transaction example](./examples/simpleInvoke) to add a new invoke transaction on testnet.
- [deploy contract UDC example](./examples/deployContractUDC) to deploy an ERC20 token using [UDC (Universal Deployer Contract)](https://docs.starknet.io/architecture-and-concepts/accounts/universal-deployer/) on testnet.
- [typed data example](./examples/typedData) to sign and verify a typed data.
- [websocket example](./examples/websocket) to learn how to subscribe to WebSocket methods.

### Run Examples

Expand Down Expand Up @@ -105,6 +106,15 @@ go run main.go

> Check [here](examples/typedData/README.md) for more details.

***starknet websocket***

```sh
cd examples/websocket
go run main.go
```

> Check [here](examples/websocket/README.md) for more details.

<br/> Check [here](https://github.com/NethermindEth/starknet.go/tree/main/examples) for some FAQ answered by these examples.


Expand Down
10 changes: 5 additions & 5 deletions account/account_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var (
//
// It sets up the test environment by parsing command line flags and loading environment variables.
// The test environment can be set using the "env" flag.
// It then sets the base path for integration tests by reading the value from the "INTEGRATION_BASE" environment variable.
// It then sets the base path for integration tests by reading the value from the "HTTP_PROVIDER_URL" environment variable.
// If the base path is not set and the test environment is not "mock", it panics.
// Finally, it exits with the return value of the test suite
//
Expand All @@ -48,12 +48,12 @@ func TestMain(m *testing.M) {
if testEnv == "mock" {
return
}
base = os.Getenv("INTEGRATION_BASE")
base = os.Getenv("HTTP_PROVIDER_URL")
if base == "" {
if err := godotenv.Load(fmt.Sprintf(".env.%s", testEnv)); err != nil {
panic(fmt.Sprintf("Failed to load .env.%s, err: %s", testEnv, err))
}
base = os.Getenv("INTEGRATION_BASE")
base = os.Getenv("HTTP_PROVIDER_URL")
}
os.Exit(m.Run())
}
Expand Down Expand Up @@ -1076,7 +1076,7 @@ func TestWaitForTransactionReceipt(t *testing.T) {
Timeout: 3, // Should poll 3 times
Hash: new(felt.Felt).SetUint64(100),
ExpectedReceipt: rpc.TransactionReceipt{},
ExpectedErr: rpc.Err(rpc.InternalError, &rpc.RPCData{Message: "Post \"http://localhost:5050\": context deadline exceeded"}),
ExpectedErr: rpc.Err(rpc.InternalError, &rpc.RPCData{Message: "context deadline exceeded"}),
},
},
}[testEnv]
Expand All @@ -1090,7 +1090,7 @@ func TestWaitForTransactionReceipt(t *testing.T) {
rpcErr, ok := err.(*rpc.RPCError)
require.True(t, ok)
require.Equal(t, test.ExpectedErr.Code, rpcErr.Code)
require.Equal(t, test.ExpectedErr.Data.Message, rpcErr.Data.Message)
require.Contains(t, rpcErr.Data.Message, test.ExpectedErr.Data.Message) // sometimes the error message starts with "Post \"http://localhost:5050\":..."
} else {
require.Equal(t, test.ExpectedReceipt.ExecutionStatus, (*resp).ExecutionStatus)
}
Expand Down
Loading