Skip to content

Commit

Permalink
Merge pull request #129 from portto/release/upgrade-rainbowkit
Browse files Browse the repository at this point in the history
Release: Merge to publish new version to npm
  • Loading branch information
sanyu1225 authored May 19, 2023
2 parents 646e35c + 2d2468e commit 561c604
Show file tree
Hide file tree
Showing 43 changed files with 1,638 additions and 465 deletions.
7 changes: 1 addition & 6 deletions .eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
module.exports = {
root: true,
// This tells ESLint to load the config from the package `eslint-config-custom`
extends: ["custom"],
settings: {
next: {
rootDir: ["apps/*/"],
},
},
extends: ['custom'],
};
11 changes: 10 additions & 1 deletion .github/workflows/release-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,26 @@ jobs:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Cache turbo build setup
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'

- name: Install Dependencies
run: yarn

- name: Bump Changeset Version
run: yarn ver

- name: Commit Changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
Expand Down
35 changes: 35 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Build and Test

on:
pull_request:
types: [opened, synchronize, ready_for_review]

jobs:
build:
name: Build and Test
timeout-minutes: 15
runs-on: ubuntu-latest

steps:
- name: Checkout Repo
uses: actions/checkout@v3

- name: Cache turbo build setup
uses: actions/cache@v3
with:
path: .turbo
key: ${{ runner.os }}-turbo-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-
- name: Setup Node.js 16
uses: actions/setup-node@v3
with:
node-version: 16
cache: 'yarn'

- name: Install dependencies
run: yarn

- name: Lint, Test, and Try to Build
run: yarn turbo lint test build --cache-dir=.turbo
26 changes: 12 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
<p align="center">
<a href="https://github.com/portto/blocto-sdk">
<img src="https://github.com/portto/blocto-sdk/assets/4176802/dc181640-6d85-4cd5-88f6-6bfb729c1113" alt="Blocto logo" width="500" />
</a>
</p>


# Blocto JavaScript SDK

