Add create accont Btn and update prepareAndSendPairingTx()
This commit is contained in:
parent
b9c4dfbfd9
commit
4d0c3e3f56
@ -104,6 +104,7 @@ export function initAddressInput() {
|
||||
const addressInput = container.querySelector('#addressInput') as HTMLInputElement;
|
||||
const emojiDisplay = container.querySelector('#emoji-display-2');
|
||||
const okButton = container.querySelector('#okButton') as HTMLButtonElement;
|
||||
const createButton = container.querySelector('#createButton') as HTMLButtonElement;
|
||||
addSubscription(addressInput, 'input', async () => {
|
||||
let address = addressInput.value;
|
||||
|
||||
@ -145,6 +146,12 @@ export function initAddressInput() {
|
||||
onOkButtonClick();
|
||||
});
|
||||
}
|
||||
|
||||
if (createButton) {
|
||||
addSubscription(createButton, 'click', () => {
|
||||
onCreateButtonClick();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function onOkButtonClick() {
|
||||
@ -158,14 +165,22 @@ async function onOkButtonClick() {
|
||||
}
|
||||
}
|
||||
|
||||
export async function prepareAndSendPairingTx(secondDeviceAddress: string) {
|
||||
async function onCreateButtonClick() {
|
||||
try {
|
||||
await prepareAndSendPairingTx();
|
||||
} catch (e) {
|
||||
console.error(`onCreateButtonClick error: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
export async function prepareAndSendPairingTx() {
|
||||
const service = await Services.getInstance();
|
||||
|
||||
// Device 1 wait Device 2
|
||||
service.device1 = true;
|
||||
// service.device1 = true;
|
||||
|
||||
try {
|
||||
await service.checkConnections([{ sp_addresses: [secondDeviceAddress] }]);
|
||||
await service.checkConnections([]);
|
||||
} catch (e) {
|
||||
throw e;
|
||||
}
|
||||
@ -183,7 +198,7 @@ export async function prepareAndSendPairingTx(secondDeviceAddress: string) {
|
||||
// Pass the userName as an additional parameter.
|
||||
const createPairingProcessReturn = await service.createPairingProcess(
|
||||
userName,
|
||||
[secondDeviceAddress],
|
||||
[],
|
||||
relayAddress[0].spAddress,
|
||||
1,
|
||||
userName
|
||||
@ -204,17 +219,21 @@ export async function generateQRCode(spAddress: string) {
|
||||
const url = await QRCode.toDataURL(currentUrl + '?sp_address=' + spAddress);
|
||||
const qrCode = container?.querySelector('.qr-code img');
|
||||
qrCode?.setAttribute('src', url);
|
||||
|
||||
//Generate Address CopyBtn
|
||||
const address = container?.querySelector('.sp-address-btn');
|
||||
if (address) {
|
||||
address.textContent = 'Copy address';
|
||||
}
|
||||
const copyBtn = container.querySelector('#copyBtn');
|
||||
if (copyBtn) {
|
||||
addSubscription(copyBtn, 'click', () => copyToClipboard(currentUrl + '?sp_address=' + spAddress));
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
|
||||
export async function generateCreateBtn() {
|
||||
try{
|
||||
//Generate CreateBtn
|
||||
const container = getCorrectDOM('login-4nk-component') as HTMLElement
|
||||
const createBtn = container?.querySelector('.create-btn');
|
||||
if (createBtn) {
|
||||
createBtn.textContent = 'CREATE';
|
||||
}
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user