Skip to content

Commit

Permalink
Release v1.1.0 (#45)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogaldh authored Mar 29, 2024
1 parent 0de86bd commit cf246db
Show file tree
Hide file tree
Showing 36 changed files with 4,364 additions and 264 deletions.
100 changes: 0 additions & 100 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
1 change: 1 addition & 0 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
book
6 changes: 6 additions & 0 deletions docs/book.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[book]
authors = []
language = "en"
multilingual = false
src = "src"
title = "Token Upgrade UI"
3 changes: 3 additions & 0 deletions docs/src/SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Summary

- [Introduction](./index.md)
162 changes: 162 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
# Introduction

[Token Upgrade UI](https://github.com/hoodieshq/token-upgrade-ui) provides a client interface to upgrade tokens to the new format of a token ([Token Extension](https://solana.com/solutions/token-extensions)).

## Contents

### 🚀 `packages/app`

Demo application powered by [Next.js](https://nextjs.org).

It demonstrates how to integrate the [`TokenUpgrade`](https://github.com/hoodieshq/token-upgrade-ui/blob/main/packages/app/src/widgets/index-page.tsx#L52-L67) component and its functionality into a project with [React](https://react.dev) under the hood.

Use the button down here to launch it on [Vercel](https://vercel.com).

[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fhoodieshq%2Ftoken-upgrade-ui&env=NEXT_PUBLIC_TOKEN_UPGRADE_PROGRAM_ID&envDescription=Upgrade%20Program%20Address&project-name=solana-token-upgrade-app&repository-name=solana-token-upgrade-app&demo-title=Token%20Upgrade%20UI&demo-description=App%20to%20Upgrade%20Token%20on%20Solana%20Blockchain)

Bear in mind it will require some configuration:

- Set `NEXT_PUBLIC_TOKEN_UPGRADE_PROGRAM_ID` environment variable and provide the address of the deployed [`token-upgrade`](https://github.com/solana-labs/solana-program-library/tree/master/token-upgrade) program.
- The [root directory](https://vercel.com/docs/deployments/configure-a-build#root-directory) should lead to the `packages/app` directory.
- `[email protected]`

#### Usage

To upgrade a token except for the program, you should have:
- replacement token (Token Extension)
- escrow account
- escrow should have enough replacement tokens for future upgrades

To create a replacement token, you use `@solana/spl-token`.

The [`spl-token-upgrade`](https://github.com/solana-labs/solana-program-library/tree/master/token-upgrade/cli) CLI creates an escrow.

Having all these, you can mint some tokens with ease.

There is a `scripts/issue-tokens.mts` script to demonstrate the complete flow. It will create all the needed tokens and accounts. The same is true for minting. You can use it on `devnet` like so:

```sh
SOLANA_TOKEN_UPGRADE_CLI=<%path_to_upgrade_cli%> \
pnpx tsx ./scripts/issue-tokens.mts $HOLDER_ADDRESS
```
- `HOLDER_ADDRESS` - wallet to hold tokens
- `<%path_to_upgrade_cli%>` - path to a `spl-token-upgrade` cli at your system

> Do not forget to declare the proper ID for your [source code](https://github.com/solana-labs/solana-program-library/blob/master/token-upgrade/program/src/lib.rs#L15) version.
Upon execution, the script will provide a query string with all the needed addresses. You can launch the application and paste it into a browser.

### ⚙️ `packages/ui`

The package contains the `TokenUpgrade` component and the blocks from which it is built.

#### Basic usage

Use this sample to integrate the component.

```typescript
import { TokenUpgrade } from "@solana/token-upgrade-ui"

const OuterComponent = () => (
<TokenUpgrade
escrow={/* escrow address */}
onUpgradeStart={() =>
console.log({ message: "Upgrading token..." })
}
onUpgradeEnd={({ signature }) =>
console.log({
message: "Token upgraded",
link: `https://explorer.solana.com/tx/${signature}`,
})
}
tokenAddress={/* token address to upgrade */}
tokenExtAddress={/* token extension address */}
tokenUpgradeProgramId={/* deployed upgrade program address */}
/>
)
```

If you do not need the UI, core functions can be used.

```typescript
import {
createUpgradeTokenInstruction, // construct upgrade instruction
upgradeToken, // build upgrade transaction
useTokenUpgrade // hook to upgrade a token
} from "@solana/token-upgrade-ui"
```

### 🔒 `packages/shared`

Shared configuration for both packages.

## Development

### 🛠️ Setup

```sh
pnpm it
# Install & check
```

### 💪 Build

```sh
pnpm dev
# Launch the demo application in watch mode.
# Scripts will track changes.
# Use it for development
```

```sh
pnpm playground
# Launch Storybook. Use it to improve UI for components.
```

### 📋 Test & Quality control

```sh
pnpm lint
# Check code style
```

```sh
pnpm --filter "*" lint-fix
# Linting the source code
```

```sh
pnpm --filter "@solana/*ui" local:test-e2e
# Test the `upgrade token` scenario.
# To run this properly env variables shall be tweaked.
# See `packages/ui/tests/e2e.test.ts` for more info
```

```sh
pnpm --filter "@solana/*ui" local:test-smoke
# Run UI tests
```

### 📦 Release

```sh
pnpm build
# Build UI for a production
```

```sh
pnpm build-sb
# Build Storybook's artifacts
```

```sh
pnpm changeset $COMMAND
# Use `changeset` to prepare for a release
```

### 📒 Documentation

```sh
pnpm run docs
# Launch documentation
```
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "token-upgrade-ui",
"version": "1.0.0",
"version": "1.1.0",
"private": true,
"description": "",
"keywords": [
Expand All @@ -14,14 +14,15 @@
"build-sb": "turbo run build-sb",
"changeset": "changeset",
"dev": "turbo run dev",
"docs": "mdbook serve docs --open",
"lint": "turbo run lint",
"playground": "turbo run storybook",
"test": "manypkg check && turbo run test"
},
"dependencies": {
"@changesets/cli": "^2.27.1",
"@manypkg/cli": "^0.21.2",
"@solana/token-upgrade-ui": "1.0.0",
"@solana/token-upgrade-ui": "1.1.0",
"prettier": "^3.2.5",
"rimraf": "^5.0.5",
"turbo": "^1.13.0"
Expand Down
13 changes: 13 additions & 0 deletions packages/app/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
# @solana/token-upgrade-app

## 1.1.0

### Minor Changes

- - Use proper `amount` for upgrade
- Add docs
- Improve tests

### Patch Changes

- Updated dependencies
- @solana/token-upgrade-ui@1.1.0

## 1.0.0

### Major Changes
Expand Down
1 change: 0 additions & 1 deletion packages/app/env.local

This file was deleted.

4 changes: 2 additions & 2 deletions packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@solana/token-upgrade-app",
"version": "1.0.0",
"version": "1.1.0",
"private": true,
"description": "",
"keywords": [
Expand All @@ -21,7 +21,7 @@
"dependencies": {
"@headlessui/react": "^1.7.18",
"@solana/spl-token": "^0.4.1",
"@solana/token-upgrade-ui": "1.0.0",
"@solana/token-upgrade-ui": "1.1.0",
"@solana/wallet-adapter-base": "^0.9.23",
"@solana/wallet-adapter-react": "^0.15.35",
"@solana/wallet-adapter-react-ui": "^0.9.35",
Expand Down
Loading

0 comments on commit cf246db

Please sign in to comment.