|
@@ -2,7 +2,7 @@ import "../assets/style.scss";
|
2
|
2
|
import * as _ from "lodash";
|
3
|
3
|
import { connect, WalletConnection, keyStores, Near } from 'near-api-js';
|
4
|
4
|
import { BrowserLocalStorageKeyStore } from "near-api-js/lib/key_stores";
|
5
|
|
-const { KeyProvisioner, ErrorType, ProvisionerConfig } = await import("../../pkg/web_client");
|
|
5
|
+const { KeyProvisioner, ProvisionerConfig } = await import("../../pkg/web_client");
|
6
|
6
|
|
7
|
7
|
async function ui() {
|
8
|
8
|
let keyStore = new keyStores.BrowserLocalStorageKeyStore();
|
|
@@ -48,7 +48,7 @@ async function handle_wallet(wallet_connection: WalletConnection, near_connectio
|
48
|
48
|
let keypair = await keyStore.getKey("testnet", account_id.toString());
|
49
|
49
|
let found = accessKeys.find(key => key.public_key.toString() == keypair.getPublicKey().toString());
|
50
|
50
|
|
51
|
|
- let config = new ProvisionerConfig("contract2.demoacc.testnet", "https://rpc.testnet.near.org", "http://servtest.relayz.io:3000");
|
|
51
|
+ let config = new ProvisionerConfig("relayz-meet.testnet", "https://rpc.testnet.near.org", "http://servtest.relayz.io:3000");
|
52
|
52
|
let provisioner = new KeyProvisioner(keypair.toString(), BigInt(found.access_key.nonce), account_id.toString(), config);
|
53
|
53
|
|
54
|
54
|
console.log("KeyPair: ", keypair.getPublicKey().toString());
|
|
@@ -62,24 +62,24 @@ async function handle_wallet(wallet_connection: WalletConnection, near_connectio
|
62
|
62
|
let participants = (document.getElementById("inp_participants") as HTMLInputElement | null)?.value;
|
63
|
63
|
if (participants.length > 0) {
|
64
|
64
|
console.log("Participants: " + participants);
|
65
|
|
- provisioner.init(new Set(participants.split(",")), timeout_ms)
|
66
|
|
- .then((id: string) => {
|
67
|
|
- (document.getElementById("meeting_id_label") as HTMLSpanElement).textContent = id;
|
68
|
|
- console.log("Meeting Id:", id);
|
69
|
|
- provisioner.send_keys(id, interaction_timeout_ms)
|
|
65
|
+ provisioner.init_meeting(new Set(participants.split(",")), timeout_ms)
|
|
66
|
+ .then((meeting) => {
|
|
67
|
+ console.log("Meeting Id:", meeting.meet_id);
|
|
68
|
+ console.log("Transaction Id:", meeting.transaction_id);
|
|
69
|
+ (document.getElementById("meeting_id_label") as HTMLSpanElement).textContent = meeting.meet_id;
|
|
70
|
+ provisioner.send_keys(meeting.meet_id, interaction_timeout_ms)
|
70
|
71
|
.then((secret_key) => {
|
71
|
72
|
(document.getElementById("secret_id_label") as HTMLSpanElement).textContent = secret_key;
|
72
|
73
|
console.log("Secret Key" + secret_key);
|
73
|
74
|
})
|
74
|
75
|
.then(() => console.log("Send keys is ok"))
|
75
|
76
|
.catch((err) => {
|
76
|
|
- console.log("Error: " + err.err_msg());
|
|
77
|
+ console.log("Error: ", err);
|
77
|
78
|
});
|
78
|
79
|
})
|
79
|
80
|
.then(() => console.log("Init is ok"))
|
80
|
81
|
.catch((err) => {
|
81
|
|
- console.log("ErrorType: " + ErrorType[err.err_type()]);
|
82
|
|
- console.log("Error: " + err.err_msg());
|
|
82
|
+ console.log("Error: ", err);
|
83
|
83
|
});
|
84
|
84
|
}
|
85
|
85
|
});
|
|
@@ -87,17 +87,11 @@ async function handle_wallet(wallet_connection: WalletConnection, near_connectio
|
87
|
87
|
document.getElementById("join_meeting_id").addEventListener("click", () => {
|
88
|
88
|
let meeting_id = (document.getElementById("inp_meeting_id") as HTMLInputElement | null)?.value;
|
89
|
89
|
if (meeting_id.length > 0) {
|
90
|
|
- provisioner.push_to_near(meeting_id, timeout_ms).then((_id) => {
|
91
|
|
- provisioner.get_key(meeting_id, timeout_ms).then((secret_key) => {
|
92
|
|
- (document.getElementById("secret_id_label") as HTMLSpanElement).textContent = secret_key;
|
93
|
|
- console.log("Secret Key" + secret_key);
|
94
|
|
- }).catch((err) => {
|
95
|
|
- console.log("ErrorType: " + ErrorType[err.err_type()]);
|
96
|
|
- console.log("Error: " + err.err_msg());
|
97
|
|
- });
|
98
|
|
- })
|
99
|
|
- .catch((err) => {
|
100
|
|
- console.log("Error: " + err.err_msg());
|
|
90
|
+ provisioner.get_key(meeting_id, timeout_ms).then((secret_key) => {
|
|
91
|
+ (document.getElementById("secret_id_label") as HTMLSpanElement).textContent = secret_key;
|
|
92
|
+ console.log("Secret Key" + secret_key);
|
|
93
|
+ }).catch((err) => {
|
|
94
|
+ console.log("Error: ", err);
|
101
|
95
|
});
|
102
|
96
|
}
|
103
|
97
|
});
|