@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.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/actions/AddMiniApp.d.ts +36 -0
- package/dist/actions/AddMiniApp.js +57 -0
- package/dist/actions/ComposeCast.d.ts +37 -0
- package/dist/actions/ComposeCast.js +2 -0
- package/dist/actions/Haptics.d.ts +5 -0
- package/dist/actions/Haptics.js +2 -0
- package/dist/actions/Ready.d.ts +13 -0
- package/dist/actions/Ready.js +6 -0
- package/dist/actions/SendToken.d.ts +48 -0
- package/dist/actions/SendToken.js +2 -0
- package/dist/actions/SignIn.d.ts +55 -0
- package/dist/actions/SignIn.js +47 -0
- package/dist/actions/SwapToken.d.ts +46 -0
- package/dist/actions/SwapToken.js +2 -0
- package/dist/actions/ViewCast.d.ts +25 -0
- package/dist/actions/ViewCast.js +2 -0
- package/dist/actions/ViewProfile.d.ts +4 -0
- package/dist/actions/ViewProfile.js +2 -0
- package/dist/actions/ViewToken.d.ts +4 -0
- package/dist/actions/ViewToken.js +2 -0
- package/dist/actions/index.d.ts +10 -0
- package/dist/actions/index.js +46 -0
- package/dist/back.d.ts +13 -0
- package/dist/back.js +6 -0
- package/dist/context.d.ts +94 -0
- package/dist/context.js +2 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +49 -0
- package/dist/internal/types.d.ts +8 -0
- package/dist/internal/types.js +2 -0
- package/dist/manifest.d.ts +113 -0
- package/dist/manifest.js +10 -0
- package/dist/schemas/embeds.d.ts +128 -0
- package/dist/schemas/embeds.js +43 -0
- package/dist/schemas/events.d.ts +63 -0
- package/dist/schemas/events.js +35 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +21 -0
- package/dist/schemas/manifest.d.ts +236 -0
- package/dist/schemas/manifest.js +127 -0
- package/dist/schemas/notifications.d.ts +22 -0
- package/dist/schemas/notifications.js +23 -0
- package/dist/schemas/shared.d.ts +24 -0
- package/dist/schemas/shared.js +110 -0
- package/dist/solana.d.ts +72 -0
- package/dist/solana.js +15 -0
- package/dist/solanaWire.d.ts +3 -0
- package/dist/solanaWire.js +84 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.js +41 -0
- package/dist/wallet/ethereum.d.ts +47 -0
- package/dist/wallet/ethereum.js +2 -0
- package/dist/wallet/index.d.ts +1 -0
- package/dist/wallet/index.js +37 -0
- package/esm/actions/AddMiniApp.d.ts +36 -0
- package/esm/actions/AddMiniApp.js +19 -0
- package/esm/actions/ComposeCast.d.ts +37 -0
- package/esm/actions/ComposeCast.js +1 -0
- package/esm/actions/Haptics.d.ts +5 -0
- package/esm/actions/Haptics.js +1 -0
- package/esm/actions/Ready.d.ts +13 -0
- package/esm/actions/Ready.js +3 -0
- package/esm/actions/SendToken.d.ts +48 -0
- package/esm/actions/SendToken.js +1 -0
- package/esm/actions/SignIn.d.ts +55 -0
- package/esm/actions/SignIn.js +10 -0
- package/esm/actions/SwapToken.d.ts +46 -0
- package/esm/actions/SwapToken.js +1 -0
- package/esm/actions/ViewCast.d.ts +25 -0
- package/esm/actions/ViewCast.js +1 -0
- package/esm/actions/ViewProfile.d.ts +4 -0
- package/esm/actions/ViewProfile.js +1 -0
- package/esm/actions/ViewToken.d.ts +4 -0
- package/esm/actions/ViewToken.js +1 -0
- package/esm/actions/index.d.ts +10 -0
- package/esm/actions/index.js +10 -0
- package/esm/back.d.ts +13 -0
- package/esm/back.js +3 -0
- package/esm/context.d.ts +94 -0
- package/esm/context.js +1 -0
- package/esm/errors.d.ts +13 -0
- package/esm/errors.js +8 -0
- package/esm/index.d.ts +10 -0
- package/esm/index.js +10 -0
- package/esm/internal/types.d.ts +8 -0
- package/esm/internal/types.js +1 -0
- package/esm/manifest.d.ts +113 -0
- package/esm/manifest.js +7 -0
- package/esm/schemas/embeds.d.ts +128 -0
- package/esm/schemas/embeds.js +39 -0
- package/esm/schemas/events.d.ts +63 -0
- package/esm/schemas/events.js +32 -0
- package/esm/schemas/index.d.ts +5 -0
- package/esm/schemas/index.js +5 -0
- package/esm/schemas/manifest.d.ts +236 -0
- package/esm/schemas/manifest.js +124 -0
- package/esm/schemas/notifications.d.ts +22 -0
- package/esm/schemas/notifications.js +20 -0
- package/esm/schemas/shared.d.ts +24 -0
- package/esm/schemas/shared.js +106 -0
- package/esm/solana.d.ts +72 -0
- package/esm/solana.js +11 -0
- package/esm/solanaWire.d.ts +3 -0
- package/esm/solanaWire.js +80 -0
- package/esm/tsconfig.tsbuildinfo +1 -0
- package/esm/types.d.ts +91 -0
- package/esm/types.js +23 -0
- package/esm/wallet/ethereum.d.ts +47 -0
- package/esm/wallet/ethereum.js +1 -0
- package/esm/wallet/index.d.ts +1 -0
- package/esm/wallet/index.js +1 -0
- package/package.json +42 -0
- package/src/actions/AddMiniApp.ts +51 -0
- package/src/actions/ComposeCast.ts +44 -0
- package/src/actions/Haptics.ts +9 -0
- package/src/actions/Ready.ts +15 -0
- package/src/actions/SendToken.ts +57 -0
- package/src/actions/SignIn.ts +67 -0
- package/src/actions/SwapToken.ts +54 -0
- package/src/actions/ViewCast.ts +27 -0
- package/src/actions/ViewProfile.ts +5 -0
- package/src/actions/ViewToken.ts +5 -0
- package/src/actions/index.ts +10 -0
- package/src/back.ts +15 -0
- package/src/context.ts +117 -0
- package/src/errors.ts +21 -0
- package/src/index.ts +10 -0
- package/src/internal/types.ts +20 -0
- package/src/manifest.ts +131 -0
- package/src/schemas/embeds.ts +58 -0
- package/src/schemas/events.ts +57 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/manifest.ts +142 -0
- package/src/schemas/notifications.ts +35 -0
- package/src/schemas/shared.ts +138 -0
- package/src/solana.ts +108 -0
- package/src/solanaWire.ts +120 -0
- package/src/types.ts +165 -0
- package/src/wallet/ethereum.ts +65 -0
- 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'
|