@farcaster/miniapp-core 0.0.0-canary-20250630212339

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 (144) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +13 -0
  3. package/dist/actions/AddMiniApp.d.ts +36 -0
  4. package/dist/actions/AddMiniApp.js +57 -0
  5. package/dist/actions/ComposeCast.d.ts +37 -0
  6. package/dist/actions/ComposeCast.js +2 -0
  7. package/dist/actions/Haptics.d.ts +5 -0
  8. package/dist/actions/Haptics.js +2 -0
  9. package/dist/actions/Ready.d.ts +13 -0
  10. package/dist/actions/Ready.js +6 -0
  11. package/dist/actions/SendToken.d.ts +48 -0
  12. package/dist/actions/SendToken.js +2 -0
  13. package/dist/actions/SignIn.d.ts +55 -0
  14. package/dist/actions/SignIn.js +47 -0
  15. package/dist/actions/SwapToken.d.ts +46 -0
  16. package/dist/actions/SwapToken.js +2 -0
  17. package/dist/actions/ViewCast.d.ts +25 -0
  18. package/dist/actions/ViewCast.js +2 -0
  19. package/dist/actions/ViewProfile.d.ts +4 -0
  20. package/dist/actions/ViewProfile.js +2 -0
  21. package/dist/actions/ViewToken.d.ts +4 -0
  22. package/dist/actions/ViewToken.js +2 -0
  23. package/dist/actions/index.d.ts +10 -0
  24. package/dist/actions/index.js +46 -0
  25. package/dist/back.d.ts +13 -0
  26. package/dist/back.js +6 -0
  27. package/dist/context.d.ts +94 -0
  28. package/dist/context.js +2 -0
  29. package/dist/errors.d.ts +13 -0
  30. package/dist/errors.js +12 -0
  31. package/dist/index.d.ts +10 -0
  32. package/dist/index.js +49 -0
  33. package/dist/internal/types.d.ts +8 -0
  34. package/dist/internal/types.js +2 -0
  35. package/dist/manifest.d.ts +113 -0
  36. package/dist/manifest.js +10 -0
  37. package/dist/schemas/embeds.d.ts +128 -0
  38. package/dist/schemas/embeds.js +43 -0
  39. package/dist/schemas/events.d.ts +63 -0
  40. package/dist/schemas/events.js +35 -0
  41. package/dist/schemas/index.d.ts +5 -0
  42. package/dist/schemas/index.js +21 -0
  43. package/dist/schemas/manifest.d.ts +236 -0
  44. package/dist/schemas/manifest.js +127 -0
  45. package/dist/schemas/notifications.d.ts +22 -0
  46. package/dist/schemas/notifications.js +23 -0
  47. package/dist/schemas/shared.d.ts +24 -0
  48. package/dist/schemas/shared.js +110 -0
  49. package/dist/solana.d.ts +72 -0
  50. package/dist/solana.js +15 -0
  51. package/dist/solanaWire.d.ts +3 -0
  52. package/dist/solanaWire.js +84 -0
  53. package/dist/types.d.ts +91 -0
  54. package/dist/types.js +41 -0
  55. package/dist/wallet/ethereum.d.ts +47 -0
  56. package/dist/wallet/ethereum.js +2 -0
  57. package/dist/wallet/index.d.ts +1 -0
  58. package/dist/wallet/index.js +37 -0
  59. package/esm/actions/AddMiniApp.d.ts +36 -0
  60. package/esm/actions/AddMiniApp.js +19 -0
  61. package/esm/actions/ComposeCast.d.ts +37 -0
  62. package/esm/actions/ComposeCast.js +1 -0
  63. package/esm/actions/Haptics.d.ts +5 -0
  64. package/esm/actions/Haptics.js +1 -0
  65. package/esm/actions/Ready.d.ts +13 -0
  66. package/esm/actions/Ready.js +3 -0
  67. package/esm/actions/SendToken.d.ts +48 -0
  68. package/esm/actions/SendToken.js +1 -0
  69. package/esm/actions/SignIn.d.ts +55 -0
  70. package/esm/actions/SignIn.js +10 -0
  71. package/esm/actions/SwapToken.d.ts +46 -0
  72. package/esm/actions/SwapToken.js +1 -0
  73. package/esm/actions/ViewCast.d.ts +25 -0
  74. package/esm/actions/ViewCast.js +1 -0
  75. package/esm/actions/ViewProfile.d.ts +4 -0
  76. package/esm/actions/ViewProfile.js +1 -0
  77. package/esm/actions/ViewToken.d.ts +4 -0
  78. package/esm/actions/ViewToken.js +1 -0
  79. package/esm/actions/index.d.ts +10 -0
  80. package/esm/actions/index.js +10 -0
  81. package/esm/back.d.ts +13 -0
  82. package/esm/back.js +3 -0
  83. package/esm/context.d.ts +94 -0
  84. package/esm/context.js +1 -0
  85. package/esm/errors.d.ts +13 -0
  86. package/esm/errors.js +8 -0
  87. package/esm/index.d.ts +10 -0
  88. package/esm/index.js +10 -0
  89. package/esm/internal/types.d.ts +8 -0
  90. package/esm/internal/types.js +1 -0
  91. package/esm/manifest.d.ts +113 -0
  92. package/esm/manifest.js +7 -0
  93. package/esm/schemas/embeds.d.ts +128 -0
  94. package/esm/schemas/embeds.js +39 -0
  95. package/esm/schemas/events.d.ts +63 -0
  96. package/esm/schemas/events.js +32 -0
  97. package/esm/schemas/index.d.ts +5 -0
  98. package/esm/schemas/index.js +5 -0
  99. package/esm/schemas/manifest.d.ts +236 -0
  100. package/esm/schemas/manifest.js +124 -0
  101. package/esm/schemas/notifications.d.ts +22 -0
  102. package/esm/schemas/notifications.js +20 -0
  103. package/esm/schemas/shared.d.ts +24 -0
  104. package/esm/schemas/shared.js +106 -0
  105. package/esm/solana.d.ts +72 -0
  106. package/esm/solana.js +11 -0
  107. package/esm/solanaWire.d.ts +3 -0
  108. package/esm/solanaWire.js +80 -0
  109. package/esm/tsconfig.tsbuildinfo +1 -0
  110. package/esm/types.d.ts +91 -0
  111. package/esm/types.js +23 -0
  112. package/esm/wallet/ethereum.d.ts +47 -0
  113. package/esm/wallet/ethereum.js +1 -0
  114. package/esm/wallet/index.d.ts +1 -0
  115. package/esm/wallet/index.js +1 -0
  116. package/package.json +42 -0
  117. package/src/actions/AddMiniApp.ts +51 -0
  118. package/src/actions/ComposeCast.ts +44 -0
  119. package/src/actions/Haptics.ts +9 -0
  120. package/src/actions/Ready.ts +15 -0
  121. package/src/actions/SendToken.ts +57 -0
  122. package/src/actions/SignIn.ts +67 -0
  123. package/src/actions/SwapToken.ts +54 -0
  124. package/src/actions/ViewCast.ts +27 -0
  125. package/src/actions/ViewProfile.ts +5 -0
  126. package/src/actions/ViewToken.ts +5 -0
  127. package/src/actions/index.ts +10 -0
  128. package/src/back.ts +15 -0
  129. package/src/context.ts +117 -0
  130. package/src/errors.ts +21 -0
  131. package/src/index.ts +10 -0
  132. package/src/internal/types.ts +20 -0
  133. package/src/manifest.ts +131 -0
  134. package/src/schemas/embeds.ts +58 -0
  135. package/src/schemas/events.ts +57 -0
  136. package/src/schemas/index.ts +5 -0
  137. package/src/schemas/manifest.ts +142 -0
  138. package/src/schemas/notifications.ts +35 -0
  139. package/src/schemas/shared.ts +138 -0
  140. package/src/solana.ts +108 -0
  141. package/src/solanaWire.ts +120 -0
  142. package/src/types.ts +165 -0
  143. package/src/wallet/ethereum.ts +65 -0
  144. package/src/wallet/index.ts +1 -0
