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

Wc2 pub #1519

Closed
wants to merge 46 commits into from
Closed

Wc2 pub #1519

Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
77562a2
use wc2 pub
phuocbitmark Jul 5, 2023
2ae1aee
update lib
phuocbitmark Oct 12, 2023
e5c7219
Merge branch 'develop' into wc2_pub
phuocbitmark Dec 15, 2023
7fb19bb
merge develop
phuocbitmark Dec 15, 2023
0432428
Merge branch 'develop' into wc2_pub
phuocbitmark Jan 31, 2024
83cfca1
Merge branch 'develop' into wc2_pub
ppupha Jan 31, 2024
1d84639
lint
phuocbitmark Feb 2, 2024
eb10675
fix: lint
ppupha Feb 5, 2024
9f03263
Merge branch 'develop' into wc2_pub
ppupha Feb 5, 2024
cdb9124
Merge remote-tracking branch 'origin/wc2_pub' into wc2_pub
ppupha Feb 5, 2024
a89075e
Update Handler
ppupha Feb 6, 2024
e536f77
handle au_sign
ppupha Feb 6, 2024
4e8240c
remove wc2_channel
ppupha Feb 6, 2024
1d07cde
remove unused code
ppupha Feb 6, 2024
8dc561d
fix lint
ppupha Feb 6, 2024
868168f
Merge branch 'develop' into wc2_pub
ppupha Feb 15, 2024
8583975
wait for session approve
ppupha Feb 19, 2024
474916e
Merge branch 'develop' into wc2_pub
ppupha Feb 19, 2024
bf193d7
fix: remove test code
ppupha Feb 19, 2024
d6c129d
Merge branch 'develop' into wc2_pub
ppupha Feb 22, 2024
1a5d4e8
Merge branch 'develop' into wc2_pub
phuocbitmark Feb 28, 2024
967c2c1
fix merge
phuocbitmark Feb 28, 2024
2de16f7
fix: latest pub version
phuocbitmark Feb 28, 2024
3c39fe7
fix sign autonomy connect
phuocbitmark Feb 28, 2024
eca7ffc
fix: handle return signature
phuocbitmark Feb 28, 2024
0d6cde5
fix: handle return signature send tx
phuocbitmark Feb 28, 2024
16aba6a
fix: add optional namespaces
ppupha Feb 28, 2024
d0850ee
fix: handle pop in autonomy connect
phuocbitmark Feb 28, 2024
0f57c23
Merge branch 'wc2_pub' of github.com:bitmark-inc/autonomy-client into…
phuocbitmark Feb 28, 2024
ed36b2a
fix: fix wait for approve session
phuocbitmark Feb 28, 2024
4b28b79
fix: update error
phuocbitmark Feb 28, 2024
d870c27
refactor
phuocbitmark Feb 28, 2024
ac30989
Merge branch 'develop' into wc2_pub
phuocbitmark Feb 28, 2024
eb9bcf4
fix onPopInvoked
phuocbitmark Feb 28, 2024
2af5310
Merge branch 'develop' into wc2_pub
phuocbitmark Feb 28, 2024
8a30e46
Update lib/screen/wallet_connect/v2/wc2_permission_page.dart
phuocbitmark Feb 29, 2024
7547a24
fix: check irl for wc is obselete
phuocbitmark Feb 29, 2024
e4b5f35
fix: remove android native code
phuocbitmark Feb 29, 2024
a4bc7c0
fix merge namespace
phuocbitmark Feb 29, 2024
70fd167
Merge branch 'develop' into wc2_pub
phuocbitmark Mar 1, 2024
b8d232c
handle au tezoz send transaction
phuocbitmark Mar 1, 2024
3cb71dc
fix: uncommit unecessary file
phuocbitmark Mar 1, 2024
a56e607
Merge branch 'develop' into wc2_pub
phuocbitmark Mar 1, 2024
33054f9
Merge branch 'develop' into wc2_pub
phuocbitmark Mar 4, 2024
0a314d3
Merge branch 'develop' into wc2_pub
phuocbitmark Mar 15, 2024
a3c7598
Merge branch 'develop' into wc2_pub
ppupha Mar 26, 2024
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ class MainActivity : FlutterFragmentActivity() {

BackupDartPlugin().createChannels(flutterEngine, applicationContext)
TezosBeaconDartPlugin().createChannels(flutterEngine)
flutterEngine.plugins.add(Wc2ConnectPlugin(this.application))
}

