Skip to content

Commit

Permalink
Merge pull request #2 from blockaid-official/release-please--branches…
Browse files Browse the repository at this point in the history
…--main--changes--next--components--client

release: 0.7.0
  • Loading branch information
omricohen1 authored May 2, 2024
2 parents 73bafea + 67c8d1a commit c262d44
Show file tree
Hide file tree
Showing 47 changed files with 489 additions and 125 deletions.
32 changes: 32 additions & 0 deletions .github/workflows/publish-npm.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# This workflow is triggered when a GitHub release is created.
# It can also be run manually to re-publish to NPM in case it failed for some reason.
# You can run this workflow by navigating to https://www.github.com/blockaid-official/blockaid-client-node/actions/workflows/publish-npm.yml
name: Publish NPM
on:
workflow_dispatch:

release:
types: [published]

jobs:
publish:
name: publish
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: '18'

- name: Install dependencies
run: |
yarn install
- name: Publish to NPM
run: |
bash ./bin/publish-npm
env:
NPM_TOKEN: ${{ secrets.BLOCKAID_NPM_TOKEN || secrets.NPM_TOKEN }}
19 changes: 19 additions & 0 deletions .github/workflows/release-doctor.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: Release Doctor
on:
pull_request:
workflow_dispatch:

jobs:
release_doctor:
name: release doctor
runs-on: ubuntu-latest
if: github.repository == 'blockaid-official/blockaid-client-node' && (github.event_name == 'push' || github.event_name == 'workflow_dispatch' || startsWith(github.head_ref, 'release-please') || github.head_ref == 'next')

steps:
- uses: actions/checkout@v4

- name: Check release environment
run: |
bash ./bin/check-release-environment
env:
NPM_TOKEN: ${{ secrets.BLOCKAID_NPM_TOKEN || secrets.NPM_TOKEN }}
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.7.0"
}
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 5
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-f7745627dabd1a61b80339c0138885efa0a20694b62a79891fff2f57d7ed4d65.yml
configured_endpoints: 6
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/new%2Fblockaid-35e92c2ca8e7a8cd7c2f58d0fe2f217585365bd24e68c6ee61b9f11a1cbf68a7.yml
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog

## 0.7.0 (2024-05-02)