[![npm (lastest)](https://img.shields.io/npm/v/@blocto/sdk/latest)](https://www.npmjs.com/package/@blocto/sdk)
[![npm (beta)](https://img.shields.io/npm/v/@blocto/sdk/beta)](https://www.npmjs.com/package/@blocto/sdk)
[![npm bundle size](https://img.shields.io/bundlephobia/minzip/@blocto/sdk)](https://www.npmjs.com/package/@blocto/sdk)
[![Github Checks](https://github.com/portto/blocto-sdk/actions/workflows/test.yml/badge.svg)](https://github.com/portto/blocto-sdk/actions/workflows/test.yml)
[![npm downloads](https://img.shields.io/npm/dw/@blocto/sdk)](https://www.npmjs.com/package/@blocto/sdk)
[![LICENSE](https://img.shields.io/github/license/portto/blocto-sdk)](https://github.com/portto/blocto-sdk/blob/main/LICENSE)
[![Discord](https://img.shields.io/discord/720454370650619984.svg?label=&logo=discord&logoColor=ffffff&color=7389D8&labelColor=6A7EC2)](https://discord.com/invite/QRZTr6yHmY)

This is a monorepo of Blocto JavaScript SDK. Check out the docs here: [docs.blocto.app](https://docs.blocto.app/).
Expand All @@ -10,7 +21,7 @@ There are some adapters to make it easier to integrate:
|lib name|npm|
|-|-|
|[@blocto/aptos-wallet-adapter-plugin](./adapters/aptos-wallet-adapter-plugin/)|[![npm (lastest)](https://img.shields.io/npm/v/@blocto/aptos-wallet-adapter-plugin/latest)](https://www.npmjs.com/package/@blocto/aptos-wallet-adapter-plugin)|
|[@blocto/react-web3-connector](./adapters/react-web3-connector/)|[![npm (lastest)](https://img.shields.io/npm/v/@blocto/react-web3-connector/latest)](https://www.npmjs.com/package/@blocto/react-web3-connector)|
|[@blocto/web3-react-connector](./adapters/web3-react-connector/)|[![npm (lastest)](https://img.shields.io/npm/v/@blocto/web3-react-connector/latest)](https://www.npmjs.com/package/@blocto/web3-react-connector)|
|[@blocto/wagmi-connector](./adapters/wagmi-connector/)|[![npm (lastest)](https://img.shields.io/npm/v/@blocto/wagmi-connector/latest)](https://www.npmjs.com/package/@blocto/wagmi-connector)|
|[@blocto/rainbowkit-connector](./adapters/rainbowkit-connector/)|[![npm (lastest)](https://img.shields.io/npm/v/@blocto/rainbowkit-connector/latest)](https://www.npmjs.com/package/@blocto/rainbowkit-connector)|

Expand Down Expand Up @@ -101,17 +112,4 @@ Changesets are designed to stack, so there's no problem with adding multiple. Yo
- You want to release multiple packages with different changelog entries
- You have made multiple changes to a package that should each be called out separately

## Release

Work in progress. Will automate in future.

## Useful Links

Learn more about the power of Turborepo:

- [Tasks](https://turbo.build/repo/docs/core-concepts/monorepos/running-tasks)
- [Caching](https://turbo.build/repo/docs/core-concepts/caching)
- [Remote Caching](https://turbo.build/repo/docs/core-concepts/remote-caching)
- [Filtering](https://turbo.build/repo/docs/core-concepts/monorepos/filtering)
- [Configuration Options](https://turbo.build/repo/docs/reference/configuration)
- [CLI Usage](https://turbo.build/repo/docs/reference/command-line-reference)
17 changes: 17 additions & 0 deletions adapters/aptos-wallet-adapter-plugin/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,22 @@
# @blocto/aptos-wallet-adapter-plugin

## 0.1.8

### Patch Changes

- ebfb0da: Fix TypeScript types and eslint errors
- Updated dependencies [ebfb0da]
- Updated dependencies [0570b1e]
- @blocto/sdk@0.4.7

## 0.1.8-beta.0

### Patch Changes

- ebfb0da: Fix TypeScript types and eslint errors
- Updated dependencies [ebfb0da]
- @blocto/sdk@0.4.7-beta.0

## 0.1.7

### Patch Changes
Expand Down
7 changes: 4 additions & 3 deletions adapters/aptos-wallet-adapter-plugin/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blocto/aptos-wallet-adapter-plugin",
"version": "0.1.7",
"version": "0.1.8",
"description": "Blocto Wallet plugin to use with Aptos Wallet Adapter",
"author": "Blcoto Wallet",
"main": "./dist/index.js",
Expand All @@ -14,11 +14,12 @@
},
"scripts": {
"build": "tsup src/index.ts --format esm,cjs --dts",
"test": "jest"
"test": "jest",
"lint": "eslint src --ext .ts"
},
"dependencies": {
"@aptos-labs/wallet-adapter-core": "^0.2.2",
"@blocto/sdk": "^0.4.6",
"@blocto/sdk": "^0.4.7",
"aptos": "^1.4.0"
},
"devDependencies": {
Expand Down
121 changes: 42 additions & 79 deletions adapters/aptos-wallet-adapter-plugin/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,21 +62,17 @@ export class BloctoWallet implements AdapterPlugin {
}

async connect(): Promise<AccountInfo> {
try {
const accountInfo = await this.provider?.connect();
if (!accountInfo) throw `${BloctoWalletName} Address Info Error`;
if (!accountInfo.address) throw `${BloctoWalletName} address null`;
if (!accountInfo.publicKey) throw `${BloctoWalletName} publicKey null`;
if (!accountInfo.minKeysRequired)
throw `${BloctoWalletName} minKeysRequired null`;
return {
address: accountInfo.address,
publicKey: accountInfo.publicKey,
minKeysRequired: accountInfo.minKeysRequired,
};
} catch (error: any) {
throw error;
}
const accountInfo = await this.provider?.connect();
if (!accountInfo) throw `${BloctoWalletName} Address Info Error`;
if (!accountInfo.address) throw `${BloctoWalletName} address null`;
if (!accountInfo.publicKey) throw `${BloctoWalletName} publicKey null`;
if (!accountInfo.minKeysRequired)
throw `${BloctoWalletName} minKeysRequired null`;
return {
address: accountInfo.address,
publicKey: accountInfo.publicKey,
minKeysRequired: accountInfo.minKeysRequired,
};
}

async account(): Promise<AccountInfo> {
Expand All @@ -94,87 +90,54 @@ export class BloctoWallet implements AdapterPlugin {
}

async disconnect(): Promise<void> {
try {
await this.provider?.disconnect();
} catch (error: any) {
throw error;
}
await this.provider?.disconnect();
}

async signAndSubmitTransaction(
transaction: Types.TransactionPayload,
options?: any
): Promise<{ hash: Types.HexEncodedBytes }> {
try {
try {
const provider = this.provider;
const response = await provider?.signAndSubmitTransaction(
transaction,
options
);
if (response) {
return { hash: response.hash };
} else {
throw new Error('Transaction failed');
}
} catch (error: any) {
throw new Error(error.message || error);
}
} catch (error: any) {
const errMsg = error.message;
throw errMsg;
const provider = this.provider;
const response = await provider?.signAndSubmitTransaction(
transaction,
options
);
if (response) {
return { hash: response.hash };
} else {
throw new Error('Transaction failed');
}
}

async signMessage(message: SignMessagePayload): Promise<SignMessageResponse> {
try {
if (typeof message !== 'object' || !message.nonce) {
`${BloctoWalletName} Invalid signMessage Payload`;
}
const response = await this.provider?.signMessage(message);
if (response) {
return response;
} else {
throw `${BloctoWalletName} Sign Message failed`;
}
} catch (error: any) {
const errMsg = error.message;
throw errMsg;
if (typeof message !== 'object' || !message.nonce) {
`${BloctoWalletName} Invalid signMessage Payload`;
}
const response = await this.provider?.signMessage(message);
if (response) {
return response;
} else {
throw `${BloctoWalletName} Sign Message failed`;
}
}

async network(): Promise<NetworkInfo> {
try {
const response = await this.provider?.network();
if (!response) throw `${BloctoWalletName} Network Error`;
const name = response.name as unknown;
return {
name: name as NetworkName,
chainId: response.chainId,
};
} catch (error: any) {
throw error;
}
const response = await this.provider?.network();
if (!response) throw `${BloctoWalletName} Network Error`;
const name = response.name as unknown;
return {
name: name as NetworkName,
chainId: response.chainId,
};
}

async onNetworkChange(callback: any): Promise<void> {
try {
// not supported yet
return Promise.resolve();
} catch (error: any) {
const errMsg = error.message;
throw errMsg;
}
async onNetworkChange(): Promise<void> {
// not supported yet
return Promise.resolve();
}

async onAccountChange(callback: any): Promise<void> {
try {
// not supported yet
return Promise.resolve();
} catch (error: any) {
console.log(error);
const errMsg = error.message;
throw errMsg;
}
async onAccountChange(): Promise<void> {
// not supported yet
return Promise.resolve();
}
}
18 changes: 18 additions & 0 deletions adapters/rainbowkit-connector/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @blocto/rainbowkit-connector

## 0.1.2

### Patch Changes

- a94cb6c: support rainbowkit new version
- ebfb0da: Fix TypeScript types and eslint errors
- Updated dependencies [ebfb0da]
- Updated dependencies [0570b1e]
- @blocto/sdk@0.4.7

## 0.1.2-beta.0

### Patch Changes

- ebfb0da: Fix TypeScript types and eslint errors
- Updated dependencies [ebfb0da]
- @blocto/sdk@0.4.7-beta.0

## 0.1.1

### Patch Changes
Expand Down
12 changes: 6 additions & 6 deletions adapters/rainbowkit-connector/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@blocto/rainbowkit-connector",
"version": "0.1.1",
"version": "0.1.2",
"description": "blocto wallet connector to use rainbowkit",
"author": "Blcoto Wallet",
"main": "./dist/index.js",
Expand Down Expand Up @@ -29,13 +29,13 @@
},
"scripts": {
"build": "tsup src/index.ts --format esm,cjs --dts",
"test": "NODE_OPTIONS=--experimental-vm-modules jest --ci --silent"
"lint": "eslint src --ext .ts"
},
"dependencies": {
"@blocto/sdk": "^0.4.6",
"@rainbow-me/rainbowkit": "^0.12.12",
"ethers": "^5.7.1",
"wagmi": "0.12.12"
"@blocto/sdk": "^0.4.7",
"@rainbow-me/rainbowkit": "^1.0.0",
"viem": "^0.3.27",
"wagmi": "1.0.5"
},
"devDependencies": {
"@types/jest": "^29.2.3",
Expand Down
Loading

0 comments on commit 561c604

Please sign in to comment.