Skip to content
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

feat: Masca ReputeX demo #2

Merged
merged 4 commits into from
Oct 12, 2023
Merged
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
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@
},
"dependencies": {
"@apollo/client": "^3.7.2",
"@blockchain-lab-um/masca-connector": "1.0.0-beta.1",
"@blockchain-lab-um/masca-connector": "1.1.0",
"@coinbase/wallet-sdk": "^3.6.4",
"@fontsource/ibm-plex-mono": "^4.5.1",
"@fontsource/inter": "^4.5.1",
Expand All @@ -194,7 +194,6 @@
"@sentry/react": "^7.45.0",
"@sentry/tracing": "^7.45.0",
"@sentry/types": "^7.45.0",
"@types/qrcode": "^1.5.1",
"@types/react-window-infinite-loader": "^1.0.6",
"@uniswap/analytics": "1.5.0",
"@uniswap/analytics-events": "^2.24.0",
Expand Down Expand Up @@ -264,7 +263,6 @@
"numbro": "^2.3.6",
"polished": "^3.3.2",
"polyfill-object.fromentries": "^1.0.1",
"qrcode": "^1.5.3",
"qrcode.react": "^3.1.0",
"qs": "^6.9.4",
"rc-slider": "^10.0.1",
Expand Down
32 changes: 16 additions & 16 deletions public/sitemap.xml
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<url loc="https://app.uniswap.org/" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="1"/>
<url loc="https://app.uniswap.org/tokens" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.8"/>
<url loc="https://app.uniswap.org/send" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/swap" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.9"/>
<url loc="https://app.uniswap.org/pool/v2/find" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pool/v2" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pool" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pools/v2/find" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pools/v2" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pools" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.7"/>
<url loc="https://app.uniswap.org/add/v2" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/add" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/increase" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/migrate/v2" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/nfts" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/nfts/profile" lastmod="2023-10-06T11:39:07.450Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="1"/>
<url loc="https://app.uniswap.org/tokens" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.8"/>
<url loc="https://app.uniswap.org/send" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/swap" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.9"/>
<url loc="https://app.uniswap.org/pool/v2/find" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pool/v2" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pool" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pools/v2/find" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pools/v2" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/pools" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.7"/>
<url loc="https://app.uniswap.org/add/v2" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/add" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/increase" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/migrate/v2" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/nfts" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
<url loc="https://app.uniswap.org/nfts/profile" lastmod="2023-10-06T13:18:58.734Z" changefreq="weekly" priority="0.6"/>
</urlset>
4 changes: 3 additions & 1 deletion src/components/Web3Provider/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ function Updater() {
}
const mascaResult = await enableMasca((account as string).toLowerCase(), {
snapId: 'npm:@blockchain-lab-um/masca',
version: '1.0.0-beta.2',
// snapId: 'local:http://localhost:8081',
// version: 'v1.0.0-beta.5',
version: 'v1.0.0',
supportedMethods: ['did:polygonid'],
})
if (isError(mascaResult)) {
Expand Down
2 changes: 1 addition & 1 deletion src/connection/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function getInjection(isDarkMode?: boolean): { name: string; icon: string
}

// Check for MetaMask last, as other injectors will also set this flag, i.e. Brave browser and Phantom wallet
if (window.ethereum?.isMetaMask) return { name: 'MetaMask Flask', icon: METAMASK_ICON }
if (window.ethereum?.isMetaMask) return { name: 'MetaMask', icon: METAMASK_ICON }

// Prompt metamask installation when there is no injection present or the only injection detected is coinbase (CB has separate entry point in UI)
if (!window.ethereum || window.ethereum.isCoinbaseWallet) return { name: 'Install MetaMask', icon: METAMASK_ICON }
Expand Down
33 changes: 28 additions & 5 deletions src/pages/Swap/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -479,8 +479,31 @@ export function Swap({

const handleAuthorization = useCallback(async () => {
setShowAuthenticationModal(true)
const kycEndpoint = 'https://verifier-v2.polygonid.me/api/sign-in?type=kycSig'
const response = await fetch(kycEndpoint)
const requestBody = {
circuitId: 'credentialAtomicQuerySigV2',
requestID: 1,
query: {
type: 'ReputeXUniswapCredibilityCredential',
allowedIssuers: ['did:polygonid:polygon:main:2q5Pyn8q8GKKAy8fKQjMe9ADjSQD69tWTUW3aJRhuv'],
context:
'https://raw.githubusercontent.com/reputex/polygon-id-credential-schemas/main/ReputeXUniswapCredibilityCredential/ReputeXUniswapCredibilityCredential.jsonld',
skipClaimRevocationCheck: true,
credentialSubject: {
protocolScore: {
$eq: 0,
},
},
},
}

const kycEndpoint = 'https://verifier-v2.polygonid.me/api/sign-in?type=custom'
const response = await fetch(kycEndpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestBody),
})
const authorizationRequestObject = await response.json()

if (!mascaApi) throw new Error('Masca API is not defined')
Expand All @@ -491,15 +514,15 @@ export function Swap({
if (selectedMethodResult.data !== 'did:polygonid') {
await mascaApi?.switchDIDMethod('did:polygonid')
// TODO: optional error handling with isError can come here, not neccessary-
// due to only supported method is did:polygonid
// due to only supported method being did:polygonid
}
await selectChain(ChainId.POLYGON_MUMBAI)
await selectChain(ChainId.POLYGON)
const authorizationRequest = JSON.stringify(authorizationRequestObject)
const authResult = await mascaApi?.handleAuthorizationRequest({
authorizationRequest,
})
if (!authResult.success) {
console.error(authResult.error)
console.error(authResult)
setShowAuthenticationModal(false)
return
}
Expand Down
Loading
Loading