mirror of
https://github.com/pezkuwichain/bizinikiwi-connect.git
synced 2026-04-22 02:57:55 +00:00
feat: initial commit for bizinikiwi-connect with clean CI
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
# @bizinikiwi/connect-discovery
|
||||
|
||||
## 0.2.2
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 92316c0: chore(deps-dev): bump vitest in the npm_and_yarn group
|
||||
|
||||
Bumps the npm_and_yarn group with 1 update: [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest).
|
||||
|
||||
Updates `vitest` from 2.1.4 to 2.1.9
|
||||
|
||||
- [Release notes](https://github.com/vitest-dev/vitest/releases)
|
||||
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.9/packages/vitest)
|
||||
|
||||
***
|
||||
|
||||
updated-dependencies:
|
||||
|
||||
- dependency-name: vitest
|
||||
dependency-type: direct:development
|
||||
dependency-group: npm_and_yarn
|
||||
...
|
||||
|
||||
Signed-off-by: dependabot[bot] <support@github.com>
|
||||
|
||||
- Updated dependencies [92316c0]
|
||||
- @bizinikiwi/discovery@0.2.2
|
||||
|
||||
## 0.2.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 09f1c22: chore(deps-dev): bump vitest from 2.0.5 to 2.1.4
|
||||
|
||||
Bumps [vitest](https://github.com/vitest-dev/vitest/tree/HEAD/packages/vitest) from 2.0.5 to 2.1.4.
|
||||
|
||||
- [Release notes](https://github.com/vitest-dev/vitest/releases)
|
||||
- [Commits](https://github.com/vitest-dev/vitest/commits/v2.1.4/packages/vitest)
|
||||
|
||||
***
|
||||
|
||||
updated-dependencies:
|
||||
|
||||
- dependency-name: vitest
|
||||
dependency-type: direct:development
|
||||
update-type: version-update:semver-minor
|
||||
...
|
||||
|
||||
Signed-off-by: dependabot[bot] <support@github.com>
|
||||
|
||||
- Updated dependencies [09f1c22]
|
||||
- @bizinikiwi/discovery@0.2.1
|
||||
|
||||
## 0.2.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- 198b375: chore: catalog and upgrade papi dependencies
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [198b375]
|
||||
- @bizinikiwi/discovery@0.2.0
|
||||
|
||||
## 0.1.1
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- d0316d7: update docs
|
||||
|
||||
## 0.1.0
|
||||
|
||||
### Minor Changes
|
||||
|
||||
- b476e7e: update build system to tshy
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- Updated dependencies [b476e7e]
|
||||
- @bizinikiwi/discovery@0.1.0
|
||||
|
||||
## 0.0.8
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- e8fef4e: update docs
|
||||
- Updated dependencies [e8fef4e]
|
||||
- @bizinikiwi/discovery@0.0.2
|
||||
|
||||
## 0.0.7
|
||||
|
||||
### Patch Changes
|
||||
|
||||
- 444503f: chore: update READMEs across repo
|
||||
@@ -0,0 +1,44 @@
|
||||
<br /><br />
|
||||
|
||||
<div align="center">
|
||||
<h1 align="center">@bizinikiwi/connect-discovery</h1>
|
||||
<p align="center">
|
||||
<a href="https://www.npmjs.com/package/@bizinikiwi/discovery">
|
||||
<img alt="npm" src="https://img.shields.io/npm/v/@bizinikiwi/discovery" />
|
||||
</a>
|
||||
<a href="https://github.com/pezkuwichain/bizinikiwi-connect/blob/master/LICENSE">
|
||||
<img alt="GPL-3.0-or-later" src="https://img.shields.io/npm/l/@bizinikiwi/discovery" />
|
||||
</a>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<br /><br />
|
||||
|
||||
<div align="center" style="padding: 10px; border: 2px solid red; color: red; font-weight: bold; background-color: #ffe6e6;">
|
||||
⚠️ WARNING: This interface is currently unstable and is likely to change ⚠️
|
||||
</div>
|
||||
|
||||
<br /><br />
|
||||
|
||||
A TypeScript package extended from the [`@bizinikiwi/discovery`](../discovery/README.md) npm module, that allows to discover and filter Bizinikiwi Connect Extension providers from a list of providers.
|
||||
|
||||
## Installation
|
||||
|
||||
You can install the package using npm or yarn:
|
||||
|
||||
```sh
|
||||
corepack pnpm i @bizinikiwi/connect-discovery
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
Here's an example of how to use the package:
|
||||
|
||||
```ts
|
||||
import { Unstable } from "@bizinikiwi/connect-discovery"
|
||||
|
||||
const connectExtensionProviders =
|
||||
Unstable.getBizinikiwiConnectExtensionProviders()
|
||||
|
||||
console.log(connectExtensionProviders)
|
||||
```
|
||||
@@ -0,0 +1,61 @@
|
||||
{
|
||||
"name": "@bizinikiwi/connect-discovery",
|
||||
"version": "0.2.3",
|
||||
"author": "Parity Technologies (https://github.com/pezkuwichain)",
|
||||
"type": "module",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/pezkuwichain/bizinikiwi-connect.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"main": "./dist/commonjs/index.js",
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"module": "./dist/esm/index.js",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": {
|
||||
"import": {
|
||||
"@bizinikiwi-connect/source": "./src/index.ts",
|
||||
"types": "./dist/esm/index.d.ts",
|
||||
"default": "./dist/esm/index.js"
|
||||
},
|
||||
"require": {
|
||||
"types": "./dist/commonjs/index.d.ts",
|
||||
"default": "./dist/commonjs/index.js"
|
||||
}
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"tshy": {
|
||||
"project": "./tsconfig.build.json",
|
||||
"exports": {
|
||||
"./package.json": "./package.json",
|
||||
".": "./src/index.ts"
|
||||
},
|
||||
"sourceDialects": [
|
||||
"@bizinikiwi-connect/source"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"prepare": "corepack pnpm turbo build",
|
||||
"deep-clean": "npm run clean && rimraf dist node_modules",
|
||||
"clean": "rimraf dist .tshy .tshy-build",
|
||||
"build": "npm run clean && tshy",
|
||||
"dev": "pnpm build --watch",
|
||||
"lint": "prettier --check README.md \"src/**/*.{js,jsx,ts,tsx,json,md}\""
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 80,
|
||||
"semi": false,
|
||||
"trailingComma": "all"
|
||||
},
|
||||
"dependencies": {
|
||||
"@bizinikiwi/discovery": "^0.2.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"typescript": "5.6.2",
|
||||
"vitest": "^2.1.9"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
import {
|
||||
getProviders,
|
||||
type ProviderDetail,
|
||||
type ProviderInfo,
|
||||
} from "@bizinikiwi/discovery"
|
||||
|
||||
export namespace Unstable {
|
||||
export const Kind = "bizinikiwi-connect-unstable"
|
||||
|
||||
type Callback<T> = (value: T) => void
|
||||
type UnsubscribeFn = () => void
|
||||
|
||||
export interface Provider {
|
||||
// Allows dApp developers to request the provider to register their chain
|
||||
getChain: (
|
||||
chainSpec: string,
|
||||
relayChainGenesisHash?: string,
|
||||
) => Promise<RawChain>
|
||||
|
||||
// Retrieves the current list of available Chains
|
||||
getChains: () => RawChains
|
||||
|
||||
// Registers a callback invoked when the list of available chains changes
|
||||
addChainsChangeListener: (listener: Callback<RawChains>) => UnsubscribeFn
|
||||
|
||||
// TODO: move inside RawChains and remove chainId
|
||||
getAccounts: (chainId: string) => Promise<Account[]>
|
||||
|
||||
// TODO: move inside RawChains and remove chainId
|
||||
createTx: (
|
||||
chainId: string,
|
||||
from: string,
|
||||
// TODO: it should encode a Tuple<CallData, Extra, AdditionalSigned>
|
||||
callData: string,
|
||||
) => Promise<string>
|
||||
}
|
||||
|
||||
export type Account = {
|
||||
address: string
|
||||
}
|
||||
|
||||
// The key is the genesis hash
|
||||
export type RawChains = Record<string, RawChain>
|
||||
|
||||
export interface RawChain {
|
||||
genesisHash: string
|
||||
|
||||
name: string
|
||||
|
||||
connect: (
|
||||
// the listener callback that the JsonRpcProvider will be sending messages to.
|
||||
onMessage: Callback<string>,
|
||||
) => JsonRpcProvider
|
||||
}
|
||||
|
||||
export interface JsonRpcProvider {
|
||||
// it sends messages to the JSON RPC Server
|
||||
send: Callback<string>
|
||||
|
||||
// it disconnects from the JSON RPC Server and it de-registers
|
||||
// the `onMessage` and `onStatusChange` callbacks that was previously registered
|
||||
disconnect: UnsubscribeFn
|
||||
}
|
||||
|
||||
export type BizinikiwiConnectProviderDetail = {
|
||||
kind: typeof Kind
|
||||
info: ProviderInfo
|
||||
provider: Promise<Provider>
|
||||
}
|
||||
|
||||
export const isBizinikiwiConnectExtension = (
|
||||
provider: ProviderDetail,
|
||||
): provider is BizinikiwiConnectProviderDetail => {
|
||||
if (provider.kind !== Kind) return false
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
export const getBizinikiwiConnectExtensionProviders = () => {
|
||||
return getProviders().filter(isBizinikiwiConnectExtension)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.build.json",
|
||||
"include": ["src"]
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "../../tsconfig.base",
|
||||
"include": ["src", "tests"]
|
||||
}
|
||||
Reference in New Issue
Block a user