@farcaster/frame-core 0.0.27 → 0.0.29

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.
Files changed (61) hide show
  1. package/LICENSE +21 -0
  2. package/dist/actions/Ready.d.ts +13 -0
  3. package/dist/actions/Ready.js +6 -0
  4. package/dist/actions/index.d.ts +3 -2
  5. package/dist/actions/index.js +4 -3
  6. package/dist/index.d.ts +1 -0
  7. package/dist/index.js +1 -0
  8. package/dist/types.d.ts +12 -77
  9. package/dist/types.js +18 -3
  10. package/dist/wallet/ethereum.d.ts +43 -0
  11. package/dist/wallet/ethereum.js +2 -0
  12. package/dist/wallet/index.d.ts +1 -0
  13. package/dist/wallet/index.js +37 -0
  14. package/esm/actions/AddFrame.d.ts +27 -23
  15. package/esm/actions/AddFrame.js +9 -9
  16. package/esm/actions/Ready.d.ts +13 -0
  17. package/esm/actions/Ready.js +3 -0
  18. package/esm/actions/SignIn.d.ts +35 -33
  19. package/esm/actions/SignIn.js +5 -5
  20. package/esm/actions/Swap.d.ts +44 -43
  21. package/esm/actions/Swap.js +1 -1
  22. package/esm/actions/ViewProfile.d.ts +3 -3
  23. package/esm/actions/ViewProfile.js +1 -1
  24. package/esm/actions/ViewToken.d.ts +3 -3
  25. package/esm/actions/ViewToken.js +1 -1
  26. package/esm/actions/index.d.ts +6 -5
  27. package/esm/actions/index.js +6 -5
  28. package/esm/context.d.ts +65 -61
  29. package/esm/context.js +1 -1
  30. package/esm/errors.d.ts +9 -7
  31. package/esm/errors.js +6 -6
  32. package/esm/index.d.ts +5 -4
  33. package/esm/index.js +5 -4
  34. package/esm/internal/types.d.ts +18 -7
  35. package/esm/internal/types.js +1 -1
  36. package/esm/schemas/embeds.d.ts +346 -239
  37. package/esm/schemas/embeds.js +31 -23
  38. package/esm/schemas/events.d.ts +225 -129
  39. package/esm/schemas/events.js +17 -17
  40. package/esm/schemas/index.d.ts +5 -5
  41. package/esm/schemas/index.js +5 -5
  42. package/esm/schemas/manifest.d.ts +154 -110
  43. package/esm/schemas/manifest.js +29 -23
  44. package/esm/schemas/notifications.d.ts +86 -58
  45. package/esm/schemas/notifications.js +17 -17
  46. package/esm/schemas/shared.d.ts +53 -35
  47. package/esm/schemas/shared.js +25 -23
  48. package/esm/tsconfig.tsbuildinfo +1 -1
  49. package/esm/types.d.ts +69 -115
  50. package/esm/types.js +3 -3
  51. package/esm/wallet/ethereum.d.ts +58 -0
  52. package/esm/wallet/ethereum.js +1 -0
  53. package/esm/wallet/index.d.ts +1 -0
  54. package/esm/wallet/index.js +1 -0
  55. package/package.json +8 -2
  56. package/src/actions/Ready.ts +15 -0
  57. package/src/actions/index.ts +3 -2
  58. package/src/index.ts +1 -0
  59. package/src/types.ts +22 -100
  60. package/src/wallet/ethereum.ts +61 -0
  61. package/src/wallet/index.ts +1 -0
