Skip to content

Commit ca4c365

Browse files
Aaron BarnardAaron Barnard
authored andcommitted
Add rpcUrl validation
1 parent 961fec3 commit ca4c365

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/modules/select/wallets/ledger.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ async function ledgerProvider(options: {
9898
}
9999
})
100100

101-
const rpcSubProvider = new RpcSource({ rpcUrl })
101+
const rpcSubProvider = new RpcSource({
102+
rpcUrl: rpcUrl.includes('http') ? rpcUrl : `https://${rpcUrl}`
103+
})
102104
const provider = new Web3ProviderEngine()
103105

104106
provider.on('error', (err: any) => {})
@@ -164,13 +166,15 @@ async function ledgerProvider(options: {
164166
}
165167

166168
async function getAccounts(numberToGet: number = 1, getMore?: boolean) {
169+
console.log('get accounts called:', { numberToGet, getMore: getMore })
167170
if (!enabled) {
168171
return [null]
169172
}
170173

171174
const addressesAlreadyFetched = addressToPath.size
172175

173176
if (addressesAlreadyFetched > 0 && !getMore) {
177+
console.log('already have 1 address')
174178
return addresses()
175179
}
176180

@@ -190,11 +194,14 @@ async function ledgerProvider(options: {
190194
paths.push(`${basePath}/0'/0`)
191195
}
192196

197+
console.log('creating transport')
193198
const transport = await TransportU2F.create()
194199
const eth = new Eth(transport)
200+
console.log('transport created')
195201

196202
for (const path of paths) {
197203
try {
204+
console.log('getting address for path:', path)
198205
const { address } = await eth.getAddress(path)
199206
addressToPath.set(address.toLowerCase(), path)
200207
} catch (err) {

src/modules/select/wallets/trezor.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,9 @@ async function trezorProvider(options: {
122122
}
123123
})
124124

125-
const rpcSubProvider = new RpcSource({ rpcUrl })
125+
const rpcSubProvider = new RpcSource({
126+
rpcUrl: rpcUrl.includes('http') ? rpcUrl : `https://${rpcUrl}`
127+
})
126128
const provider = new Web3ProviderEngine()
127129

128130
provider.on('error', (err: any) => {})

0 commit comments

Comments
 (0)