Skip to content

Commit 2890d12

Browse files
author
NankaiPosition
committed
Initial commit
0 parents  commit 2890d12

File tree

90 files changed

+4312
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+4312
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.idea

CHANGELOG.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
## 1.1.1
2+
* update version flutter_inappwebview
3+
4+
## 1.1.0
5+
* allow custom provider
6+
7+
## 1.0.3
8+
* connect to new wallet
9+
10+
## 1.0.2
11+
12+
* update docs
13+
14+
## 1.0.1
15+
16+
* update docs
17+
* update path provider
18+
19+
## 1.0.0
20+
21+
* init plugin

LICENSE

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Copyright 2022 The Flutter Authors. All rights reserved.
2+
3+
Redistribution and use in source and binary forms, with or without modification,
4+
are permitted provided that the following conditions are met:
5+
6+
* Redistributions of source code must retain the above copyright
7+
notice, this list of conditions and the following disclaimer.
8+
* Redistributions in binary form must reproduce the above
9+
copyright notice, this list of conditions and the following
10+
disclaimer in the documentation and/or other materials provided
11+
with the distribution.
12+
* Neither the name of Google Inc. nor the names of its
13+
contributors may be used to endorse or promote products derived
14+
from this software without specific prior written permission.
15+
16+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17+
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18+
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
20+
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21+
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
23+
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24+
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
## web3_provider
2+
The project supported send and receive messages between Dapp and in-app webview “Only EIP-1193 standard supported”
3+
4+
## Overview
5+
6+
* Communicate between dapp and your app.
7+
8+
<img src="https://raw.githubusercontent.com/VNAPNIC/web3-provider/master/art/sequence_diagram_communication.png"/>
9+
10+
* Dapp interact with blockchain.
11+
12+
<img src="https://raw.githubusercontent.com/VNAPNIC/web3-provider/master/art/sequence_diagram_sign_transaction.png"/>
13+
14+
## Usage
15+
16+
```dart
17+
import 'package:web3_provider/web3_provider.dart';
18+
19+
InAppWebViewGroupOptions options = InAppWebViewGroupOptions(
20+
crossPlatform: InAppWebViewOptions(
21+
useShouldOverrideUrlLoading: true,
22+
mediaPlaybackRequiresUserGesture: false,
23+
userAgent:
24+
"Mozilla/5.0 (Linux; Android 4.4.4; SAMSUNG-SM-N900A Build/tt) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/33.0.0.0 Mobile Safari/537.36",
25+
),
26+
android: AndroidInAppWebViewOptions(
27+
useHybridComposition: true,
28+
domStorageEnabled: true,
29+
),
30+
ios: IOSInAppWebViewOptions(
31+
allowsInlineMediaPlayback: true,
32+
),
33+
);
34+
35+
/// By default config
36+
InAppWebViewEIP1193(
37+
chainId: 56, // Replace your chain id network you want connect
38+
rpcUrl: 'https://bsc-dataseed.binance.org/', // Replace your rpc url network you want connect
39+
walletAddress: walletAddress,
40+
signCallback: (rawData, eip1193, controller) {
41+
// Handler callback when dapp interact with blockchain
42+
switch (eip1193) {
43+
case EIP1193.requestAccounts:
44+
controller?.setAddress(walletAddress, id);
45+
print('requestAccounts');
46+
break;
47+
case EIP1193.signTransaction:
48+
print('signTransaction');
49+
break;
50+
case EIP1193.signMessage:
51+
print('signMessage');
52+
break;
53+
case EIP1193.signPersonalMessage:
54+
print('signPersonalMessage');
55+
break;
56+
case EIP1193.signTypedMessage:
57+
print('addEthereumChain');
58+
break;
59+
case EIP1193.addEthereumChain:
60+
print('addEthereumChain');
61+
break;
62+
},
63+
initialUrlRequest: URLRequest(
64+
url: Uri.parse(
65+
'https://position.exchange', // Replace your dapp domain
66+
),
67+
),
68+
initialOptions: options
69+
);
70+
```
71+
72+
If you want use your provider script
73+
you provide [customPathProvider] and [customWalletName]
74+
75+
`signCallback: (rawData, eip1193, controller)`: callback was called when dapp when interact with blockchain. <br/>
76+
- `rawData`: data received.
77+
- `eip1193`: type function support.
78+
- requestAccounts: Pass when web app connect wallet
79+
- signTransaction: Pass when web app approve contract or send transaction
80+
- signMessage: Pass when web app sign a message
81+
- signPersonalMessage: Pass when web app sign a personal message
82+
- signTypedMessage: Pass when web app sign a type message
83+
- addEthereumChain: Pass when web app add a new chain
84+
85+
86+
When you pass data from dapp to your app
87+
```
88+
const args = {/* Pass data you want */};
89+
if (window.flutter_inappwebview.callHandler) {
90+
window.flutter_inappwebview.callHandler('functionName', args)
91+
.then(function(result) {
92+
/// Receive data from your app
93+
});
94+
}
95+
```
96+
97+
And receive in your app
98+
```
99+
onWebViewCreated: (controller) {
100+
controller.addJavaScriptHandler(
101+
handlerName: 'functionName',
102+
callback: (args) {
103+
/// Receive data from dapp
104+
105+
106+
/// Send data to dapp;
107+
return /* anything */;
108+
},
109+
);
110+
},
111+
```

