@farcaster/frame-core 0.0.29 → 0.0.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/dist/actions/ComposeCast.d.ts +32 -0
- package/dist/actions/ComposeCast.js +2 -0
- package/dist/actions/index.d.ts +1 -0
- package/dist/actions/index.js +2 -1
- package/dist/errors.d.ts +3 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +3 -1
- package/dist/manifest.d.ts +101 -0
- package/dist/manifest.js +2 -0
- package/dist/schemas/shared.js +1 -1
- package/dist/types.d.ts +3 -1
- package/esm/actions/AddFrame.d.ts +23 -27
- package/esm/actions/AddFrame.js +9 -9
- package/esm/actions/ComposeCast.d.ts +32 -0
- package/esm/actions/ComposeCast.js +1 -0
- package/esm/actions/Ready.d.ts +11 -11
- package/esm/actions/Ready.js +2 -2
- package/esm/actions/SignIn.d.ts +33 -35
- package/esm/actions/SignIn.js +5 -5
- package/esm/actions/Swap.d.ts +43 -44
- package/esm/actions/Swap.js +1 -1
- package/esm/actions/ViewProfile.d.ts +3 -3
- package/esm/actions/ViewProfile.js +1 -1
- package/esm/actions/ViewToken.d.ts +3 -3
- package/esm/actions/ViewToken.js +1 -1
- package/esm/actions/index.d.ts +7 -6
- package/esm/actions/index.js +7 -6
- package/esm/context.d.ts +61 -65
- package/esm/context.js +1 -1
- package/esm/errors.d.ts +10 -9
- package/esm/errors.js +6 -6
- package/esm/index.d.ts +7 -5
- package/esm/index.js +7 -5
- package/esm/internal/types.d.ts +7 -18
- package/esm/internal/types.js +1 -1
- package/esm/manifest.d.ts +101 -0
- package/esm/manifest.js +1 -0
- package/esm/schemas/embeds.d.ts +239 -346
- package/esm/schemas/embeds.js +23 -31
- package/esm/schemas/events.d.ts +129 -225
- package/esm/schemas/events.js +17 -17
- package/esm/schemas/index.d.ts +5 -5
- package/esm/schemas/index.js +5 -5
- package/esm/schemas/manifest.d.ts +110 -154
- package/esm/schemas/manifest.js +23 -29
- package/esm/schemas/notifications.d.ts +58 -86
- package/esm/schemas/notifications.js +17 -17
- package/esm/schemas/shared.d.ts +35 -53
- package/esm/schemas/shared.js +23 -25
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/esm/types.d.ts +53 -70
- package/esm/types.js +2 -2
- package/esm/wallet/ethereum.d.ts +35 -50
- package/esm/wallet/ethereum.js +1 -1
- package/esm/wallet/index.d.ts +1 -1
- package/esm/wallet/index.js +1 -1
- package/package.json +1 -1
- package/src/actions/ComposeCast.ts +36 -0
- package/src/actions/index.ts +1 -0
- package/src/errors.ts +4 -0
- package/src/index.ts +2 -0
- package/src/manifest.ts +113 -0
- package/src/schemas/shared.ts +1 -1
- package/src/types.ts +7 -0
package/esm/types.d.ts
CHANGED
|
@@ -1,75 +1,58 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Swap,
|
|
6
|
-
ViewProfile,
|
|
7
|
-
ViewToken,
|
|
8
|
-
} from './actions'
|
|
9
|
-
import type { FrameContext } from './context'
|
|
10
|
-
import type {
|
|
11
|
-
EventFrameAdded,
|
|
12
|
-
EventFrameRemoved,
|
|
13
|
-
EventNotificationsDisabled,
|
|
14
|
-
EventNotificationsEnabled,
|
|
15
|
-
} from './schemas'
|
|
16
|
-
import type { Ethereum } from './wallet'
|
|
1
|
+
import type { AddFrame, ComposeCast, Ready, SignIn, Swap, ViewProfile, ViewToken } from './actions';
|
|
2
|
+
import type { FrameContext } from './context';
|
|
3
|
+
import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
|
|
4
|
+
import type { Ethereum } from './wallet';
|
|
17
5
|
export type SetPrimaryButtonOptions = {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
23
|
-
export * from './wallet/ethereum'
|
|
24
|
-
export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready'
|
|
25
|
-
export type SignInOptions = SignIn.SignInOptions
|
|
26
|
-
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
|
|
6
|
+
text: string;
|
|
7
|
+
loading?: boolean;
|
|
8
|
+
disabled?: boolean;
|
|
9
|
+
hidden?: boolean;
|
|
10
|
+
};
|
|
11
|
+
export * from './wallet/ethereum';
|
|
12
|
+
export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready';
|
|
13
|
+
export type SignInOptions = SignIn.SignInOptions;
|
|
14
|
+
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
|
|
27
15
|
export type WireFrameHost = {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
16
|
+
context: FrameContext;
|
|
17
|
+
close: () => void;
|
|
18
|
+
ready: Ready.Ready;
|
|
19
|
+
openUrl: (url: string) => void;
|
|
20
|
+
signIn: SignIn.WireSignIn;
|
|
21
|
+
setPrimaryButton: SetPrimaryButton;
|
|
22
|
+
ethProviderRequest: Ethereum.EthProvideRequest;
|
|
23
|
+
ethProviderRequestV2: Ethereum.RpcTransport;
|
|
24
|
+
eip6963RequestProvider: () => void;
|
|
25
|
+
addFrame: AddFrame.WireAddFrame;
|
|
26
|
+
viewProfile: ViewProfile.ViewProfile;
|
|
27
|
+
viewToken: ViewToken.ViewToken;
|
|
28
|
+
swap: Swap.Swap;
|
|
29
|
+
composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
|
|
30
|
+
};
|
|
42
31
|
export type FrameHost = {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
32
|
+
context: FrameContext;
|
|
33
|
+
close: () => void;
|
|
34
|
+
ready: Ready.Ready;
|
|
35
|
+
openUrl: (url: string) => void;
|
|
36
|
+
signIn: SignIn.SignIn;
|
|
37
|
+
setPrimaryButton: SetPrimaryButton;
|
|
38
|
+
ethProviderRequest: Ethereum.EthProvideRequest;
|
|
39
|
+
ethProviderRequestV2: Ethereum.RpcTransport;
|
|
40
|
+
/**
|
|
41
|
+
* Receive forwarded eip6963:requestProvider events from the frame document.
|
|
42
|
+
* Hosts must emit an EventEip6963AnnounceProvider in response.
|
|
43
|
+
*/
|
|
44
|
+
eip6963RequestProvider: () => void;
|
|
45
|
+
addFrame: AddFrame.AddFrame;
|
|
46
|
+
viewProfile: ViewProfile.ViewProfile;
|
|
47
|
+
viewToken: ViewToken.ViewToken;
|
|
48
|
+
swap: Swap.Swap;
|
|
49
|
+
composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
|
|
50
|
+
};
|
|
61
51
|
export type EventFrameAddRejected = {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
52
|
+
event: 'frame_add_rejected';
|
|
53
|
+
reason: AddFrame.AddFrameRejectedReason;
|
|
54
|
+
};
|
|
65
55
|
export type EventPrimaryButtonClicked = {
|
|
66
|
-
|
|
67
|
-
}
|
|
68
|
-
export type FrameClientEvent =
|
|
69
|
-
| EventFrameAdded
|
|
70
|
-
| EventFrameAddRejected
|
|
71
|
-
| EventFrameRemoved
|
|
72
|
-
| EventNotificationsEnabled
|
|
73
|
-
| EventNotificationsDisabled
|
|
74
|
-
| EventPrimaryButtonClicked
|
|
75
|
-
| Ethereum.EventEip6963AnnounceProvider
|
|
56
|
+
event: 'primary_button_clicked';
|
|
57
|
+
};
|
|
58
|
+
export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | Ethereum.EventEip6963AnnounceProvider;
|
package/esm/types.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
// start backwards compat, remove in 1.0
|
|
2
|
-
export * from './wallet/ethereum'
|
|
3
|
-
export { DEFAULT_READY_OPTIONS } from './actions/Ready'
|
|
2
|
+
export * from './wallet/ethereum';
|
|
3
|
+
export { DEFAULT_READY_OPTIONS } from './actions/Ready';
|
package/esm/wallet/ethereum.d.ts
CHANGED
|
@@ -1,58 +1,43 @@
|
|
|
1
|
-
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
|
|
2
|
-
export type EthProvideRequest<
|
|
3
|
-
schema extends RpcSchema.Generic = RpcSchema.Default,
|
|
4
|
-
> = Provider.RequestFn<schema>
|
|
1
|
+
import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
|
|
2
|
+
export type EthProvideRequest<schema extends RpcSchema.Generic = RpcSchema.Default> = Provider.RequestFn<schema>;
|
|
5
3
|
export type FrameEthProviderEventData = {
|
|
6
|
-
|
|
7
|
-
} & EthProviderWireEvent
|
|
8
|
-
export type RpcTransport = (
|
|
9
|
-
request: RpcRequest.RpcRequest,
|
|
10
|
-
) => Promise<RpcResponse.RpcResponse>
|
|
4
|
+
type: 'frame_eth_provider_event';
|
|
5
|
+
} & EthProviderWireEvent;
|
|
6
|
+
export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
|
|
11
7
|
export type ProviderRpcError = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
export type EthProviderWireEvent =
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
params: [Provider.Message]
|
|
36
|
-
}
|
|
37
|
-
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
|
|
38
|
-
event: event,
|
|
39
|
-
params: Extract<
|
|
40
|
-
EthProviderWireEvent,
|
|
41
|
-
{
|
|
42
|
-
event: event
|
|
43
|
-
}
|
|
44
|
-
>['params'],
|
|
45
|
-
) => void
|
|
8
|
+
code: number;
|
|
9
|
+
details?: string;
|
|
10
|
+
message?: string;
|
|
11
|
+
};
|
|
12
|
+
export type EthProviderWireEvent = {
|
|
13
|
+
event: 'accountsChanged';
|
|
14
|
+
params: [readonly Address.Address[]];
|
|
15
|
+
} | {
|
|
16
|
+
event: 'chainChanged';
|
|
17
|
+
params: [string];
|
|
18
|
+
} | {
|
|
19
|
+
event: 'connect';
|
|
20
|
+
params: [Provider.ConnectInfo];
|
|
21
|
+
} | {
|
|
22
|
+
event: 'disconnect';
|
|
23
|
+
params: [ProviderRpcError];
|
|
24
|
+
} | {
|
|
25
|
+
event: 'message';
|
|
26
|
+
params: [Provider.Message];
|
|
27
|
+
};
|
|
28
|
+
export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
|
|
29
|
+
event: event;
|
|
30
|
+
}>['params']) => void;
|
|
46
31
|
/**
|
|
47
32
|
* Metadata of the EIP-1193 Provider.
|
|
48
33
|
*/
|
|
49
34
|
export interface EIP6963ProviderInfo {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
35
|
+
icon: `data:image/${string}`;
|
|
36
|
+
name: string;
|
|
37
|
+
rdns: string;
|
|
38
|
+
uuid: string;
|
|
54
39
|
}
|
|
55
40
|
export type EventEip6963AnnounceProvider = {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}
|
|
41
|
+
event: 'eip6963:announceProvider';
|
|
42
|
+
info: EIP6963ProviderInfo;
|
|
43
|
+
};
|
package/esm/wallet/ethereum.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {}
|
|
1
|
+
export {};
|
package/esm/wallet/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as Ethereum from './ethereum'
|
|
1
|
+
export * as Ethereum from './ethereum';
|
package/esm/wallet/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export * as Ethereum from './ethereum'
|
|
1
|
+
export * as Ethereum from './ethereum';
|
package/package.json
CHANGED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type Options<close extends boolean | undefined = undefined> = {
|
|
2
|
+
/**
|
|
3
|
+
* Suggested text for the body of the cast.
|
|
4
|
+
*
|
|
5
|
+
* Mentions can be included using the human-writeable form (e.g. @farcaster).
|
|
6
|
+
**/
|
|
7
|
+
text?: string
|
|
8
|
+
|
|
9
|
+
/** Suggested embeds. Max two. */
|
|
10
|
+
embeds?: [] | [string] | [string, string]
|
|
11
|
+
|
|
12
|
+
/** Suggested parent. */
|
|
13
|
+
parent?: { type: 'cast'; hash: string }
|
|
14
|
+
|
|
15
|
+
/** Whether the app should be closed when this action is called. */
|
|
16
|
+
close?: close
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export type Result<close extends boolean | undefined = undefined> =
|
|
20
|
+
close extends true
|
|
21
|
+
? undefined
|
|
22
|
+
: {
|
|
23
|
+
cast: {
|
|
24
|
+
/** Cast of the created cast */
|
|
25
|
+
hash: string
|
|
26
|
+
|
|
27
|
+
/** Text of the created cast */
|
|
28
|
+
text?: string
|
|
29
|
+
|
|
30
|
+
/** Embeds of the created cast */
|
|
31
|
+
embeds?: [] | [string] | [string, string]
|
|
32
|
+
|
|
33
|
+
/** Parent of the created cast */
|
|
34
|
+
parent?: { type: 'cast'; hash: string }
|
|
35
|
+
}
|
|
36
|
+
}
|
package/src/actions/index.ts
CHANGED
package/src/errors.ts
CHANGED
package/src/index.ts
CHANGED
package/src/manifest.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Farcaster manifest for a domain hosted at `/.well-known/farcaster.json`
|
|
3
|
+
*/
|
|
4
|
+
export type Manifest = {
|
|
5
|
+
accountAssociation: AccountAssociation
|
|
6
|
+
frame: FrameConfig
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Signed domain association linking this frame to a Farcaster account
|
|
11
|
+
*
|
|
12
|
+
* A DomainAssociation can be generated using the {@link https://warpcast.com/~/developers/domains | Warpcast
|
|
13
|
+
* Domains Developer} tool.
|
|
14
|
+
*/
|
|
15
|
+
export type AccountAssociation = {
|
|
16
|
+
/**
|
|
17
|
+
* Base64URL encoded JFS signature
|
|
18
|
+
*/
|
|
19
|
+
header: string
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Base64URL encoded payload signature
|
|
23
|
+
*/
|
|
24
|
+
payload: string
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Base64URL encoded signature
|
|
28
|
+
*/
|
|
29
|
+
signature: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Frame configuration
|
|
34
|
+
*
|
|
35
|
+
* @example
|
|
36
|
+
* ``ts
|
|
37
|
+
* const frame: FrameConfig = {
|
|
38
|
+
* version: '1',
|
|
39
|
+
* name: 'Yoink!',
|
|
40
|
+
* homeUrl: 'https://yoink.party',
|
|
41
|
+
* iconUrl: 'https://yoink.party/img/icon.png',
|
|
42
|
+
* imageUrl: 'https://yoink.party/framesV2/opengraph-image',
|
|
43
|
+
* buttonTitle: '🚩 Start',
|
|
44
|
+
* splashImageUrl: 'https://yoink.party/img/splash.png',
|
|
45
|
+
* splashImageBackgroundColor: '#eeeee4',
|
|
46
|
+
* webhookUrl: 'https://yoink.party/webhook'
|
|
47
|
+
* };
|
|
48
|
+
* ``
|
|
49
|
+
*/
|
|
50
|
+
export type FrameConfig = {
|
|
51
|
+
/**
|
|
52
|
+
* Manifest version
|
|
53
|
+
*
|
|
54
|
+
* Must be the literal '1'.
|
|
55
|
+
*/
|
|
56
|
+
version: '1'
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* App name that will be displayed to users
|
|
60
|
+
*
|
|
61
|
+
* Max length of 32 characters.
|
|
62
|
+
*/
|
|
63
|
+
name: string
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Default launch URL
|
|
67
|
+
*
|
|
68
|
+
* Max length of 1024 characters.
|
|
69
|
+
*/
|
|
70
|
+
homeUrl: string
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Icon URL
|
|
74
|
+
*
|
|
75
|
+
* Max length of 1024 characters. Image must be 200x200px and less than 1MB.
|
|
76
|
+
*/
|
|
77
|
+
iconUrl: string
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Image URL
|
|
81
|
+
*
|
|
82
|
+
* Max length of 1024 characters. Image must have a 3:2 ratio.
|
|
83
|
+
*/
|
|
84
|
+
imageUrl: string
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Default button title to use when frame is rendered.
|
|
88
|
+
*
|
|
89
|
+
* Max length of 32 characters.
|
|
90
|
+
*/
|
|
91
|
+
buttonTitle: string
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Splash image URL
|
|
95
|
+
*
|
|
96
|
+
* Max length of 1024 characters. Image must be 200x200px and less than 1MB.
|
|
97
|
+
*/
|
|
98
|
+
splashImageUrl?: string
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Splash background color
|
|
102
|
+
*
|
|
103
|
+
* Must be a hex color code.
|
|
104
|
+
*/
|
|
105
|
+
splashBackgroundColor?: string
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* URL to which clients will POST server events.
|
|
109
|
+
* Max length of 1024 characters.
|
|
110
|
+
* Required if the frame application uses notifications.
|
|
111
|
+
*/
|
|
112
|
+
webhookUrl?: string
|
|
113
|
+
}
|
package/src/schemas/shared.ts
CHANGED
package/src/types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type {
|
|
2
2
|
AddFrame,
|
|
3
|
+
ComposeCast,
|
|
3
4
|
Ready,
|
|
4
5
|
SignIn,
|
|
5
6
|
Swap,
|
|
@@ -44,6 +45,9 @@ export type WireFrameHost = {
|
|
|
44
45
|
viewProfile: ViewProfile.ViewProfile
|
|
45
46
|
viewToken: ViewToken.ViewToken
|
|
46
47
|
swap: Swap.Swap
|
|
48
|
+
composeCast: <close extends boolean | undefined = undefined>(
|
|
49
|
+
options: ComposeCast.Options<close>,
|
|
50
|
+
) => Promise<ComposeCast.Result<close>>
|
|
47
51
|
}
|
|
48
52
|
|
|
49
53
|
export type FrameHost = {
|
|
@@ -64,6 +68,9 @@ export type FrameHost = {
|
|
|
64
68
|
viewProfile: ViewProfile.ViewProfile
|
|
65
69
|
viewToken: ViewToken.ViewToken
|
|
66
70
|
swap: Swap.Swap
|
|
71
|
+
composeCast: <close extends boolean | undefined = undefined>(
|
|
72
|
+
options: ComposeCast.Options<close>,
|
|
73
|
+
) => Promise<ComposeCast.Result<close>>
|
|
67
74
|
}
|
|
68
75
|
|
|
69
76
|
export type EventFrameAddRejected = {
|