-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#7 Allow configuring contract addresses via environment
- Loading branch information
1 parent
9101f02
commit 13cf23e
Showing
2 changed files
with
28 additions
and
21 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,39 @@ | ||
declare global { | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
JSONRPC_URL: string, | ||
KOIN_ADDRESS: string, | ||
VHP_ADDRESS: string, | ||
POB_ADDRESS: string, | ||
CLAIM_ADDRESS: string, | ||
GOVERNANCE_ADDRESS: string, | ||
NAMESERVICE_ADDRESS: string, | ||
RESOURCES_ADDRESS: string, | ||
KAP_ADDRESS: string, | ||
NICKNAMES_ADDRESS: string | ||
} | ||
} | ||
} | ||
|
||
export type Config = { | ||
jsonRPC: string | ||
systemContracts: Record<string, string> | ||
contracts: Record<string, string> | ||
} | ||
|
||
export const config: Config = { | ||
jsonRPC: 'http://localhost:8080/', | ||
jsonRPC: process.env.JSONRPC_URL || 'http://localhost:8080/', | ||
systemContracts: { | ||
koin: '15DJN4a8SgrbGhhGksSBASiSYjGnMU8dGL', | ||
vhp: '18tWNU7E4yuQzz7hMVpceb9ixmaWLVyQsr', | ||
pob: '159myq5YUhhoVWu3wsHKHiJYKPKGUrGiyv', | ||
claim: '18zw3ZokdfHtudzaWAUnU4tUvKzKiJeN76', | ||
governance: '19qj51eTbSFJYU7ZagudkpxPgNSzPMfdPX', | ||
nameservice: '19WxDJ9Kcvx4VqQFkpwVmwVEy1hMuwXtQE', | ||
resources: '1HGN9h47CzoFwU2bQZwe6BYoX4TM6pXc4b' | ||
koin: process.env.KOIN_ADDRESS || '15DJN4a8SgrbGhhGksSBASiSYjGnMU8dGL', | ||
vhp: process.env.VHP_ADDRESS || '18tWNU7E4yuQzz7hMVpceb9ixmaWLVyQsr', | ||
pob: process.env.POB_ADDRESS || '159myq5YUhhoVWu3wsHKHiJYKPKGUrGiyv', | ||
claim: process.env.CLAIM_ADDRESS || '18zw3ZokdfHtudzaWAUnU4tUvKzKiJeN76', | ||
governance: process.env.GOVERNANCE_ADDRESS || '19qj51eTbSFJYU7ZagudkpxPgNSzPMfdPX', | ||
nameservice: process.env.NAMESERVICE_ADDRESS || '19WxDJ9Kcvx4VqQFkpwVmwVEy1hMuwXtQE', | ||
resources: process.env.RESOURCES_ADDRESS || '1HGN9h47CzoFwU2bQZwe6BYoX4TM6pXc4b' | ||
}, | ||
contracts: { | ||
kap: '13tmzDmfqCsbYT26C4CmKxq86d33senqH3', | ||
nicknames:'1KD9Es7LBBjA1FY3ViCgQJ7e6WH1ipKbhz' | ||
kap: process.env.KAP_ADDRESS || '13tmzDmfqCsbYT26C4CmKxq86d33senqH3', | ||
nicknames: process.env.NICKNAMES_ADDRESS || '1KD9Es7LBBjA1FY3ViCgQJ7e6WH1ipKbhz' | ||
} | ||
} |
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,16 +1,6 @@ | ||
import { config } from '@/app.config' | ||
import { Provider } from 'koilib' | ||
|
||
declare global { | ||
namespace NodeJS { | ||
interface ProcessEnv { | ||
JSONRPC_URL: string; | ||
} | ||
} | ||
} | ||
|
||
export function getProvider() { | ||
const xJsonRpc = process.env.JSONRPC_URL || config.jsonRPC | ||
|
||
return new Provider(xJsonRpc) | ||
return new Provider(config.jsonRPC) | ||
} |