open-index/open-npm huggingface dataset:
npm package: @farbcodegmbh/nuxt-mosaic
Description: Mosaic Nuxt Module for creating and evaluating rules.
Author: Raphael Störk
Latest version: 0.1.4

# Mosaic

[![npm version][npm-version-src]][npm-version-href]
[![npm downloads][npm-downloads-src]][npm-downloads-href]
[![Nuxt][nuxt-src]][nuxt-href]

The new and improved version of the RuleBuilder Plugin now as a Nuxt3 Module.

- [✨ &nbsp;Release Notes](/CHANGELOG.md)

## Table of Contents

- [Mosaic](#mosaic)
  - [Table of Contents](#table-of-contents)
  - [Features](#features)
  - [Quick Setup](#quick-setup)
  - [Contribution](#contribution)

## Features

- A new //farbcode owned Nuxt3 Module for the Mosaic Logic
- The possibility to define arbitrary rule options
- Evaluating any well defined mosaic with the new useMosaic composable


## Quick Setup

Install the module to your Nuxt application with one command:

```bash
npx nuxi module add @farbcodegmbh/nuxt-mosaic
```

That's it! You can now use Mosaic in your Nuxt app ✨


## Contribution

<details>
  <summary>//farbcode development</summary>

Use the module as a sub repo in the //farbcode Base Project under
client/modules. Use a local version of the module in the Base Project.

```typescript
// client/nuxt.config.ts
  modules: [
    // ...
    './modules/mosaic/src/module',
  ]
```
</details>

<details>
  <summary>Alternative Local development</summary>
  
  ```bash
  # Install dependencies
  npm install
  
  # Generate type stubs
  npm run dev:prepare
  
  # Develop with the playground
  npm run dev
  
  # Build the playground
  npm run dev:build
  
  # Run ESLint
  npm run lint
  
  # Run Vitest
  npm run test
  npm run test:watch
  
  # Release new version
  npm run release
  ```

</details>


<!-- Badges -->
[npm-version-src]: https://img.shields.io/npm/v/@farbcodegmbh/nuxt-mosaic/latest.svg?style=flat&colorA=020420&colorB=00DC82
[npm-version-href]: https://npmjs.com/package/@farbcodegmbh/nuxt-mosaic

[npm-downloads-src]: https://img.shields.io/npm/v/@farbcodegmbh/nuxt-mosaic.svg?style=flat&colorA=020420&colorB=00DC82
[npm-downloads-href]: https://npm.chart.dev/@farbcodegmbh/nuxt-mosaic

[nuxt-src]: https://img.shields.io/badge/Nuxt-002E3B?logo=nuxt&logoColor=#00DC82
[nuxt-href]: https://nuxt.com
npm package: @farbenmeer/lacy
Description: Lightweight utility for lazy evaluation of JavaScript promises. Chain property access and method calls without awaiting intermediate values.
Author: Michel Smola
Latest version: 1.0.0

# @farbenmeer/lacy

Lightweight utility for lazy evaluation of JavaScript promises. Chain property access and method calls without awaiting intermediate values.

**[Documentation](https://oss-docs.apps.farbenmeer.de/lacy/)** | **[GitHub](https://github.com/farbenmeer/tapi/tree/main/packages/1-lacy)** | **[npm](https://www.npmjs.com/package/@farbenmeer/lacy)** 

```ts
import { lacy } from "@farbenmeer/lacy";

// Instead of this:
const response = await fetch("/api/users");
const data = await response.json();
const name = data[0].name;

// Write this:
const name = await lacy(fetch("/api/users")).json()[0].name;
```

## Installation

```bash
npm install @farbenmeer/lacy
yarn add @farbenmeer/lacy
pnpm add @farbenmeer/lacy
bun add @farbenmeer/lacy
```

## License

MIT
npm package: @farbenmeer/next-image-autosize
Description: A wrapper around next/image that automatically sets width and height.
Author: farbenmeer GmbH
Latest version: 1.0.4

# next-image-autosize
A wrapper around [next/image](https://nextjs.org/docs/api-reference/next/image) that automatically sets `width` and `height`.

This is useful in testing and development-environments where `next-image-loader` is not available (e.G. [storybook](https://storybook.js.org/)).
It will render a next/image without knowing the `width` and `height` beforehand by rendering a plain `<img>` first, then reading out the image dimensions and replacing the `<img>` with next/image.

## Warning
*DO NOT USE THIS IN PRODUCTION*
It will cause layout shift on two subsequent renders.

## Usage

### Storybook
```js
// .storybook/preview.js
import * as NextImage from 'next/image'
import NextImageAutosize from '@farbenmeer/next-image-autosize'

const OriginalNextImage = NextImage.default

Object.defineProperty(NextImage, 'default', {
  configurable: true,
  value: NextImageAutosize
})
```
npm package: @farcaster/flatbuffers
Description: A collection of [Flatbuffer](https://github.com/google/flatbuffers) schemas and generated Typescript classes used in the Farcaster Hub.
Latest version: 0.1.5
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# Flatbuffers

A collection of [Flatbuffer](https://github.com/google/flatbuffers) schemas and generated Typescript classes used in the Farcaster Hub.

| Schema                                                        | Description                             |
| ------------------------------------------------------------- | --------------------------------------- |
| [Message](./src/schemas/message.fbs)                          | Farcaster Deltas created by users       |
| [Id Registry Events](./src/schemas/id_registry_event.fbs)     | Events from the Farcaster Id Registry   |
| [Name Registry Events](./src/schemas/name_registry_event.fbs) | Events from the Farcaster Name Registry |
| [RPC](./src/schemas/rpc.fbs)                                  | Requests to the RPC Server              |
| [Gossip](./src/schemas/gossip.fbs)                            | Messages sent over the gossip network   |
| [Hub State](./src/schemas/hub_state.fbs)                      | State persisted by the Hub              |

If you update any `*.fbs` files you must regenerate the TS classes by running `yarn flatc`.
npm package: @farcaster/frame-host-react-native
Description: Library for hosting Mini Apps in React Native
Latest version: 0.2.0

# @farcaster/frame-host-react-native

Library for hosting Mini Apps in React Native

## Installation

```bash
pnpm add @farcaster/frame-host-react-native
```

## Documentation

For documentation and guides, visit [miniapps.farcaster.xyz](https://miniapps.farcaster.xyz).
npm package: @farcaster/frame-node
Description: Utility methods for Mini App backends
Latest version: 0.2.0

# @farcaster/frame-node

Utility methods for Mini App backends

## Installation

```bash
pnpm add @farcaster/frame-node
```

## Documentation

- `parseWebhookEvent`: parses and verifies webhook events, using a `VerifyAppKey` method
- `verifyJsonFarcasterSignature`: verifies a [JSON Farcaster Signature](https://github.com/farcasterxyz/protocol/discussions/208) payload, using a `VerifyAppKey` method
- `createJsonFarcasterSignature`: creates a [JSON Farcaster Signature](https://github.com/farcasterxyz/protocol/discussions/208) payload

For signature verification, you need to pass in a `VerifyAppKey` method that verifies that an app key is valid for an FID. You can use the included `verifyAppKeyWithNeynar` which uses [Neynar](https://neynar.com) and requires the `NEYNAR_API_KEY` environment variable to be defined.
npm package: @farcaster/frame-wagmi-connector
Description: A [Wagmi connector](https://wagmi.sh/) for interacting with wallets in Mini Apps.
Latest version: 2.0.0

# @farcaster/frame-wagmi-connector

A [Wagmi connector](https://wagmi.sh/) for interacting with wallets in Mini Apps.


## Installation

[Install and setup wagmi](https://wagmi.sh/react/getting-started#manual-installation).

```bash
pnpm add @farcaster/frame-wagmi-connector
```

## Usage

Connect to users wallet:

```
import { useConnect } from 'wagmi'
import { farcasterFrame } from "@farcaster/frame-wagmi-connector";

function App() {
  const { connect } = useConnect()

  return (
    <button onClick={() => connect({ connector: farcasterFrame() })}>
      Connect
    </button>
  )
}
```

You can now interact with the users connected wallet via Wagmi.
npm package: @farcaster/hot-shots
Description: Fork of hot-shots with optional unix-dgram dependency removed
Author: Steve Ivy
Latest version: 10.0.0

# (FORK) hot-shots

Fork of version 10.0.0 of [brightcove/hot-shots](https://github.com/brightcove/hot-shots) with the optional `unix-dgram` dependency removed, which isn't supported on Node 21+.

**Don't use this** if you are using a Unix domain socket.
npm package: @farcaster/hub-nodejs
Description: A lightweight, fast Typescript interface for Farcaster Hubs. Designed to work with [Hubble](https://github.com/farcasterxyz/hubble/) and any other Hub that implements the [Farcaster protocol](https://github.com/farcasterxyz/protocol).
Latest version: 0.15.10

# @farcaster/hub-nodejs

A lightweight, fast Typescript interface for Farcaster Hubs. Designed to work with [Hubble](https://github.com/farcasterxyz/hubble/) and any other Hub that implements the [Farcaster protocol](https://github.com/farcasterxyz/protocol).

## Features

- Call any Hub endpoint from a NodeJS environment.
- Serializes and deserializes Farcaster protobufs into Javascript objects.
- Has helpers to create and sign Farcaster messages.
- Written entirely in TypeScript, with strict types for safety.

Read the [documentation](https://github.com/farcasterxyz/hubble/tree/main/packages/hub-nodejs/docs), see more [examples](https://github.com/farcasterxyz/hubble/tree/main/packages/hub-nodejs/examples) or get started with the guide below.

## Installation

Install @farcaster/hub-nodejs with the package manager of your choice

```bash
npm install @farcaster/hub-nodejs
yarn add @farcaster/hub-nodejs
pnpm install @farcaster/hub-nodejs
```

## Quickstart

### Fetching Data from Hubs

```typescript
import { getSSLHubRpcClient } from '@farcaster/hub-nodejs';

client.$.waitForReady(Date.now() + 5000, async (e) => {
  if (e) {
    console.error(`Failed to connect to ${hubRpcEndpoint}:`, e);
    process.exit(1);
  } else {
    console.log(`Connected to ${hubRpcEndpoint}`);
    const castsResult = await client.getCastsByFid({ fid: 8928 });
    castsResult.map((casts) => casts.messages.map((cast) => console.log(cast.data?.castAddBody?.text)));
    client.close();
  }
});
```

## Documentation

The HTTP API endpoints are [documented here](https://docs.farcaster.xyz/reference/hubble/httpapi/httpapi).

An OpenAPI spec is provided [here](./spec.yaml).

## Contributing

Please see our [contributing guidelines](https://github.com/farcasterxyz/hubble/blob/main/CONTRIBUTING.md) before making a pull request.

## License

MIT License
npm package: @farcaster/hub-web
Description: A fast and easy REST-like interface to work with Farcaster Hubs. Designed to work with [Hubble](https://github.com/farcasterxyz/hubble/) and any other Hub that implements the [Farcaster protocol](https://github.com/farcasterxyz/protocol).
Latest version: 0.11.8

# @farcaster/hub-web

A fast and easy REST-like interface to work with Farcaster Hubs. Designed to work with [Hubble](https://github.com/farcasterxyz/hubble/) and any other Hub that implements the [Farcaster protocol](https://github.com/farcasterxyz/protocol).

## Features

- Call any endpoint using a simple HTTP API, including from a browser environment
- Responses are plain JSON
- Written entirely in Typescript, with strict types for safety.

## Installation

The examples in this package use `axios` to make HTTP requests, but you can use any library. It is also useful to install the `@farcaster/core` library which has several helper methods that are useful while working with Farcaster messages.

```bash
yarn add axios @farcaster/core
yarn add -D @types/axios 
```

## Documentation

The HTTP API endpoints are [documented here](https://www.thehubble.xyz/docs/httpapi/httpapi.html).

### Getting started: fetching casts

```typescript
import axios from "axios";

const fid = 2;
const server = "http://nemes.farcaster.xyz:2281";

try {
    const response = await axios.get(`${server}/v1/castsByFid?fid=${fid}`);

    console.log(`API Returned HTTP status ${response.status}`);    
    console.log(`The first cast's text is ${response.messages[0].data.castAddBody.text}`);
} catch (e) {
    // Handle errors
    console.log(response);
}
```

### Get the username by FID

```typescript
const getFnameFromFid = async (
  fid: number,
  client: HubRpcClient
): HubAsyncResult<string> => {
  const result = await client.getUserData({
    fid: fid,
    userDataType: UserDataType.FNAME,
  });
  return result.map((message) => {
    if (isUserDataAddMessage(message)) {
      return message.data.userDataBody.value;
    } else {
      return '';
    }
  });
};
```

### Running the examples

There are several examples in the `examples/` folder. To run the examples, please look at the individual README files in the examples directory. Most examples can be run by

```bash
yarn install
yarn start
```

## grpc-Web

grpc-web was an older way of proxying to the grpc API from web environments. This has been deprecated and is no longer supported. You can read the original [grpc-web documentation and examples here](./README.grpcweb.md).

## Contributing

Please see our [contributing guidelines](https://github.com/farcasterxyz/hubble/blob/main/CONTRIBUTING.md) before making a pull request.

## License

MIT License
npm package: @farcaster/js
Description: A lightweight, fast Typescript interface for Farcaster Hubs. Designed to work with [Hubble](https://github.com/farcasterxyz/hubble/) and any other Hub that implements the [Farcaster protocol](https://github.com/farcasterxyz/protocol).
Latest version: 0.3.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# farcaster.js

A lightweight, fast Typescript interface for Farcaster Hubs. Designed to work with [Hubble](https://github.com/farcasterxyz/hubble/) and any other Hub that implements the [Farcaster protocol](https://github.com/farcasterxyz/protocol).

## Features

- Call any Hub endpoint from a NodeJS environment.
- Serializes and deserializes Farcaster protobufs into Javascript objects.
- Has helpers to create and sign Farcaster messages.
- Written entirely in TypeScript, with strict types for safety.

Read the [documentation](./docs/README.md), see more [examples](./examples/) or get started with the guide below.

## Installation

Install @farcaster/js with the package manager of your choice

```bash
npm install @farcaster/js
yarn add @farcaster/js
pnpm install @farcaster/js
```

## Quickstart

### Fetching Data from Hubs

```typescript
import { Client } from '@farcaster/js';

(async () => {
  // Connect to a known hub using its address of the form <ip_address>:<rpc_port>
  const client = new Client('127.0.0.1:8080');

  // Set the user whose casts we will be fetching
  const fid = 2;

  const castsResult = await client.getCastsByFid(fid);

  if (castsResult.isErr()) {
    console.log('Failed: ', castsResult.error);
  }

  castsResult.map((casts) => casts.map((c) => console.log(`${c.data.body.text}\n`)));
})();
```

## Contributing

Please see our [contributing guidelines](../../../CONTRIBUTING.md) before making a pull request.

## License

MIT License
npm package: @farcaster/miniapp-core
Description: Build onchain social apps
Latest version: 0.6.0

# @farcaster/miniapp-core

Build onchain social apps

## Installation

```bash
pnpm add @farcaster/miniapp-core
```

## Documentation

For documentation and guides, visit [miniapps.farcaster.xyz](https://miniapps.farcaster.xyz).
npm package: @farcaster/miniapp-host
Description: Library for hosting Mini Apps
Latest version: 0.3.0

# @farcaster/miniapp-host

Library for hosting Mini Apps

## Installation

```bash
pnpm add @farcaster/miniapp-host
```

## Documentation

For documentation and guides, visit [miniapps.farcaster.xyz](https://miniapps.farcaster.xyz).
npm package: @farcaster/miniapp-host-react-native
Description: Library for hosting Mini Apps in React Native
Latest version: 0.2.0

# @farcaster/miniapp-host-react-native

Library for hosting Mini Apps in React Native

## Installation

```bash
pnpm add @farcaster/miniapp-host-react-native
```

## Documentation

For documentation and guides, visit [miniapps.farcaster.xyz](https://miniapps.farcaster.xyz).
npm package: @farcaster/miniapp-node
Description: Utility methods for Mini App backends
Latest version: 0.2.0

# @farcaster/miniapp-node

Utility methods for Mini App backends

## Installation

```bash
pnpm add @farcaster/miniapp-node
```

## Documentation

- `parseWebhookEvent`: parses and verifies webhook events, using a `VerifyAppKey` method
- `verifyJsonFarcasterSignature`: verifies a [JSON Farcaster Signature](https://github.com/farcasterxyz/protocol/discussions/208) payload, using a `VerifyAppKey` method
- `createJsonFarcasterSignature`: creates a [JSON Farcaster Signature](https://github.com/farcasterxyz/protocol/discussions/208) payload

For signature verification, you need to pass in a `VerifyAppKey` method that verifies that an app key is valid for an FID. You can use the included `verifyAppKeyWithNeynar` which uses [Neynar](https://neynar.com) and requires the `NEYNAR_API_KEY` environment variable to be defined.
npm package: @farcaster/miniapp-wagmi-connector
Description: A [Wagmi connector](https://wagmi.sh/) for interacting with wallets in Mini Apps.
Latest version: 2.0.0

# @farcaster/miniapp-wagmi-connector

A [Wagmi connector](https://wagmi.sh/) for interacting with wallets in Mini Apps.


## Installation

[Install and setup wagmi](https://wagmi.sh/react/getting-started#manual-installation).

```bash
pnpm add @farcaster/miniapp-wagmi-connector
```

## Usage

Connect to users wallet:

```
import { useConnect } from 'wagmi'
import { farcasterMiniApp } from "@farcaster/miniapp-wagmi-connector";

function App() {
  const { connect } = useConnect()

  return (
    <button onClick={() => connect({ connector: farcasterMiniApp() })}>
      Connect
    </button>
  )
}
```

You can now interact with the users connected wallet via Wagmi.
npm package: @farcaster/protobufs
Description: Specifications for API's and data formats used in Hubble, including both Farcaster protocol types and Hubble specific types.
Latest version: 0.2.0
Deprecated: Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

# @farcaster/protobufs

Specifications for API's and data formats used in Hubble, including both Farcaster protocol types and Hubble specific types.

| Schema                                                     | Type Description                         | Docs                    |
| ---------------------------------------------------------- | ---------------------------------------- | ----------------------- |
| [Message](src/schemas/message.proto)                       | Types for Farcaster deltas               | [docs](docs/message.md) |
| [RPC](src/schemas/rpc.proto)                               | Types for gRPC APIs exposed by Hubs      | [docs](docs/rpc.md)     |
| [Gossip](src/schemas/gossip.proto)                         | Types for gossiping data between Hubs    |                         |
| [IdRegistryEvent](src/schemas/id_registry_event.proto)     | Types for representing on-chain activity |                         |
| [NameRegistryEvent](src/schemas/name_registry_event.proto) | Types for representing on-chain activity |                         |
| [HubState](src/schemas/hub_state.proto)                    | Types for for maintaining internal state |                         |

## Getting Started

### Generate Bindings

Coming soon

### Generate Docs

Documentation of gRPC endpoints is done manually, but `protoc` can be used to generate Message docs:

1. Install [protoc](https://grpc.io/docs/protoc-installation/)
2. Download latest `protoc-gen-doc` binary from the [repo](https://github.com/pseudomuto/protoc-gen-doc) and place in this folder
3. On OS X, you may need to remove the binary from quaratine with `xattr -d com.apple.quarantine protoc-gen-doc`
4. Run `protoc --plugin=protoc-gen-doc=./protoc-gen-doc --doc_out=. --doc_opt=markdown,message.md src/schemas/message.proto`

The output should be merged with the existing documentation by hand because it makes some errors like not correctly documenting [oneOf](https://github.com/pseudomuto/protoc-gen-doc/issues/333). It also organizes items alphabetically which makes it harder to parse.
npm package: @farcaster/quick-auth
Description: Client for Farcaster Quick Auth
Latest version: 0.0.8

# @farcaster/quick-auth

A client for interacting with a Farcaster Quick Auth server.

## Installation

```sh
npm install @auth-server/client
# or
yarn add @auth-server/client
# or
pnpm add @auth-server/client
```

## Usage

```typescript
import { createClient } from '@farcaster/quick-auth';

// Get a nonce
const domain = 'your-domain.com';
const client = createClient();
const nonce = await client.getNonce();

// Generate a SIWF message using nonce and domain (not shown)

// Verify a SIWF message and get a JWT token
const token = await client.verifySiwf({
  message,
  signature,
  domain
});

// Use the return JWT as an Bearer token and validate on your server
const token = await client.verifyToken({
  token,
  domain
});
```
npm package: @farcaster/shuttle
Description: Package to help move data from a hub to a database.
Latest version: 0.9.6

# Hub Shuttle Package

Package to help move data from a hub to a database.

Currently in beta. APIs should be relatively stable, but still subject to change.

However, database schema is stable and will not change (except for addition of new tables).

## Architecture

![Architecture](./architecture.jpg)

There are 3 main components:
- a hub subscriber that listens to the hub for new messages
- an event processor that can process messages and write them to the database
- a reconciler that can backfill messages and ensures the messages are in sync with the hub

The event processor has a hook for your code to plug into the message processing loop. You must implement the `MessageHandler` interface
and provide it to the system. The system will call your `handleMessageMerge` method for each message it processes, within the same transaction
where the message is written to the db. The function is always expected to succeed, it is not possible to instruct it to "skip"  a message.
If your function fails, the message will not be written to the db and will be retried at a later time.


## Usage
The package is meant to be used as a library. The app provided is just an example.

If you want to run the test the app, do the following:
```bash

# Ensure you have node 21 installed, use nvm to install it
nvm install 21

# If necessary, build packages/core dependency
( cd packages/core && yarn install && yarn build; )

# If necessary, build packages/hub-nodejs dependency
( cd packages/hub-nodejs && yarn install && yarn build; )

# Do remainder within the packages/shuttle directory
cd packages/shuttle
yarn install && yarn build

# Start the db dependencies
docker compose up postgres redis

# To perform reconciliation/backfill, start the worker (can run multiple processes to speed this up)
POSTGRES_URL=postgres://shuttle:password@0.0.0.0:6541 REDIS_URL=0.0.0.0:16379 HUB_HOST=<host>:<port> HUB_SSL=false yarn start worker

# Kick off the backfill process (configure with MAX_FID=100 or BACKFILL_FIDS=1,2,3)
POSTGRES_URL=postgres://shuttle:password@0.0.0.0:6541 REDIS_URL=0.0.0.0:16379 HUB_HOST=<host>:<port> HUB_SSL=false yarn start backfill

# Start the app and sync messages from the event stream
POSTGRES_URL=postgres://shuttle:password@0.0.0.0:6541 REDIS_URL=0.0.0.0:16379 HUB_HOST=<host>:<port> HUB_SSL=false yarn start start
```


If you are using this as a package implement the `MessageHandler` interface and take a look at the `App` class on how to call the other classes.

## TODO
- [ ] Onchain events and fnames
- [ ] Detect if already backfilled and only backfill if not
- [ ] Better retries and error handling
- [ ] More tests
npm package: @fardel/pointer-events
Description: Minimal library to handle pointer events in the browser
Author: Ivan Juarez
Latest version: 0.1.0

# Pointer Events

This package extends [Pointer Events](https://developer.mozilla.org/en-US/docs/Web/CSS/pointer-events) to handle other browser inputs and gestures such as: tap, pan/drag, rotate, swipe and pinch/zoom. This library doesn't implement any fallback code so before using it make sure that your target browsers [support](https://caniuse.com/pointer) pointer events natively.
npm package: @fardog/resolve-protobuf-schema
Description: Read a protobuf schema from the disk, parse it and resolve all imports
Author: Mathias Buus
Latest version: 3.0.0

# resolve-protobuf-schema

Read a protobuf schema from the disk, parse it and resolve all imports

```
npm install resolve-protobuf-schema
```

[![build status](http://img.shields.io/travis/fardog/resolve-protobuf-schema.svg?style=flat)](http://travis-ci.org/fardog/resolve-protobuf-schema)

This is a fork of mafintosh's [resolve-protobuf-schema][] which namespaces
imported protobufs if they specify a `package` directive.

## Usage

Store the following example protobuf schema in `test.proto`

```
package com.example.test;

message Test {
  optional string test = 1;
}
```

Then run

``` js
var resolve = require('resolve-protobuf-schema')
console.log(resolve.sync('test.proto')) // prints the parsed schema
```

Schema imports will resolved as well

```
package com.example.anothertest;

import "./test.proto"

message AnotherTest {
  optional string something = 1;
  optional com.example.test.Test test = 2;
}
```

``` js
console.log(resolve.sync('./another-test.proto')) // will print a combined parsed schema
```

## API

* `resolve(path, cb)` read and resolve a schema
* `resolve.sync(path)` sync version of `resolve`

## License

MIT

[resolve-protobuf-schema]: https://github.com/mafintosh/resolve-protobuf-schema
npm package: @fardream/confirm-solana-transaction
Description: Confirm solana transaction with last valid block height.
Author: Chao Xu
Latest version: 1.0.1

# confirm-solana-transaction

Many solana client sends a transaction to the network and then wait for the status of the transaction signature to the confirm the transaction.

The classic way to do this is to check the status of the transaction signature, and see if that transaction's status matches the desired commitment level. This can be done in one shot with `sendAndConfirmTransaction` in the solana web3 library.

```typescript
const tx = ...some..transaction;
const signature = await sendAndConfirmTransaction(connection, tx, signers, options);
```

During network congestions, the transaction may be dropped and the status will never return in the websocket subscription or will be null in the rpc call. However, the `sendAndConfirmTransaction` method doesn't check for if the transaction is dropped or not. It simply waits for 60 seconds and will throw an error if time out. However, there is not way to tell if the transaction is dropped or not.

A more robust method is to record the block hash and the `lastValidBlockHeight` from the `getLatestBlockHash` call, set the recent block hash on the transaction to that block hash, and send the transaction to the network. After transaction is sent, check what is the current valid block height. If the current valid block height is higher than the lastValidBlockHeight, the transaction has been dropped by the network and a new transaction with a different block hash can be safely retry, otherwise the transaction may still be included in a block and therefore there is still a chance that the transaction signature status can still return.

**Note**: if the same transaction is sent multiple times to the network, only one of the them will be executed (this is a guarantee by the network).

This library does this:

```typescript
import {sendAndConfirmTransaction} from "@foonetic/confirm-solana-transaction";

const tx = ...some...transaction
const signature = await sendAndConfirmTransaction(connection, tx, signers, options, time_out);
```

Or if you have recorded the `lastValidBlockHeight`, you can simply call `confirmTransaction`.

**sendTransaction** on the solana client will automatically get the recent block hash but it doesn't expose the `lastValidBlockHeight`. This can be changed to

1. get the recent block hash and last valid block height.
2. set the block hash on the transaction, sign the transaction and serialize the data.
3. send the serialized transaction with `sendRawTransaction`.