Skip to content

Commit

Permalink
cleanup: code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
dafuga committed Jul 24, 2024
1 parent 50af139 commit 140ef6b
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,20 @@ export class WalletPluginMetaMask extends AbstractWalletPlugin implements Wallet
}

async lookupAccounts(publicKey: PublicKey, chainId: Checksum256Type): Promise<AccountFound[]> {
try {
const response = await fetch(
`${ACCOUNT_LOOKUP_URL}/lookup/${publicKey.toLegacyString()}?includeTestnets=true`
)
const accountsByNetwork: AccountLookup[] = await response.json()
const response = await fetch(
`${ACCOUNT_LOOKUP_URL}/lookup/${publicKey.toLegacyString()}?includeTestnets=true`
)
const accountsByNetwork: AccountLookup[] = await response.json()

const networkAccount = accountsByNetwork.find(
(networkAccount: AccountLookup) => networkAccount.chainId === String(chainId)
)
const networkAccount = accountsByNetwork.find(
(networkAccount: AccountLookup) => networkAccount.chainId === String(chainId)
)

if (!networkAccount) {
return []
}

return networkAccount.accounts
} catch (error) {
console.error('Error looking up accounts', error)
throw error
if (!networkAccount) {
return []
}

return networkAccount.accounts
}

async getPermissionLevel(
Expand All @@ -91,7 +86,6 @@ export class WalletPluginMetaMask extends AbstractWalletPlugin implements Wallet
}

const activeKey = await this.retrievePublicKey(chain.id, 1)
console.log({activeKey: String(activeKey)})
const accounts = await this.lookupAccounts(activeKey, chain.id)

if (!context.ui) {
Expand All @@ -109,8 +103,6 @@ export class WalletPluginMetaMask extends AbstractWalletPlugin implements Wallet

const ownerKey = await this.retrievePublicKey(chain.id, 0)

console.log({ownerKey: String(ownerKey)})

qs.set('owner_key', String(ownerKey))
qs.set('active_key', String(activeKey))
const accountCreator = new AccountCreator({
Expand Down

0 comments on commit 140ef6b

Please sign in to comment.