Full Changelog: [v0.0.1-alpha.0...v0.7.0](https://github.com/blockaid-official/blockaid-client-node/compare/v0.0.1-alpha.0...v0.7.0)

### Features

* **api:** update via SDK Studio ([c72a5c8](https://github.com/blockaid-official/blockaid-client-node/commit/c72a5c8092b257a61e539c3066f9f56af1b2fb2a))
* **api:** update via SDK Studio ([#1](https://github.com/blockaid-official/blockaid-client-node/issues/1)) ([6a9222a](https://github.com/blockaid-official/blockaid-client-node/commit/6a9222ad5a172312fa06fccd4924951d15c0c695))
* **api:** update via SDK Studio ([#3](https://github.com/blockaid-official/blockaid-client-node/issues/3)) ([6ddd9b1](https://github.com/blockaid-official/blockaid-client-node/commit/6ddd9b182c924f0a200224aa131dfe22b4d44874))
* **api:** update via SDK Studio ([#4](https://github.com/blockaid-official/blockaid-client-node/issues/4)) ([b222e24](https://github.com/blockaid-official/blockaid-client-node/commit/b222e241d44f9af46fba19eaf9ddd6358cd668e9))
* **api:** update via SDK Studio ([#5](https://github.com/blockaid-official/blockaid-client-node/issues/5)) ([94cf774](https://github.com/blockaid-official/blockaid-client-node/commit/94cf774dc471aae9e7e3f2227fc82ddc154c92e3))


### Chores

* update SDK settings ([73bafea](https://github.com/blockaid-official/blockaid-client-node/commit/73bafea0cedaccb5d1c8beeada3a6ffb16a112a1))
10 changes: 5 additions & 5 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,25 +42,25 @@ If you’d like to use the repository from source, you can either install from g
To install via git:

```bash
npm install git+ssh://[email protected]:stainless-sdks/new/blockaid-node.git
npm install git+ssh://[email protected]:blockaid-official/blockaid-client-node.git
```

Alternatively, to link a local copy of the repo:

```bash
# Clone
git clone https://www.github.com/stainless-sdks/new/blockaid-node
git clone https://www.github.com/blockaid-official/blockaid-client-node
cd blockaid-client-node

# With yarn
yarn link
cd ../my-package
yarn link blockaid
yarn link @blockaid/client

# With pnpm
pnpm link --global
cd ../my-package
pnpm link -—global blockaid
pnpm link -—global @blockaid/client
```

## Running tests
Expand Down Expand Up @@ -99,7 +99,7 @@ the changes aren't made through the automated pipeline, you may want to make rel

### Publish with a GitHub workflow

You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/stainless-sdks/new/blockaid-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.
You can release to package managers by using [the `Publish NPM` GitHub action](https://www.github.com/blockaid-official/blockaid-client-node/actions/workflows/publish-npm.yml). This requires a setup organization or repository secret to be set up.

### Publish manually

Expand Down
25 changes: 11 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Blockaid Node API Library

[![NPM version](https://img.shields.io/npm/v/blockaid.svg)](https://npmjs.org/package/blockaid)
[![NPM version](https://img.shields.io/npm/v/@blockaid/client.svg)](https://npmjs.org/package/@blockaid/client)

This library provides convenient access to the Blockaid REST API from server-side TypeScript or JavaScript.

Expand All @@ -11,19 +11,16 @@ It is generated with [Stainless](https://www.stainlessapi.com/).
## Installation

```sh
npm install git+ssh://[email protected]:stainless-sdks/new/blockaid-node.git
npm install @blockaid/client
```

> [!NOTE]
> Once this package is [published to npm](https://app.stainlessapi.com/docs/guides/publish), this will become: `npm install blockaid`
## Usage

The full API of this library can be found in [api.md](api.md).

<!-- prettier-ignore -->
```js
import Blockaid from 'blockaid';
import Blockaid from '@blockaid/client';

const blockaid = new Blockaid({
apiKey: process.env['BLOCKAID_CLIENT_API_KEY'], // This is the default and can be omitted
Expand Down Expand Up @@ -54,7 +51,7 @@ This library includes TypeScript definitions for all request params and response

<!-- prettier-ignore -->
```ts
import Blockaid from 'blockaid';
import Blockaid from '@blockaid/client';

const blockaid = new Blockaid({
apiKey: process.env['BLOCKAID_CLIENT_API_KEY'], // This is the default and can be omitted
Expand Down Expand Up @@ -270,12 +267,12 @@ add the following import before your first import `from "Blockaid"`:
```ts
// Tell TypeScript and the package to use the global web fetch instead of node-fetch.
// Note, despite the name, this does not add any polyfills, but expects them to be provided if needed.
import 'blockaid/shims/web';
import Blockaid from 'blockaid';
import '@blockaid/client/shims/web';
import Blockaid from '@blockaid/client';
```

To do the inverse, add `import "blockaid/shims/node"` (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/stainless-sdks/blockaid-client-node/tree/main/src/_shims#readme)).
To do the inverse, add `import "@blockaid/client/shims/node"` (which does import polyfills).
This can also be useful if you are getting the wrong TypeScript types for `Response` ([more details](https://github.com/blockaid-official/blockaid-client-node/tree/main/src/_shims#readme)).

### Logging and middleware

Expand All @@ -284,7 +281,7 @@ which can be used to inspect or alter the `Request` or `Response` before/after e

```ts
import { fetch } from 'undici'; // as one example
import Blockaid from 'blockaid';
import Blockaid from '@blockaid/client';

const client = new Blockaid({
fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
Expand Down Expand Up @@ -344,7 +341,7 @@ This package generally follows [SemVer](https://semver.org/spec/v2.0.0.html) con

We take backwards-compatibility seriously and work hard to ensure you can rely on a smooth upgrade experience.

We are keen for your feedback; please open an [issue](https://www.github.com/stainless-sdks/new/blockaid-node/issues) with questions, bugs, or suggestions.
We are keen for your feedback; please open an [issue](https://www.github.com/blockaid-official/blockaid-client-node/issues) with questions, bugs, or suggestions.

## Requirements

Expand All @@ -353,7 +350,7 @@ TypeScript >= 4.5 is supported.
The following runtimes are supported:

- Node.js 18 LTS or later ([non-EOL](https://endoflife.date/nodejs)) versions.
- Deno v1.28.0 or higher, using `import Blockaid from "npm:blockaid"`.
- Deno v1.28.0 or higher, using `import Blockaid from "npm:@blockaid/client"`.
- Bun 1.0 or later.
- Cloudflare Workers.
- Vercel Edge Runtime.
Expand Down
4 changes: 4 additions & 0 deletions api.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ Methods:

## UserOperation

Methods:

- <code title="post /evm/user-operation/scan">client.evm.userOperation.<a href="./src/resources/evm/user-operation.ts">scan</a>({ ...params }) -> TransactionScanResponse</code>

# Site

Types:
Expand Down
32 changes: 32 additions & 0 deletions bin/check-release-environment
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#!/usr/bin/env bash

warnings=()
errors=()

if [ -z "${NPM_TOKEN}" ]; then
warnings+=("The BLOCKAID_NPM_TOKEN secret has not been set. Please set it in either this repository's secrets or your organization secrets")
fi

lenWarnings=${#warnings[@]}

if [[ lenWarnings -gt 0 ]]; then
echo -e "Found the following warnings in the release environment:\n"

for warning in "${warnings[@]}"; do
echo -e "- $warning\n"
done
fi

lenErrors=${#errors[@]}

if [[ lenErrors -gt 0 ]]; then
echo -e "Found the following errors in the release environment:\n"

for error in "${errors[@]}"; do
echo -e "- $error\n"
done

exit 1
fi

echo "The environment is ready to push releases!"
6 changes: 3 additions & 3 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ const config: JestConfigWithTsJest = {
'^.+\\.(t|j)sx?$': ['@swc/jest', { sourceMaps: 'inline' }],
},
moduleNameMapper: {
'^blockaid$': '<rootDir>/src/index.ts',
'^blockaid/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^blockaid/(.*)$': '<rootDir>/src/$1',
'^@blockaid/client$': '<rootDir>/src/index.ts',
'^@blockaid/client/_shims/auto/(.*)$': '<rootDir>/src/_shims/auto/$1-node',
'^@blockaid/client/(.*)$': '<rootDir>/src/$1',
},
modulePathIgnorePatterns: [
'<rootDir>/ecosystem-tests/',
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{
"name": "blockaid",
"version": "0.0.1-alpha.0",
"name": "@blockaid/client",
"version": "0.7.0",
"description": "The official TypeScript library for the Blockaid API",
"author": "Blockaid <[email protected]>",
"types": "dist/index.d.ts",
"main": "dist/index.js",
"type": "commonjs",
"repository": "github:stainless-sdks/blockaid-client-node",
"repository": "github:blockaid-official/blockaid-client-node",
"license": "Apache-2.0",
"packageManager": "[email protected]",
"files": [
Expand Down Expand Up @@ -61,8 +61,8 @@
"./shims/web.mjs"
],
"imports": {
"blockaid": ".",
"blockaid/*": "./src/*"
"@blockaid/client": ".",
"@blockaid/client/*": "./src/*"
},
"exports": {
"./_shims/auto/*": {
Expand Down
67 changes: 67 additions & 0 deletions release-please-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
{
"packages": {
".": {}
},
"$schema": "https://raw.githubusercontent.com/stainless-api/release-please/main/schemas/config.json",
"include-v-in-tag": true,
"include-component-in-tag": false,
"versioning": "prerelease",
"prerelease": true,
"bump-minor-pre-major": true,
"bump-patch-for-minor-pre-major": false,
"pull-request-header": "Automated Release PR",
"pull-request-title-pattern": "release: ${version}",
"changelog-sections": [
{
"type": "feat",
"section": "Features"
},
{
"type": "fix",
"section": "Bug Fixes"
},
{
"type": "perf",
"section": "Performance Improvements"
},
{
"type": "revert",
"section": "Reverts"
},
{
"type": "chore",
"section": "Chores"
},
{
"type": "docs",
"section": "Documentation"
},
{
"type": "style",
"section": "Styles"
},
{
"type": "refactor",
"section": "Refactors"
},
{
"type": "test",
"section": "Tests",
"hidden": true
},
{
"type": "build",
"section": "Build System"
},
{
"type": "ci",
"section": "Continuous Integration",
"hidden": true
}
],
"release-type": "node",
"extra-files": [
"src/version.ts",
"README.md"
]
}
6 changes: 3 additions & 3 deletions scripts/build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ node scripts/utils/check-version.cjs

# Build into dist and will publish the package from there,
# so that src/resources/foo.ts becomes <package root>/resources/foo.js
# This way importing from `"blockaid/resources/foo"` works
# This way importing from `"@blockaid/client/resources/foo"` works
# even with `"moduleResolution": "node"`

rm -rf dist; mkdir dist
Expand Down Expand Up @@ -47,8 +47,8 @@ node scripts/utils/postprocess-files.cjs

# make sure that nothing crashes when we require the output CJS or
# import the output ESM
(cd dist && node -e 'require("blockaid")')
(cd dist && node -e 'import("blockaid")' --input-type=module)
(cd dist && node -e 'require("@blockaid/client")')
(cd dist && node -e 'import("@blockaid/client")' --input-type=module)

if command -v deno &> /dev/null && [ -e ./scripts/build-deno ]
then
Expand Down
4 changes: 2 additions & 2 deletions scripts/utils/postprocess-files.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const fs = require('fs');
const path = require('path');
const { parse } = require('@typescript-eslint/parser');

const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? 'blockaid/';
const pkgImportPath = process.env['PKG_IMPORT_PATH'] ?? '@blockaid/client/';

const distDir =
process.env['DIST_PATH'] ?
Expand Down Expand Up @@ -142,7 +142,7 @@ async function postprocess() {

if (file.endsWith('.d.ts')) {
// work around bad tsc behavior
// if we have `import { type Readable } from 'blockaid/_shims/index'`,
// if we have `import { type Readable } from '@blockaid/client/_shims/index'`,
// tsc sometimes replaces `Readable` with `import("stream").Readable` inline
// in the output .d.ts
transformed = transformed.replace(/import\("stream"\).Readable/g, 'Readable');
Expand Down
Loading

0 comments on commit c262d44

Please sign in to comment.