Skip to content

Commit 46c21c8

Browse files
authored
Cleanup (#16)
* Update build commands and clean node-env script * fix node-envv * clean up * update doc * fixes * rm tests files * rm * fix example * fix
1 parent f17bbf2 commit 46c21c8

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

tools/lib/index.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,18 @@ const codegenDir = join(import.meta.dirname!, '..', '..', 'codegen')
2020

2121
const rpcUrl = Deno.env.get('RPC_URL') ?? 'http://localhost:8545'
2222

23-
// default account is 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
24-
const privateKey = (Deno.env.get('PRIVATE_KEY') ??
25-
'0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133') as Hex
23+
/// load private key, default account is 0xf24FF3a9CF04c71Dbc94D0b566f7A27B94566cac
24+
function loadPrivateKey(): Hex {
25+
if (Deno.env.has('PRIVATE_KEY')) {
26+
const privateKey = Deno.env.get('PRIVATE_KEY')
27+
return privateKey!.startsWith('0x')
28+
? privateKey as Hex
29+
: ('0x' + privateKey) as Hex
30+
}
31+
return '0x5fb92d6e98884f76de468fa3f6278f8807c48bebc13595d45af5bdc4da702133'
32+
}
33+
34+
const privateKey = loadPrivateKey()
2635

2736
export const env = await createEnv({
2837
rpcUrl,

0 commit comments

Comments
 (0)