Skip to content

Commit

Permalink
Fix enums
Browse files Browse the repository at this point in the history
I'm not sure why enums changed like this in webrpc..
  • Loading branch information
VojtechVitek committed May 5, 2024
1 parent 9aed493 commit c03af33
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 13 deletions.
12 changes: 6 additions & 6 deletions rpc/intents.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,10 @@ func (s *RPC) SendIntent(ctx context.Context, protoIntent *proto.Intent) (*proto
}

switch intent.Name {
case intents.IntentNameOpenSession:
case intents.IntentName_openSession:
return nil, fmt.Errorf("opening a session is unsupported outside of RegisterSession")

case intents.IntentNameCloseSession:
case intents.IntentName_closeSession:
intentTyped, err := intents.NewIntentTypedFromIntent[intents.IntentDataCloseSession](intent)
if err != nil {
return nil, err
Expand All @@ -90,7 +90,7 @@ func (s *RPC) SendIntent(ctx context.Context, protoIntent *proto.Intent) (*proto
}
return makeIntentResponse("sessionClosed", intents.IntentResponseSessionClosed{}), nil

case intents.IntentNameListSessions:
case intents.IntentName_listSessions:
intentTyped, err := intents.NewIntentTypedFromIntent[intents.IntentDataListSessions](intent)
if err != nil {
return nil, err
Expand All @@ -101,21 +101,21 @@ func (s *RPC) SendIntent(ctx context.Context, protoIntent *proto.Intent) (*proto
}
return makeIntentResponse("sessionsListed", sessions), nil

case intents.IntentNameSessionAuthProof:
case intents.IntentName_sessionAuthProof:
intentTyped, err := intents.NewIntentTypedFromIntent[intents.IntentDataSessionAuthProof](intent)
if err != nil {
return nil, err
}
return s.sessionAuthProof(ctx, sess, intentTyped)

case intents.IntentNameSignMessage:
case intents.IntentName_signMessage:
intentTyped, err := intents.NewIntentTypedFromIntent[intents.IntentDataSignMessage](intent)
if err != nil {
return nil, err
}
return s.signMessage(ctx, sess, intentTyped)

case intents.IntentNameSendTransaction:
case intents.IntentName_sendTransaction:
intentTyped, err := intents.NewIntentTypedFromIntent[intents.IntentDataSendTransaction](intent)
if err != nil {
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion rpc/send_transaction_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ func TestRPC_SendIntent_SendTransaction(t *testing.T) {
json.RawMessage(`{"data":"0x010203","to":"0x27CabC9700EE6Db2797b6AC1e1eCe81C72A2cD8D","type":"transaction","value":"0x2000000000"}`),
},
}
intent := generateSignedIntent(t, intents.IntentNameSendTransaction, intentData, signingSession)
intent := generateSignedIntent(t, intents.IntentName_sendTransaction, intentData, signingSession)

c := proto.NewWaasAuthenticatorClient(srv.URL, http.DefaultClient)
header := make(http.Header)
Expand Down
2 changes: 1 addition & 1 deletion rpc/sessions.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (s *RPC) RegisterSession(
return nil, nil, fmt.Errorf("parse intent: %w", err)
}

if intent.Name != intents.IntentNameOpenSession {
if intent.Name != intents.IntentName_openSession {
return nil, nil, fmt.Errorf("unexpected intent name: %q", intent.Name)
}

Expand Down
8 changes: 4 additions & 4 deletions rpc/sessions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func TestRPC_RegisterSession(t *testing.T) {
intentBuilderFn: func(t *testing.T, data intents.IntentDataOpenSession) *proto.Intent {
return &proto.Intent{
Version: "1.0.0",
Name: intents.IntentNameOpenSession,
Name: intents.IntentName_openSession,
ExpiresAt: uint64(time.Now().Add(1 * time.Minute).Unix()),
IssuedAt: uint64(time.Now().Unix()),
Data: data,
Expand Down Expand Up @@ -165,7 +165,7 @@ func TestRPC_RegisterSession(t *testing.T) {
t.Run(label, func(t *testing.T) {
if testCase.intentBuilderFn == nil {
testCase.intentBuilderFn = func(t *testing.T, data intents.IntentDataOpenSession) *proto.Intent {
return generateSignedIntent(t, intents.IntentNameOpenSession, data, signingSession)
return generateSignedIntent(t, intents.IntentName_openSession, data, signingSession)
}
}

Expand Down Expand Up @@ -277,7 +277,7 @@ func TestRPC_SendIntent_DropSession(t *testing.T) {
t.Run(label, func(t *testing.T) {
if testCase.intentBuilderFn == nil {
testCase.intentBuilderFn = func(t *testing.T, data intents.IntentDataCloseSession) *proto.Intent {
return generateSignedIntent(t, intents.IntentNameCloseSession, data, signingSession)
return generateSignedIntent(t, intents.IntentName_closeSession, data, signingSession)
}
}

Expand Down Expand Up @@ -408,7 +408,7 @@ func TestRPC_SendIntent_ListSessions(t *testing.T) {
intentData := &intents.IntentDataListSessions{
Wallet: walletAddr,
}
intent := generateSignedIntent(t, intents.IntentNameListSessions, intentData, signingSession)
intent := generateSignedIntent(t, intents.IntentName_listSessions, intentData, signingSession)

c := proto.NewWaasAuthenticatorClient(srv.URL, http.DefaultClient)
header := make(http.Header)
Expand Down
2 changes: 1 addition & 1 deletion rpc/sign_message_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ func TestRPC_SendIntent_SignMessage(t *testing.T) {
Wallet: walletAddr,
Message: "Test",
}
intent := generateSignedIntent(t, intents.IntentNameSignMessage, intentData, signingSession)
intent := generateSignedIntent(t, intents.IntentName_signMessage, intentData, signingSession)

c := proto.NewWaasAuthenticatorClient(srv.URL, http.DefaultClient)
header := make(http.Header)
Expand Down

0 comments on commit c03af33

Please sign in to comment.