-
-
Notifications
You must be signed in to change notification settings - Fork 115
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: socket reconnection optimization (#994)
* feat: prevent duplicate events * feat: fully reuse existing channel * fix: unit tests * feat: cleanup * feat: cleanup * feat: cleanup * feat: wip * feat: connection management and cleanup events * feat: cleanup * feat: cleanup * feat: prevent e2e locally * feat: cleanup * fix: tests * fix: unit tests * fix: unit tests * fix: unit tests * fix: unit tests * fix: unit tests * fix: unit tests * fix: unit test * fix: unit tests * fix: unit tests * fix: cleanup * feat: cleanup * feat: add missing sdkVersion to originatorInfo * feat: add utility to debug universal links * feat: cleanup * feat: working nodejs and wagmi * feat: working state * feat: debug logs * fix: authorized not reset after terminate
- Loading branch information
1 parent
9e9f1ac
commit 5af7cbf
Showing
72 changed files
with
1,611 additions
and
1,506 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,226 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Custom Input Debug Universal Link</title> | ||
<style> | ||
body { | ||
font-family: Arial, sans-serif; | ||
line-height: 1.6; | ||
padding: 20px; | ||
max-width: 800px; | ||
margin: 0 auto; | ||
} | ||
|
||
pre { | ||
background-color: #f4f4f4; | ||
padding: 10px; | ||
border-radius: 5px; | ||
overflow-x: auto; | ||
white-space: pre-wrap; | ||
word-wrap: break-word; | ||
} | ||
|
||
table { | ||
border-collapse: collapse; | ||
width: 100%; | ||
margin-bottom: 20px; | ||
table-layout: fixed; | ||
} | ||
|
||
th, | ||
td { | ||
border: 1px solid #ddd; | ||
padding: 8px; | ||
text-align: left; | ||
} | ||
|
||
th { | ||
background-color: #f2f2f2; | ||
} | ||
|
||
.param-column { | ||
width: 30%; | ||
word-break: break-word; | ||
} | ||
|
||
.value-column { | ||
width: 70%; | ||
word-break: break-word; | ||
} | ||
|
||
.param-control { | ||
display: flex; | ||
align-items: center; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.param-control input[type="checkbox"] { | ||
margin-right: 10px; | ||
} | ||
|
||
button, | ||
input[type="text"] { | ||
margin-top: 10px; | ||
padding: 5px 10px; | ||
} | ||
|
||
input[type="text"] { | ||
width: 100%; | ||
box-sizing: border-box; | ||
} | ||
|
||
#decodedInfo { | ||
max-height: 300px; | ||
overflow-y: auto; | ||
} | ||
</style> | ||
</head> | ||
|
||
<body> | ||
<h1>Custom Input Universal Link Debug</h1> | ||
<p>Paste your own deep link or use the default:</p> | ||
<input type="text" id="customLink" placeholder="Paste your deep link here"> | ||
<button id="useCustomLink">Use Custom Link</button> | ||
<button id="useDefaultLink">Use Default Link</button> | ||
|
||
<h2>Modify Parameters:</h2> | ||
<div id="paramControls"></div> | ||
<button id="updateLink">Update Link</button> | ||
<button id="testLink">Test Updated Link</button> | ||
|
||
<h2>Current Link:</h2> | ||
<pre id="currentLink"></pre> | ||
|
||
<h2>Query Parameters:</h2> | ||
<table id="paramsTable"> | ||
<tr> | ||
<th class="param-column">Parameter</th> | ||
<th class="value-column">Value</th> | ||
</tr> | ||
</table> | ||
|
||
<h2>Decoded originatorInfo:</h2> | ||
<pre id="decodedInfo"></pre> | ||
|
||
<script> | ||
const defaultLink = "https://metamask.app.link/connect?channelId=4e8f280b-3c3b-41f4-9cbe-9967f67f1ee8&v=2&comm=socket&pubkey=0248e0e610fd2ce7a1058a57434a65114520d2f0a6dcafa587b7ceebe5ac439359&t=q&originatorInfo=eyJ1cmwiOiJodHRwczovL2RldmRhcHAuc2l0ZWVkLm5ldCIsInRpdGxlIjoiRGV2TmV4dCIsImljb24iOiJodHRwczovL2RldmRhcHAuc2l0ZWVkLm5ldC9mYXZpY29uLmljbyIsInNjaGVtZSI6IiIsImFwaVZlcnNpb24iOiIwLjI3LjAiLCJkYXBwSWQiOiJkZXZkYXBwLnNpdGVlZC5uZXQiLCJwbGF0Zm9ybSI6IndlYi1kZXNrdG9wIiwic291cmNlIjoiZGlyZWN0In0="; | ||
let currentLink = defaultLink; | ||
let originalParams = new URLSearchParams(new URL(defaultLink).search); | ||
|
||
function decodeOriginatorInfo(encodedInfo) { | ||
try { | ||
return JSON.parse(atob(decodeURIComponent(encodedInfo))); | ||
} catch (e) { | ||
return "Error decoding originatorInfo: " + e.message; | ||
} | ||
} | ||
|
||
function displayLinkInfo(link) { | ||
const url = new URL(link); | ||
const currentLinkElement = document.getElementById('currentLink'); | ||
const paramsTable = document.getElementById('paramsTable'); | ||
const decodedInfo = document.getElementById('decodedInfo'); | ||
|
||
currentLinkElement.textContent = link; | ||
|
||
// Clear existing rows | ||
while (paramsTable.rows.length > 1) { | ||
paramsTable.deleteRow(1); | ||
} | ||
|
||
// Display query parameters | ||
url.searchParams.forEach((value, key) => { | ||
const row = paramsTable.insertRow(); | ||
const cell1 = row.insertCell(0); | ||
const cell2 = row.insertCell(1); | ||
cell1.className = 'param-column'; | ||
cell2.className = 'value-column'; | ||
cell1.textContent = key; | ||
cell2.textContent = value; | ||
}); | ||
|
||
// Decode and display originatorInfo | ||
const originatorInfo = url.searchParams.get('originatorInfo'); | ||
if (originatorInfo) { | ||
decodedInfo.textContent = JSON.stringify(decodeOriginatorInfo(originatorInfo), null, 2); | ||
} else { | ||
decodedInfo.textContent = "No originatorInfo found in the URL."; | ||
} | ||
} | ||
|
||
function createParamControls(link) { | ||
const url = new URL(link); | ||
const controlsContainer = document.getElementById('paramControls'); | ||
controlsContainer.innerHTML = ''; // Clear existing controls | ||
|
||
originalParams = new URLSearchParams(url.search); | ||
|
||
originalParams.forEach((value, key) => { | ||
const controlDiv = document.createElement('div'); | ||
controlDiv.className = 'param-control'; | ||
|
||
const checkbox = document.createElement('input'); | ||
checkbox.type = 'checkbox'; | ||
checkbox.id = `check-${key}`; | ||
checkbox.checked = true; | ||
|
||
const label = document.createElement('label'); | ||
label.htmlFor = `check-${key}`; | ||
label.textContent = key; | ||
|
||
controlDiv.appendChild(checkbox); | ||
controlDiv.appendChild(label); | ||
controlsContainer.appendChild(controlDiv); | ||
}); | ||
} | ||
|
||
function updateLink() { | ||
const url = new URL(currentLink); | ||
const newUrl = new URL(url.origin + url.pathname); | ||
|
||
originalParams.forEach((value, key) => { | ||
const checkbox = document.getElementById(`check-${key}`); | ||
if (checkbox && checkbox.checked) { | ||
newUrl.searchParams.append(key, value); | ||
} | ||
}); | ||
|
||
currentLink = newUrl.toString(); | ||
displayLinkInfo(currentLink); | ||
} | ||
|
||
document.getElementById('useCustomLink').addEventListener('click', function () { | ||
const customLinkInput = document.getElementById('customLink'); | ||
if (customLinkInput.value) { | ||
currentLink = customLinkInput.value; | ||
createParamControls(currentLink); | ||
displayLinkInfo(currentLink); | ||
} else { | ||
alert('Please enter a custom link first.'); | ||
} | ||
}); | ||
|
||
document.getElementById('useDefaultLink').addEventListener('click', function () { | ||
currentLink = defaultLink; | ||
document.getElementById('customLink').value = ''; | ||
createParamControls(currentLink); | ||
displayLinkInfo(currentLink); | ||
}); | ||
|
||
document.getElementById('updateLink').addEventListener('click', updateLink); | ||
|
||
document.getElementById('testLink').addEventListener('click', function () { | ||
console.log('Testing link:', currentLink); | ||
window.location.href = currentLink; | ||
}); | ||
|
||
// Initialize the page | ||
createParamControls(currentLink); | ||
displayLinkInfo(currentLink); | ||
</script> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.