0.4.0 • Published 11 months ago

@bloom-labs/url v0.4.0

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

@bloom-labs/url

@bloom-labs/url downloads CI

TypeScript library for building and parsing Bloom deep links.

Installation

# NPM
npm i @bloom-labs/url

# Yarn
yarn add @bloom-labs/url

Usage

Building

import { buildDeepLink, BloomDeepLinkContext, WalletOperation } from '@bloom-labs/url'

const deepLink = buildDeepLink({
    context: BloomDeepLinkContext.Wallet,
    operation: WalletOperation.ImportToken,
    parameters: {
        chainId: 1071,
        tokenAddress: '0x7EA2be2df7BA6E54B1A9C70676f668455E329d29',
    }
})

console.log(deepLink)
// bloom://wallet/importToken?chainId=1071&tokenAddress=0x7EA2be2df7BA6E54B1A9C70676f668455E329d29

Parsing

import { parseDeepLink } from '@bloom-labs/url'

const deepLink = parseDeepLink('bloom://wallet/importToken?chainId=1071&tokenAddress=0x7EA2be2df7BA6E54B1A9C70676f668455E329d29')

console.log(deepLink)
// {
//     protocol: BloomDeepLinkProtocol.Beta,
//     context: BloomDeepLinkContext.Wallet,
//     operation: WalletOperation.ImportToken,
//     parameters: {
//         chainId: 1071,
//         tokenAddress: '0x7EA2be2df7BA6E54B1A9C70676f668455E329d29',
//     },
// }

Configuring

It is possible to configure the library when using the build and parse functions to suit your particular needs. The following options are supported:

  • throwError: tells the library if it should throw an error when building or parsing a deep link
    • false by default, resulting in the build and parse functions returning undefined in the case of an error

The way to set these parameters is simple:

import { buildDeepLink, IBloomDeepLinkLibraryConfiguration } from '@bloom-labs/url'

const config: IBloomDeepLinkLibraryConfiguration = {
    throwError: true,
}
const deepLink = buildDeepLink({}, config) // throws an error

Contributing

Please feel free to make a contribution in the following ways:

0.4.0

11 months ago

0.3.9

11 months ago

0.3.8

11 months ago

0.3.5

11 months ago

0.3.1

11 months ago

0.3.0

11 months ago

0.2.1

11 months ago

0.1.8

11 months ago

0.1.5

11 months ago

0.1.4

11 months ago