private fun getExistingUuids(): String {
Expand Down
Binary file not shown.
13 changes: 13 additions & 0 deletions lib/database/cloud_database.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

30 changes: 18 additions & 12 deletions lib/database/dao/connection_dao.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ abstract class ConnectionDao {
@Query('SELECT * FROM Connection')
Future<List<Connection>> getConnections();

@Query(
'SELECT * FROM Connection WHERE connectionType NOT IN ("dappConnect", "dappConnect2", "walletConnect2", "beaconP2PPeer", "manuallyIndexerTokenID")')
@Query('SELECT * FROM Connection WHERE connectionType NOT IN '
'("dappConnect", "dappConnect2", "walletConnect2", "beaconP2PPeer", '
'"manuallyIndexerTokenID")')
Future<List<Connection>> getLinkedAccounts();

// getUpdatedLinkedAccounts:
Expand All @@ -25,7 +26,7 @@ abstract class ConnectionDao {
final linkedAccounts = await getLinkedAccounts();

final deprecatedConnections = linkedAccounts
.where((element) => element.connectionType != "manuallyAddress");
.where((element) => element.connectionType != 'manuallyAddress');

if (deprecatedConnections.isNotEmpty) {
await _migrateDeprecatedConnections(deprecatedConnections.toList());
Expand All @@ -35,16 +36,20 @@ abstract class ConnectionDao {
return linkedAccounts;
}

@Query(
'SELECT * FROM Connection WHERE connectionType IN ("dappConnect", "dappConnect2", "beaconP2PPeer")')
@Query('SELECT * FROM Connection WHERE connectionType IN '
'("dappConnect", "dappConnect2", "beaconP2PPeer")')
Future<List<Connection>> getRelatedPersonaConnections();

@Query(
'SELECT * FROM Connection WHERE connectionType = :type ORDER BY createdAt DESC')
@Query('SELECT * FROM Connection WHERE connectionType IN '
'("dappConnect2", "walletConnect2")')
Future<List<Connection>> getWc2Connections();

@Query('SELECT * FROM Connection WHERE connectionType = :type '
'ORDER BY createdAt DESC')
Future<List<Connection>> getConnectionsByType(String type);

@Query(
'SELECT * FROM Connection WHERE accountNumber = :accountNumber COLLATE NOCASE')
@Query('SELECT * FROM Connection WHERE accountNumber = :accountNumber '
'COLLATE NOCASE')
Future<List<Connection>> getConnectionsByAccountNumber(String accountNumber);

@Insert(onConflict: OnConflictStrategy.replace)
Expand All @@ -65,8 +70,8 @@ abstract class ConnectionDao {
@delete
Future<void> deleteConnections(List<Connection> connections);

@Query(
'DELETE FROM Connection WHERE accountNumber = :accountNumber COLLATE NOCASE')
@Query('DELETE FROM Connection WHERE accountNumber = :accountNumber '
'COLLATE NOCASE')
Future<void> deleteConnectionsByAccountNumber(String accountNumber);

@Query('DELETE FROM Connection WHERE connectionType = :type')
Expand All @@ -82,7 +87,8 @@ abstract class ConnectionDao {
switch (oldConnection.connectionType) {
case 'ledger':
final jsonData = json.decode(oldConnection.data);
// there is a typo in creating connections for ledger code: etheremAddress
// there is a typo in creating connections for ledger code:
// etheremAddress
final etheremAddress = (jsonData['etheremAddress'] == null
? []
: (jsonData['etheremAddress'] as List<dynamic>))
Expand Down
16 changes: 9 additions & 7 deletions lib/model/connection_request_args.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import 'package:autonomy_flutter/model/wc2_request.dart';
import 'package:tezart/tezart.dart';
import 'package:walletconnect_flutter_v2/walletconnect_flutter_v2.dart';

abstract class ConnectionRequest {
bool get isWalletConnect2 => false;
Expand All @@ -15,7 +16,7 @@ abstract class ConnectionRequest {

bool get isBeaconConnect => false;

String get id;
dynamic get id;

String? get name;

Expand Down Expand Up @@ -83,16 +84,17 @@ class Wc2Proposal extends ConnectionRequest {
return proposalChains.contains(Wc2Chain.autonomy);
}

AppMetadata proposer;
Map<String, Wc2Namespace> requiredNamespaces;
Map<String, Wc2Namespace> optionalNamespaces;
PairingMetadata proposer;
Map<String, RequiredNamespace> requiredNamespaces;
Map<String, RequiredNamespace> optionalNamespaces;

Map<String, Wc2Namespace> get allNamespaces =>
Map<String, RequiredNamespace> get allNamespaces =>
{...requiredNamespaces, ...optionalNamespaces};
final String _id;

final int _id;

@override
String get id => _id;
int get id => _id;

@override
String? get name => proposer.name;
Expand Down
86 changes: 43 additions & 43 deletions lib/model/wc2_request.dart
ppupha marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import 'dart:convert';
import 'dart:io';

import 'package:autonomy_flutter/model/connection_request_args.dart';
import 'package:json_annotation/json_annotation.dart';
import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart';

part 'wc2_request.g.dart';

Expand All @@ -28,25 +28,25 @@ class Wc2Request {
String topic;
dynamic params;
String chainId;
AppMetadata? proposer;
PairingMetadata? proposer;

factory Wc2Request.fromJson(Map<String, dynamic> json) => Wc2Request(
id: json["id"] is int ? json["id"] : int.tryParse(json["id"]) ?? 0,
method: json["method"],
topic: json["topic"],
params: Platform.isIOS ? json["params"] : jsonDecode(json["params"]),
chainId: json["chainId"],
proposer: json["proposer"] != null
? AppMetadata.fromJson(json["proposer"])
id: json['id'] is int ? json['id'] : int.tryParse(json['id']) ?? 0,
method: json['method'],
topic: json['topic'],
params: Platform.isIOS ? json['params'] : jsonDecode(json['params']),
chainId: json['chainId'],
proposer: json['proposer'] != null
? PairingMetadata.fromJson(json['proposer'])
: null,
);

Map<String, dynamic> toJson() => {
"id": id,
"method": method,
"topic": topic,
"params": params,
"chainId": chainId,
'id': id,
'method': method,
'topic': topic,
'params': params,
'chainId': chainId,
};
}

Expand All @@ -63,16 +63,16 @@ class Wc2PermissionsRequestParams {

factory Wc2PermissionsRequestParams.fromJson(Map<String, dynamic> json) =>
Wc2PermissionsRequestParams(
message: json["message"],
message: json['message'],
permissions: List<Wc2Permission>.from(
json["permissions"].map((x) => Wc2Permission.fromJson(x))),
account: json["account"],
json['permissions'].map((x) => Wc2Permission.fromJson(x))),
account: json['account'],
);

Map<String, dynamic> toJson() => {
"message": message,
"permissions": List<dynamic>.from(permissions.map((x) => x.toJson())),
"account": account,
'message': message,
'permissions': List<dynamic>.from(permissions.map((x) => x.toJson())),
'account': account,
};
}

Expand All @@ -88,15 +88,15 @@ class Wc2Permission {
Wc2ChainsPermissionRequest request;

factory Wc2Permission.fromJson(Map<String, dynamic> json) => Wc2Permission(
type: json["type"],
includeLinkedAccount: json["includeLinkedAccount"],
request: Wc2ChainsPermissionRequest.fromJson(json["request"]),
type: json['type'],
includeLinkedAccount: json['includeLinkedAccount'],
request: Wc2ChainsPermissionRequest.fromJson(json['request']),
);

Map<String, dynamic> toJson() => {
"type": type,
"includeLinkedAccount": includeLinkedAccount,
"request": request.toJson(),
'type': type,
'includeLinkedAccount': includeLinkedAccount,
'request': request.toJson(),
};
}

Expand All @@ -109,11 +109,11 @@ class Wc2ChainsPermissionRequest {

factory Wc2ChainsPermissionRequest.fromJson(Map<String, dynamic> json) =>
Wc2ChainsPermissionRequest(
chains: List<String>.from(json["chains"].map((x) => x)),
chains: List<String>.from(json['chains'].map((x) => x)),
);

Map<String, dynamic> toJson() => {
"chains": List<dynamic>.from(chains.map((x) => x)),
'chains': List<dynamic>.from(chains.map((x) => x)),
};
}

Expand All @@ -130,15 +130,15 @@ class Wc2SignRequestParams {

factory Wc2SignRequestParams.fromJson(Map<String, dynamic> json) =>
Wc2SignRequestParams(
chain: json["chain"],
address: json["address"],
message: json["message"],
chain: json['chain'],
address: json['address'],
message: json['message'],
);

Map<String, dynamic> toJson() => {
"chain": chain,
"address": address,
"message": message,
'chain': chain,
'address': address,
'message': message,
};
}

Expand All @@ -155,15 +155,15 @@ class Wc2SendRequestParams {

factory Wc2SendRequestParams.fromJson(Map<String, dynamic> json) =>
Wc2SendRequestParams(
chain: json["chain"],
address: json["address"],
transactions: json["transactions"],
chain: json['chain'],
address: json['address'],
transactions: json['transactions'],
);

Map<String, dynamic> toJson() => {
"chain": chain,
"address": address,
"transactions": transactions,
'chain': chain,
'address': address,
'transactions': transactions,
};
}

Expand Down Expand Up @@ -215,9 +215,9 @@ class Wc2ChainResult {

@JsonSerializable()
class Wc2Chain {
static const autonomy = "autonomy";
static const ethereum = "eip155";
static const tezos = "tezos";
static const autonomy = 'autonomy';
static const ethereum = 'eip155';
static const tezos = 'tezos';

final String chain;
final String address;
Expand Down
9 changes: 4 additions & 5 deletions lib/screen/app_router.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import 'package:autonomy_flutter/model/connection_request_args.dart';
import 'package:autonomy_flutter/model/ff_series.dart';
import 'package:autonomy_flutter/model/play_list_model.dart';
import 'package:autonomy_flutter/model/postcard_claim.dart';
import 'package:autonomy_flutter/model/wc2_request.dart';
import 'package:autonomy_flutter/screen/account/access_method_page.dart';
import 'package:autonomy_flutter/screen/account/link_manually_page.dart';
import 'package:autonomy_flutter/screen/account/recovery_phrase_page.dart';
Expand Down Expand Up @@ -135,6 +134,7 @@ import 'package:autonomy_flutter/screen/wallet_connect/wc_connect_page.dart';
import 'package:autonomy_flutter/screen/wallet_connect/wc_sign_message_page.dart';
import 'package:autonomy_flutter/service/audit_service.dart';
import 'package:autonomy_flutter/service/configuration_service.dart';
import 'package:autonomy_flutter/service/wc2_service.dart';
import 'package:autonomy_flutter/view/transparent_router.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
Expand Down Expand Up @@ -476,7 +476,6 @@ class AppRouter {
injector(),
injector(),
injector(),
injector(),
),
child: WCSendTransactionPage(
args: settings.arguments! as WCSendTransactionPageArgs),
Expand Down Expand Up @@ -723,8 +722,8 @@ class AppRouter {
case AUSignMessagePage.tag:
return CupertinoPageRoute(
settings: settings,
builder: (context) =>
AUSignMessagePage(request: settings.arguments! as Wc2Request),
builder: (context) => AUSignMessagePage(
request: settings.arguments! as Wc2RequestPayload),
);
case TBSendTransactionPage.tag:
return CupertinoPageRoute(
Expand Down Expand Up @@ -988,7 +987,7 @@ class AppRouter {
),
],
child: Wc2RequestPage(
request: settings.arguments! as Wc2Request)));
request: settings.arguments! as Wc2RequestPayload)));

case walletPage:
return CupertinoPageRoute(
Expand Down
11 changes: 3 additions & 8 deletions lib/screen/irl_screen/webview_irl_screen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_inappwebview/flutter_inappwebview.dart';
import 'package:tezart/tezart.dart';
import 'package:walletconnect_flutter_v2/apis/core/pairing/utils/pairing_models.dart';
ppupha marked this conversation as resolved.
Show resolved Hide resolved
import 'package:uuid/uuid.dart';

class IRLWebScreen extends StatefulWidget {
Expand Down Expand Up @@ -314,14 +315,8 @@ class _IRLWebScreenState extends State<IRLWebScreen> {
}

final args = WCSendTransactionPageArgs(
1,
AppMetadata.fromJson(argument.metadata ??
{
'name': '',
'url': '',
'icons': [''],
'description': '',
}),
const PairingMetadata(
name: '', description: '', url: '', icons: []),
WCEthereumTransaction.fromJson(transaction),
account.wallet.uuid,
account.index,
Expand Down
Loading
Loading