Skip to content

Commit

Permalink
feat: Delete web3 wallets (#321)
Browse files Browse the repository at this point in the history
  • Loading branch information
NicolasLopes7 authored Sep 5, 2024
1 parent 84b590a commit 7bfc31c
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
5 changes: 5 additions & 0 deletions user/api.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions user/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,15 @@ func (c *Client) DeletePasskey(ctx context.Context, userID, identificationID str
err = c.Backend.Call(ctx, req, resource)
return resource, err
}

// DeleteWeb3Wallet deletes a web3 wallet by its identification ID.
func (c *Client) DeleteWeb3Wallet(ctx context.Context, userID, identificationID string) (*clerk.DeletedResource, error) {
path, err := clerk.JoinPath(path, userID, "/web3_wallets", identificationID)
if err != nil {
return nil, err
}
req := clerk.NewAPIRequest(http.MethodDelete, path)
resource := &clerk.DeletedResource{}
err = c.Backend.Call(ctx, req, resource)
return resource, err
}
19 changes: 19 additions & 0 deletions user/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -441,3 +441,22 @@ func TestUserClientDeletePasskey(t *testing.T) {
require.NoError(t, err)
require.Equal(t, passkeyIdentificationID, passkey.ID)
}

func TestUserClientDeleteWeb3Wallet(t *testing.T) {
t.Parallel()
userID := "user_123"
web3WalletIdentificationID := "idn_345"
config := &clerk.ClientConfig{}
config.HTTPClient = &http.Client{
Transport: &clerktest.RoundTripper{
T: t,
Out: json.RawMessage(fmt.Sprintf(`{"id":"%s"}`, web3WalletIdentificationID)),
Method: http.MethodDelete,
Path: "/v1/users/" + userID + "/web3_wallets/" + web3WalletIdentificationID,
},
}
client := NewClient(config)
web3Wallet, err := client.DeleteWeb3Wallet(context.Background(), userID, web3WalletIdentificationID)
require.NoError(t, err)
require.Equal(t, web3WalletIdentificationID, web3Wallet.ID)
}

0 comments on commit 7bfc31c

Please sign in to comment.