Skip to content

Commit

Permalink
Release (#44)
Browse files Browse the repository at this point in the history
  • Loading branch information
rogaldh authored Mar 27, 2024
1 parent 9fe3306 commit 0de86bd
Show file tree
Hide file tree
Showing 37 changed files with 1,038 additions and 647 deletions.
10 changes: 10 additions & 0 deletions .changeset/config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://unpkg.com/@changesets/[email protected]/schema.json",
"changelog": "@changesets/cli/changelog",
"commit": false,
"fixed": [],
"linked": [],
"access": "restricted",
"baseBranch": "main",
"updateInternalDependencies": "patch"
}
37 changes: 37 additions & 0 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: 🐞 Bug Report
description: Create a bug report to help us improve
title: "bug: "
labels: ["🐞❔ unconfirmed bug"]
body:
- type: textarea
attributes:
label: Provide environment information
description: |
Run this command in your project root and paste the results in a code block:
```bash
npx envinfo --system --binaries
```
validations:
required: true
- type: textarea
attributes:
label: Describe the bug
description: A clear and concise description of the bug, as well as what you expected to happen when encountering it.
validations:
required: true
- type: input
attributes:
label: Link to reproduction
description: Please provide a link to a reproduction of the bug.
validations:
required: false
- type: textarea
attributes:
label: To reproduce
description: Describe how to reproduce your bug. Steps, code snippets, reproduction repos etc.
validations:
required: true
- type: textarea
attributes:
label: Additional information
description: Add any other information related to the bug here, screenshots if applicable.
30 changes: 30 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,36 @@ SOLANA_TOKEN_UPGRADE_CLI=<%path_to_upgrade_cli%> pnpx tsx ./scripts/issue-tokens
Do not forget to declare proper id at the [source code](https://github.com/solana-labs/solana-program-library/blob/master/token-upgrade/program/src/lib.rs#L15).

##### Example

Here is the sample of script's output.

```sh
Creating mint
Mint created: HoKw8CavcPjnd4QpFkvMyetz9bpQ9AqUJRjFqbjjnjqY
Creating ATA to hold the mint
Token Account Dejd9iw68G5wjtdu87b2qg2YcJJnruHNJQdJ8fPYbPs4 created
Creating mint
Mint created: DV389z9WBcYVmYLSBQCxi22mRv2pVosorqSMAuAJbTxQ
Creating ATA to hold the mint
Token-2022 Account 9jVB4ovwNaTnCZqXKDHTKHRh2fAG9PU4VCm3kjbDyP87 created
Creating account for holder to store the token
Holder account created
Minting 1 of HoKw8CavcPjnd4QpFkvMyetz9bpQ9AqUJRjFqbjjnjqY to ...
Token minted: ...
|> Creating escrow account CRsajQtD7ZknkfypD9FhPfVh7uLkLTdmTAwtiManXQd3 owned by escrow authority DV5egMMZKAMVkS3EBuM8tPWYfy4ioTtMNWXi788Fh8kC
Signature: 5g16wj4owBXF5fZJYkKSuGB4Zb3Fb7iNC9HzJdr4gCGYi5HPUQYbZ7gTGyb3GTdjuxeLAjs5CAdVgCchKxLfGVHc


Escrow account created: CRsajQtD7ZknkfypD9FhPfVh7uLkLTdmTAwtiManXQd3
Minting 1 of DV389z9WBcYVmYLSBQCxi22mRv2pVosorqSMAuAJbTxQ to escrow
Token minted to escrow: 2fdHGHQ7PVxjA1WmRiGvdqjVkrd3kzsUv5pztVTcDCAzWikeJ1cQpgYYVJvXRKaCL4R8P211xSNngeEY1EKQ5Dfm
Success. HoKw8CavcPjnd4QpFkvMyetz9bpQ9AqUJRjFqbjjnjqY is eligible for upgrade.
Use this query string for demonstration: "?token=HoKw8CavcPjnd4QpFkvMyetz9bpQ9AqUJRjFqbjjnjqY&tokenExt=DV389z9WBcYVmYLSBQCxi22mRv2pVosorqSMAuAJbTxQ&escrow=CRsajQtD7ZknkfypD9FhPfVh7uLkLTdmTAwtiManXQd3"
```

You may use QueryString sample from the stdout to fill the necessary fields at the demo application.

### Setup

```typescript
Expand Down
4 changes: 4 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,17 @@
"author": "",
"scripts": {
"build": "turbo run build",
"build-sb": "turbo run build-sb",
"changeset": "changeset",
"dev": "turbo run dev",
"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",
"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
@@ -0,0 +1,13 @@
# @solana/token-upgrade-app

## 1.0.0

### Major Changes

- Initial release

Contains:

- Demo application package
- UI package which contains needed components
- `issue-tokens.mts` script which allows to create proper accounts for upgrade process
5 changes: 1 addition & 4 deletions packages/app/src/app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import "./globals.css"
import * as React from "react"
import clsx from "clsx"
import { Inter } from "next/font/google"
import { Layout } from "../widgets/layout"
import { Metadata } from "next"

const inter = Inter({ subsets: ["latin"], variable: "--font-inter" })
Expand All @@ -18,9 +17,7 @@ export default function RootLayout({
return (
<html lang="en" className={clsx("h-full", inter.variable)}>
<body className="flex min-h-full bg-white antialiased dark:bg-zinc-900">
<div className="w-full">
<Layout>{children}</Layout>
</div>
<div className="w-full">{children}</div>
</body>
</html>
)
Expand Down
104 changes: 6 additions & 98 deletions packages/app/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,101 +1,9 @@
"use client"
import { TokenUpgrade, useNotificationContext } from "@solana/token-upgrade-ui"
import { Pattern } from "../shared/pattern"
import { TOKEN_UPGRADE_PROGRAM_ID } from "../env"
import { useCallback, useEffect, useState } from "react"
import ChangeCluster from "../features/change-cluster"
import Input from "../shared/input"
import * as web3 from "@solana/web3.js"
import dynamic from "next/dynamic"

export default function Home() {
const { setNotification } = useNotificationContext()

const _log = useCallback(
(msg: string) => {
setNotification({ message: msg })
globalThis.console.log(msg)
},
[setNotification],
)

const [token, setToken] = useState<web3.PublicKey>()
const [tokenExt, setTokenExt] = useState<web3.PublicKey>()
const [escrow, setEscrow] = useState<web3.PublicKey>()

useEffect(() => {
const url = new URLSearchParams(globalThis.location.search)
console.log(url.get("token"), url.get("tokenExt"), url.get("escrow"))
const NoSSRIndexEntrie = dynamic(() => import("../entries/index"), {
ssr: false,
})

const t = url.get("token")
const te = url.get("tokenExt")
const e = url.get("escrow")
if (t) setToken(new web3.PublicKey(t))
if (te) setTokenExt(new web3.PublicKey(te))
if (e) setEscrow(new web3.PublicKey(e))
}, [])

return (
<>
<Pattern />
<div className="prose py-2 dark:prose-invert">
<div className="container flex justify-center">
<TokenUpgrade
escrow={escrow?.toString()}
onUpgradeStart={() => _log("Upgrading token")}
onUpgradeEnd={({ signature }) =>
setNotification({
message: "Token upgraded",
link: `https://explorer.solana.com/tx/${signature}`,
})
}
onUpgradeError={(error) =>
_log(`Error: ${error.message || error.name}`)
}
tokenAddress={token?.toString()}
tokenExtAddress={tokenExt?.toString()}
tokenUpgradeProgramId={TOKEN_UPGRADE_PROGRAM_ID}
/>
</div>
</div>

