Skip to content
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

export balance from utxo to evm with 4337 #10

Merged
merged 21 commits into from
Nov 30, 2024
9 changes: 2 additions & 7 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,7 @@ module.exports = {

parserOptions: {
sourceType: 'module',
},
"rules": {
"@typescript-eslint/no-misused-promises": [2, {
"checksVoidReturn": {
"attributes": false
}
}]
project: ['tsconfig.json'],
},
extends: ['@metamask/eslint-config'],

Expand Down Expand Up @@ -44,5 +38,6 @@ module.exports = {
'**/build',
'**/public',
'**/.cache',
'!.manifest.json',
],
};
2 changes: 0 additions & 2 deletions .github/workflows/build-lint-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@ jobs:
path: ./packages/snap/dist
key: snap-${{ runner.os }}-${{ github.sha }}
- run: yarn install --immutable
- name: Run e2e tests
run: yarn workspace snap run test
- name: Require clean working directory
shell: bash
run: |
Expand Down
13 changes: 13 additions & 0 deletions IMPORT.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Import qng balance to qngsnap

- 1. export the privatekey from your wallet
- 2. import the privatekey to your metamask flask
- 3. enter the qng address corresponding to this private key in qngsnap
- 4. import with qngsnap
- 5. meerchange with qngsnap

```
test
priv: 02addd806e8813f85fad05b97541915eb3a1f27528d3156f2ef8166823d6722b58
addr: TnV2vWDJoKceiyUHFCqFKaTLLkyDK6cY5ka
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,12 @@
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,jsx,ts,tsx",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
"lint:misc": "prettier '**/*.json' '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"lint:misc": "prettier '**/*.md' '!**/CHANGELOG.md' '**/*.yml' --ignore-path .gitignore",
"start": "yarn workspaces foreach --parallel --interlaced --verbose run start",
"test": "yarn workspace snap run test"
"test": "yarn workspace qngsnap run test"
},
"dependencies": {
"@material-ui/core": "^4.12.4",
"@metamask/superstruct": "^3.1.0"
},
"devDependencies": {
Expand Down
1 change: 1 addition & 0 deletions packages/site/.env.production.dist
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
* To use this, rename to `.env.production` and set the production SNAP_ORIGIN here
*/
SNAP_ORIGIN=
PROXY_SERVER=
1 change: 1 addition & 0 deletions packages/site/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module.exports = {

parserOptions: {
tsconfigRootDir: __dirname,
project: ['./tsconfig.json'],
},

overrides: [
Expand Down
49 changes: 48 additions & 1 deletion packages/site/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,56 @@
# TypeScript Example Snap Front-end
# Qng-Amount-Recovery-Tool

This project was bootstrapped with [Gatsby](https://www.gatsbyjs.com/).

## Node Version

### `Node > 18`

# Dependence

### 1. Run Qng Node , see https://github.com/Qitmeer/qng or use public rpc service

### 2. Run Bundler service , see https://github.com/eth-infinitism/bundler . checkout tag v0.6.0

- update the config file in `packages/bundler/localconfig/bundler.config.json`
`network` is the qng rpc server
`entryPoint` can see https://github.com/Qitmeer/eip4337-account-abstraction/blob/v0.6-qng/contracts/address.ts
`beneficiary` is your bundler address which can receive the left fee.
- run bundler
`yarn && yarn preprocess`
`yarn run bundler --unsafe`

### 3. start your nginx proxy server

```
server {
listen 443 ssl;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
ssl_certificate ssl/myserver.crt;
ssl_certificate_key ssl/myserver.key;
server_name 127.0.0.1;
root /opt/qng-snap/packages/site/public;
location /qng {
proxy_pass http://127.0.0.1:1234/; # qng server rpc
}
location /bundler {
proxy_pass http://127.0.0.1:3000/rpc; # bundler server rpc
}
}

```

## Available Scripts

In the project directory, you can run:

### `cd packages/site`

### `npm install buffer`

### `yarn install`

### `yarn start`

Runs the app in the development mode.\
Expand All @@ -32,6 +77,8 @@ In development, Gatsby will load environment variables from a file named `.env.d

By default you can use the `SNAP_ORIGIN` variable (used in `src/config/snap.ts`) to define a production origin for you snap (eg. `npm:MyPackageName`). If not defined it will defaults to `local:http://localhost:8080`.

