Skip to content

Commit ecda587

Browse files
authored
Merge pull request #41 from AmbireTech/develop
Release v0.7.0
2 parents da519aa + 177bcdd commit ecda587

29 files changed

Lines changed: 487 additions & 185 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"version": "0.6.0",
2+
"version": "0.7.0",
33
"name": "ambire-common",
44
"description": "Common ground for the Ambire apps",
55
"private": true,

src/constants/multiplierBadges.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
export type MultiplierBadge = {
2+
id: string
3+
name: string
4+
icon: string
5+
color: string
6+
multiplier: number
7+
link: string
8+
}
9+
10+
export const multiplierBadges: MultiplierBadge[] = [
11+
{
12+
id: 'beta-tester',
13+
name: 'Beta Testers',
14+
icon: '🧪',
15+
color: '#6000FF',
16+
multiplier: 1.25,
17+
link: 'https://blog.ambire.com/announcing-the-wallet-token-a137aeda9747'
18+
},
19+
{
20+
id: 'lobsters',
21+
name: 'Lobsters',
22+
icon: '🦞',
23+
color: '#E82949',
24+
multiplier: 1.5,
25+
link: 'https://blog.ambire.com/ambire-wallet-to-partner-with-lobsterdao-10b57e6da0-53c59c88726b'
26+
},
27+
{
28+
id: 'cryptoTesters',
29+
name: 'CryptoTesters',
30+
icon: '🧑‍🔬',
31+
color: '#b200e1',
32+
multiplier: 1.25,
33+
link: 'https://blog.ambire.com/win-a-cryptotesters-nft-with-ambire-and-get-into-one-of-the-hottest-web3-communities-c9d7185760b1'
34+
}
35+
]
36+
37+
export const MULTIPLIERS_READ_MORE_URL =
38+
'https://blog.ambire.com/announcing-the-wallet-token-a137aeda9747'

src/hooks/accounts/index.ts

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/hooks/network/index.ts

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/hooks/useAccounts/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import useAccounts from './useAccounts'
2+
3+
export * from './types'
4+
export default useAccounts

src/hooks/useAccounts/types.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { UseStorageProps, UseStorageReturnType } from '../useStorage'
2+
import { UseToastsReturnType } from '../useToasts'
3+
4+
export type OnAddAccountOptions = {
5+
shouldRedirect?: boolean
6+
isNew?: boolean
7+
select?: boolean
8+
}
9+
10+
export type Account = {
11+
baseIdentityAddr: string
12+
bytecode: string
13+
email: string
14+
id: string
15+
identityFactoryAddr: string
16+
primaryKeyBackup: string
17+
salt: string
18+
signer: {
19+
one: string
20+
quickAccManager: string
21+
timelock: number
22+
two: string
23+
// Sometimes passed as an extra prop
24+
address?: string
25+
}
26+
}
27+
28+
export interface UseAccountsProps {
29+
onAdd: (opts: OnAddAccountOptions) => void
30+
onRemoveLastAccount: () => void
31+
useStorage: (p: Omit<UseStorageProps, 'storage'>) => UseStorageReturnType
32+
useToasts: () => UseToastsReturnType
33+
}
34+
35+
export interface UseAccountsReturnType {
36+
accounts: Account[]
37+
account: Account | {}
38+
selectedAcc: string
39+
onSelectAcc: (accountId: Account['id']) => void
40+
onAddAccount: (acc: Account, opts: OnAddAccountOptions) => void
41+
onRemoveAccount: (accountId: Account['id']) => void
42+
}
Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,6 @@
1-
import React, { useCallback, useMemo } from 'react'
1+
import { useCallback, useMemo } from 'react'
22

