npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ixo/jambo-wallet-sdk

v0.1.1

Published

An SDK to easily access the Opera mobile wallet for JAMBO dapps

Downloads

16

Readme

JAMBO WALLET SDK 💼

GitHub contributors GitHub repo size Twitter Follow Medium

NodeJSTypeScript

This repo and product is intentionally managed as Open Source and we aim to use this guide to light our way https://opensource.guide/. Let us know how we are doing!

🔨 Install

npm install @ixo/jambo-wallet-sdk

yarn add  @ixo/jambo-wallet-sdk

💻 Usage

This SDK interacts with the Impacts X in-app browser wallet and the Opera mobile wallet and exposes new functions that'll make interaction with the wallets easier, and these exposed functions mimic the same structure as the Keplr browser extension wallet.

To use the SDK, you can call the getImpactsX or getOpera functions, which returns an object of methods similar to the Keplr wallet if those wallets are available. Otherwise, it returns undefined.

Opera

import { getOpera } from '@ixo/jambo-wallet-sdk';

const operaWallet = await getOpera();

if (operaWallet) {
	// interact with the opera mobile wallet using the SDK
}

The operaWallet object returned by getOpera() includes the following functions:

enable

async operaWallet.enable(chainNameOrId: string, chainNetwork: ChainNetwork = 'mainnet'): Promise<void>

Enables a chain with the given chain ID or name-and-network type. If the chain is not yet enabled, it retrieves the chain info via the @ixo/cosmos-chain-resolver from the Cosmos or Keplr chain registries and stores it locally for further usage.

experimentalSuggestChain

async operaWallet.experimentalSuggestChain(chainInfo: KeplrChainInfo): Promise<void>

Suggests a new or custom chain by providing a chain info object. This is very useful if the chain info cannot be found by the @ixo/cosmos-chain-resolver.

getKey

async operaWallet.getKey(chainId: string, includeDid: boolean = false): Promise<WalletKey | undefined>

Retrieves the account 'key' associated with the provided chain ID. The returned 'key' includes the following fields:

  • name: string (an empty string)
  • algo: string (secp256k1)
  • pubKey: uint8Array
  • address: uint8Array
  • bech32Address: string
  • isNanoLedger: boolean (false)
  • isKeystone: boolean (false)

If the includeDid flag is set to true, getKey also includes the did (Decentralized Identifier) associated with the account key.

Additionally, getKey stores the user's data in session storage to be used by the offline signer, so it needs to be called at least once for every session.

To provide a better user experience, we advise against calling getKey too frequently. This is because getKey requires the user to authenticate via fingerprint scan, facial recognition, or password (depending on the authentication method enabled on their device/opera mobile browser), which may be cumbersome for the user.

getOfflineSigner

async operaWallet.getOfflineSigner(chainId: string): Promise<OfflineDirectSigner | null>

Returns an offline signer for the given chain ID.

signDirect

async operaWallet.signDirect(signerAddress: string, signDoc: SignDoc): Promise<DirectSignResponse>

Signs a transaction with the specified signer address.

raw (for advanced developers)

The __raw__ property exposes the original interchain object provided by the OperaWallet on the window object. This property is intended for advanced developers who require direct access to the underlying interchain object for more complex use cases.

Please note that the OperaWallet's interchain object, including the __raw__ property, is not officially documented (except for this). Using it directly may lead to unexpected behavior or errors, and should be done only by developers who have a thorough understanding of how it works and why it is necessary for their use case. If you are unsure whether you need to use __raw__, we recommend using the aforementioned documented methods and properties instead.

Impacts X

import { getImpactsX } from '@ixo/jambo-wallet-sdk';

const impactsXWallet = await getImpactsX();

if (impactsXWallet) {
	// interact with the Impacts X in-app mobile wallet using the SDK
}

The impactsXWallet object returned by getImpactsX() includes the following functions:

enable

async impactsXWallet.enable(chainNameOrId: string, chainNetwork: ChainNetwork = 'mainnet'): Promise<void>

The enable method allows you to activate a specific blockchain chain using either its ID or name-and-network configuration. This functionality currently supports the ixo blockchain only, limited to the chain network active on the mobile app. When utilizing this method, your website's authenticity will also be verified against the ImpactsX whitelist.

It is crucial to call this method before invoking any other impactsX methods to ensure they function correctly. The enabling process only needs to occur once per domain until any significant changes to the domain take place. If your site navigates away from the enabled domain, permissions will reset, requiring the enabling process to be repeated.