package/esm/types.d.ts CHANGED
@@ -1,121 +1,75 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
2
- import type { AddFrame, SignIn, Swap, ViewProfile, ViewToken } from './actions';
3
- import type { FrameContext } from './context';
4
- import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
1
+ import type {
2
+ AddFrame,
3
+ Ready,
4
+ SignIn,
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'
5
17
  export type SetPrimaryButtonOptions = {
6
- text: string;
7
- loading?: boolean;
8
- disabled?: boolean;
9
- hidden?: boolean;
10
- };
11
- export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
12
- export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
13
- export type ReadyOptions = {
14
- /**
15
- * Disable native gestures. Use this option if your frame uses gestures
16
- * that conflict with native gestures.
17
- *
18
- * @defaultValue false
19
- */
20
- disableNativeGestures: boolean;
21
- };
22
- export declare const DEFAULT_READY_OPTIONS: ReadyOptions;
23
- export type SignInOptions = {
24
- /**
25
- * A random string used to prevent replay attacks.
26
- */
27
- nonce: string;
28
- /**
29
- * Start time at which the signature becomes valid.
30
- * ISO 8601 datetime.
31
- */
32
- notBefore?: string;
33
- /**
34
- * Expiration time at which the signature is no longer valid.
35
- * ISO 8601 datetime.
36
- */
37
- expirationTime?: string;
38
- };
18
+ text: string
19
+ loading?: boolean
20
+ disabled?: boolean
21
+ hidden?: boolean
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
39
27
  export type WireFrameHost = {
40
- context: FrameContext;
41
- close: () => void;
42
- ready: (options?: Partial<ReadyOptions>) => void;
43
- openUrl: (url: string) => void;
44
- signIn: SignIn.WireSignIn;
45
- setPrimaryButton: SetPrimaryButton;
46
- ethProviderRequest: EthProviderRequest;
47
- ethProviderRequestV2: RpcTransport;
48
- eip6963RequestProvider: () => void;
49
- addFrame: AddFrame.WireAddFrame;
50
- viewProfile: ViewProfile.ViewProfile;
51
- viewToken: ViewToken.ViewToken;
52
- swap: Swap.Swap;
53
- };
28
+ context: FrameContext
29
+ close: () => void
30
+ ready: Ready.Ready
31
+ openUrl: (url: string) => void
32
+ signIn: SignIn.WireSignIn
33
+ setPrimaryButton: SetPrimaryButton
34
+ ethProviderRequest: Ethereum.EthProvideRequest
35
+ ethProviderRequestV2: Ethereum.RpcTransport
36
+ eip6963RequestProvider: () => void
37
+ addFrame: AddFrame.WireAddFrame
38
+ viewProfile: ViewProfile.ViewProfile
39
+ viewToken: ViewToken.ViewToken
40
+ swap: Swap.Swap
41
+ }
54
42
  export type FrameHost = {
55
- context: FrameContext;
56
- close: () => void;
57
- ready: (options?: Partial<ReadyOptions>) => void;
58
- openUrl: (url: string) => void;
59
- signIn: SignIn.SignIn;
60
- setPrimaryButton: SetPrimaryButton;
61
- ethProviderRequest: EthProviderRequest;
62
- ethProviderRequestV2: RpcTransport;
63
- /**
64
- * Receive forwarded eip6963:requestProvider events from the frame document.
65
- * Hosts must emit an EventEip6963AnnounceProvider in response.
66
- */
67
- eip6963RequestProvider: () => void;
68
- addFrame: AddFrame.AddFrame;
69
- viewProfile: ViewProfile.ViewProfile;
70
- viewToken: ViewToken.ViewToken;
71
- swap: Swap.Swap;
72
- };
73
- export type FrameEthProviderEventData = {
74
- type: 'frame_eth_provider_event';
75
- } & EthProviderWireEvent;
76
- export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
77
- export type ProviderRpcError = {
78
- code: number;
79
- details?: string;
80
- message?: string;
81
- };
82
- export type EthProviderWireEvent = {
83
- event: 'accountsChanged';
84
- params: [readonly Address.Address[]];
85
- } | {
86
- event: 'chainChanged';
87
- params: [string];
88
- } | {
89
- event: 'connect';
90
- params: [Provider.ConnectInfo];
91
- } | {
92
- event: 'disconnect';
93
- params: [ProviderRpcError];
94
- } | {
95
- event: 'message';
96
- params: [Provider.Message];
97
- };
98
- export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
99
- event: event;
100
- }>['params']) => void;
43
+ context: FrameContext
44
+ close: () => void
45
+ ready: Ready.Ready
46
+ openUrl: (url: string) => void
47
+ signIn: SignIn.SignIn
48
+ setPrimaryButton: SetPrimaryButton
49
+ ethProviderRequest: Ethereum.EthProvideRequest
50
+ ethProviderRequestV2: Ethereum.RpcTransport
51
+ /**
52
+ * Receive forwarded eip6963:requestProvider events from the frame document.
53
+ * Hosts must emit an EventEip6963AnnounceProvider in response.
54
+ */
55
+ eip6963RequestProvider: () => void
56
+ addFrame: AddFrame.AddFrame
57
+ viewProfile: ViewProfile.ViewProfile
58
+ viewToken: ViewToken.ViewToken
59
+ swap: Swap.Swap
60
+ }
101
61
  export type EventFrameAddRejected = {
102
- event: 'frame_add_rejected';
103
- reason: AddFrame.AddFrameRejectedReason;
104
- };
62
+ event: 'frame_add_rejected'
63
+ reason: AddFrame.AddFrameRejectedReason
64
+ }
105
65
  export type EventPrimaryButtonClicked = {
106
- event: 'primary_button_clicked';
107
- };
108
- /**
109
- * Metadata of the EIP-1193 Provider.
110
- */
111
- export interface EIP6963ProviderInfo {
112
- icon: `data:image/${string}`;
113
- name: string;
114
- rdns: string;
115
- uuid: string;
66
+ event: 'primary_button_clicked'
116
67
  }
