Skip to content

Commit

Permalink
feat: add devnet tools
Browse files Browse the repository at this point in the history
  • Loading branch information
simonheys committed Jul 5, 2022
1 parent e3f2c95 commit 281fb14
Show file tree
Hide file tree
Showing 9 changed files with 61,077 additions and 25 deletions.
14 changes: 9 additions & 5 deletions Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,13 +121,13 @@ To test changes made to the `extension` package you need to load the local unpac

Some tests require [`starknet-devnet`](https://github.com/Shard-Labs/starknet-devnet) to be available at http://127.0.0.1:5050/. If tests are run without then you may see errors including `connect ECONNREFUSED 127.0.0.1:5050`.

For convenience this service can be started with Docker, note if successful there will be no message displayed;
### Run devnet locally

- For ARM computers (e.g. Mac computers with Apple silicon)
For convenience this service can be started with [Docker desktop](https://www.docker.com/get-started/) running;

```bash
docker run -it -p 5050:5050 shardlabs/starknet-devnet:latest-arm --seed 0
```
```bash
docker run -it -p 5050:5050 shardlabs/starknet-devnet:latest-arm --seed 0
```

- Otherwise

Expand All @@ -142,6 +142,10 @@ yarn test # run unit tests for all packages
yarn test:e2e # run end-to-end tests for all packages
```

### Tools to help with testing

See also [/docs/tools-for-local-testing.md](/docs/tools-for-local-testing.md)

## ✏️ Contributing

Everyone is welcome to contribute. Please take a moment to review the [contributing guidelines](Contributing.md).
Expand Down
33 changes: 33 additions & 0 deletions docs/tools-for-local-testing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 🧪 Tools for local testing only

## ⬆️ Contract upgrades

To help test contract upgrades there is a simple script which will declare an upgradable contract to a locally running devnet and allow you to transfer funds to a local wallet.

- Make sure you have devnet running locally (see above)

```bash
# For ARM computers (e.g. Mac computers with Apple silicon)
yarn devnet:start:arm

# otherwise
yarn devnet:start
```

- Start the tool and declare the contract (make note of the contract class hash for later)

```bash
# switch to Node 18
nvm use 18

# start the tool
yarn devnet:upgrade-helper
```

- Set the contract class hash in Settings → Manage Networks → Localhost → Advanced

- You should then see that an account upgrade is available

- Transfer some ETH to your local wallet so you have funds to upgrade

- You can reset the contract class hash to make upgrade available again
10 changes: 9 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,18 @@
"repository": "github:argentlabs/argent-x",
"homepage": "https://github.com/argentlabs/argent-x/#readme",
"devDependencies": {
"@tsconfig/node18": "^1.0.1",
"@types/prompt": "^1.1.2",
"bundlewatch": "^0.3.3",
"husky": "^8.0.0",
"import-sort-style-module": "^6.0.0",
"lerna": "^5.0.0",
"lint-staged": ">=10",
"prettier": ">=2",
"prettier-plugin-import-sort": "^0.0.7",
"prompt": "^1.3.0",
"starknet": "^3.16.0",
"ts-node": "^10.8.1",
"typescript": "^4.7.4"
},
"workspaces": [
Expand All @@ -27,7 +32,10 @@
"test": "lerna run test --stream",
"test:e2e": "lerna run test:e2e --stream",
"prepare": "yarn --cwd packages/get-starknet build && husky install",
"storybook": "cd packages/storybook && yarn storybook"
"storybook": "cd packages/storybook && yarn storybook",
"devnet:start": "docker run -it -p 5050:5050 shardlabs/starknet-devnet:latest --seed 0 --accounts 1",
"devnet:start:arm": "docker run -it -p 5050:5050 shardlabs/starknet-devnet:latest-arm --seed 0 --accounts 1",
"devnet:upgrade-helper": "NODE_NO_WARNINGS=1 ts-node ./scripts/devnet/devnet-upgrade-helper.ts"
},
"importSort": {
".js, .jsx, .ts, .tsx": {
Expand Down
8 changes: 1 addition & 7 deletions packages/extension/src/background/accountUpgrade.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { stark } from "starknet/src"
import { stark } from "starknet"

import { ActionItem } from "../shared/actionQueue"
import { BaseWalletAccount } from "../shared/wallet.model"
Expand All @@ -12,12 +12,6 @@ export interface IUpgradeAccount {
actionQueue: Queue<ActionItem>
}

/* TODO: remove
contract class hashes
0x3e327de1c40540b98d05cbcb13552008e36f0ec8d61d46956d2f9752c294328
0x2dd6540d2f692de21cea9e842672f6fdf70063dd801ccd8d354ede601156d58
*/

export const upgradeAccount = async ({
account,
wallet,
Expand Down
2 changes: 0 additions & 2 deletions packages/extension/src/ui/features/accounts/UpgradeScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ export const UpgradeScreen: FC = () => {
confirmButtonText="Upgrade"
rejectButtonText="Cancel"
onSubmit={async () => {
useAppState.setState({ isLoading: true })
await upgradeAccount(selectedAccount)
useAppState.setState({ isLoading: false })
navigate(routes.accountTokens())
}}
onReject={() => {
Expand Down
31 changes: 31 additions & 0 deletions scripts/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
module.exports = {
env: {
es2021: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:react/recommended",
"plugin:@typescript-eslint/recommended",
],
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: "latest",
sourceType: "module",
},
plugins: ["@typescript-eslint"],
rules: {
"@typescript-eslint/no-explicit-any": "off",
"@typescript-eslint/no-extra-semi": "off",
"@typescript-eslint/no-unused-vars": [
"warn",
{
vars: "all",
ignoreRestSiblings: true,
argsIgnorePattern: "^_",
},
],
"@typescript-eslint/no-non-null-assertion": "error",
curly: "error",
},
}
Loading

0 comments on commit 281fb14

Please sign in to comment.