12.11.0 • Published 7 months ago

@exodus/address-provider v12.11.0

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

@exodus/address-provider

This module derives addresses for assets from different wallet accounts. Addresses for software wallet accounts are encoded public keys that are derived from the seed using Keychain, whereas hardware wallet accounts use the public keys stored in the public-key-store.

flowchart LR
    A[AddressProvider] --> B[PublicKeyProvider]
    B -->|software| D[Keychain]
    B -->|hardware| E[PublicKeyStore]

Address derivation can be pretty expensive on certain platforms (*cough, mobile*). So this package also includes a simple walletAccount and bip32 path based cache.

Install

yarn add @exodus/address-provider

Usage

This feature is designed to be used together with @exodus/headless. See using the sdk.

Play with it

  1. Open the playground https://exodus-hydra.pages.dev/features/address-provider
  2. Try out some methods via the UI. These correspond 1:1 with the exodus.addressProvider API.
  3. Run await exodus.addressProvider.getReceiveAddress({ walletAccount: 'exodus_0', assetName: 'bitcoin' }) in the Dev Tools Console.

API Side

See using the sdk for more details on how features plug into the SDK and the API interface in the type declaration.

const address = await exodus.addressProvider.getAddress({
  purpose: 44,
  assetName: 'bitcoin',
  walletAccount: 'exodus_0',
  chainIndex: 0,
  addressIndex: 0,
})

const receiveAddress = await exodus.addressProvider.getReceiveAddress({
  assetName: 'bitcoin',
  walletAccount: 'exodus_0',
})

const unusedReceiveAddress = await exodus.addressProvider.getReceiveAddress({
  assetName: 'bitcoin',
  walletAccount: 'exodus_0',
  multiAddressMode: true,
})

If you're building a feature that requires the wallet's addresses, add a dependency on the addressProvider module, which provides almost the same API as the external exodus.addressProvider API (caveat: the module expects WalletAccount instances, while the API expects WalletAccount names like 'exodus_0').

UI Side

See using the sdk for more details on basic UI-side setup.

import exodus from '~/ui/exodus'

const MyComponent = () => {
  const { loading, value: receiveAddress } = useAsync(
    exodus.addressProvider.getReceiveAddress({ walletAccount: 'exodus_0', assetName: 'bitcoin' })
  )

  return loading ? <Text>Loading...</Text> : <Text>Your address: {receiveAddress}</Text>
}

Mocking Addresses

Occasionally you may want to simulate another wallet for which you don't have the seed or private keys. You can do this by mocking at the address level here or at the xpub/public key level in public-key-provider

Mock an address by providing all the parameters that would normally be used to derive it:

exodus.debug.addressProvider.mockAddress({
  walletAccount: 'exodus_0',
  assetName: 'ethereum',
  address: '<address>',
  purpose: 44,
  chainIndex: 0,
  addressIndex: 0,
})

Mock multiple addresses by only a subset of the parameters:

exodus.debug.addressProvider.mockAddress({
  walletAccount: 'exodus_0',
  assetName: 'bitcoin',
  purpose: 44,
  address: '<address>',
})

This would result in mocking all change/receive chain addresses with the same address.

To clear all mocked addresses, call exodus.debug.addressProvider.clear().

12.11.0

7 months ago

12.10.1

7 months ago

12.10.0

8 months ago

12.9.7

8 months ago

12.9.6

8 months ago

12.9.5

8 months ago

12.9.4

10 months ago

12.9.3

10 months ago

12.9.2

10 months ago

12.9.1

10 months ago

12.9.0

11 months ago

12.8.1

11 months ago

12.8.0

11 months ago

12.7.1

11 months ago

12.7.0

11 months ago

12.6.4

1 year ago

12.6.3

1 year ago

12.6.2

1 year ago

12.6.1

1 year ago

12.6.0

1 year ago

12.5.2

1 year ago

12.5.1

1 year ago

12.5.0

1 year ago

12.4.0

1 year ago

12.3.0

1 year ago

12.2.2

1 year ago

12.2.1

1 year ago

12.2.0

1 year ago

12.1.2

1 year ago

12.1.1

1 year ago

12.1.0

1 year ago

12.0.1

1 year ago

12.0.0

1 year ago

11.3.1

1 year ago

11.3.0

1 year ago

11.2.0

2 years ago

11.1.0

2 years ago

10.5.1

2 years ago

11.0.1

2 years ago

11.0.0

2 years ago

10.5.0

2 years ago

10.4.1

2 years ago

10.4.0

2 years ago

10.3.0

2 years ago

10.2.0

2 years ago

10.1.0

2 years ago

10.0.1

2 years ago

10.0.0

2 years ago

9.2.0

2 years ago

9.1.0

2 years ago

9.0.1

2 years ago

9.0.0

2 years ago

8.2.0

2 years ago

8.1.4

2 years ago

8.1.3

2 years ago

8.1.2

2 years ago

8.1.1

2 years ago

8.1.0

2 years ago

8.0.0

2 years ago

7.4.4

2 years ago

7.4.3

2 years ago

7.4.2

2 years ago

7.4.1

2 years ago

7.4.0

2 years ago

7.3.0

2 years ago

7.2.0

2 years ago

7.1.0

2 years ago

7.0.0

2 years ago

6.1.4

2 years ago

6.1.3

2 years ago

6.1.2

2 years ago

6.1.1

3 years ago

6.1.0

3 years ago

6.0.0

3 years ago

5.0.2

3 years ago

4.2.1-hotfix.0

3 years ago

4.2.0-hotfix.1

3 years ago

4.2.0-hotfix.0

3 years ago

5.0.1

3 years ago

5.0.0

3 years ago

4.2.0

3 years ago

4.1.1

3 years ago

4.1.0

3 years ago

4.0.0

3 years ago

4.0.0-alpha.3

3 years ago

4.0.0-alpha.2

3 years ago

4.0.0-alpha.1

3 years ago

4.0.0-alpha.0

3 years ago