Skip to content

Commit

Permalink
refactor: clean up, deprecate, reduce bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
bangjelkoski committed Dec 6, 2024
1 parent 44b644f commit ad2fe29
Show file tree
Hide file tree
Showing 305 changed files with 3,222 additions and 6,081 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default class BitGet extends BaseConcreteStrategy implements ConcreteWall
try {
return await ethereum.request({
method: 'eth_requestAccounts',
})
}) as string[]
} catch (e: unknown) {
throw new BitGetException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -93,7 +93,7 @@ export default class BitGet extends BaseConcreteStrategy implements ConcreteWall
return await ethereum.request({
method: 'eth_sendTransaction',
params: [transaction],
})
}) as string
} catch (e: unknown) {
throw new BitGetException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -149,7 +149,7 @@ export default class BitGet extends BaseConcreteStrategy implements ConcreteWall
return await ethereum.request({
method: 'eth_signTypedData_v4',
params: [address, eip712json],
})
}) as string
} catch (e: unknown) {
throw new BitGetException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -204,7 +204,7 @@ export default class BitGet extends BaseConcreteStrategy implements ConcreteWall
params: [toUtf8(data), signer],
})

return signature
return signature as string
} catch (e: unknown) {
throw new BitGetException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -218,7 +218,7 @@ export default class BitGet extends BaseConcreteStrategy implements ConcreteWall
const ethereum = await this.getEthereum()

try {
return ethereum.request({ method: 'eth_chainId' })
return ethereum.request({ method: 'eth_chainId' }) as Promise<string>
} catch (e: unknown) {
throw new BitGetException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -236,7 +236,7 @@ export default class BitGet extends BaseConcreteStrategy implements ConcreteWall
const receipt = await ethereum.request({
method: 'eth_getTransactionReceipt',
params: [txHash],
})
}) as string

if (!receipt) {
await sleep(interval)
Expand Down Expand Up @@ -275,7 +275,7 @@ export default class BitGet extends BaseConcreteStrategy implements ConcreteWall
}

async onAccountChange(
callback: (account: AccountAddress) => void,
callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
const ethereum = await this.getEthereum()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default class Keplr extends BaseConcreteStrategy implements ConcreteWalle
}

async onAccountChange(
callback: (account: AccountAddress) => void,
callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
const listener = async () => {
const [account] = await this.getAddresses()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ export default class Leap extends BaseConcreteStrategy implements ConcreteWallet
}

async onAccountChange(
callback: (account: AccountAddress) => void,
callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
const listener = async () => {
const [account] = await this.getAddresses()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ export default class LedgerBase
const ledger = await this.ledger.getInstance()
const { derivationPath } = await this.getWalletForAddress(options.address)
const ledgerService = await import(
'@ledgerhq/hw-app-eth/lib/services/ledger/index.js'
'@ledgerhq/hw-app-eth/lib-es/services/ledger/index.js'
)
const resolution = await ledgerService.default.resolveTransaction(
encodedMessageHex,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import TransportWebHID from '@ledgerhq/hw-transport-webhid'
import TransportWebUSB from '@ledgerhq/hw-transport-webusb'
import type EthereumApp from '@ledgerhq/hw-app-eth'
import type Transport from '@ledgerhq/hw-transport'
import EthereumApp from '@ledgerhq/hw-app-eth'
import Transport from '@ledgerhq/hw-transport'
import { LedgerException } from '@injectivelabs/exceptions'
import AccountManager from './AccountManager.js'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default class Metamask
try {
return await ethereum.request({
method: 'eth_requestAccounts',
})
}) as string[]
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -96,7 +96,7 @@ export default class Metamask
return await ethereum.request({
method: 'eth_sendTransaction',
params: [transaction],
})
}) as string
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -152,7 +152,7 @@ export default class Metamask
return await ethereum.request({
method: 'eth_signTypedData_v4',
params: [address, eip712json],
})
}) as string
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -207,7 +207,7 @@ export default class Metamask
params: [toUtf8(data), signer],
})

return signature
return signature as string
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -221,7 +221,7 @@ export default class Metamask
const ethereum = await this.getEthereum()

try {
return ethereum.request({ method: 'eth_chainId' })
return ethereum.request({ method: 'eth_chainId' }) as Promise<string>
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -239,7 +239,7 @@ export default class Metamask
const receipt = await ethereum.request({
method: 'eth_getTransactionReceipt',
params: [txHash],
})
}) as string

if (!receipt) {
await sleep(interval)
Expand Down Expand Up @@ -278,7 +278,7 @@ export default class Metamask
}

async onAccountChange(
callback: (account: AccountAddress) => void,
callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
const ethereum = await this.getEthereum()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ export default class Ninji extends BaseConcreteStrategy implements ConcreteWalle
}

