Skip to content

Commit

Permalink
Feature: create explicit mainnet path (#133)
Browse files Browse the repository at this point in the history
* Create explicit mainnet path

* Update readme

Co-authored-by: Chase Fleming <[email protected]>
  • Loading branch information
chasefleming and chasefleming authored Oct 27, 2022
1 parent 812bff5 commit 3c44a7e
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 18 deletions.
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ yarn dev

### Discovery Routes

| Environment | Example |
| ----------- | ------------------------------------- |
| Mainnet | `http://localhost:3002/authn` |
| Testnet | `http://localhost:3002/testnet/authn` |
| Local | `http://localhost:3002/local/authn` |
| Environment | Example |
| ----------- | ---------------------------------------------------------------------- |
| Mainnet | `http://localhost:3002/authn` or `http://localhost:3002/mainnet/authn` |
| Testnet | `http://localhost:3002/testnet/authn` |
| Local | `http://localhost:3002/local/authn` |

### Discovery API Endpoints

| Environment | Example |
| ----------- | ----------------------------------------- |
| Mainnet | `http://localhost:3002/api/authn` |
| Testnet | `http://localhost:3002/api/testnet/authn` |
| Local | `http://localhost:3002/api/local/authn` |
| Environment | Example |
| ----------- | ------------------------------------------------------------------------------ |
| Mainnet | `http://localhost:3002/api/authn` or `http://localhost:3002/api/mainnet/authn` |
| Testnet | `http://localhost:3002/api/testnet/authn` |
| Local | `http://localhost:3002/api/local/authn` |

> Note: Local will return Dev Wallet as a service for developing locally with the default port of 8701. If you'd like to override the default port add ?port=0000 with the port being whatever you'd like to override it to.
Expand Down
21 changes: 13 additions & 8 deletions helpers/__tests__/paths.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,35 @@ import { createPathFromArray, isValidPath, getNetworkFromPath } 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']
const arrTwo = ['mainnet', 'authn']
const arrThree = ['testnet', 'authn']
const arrFour = ['canarynet', 'authn']

const expectedResponseOne = '/authn'
const expectedResponseTwo = '/testnet/authn'
const expectedResponseThree = '/canarynet/authn'
const expectedResponseTwo = '/mainnet/authn'
const expectedResponseThree = '/testnet/authn'
const expectedResponseFour = '/canarynet/authn'

expect(createPathFromArray(arrOne)).toEqual(expectedResponseOne)
expect(createPathFromArray(arrTwo)).toEqual(expectedResponseTwo)
expect(createPathFromArray(arrThree)).toEqual(expectedResponseThree)
expect(createPathFromArray(arrFour)).toEqual(expectedResponseFour)
})
})

describe('paths helpers: isValidPath', () => {
it('should check a path is valid', () => {
const pathOne = ['authn']
const pathTwo = ['testnet', 'authn']
const pathThree = ['canarynet', 'authn']
const pathFour = ['foo', 'bar']
const pathTwo = ['mainnet', 'authn']
const pathThree = ['testnet', 'authn']
const pathFour = ['canarynet', 'authn']
const pathFive = ['foo', 'bar']

expect(isValidPath(pathOne)).toBe(true)
expect(isValidPath(pathTwo)).toBe(true)
expect(isValidPath(pathThree)).toBe(true)
expect(isValidPath(pathFour)).toBe(false)
expect(isValidPath(pathFour)).toBe(true)
expect(isValidPath(pathFive)).toBe(false)
expect(isValidPath(null)).toBe(false)
})
})
Expand Down
1 change: 1 addition & 0 deletions helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const SERVICE_METHODS = {

export const PATHS = {
MAINNET: '/authn',
MAINNET_EXPLICIT: '/mainnet/authn',
TESTNET: '/testnet/authn',
CANARYNET: '/canarynet/authn',
LOCAL: '/local/authn'
Expand Down

1 comment on commit 3c44a7e

@vercel
Copy link

@vercel vercel bot commented on 3c44a7e Oct 27, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.