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

Feature/update complete #9

Merged
merged 27 commits into from
Nov 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
36afef8
refactor: rename client package
yk-saito Oct 19, 2023
794a6bd
fix: QrImage exported from qr and qr_flutter
yk-saito Oct 19, 2023
89a3deb
refactor: remove unnecessary imports by Dart extension
yk-saito Oct 19, 2023
fcc798e
chore: set yarn version v3.6.4
yk-saito Oct 31, 2023
538eee8
chore: update node version to v20
yk-saito Oct 31, 2023
2d6b664
feat: changed wallet connection to use walletconnect_flutter_v2 package
yk-saito Nov 1, 2023
1a6846a
feat: update send transaction
yk-saito Nov 1, 2023
6a96cb3
refactor: restored contract calls in Home class after tx update
yk-saito Nov 1, 2023
824311f
refactor: restored contract calls in Wallet class after tx update
yk-saito Nov 1, 2023
0850bd1
refactor: restored show QR code
yk-saito Nov 1, 2023
fee3dca
refactor: sort imports
yk-saito Nov 1, 2023
7896db1
chore: remove typechain-types/ and artifacts/ from git tracking
yk-saito Nov 1, 2023
4f65d42
chore: format package.json
yk-saito Nov 1, 2023
1930d49
refactor: sort token contract deployment definitions alphabetically
yk-saito Nov 1, 2023
0e4252b
chore: remove .env from git tracking
yk-saito Nov 1, 2023
00f31ac
Merge pull request #8 from unchain-tech/feature/update-wallet-connect
yk-saito Nov 1, 2023
8a2d029
refactor: remove unnecessary debugPrint
yk-saito Nov 2, 2023
b921d4e
refactor: remove comment; refactor: remove unnecessary imports
yk-saito Nov 2, 2023
f0b62a7
fix: no dai token in the token list
yk-saito Nov 2, 2023
d099ec1
refactor: set project id as environment variable
yk-saito Nov 2, 2023
6df2c8a
refactor: add error catch
yk-saito Nov 2, 2023
cf11b51
chore: regenerate pubspec.lock file
yk-saito Nov 2, 2023
4b03683
chore: update README
yk-saito Nov 2, 2023
275199d
chore: format
yk-saito Nov 2, 2023
8217915
chore: lock dependencies versoin
yk-saito Nov 9, 2023
d472cbf
chore: change require to import
yk-saito Nov 9, 2023
996ad23
chore: update actions setup-node to v4
yk-saito Nov 9, 2023
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
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x
cache: 'yarn'
- uses: actions/cache@v3
id: yarn-cache
Expand Down
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
**/yarn-error.log*
#yarn
**/.yarn/*
!**/.yarn/plugins
!**/.yarn/releases

# dependencies
**/node_modules
Expand Down
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
.yarn
node_modules
.openzeppelin
.vscode

artifacts
cache
coverage*
typechain-types

gasReporterOutput.json
package.json
Expand Down
874 changes: 874 additions & 0 deletions .yarn/releases/yarn-3.6.4.cjs

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
nodeLinker: node-modules

yarnPath: .yarn/releases/yarn-3.6.4.cjs
130 changes: 49 additions & 81 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,113 +1,81 @@
## 💬 NEAR-Mulpay(prototype)
# 💬 NEAR MulPay(prototype)

本レポジトリは NEAR-Mulpay の完成版を示したものになります。
本レポジトリは NEAR MulPay の完成版を示したものになります。

以下の手順を実行することで NEAR-Mulpay の挙動を確認できます。
## 実行方法