async onAccountChange(
callback: (account: AccountAddress) => void,
callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
const listener = async () => {
const [account] = await this.getAddresses()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
} from '../../../../types/enums.js'
import { getOkxWalletProvider } from './utils.js'

export default class OkxWallet extends BaseConcreteStrategy implements ConcreteWalletStrategy {
export default class OkxWallet
extends BaseConcreteStrategy
implements ConcreteWalletStrategy
{
constructor(args: EthereumWalletStrategyArgs) {
super(args)
}
Expand Down Expand Up @@ -62,9 +65,9 @@ export default class OkxWallet extends BaseConcreteStrategy implements ConcreteW
const ethereum = await this.getEthereum()

try {
return await ethereum.request({
return (await ethereum.request({
method: 'eth_requestAccounts',
})
})) as string[]
} catch (e: unknown) {
throw new OkxWalletException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -90,10 +93,10 @@ export default class OkxWallet extends BaseConcreteStrategy implements ConcreteW
const ethereum = await this.getEthereum()

try {
return await ethereum.request({
return (await ethereum.request({
method: 'eth_sendTransaction',
params: [transaction],
})
})) as string
} catch (e: unknown) {
throw new OkxWalletException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -146,10 +149,10 @@ export default class OkxWallet extends BaseConcreteStrategy implements ConcreteW
const ethereum = await this.getEthereum()

try {
return await ethereum.request({
return (await ethereum.request({
method: 'eth_signTypedData_v4',
params: [address, eip712json],
})
})) as string
} catch (e: unknown) {
throw new OkxWalletException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -204,7 +207,7 @@ export default class OkxWallet extends BaseConcreteStrategy implements ConcreteW
params: [toUtf8(data), signer],
})

return signature
return signature as string
} catch (e: unknown) {
throw new OkxWalletException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -218,7 +221,7 @@ export default class OkxWallet extends BaseConcreteStrategy implements ConcreteW
const ethereum = await this.getEthereum()

try {
return ethereum.request({ method: 'eth_chainId' })
return ethereum.request({ method: 'eth_chainId' }) as Promise<string>
} catch (e: unknown) {
throw new OkxWalletException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -233,10 +236,10 @@ export default class OkxWallet extends BaseConcreteStrategy implements ConcreteW

const interval = 1000
const transactionReceiptRetry = async () => {
const receipt = await ethereum.request({
const receipt = (await ethereum.request({
method: 'eth_getTransactionReceipt',
params: [txHash],
})
})) as string

if (!receipt) {
await sleep(interval)
Expand Down Expand Up @@ -275,7 +278,7 @@ export default class OkxWallet extends BaseConcreteStrategy implements ConcreteW
}

async onAccountChange(
callback: (account: AccountAddress) => void,
callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
const ethereum = await this.getEthereum()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ import {
} from '../../../../types/enums.js'
import { getPhantomProvider } from './utils.js'

export default class Phantom extends BaseConcreteStrategy implements ConcreteWalletStrategy {
export default class Phantom
extends BaseConcreteStrategy
implements ConcreteWalletStrategy
{
constructor(args: EthereumWalletStrategyArgs) {
super(args)
}
Expand Down Expand Up @@ -64,9 +67,9 @@ export default class Phantom extends BaseConcreteStrategy implements ConcreteWal
const ethereum = await this.getEthereum()

try {
return await ethereum.request({
return (await ethereum.request({
method: 'eth_requestAccounts',
})
})) as string[]
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -92,10 +95,10 @@ export default class Phantom extends BaseConcreteStrategy implements ConcreteWal
const ethereum = await this.getEthereum()

try {
return await ethereum.request({
return (await ethereum.request({
method: 'eth_sendTransaction',
params: [transaction],
})
})) as string
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -148,10 +151,10 @@ export default class Phantom extends BaseConcreteStrategy implements ConcreteWal
const ethereum = await this.getEthereum()

try {
return await ethereum.request({
return (await ethereum.request({
method: 'eth_signTypedData_v4',
params: [address, eip712json],
})
})) as string
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand Down Expand Up @@ -206,7 +209,7 @@ export default class Phantom extends BaseConcreteStrategy implements ConcreteWal
params: [toUtf8(data), signer],
})

return signature
return signature as string
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -220,7 +223,7 @@ export default class Phantom extends BaseConcreteStrategy implements ConcreteWal
const ethereum = await this.getEthereum()

try {
return ethereum.request({ method: 'eth_chainId' })
return ethereum.request({ method: 'eth_chainId' }) as Promise<string>
} catch (e: unknown) {
throw new MetamaskException(new Error((e as any).message), {
code: UnspecifiedErrorCode,
Expand All @@ -235,10 +238,10 @@ export default class Phantom extends BaseConcreteStrategy implements ConcreteWal

const interval = 1000
const transactionReceiptRetry = async () => {
const receipt = await ethereum.request({
const receipt = (await ethereum.request({
method: 'eth_getTransactionReceipt',
params: [txHash],
})
})) as string

if (!receipt) {
await sleep(interval)
Expand Down Expand Up @@ -277,7 +280,7 @@ export default class Phantom extends BaseConcreteStrategy implements ConcreteWal
}

async onAccountChange(
callback: (account: AccountAddress) => void,
callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
const ethereum = await this.getEthereum()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ export default class PrivateKey
}

async onAccountChange(
_callback: (account: AccountAddress) => void,
_callback: (account: AccountAddress | string[]) => void,
): Promise<void> {
//
}
Expand Down
Loading

0 comments on commit ad2fe29

Please sign in to comment.