Skip to content

Commit 3920cc8

Browse files
authored
Feature/refactor types (#50)
* feat: implement headless hooks and types * feat: add blink list hook, adjust naming * chore: BREAKING: rename most of the instances from `*action*` to `*blink*`. Most have fallbacks to old naming, but `action` prop is now renamed to `blink` for Blink components * feat: add ability to hide website url row by passing `false` to `websiteText` * feat: pass through resolved blinkApiUrl from useBlink * chore: rename BlinkConfig to BlinkSolanaConfig, move BlinkAdapter to a separate file, rename Action folder to BlinkInstance, minor adjustments * chore: rename Provider type to BlinkProvider * feat: no proxy wrap, if requests are made to dial.to service * chore: log adjustments * chore: add missing export * docs: adjust readme * fix: align types * fix: adjust blink list entry type * feat: add class names to blink elements * chore: missing rename * chore: adjust blink preview response type * docs: adjust formatting in readme
1 parent 9dd6402 commit 3920cc8

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+1175
-618
lines changed

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ Package provides an entrypoint function with styled for X Blink components
103103
```ts
104104
// contentScript.ts
105105
import { setupTwitterObserver } from "@dialectlabs/blinks/ext/twitter";
106-
import { ActionConfig } from "@dialectlabs/blinks";
106+
import { BlinkSolanaConfig } from "@dialectlabs/blinks";
107107

108108
// your RPC_URL is used to create a connection to confirm the transaction after action execution
109-
setupTwitterObserver(new ActionConfig(RPC_URL, {
109+
setupTwitterObserver(new BlinkSolanaConfig(RPC_URL, {
110110
metadata: {
111111
supportedBlockchainIds: [BlockchainIds.SOLANA_MAINNET]
112112
},
@@ -116,21 +116,25 @@ setupTwitterObserver(new ActionConfig(RPC_URL, {
116116

117117
// or
118118

119-
import { type ActionAdapter } from "@dialectlabs/blinks";
119+
import type { BlinkAdapter, BlinkAdapterMetadata } from "@dialectlabs/blinks";
120120

121-
class MyActionAdapter implements ActionAdapter {
121+
class MyBlinkAdapter implements BlinkAdapter {
122122
async connect() { ... }
123+
123124
async signTransaction(tx: string) { ... }
125+
124126
async confirmTransaction(sig: string) { ... }
125-
get metadata(): ActionAdapterMetadata {
127+
128+
get metadata(): BlinkAdapterMetadata {
126129
return {
127130
supportedBlockchainIds: [BlockchainIds.SOLANA_MAINNET],
128131
};
129132
}
133+
130134
async signMessage(data: string | SignMessageData) { ... }
131135
}
132136

133-
setupTwitterObserver(new MyActionAdapter());
137+
setupTwitterObserver(new MyBlinkAdapter());
134138
```
135139

136140
#### Manifest

bun.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"packages/blinks": {
4848
"name": "@dialectlabs/blinks",
49-
"version": "0.20.1",
49+
"version": "0.20.2",
5050
"dependencies": {
5151
"@dialectlabs/blinks-core": "packages/blinks-core",
5252
"bs58": "^6.0.0",

examples/mini-blinks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"preview": "vite preview"
1111
},
1212
"dependencies": {
13-
"@dialectlabs/blinks": "0.20.0",
13+
"@dialectlabs/blinks": "^0.20.2",
1414
"@solana/wallet-adapter-react": "^0.15.0",
1515
"@solana/wallet-adapter-react-ui": "^0.9.0",
1616
"@solana/web3.js": "^1.95.1",

examples/mini-blinks/src/App.tsx

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import {
22
Miniblink,
3-
useAction,
4-
useActionsRegistryInterval,
3+
useBlink,
4+
useBlinksRegistryInterval,
55
} from '@dialectlabs/blinks';
6-
import { useActionSolanaWalletAdapter } from '@dialectlabs/blinks/hooks/solana';
6+
import { useBlinkSolanaWalletAdapter } from '@dialectlabs/blinks/hooks/solana';
77
import '@dialectlabs/blinks/index.css';
88
import { WalletMultiButton } from '@solana/wallet-adapter-react-ui';
99
import '@solana/wallet-adapter-react-ui/styles.css';
1010

1111
function App() {
12-
useActionsRegistryInterval();
12+
useBlinksRegistryInterval();
1313

14-
const { adapter } = useActionSolanaWalletAdapter(
14+
const { adapter } = useBlinkSolanaWalletAdapter(
1515
import.meta.env.VITE_PUBLIC_RPC_URL,
1616
);
17-
const { action, isLoading } = useAction({
17+
const { blink, isLoading } = useBlink({
1818
url: 'solana-action:https://dial.to/api/donate',
1919
});
2020

@@ -23,15 +23,15 @@ function App() {
2323
<div className="flex min-w-[400px] flex-col items-center">
2424
<h1 className="mb-4 text-center text-4xl font-bold">Mini Blinks</h1>
2525
<div className="mb-4 w-full">
26-
{isLoading || !action ? (
26+
{isLoading || !blink ? (
2727
<span>Loading</span>
2828
) : (
2929
<Miniblink
3030
adapter={adapter}
3131
selector={(currentAction) =>
3232
currentAction.actions.find((a) => a.label === 'Donate')!
3333
}
34-
action={action}
34+
blink={blink}
3535
/>
3636
)}
3737
</div>

packages/blinks-core/package.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,11 @@
1717
"module": "dist/index.js",
1818
"types": "dist/index.d.ts",
1919
"exports": {
20+
"./api": {
21+
"import": "./dist/service-api/index.js",
22+
"require": "./dist/service-api/index.cjs",
23+
"types": "./dist/service-api/index.d.ts"
24+
},
2025
".": {
2126
"import": "./dist/index.js",
2227
"require": "./dist/index.cjs",

0 commit comments

Comments
 (0)