117
- export type EventEip6963AnnounceProvider = {
118
- event: 'eip6963:announceProvider';
119
- info: EIP6963ProviderInfo;
120
- };
121
- export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | EventEip6963AnnounceProvider;
68
+ export type FrameClientEvent =
69
+ | EventFrameAdded
70
+ | EventFrameAddRejected
71
+ | EventFrameRemoved
72
+ | EventNotificationsEnabled
73
+ | EventNotificationsDisabled
74
+ | EventPrimaryButtonClicked
75
+ | Ethereum.EventEip6963AnnounceProvider
package/esm/types.js CHANGED
@@ -1,3 +1,3 @@
1
- export const DEFAULT_READY_OPTIONS = {
2
- disableNativeGestures: false,
3
- };
1
+ // start backwards compat, remove in 1.0
2
+ export * from './wallet/ethereum'
3
+ export { DEFAULT_READY_OPTIONS } from './actions/Ready'
@@ -0,0 +1,58 @@
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>
5
+ export type FrameEthProviderEventData = {
6
+ type: 'frame_eth_provider_event'
7
+ } & EthProviderWireEvent
8
+ export type RpcTransport = (
9
+ request: RpcRequest.RpcRequest,
10
+ ) => Promise<RpcResponse.RpcResponse>
11
+ export type ProviderRpcError = {
12
+ code: number
13
+ details?: string
14
+ message?: string
15
+ }
16
+ export type EthProviderWireEvent =
17
+ | {
18
+ event: 'accountsChanged'
19
+ params: [readonly Address.Address[]]
20
+ }
21
+ | {
22
+ event: 'chainChanged'
23
+ params: [string]
24
+ }
25
+ | {
26
+ event: 'connect'
27
+ params: [Provider.ConnectInfo]
28
+ }
29
+ | {
30
+ event: 'disconnect'
31
+ params: [ProviderRpcError]
32
+ }
33
+ | {
34
+ event: 'message'
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
46
+ /**
47
+ * Metadata of the EIP-1193 Provider.
48
+ */
49
+ export interface EIP6963ProviderInfo {
50
+ icon: `data:image/${string}`
51
+ name: string
52
+ rdns: string
53
+ uuid: string
54
+ }
55
+ export type EventEip6963AnnounceProvider = {
56
+ event: 'eip6963:announceProvider'
57
+ info: EIP6963ProviderInfo
58
+ }
@@ -0,0 +1 @@
1
+ export {}
@@ -0,0 +1 @@
1
+ export * as Ethereum from './ethereum'
@@ -0,0 +1 @@
1
+ export * as Ethereum from './ethereum'
package/package.json CHANGED
@@ -1,6 +1,12 @@
1
1
  {
2
2
  "name": "@farcaster/frame-core",
3
- "version": "0.0.27",
3
+ "version": "0.0.29",
4
+ "license": "MIT",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/farcasterxyz/frames.git",
8
+ "directory": "packages/frame-core"
9
+ },
4
10
  "main": "dist/index.js",
5
11
  "module": "esm/index.js",
6
12
  "files": [
@@ -11,7 +17,7 @@
11
17
  "devDependencies": {
12
18
  "@vitest/coverage-v8": "^2.1.8",
13
19
  "typescript": "^5.7.2",
14
- "vitest": "^2.1.8",
20
+ "vitest": "^2.1.9",
15
21
  "@farcaster/tsconfig": "0.0.2"
16
22
  },
17
23
  "dependencies": {
@@ -0,0 +1,15 @@
1
+ export type ReadyOptions = {
2
+ /**
3
+ * Disable native gestures. Use this option if your frame uses gestures
4
+ * that conflict with native gestures.
5
+ *
6
+ * @defaultValue false
7
+ */
8
+ disableNativeGestures: boolean
9
+ }
10
+
11
+ export const DEFAULT_READY_OPTIONS = {
12
+ disableNativeGestures: false,
13
+ } satisfies ReadyOptions
14
+
15
+ export type Ready = (options?: Partial<ReadyOptions>) => void
@@ -1,5 +1,6 @@
1
1
  export * as AddFrame from './AddFrame'
2
- export * as ViewProfile from './ViewProfile'
3
- export * as ViewToken from './ViewToken'
2
+ export * as Ready from './Ready'
4
3
  export * as SignIn from './SignIn'
5
4
  export * as Swap from './Swap'
5
+ export * as ViewProfile from './ViewProfile'
6
+ export * as ViewToken from './ViewToken'
package/src/index.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './actions'
2
+ export * from './wallet'
2
3
  export * as Context from './context'
3
4
  export * from './types'
4
5
  export * from './schemas'
package/src/types.ts CHANGED
@@ -1,5 +1,11 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
2
- import type { AddFrame, SignIn, Swap, ViewProfile, ViewToken } from './actions'
1
+ import type {
2
+ AddFrame,
3
+ Ready,
4
+ SignIn,
5
+ Swap,
6
+ ViewProfile,
7
+ ViewToken,
8
+ } from './actions'
3
9
  import type { FrameContext } from './context'
4
10
  import type {
5
11
  EventFrameAdded,
@@ -7,6 +13,7 @@ import type {
7
13
  EventNotificationsDisabled,
8
14
  EventNotificationsEnabled,
9
15
  } from './schemas'
16
+ import type { Ethereum } from './wallet'
10
17
 
11
18
  export type SetPrimaryButtonOptions = {
12
19
  text: string
@@ -15,52 +22,23 @@ export type SetPrimaryButtonOptions = {
15
22
  hidden?: boolean
16
23
  }
17
24
 
18
- export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
19
-
20
- export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>
21
-
22
- export type ReadyOptions = {
23
- /**
24
- * Disable native gestures. Use this option if your frame uses gestures
25
- * that conflict with native gestures.
26
- *
27
- * @defaultValue false
28
- */
29
- disableNativeGestures: boolean
30
- }
31
-
32
- export const DEFAULT_READY_OPTIONS: ReadyOptions = {
33
- disableNativeGestures: false,
34
- }
35
-
36
- export type SignInOptions = {
37
- /**
38
- * A random string used to prevent replay attacks.
39
- */
40
- nonce: string
41
-
42
- /**
43
- * Start time at which the signature becomes valid.
44
- * ISO 8601 datetime.
45
- */
46
- notBefore?: string
25
+ // start backwards compat, remove in 1.0
26
+ export * from './wallet/ethereum'
27
+ export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready'
28
+ export type SignInOptions = SignIn.SignInOptions
29
+ // end backwards compat
47
30
 
48
- /**
49
- * Expiration time at which the signature is no longer valid.
50
- * ISO 8601 datetime.
51
- */
52
- expirationTime?: string
53
- }
31
+ export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
54
32
 
55
33
  export type WireFrameHost = {
56
34
  context: FrameContext
57
35
  close: () => void
58
- ready: (options?: Partial<ReadyOptions>) => void
36
+ ready: Ready.Ready
59
37
  openUrl: (url: string) => void
60
38
  signIn: SignIn.WireSignIn
61
39
  setPrimaryButton: SetPrimaryButton
62
- ethProviderRequest: EthProviderRequest
63
- ethProviderRequestV2: RpcTransport
40
+ ethProviderRequest: Ethereum.EthProvideRequest
41
+ ethProviderRequestV2: Ethereum.RpcTransport
64
42
  eip6963RequestProvider: () => void
65
43
  addFrame: AddFrame.WireAddFrame
66
44
  viewProfile: ViewProfile.ViewProfile
@@ -71,12 +49,12 @@ export type WireFrameHost = {
71
49
  export type FrameHost = {
72
50
  context: FrameContext
73
51
  close: () => void
74
- ready: (options?: Partial<ReadyOptions>) => void
52
+ ready: Ready.Ready
75
53
  openUrl: (url: string) => void
76
54
  signIn: SignIn.SignIn
77
55
  setPrimaryButton: SetPrimaryButton
78
- ethProviderRequest: EthProviderRequest
79
- ethProviderRequestV2: RpcTransport
56
+ ethProviderRequest: Ethereum.EthProvideRequest
57
+ ethProviderRequestV2: Ethereum.RpcTransport
80
58
  /**
81
59
  * Receive forwarded eip6963:requestProvider events from the frame document.
82
60
  * Hosts must emit an EventEip6963AnnounceProvider in response.
@@ -88,47 +66,6 @@ export type FrameHost = {
88
66
  swap: Swap.Swap
89
67
  }
90
68
 
91
- export type FrameEthProviderEventData = {
92
- type: 'frame_eth_provider_event'
93
- } & EthProviderWireEvent
94
-
95
- export type RpcTransport = (
96
- request: RpcRequest.RpcRequest,
97
- ) => Promise<RpcResponse.RpcResponse>
98
-
99
- export type ProviderRpcError = {
100
- code: number
101
- details?: string
102
- message?: string
103
- }
104
-
105
- export type EthProviderWireEvent =
106
- | {
107
- event: 'accountsChanged'
108
- params: [readonly Address.Address[]]
109
- }
110
- | {
111
- event: 'chainChanged'
112
- params: [string]
113
- }
114
- | {
115
- event: 'connect'
116
- params: [Provider.ConnectInfo]
117
- }
118
- | {
119
- event: 'disconnect'
120
- params: [ProviderRpcError]
121
- }
122
- | {
123
- event: 'message'
124
- params: [Provider.Message]
125
- }
126
-
127
- export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
128
- event: event,
129
- params: Extract<EthProviderWireEvent, { event: event }>['params'],
130
- ) => void
131
-
132
69
  export type EventFrameAddRejected = {
133
70
  event: 'frame_add_rejected'
134
71
  reason: AddFrame.AddFrameRejectedReason
@@ -138,21 +75,6 @@ export type EventPrimaryButtonClicked = {
138
75
  event: 'primary_button_clicked'
139
76
  }
140
77
 
141
- /**
142
- * Metadata of the EIP-1193 Provider.
143
- */
144
- export interface EIP6963ProviderInfo {
145
- icon: `data:image/${string}` // RFC-2397
146
- name: string
147
- rdns: string
148
- uuid: string
149
- }
150
-
151
- export type EventEip6963AnnounceProvider = {
152
- event: 'eip6963:announceProvider'
153
- info: EIP6963ProviderInfo
154
- }
155
-
156
78
  export type FrameClientEvent =
157
79
  | EventFrameAdded
158
80
  | EventFrameAddRejected
@@ -160,4 +82,4 @@ export type FrameClientEvent =
160
82
  | EventNotificationsEnabled
161
83
  | EventNotificationsDisabled
162
84
  | EventPrimaryButtonClicked
163
- | EventEip6963AnnounceProvider
85
+ | Ethereum.EventEip6963AnnounceProvider
@@ -0,0 +1,61 @@
1
+ import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox'
2
+
3
+ export type EthProvideRequest<
4
+ schema extends RpcSchema.Generic = RpcSchema.Default,
5
+ > = Provider.RequestFn<schema>
6
+
7
+ export type FrameEthProviderEventData = {
8
+ type: 'frame_eth_provider_event'
9
+ } & EthProviderWireEvent
10
+
11
+ export type RpcTransport = (
12
+ request: RpcRequest.RpcRequest,
13
+ ) => Promise<RpcResponse.RpcResponse>
14
+
15
+ export type ProviderRpcError = {
16
+ code: number
17
+ details?: string
18
+ message?: string
19
+ }
20
+
21
+ export type EthProviderWireEvent =
22
+ | {
23
+ event: 'accountsChanged'
24
+ params: [readonly Address.Address[]]
25
+ }
26
+ | {
27
+ event: 'chainChanged'
28
+ params: [string]
29
+ }
30
+ | {
31
+ event: 'connect'
32
+ params: [Provider.ConnectInfo]
33
+ }
34
+ | {
35
+ event: 'disconnect'
36
+ params: [ProviderRpcError]
37
+ }
38
+ | {
39
+ event: 'message'
40
+ params: [Provider.Message]
41
+ }
42
+
43
+ export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
44
+ event: event,
45
+ params: Extract<EthProviderWireEvent, { event: event }>['params'],
46
+ ) => void
47
+
48
+ /**
49
+ * Metadata of the EIP-1193 Provider.
50
+ */
51
+ export interface EIP6963ProviderInfo {
52
+ icon: `data:image/${string}` // RFC-2397
53
+ name: string
54
+ rdns: string
55
+ uuid: string
56
+ }
57
+
58
+ export type EventEip6963AnnounceProvider = {
59
+ event: 'eip6963:announceProvider'
60
+ info: EIP6963ProviderInfo
61
+ }
@@ -0,0 +1 @@
1
+ export * as Ethereum from './ethereum'