Skip to content

Commit 07711f1

Browse files
authored
feat: align chaining for message signing with spec 2.4.2 (#36)
* bump actions spec to 2.4.2 * relay back 'data' attribute in message signing chain request
1 parent 09444c2 commit 07711f1

File tree

5 files changed

+31
-8
lines changed

5 files changed

+31
-8
lines changed

bun.lockb

0 Bytes
Binary file not shown.

packages/blinks-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"dist"
2828
],
2929
"devDependencies": {
30-
"@solana/actions-spec": "~2.4.1",
30+
"@solana/actions-spec": "~2.4.2",
3131
"@types/react": "^18.3.3",
3232
"@types/react-dom": "^18.3.0",
3333
"@typescript-eslint/eslint-plugin": "^7.16.1",

packages/blinks-core/src/BlinkContainer.tsx

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
import type {
2+
MessageNextActionPostRequest,
3+
NextActionPostRequest,
4+
} from '@solana/actions-spec';
15
import {
26
type ComponentType,
37
useEffect,
@@ -492,12 +496,28 @@ export const BlinkContainer = ({
492496
return;
493497
}
494498

499+
if (response.type === 'message' && !signature) {
500+
dispatch({
501+
type: ExecutionType.SOFT_RESET,
502+
errorMessage: 'Missing signature for message',
503+
});
504+
return;
505+
}
506+
495507
// chain
496-
const nextAction = await action.chain(response.links.next, {
497-
signature: signature,
498-
account: account,
499-
state: response.type === 'message' ? response.state : undefined,
500-
});
508+
const chainData: MessageNextActionPostRequest | NextActionPostRequest =
509+
response.type === 'message'
510+
? {
511+
signature: signature!,
512+
account: account,
513+
state: response.state,
514+
data: response.data,
515+
}
516+
: {
517+
signature: signature,
518+
account: account,
519+
};
520+
const nextAction = await action.chain(response.links.next, chainData);
501521

502522
// if this is running in partial action mode, then we end the chain, if passed fn returns a null value for the next action
503523
if (!nextAction || (isPartialAction && !selector?.(nextAction))) {

packages/blinks-core/src/api/Action/Action.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import type { MessageNextActionPostRequest } from '@solana/actions-spec';
12
import { nanoid } from 'nanoid/non-secure';
23
import { proxify, proxifyImage } from '../../utils';
34
import { isUrlSameOrigin } from '../../utils/security.ts';
@@ -179,7 +180,9 @@ export class Action {
179180

180181
public async chain<N extends NextActionLink>(
181182
next: N,
182-
chainData?: N extends PostNextActionLink ? NextActionPostRequest : never,
183+
chainData?: N extends PostNextActionLink
184+
? MessageNextActionPostRequest | NextActionPostRequest
185+
: never,
183186
): Promise<Action | null> {
184187
const id = nanoid();
185188

packages/blinks/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
"dist"
3939
],
4040
"devDependencies": {
41-
"@solana/actions-spec": "~2.4.1",
41+
"@solana/actions-spec": "~2.4.2",
4242
"@types/react": "^18.3.3",
4343
"@types/react-dom": "^18.3.0",
4444
"@typescript-eslint/eslint-plugin": "^7.16.1",

0 commit comments

Comments
 (0)