Skip to content

Commit f91f6ea

Browse files
committed
fix conflicts
1 parent 8a95e65 commit f91f6ea

File tree

7 files changed

+74
-50
lines changed

7 files changed

+74
-50
lines changed

.dart_tool/package_config.json

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,9 @@
171171
},
172172
{
173173
"name": "file",
174-
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/file-7.0.0",
174+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/file-6.1.4",
175175
"packageUri": "lib/",
176-
"languageVersion": "3.0"
176+
"languageVersion": "2.12"
177177
},
178178
{
179179
"name": "fixnum",
@@ -219,9 +219,9 @@
219219
},
220220
{
221221
"name": "http",
222-
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/http-1.2.1",
222+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/http-1.2.0",
223223
"packageUri": "lib/",
224-
"languageVersion": "3.3"
224+
"languageVersion": "3.2"
225225
},
226226
{
227227
"name": "http_multi_server",
@@ -285,9 +285,9 @@
285285
},
286286
{
287287
"name": "melos",
288-
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/melos-4.1.0",
288+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/melos-3.4.0",
289289
"packageUri": "lib/",
290-
"languageVersion": "3.0"
290+
"languageVersion": "2.18"
291291
},
292292
{
293293
"name": "merlin",
@@ -309,7 +309,7 @@
309309
},
310310
{
311311
"name": "moment_dart",
312-
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/moment_dart-2.0.2",
312+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/moment_dart-2.1.0",
313313
"packageUri": "lib/",
314314
"languageVersion": "2.19"
315315
},
@@ -381,9 +381,9 @@
381381
},
382382
{
383383
"name": "process",
384-
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/process-5.0.2",
384+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/process-4.2.4",
385385
"packageUri": "lib/",
386-
"languageVersion": "3.0"
386+
"languageVersion": "2.14"
387387
},
388388
{
389389
"name": "prompts",
@@ -405,7 +405,7 @@
405405
},
406406
{
407407
"name": "pub_updater",
408-
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/pub_updater-0.4.0",
408+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/pub_updater-0.3.1",
409409
"packageUri": "lib/",
410410
"languageVersion": "3.0"
411411
},
@@ -433,12 +433,24 @@
433433
"packageUri": "lib/",
434434
"languageVersion": "3.0"
435435
},
436+
{
437+
"name": "ristretto255",
438+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/ristretto255-1.0.2",
439+
"packageUri": "lib/",
440+
"languageVersion": "3.0"
441+
},
436442
{
437443
"name": "rmb_client",
438444
"rootUri": "../packages/rmb_client",
439445
"packageUri": "lib/",
440446
"languageVersion": "3.2"
441447
},
448+
{
449+
"name": "secp256k1_ecdsa",
450+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/secp256k1_ecdsa-0.4.0",
451+
"packageUri": "lib/",
452+
"languageVersion": "3.0"
453+
},
442454
{
443455
"name": "shelf",
444456
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/shelf-1.4.1",
@@ -615,9 +627,9 @@
615627
},
616628
{
617629
"name": "web",
618-
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/web-0.5.1",
630+
"rootUri": "file:///home/alaa/.pub-cache/hosted/pub.dev/web-0.4.2",
619631
"packageUri": "lib/",
620-
"languageVersion": "3.3"
632+
"languageVersion": "3.2"
621633
},
622634
{
623635
"name": "web_socket_channel",
@@ -656,7 +668,8 @@
656668
"languageVersion": "3.2"
657669
}
658670
],
659-
"generated": "2024-01-10T13:39:16.827881Z",
671+
"generated": "2024-06-01T17:42:48.645343Z",
660672
"generator": "pub",
661-
"generatorVersion": "3.3.3"
673+
"generatorVersion": "3.4.0",
674+
"pubCache": "file:///home/alaa/.pub-cache"
662675
}

packages/rmb_client/lib/rmb_client.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import 'dart:convert';
55
import 'dart:typed_data';
66
import 'package:polkadart_keyring/polkadart_keyring.dart';
77
import 'package:rmb_client/src/sign.dart';
8+
import 'package:tfchain_client/models/twins.dart';
89
import 'package:web_socket_channel/web_socket_channel.dart';
910
import 'package:tfchain_client/tfchain_client.dart' as TFClient;
1011

packages/rmb_client/lib/src/client.dart

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
part of "../rmb_client.dart";
22

