Skip to content

Commit

Permalink
#7 Allow configuring contract addresses via environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mvandeberg committed May 6, 2024
1 parent 9101f02 commit 13cf23e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 21 deletions.
37 changes: 27 additions & 10 deletions app.config.ts
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'
}
}
12 changes: 1 addition & 11 deletions utils/providers.ts
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)
}

0 comments on commit 13cf23e

Please sign in to comment.