Skip to content

Commit

Permalink
fix(sdk): fix react sdk cancel not using useArkAccount (#348)
Browse files Browse the repository at this point in the history
## Description

Fix react SDK, update useCancel to use useBurner instead of directly
declaring a new account

## What type of PR is this? (check all applicable)

- [x] 🐛 Bug Fix (`fix:`)

## Related Tickets & Documents

<!--
Please use this format to link related issues: Fixes #<issue_number>
More info:
https://docs.github.com/en/free-pro-team@latest/github/managing-your-work-on-github/linking-a-pull-request-to-an-issue#linking-a-pull-request-to-an-issue-using-a-keyword
-->

## Added tests?

- [ ] 👍 yes
- [ ] 🙅 no, because they aren't needed
- [ ] 🙋 no, because I need help

## Added to documentation?

- [ ] 📜 README.md
- [ ] 📓 Documentation
- [ ] 🙅 no documentation needed

## [optional] Are there any post-deployment tasks we need to perform?

<!-- Describe any additional tasks, if any, and provide steps. -->

## [optional] What gif best describes this PR or how it makes you feel?

<!-- Share a fun gif related to your PR! -->

### PR Title and Description Guidelines:

- Ensure your PR title follows semantic versioning standards. This helps
automate releases and changelogs.
- Use types like `feat:`, `fix:`, `chore:`, `BREAKING CHANGE:` etc. in
your PR title.
- Your PR title will be used as a commit message when merging. Make sure
it adheres to [Conventional Commits
standards](https://www.conventionalcommits.org/).

## Closing Issues

<!--
Use keywords to close related issues. This ensures that the associated
issues will automatically close when the PR is merged.

- `Fixes #123` will close issue 123 when the PR is merged.
- `Closes #123` will also close issue 123 when the PR is merged.
- `Resolves #123` will also close issue 123 when the PR is merged.

You can also use multiple keywords in one comment:
- `Fixes #123, Resolves #456`

More info:
https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue
-->
  • Loading branch information
kwiss authored Apr 26, 2024
1 parent 63de7a7 commit 90fa414
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/stupid-planets-decide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ark-project/react": minor
---

Change useCancel ark account creation with useBurnerWallet
26 changes: 4 additions & 22 deletions packages/react/src/hooks/useCancel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import { useState } from "react";

import { Account, AccountInterface } from "starknet";
import { AccountInterface } from "starknet";

import {
CancelInfo,
Expand All @@ -11,7 +11,7 @@ import {
} from "@ark-project/core";

import { Status } from "../types";
import { useArkRpc } from "./useArkRpc";
import { useBurnerWallet } from "./useBurnerWallet";
import { useConfig } from "./useConfig";
import { useOwner } from "./useOwner";

Expand All @@ -20,30 +20,12 @@ type CancelParameters = {
} & CancelInfo;

function useCancel() {
const { rpcProvider } = useArkRpc();
const [status, setStatus] = useState<Status>("idle");
const owner = useOwner();
const config = useConfig();

const arkAccount = useBurnerWallet();
async function cancel(parameters: CancelParameters) {
const burner_address = localStorage.getItem("burner_address");
const burner_private_key = localStorage.getItem("burner_private_key");
const burner_public_key = localStorage.getItem("burner_public_key");

if (
burner_address === null ||
burner_private_key === null ||
burner_public_key === null
) {
throw new Error("No burner wallet in local storage");
}

const arkAccount = new Account(
rpcProvider,
burner_address,
burner_private_key
);

if (!arkAccount) throw new Error("No burner wallet.");
try {
setStatus("loading");
await cancelOrderCore(config as Config, {
Expand Down

0 comments on commit 90fa414

Please sign in to comment.