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

Auth SDK changes for chain management #171

Merged
merged 3 commits into from
May 5, 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
70 changes: 0 additions & 70 deletions src/chainList.ts

This file was deleted.

29 changes: 2 additions & 27 deletions src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { NetworkConfig, RpcConfig, ChainConfigInput, Network } from './typings'
import { Chain, getConfigFromChain } from './chainList'
import { NetworkConfig, RpcConfig, Network } from './typings'

const DEV_NETWORK_CONFIG: NetworkConfig = {
authUrl: 'https://verify.dev.arcana.network',
Expand Down Expand Up @@ -39,30 +38,6 @@ const getNetworkConfig = (n: Network | NetworkConfig) => {
}
}

const getRpcConfig = (c: ChainConfigInput | undefined): RpcConfig => {
if (isRpcConfigInput(c)) {
const config = getConfigFromChain(c.chainId)
if (c.rpcUrl) {
config.rpcUrls = [c.rpcUrl]
}
return config
}

return getConfigFromChain(Chain.ETHEREUM_MAINNET)
}

function isRpcConfigInput(
c: ChainConfigInput | undefined
): c is ChainConfigInput {
if (typeof c === 'undefined') {
return false
}
if (!(typeof c == 'object' && c.chainId)) {
return false
}
return true
}

function isNetworkConfig(
network: string | NetworkConfig
): network is NetworkConfig {
Expand All @@ -81,4 +56,4 @@ function isNetworkConfig(
return true
}

export { getNetworkConfig, getRpcConfig }
export { getNetworkConfig }
8 changes: 1 addition & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ import {
isClientId,
getParamsFromClientId,
} from './utils'
import { getNetworkConfig, getRpcConfig } from './config'
import { getNetworkConfig } from './config'
import {
AppConfig,
AppMode,
ConstructorParams,
ChainConfigInput,
NetworkConfig,
Position,
RpcConfig,
Expand All @@ -31,7 +30,6 @@ import {
import { getAppInfo, getImageUrls } from './appInfo'
import { ErrorNotInitialized, ArcanaAuthError } from './errors'
import { LOG_LEVEL, setExceptionReporter, setLogLevel } from './logger'
import { Chain } from './chainList'
import Popup from './popup'
import { ModalController } from './ui/modalController'

Expand Down Expand Up @@ -66,7 +64,6 @@ class AuthProvider {
this.networkConfig = getNetworkConfig(this.params.network)

preLoadIframe(this.networkConfig.walletUrl, this.appId)
this.rpcConfig = getRpcConfig(this.params.chainConfig)
this._provider = new ArcanaProvider(this.rpcConfig)

if (this.params.debug) {
Expand Down Expand Up @@ -391,13 +388,10 @@ class AuthProvider {
export {
AuthProvider,
ConstructorParams,
ChainConfigInput,
Chain as CHAIN,
EthereumProvider,
AppConfig,
Theme,
Position,
RpcConfig,
Logins,
UserInfo,
ThemeConfig,
Expand Down
8 changes: 0 additions & 8 deletions src/typings.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { Chain } from './chainList'

export type Theme = 'light' | 'dark'

export type Orientation = 'horizontal' | 'vertical'
Expand Down Expand Up @@ -141,11 +139,6 @@ export interface NetworkConfig {
walletUrl: string
}

export interface ChainConfigInput {
rpcUrl?: string
chainId: Chain
}

export interface RpcConfig {
rpcUrls: string[]
chainId: string
Expand Down Expand Up @@ -177,7 +170,6 @@ export interface ConstructorParams {
network: ('testnet' | 'dev' | 'mainnet') | NetworkConfig
debug: boolean
alwaysVisible: boolean
chainConfig?: ChainConfigInput
redirectUrl?: string
theme: Theme
position: Position
Expand Down
3 changes: 0 additions & 3 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -287,9 +287,6 @@ const getConstructorParams = (initParams?: Partial<ConstructorParams>) => {
if (initParams?.debug !== undefined) {
p.debug = initParams.debug
}
if (initParams?.chainConfig) {
p.chainConfig = initParams.chainConfig
}
if (initParams?.redirectUrl) {
p.redirectUrl = initParams.redirectUrl
}
Expand Down