### レポジトリのクローン
事前に[こちら](https://app.unchain.tech/learn/NEAR-MulPay/ja/0/2/)のページを参考にして環境構築を行なってください。

[こちら](https://github.com/unchain-tech/NEAR-MulPay.git)から NEAR-Mulpay をクローンします。
### 1. レポジトリのクローン

### コントラクトとフロントの準備
[こちら](https://github.com/unchain-tech/NEAR-MulPay.git)から NEAR MulPay をクローンします。

1. 環境構築

[こちら](https://app.unchain.tech/learn/NEAR-MulPay/ja/0/2/)のページを参考にして環境構築を行います。

2. キーの指定とテスト

packages/client, packages/contract 下に.env ファイルを作成し、下のように コントラクトのアドレス,名前と Infura の key を指定しましょう。Infura の key に関しては 1. において作成したものを使用します。

[packages/contract]
クローンが完了したら、プロジェクトに移動して下のコマンドを実行してください。必要なパッケージをインストールします。

```
AURORA_PRIVATE_KEY=METAMASKのPrivateKey
yarn
```

[packages/client]
### 2. コントラクトのデプロイ

`packages/contract`ディレクトリに`.env`ファイルを作成し、下のように記述しましょう。`YOUR_PRIVATE_KEY`には Metamask の秘密鍵を指定してください。

```
AOA_CONTRACT_ADDRESS = "0x10Fc0df445Cc2be44Af50C008a83248b26228Df4"
SHIB_CONTRACT_ADDRESS = "0x53541b23074e4E14AE32f02aFc299E1990590D44"
ETH_CONTRACT_ADDRESS = "0x78C4F9eBF32E2a02Cd0dAE561DD0FAFF7bA64b9a"
SOL_CONTRACT_ADDRESS = "0xb2C9AA59BE1ba9bfda60EEa8a40d57aA08A8A49b"
USDT_CONTRACT_ADDRESS = "0x0004976DD6E9Bf9148d46706845962A5AD5F429e"
UNI_CONTRACT_ADDRESS = "0x9528bf0F166f0f167cbb1e028Ba951852e83927a"
MATIC_CONTRACT_ADDRESS = "0xE91fAD00f61076f9274e1656f263597B6ddA090D"
DAI_CONTRACT_ADDRESS = "0x7363F3bBf35fda8E14C98794EAc4196DbeDc76cC"
SWAP_CONTRACT_ADDRESS = "0x734156aE604355bEc16762168994bEb09b899da7"

SWAP_CONTRACT_NAME = "SwapContract"
DAI_CONTRACT_NAME = "DaiToken"
ETH_CONTRACT_NAME = "EthToken"
AOA_CONTRACT_NAME = "AuroraToken"
SHIB_CONTRACT_NAME = "ShibainuToken"
SOL_CONTRACT_NAME = "SolanaToken"
USDT_CONTRACT_NAME = "TetherToken"
UNI_CONTRACT_NAME = "UniswapToken"
MATIC_CONTRACT_NAME = "PolygonToken"

INFURA_KEY_TEST = InfuraのPrivateKey
AURORA_PRIVATE_KEY="YOUR_PRIVATE_KEY"
```

次に下のコマンドを実行することでコントラクトのテスト+コンパイルができます
.env ファイルを作成したら下のコマンドを実行しましょう

```
yarn contract test
yarn contract deploy
```

下のような結果が出ていれば成功です!

```
Swap Contract
Deployment
1000000000000000000000000
✔ ERC20 token is minted from smart contract (1556ms)
value of ETH/DAI is 0.1
✔ Get value between DAI and ETH
Before transfer, address_1 has 0 ETH
After transfer, address_1 has 0.1 ETH
✔ swap function (103ms)
デプロイ完了後に表示された各コントラクトのアドレスは、次のステップで使用します。

### 3. フロントエンドの起動

3 passing (2s)
`packages/client`ディレクトリに`.env`ファイルを作成し、下のように記述しましょう。

✨ Done in 4.05s.
```
SWAP_CONTRACT_ADDRESS="YOUR_SWAP_CONTRACT_ADDRESS"
AOA_CONTRACT_ADDRESS="YOUR_AOA_CONTRACT_ADDRESS"
DAI_CONTRACT_ADDRESS="YOUR_DAI_CONTRACT_ADDRESS"
ETH_CONTRACT_ADDRESS="YOUR_ETH_CONTRACT_ADDRESS"
MATIC_CONTRACT_ADDRESS="YOUR_MATIC_CONTRACT_ADDRESS"
SHIB_CONTRACT_ADDRESS="YOUR_SHIB_CONTRACT_ADDRESS"
SOL_CONTRACT_ADDRESS="YOUR_SOL_CONTRACT_ADDRESS"
UNI_CONTRACT_ADDRESS="YOUR_UNI_CONTRACT_ADDRESS"
USDT_CONTRACT_ADDRESS="YOUR_USDT_CONTRACT_ADDRESS"

SWAP_CONTRACT_NAME="SwapContract"
AOA_CONTRACT_NAME="AuroraToken"
DAI_CONTRACT_NAME="DaiToken"
ETH_CONTRACT_NAME="EthToken"
MATIC_CONTRACT_NAME="PolygonToken"
SHIB_CONTRACT_NAME="ShibainuToken"
SOL_CONTRACT_NAME="SolanaToken"
UNI_CONTRACT_NAME="UniswapToken"
USDT_CONTRACT_NAME="TetherToken"

AURORA_TESTNET_INFURA_KEY="YOUR_INFURA_KEY"

WALLETCONNECT_PROJECT_ID="YOUR_PROJECT_ID"
```

3. コントラクトのデプロイとフロントへの反映
- `YOUR_xxx_CONTRACT_ADDRESS`:2. でデプロイしたコントラクトのアドレスを指定してください。
- `YOUR_INFURA_KEY`:環境構築で作成した Infura の API Key を指定してください。
- `YOUR_PROJECT_ID`:環境構築で作成した WalletConnect の Project ID を指定してください。

`packages/contract`ディレクトリに移動し、以下のコマンドを実行しましょう
.env ファイルを作成したら下のコマンドを実行しましょう。flutter のパッケージをインストールします

```
yarn contract deploy
yarn client flutter:install
```

下記のような結果がでていれば成功です
エミュレータや実機が接続されていることを確認し、下のコマンドを実行しましょう

```
Deploying contracts with the account: 0xa9eD1748Ffcda5442dCaEA242603E7e3FF09dD7F
Account balance: 228411549210000000
deployer address is 0xa9eD1748Ffcda5442dCaEA242603E7e3FF09dD7F
Swap Contract is deployed to: 0x734156aE604355bEc16762168994bEb09b899da7
DaiToken is deployed to: 0x7363F3bBf35fda8E14C98794EAc4196DbeDc76cC
EthToken is deployed to: 0x78C4F9eBF32E2a02Cd0dAE561DD0FAFF7bA64b9a
AoaToken is deployed to: 0x10Fc0df445Cc2be44Af50C008a83248b26228Df4
ShibToken is deployed to: 0x53541b23074e4E14AE32f02aFc299E1990590D44
SolToken is deployed to: 0xb2C9AA59BE1ba9bfda60EEa8a40d57aA08A8A49b
UsdtToken is deployed to: 0x0004976DD6E9Bf9148d46706845962A5AD5F429e
UniToken is deployed to: 0x9528bf0F166f0f167cbb1e028Ba951852e83927a
MaticToken is deployed to: 0xE91fAD00f61076f9274e1656f263597B6ddA090D
yarn client flutter:run
```

これでコントラクトとフロントエンドの準備は完了です!

### フロントエンドを起動

下のコマンドを実行させることでフロントエンドの動きを確認してみましょう。

[こちら](https://app.unchain.tech/learn/NEAR-MulPay/ja/3/1/)のページのように動作していれば成功です!

```
yarn client start
```
アプリケーションを操作してみましょう。[こちら](https://app.unchain.tech/learn/NEAR-MulPay/ja/3/1/)のページのように動作していれば成功です!
11 changes: 5 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"name": "NEAR-Mulpay",
"version": "1.0.0",
"packageManager": "[email protected]",
"description": "\"sample of NEAR-Mulpay\"",
"main": "\"\"",
"license": "UNLICENSED",
Expand All @@ -22,11 +23,9 @@
"prettier-plugin-solidity": "^1.1.2",
"simple-git-hooks": "^2.8.1"
},
"workspaces": {
"packages": [
"packages/*"
]
},
"workspaces": [
"packages/*"
],
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
Expand All @@ -39,4 +38,4 @@
"lint:contract": "eslint packages/contract/contracts/ERC20Tokens.sol",
"lint:fix": "eslint --fix ."
}
}
}
21 changes: 0 additions & 21 deletions packages/client/.env

This file was deleted.

3 changes: 3 additions & 0 deletions packages/client/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ app.*.map.json
/android/app/debug
/android/app/profile
/android/app/release

# Environment variables file
.env
Binary file added packages/client/assets/dai-dai-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 4 additions & 3 deletions packages/client/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import 'package:flutter/material.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:hexcolor/hexcolor.dart';
import 'package:mulpay_frontend/model/contract_model.dart';
import 'package:mulpay_frontend/view/screens/signin.dart';
import 'package:mulpay_frontend/view/widgets/navbar.dart';
import 'package:provider/provider.dart';
import 'package:responsive_framework/responsive_framework.dart';

import 'model/contract_model.dart';
import 'view/screens/signin.dart';
import 'view/widgets/navbar.dart';

Future main() async {
await dotenv.load(fileName: ".env");
runApp(
Expand Down
Loading