By default you can use the `PROXY_SERVER` variable (used in `src/utils/config.ts`) to define a production origin for you nginx proxy server. If not defined it will defaults to `https://127.0.0.1`. the nginx proxy server need https

A `.env` file template is available, to use it rename `.env.production.dist` to `.env.production`

To learn more visit [Gatsby documentation](https://www.gatsbyjs.com/docs/how-to/local-development/environment-variables/)
Expand Down
6 changes: 6 additions & 0 deletions packages/site/gatsby-browser.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
/* eslint-disable @typescript-eslint/no-unused-vars */
/* eslint-disable import/no-nodejs-modules */
import { Buffer } from 'buffer';
import type { GatsbyBrowser } from 'gatsby';
import { StrictMode } from 'react';

import { App } from './src/App';
import { Root } from './src/Root';

Buffer.from('00ff');
window.Buffer = window.Buffer || Buffer;

export const wrapRootElement: GatsbyBrowser['wrapRootElement'] = ({
element,
}) => (
Expand Down
1 change: 0 additions & 1 deletion packages/site/gatsby-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import type { GatsbyConfig } from 'gatsby';
const config: GatsbyConfig = {
// This is required to make use of the React 17+ JSX transform.
jsxRuntime: 'automatic',

plugins: [
'gatsby-plugin-svgr',
'gatsby-plugin-styled-components',
Expand Down
18 changes: 18 additions & 0 deletions packages/site/gatsby-node.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// gatsby-node.ts
import type { GatsbyNode } from 'gatsby';
import webpack from 'webpack';

export const onCreateWebpackConfig: GatsbyNode['onCreateWebpackConfig'] = ({
actions,
}) => {
const { setWebpackConfig } = actions;

setWebpackConfig({
plugins: [
new webpack.ProvidePlugin({
React: 'react', //
Buffer: ['buffer', 'Buffer'],
}),
],
});
};
28 changes: 25 additions & 3 deletions packages/site/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
"scripts": {
"allow-scripts": "yarn workspace root allow-scripts",
"build": "GATSBY_TELEMETRY_DISABLED=1 gatsby build",
"clean": "rimraf public",
"lint": "yarn lint:eslint && yarn lint:misc --check",
"lint:eslint": "eslint . --cache --ext js,ts",
"lint:fix": "yarn lint:eslint --fix && yarn lint:misc --write",
Expand All @@ -26,11 +25,35 @@
]
},
"dependencies": {
"@account-abstraction/contracts": "^0.6.0",
"@account-abstraction/sdk": "^0.6.0",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@metamask/key-tree": "^9.1.2",
"@metamask/providers": "^16.0.0",
"@metamask/snaps-sdk": "^4.0.0",
"@mui/material": "^6.1.7",
"@noble/hashes": "^1.4.0",
"@qng/eip4337-contracts": "0.6.2",
"@qng/eip4337-sdk": "0.6.11",
"@qng/meerchange-contracts": "0.0.4",
"@types/base-x": "^3.0.6",
"antd": "^5.21.1",
"bs58": "^6.0.0",
"buffer": "^6.0.3",
"ethers": "^5.7.2",
"merkle-lib": "^2.0.10",
"qitmeerts": "^1.1.2",
"randombytes": "^2.1.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-is": "^18.2.0",
"styled-components": "5.3.3"
"stream-browserify": "^3.0.0",
"styled-components": "5.3.3",
"tiny-secp256k1": "^1.1.6",
"uint8array-tools": "^0.0.8",
"varuint-bitcoin": "^1.1.2",
"webpack": "^5.96.1"
},
"devDependencies": {
"@metamask/eslint-config": "^12.2.0",
Expand Down Expand Up @@ -63,7 +86,6 @@
"gatsby-plugin-svgr": "^3.0.0-beta.0",
"prettier": "^2.7.1",
"prettier-plugin-packagejson": "^2.2.18",
"rimraf": "^3.0.2",
"typescript": "^4.7.4"
},
"engines": {
Expand Down
Binary file added packages/site/src/assets/import1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/site/src/assets/import2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/site/src/assets/import3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added packages/site/src/assets/import4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion packages/site/src/components/Buttons.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export const ReconnectButton = (props: ComponentProps<typeof Button>) => {
return (
<Button {...props}>
<FlaskFox />
<ButtonText>Reconnect</ButtonText>
<ButtonText>Reinstall</ButtonText>
</Button>
);
};
Expand Down
Loading
Loading