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

@pepe-team/bridge-widget-embedder

v0.1.12

Published

### Widget config parameters

Downloads

85

Readme

Bridge Widget Embedder

Widget config parameters

| Key | Type | Note | | -------------------- | -------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------- | | host | HTMLElement | DOM element where widget should be placed | | iframeUrl | string | URL for origin iframe URL (https://bridge.pepe.team/iframe) | | token | string | Which token should be transferred. It should be token symbol, e.g. ETH | | token_bridge_id | string | Which token should be transferred. It should be token bridge id, e.g. ETH-Ethereum-PPT | | source_chain_id | number | Transfer source chain (where transfer from). It should be bridge chain id, e.g. 1, 2 for mainnet or 10001, 10002 for testnet | | target_chain_id | number | Transfer target chain (where transfer to). It should be bridge chain id, e.g. 1, 2 for mainnet or 10001, 10002 for testnet | | recipient | string | Address of transfer recipient | | amount | number | Amount to be prefilled in the form | | referrer | string | Address of referrer – this address will receive cashback extracted from protocol fee as reward for the transfer. If empty, referrer will be an empty string | | ext_signing_chains | string[] | For which chains (sending asset chain) widget should dispatch signTx events and use its results as proofs | | color_schema | JSON-encoded object (ColorSchema) | Color schema to be used in the widget. If not provided, default will be used |

Widget tabs:

| Name | | ---------- | | transfer | | history |

Color Schema

All color values are presented as #HEX

| key | default | | ------------------------- | --------- | | bg-primary | #00A575 | | bg-secondary | #FFFFFF | | bg-tertiary | #F7F7F7 | | border-primary | #00A575 | | border-secondary | #FFFFFF | | border-error | #E80000 | | border-disabled | #BFBFBF | | button-bg-primary | #00A575 | | button-bg-secondary | #FFFFFF | | button-bg-error | #FFFFFF | | button-bg-disabled | #FFFFFF | | button-text-primary | #FFFFFF | | button-text-secondary | #00A575 | | button-text-error | #E80000 | | button-text-disabled | #BFBFBF | | button-border-primary | #FFFFFF | | button-border-secondary | #00A575 | | button-border-error | #E80000 | | button-border-disabled | #BFBFBF | | text-primary | #333333 | | text-secondary | #717171 | | text-tertiary | #BFBFBF | | skeleton-primary | #F4F4F4 | | skeleton-secondary | #E9E9E9 | | skeleton-tertiary | #E4E4E4 | | skeleton-shimer | #FFFFFF | | skeleton-border | #EEEEEE | | tab-btn-primary | #00A575 | | tab-btn-secondary | #FFFFFF | | fee-low | #F5AC37 | | fee-normal | #00A575 | | fee-high | #E80000 | | fee-custom | #717171 |

Color schema example:

{
	"bg-primary": "#FFFFFF",
	"bg-secondary": "#AAAAAA"
}

Methods

run

Start the widget

| Arg | Type | Note | | -------- | ------------ | ------------------------------------------------------ | | config | WidgetArgs | Widget config paramenters |

widget.run({
	iframeUrl: 'https://bridge.pepe.team/iframe',
	host: document.body,
	token_bridge_id: 'ETH-Ethereum-PPT'
});

on

Listen for widget incomming messages (widget interaction)

| Arg | Type | Note | | ----------- | ------------------------------------------- | ------------------------ | | eventKind | IncomingMessageKind | Kind of incoming message | | callback | (msg: Message<IncomingMessageKind>): void | Message handler |

widget.on(IncomingMessageKind.TxBroadcasted, (tx_id) => {
	console.log('Tx broadcasted', tx_id);
});

sendMessage

Send message to the widget (widget interaction)

| Arg | Type | Note | | --------- | ------------------------------ | ---------------------------- | | message | Message<OutgoingMessageKind> | Message to be send to widget |

const msg = {
	mid: 1,
	kind: OutgoingMessageKind.TxRejection,
	payload: {
		reason: 'User rejection'
	}
};
widget.sendMessage(msg);

setAmount

Set form field amount to provided value

| Arg | Type | Note | | -------- | ----------------------------------- | ----------------------------- | | amount | BigNumber | number | string | New form field amount value |

widget.setAmount(1);

setColorSchema

| Arg | Type | Note | | -------- | ----------------- | ----------------------------- | | colors | Partial<Colors> | New form colors to be applied |

const colors = {
	'bg-primary': '#000000',
	'text-primary': '#FFFFFF'
};
widget.setColorSchema(colors);

Widget usage example

const widget = new BridgeWidget();

widget.on(IncomingMessageKind.GetAccount, (m) => {
	widget.sendMessage({
		mid: m.mid,
		kind: OutgoingMessageKind.Account,
		payload: {
			account: {
				chainId: 'T',
				address: 'ADDRESS',
				publicKey: 'PUBLIC-KEY'
			}
		}
	});
});

widget.run({
	iframeUrl: 'https://bridge.pepe.team/iframe',
	host: document.body,
	token_bridge_id: 'ETH-Ethereum-PPT',
	source_chain_id: 1,
	target_chain_id: 2,
	ext_signing_chains: [1],
	recipient: 'RECIPIENT',
	amount: 100,
	referrer: 'REFERRER',
	color_schema: {
		'bg-primary': '#000000',
		'text-primary': '#FFFFFF'
	}
});

// destroy widget when transfer is done
widget.destroy();

Widget incoming events

| Name | | -------------------- | | widgetLoaded | | getAccount | | getAccountTimeout | | signTx | | txBroadcasted | | txConfirmed | | txError | | signTxTimeout | | unexpectedMid | | unexpectedKind | | invalidPayload | | unexpectedMessage | | invalidPrefillData |