<div className="light:text-black dark:text-white">
<div className="container flex flex-col items-center justify-center py-2">
<div className="min-w-80 pb-1.5 pt-2.5">
<Input
defaultValue={token?.toString()}
name="tokenAddress"
label="Token address"
onChange={(e) => {
setToken(new web3.PublicKey(e.target.value.trim()))
}}
placeholder="Paste here token address to update"
/>
</div>
<div className="min-w-80 pb-1.5 pt-2.5">
<Input
defaultValue={tokenExt?.toString()}
name="token2022Address"
label="Token Extension address"
onChange={(e) => {
setTokenExt(new web3.PublicKey(e.target.value.trim()))
}}
placeholder="Paste here token address to update"
/>
</div>
<div className="min-w-80 pb-1.5 pt-2.5">
<Input
defaultValue={escrow?.toString()}
name="escrow"
label="Escrow address"
onChange={(e) => {
setEscrow(new web3.PublicKey(e.target.value.trim()))
}}
placeholder="Paste here token address to update"
/>
</div>
<ChangeCluster className="min-w-80 pb-1.5 pt-2.5" />
</div>
</div>
</>
)
export default function Home() {
return <NoSSRIndexEntrie />
}
12 changes: 12 additions & 0 deletions packages/app/src/entries/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"use client"
import * as React from "react"
import { Layout } from "../features/layout"
import IndexPage from "../widgets/index-page"

