Skip to content

fix: update get-starknet-core version #372

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

Merged
merged 2 commits into from
Jan 14, 2025
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
1 change: 1 addition & 0 deletions examples/example-vite-react-sql/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
"drizzle-kit": "^0.30.1",
"postcss": "^8.4.49",
"tailwindcss": "^3.4.17",
"typescript": "^5.6.2",
"vite": "^6.0.7",
"vite-plugin-top-level-await": "^1.4.4",
"vite-plugin-wasm": "^3.4.1"
Expand Down
4 changes: 2 additions & 2 deletions packages/create-burner/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,9 @@
"dependencies": {
"@dojoengine/core": "workspace:*",
"@scure/bip32": "^1.5.0",
"@starknet-react/core": "2.3.0",
"@starknet-react/core": "catalog:",
"encoding": "^0.1.13",
"get-starknet-core": "^3.3.3",
"get-starknet-core": "catalog:",
"js-cookie": "^3.0.5"
}
}
21 changes: 15 additions & 6 deletions packages/create-burner/src/connectors/burner.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Connector } from "@starknet-react/core";
import { StarknetWindowObject } from "get-starknet-core";
import { Account, AccountInterface, shortString } from "starknet";

import { katanaIcon } from "./icons";
Expand All @@ -16,12 +17,8 @@ interface BurnerConnectorOptions {
/** Non exported types from @starknet-react/core*/

/** Connector icons, as base64 encoded svg. */
type ConnectorIcons = {
/** Dark-mode icon. */
dark?: string;
/** Light-mode icon. */
light?: string;
};
type ConnectorIcons = StarknetWindowObject["icon"];

/** Connector data. */
type ConnectorData = {
/** Connector account. */
Expand Down Expand Up @@ -104,4 +101,16 @@ export class BurnerConnector extends Connector {
}
);
}

async request(call: any) {
switch (call.type) {
case "wallet_requestAccounts": {
return [this._account.address];
}
default:
throw new Error(
`BurnerConnector: request not implemented [${call.type}]`
);
}
}
Comment on lines +105 to +115
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Improve type safety and documentation of the request method.

Several improvements are recommended:

  1. Replace any with proper request type from get-starknet-core.
  2. Add JSDoc documentation explaining the method's purpose and parameters.
  3. Consider implementing other standard wallet request types.

Apply this diff to improve the implementation:

+    /**
+     * Handles wallet requests as per the Starknet wallet standard.
+     * @param {StarknetWindowObject['request']['parameters'][0]} call - The request parameters
+     * @returns {Promise<any>} The request result
+     */
-    async request(call: any) {
+    async request(call: StarknetWindowObject['request']['parameters'][0]) {
         switch (call.type) {
             case "wallet_requestAccounts": {
                 return [this._account.address];
             }
+            case "wallet_switchChain": {
+                // TODO: Implement chain switching
+                throw new Error("Chain switching not implemented");
+            }
             default:
                 throw new Error(
-                    `BurnerConnector: request not implemented [${call.type}]`
+                    `BurnerConnector: The request type "${call.type}" is not supported. ` +
+                    `Supported types: wallet_requestAccounts`
                 );
         }
     }

Committable suggestion skipped: line range outside the PR's diff.


💡 Codebase verification

Implement missing wallet standard methods

The BurnerConnector is missing several standard wallet methods that are implemented in the predeployed connector. At minimum, implement:

  • wallet_getPermissions: Required for permission management
  • wallet_requestChainId: Required for network identification
  • wallet_addInvokeTransaction: Required for transaction execution
  • wallet_signTypedData: Required for message signing
🔗 Analysis chain

Verify implementation against Starknet wallet standard.

Let's verify if we're implementing all required wallet methods.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for wallet method implementations in get-starknet-core
rg -A 5 'wallet_[a-zA-Z]+' $(fd -t f -e ts -e js get-starknet-core)

# Search for other burner wallet implementations for comparison
rg -A 5 'class.*extends.*Connector.*{' $(fd -t f -e ts)

Length of output: 19212


Script:

#!/bin/bash
# Search for wallet interface definitions
ast-grep --pattern 'interface $_ {
  $$$
  wallet_$$$
  $$$
}'

# Search for any type definitions related to wallet methods
rg -A 5 'type.*Wallet' 

Length of output: 564


Script:

#!/bin/bash
# Find connector/provider interface files
fd -t f -e ts "(connector|provider|interface)" 

# Search for interface definitions in those files
rg -A 10 "interface.*Connector|interface.*Provider|interface.*Wallet"

# Look for documentation files
fd -t f "README|SPEC|standard" -e md

Length of output: 3115


Script:

#!/bin/bash
# Search for Starknet-related files
fd -t f -e ts "starknet|wallet"

# Search for Starknet-related types and interfaces
rg -A 10 "type.*Starknet|interface.*Starknet|enum.*Starknet"

# Search for wallet method constants or types
rg -A 5 "const.*WALLET_|type.*WALLET_|enum.*Wallet"

Length of output: 889

}
4 changes: 2 additions & 2 deletions packages/create-burner/src/connectors/dojoBurnerSWO.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IStarknetWindowObject } from "get-starknet-core";
import { StarknetWindowObject } from "get-starknet-core";
import { AccountInterface, RpcProvider } from "starknet";

import { BurnerManager } from "..";
Expand All @@ -8,7 +8,7 @@ const ID = "dojoburner";
const NAME = "Dojo Burner";
const VERSION = "0.0.1";

export class DojoBurnerStarknetWindowObject implements IStarknetWindowObject {
export class DojoBurnerStarknetWindowObject implements StarknetWindowObject {
id = ID;
name = NAME;
icon = katanaIcon;
Expand Down
4 changes: 2 additions & 2 deletions packages/create-burner/src/connectors/dojoPredeployedSWO.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IStarknetWindowObject } from "get-starknet-core";
import { StarknetWindowObject } from "get-starknet-core";
import { AccountInterface, RpcProvider } from "starknet";

import { PredeployedManager } from "..";
Expand All @@ -9,7 +9,7 @@ const NAME = "Dojo Predeployed";
const VERSION = "0.0.1";

export class DojoPredeployedStarknetWindowObject
implements IStarknetWindowObject
implements StarknetWindowObject
{
id = ID;
name = NAME;
Expand Down
2 changes: 1 addition & 1 deletion packages/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"@latticexyz/utils": "^2.2.8",
"encoding": "^0.1.13",
"fast-deep-equal": "^3.1.3",
"get-starknet-core": "^3.3.3",
"get-starknet-core": "catalog:",
"js-cookie": "^3.0.5",
"rxjs": "7.5.5",
"zustand": "^4.5.5"
Expand Down
45 changes: 14 additions & 31 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ packages:

catalog:
starknet: 6.21.0
get-starknet-core: ^3.3.4
get-starknet-core: ^4.0.0
"@starknet-react/core": ^3.6.2
"@starknet-react/chains": ^3.1.0
Loading