Skip to content

Changes type of chainId to String #16

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ connector.on('disconnect', (session) => print(session));
// Create a new session
if (!connector.connected) {
final session = await connector.createSession(
chainId: 4160,
chainId: '4160',
onDisplayUri: (uri) => print(uri),
);
}
Expand Down Expand Up @@ -119,13 +119,13 @@ connector.on('disconnect', (session) => print(session));

```dart
// Approve session
await connector.approveSession(chainId: 4160, accounts: ['0x4292...931B3']);
await connector.approveSession(chainId: '4160', accounts: ['0x4292...931B3']);

// Reject session
await connector.rejectSession(message: 'Optional error message');

// Update session
await connector.updateSession(SessionStatus(chainId: 4000, accounts: ['0x4292...931B3']));
await connector.updateSession(SessionStatus(chainId: '4000', accounts: ['0x4292...931B3']));
```

**Kill session**
Expand Down
2 changes: 1 addition & 1 deletion example/dapp/lib/dapp.dart
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ void main() async {

// Check if connection is already established
final session = await connector.createSession(
chainId: 4160,
chainId: '4160',
onDisplayUri: (uri) => print(uri),
);
final sender = Address.fromAlgorandAddress(address: session.accounts[0]);
Expand Down
2 changes: 1 addition & 1 deletion example/example.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ connector.setDefaultProvider(AlgorandWCProvider(connector));

// Check if connection is already established
final session = await connector.createSession(
chainId: 4160,
chainId: '4160',
onDisplayUri: (uri) => print(uri),
);

Expand Down
2 changes: 1 addition & 1 deletion example/mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class _MyHomePageState extends State<MyHomePage> {
child: const Icon(Icons.add),
onPressed: () async {
final session = await wc.connector.createSession(
chainId: 4160,
chainId: '4160',
onDisplayUri: (uri) {
// launch(uri);
setState(() {
Expand Down
6 changes: 3 additions & 3 deletions example/wallet/lib/wallet.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ void main() async {
final connector = _buildApp();
if (!connector.connected) {
final session = await connector.createSession(
chainId: 4160,
chainId: '4160',
onDisplayUri: (uri) {
print(uri);

Expand Down Expand Up @@ -63,10 +63,10 @@ void _connectWallet({required String uri}) {

// Subscribe to session requests
connector.on('session_request', (payload) async {
await connector.approveSession(chainId: 4160, accounts: ['test']);
await connector.approveSession(chainId: '4160', accounts: ['test']);

await connector
.updateSession(SessionStatus(chainId: 4000, accounts: ['test2']));
.updateSession(SessionStatus(chainId: '4000', accounts: ['test2']));
});

connector.on('disconnect', (message) async {
Expand Down
2 changes: 1 addition & 1 deletion lib/src/api/walletconnect/wc_session_request.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ part 'wc_session_request.g.dart';
@JsonSerializable()
class WCSessionRequest {
@JsonKey(name: 'chainId')
final int? chainId;
final String? chainId;

@JsonKey(name: 'peerId')
final String? peerId;
Expand Down
2 changes: 1 addition & 1 deletion lib/src/api/walletconnect/wc_session_request.g.dart

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

4 changes: 2 additions & 2 deletions lib/src/api/walletconnect/wc_session_request_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class WCSessionRequestResponse {
final bool approved;

@JsonKey(name: 'chainId')
final int? chainId;
final String? chainId;

@JsonKey(name: 'accounts', defaultValue: [])
final List<String> accounts;
Expand All @@ -37,7 +37,7 @@ class WCSessionRequestResponse {

/// Get the status of the session;
SessionStatus get status => SessionStatus(
chainId: chainId ?? 0,
chainId: chainId ?? '0',
accounts: accounts,
);

Expand Down

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

4 changes: 2 additions & 2 deletions lib/src/api/walletconnect/wc_session_update_response.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ class WCSessionUpdateResponse {
@JsonKey(name: 'approved', defaultValue: false)
final bool approved;

@JsonKey(name: 'chainId', defaultValue: 0)
final int chainId;
@JsonKey(name: 'chainId', defaultValue: '0')
final String chainId;

@JsonKey(name: 'accounts', defaultValue: [])
final List<String> accounts;
Expand Down

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

2 changes: 1 addition & 1 deletion lib/src/providers/wallet_connect_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ abstract class WalletConnectProvider {
});

/// Get the chain id.
int get chainId;
String get chainId;
}
2 changes: 1 addition & 1 deletion lib/src/providers/wc_algorand_provider.dart
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@ class AlgorandWCProvider extends WalletConnectProvider {

/// The chain id of the Algorand blockchain.
@override
int get chainId => 4160;
String get chainId => '4160';
}
4 changes: 2 additions & 2 deletions lib/src/session/session_status.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// Information regarding the current session.
class SessionStatus {
final int chainId;
final String chainId;
final List<String> accounts;
final int? networkId;
final String? rpcUrl;
Expand All @@ -13,7 +13,7 @@ class SessionStatus {
});

SessionStatus copyWith({
int? chainId,
String? chainId,
List<String>? accounts,
int? networkId,
String? rpcUrl,
Expand Down
4 changes: 2 additions & 2 deletions lib/src/session/wallet_connect_session.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class WalletConnectSession {
int version;
bool connected;
List<String> accounts;
int chainId;
String chainId;
String bridge = '';

@KeyConverter()
Expand All @@ -33,7 +33,7 @@ class WalletConnectSession {
this.protocol = 'wc',
this.version = 1,
this.connected = false,
this.chainId = 0,
this.chainId = '0',
this.bridge = '',
this.key,
this.clientId = '',
Expand Down
2 changes: 1 addition & 1 deletion lib/src/session/wallet_connect_session.g.dart

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

6 changes: 3 additions & 3 deletions lib/src/walletconnect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class WalletConnect {
}

/// Create a new session.
Future<SessionStatus> connect({int? chainId}) async {
Future<SessionStatus> connect({String? chainId}) async {
if (connected) {
return SessionStatus(
chainId: session.chainId,
Expand All @@ -168,7 +168,7 @@ class WalletConnect {

/// Create a new session between the dApp and wallet.
Future<SessionStatus> createSession({
int? chainId,
String? chainId,
OnDisplayUriCallback? onDisplayUri,
}) async {
if (connected) {
Expand Down Expand Up @@ -210,7 +210,7 @@ class WalletConnect {
/// Approve the session.
Future approveSession({
required List<String> accounts,
required int chainId,
required String chainId,
}) async {
if (connected) {
throw WalletConnectException('Session currently connected');
Expand Down