export default function IndexEntrie() {
return (
<Layout>
<IndexPage />
</Layout>
)
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"use client"
import * as React from "react"
import { Header } from "../features/header"
import React from "react"
import { Header } from "./header"
import { motion } from "framer-motion"
import { AllProviders } from "../features/connect-providers"
import { AllProviders } from "./connect-providers"

export function Layout({ children }: Readonly<{ children: React.ReactNode }>) {
export function Layout({ children }: React.PropsWithChildren) {
return (
<AllProviders>
<div className="h-full">
Expand Down
111 changes: 111 additions & 0 deletions packages/app/src/widgets/index-page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
import * as web3 from "@solana/web3.js"
import ChangeCluster from "../features/change-cluster"
import Input from "../shared/input"
import { Pattern } from "../shared/pattern"
import { TOKEN_UPGRADE_PROGRAM_ID } from "../env"
import { TokenUpgrade, useNotificationContext } from "@solana/token-upgrade-ui"
import { useCallback, useEffect, useState } from "react"
import { useConnection } from "@solana/wallet-adapter-react"

function getCluster(rpc: string) {
function getMoniker(s: string): web3.Cluster | "custom" {
if (s === web3.clusterApiUrl("devnet")) return "devnet"
if (s === web3.clusterApiUrl("mainnet-beta")) return "mainnet-beta"
if (s === web3.clusterApiUrl("testnet")) return "testnet"
return "custom"
}
return getMoniker(rpc)
}

export default function IndexPage() {
const { connection } = useConnection()
const { setNotification } = useNotificationContext()

const _log = useCallback(
(msg: string) => {
setNotification({ message: msg })
globalThis.console.log(msg)
},
[setNotification],
)

const [token, setToken] = useState<web3.PublicKey>()
const [tokenExt, setTokenExt] = useState<web3.PublicKey>()
const [escrow, setEscrow] = useState<web3.PublicKey>()

useEffect(() => {
const url = new URLSearchParams(globalThis.location.search)

const t = url.get("token")
const te = url.get("tokenExt")
const e = url.get("escrow")
if (t) setToken(new web3.PublicKey(t))
if (te) setTokenExt(new web3.PublicKey(te))
if (e) setEscrow(new web3.PublicKey(e))
}, [])

return (
<>
<Pattern />
<div className="prose py-2 dark:prose-invert">
<div className="container flex justify-center">
<TokenUpgrade
escrow={escrow?.toString()}
onUpgradeStart={() => _log("Upgrading token")}
onUpgradeEnd={({ signature }) =>
setNotification({
message: "Token upgraded",
link: `https://explorer.solana.com/tx/${signature}?cluster=${getCluster(connection.rpcEndpoint)}`,
})
}
onUpgradeError={(error) =>
_log(`Error: ${error.message || error.name}`)
}
tokenAddress={token?.toString()}
tokenExtAddress={tokenExt?.toString()}
tokenUpgradeProgramId={TOKEN_UPGRADE_PROGRAM_ID}
/>
</div>
</div>

<div className="light:text-black dark:text-white">
<div className="container flex flex-col items-center justify-center py-2">
<div className="min-w-80 pb-1.5 pt-2.5">
<Input
defaultValue={token?.toString()}
name="tokenAddress"
label="Token address"
onChange={(e) => {
setToken(new web3.PublicKey(e.target.value.trim()))
}}
placeholder="Paste here token address to update"
/>
</div>
<div className="min-w-80 pb-1.5 pt-2.5">
<Input
defaultValue={tokenExt?.toString()}
name="token2022Address"
label="Token Extension address"
onChange={(e) => {
setTokenExt(new web3.PublicKey(e.target.value.trim()))
}}
placeholder="Paste here token address to update"
/>
</div>
<div className="min-w-80 pb-1.5 pt-2.5">
<Input
defaultValue={escrow?.toString()}
name="escrow"
label="Escrow address"
onChange={(e) => {
setEscrow(new web3.PublicKey(e.target.value.trim()))
}}
placeholder="Paste here token address to update"
/>
</div>
<ChangeCluster className="min-w-80 pb-1.5 pt-2.5" />
</div>
</div>
</>
)
}
13 changes: 13 additions & 0 deletions packages/shared/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# token-upgrade-ui-shared

## 1.0.0

### Major Changes

- Initial release

Contains:

- Demo application package
- UI package which contains needed components
- `issue-tokens.mts` script which allows to create proper accounts for upgrade process
Loading

0 comments on commit 0de86bd

Please sign in to comment.