3-
// TODO: How to import tfchain_client ??
4-
53
class Client {
64
KeyPair? signer;
75
String relayUrl;
@@ -12,6 +10,7 @@ class Client {
1210
WebSocketChannel? channel;
1311
int? retries;
1412
TFClient.QueryClient? client;
13+
String keypairType;
1514
var connections = new Map();
1615

1716
Client(
@@ -20,18 +19,14 @@ class Client {
2019
this.mnemonic,
2120
this.session, {
2221
this.retries = 5,
23-
required String keypairType,
22+
required this.keypairType,
2423
}) {
2524
final key = '${relayUrl}:${mnemonic}:${keypairType}';
2625
if (connections.containsKey(key)) {
2726
// TODO: how to return from constructor ??
2827
// return connections[key] as Client;
2928
}
3029

31-
if (keypairType != "ed25519") {
32-
throw ArgumentError("Unsupported Keypair type");
33-
}
34-
3530
client = TFClient.QueryClient(chainUrl);
3631
client?.connect();
3732
}
@@ -51,9 +46,13 @@ class Client {
5146
print("connected to relay ");
5247

5348
print(signer!.address);
54-
twin = await client?.twins
55-
.getTwinIdByAccountId(accountId: signer!.publicKey.bytes);
49+
twin = await client?.twins.getTwinIdByAccountId(
50+
QueryTwinsGetTwinByAccountIdOptions(
51+
accountId: signer!.publicKey.bytes));
5652
print(twin);
53+
if (twin == 0) {
54+
throw "Couldn't find a user for the provided mnemonic on this network.";
55+
}
5756

5857
await channel!.ready;
5958
} catch (e) {
@@ -79,7 +78,11 @@ class Client {
7978
String jwt =
8079
'${base64Url.encode(utf8.encode(jsonEncode(header)))}.${base64Url.encode(utf8.encode(jsonEncode(claims)))}';
8180

82-
signer = await KeyPair.fromMnemonic(mnemonic);
81+
if (keypairType == KPType.ed25519) {
82+
signer = await KeyPair.ed25519.fromMnemonic(mnemonic);
83+
} else if (keypairType == KPType.sr25519) {
84+
signer = await KeyPair.sr25519.fromMnemonic(mnemonic);
85+
}
8386

8487
Uint8List sigPrefixed = sign(Uint8List.fromList(jwt.codeUnits), signer!);
8588
String token = '$jwt.${base64Url.encode(sigPrefixed)}';

packages/rmb_client/lib/src/sign.dart

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import 'dart:typed_data';
44
import 'package:polkadart_keyring/polkadart_keyring.dart';
55

66
class KPType {
7-
static const sr25519 = "sr25519"; //not supported
7+
static const sr25519 = "sr25519";
88
static const ed25519 = "ed25519";
99
}
1010

@@ -14,8 +14,12 @@ Uint8List sign(Uint8List payload, KeyPair signer) {
1414
final newPayload = Uint8List.fromList(payload.sublist(0, payload.length - 1));
1515

1616
// String resultString = String.fromCharCodes(newPayload);
17-
18-
String typePrefix = "e";
17+
String typePrefix = "";
18+
if (signer.keyPairType.toString() == KPType.ed25519) {
19+
typePrefix = "e";
20+
} else if (signer.keyPairType.toString() == KPType.sr25519) {
21+
typePrefix = "s";
22+
}
1923

2024
final sig = signer.sign(newPayload);
2125

packages/rmb_client/pubspec.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,12 @@ environment:
1010
# Add regular dependencies here.
1111
dependencies:
1212
fixnum: ^1.1.0
13-
polkadart_keyring: ^0.2.1
13+
polkadart_keyring: ^0.4.3
1414
protobuf: ^3.1.0
1515
web_socket_channel: ^2.4.1
1616
tfchain_client:
1717
path: ../tfchain_client
1818

1919
dev_dependencies:
20-
lints: ^2.1.0
20+
lints: ^4.0.0
2121
test: ^1.24.0

packages/tfchain_client/pubspec.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ dependencies:
1313
hex: ^0.2.0
1414
bip39: ^1.0.6
1515
convert: ^3.1.1
16+
moment_dart: ^2.1.0
17+
signer:
18+
path: ../signer
1619

1720
dev_dependencies:
1821
lints: ^3.0.0

pubspec.lock

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -229,10 +229,10 @@ packages:
229229
dependency: transitive
230230
description:
231231
name: file
232-
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
232+
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
233233
url: "https://pub.dev"
234234
source: hosted
235-
version: "7.0.0"
235+
version: "6.1.4"
236236
fixnum:
237237
dependency: transitive
238238
description:
@@ -293,10 +293,10 @@ packages:
293293
dependency: transitive
294294
description:
295295
name: http
296-
sha256: "761a297c042deedc1ffbb156d6e2af13886bb305c2a343a4d972504cd67dd938"
296+
sha256: a2bbf9d017fcced29139daa8ed2bba4ece450ab222871df93ca9eec6f80c34ba
297297
url: "https://pub.dev"
298298
source: hosted
299-
version: "1.2.1"
299+
version: "1.2.0"
300300
http_multi_server:
301301
dependency: transitive
302302
description:
@@ -381,10 +381,10 @@ packages:
381381
dependency: "direct main"
382382
description:
383383
name: melos
384-
sha256: "7266e9fc9fee5f4a0c075e5cec375c00736dfc944358f533b740b93b3d8d681e"
384+
sha256: "96e64bbade5712c3f010137e195bca9f1b351fac34ab1f322af492ae34032067"
385385
url: "https://pub.dev"
386386
source: hosted
387-
version: "4.1.0"
387+
version: "3.4.0"
388388
merlin:
389389
dependency: transitive
390390
description:
@@ -413,10 +413,10 @@ packages:
413413
dependency: transitive
414414
description:
415415
name: moment_dart
416-
sha256: "252e06594ad7d1f1815c18a9112b76451fcee05743667c0566e24b83a078b91d"
416+
sha256: e8683f46ea80dbe47bb0f9f684253630f6a09faa5f626869e1f31bdcf14f6b91
417417
url: "https://pub.dev"
418418
source: hosted
419-
version: "2.0.2"
419+
version: "2.1.0"
420420
mustache_template:
421421
dependency: transitive
422422
description:
@@ -509,10 +509,10 @@ packages:
509509
dependency: transitive
510510
description:
511511
name: process
512-
sha256: "21e54fd2faf1b5bdd5102afd25012184a6793927648ea81eea80552ac9405b32"
512+
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
513513
url: "https://pub.dev"
514514
source: hosted
515-
version: "5.0.2"
515+
version: "4.2.4"
516516
prompts:
517517
dependency: transitive
518518
description:
@@ -541,10 +541,10 @@ packages:
541541
dependency: transitive
542542
description:
543543
name: pub_updater
544-
sha256: "54e8dc865349059ebe7f163d6acce7c89eb958b8047e6d6e80ce93b13d7c9e60"
544+
sha256: b06600619c8c219065a548f8f7c192b3e080beff95488ed692780f48f69c0625
545545
url: "https://pub.dev"
546546
source: hosted
547-
version: "0.4.0"
547+
version: "0.3.1"
548548
pubspec:
549549
dependency: transitive
550550
description:
@@ -585,6 +585,13 @@ packages:
585585
url: "https://pub.dev"
586586
source: hosted
587587
version: "1.0.2"
588+
rmb_client:
589+
dependency: "direct main"
590+
description:
591+
path: "packages/rmb_client"
592+
relative: true
593+
source: path
594+
version: "1.0.0"
588595
secp256k1_ecdsa:
589596
dependency: transitive
590597
description:
@@ -593,13 +600,6 @@ packages:
593600
url: "https://pub.dev"
594601
source: hosted
595602
version: "0.4.0"
596-
rmb_client:
597-
dependency: "direct main"
598-
description:
599-
path: "packages/rmb_client"
600-
relative: true
601-
source: path
602-
version: "1.0.0"
603603
shelf:
604604
dependency: transitive
605605
description:
@@ -834,10 +834,10 @@ packages:
834834
dependency: transitive
835835
description:
836836
name: web
837-
sha256: "97da13628db363c635202ad97068d47c5b8aa555808e7a9411963c533b449b27"
837+
sha256: "4188706108906f002b3a293509234588823c8c979dc83304e229ff400c996b05"
838838
url: "https://pub.dev"
839839
source: hosted
840-
version: "0.5.1"
840+
version: "0.4.2"
841841
web_socket_channel:
842842
dependency: transitive
843843
description:

0 commit comments

Comments
 (0)