-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
1 parent
dfe13bd
commit cd1cd62
Showing
20 changed files
with
126 additions
and
97 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.next | ||
node_modules |
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,6 @@ | ||
{ | ||
"semi": false, | ||
"trailingComma": "es5", | ||
"bracketSpacing": false, | ||
"arrowParens": "avoid" | ||
} |
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
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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
import { createPathFromArray } from "../paths" | ||
import {createPathFromArray} from "../paths" | ||
|
||
describe('paths helpers: createPathFromArray', () => { | ||
it('should create paths from array of directories', () => { | ||
const arrOne = ['authn'] | ||
const arrTwo = ['testnet', 'authn'] | ||
const arrThree = ['canarynet', 'authn'] | ||
describe("paths helpers: createPathFromArray", () => { | ||
it("should create paths from array of directories", () => { | ||
const arrOne = ["authn"] | ||
const arrTwo = ["testnet", "authn"] | ||
const arrThree = ["canarynet", "authn"] | ||
|
||
const expectedResponseOne = '/authn' | ||
const expectedResponseTwo = '/testnet/authn' | ||
const expectedResponseThree = '/canarynet/authn' | ||
const expectedResponseOne = "/authn" | ||
const expectedResponseTwo = "/testnet/authn" | ||
const expectedResponseThree = "/canarynet/authn" | ||
|
||
expect(createPathFromArray(arrOne)).toEqual(expectedResponseOne) | ||
expect(createPathFromArray(arrTwo)).toEqual(expectedResponseTwo) | ||
expect(createPathFromArray(arrThree)).toEqual(expectedResponseThree) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,63 +1,65 @@ | ||
import { combineServices, serviceListOfType } from "../services" | ||
|
||
describe('services helpers: combineServices', () => { | ||
it('should combine services with right ordering and filter unique', () => { | ||
import {combineServices, serviceListOfType} from "../services" | ||
|
||
describe("services helpers: combineServices", () => { | ||
it("should combine services with right ordering and filter unique", () => { | ||
const serviceA = { | ||
"id": 1, | ||
"endpoint": "https://flow-wallet.blocto.app/authn", | ||
"provider": { | ||
"name": "Blocto" | ||
} | ||
id: 1, | ||
endpoint: "https://flow-wallet.blocto.app/authn", | ||
provider: { | ||
name: "Blocto", | ||
}, | ||
} | ||
|
||
const serviceB = { | ||
"id": 2, | ||
"endpoint": "https://fcl-ledger.onflow.org/mainnet/authn", | ||
"provider": { | ||
"name": "Ledger" | ||
} | ||
id: 2, | ||
endpoint: "https://fcl-ledger.onflow.org/mainnet/authn", | ||
provider: { | ||
name: "Ledger", | ||
}, | ||
} | ||
|
||
const serviceC = { | ||
"id": 3, | ||
id: 3, | ||
endpoint: "liquality", | ||
provider: { | ||
name: "Liquality Wallet Extension", | ||
} | ||
}, | ||
} | ||
|
||
const serviceListOne = [serviceA, serviceB] | ||
const serviceListTwo = [serviceC, serviceC] | ||
const expectedListOne = [serviceA, serviceB, serviceC] | ||
const expectedListTwo = [serviceC, serviceA, serviceB] | ||
|
||
expect(combineServices(serviceListOne, serviceListTwo)).toEqual(expectedListOne) | ||
expect(combineServices(serviceListOne, serviceListTwo, true)).toEqual(expectedListTwo) | ||
expect(combineServices(serviceListOne, serviceListTwo)).toEqual( | ||
expectedListOne | ||
) | ||
expect(combineServices(serviceListOne, serviceListTwo, true)).toEqual( | ||
expectedListTwo | ||
) | ||
}) | ||
}) | ||
|
||
describe('services helpers: serviceListOfType', () => { | ||
it('should combine services with right ordering and filter unique', () => { | ||
|
||
describe("services helpers: serviceListOfType", () => { | ||
it("should combine services with right ordering and filter unique", () => { | ||
const serviceA = { | ||
"id": 1, | ||
"type": "authn" | ||
id: 1, | ||
type: "authn", | ||
} | ||
|
||
const serviceB = { | ||
"id": 2, | ||
"type": "authz" | ||
id: 2, | ||
type: "authz", | ||
} | ||
|
||
const serviceC = { | ||
"id": 2, | ||
"type": "pre-authz" | ||
id: 2, | ||
type: "pre-authz", | ||
} | ||
|
||
const serviceList = [serviceA, serviceB, serviceC] | ||
|
||
expect(serviceListOfType(serviceList, "authn").length).toEqual(1) | ||
expect(serviceListOfType(serviceList, "authn")[0]).toEqual(serviceA) | ||
}) | ||
}) | ||
}) |
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 |
---|---|---|
@@ -1,9 +1,9 @@ | ||
export const PATHS = { | ||
MAIN: '/authn', | ||
TESTNET: '/testnet/authn', | ||
CANARYNET: '/canarynet/authn' | ||
MAIN: "/authn", | ||
TESTNET: "/testnet/authn", | ||
CANARYNET: "/canarynet/authn", | ||
} | ||
|
||
export const SERVICE_TYPES = { | ||
AUTHN: "authn" | ||
} | ||
AUTHN: "authn", | ||
} |
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 |
---|---|---|
@@ -1 +1 @@ | ||
export const createPathFromArray = (arr = []) => `/${arr.join('/')}` | ||
export const createPathFromArray = (arr = []) => `/${arr.join("/")}` |
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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
reactStrictMode: true, | ||
eslint: { | ||
ignoreDuringBuilds: true | ||
} | ||
ignoreDuringBuilds: true, | ||
}, | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,18 +1,18 @@ | ||
import { useRouter } from 'next/router' | ||
import { Discovery } from '../components/Discovery' | ||
import { PATHS } from '../helpers/constants' | ||
import { createPathFromArray } from '../helpers/paths' | ||
import {useRouter} from "next/router" | ||
import {Discovery} from "../components/Discovery" | ||
import {PATHS} from "../helpers/constants" | ||
import {createPathFromArray} from "../helpers/paths" | ||
|
||
const Router = ({ handleCancel }) => { | ||
const Router = ({handleCancel}) => { | ||
const router = useRouter() | ||
const { path } = router.query // ['authn'] ['testnet', 'authn'] ['canarynet', 'authn'] | ||
const {path} = router.query // ['authn'] ['testnet', 'authn'] ['canarynet', 'authn'] | ||
const pathStr = createPathFromArray(path) | ||
const isValidRoute = Object.values(PATHS).some(p => p === pathStr) | ||
const network = path && path.length === 2 ? path[0] : 'mainnet' | ||
const network = path && path.length === 2 ? path[0] : "mainnet" | ||
|
||
if (!isValidRoute) return <div>Page Not Found</div> | ||
|
||
return <Discovery network={network} handleCancel={handleCancel} /> | ||
} | ||
|
||
export default Router | ||
export default Router |
Oops, something went wrong.