package/src/types.ts ADDED
@@ -0,0 +1,165 @@
1
+ import type {
2
+ ImpactOccurred,
3
+ NotificationOccurred,
4
+ SelectionChanged,
5
+ } from './actions/Haptics.ts'
6
+ import type {
7
+ AddMiniApp,
8
+ ComposeCast,
9
+ Ready,
10
+ SendToken,
11
+ SignIn,
12
+ SwapToken,
13
+ ViewCast,
14
+ ViewProfile,
15
+ ViewToken,
16
+ } from './actions/index.ts'
17
+ import type { UpdateBackState } from './back.ts'
18
+ import type { MiniAppContext } from './context.ts'
19
+ import type {
20
+ EventFrameAdded,
21
+ EventFrameRemoved,
22
+ EventMiniAppAdded,
23
+ EventMiniAppRemoved,
24
+ EventNotificationsDisabled,
25
+ EventNotificationsEnabled,
26
+ } from './schemas/index.ts'
27
+ import type { SolanaRequestFn, SolanaWireRequestFn } from './solana.ts'
28
+ import type { Ethereum } from './wallet/index.ts'
29
+
30
+ export type SetPrimaryButtonOptions = {
31
+ text: string
32
+ loading?: boolean
33
+ disabled?: boolean
34
+ hidden?: boolean
35
+ }
36
+
37
+ // start backwards compat, remove in 1.0
38
+ export * from './wallet/ethereum.ts'
39
+ export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready.ts'
40
+ export type SignInOptions = SignIn.SignInOptions
41
+ // end backwards compat
42
+
43
+ export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
44
+
45
+ // Export haptics types
46
+ export type { ImpactOccurred, NotificationOccurred, SelectionChanged }
47
+
48
+ export const miniAppHostCapabilityList = [
49
+ 'wallet.getEthereumProvider',
50
+ 'wallet.getSolanaProvider',
51
+ 'actions.ready',
52
+ 'actions.openUrl',
53
+ 'actions.close',
54
+ 'actions.setPrimaryButton',
55
+ 'actions.addMiniApp',
56
+ 'actions.signIn',
57
+ 'actions.viewCast',
58
+ 'actions.viewProfile',
59
+ 'actions.composeCast',
60
+ 'actions.viewToken',
61
+ 'actions.sendToken',
62
+ 'actions.swapToken',
63
+ 'haptics.impactOccurred',
64
+ 'haptics.notificationOccurred',
65
+ 'haptics.selectionChanged',
66
+ 'back',
67
+ ] as const
68
+
69
+ export type MiniAppHostCapability = (typeof miniAppHostCapabilityList)[number]
70
+
71
+ export type GetCapabilities = () => Promise<MiniAppHostCapability[]>
72
+
73
+ // Returns a list of CAIP-2 identifiers
74
+ export type GetChains = () => Promise<string[]>
75
+
76
+ export type WireMiniAppHost = {
77
+ context: MiniAppContext
78
+ close: () => void
79
+ ready: Ready.Ready
80
+ openUrl: (url: string) => void
81
+ signIn: SignIn.WireSignIn
82
+ setPrimaryButton: SetPrimaryButton
83
+ ethProviderRequest: Ethereum.EthProvideRequest
84
+ ethProviderRequestV2: Ethereum.RpcTransport
85
+ eip6963RequestProvider: () => void
86
+ solanaProviderRequest?: SolanaWireRequestFn
87
+ addMiniApp: AddMiniApp.WireAddMiniApp
88
+ viewCast: ViewCast.ViewCast
89
+ viewProfile: ViewProfile.ViewProfile
90
+ viewToken: ViewToken.ViewToken
91
+ sendToken: SendToken.SendToken
92
+ swapToken: SwapToken.SwapToken
93
+ composeCast: <close extends boolean | undefined = undefined>(
94
+ options: ComposeCast.Options<close>,
95
+ ) => Promise<ComposeCast.Result<close>>
96
+ impactOccurred: ImpactOccurred
97
+ notificationOccurred: NotificationOccurred
98
+ selectionChanged: SelectionChanged
99
+ getCapabilities: GetCapabilities
100
+ getChains: GetChains
101
+ updateBackState: UpdateBackState
102
+ }
103
+
104
+ export type MiniAppHost = {
105
+ context: MiniAppContext
106
+ close: () => void
107
+ ready: Ready.Ready
108
+ openUrl: (url: string) => void
109
+ signIn: SignIn.SignIn
110
+ setPrimaryButton: SetPrimaryButton
111
+ ethProviderRequest: Ethereum.EthProvideRequest
112
+ ethProviderRequestV2: Ethereum.RpcTransport
113
+ /**
114
+ * Receive forwarded eip6963:requestProvider events from the frame document.
115
+ * Hosts must emit an EventEip6963AnnounceProvider in response.
116
+ */
117
+ eip6963RequestProvider: () => void
118
+ solanaProviderRequest?: SolanaRequestFn
119
+ addMiniApp: AddMiniApp.AddMiniApp
120
+ viewCast: ViewCast.ViewCast
121
+ viewProfile: ViewProfile.ViewProfile
122
+ viewToken: ViewToken.ViewToken
123
+ sendToken: SendToken.SendToken
124
+ swapToken: SwapToken.SwapToken
125
+ composeCast: <close extends boolean | undefined = undefined>(
126
+ options: ComposeCast.Options<close>,
127
+ ) => Promise<ComposeCast.Result<close>>
128
+ impactOccurred: ImpactOccurred
129
+ notificationOccurred: NotificationOccurred
130
+ selectionChanged: SelectionChanged
131
+ getCapabilities: GetCapabilities
132
+ getChains: GetChains
133
+ updateBackState: UpdateBackState
134
+ }
135
+
136
+ export type EventFrameAddRejected = {
137
+ event: 'frame_add_rejected'
138
+ reason: AddMiniApp.AddMiniAppRejectedReason
139
+ }
140
+
141
+ export type EventMiniAppAddRejected = {
142
+ event: 'miniapp_add_rejected'
143
+ reason: AddMiniApp.AddMiniAppRejectedReason
144
+ }
145
+
146
+ export type EventPrimaryButtonClicked = {
147
+ event: 'primary_button_clicked'
148
+ }
149
+
150
+ export type EventBackNavigationTriggered = {
151
+ event: 'back_navigation_triggered'
152
+ }
153
+
154
+ export type MiniAppClientEvent =
155
+ | EventMiniAppAdded
156
+ | EventMiniAppAddRejected
157
+ | EventMiniAppRemoved
158
+ | EventNotificationsEnabled
159
+ | EventNotificationsDisabled
160
+ | EventPrimaryButtonClicked
161
+ | EventBackNavigationTriggered
162
+ | Ethereum.EventEip6963AnnounceProvider
163
+ | EventFrameAdded
164
+ | EventFrameAddRejected
165
+ | EventFrameRemoved
@@ -0,0 +1,65 @@
1
+ import type * as Address from 'ox/Address'
2
+ import type * as Provider from 'ox/Provider'
3
+ import type * as RpcRequest from 'ox/RpcRequest'
4
+ import type * as RpcResponse from 'ox/RpcResponse'
5
+ import type * as RpcSchema from 'ox/RpcSchema'
6
+
7
+ export type EthProvideRequest<
8
+ schema extends RpcSchema.Generic = RpcSchema.Default,
9
+ > = Provider.RequestFn<schema>
10
+
11
+ export type FrameEthProviderEventData = {
12
+ type: 'frame_eth_provider_event'
13
+ } & EthProviderWireEvent
14
+
15
+ export type RpcTransport = (
16
+ request: RpcRequest.RpcRequest,
17
+ ) => Promise<RpcResponse.RpcResponse>
18
+
19
+ export type ProviderRpcError = {
20
+ code: number
21
+ details?: string
22
+ message?: string
23
+ }
24
+
25
+ export type EthProviderWireEvent =
26
+ | {
27
+ event: 'accountsChanged'
28
+ params: [readonly Address.Address[]]
29
+ }
30
+ | {
31
+ event: 'chainChanged'
32
+ params: [string]
33
+ }
34
+ | {
35
+ event: 'connect'
36
+ params: [Provider.ConnectInfo]
37
+ }
38
+ | {
39
+ event: 'disconnect'
40
+ params: [ProviderRpcError]
41
+ }
42
+ | {
43
+ event: 'message'
44
+ params: [Provider.Message]
45
+ }
46
+
47
+ export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(
48
+ event: event,
49
+ params: Extract<EthProviderWireEvent, { event: event }>['params'],
50
+ ) => void
51
+
52
+ /**
53
+ * Metadata of the EIP-1193 Provider.
54
+ */
55
+ export interface EIP6963ProviderInfo {
56
+ icon: `data:image/${string}` // RFC-2397
57
+ name: string
58
+ rdns: string
59
+ uuid: string
60
+ }
61
+
62
+ export type EventEip6963AnnounceProvider = {
63
+ event: 'eip6963:announceProvider'
64
+ info: EIP6963ProviderInfo
65
+ }
@@ -0,0 +1 @@
1
+ export * as Ethereum from './ethereum.ts'