Please be aware that the ImpactsX whitelist is administered by Ixo and requests for access should be directed to Ixo. This whitelist operates on a subdomain level, meaning that whitelisting a specific domain (e.g., jambo.earth) will not cover subdomains (e.g., `my.jambo.earth``). For subdomains to function seamlessly, they must be individually whitelisted (e.g., my.jambo.earth needs its own whitelisting).

It's important to stay updated with any further developments in the impactsX ecosystem as these details may evolve over time.

experimentalSuggestChain

async impactsXWallet.experimentalSuggestChain(chainInfo: KeplrChainInfo): Promise<void>

Suggests a new or custom chain by providing a chain info object. This is feature is not supported yet and will return error until further development.

getKey

async impactsXWallet.getKey(chainId: string, includeDid: boolean = false): Promise<WalletKey | undefined>

Retrieves the account 'key' associated with the provided chain ID (supports only the active chain and chainNetwork in the app until further development). The returned 'key' includes the following fields:

  • name: string (an empty string)
  • algo: string (secp256k1)
  • pubKey: uint8Array
  • address: uint8Array
  • bech32Address: string
  • isNanoLedger: boolean (false)
  • isKeystone: boolean (false)

If the includeDid flag is set to true, getKey also includes the did (Decentralized Identifier) associated with the account key.

getOfflineSigner

impactsXWallet.getOfflineSigner(chainId: string): OfflineDirectSigner

Returns an offline signer for the given chain ID (supports only the active chain and chainNetwork in the app until further development).

signDirect

async impactsXWallet.signDirect(signerAddress: string, signDoc: SignDoc): Promise<DirectSignResponse>

Signs a transaction with the specified signer address via biometric authentication.

📱 Examples

Opera Example

const opera = getOpera()

// initialize opera with custom chain info
const initializeOpera = async (chainInfo: ChainInfo): Promise<Key | undefined> => {
	try {
		if (!opera) throw new Error('Opera not available');
		await opera.experimentalSuggestChain(chainInfo);
		await opera.enable(chainInfo.chainId);
		const key = await opera.getKey(chainInfo.chainId);
		return key;
	} catch (error) {
		console.error('Error initializing Opera:: ' + error);
	}
};

// or
// initialize opera using a chain ID
const chainId = 'ixo-5';

const initializeOpera = async (): Promise<Key | undefined> => {
	try {
		if (!opera) throw new Error('Opera not available');
		await opera.enable(chainId);
		const key = await opera.getKey(chainId);
		return key;
	} catch (error) {
		console.error('Error initializing Opera:: ' + error);
	}
};

// sign transaction with offline signer
const key = initializeOpera();

const trx = [{
	typeUrl: '/cosmos.bank.v1beta1.MsgSend'
	value: {
		fromAddress: key.bech32Address,
		toAddress: 'ixo1wnw8t3gc...ezn7xge',
		amount: [{
			denom: 'uixo',
			amount: '1000000'
		}]
	}
}]

const offlineSigner = await opera.getOfflineSigner(chainId);

const signingClient = await createSigningClient(rpcEndpoint, offlineSigner);

// signingClient.signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: number | StdFee | "auto", memo?: string | undefined)
await signingClient.signAndBroadcast(key.bech32Address, trx, 'auto', undefined);

ImpactsX Example

const impactsX = getOpera()

// initialize impactsX using a chain ID
const chainId = 'ixo-5';

const initializeImpactsX = async (): Promise<Key | undefined> => {
	try {
		if (!impactsX) throw new Error('ImpactsX not available');
		await impactsX.enable(chainId);
		const key = await impactsX.getKey(chainId);
		return key;
	} catch (error) {
		console.error('Error initializing ImpactsX:: ' + error);
	}
};

// sign transaction with offline signer
const key = initializeImpactsX();

const trx = [{
	typeUrl: '/cosmos.bank.v1beta1.MsgSend'
	value: {
		fromAddress: key.bech32Address,
		toAddress: 'ixo1wnw8t3gc...ezn7xge',
		amount: [{
			denom: 'uixo',
			amount: '1000000'
		}]
	}
}]

const offlineSigner = await impactsX.getOfflineSigner(chainId);

const signingClient = await createSigningClient(rpcEndpoint, offlineSigner);

// signingClient.signAndBroadcast(signerAddress: string, messages: readonly EncodeObject[], fee: number | StdFee | "auto", memo?: string | undefined)
await signingClient.signAndBroadcast(key.bech32Address, trx, 'auto', undefined);

📃 License

This SDK is licensed under the Apache 2 License. See the LICENSE file for more information.