3-
import { UseToastsReturnType } from '../toasts'
4-
import { UseStorageProps, UseStorageReturnType } from '../useStorage'
5-
6-
export type onAddAccountOptions = {
7-
shouldRedirect?: boolean
8-
isNew?: boolean
9-
select?: boolean
10-
}
11-
12-
export type Account = {
13-
baseIdentityAddr: string
14-
bytecode: string
15-
email: string
16-
id: string
17-
identityFactoryAddr: string
18-
primaryKeyBackup: string
19-
salt: string
20-
signer: {
21-
one: string
22-
quickAccManager: string
23-
timelock: number
24-
two: string
25-
// Sometimes passed as an extra prop
26-
address?: string
27-
}
28-
}
29-
30-
export interface UseAccountsProps {
31-
onAdd: (opts: onAddAccountOptions) => void
32-
onRemoveLastAccount: () => void
33-
useStorage: (p: Omit<UseStorageProps, 'storage'>) => UseStorageReturnType
34-
useToasts: () => UseToastsReturnType
35-
}
36-
37-
export interface UseAccountsReturnType {
38-
accounts: Account[]
39-
account: Account | {}
40-
selectedAcc: string
41-
onSelectAcc: (accountId: Account['id']) => void
42-
onAddAccount: (acc: Account, opts: onAddAccountOptions) => void
43-
onRemoveAccount: (accountId: Account['id']) => void
44-
}
3+
import { Account, OnAddAccountOptions, UseAccountsProps, UseAccountsReturnType } from './types'
454

465
export default function useAccounts({
476
onAdd,
@@ -84,7 +43,7 @@ export default function useAccounts({
8443
)
8544

8645
const onAddAccount = useCallback(
87-
(acc: Account, _opts: onAddAccountOptions = {}) => {
46+
(acc: Account, _opts: OnAddAccountOptions = {}) => {
8847
const opts = { shouldRedirect: true, ..._opts }
8948

9049
if (!(acc.id && acc.signer)) throw new Error('account: internal err: missing ID or signer')

src/hooks/useAddressBook/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
import useAddressBook from './useAddressBook'
22

33
export default useAddressBook
4+
export * from './types'

src/hooks/useAddressBook/types.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { UseAccountsReturnType } from '../useAccounts'
2+
import { UseStorageProps, UseStorageReturnType } from '../useStorage'
3+
import { UseToastsReturnType } from '../useToasts'
4+
5+
export type Address = {
6+
name: string
7+
address: string
8+
isUD: boolean
9+
}
10+
11+
export interface UseAddressBookProps {
12+
useAccounts: () => UseAccountsReturnType
13+
useStorage: (p: Omit<UseStorageProps, 'storage'>) => UseStorageReturnType
14+
useToasts: () => UseToastsReturnType
15+
}
16+
17+
export interface UseAddressBookReturnType {
18+
addresses: Address[]
19+
addAddress: (name: Address['name'], address: Address['address'], isUD: Address['isUD']) => void
20+
removeAddress: (name: Address['name'], address: Address['address'], isUD: Address['isUD']) => void
21+
isKnownAddress: (address: Address['address']) => boolean
22+
}

src/hooks/useAddressBook/useAddressBook.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,9 @@ import { useCallback, useEffect, useMemo, useState } from 'react'
33

44
import { isKnownTokenOrContract, isValidAddress } from '../../services/address'
55
import { setKnownAddresses } from '../../services/humanReadableTransactions'
6-
import { UseAccountsReturnType } from '../accounts'
7-
import { UseToastsReturnType } from '../toasts'
8-
import { UseStorageProps, UseStorageReturnType } from '../useStorage'
9-
10-
interface Props {
11-
useAccounts: () => UseAccountsReturnType
12-
useStorage: (p: Omit<UseStorageProps, 'storage'>) => UseStorageReturnType
13-
useToasts: () => UseToastsReturnType
14-
}
6+
import { UseAddressBookProps, UseAddressBookReturnType } from './types'
157

16-
const accountType = ({ email, signerExtra }: any) => {
8+
const accountType = ({ email, signerExtra }: any): string => {
179
const walletType =
1810
// eslint-disable-next-line no-nested-ternary
1911
signerExtra && signerExtra.type === 'ledger'
@@ -24,7 +16,11 @@ const accountType = ({ email, signerExtra }: any) => {
2416
return email ? `Ambire account for ${email}` : `Ambire account (${walletType})`
2517
}
2618

27-
const useAddressBook = ({ useAccounts, useStorage, useToasts }: Props) => {
19+
const useAddressBook = ({
20+
useAccounts,
21+
useStorage,
22+
useToasts
23+
}: UseAddressBookProps): UseAddressBookReturnType => {
2824
const { accounts } = useAccounts()
2925
const { addToast } = useToasts()
3026
const [storageAddresses, setStorageAddresses] = useStorage({ key: 'addresses', defaultValue: [] })

0 commit comments

Comments
 (0)