Skip to content

Commit

Permalink
Upgrade web3 version
Browse files Browse the repository at this point in the history
  • Loading branch information
h0ngcha0 committed Feb 3, 2023
1 parent 4eaf829 commit 5c27c3b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 167 deletions.
149 changes: 9 additions & 140 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,81 +1,15 @@
<!-- logo -->
<p align="center">
<img src="https://raw.githubusercontent.com/argentlabs/argent-x/HEAD/assets/readme-header.png">
</p>

---

<h3 align='center' style='margin: 1em;'>⬇️ Get <b>Argent X</b> for StarkNet today:</h3>

<p align="center">
<a href="https://chrome.google.com/webstore/detail/argent-x-starknet-wallet/dlcobpjiigpikoobohmabehhmhfoodbb/">
<img src="https://raw.githubusercontent.com/argentlabs/argent-x/HEAD/assets/button-download.svg">
</a>
</p>
![Alephium Logo](https://raw.githubusercontent.com/alephium/alephium-brand-guide/master/logos/light/Logo-Horizontal-Light.png#gh-dark-mode-only) ![Alephium Logo](https://raw.githubusercontent.com/alephium/alephium-brand-guide/master/logos/dark/Logo-Horizontal-Dark.png#gh-light-mode-only)

---

<h2>🌈 Table of contents</h2>

- [🧒 Example dapp](#-example-dapp)
- [🌐 Usage with your dapp](#-usage-with-your-dapp)
- [🚀 Install from sources](#-install-from-sources)
- [👩🏾‍💻 Development](#-development)
- [🧪 Testing](#-testing)
- [Setup](#setup)
- [Run tests](#run-tests)
- [✏️ Contributing](#️-contributing)
- [❤️ Family and friends](#️-family-and-friends)
- [👨🏼‍🎨 Authors and license](#-authors-and-license)

## 🧒 Example dapp

You can try the extension using our example dapp hosted at:

[https://argentlabs.github.io/argent-x/](https://argentlabs.github.io/argent-x/)

The example dapp is also contained in this repository.

## 🌐 Usage with your dapp

If you want to use this StarkNet Wallet extension with your dapp, the easiest way is to checkout the `@argent/get-starknet` package developed in this repo by running:

```bash
# starknet.js is a peer dependency
yarn add @argent/get-starknet starknet
```
<h2> Table of contents</h2>

The package is a light wrapper around [starknet.js](https://github.com/0xs34n/starknet.js) to interact with the wallet extension. You can then use it like the following:
- [Install from sources](#-install-from-sources)
- [Development](#-development)

```javascript
import { connect } from "@argent/get-starknet"

// Let the user pick a wallet (on button click)
const starknet = connect()

// or try to connect to an approved wallet silently (on mount probably)
const starknet = connect({ showList: false })

if (!starknet) {
throw Error("User rejected wallet selection or silent connect found nothing")
}

// (optional) connect the wallet
await starknet.enable()

// Check if connection was successful
if(starknet.isConnected) {
// If the extension was installed and successfully connected, you have access to a starknet.js Signer object to do all kinds of requests through the user's wallet contract.
starknet.account.execute({ ... })
} else {
// In case the extension wasn't successfully connected you still have access to a starknet.js Provider to read starknet states and sent anonymous transactions
starknet.provider.callContract( ... )
}
```

Checkout [starknet.js](https://github.com/0xs34n/starknet.js) to learn more about how to use `Provider` and `Signer`.

## 🚀 Install from sources
## Install from sources

First clone this repository on your machine then run:

Expand All @@ -84,19 +18,9 @@ yarn # setup dependencies
yarn build # run build process for all packages
```

Now you need to load the locally built chrome extension into your browser, by loading an unpacked extension from path `packages/extension/dist`:

1. Open the Extension Management page by navigating to `chrome://extensions`.
2. Enable Developer Mode by clicking the toggle switch next to **Developer mode**.
3. Click the Load unpacked button and select the extension directory.

![Chrome screenshot of setup](https://wd.imgix.net/image/BhuKGJaIeLNPW9ehns59NfwqKxF2/vOu7iPbaapkALed96rzN.png?auto=format)

[Source](https://developer.chrome.com/docs/extensions/mv3/getstarted/#manifest)

## 👩🏾‍💻 Development
To load the locally built chrome extension into your browser, follow the guide [here](https://developer.chrome.com/docs/extensions/mv3/getstarted/#manifest)

To contribute to this repository please read the [contributing guidelines](Contributing.md) first.
## Development

To setup the repo on your machine just run:

Expand All @@ -105,61 +29,6 @@ yarn # setup dependencies
yarn dev # run build process for all packages in watch mode
```

This project contains 3 packages:

| package | description |
| --- | --- |
| extension | Argent X extension |
| get-starknet | npm module to get started with starknet.js and Argent X quickly |
| dapp | example dapp for testing purposes and example for dapps how to use `get-starknet` |

To test changes made to the `extension` package you need to load the local unpacked extension into Chrome as [described above](#install-fromsources). Changes are shown after reopening the extension. Changes to `background.js` are just shown after a complete restart of the Chrome process.

## 🧪 Testing

### Setup

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`.

### Run devnet locally

For convenience this service can be started with [Docker desktop](https://www.docker.com/get-started/) running;

- For ARM computers (e.g. Mac computers with Apple silicon)

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

- Otherwise

```bash
docker run -it -p 5050:5050 shardlabs/starknet-devnet:latest-seed0
```

### Run tests

```bash
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).

## ❤️ Family and friends

Since this project would not have been possible without [starknet.js](https://github.com/seanjameshan/starknet.js), we would like to say a big thank you to all [starknet.js contributors](https://github.com/0xs34n/starknet.js/graphs/contributors) and [@0xs34n](https://github.com/0xs34n) for starting it.

One more thank you to the StarkWare Team.

## 👨🏼‍🎨 Authors and license

[Argent](https://github.com/argentlabs) and [contributors](https://github.com/argentlabs/argent-x/graphs/contributors).
## Credits

GNU General Public License V3, see the included [License.md](License.md) file.
We have built this project on top of [Argent X](https://github.com/argentlabs/argent-x)'s codebase. We would like to take this oppurtunity to thank all the [contributors](https://github.com/argentlabs/argent-x/graphs/contributors) of the Argent X project ❤️
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "0.5.0-rc.1",
"version": "0.5.0-rc.2",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.0-rc.1",
"version": "0.5.0-rc.2",
"private": true,
"name": "alephium-browser-extension-wallet",
"repository": "github:alephium/extension-wallet",
Expand Down
8 changes: 4 additions & 4 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alephium/dapp",
"version": "0.5.0-rc.1",
"version": "0.5.0-rc.2",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -10,8 +10,8 @@
"lint": "next lint"
},
"dependencies": {
"@alephium/web3": "v0.3.0-rc.7",
"@alephium/get-extension-wallet": "^0.5.0-rc.1",
"@alephium/web3": "v0.3.0-rc.8",
"@alephium/get-extension-wallet": "^0.5.0-rc.2",
"@argent/get-starknet": "^5.2.0",
"@argent/x-sessions": "^5.2.0",
"ethers": "^5.5.1",
Expand All @@ -22,7 +22,7 @@
"starknet5": "npm:starknet@5.0.0-beta.3"
},
"devDependencies": {
"@alephium/cli": "v0.3.0-rc.7",
"@alephium/cli": "v0.3.0-rc.8",
"@types/node": "18.11.18",
"@types/react": "^18.0.0",
"@types/react-dom": "^18.0.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "@alephium/extension",
"version": "0.5.0-rc.1",
"version": "0.5.0-rc.2",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@alephium/sdk": "0.3.0",
"@alephium/web3": "v0.3.0-rc.7",
"@alephium/web3-wallet": "v0.3.0-rc.7",
"@alephium/web3": "v0.3.0-rc.8",
"@alephium/web3-wallet": "v0.3.0-rc.8",
"@playwright/test": "^1.23.0",
"@sentry/webpack-plugin": "^1.18.9",
"@svgr/webpack": "^6.0.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/get-extension-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alephium/get-extension-wallet",
"version": "0.5.0-rc.1",
"version": "0.5.0-rc.2",
"main": "dist/",
"browser": {
"crypto": false
Expand Down Expand Up @@ -54,6 +54,6 @@
},
"dependencies": {
"bowser": "^2.11.0",
"@alephium/web3": "v0.3.0-rc.7"
"@alephium/web3": "v0.3.0-rc.8"
}
}
2 changes: 1 addition & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "5.2.0",
"private": true,
"devDependencies": {
"@alephium/extension": "^0.5.0-rc.1",
"@alephium/extension": "^0.5.0-rc.2",
"@argent/ui": "^5.2.0",
"@babel/core": "^7.18.5",
"@chakra-ui/storybook-addon": "^4.0.12",
Expand Down
30 changes: 15 additions & 15 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
# yarn lockfile v1


"@alephium/cli@v0.3.0-rc.7":
version "0.3.0-rc.7"
resolved "https://registry.npmjs.org/@alephium/cli/-/cli-0.3.0-rc.7.tgz"
integrity sha512-anngUxSEVr9S8Xf3tyAN+4tV1V4zAlnwnBE7352FPdvlXs0F6Z/iVyWzvoVTWqOWDy10FUzoGI81jJFe8x2o8g==
"@alephium/cli@v0.3.0-rc.8":
version "0.3.0-rc.8"
resolved "https://registry.yarnpkg.com/@alephium/cli/-/cli-0.3.0-rc.8.tgz#48395fcd43abc579cd40a46a14455251af7a901b"
integrity sha512-O+PZFM5nNFQX5+cUdmGQuPXj4w+9XyFvw8xK05mDkGkPJvdvHP1NShMSzNud/xp9WlApwAB8ZJTVMKu3QjU/vg==
dependencies:
"@alephium/web3" "^0.3.0-rc.7"
"@alephium/web3-wallet" "^0.3.0-rc.7"
"@alephium/web3" "^0.3.0-rc.8"
"@alephium/web3-wallet" "^0.3.0-rc.8"
commander "^9.4.0"
cross-fetch "^3.1.5"
crypto-js "^4.1.1"
Expand All @@ -29,23 +29,23 @@
crypto-js "^4.1.1"
elliptic "^6.5.4"

"@alephium/web3-wallet@^0.3.0-rc.7", "@alephium/web3-wallet@v0.3.0-rc.7":
version "0.3.0-rc.7"
resolved "https://registry.npmjs.org/@alephium/web3-wallet/-/web3-wallet-0.3.0-rc.7.tgz"
integrity sha512-e+Y8xGkP/LeSltFdBn8m+KZ0ONkeIRJP7p8Z99cNktL7mafPvOXYqVYv0w+V4BegNotjAhoKugKHPJ61a6CIaQ==
"@alephium/web3-wallet@^0.3.0-rc.8", "@alephium/web3-wallet@v0.3.0-rc.8":
version "0.3.0-rc.8"
resolved "https://registry.yarnpkg.com/@alephium/web3-wallet/-/web3-wallet-0.3.0-rc.8.tgz#0decfed421fb45fbf437bbe5298dae65726403da"
integrity sha512-SwXom5couvhXL3ADStzJdbRXHdzJeAoBkkYws42DK+BeUbykR/Km7i1lQOLjRW3dIjqRh04JJTPcApVJ7w9z8g==
dependencies:
"@alephium/web3" "^0.3.0-rc.7"
"@alephium/web3" "^0.3.0-rc.8"
"@types/node" "16.7.8"
bip32 "3.1.0"
bip39 "3.0.4"
buffer "^6.0.3"
fs-extra "10.0.1"
tiny-secp256k1 "2.2.1"

"@alephium/web3@^0.3.0-rc.7", "@alephium/web3@v0.3.0-rc.7":
version "0.3.0-rc.7"
resolved "https://registry.npmjs.org/@alephium/web3/-/web3-0.3.0-rc.7.tgz"
integrity sha512-3DoB+ey9kbFfC94mxItIdUKLqVY4xTUMDOsoI/a7QY7eOKUBKceMTRkGVEtU90AKv1rOjMPKOt6aekKdazeijA==
"@alephium/web3@^0.3.0-rc.8", "@alephium/web3@v0.3.0-rc.8":
version "0.3.0-rc.8"
resolved "https://registry.yarnpkg.com/@alephium/web3/-/web3-0.3.0-rc.8.tgz#378fd3f9af7e1cf4054177da5cd37377b5bdc94d"
integrity sha512-fDFsPK52btpiLVGRGVSXNPhgO4JnJOyIjg3Nf1ycy2guTC0e6afOzpWtAgy75nsFZ5CgGrSgVNXyJx0hKjfqLg==
dependencies:
base-x "4.0.0"
blakejs "1.2.1"
Expand Down

0 comments on commit 5c27c3b

Please sign in to comment.