Skip to content

Commit

Permalink
Fixes and new packages
Browse files Browse the repository at this point in the history
  • Loading branch information
lnbc1QWFyb24 committed Feb 10, 2022
1 parent 4095953 commit 94a2923
Show file tree
Hide file tree
Showing 35 changed files with 76 additions and 43 deletions.
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/common",
"version": "2.0.0-alpha.12",
"version": "2.0.0-alpha.13",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down
6 changes: 4 additions & 2 deletions packages/common/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ import type {
InjectedProvider,
Chain,
TokenSymbol,
CustomNetwork
CustomNetwork,
TransactionObject
} from './types'

export {
Expand Down Expand Up @@ -138,5 +139,6 @@ export type {
InjectedProvider,
Chain,
TokenSymbol,
CustomNetwork
CustomNetwork,
TransactionObject
}
1 change: 1 addition & 0 deletions packages/common/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,7 @@ export interface TransactionObject {
gasLimit?: string
gasPrice?: string
to: string
chainId: number
value?: string
maxFeePerGas?: string
maxPriorityFeePerGas?: string
Expand Down
1 change: 1 addition & 0 deletions packages/core/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,3 +45,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/core",
"version": "2.0.0-alpha.17",
"version": "2.0.0-alpha.18",
"scripts": {
"build": "rollup -c",
"dev": "rollup -c -w",
Expand Down
1 change: 1 addition & 0 deletions packages/fortmatic/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/fortmatic/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/fortmatic",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"description": "Fortmatic module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/gnosis/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/gnosis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/gnosis",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"description": "Gnosis module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/injected/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/injected/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/injected-wallets",
"version": "2.0.0-alpha.7",
"version": "2.0.0-alpha.8",
"description": "Injected wallets module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
3 changes: 2 additions & 1 deletion packages/injected/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"extends": "../../tsconfig.json",
"include": ["src/**/*"],

"compilerOptions": {
"outDir": "dist",
"rootDir": "src",
"declarationDir": "dist",
"allowSyntheticDefaultImports": true,
"paths": {
"*": ["./src/*", "./node_modules/*"]
},
Expand Down
1 change: 1 addition & 0 deletions packages/keepkey/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/keepkey/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/keepkey",
"version": "2.0.0-alpha.8",
"version": "2.0.0-alpha.9",
"description": "KeepKey module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/keystone/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/keystone/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/keystone",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"description": "Keystone module for Onboard.js",
"module": "dist/index.js",
"typings": "dist/index.d.ts",
Expand Down
6 changes: 4 additions & 2 deletions packages/keystone/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import {
createEIP1193Provider,
CustomNetwork,
ProviderRpcErrorCode,
GetInterfaceHelpers,
ProviderRpcError,
ScanAccountsOptions,
WalletInit
Expand Down Expand Up @@ -78,7 +77,7 @@ function keystone({
return {
label: 'Keystone',
getIcon,
getInterface: async ({ EventEmitter, chains }: GetInterfaceHelpers) => {
getInterface: async ({ EventEmitter, chains }) => {
const { JsonRpcProvider } = await import('@ethersproject/providers')
const { default: Common, Hardfork } = await import('@ethereumjs/common')

Expand Down Expand Up @@ -170,6 +169,9 @@ function keystone({
// Set the `from` field to the currently selected account
transactionObject = { ...transactionObject, from }

// @ts-ignore -- Due to weird commonjs exports
const CommonConstructor = Common.default || Common

const common = new Common({
chain: customNetwork || Number.parseInt(currentChain.id) || 1,
// Berlin is the minimum hardfork that will allow for EIP1559
Expand Down
1 change: 1 addition & 0 deletions packages/ledger/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/ledger/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/ledger",
"version": "2.0.0-alpha.12",
"version": "2.0.0-alpha.13",
"description": "Ledger module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
18 changes: 8 additions & 10 deletions packages/ledger/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ import type {
GetInterfaceHelpers
} from '@bn-onboard/common'

// these cannot be dynamically imported
import { TypedDataUtils } from '@metamask/eth-sig-util'
import { Buffer } from 'buffer'

import type Transport from '@ledgerhq/hw-transport'
import type { providers } from 'ethers'

Expand Down Expand Up @@ -64,7 +68,6 @@ const getAccount = async (
): Promise<Account> => {
//@ts-ignore
const { default: HDKey } = await import('hdkey')
const { Buffer } = await import('buffer')
const { publicToAddress, toChecksumAddress } = await import('ethereumjs-util')

const hdk = new HDKey()
Expand Down Expand Up @@ -132,11 +135,7 @@ function ledger({
const { compress } = (await import('eth-crypto')).publicKey
const ethUtil = await import('ethereumjs-util')

const {
TypedDataUtils: { hashStruct },
SignTypedDataVersion
} = await import('@metamask/eth-sig-util')

const { SignTypedDataVersion } = await import('@metamask/eth-sig-util')
const { JsonRpcProvider } = await import('@ethersproject/providers')

const { accountSelect, createEIP1193Provider, ProviderRpcError } =
Expand Down Expand Up @@ -275,8 +274,7 @@ function ledger({
transactionObject = { ...transactionObject, from }

// @ts-ignore
const CommonConstructor = Common.default

const CommonConstructor = Common.default || Common
const common = new CommonConstructor({
chain:
customNetwork || currentChain.hasOwnProperty('id')
Expand Down Expand Up @@ -358,14 +356,14 @@ function ledger({
accounts.find(account => account.address === address) ||
accounts[0]

const domainHash = hashStruct(
const domainHash = TypedDataUtils.hashStruct(
'EIP712Domain',
typedData.domain,
typedData.types,
SignTypedDataVersion.V3
).toString('hex')

const messageHash = hashStruct(
const messageHash = TypedDataUtils.hashStruct(
typedData.primaryType,
typedData.message,
typedData.types,
Expand Down
1 change: 1 addition & 0 deletions packages/mew/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/mew/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/mew",
"version": "2.0.0-alpha.6",
"version": "2.0.0-alpha.7",
"description": "MEW module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/portis/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/portis/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/portis",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"description": "Portis module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/torus/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/torus/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/torus",
"version": "2.0.0-alpha.5",
"version": "2.0.0-alpha.6",
"description": "Torus module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
1 change: 1 addition & 0 deletions packages/trezor/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/trezor/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/trezor",
"version": "2.0.0-alpha.7",
"version": "2.0.0-alpha.8",
"description": "Trezor module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
24 changes: 15 additions & 9 deletions packages/trezor/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,17 @@ import {
ScanAccountsOptions,
TransactionObject,
WalletInit
} from '@bn-onboard/common/src/types'
import type { providers } from 'ethers'
import type { BIP32Interface } from 'bip32'
import { EthereumTransaction, EthereumTransactionEIP1559 } from 'trezor-connect'
} from '@bn-onboard/common'

// cannot be dynamically imported
import { Buffer } from 'buffer'

import type { JsonRpcProvider } from '@ethersproject/providers'

import type {
EthereumTransaction,
EthereumTransactionEIP1559
} from 'trezor-connect'

interface TrezorOptions {
email: string
Expand Down Expand Up @@ -42,11 +49,10 @@ const getAccount = async (
{ publicKey, chainCode, path }: AccountData,
asset: Asset,
index: number,
provider: providers.JsonRpcProvider
provider: JsonRpcProvider
): Promise<Account> => {
//@ts-ignore
const { default: HDKey } = await import('hdkey')
const { Buffer } = await import('buffer')
const { publicToAddress, toChecksumAddress } = await import('ethereumjs-util')

const hdk = new HDKey()
Expand All @@ -73,7 +79,7 @@ const getAccount = async (
const getAddresses = async (
account: AccountData,
asset: Asset,
provider: providers.JsonRpcProvider
provider: JsonRpcProvider
): Promise<Account[]> => {
const accounts = []
let index = 0
Expand Down Expand Up @@ -324,8 +330,8 @@ function trezor(options: TrezorOptions): WalletInit {
const transactionData =
createTrezorTransactionObject(transactionObject)

// @ts-ignore
const CommonConstructor = Common.default
// @ts-ignore -- Due to weird commonjs exports
const CommonConstructor = Common.default || Common

const common = new CommonConstructor({
chain: customNetwork || Number.parseInt(currentChain.id) || 1,
Expand Down
1 change: 1 addition & 0 deletions packages/walletconnect/circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,4 @@ workflows:
branches:
only:
- main
- feature/v2
2 changes: 1 addition & 1 deletion packages/walletconnect/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@bn-onboard/walletconnect",
"version": "2.0.0-alpha.7",
"version": "2.0.0-alpha.8",
"description": "WalletConnect module for Onboard.js",
"module": "dist/index.js",
"browser": "dist/index.js",
Expand Down
Loading

0 comments on commit 94a2923

Please sign in to comment.