SECURITY.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Security Policy
2+
3+
## Supported Versions
4+
5+
Use this section to tell people about which versions of your project are
6+
currently being supported with security updates.
7+
8+
| Version | Supported |
9+
| ------- | ------------------ |
10+
| 5.1.x | :white_check_mark: |
11+
| 5.0.x | :x: |
12+
| 4.0.x | :white_check_mark: |
13+
| < 4.0 | :x: |
14+
15+
## Reporting a Vulnerability
16+
17+
Use this section to tell people how to report a vulnerability.
18+
19+
Tell them where to go, how often they can expect to get an update on a
20+
reported vulnerability, what to expect if the vulnerability is accepted or
21+
declined, etc.
100 KB
Loading
153 KB
Loading

example/.gitignore

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Miscellaneous
2+
*.class
3+
*.log
4+
*.pyc
5+
*.swp
6+
.DS_Store
7+
.atom/
8+
.buildlog/
9+
.history
10+
.svn/
11+
migrate_working_dir/
12+
13+
# IntelliJ related
14+
*.iml
15+
*.ipr
16+
*.iws
17+
.idea/
18+
19+
# The .vscode folder contains launch configuration and tasks you configure in
20+
# VS Code which you may wish to be included in version control, so this line
21+
# is commented out by default.
22+
#.vscode/
23+
24+
# Flutter/Dart/Pub related
25+
**/doc/api/
26+
**/ios/Flutter/.last_build_id
27+
.dart_tool/
28+
.flutter-plugins
29+
.flutter-plugins-dependencies
30+
.packages
31+
.pub-cache/
32+
.pub/
33+
/build/
34+
35+
# Web related
36+
lib/generated_plugin_registrant.dart
37+
38+
# Symbolication related
39+
app.*.symbols
40+
41+
# Obfuscation related
42+
app.*.map.json
43+
44+
# Android Studio will place build artifacts here
45+
/android/app/debug
46+
/android/app/profile
47+
/android/app/release

example/.metadata

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# This file tracks properties of this Flutter project.
2+
# Used by Flutter tool to assess capabilities and perform upgrades etc.
3+
#
4+
# This file should be version controlled.
5+
6+
version:
7+
revision: f1875d570e39de09040c8f79aa13cc56baab8db1
8+
channel: unknown
9+
10+
project_type: app
11+
12+
# Tracks metadata for the flutter migrate command
13+
migration:
14+
platforms:
15+
- platform: root
16+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
17+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
18+
- platform: android
19+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
20+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
21+
- platform: ios
22+
create_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
23+
base_revision: f1875d570e39de09040c8f79aa13cc56baab8db1
24+
25+
# User provided section
26+
27+
# List of Local paths (relative to this file) that should be
28+
# ignored by the migrate tool.
29+
#
30+
# Files that are not part of the templates will be ignored by default.
31+
unmanaged_files:
32+
- 'lib/main.dart'
33+
- 'ios/Runner.xcodeproj/project.pbxproj'

example/README.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# untitled
2+
3+
A new Flutter project.
4+
5+
## Getting Started
6+
7+
This project is a starting point for a Flutter application.
8+
9+
A few resources to get you started if this is your first Flutter project:
10+
11+
- [Lab: Write your first Flutter app](https://docs.flutter.dev/get-started/codelab)
12+
- [Cookbook: Useful Flutter samples](https://docs.flutter.dev/cookbook)
13+
14+
For help getting started with Flutter development, view the
15+
[online documentation](https://docs.flutter.dev/), which offers tutorials,
16+
samples, guidance on mobile development, and a full API reference.

0 commit comments

Comments
 (0)