@farcaster/frame-core 0.1.10 → 0.3.0
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/dist/index.d.ts +153 -10
- package/dist/index.js +18 -33
- package/esm/index.d.ts +153 -10
- package/esm/index.js +17 -10
- package/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +6 -8
- package/src/index.ts +50 -10
- package/dist/actions/AddMiniApp.d.ts +0 -36
- package/dist/actions/AddMiniApp.js +0 -57
- package/dist/actions/ComposeCast.d.ts +0 -37
- package/dist/actions/ComposeCast.js +0 -2
- package/dist/actions/Haptics.d.ts +0 -5
- package/dist/actions/Haptics.js +0 -2
- package/dist/actions/Ready.d.ts +0 -13
- package/dist/actions/Ready.js +0 -6
- package/dist/actions/SendToken.d.ts +0 -48
- package/dist/actions/SendToken.js +0 -2
- package/dist/actions/SignIn.d.ts +0 -55
- package/dist/actions/SignIn.js +0 -47
- package/dist/actions/SwapToken.d.ts +0 -46
- package/dist/actions/SwapToken.js +0 -2
- package/dist/actions/ViewCast.d.ts +0 -25
- package/dist/actions/ViewCast.js +0 -2
- package/dist/actions/ViewProfile.d.ts +0 -4
- package/dist/actions/ViewProfile.js +0 -2
- package/dist/actions/ViewToken.d.ts +0 -4
- package/dist/actions/ViewToken.js +0 -2
- package/dist/actions/index.d.ts +0 -10
- package/dist/actions/index.js +0 -46
- package/dist/back.d.ts +0 -13
- package/dist/back.js +0 -6
- package/dist/context.d.ts +0 -94
- package/dist/context.js +0 -2
- package/dist/errors.d.ts +0 -13
- package/dist/errors.js +0 -12
- package/dist/internal/types.d.ts +0 -8
- package/dist/internal/types.js +0 -2
- package/dist/manifest.d.ts +0 -101
- package/dist/manifest.js +0 -2
- package/dist/schemas/embeds.d.ts +0 -243
- package/dist/schemas/embeds.js +0 -32
- package/dist/schemas/events.d.ts +0 -131
- package/dist/schemas/events.js +0 -25
- package/dist/schemas/index.d.ts +0 -5
- package/dist/schemas/index.js +0 -21
- package/dist/schemas/manifest.d.ts +0 -334
- package/dist/schemas/manifest.js +0 -112
- package/dist/schemas/notifications.d.ts +0 -60
- package/dist/schemas/notifications.js +0 -23
- package/dist/schemas/shared.d.ts +0 -39
- package/dist/schemas/shared.js +0 -58
- package/dist/solana.d.ts +0 -72
- package/dist/solana.js +0 -15
- package/dist/solanaWire.d.ts +0 -3
- package/dist/solanaWire.js +0 -84
- package/dist/types.d.ts +0 -87
- package/dist/types.js +0 -41
- package/dist/wallet/ethereum.d.ts +0 -47
- package/dist/wallet/ethereum.js +0 -2
- package/dist/wallet/index.d.ts +0 -1
- package/dist/wallet/index.js +0 -37
- package/esm/actions/AddMiniApp.d.ts +0 -36
- package/esm/actions/AddMiniApp.js +0 -19
- package/esm/actions/ComposeCast.d.ts +0 -37
- package/esm/actions/ComposeCast.js +0 -1
- package/esm/actions/Haptics.d.ts +0 -5
- package/esm/actions/Haptics.js +0 -1
- package/esm/actions/Ready.d.ts +0 -13
- package/esm/actions/Ready.js +0 -3
- package/esm/actions/SendToken.d.ts +0 -48
- package/esm/actions/SendToken.js +0 -1
- package/esm/actions/SignIn.d.ts +0 -55
- package/esm/actions/SignIn.js +0 -10
- package/esm/actions/SwapToken.d.ts +0 -46
- package/esm/actions/SwapToken.js +0 -1
- package/esm/actions/ViewCast.d.ts +0 -25
- package/esm/actions/ViewCast.js +0 -1
- package/esm/actions/ViewProfile.d.ts +0 -4
- package/esm/actions/ViewProfile.js +0 -1
- package/esm/actions/ViewToken.d.ts +0 -4
- package/esm/actions/ViewToken.js +0 -1
- package/esm/actions/index.d.ts +0 -10
- package/esm/actions/index.js +0 -10
- package/esm/back.d.ts +0 -13
- package/esm/back.js +0 -3
- package/esm/context.d.ts +0 -94
- package/esm/context.js +0 -1
- package/esm/errors.d.ts +0 -13
- package/esm/errors.js +0 -8
- package/esm/internal/types.d.ts +0 -8
- package/esm/internal/types.js +0 -1
- package/esm/manifest.d.ts +0 -101
- package/esm/manifest.js +0 -1
- package/esm/schemas/embeds.d.ts +0 -243
- package/esm/schemas/embeds.js +0 -28
- package/esm/schemas/events.d.ts +0 -131
- package/esm/schemas/events.js +0 -22
- package/esm/schemas/index.d.ts +0 -5
- package/esm/schemas/index.js +0 -5
- package/esm/schemas/manifest.d.ts +0 -334
- package/esm/schemas/manifest.js +0 -109
- package/esm/schemas/notifications.d.ts +0 -60
- package/esm/schemas/notifications.js +0 -20
- package/esm/schemas/shared.d.ts +0 -39
- package/esm/schemas/shared.js +0 -54
- package/esm/solana.d.ts +0 -72
- package/esm/solana.js +0 -11
- package/esm/solanaWire.d.ts +0 -3
- package/esm/solanaWire.js +0 -80
- package/esm/types.d.ts +0 -87
- package/esm/types.js +0 -23
- package/esm/wallet/ethereum.d.ts +0 -47
- package/esm/wallet/ethereum.js +0 -1
- package/esm/wallet/index.d.ts +0 -1
- package/esm/wallet/index.js +0 -1
- package/src/actions/AddMiniApp.ts +0 -51
- package/src/actions/ComposeCast.ts +0 -44
- package/src/actions/Haptics.ts +0 -9
- package/src/actions/Ready.ts +0 -15
- package/src/actions/SendToken.ts +0 -57
- package/src/actions/SignIn.ts +0 -67
- package/src/actions/SwapToken.ts +0 -54
- package/src/actions/ViewCast.ts +0 -27
- package/src/actions/ViewProfile.ts +0 -5
- package/src/actions/ViewToken.ts +0 -5
- package/src/actions/index.ts +0 -10
- package/src/back.ts +0 -15
- package/src/context.ts +0 -117
- package/src/errors.ts +0 -21
- package/src/internal/types.ts +0 -20
- package/src/manifest.ts +0 -113
- package/src/schemas/embeds.ts +0 -44
- package/src/schemas/events.ts +0 -41
- package/src/schemas/index.ts +0 -5
- package/src/schemas/manifest.ts +0 -122
- package/src/schemas/notifications.ts +0 -33
- package/src/schemas/shared.ts +0 -81
- package/src/solana.ts +0 -108
- package/src/solanaWire.ts +0 -120
- package/src/types.ts +0 -155
- package/src/wallet/ethereum.ts +0 -65
- package/src/wallet/index.ts +0 -1
package/src/schemas/manifest.ts
DELETED
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { miniAppHostCapabilityList } from '../types.ts'
|
|
3
|
-
import {
|
|
4
|
-
buttonTitleSchema,
|
|
5
|
-
createSimpleStringSchema,
|
|
6
|
-
encodedJsonFarcasterSignatureSchema,
|
|
7
|
-
frameNameSchema,
|
|
8
|
-
hexColorSchema,
|
|
9
|
-
secureUrlSchema,
|
|
10
|
-
} from './shared.ts'
|
|
11
|
-
|
|
12
|
-
const primaryCategorySchema = z.enum([
|
|
13
|
-
'games',
|
|
14
|
-
'social',
|
|
15
|
-
'finance',
|
|
16
|
-
'utility',
|
|
17
|
-
'productivity',
|
|
18
|
-
'health-fitness',
|
|
19
|
-
'news-media',
|
|
20
|
-
'music',
|
|
21
|
-
'shopping',
|
|
22
|
-
'education',
|
|
23
|
-
'developer-tools',
|
|
24
|
-
'entertainment',
|
|
25
|
-
'art-creativity',
|
|
26
|
-
])
|
|
27
|
-
|
|
28
|
-
const chainList = [
|
|
29
|
-
'eip155:1', // Ethereum mainnet
|
|
30
|
-
'eip155:8453', // Base mainnet
|
|
31
|
-
'eip155:42161', // Arbitrum One
|
|
32
|
-
'eip155:421614', // Arbitrum Sepolia
|
|
33
|
-
'eip155:84532', // Base Sepolia
|
|
34
|
-
'eip155:666666666', // Degen
|
|
35
|
-
'eip155:100', // Gnosis
|
|
36
|
-
'eip155:10', // Optimism
|
|
37
|
-
'eip155:11155420', // Optimism Sepolia
|
|
38
|
-
'eip155:137', // Polygon
|
|
39
|
-
'eip155:11155111', // Ethereum Sepolia
|
|
40
|
-
'eip155:7777777', // Zora
|
|
41
|
-
'eip155:130', // Unichain
|
|
42
|
-
'eip155:10143', // Monad testnet
|
|
43
|
-
'eip155:42220', // Celo
|
|
44
|
-
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', // Solana
|
|
45
|
-
] as const
|
|
46
|
-
|
|
47
|
-
function removeArrayDuplicates<T>(arr: T[]) {
|
|
48
|
-
const set = new Set(arr)
|
|
49
|
-
return Array.from(set)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export const domainFrameConfigSchema = z
|
|
53
|
-
.object({
|
|
54
|
-
// 0.0.0 and 0.0.1 are not technically part of the spec but kept for
|
|
55
|
-
// backwards compatibility. next should always resolve to the most recent
|
|
56
|
-
// schema version.
|
|
57
|
-
version: z.union([
|
|
58
|
-
z.literal('0.0.0'),
|
|
59
|
-
z.literal('0.0.1'),
|
|
60
|
-
z.literal('1'),
|
|
61
|
-
z.literal('next'),
|
|
62
|
-
]),
|
|
63
|
-
name: frameNameSchema,
|
|
64
|
-
iconUrl: secureUrlSchema,
|
|
65
|
-
homeUrl: secureUrlSchema,
|
|
66
|
-
/** deprecated, set ogImageUrl instead */
|
|
67
|
-
imageUrl: secureUrlSchema.optional(),
|
|
68
|
-
/** deprecated, will rely on fc:frame meta tag */
|
|
69
|
-
buttonTitle: buttonTitleSchema.optional(),
|
|
70
|
-
splashImageUrl: secureUrlSchema.optional(),
|
|
71
|
-
splashBackgroundColor: hexColorSchema.optional(),
|
|
72
|
-
webhookUrl: secureUrlSchema.optional(),
|
|
73
|
-
/** see: https://github.com/farcasterxyz/miniapps/discussions/191 */
|
|
74
|
-
subtitle: createSimpleStringSchema({ max: 30 }).optional(),
|
|
75
|
-
description: createSimpleStringSchema({ max: 170 }).optional(),
|
|
76
|
-
screenshotUrls: z.array(secureUrlSchema).max(3).optional(),
|
|
77
|
-
primaryCategory: primaryCategorySchema.optional(),
|
|
78
|
-
tags: z
|
|
79
|
-
.array(createSimpleStringSchema({ max: 20, noSpaces: true }))
|
|
80
|
-
.max(5)
|
|
81
|
-
.optional(),
|
|
82
|
-
heroImageUrl: secureUrlSchema.optional(),
|
|
83
|
-
tagline: createSimpleStringSchema({ max: 30 }).optional(),
|
|
84
|
-
ogTitle: createSimpleStringSchema({ max: 30 }).optional(),
|
|
85
|
-
ogDescription: createSimpleStringSchema({ max: 100 }).optional(),
|
|
86
|
-
ogImageUrl: secureUrlSchema.optional(),
|
|
87
|
-
/** see: https://github.com/farcasterxyz/miniapps/discussions/204 */
|
|
88
|
-
noindex: z.boolean().optional(),
|
|
89
|
-
/** see https://github.com/farcasterxyz/miniapps/discussions/256 */
|
|
90
|
-
requiredChains: z
|
|
91
|
-
.array(z.enum(chainList))
|
|
92
|
-
.transform(removeArrayDuplicates)
|
|
93
|
-
.optional(),
|
|
94
|
-
requiredCapabilities: z
|
|
95
|
-
.array(z.enum(miniAppHostCapabilityList))
|
|
96
|
-
.transform(removeArrayDuplicates)
|
|
97
|
-
.optional(),
|
|
98
|
-
/** see https://github.com/farcasterxyz/miniapps/discussions/158 */
|
|
99
|
-
/** Documentation will be added once this feature is finalized. */
|
|
100
|
-
castShareUrl: secureUrlSchema.optional(),
|
|
101
|
-
})
|
|
102
|
-
.refine(
|
|
103
|
-
(data) => {
|
|
104
|
-
if (data.castShareUrl === undefined) return true
|
|
105
|
-
try {
|
|
106
|
-
const homeUrlDomain = new URL(data.homeUrl).hostname
|
|
107
|
-
const castShareUrlDomain = new URL(data.castShareUrl).hostname
|
|
108
|
-
return homeUrlDomain === castShareUrlDomain
|
|
109
|
-
} catch {
|
|
110
|
-
return false
|
|
111
|
-
}
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
message: 'castShareUrl must have the same domain as homeUrl',
|
|
115
|
-
path: ['castShareUrl'],
|
|
116
|
-
},
|
|
117
|
-
)
|
|
118
|
-
|
|
119
|
-
export const domainManifestSchema = z.object({
|
|
120
|
-
accountAssociation: encodedJsonFarcasterSignatureSchema,
|
|
121
|
-
frame: domainFrameConfigSchema.optional(),
|
|
122
|
-
})
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
import { secureUrlSchema } from './shared.ts'
|
|
3
|
-
|
|
4
|
-
export const notificationDetailsSchema = z.object({
|
|
5
|
-
url: z.string(),
|
|
6
|
-
token: z.string(),
|
|
7
|
-
})
|
|
8
|
-
|
|
9
|
-
export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema>
|
|
10
|
-
|
|
11
|
-
export const sendNotificationRequestSchema = z.object({
|
|
12
|
-
notificationId: z.string().max(128),
|
|
13
|
-
title: z.string().max(32),
|
|
14
|
-
body: z.string().max(128),
|
|
15
|
-
targetUrl: secureUrlSchema,
|
|
16
|
-
tokens: z.string().array().max(100),
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
export type SendNotificationRequest = z.infer<
|
|
20
|
-
typeof sendNotificationRequestSchema
|
|
21
|
-
>
|
|
22
|
-
|
|
23
|
-
export const sendNotificationResponseSchema = z.object({
|
|
24
|
-
result: z.object({
|
|
25
|
-
successfulTokens: z.array(z.string()),
|
|
26
|
-
invalidTokens: z.array(z.string()),
|
|
27
|
-
rateLimitedTokens: z.array(z.string()),
|
|
28
|
-
}),
|
|
29
|
-
})
|
|
30
|
-
|
|
31
|
-
export type SendNotificationResponse = z.infer<
|
|
32
|
-
typeof sendNotificationResponseSchema
|
|
33
|
-
>
|
package/src/schemas/shared.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod'
|
|
2
|
-
|
|
3
|
-
const SPECIAL_CHARS_PATTERN = /[@#$%^&*+=\/\\|~«»]/
|
|
4
|
-
const REPEATED_PUNCTUATION_PATTERN = /(!{2,}|\?{2,}|-{2,})/
|
|
5
|
-
|
|
6
|
-
// Unicode ranges for emoji detection:
|
|
7
|
-
// \u{1F300}-\u{1F9FF} - Miscellaneous Symbols, Pictographs, Emoticons, Transport, Map, and Supplemental
|
|
8
|
-
// \u{2702}-\u{27B0} - Dingbats
|
|
9
|
-
// \u{2600}-\u{26FF} - Miscellaneous Symbols
|
|
10
|
-
// \u{2B00}-\u{2BFF} - Miscellaneous Symbols and Arrows
|
|
11
|
-
const EMOJI_PATTERN =
|
|
12
|
-
/[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u
|
|
13
|
-
|
|
14
|
-
export const createSimpleStringSchema = ({
|
|
15
|
-
max,
|
|
16
|
-
noSpaces,
|
|
17
|
-
}: { max?: number; noSpaces?: boolean } = {}) => {
|
|
18
|
-
const stringValidations = noSpaces
|
|
19
|
-
? z
|
|
20
|
-
.string()
|
|
21
|
-
.max(max ?? Number.POSITIVE_INFINITY)
|
|
22
|
-
.regex(/^\S*$/, 'Spaces are not allowed')
|
|
23
|
-
: z.string().max(max ?? Number.POSITIVE_INFINITY)
|
|
24
|
-
|
|
25
|
-
return stringValidations
|
|
26
|
-
.refine((value) => !EMOJI_PATTERN.test(value), {
|
|
27
|
-
message: 'Emojis and symbols are not allowed',
|
|
28
|
-
})
|
|
29
|
-
.refine((value) => !SPECIAL_CHARS_PATTERN.test(value), {
|
|
30
|
-
message:
|
|
31
|
-
'Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed',
|
|
32
|
-
})
|
|
33
|
-
.refine((value) => !REPEATED_PUNCTUATION_PATTERN.test(value), {
|
|
34
|
-
message: 'Repeated punctuations (!!, ??, --) are not allowed',
|
|
35
|
-
})
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
export const secureUrlSchema = z
|
|
39
|
-
.string()
|
|
40
|
-
.url()
|
|
41
|
-
.startsWith('https://', { message: 'Must be an https url' })
|
|
42
|
-
.max(1024)
|
|
43
|
-
|
|
44
|
-
export const frameNameSchema = z.string().max(32)
|
|
45
|
-
export const buttonTitleSchema = z.string().max(32)
|
|
46
|
-
|
|
47
|
-
const CAIP_19_REGEX =
|
|
48
|
-
/^[-a-z0-9]{3,8}:[-_a-zA-Z0-9]{1,32}\/(?:[-a-z0-9]{3,8}:[-.%a-zA-Z0-9]{1,128}(?:\/[-.%a-zA-Z0-9]{1,78})?|native)$/
|
|
49
|
-
|
|
50
|
-
export const caip19TokenSchema = z
|
|
51
|
-
.string()
|
|
52
|
-
.regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' })
|
|
53
|
-
|
|
54
|
-
export const hexColorSchema = z
|
|
55
|
-
.string()
|
|
56
|
-
.regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
|
|
57
|
-
message:
|
|
58
|
-
'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
|
|
59
|
-
})
|
|
60
|
-
|
|
61
|
-
export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')])
|
|
62
|
-
|
|
63
|
-
export const encodedJsonFarcasterSignatureSchema = z.object({
|
|
64
|
-
header: z.string(),
|
|
65
|
-
payload: z.string(),
|
|
66
|
-
signature: z.string(),
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
export type EncodedJsonFarcasterSignatureSchema = z.infer<
|
|
70
|
-
typeof encodedJsonFarcasterSignatureSchema
|
|
71
|
-
>
|
|
72
|
-
|
|
73
|
-
export const jsonFarcasterSignatureHeaderSchema = z.object({
|
|
74
|
-
fid: z.number(),
|
|
75
|
-
type: z.literal('app_key'),
|
|
76
|
-
key: z.string().startsWith('0x'),
|
|
77
|
-
})
|
|
78
|
-
|
|
79
|
-
export type JsonFarcasterSignatureHeaderSchema = z.infer<
|
|
80
|
-
typeof jsonFarcasterSignatureHeaderSchema
|
|
81
|
-
>
|
package/src/solana.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Connection as SolanaConnection,
|
|
3
|
-
type SendOptions as SolanaSendOptions,
|
|
4
|
-
type Transaction as SolanaTransaction,
|
|
5
|
-
type VersionedTransaction as SolanaVersionedTransaction,
|
|
6
|
-
} from '@solana/web3.js'
|
|
7
|
-
|
|
8
|
-
export { SolanaConnection }
|
|
9
|
-
export type { SolanaSendOptions }
|
|
10
|
-
|
|
11
|
-
export type SolanaCombinedTransaction =
|
|
12
|
-
| SolanaTransaction
|
|
13
|
-
| SolanaVersionedTransaction
|
|
14
|
-
|
|
15
|
-
export type SolanaConnectRequestArguments = {
|
|
16
|
-
method: 'connect'
|
|
17
|
-
}
|
|
18
|
-
export type SolanaSignMessageRequestArguments = {
|
|
19
|
-
method: 'signMessage'
|
|
20
|
-
params: {
|
|
21
|
-
message: string
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
export type SolanaSignAndSendTransactionRequestArguments = {
|
|
25
|
-
method: 'signAndSendTransaction'
|
|
26
|
-
params: {
|
|
27
|
-
transaction: SolanaCombinedTransaction
|
|
28
|
-
options?: SolanaSendOptions
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
export type SolanaSignTransactionRequestArguments<
|
|
32
|
-
T extends SolanaCombinedTransaction = SolanaTransaction,
|
|
33
|
-
> = {
|
|
34
|
-
method: 'signTransaction'
|
|
35
|
-
params: {
|
|
36
|
-
transaction: T
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export type SolanaRequestFn = ((
|
|
41
|
-
request: SolanaConnectRequestArguments,
|
|
42
|
-
) => Promise<{ publicKey: string }>) &
|
|
43
|
-
((request: SolanaSignMessageRequestArguments) => Promise<{
|
|
44
|
-
signature: string
|
|
45
|
-
}>) &
|
|
46
|
-
((request: SolanaSignAndSendTransactionRequestArguments) => Promise<{
|
|
47
|
-
signature: string
|
|
48
|
-
}>) &
|
|
49
|
-
(<T extends SolanaCombinedTransaction>(
|
|
50
|
-
request: SolanaSignTransactionRequestArguments<T>,
|
|
51
|
-
) => Promise<{ signedTransaction: T }>)
|
|
52
|
-
|
|
53
|
-
export interface SolanaWalletProvider {
|
|
54
|
-
request: SolanaRequestFn
|
|
55
|
-
|
|
56
|
-
signMessage(message: string): Promise<{ signature: string }>
|
|
57
|
-
signTransaction<T extends SolanaCombinedTransaction>(
|
|
58
|
-
transaction: T,
|
|
59
|
-
): Promise<{ signedTransaction: T }>
|
|
60
|
-
signAndSendTransaction(input: {
|
|
61
|
-
transaction: SolanaCombinedTransaction
|
|
62
|
-
}): Promise<{ signature: string }>
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
export const createSolanaWalletProvider = (
|
|
66
|
-
request: SolanaRequestFn,
|
|
67
|
-
): SolanaWalletProvider => ({
|
|
68
|
-
request,
|
|
69
|
-
signMessage: (msg: string) =>
|
|
70
|
-
request({ method: 'signMessage', params: { message: msg } }),
|
|
71
|
-
signTransaction: <T extends SolanaCombinedTransaction>(transaction: T) =>
|
|
72
|
-
request({ method: 'signTransaction', params: { transaction } }),
|
|
73
|
-
signAndSendTransaction: (input: {
|
|
74
|
-
transaction: SolanaCombinedTransaction
|
|
75
|
-
}) =>
|
|
76
|
-
request({
|
|
77
|
-
method: 'signAndSendTransaction',
|
|
78
|
-
params: input,
|
|
79
|
-
}),
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
export type SolanaWireSignAndSendTransactionRequestArguments = {
|
|
83
|
-
method: 'signAndSendTransaction'
|
|
84
|
-
params: {
|
|
85
|
-
transaction: string
|
|
86
|
-
options?: SolanaSendOptions
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export type SolanaWireSignTransactionRequestArguments = {
|
|
91
|
-
method: 'signTransaction'
|
|
92
|
-
params: {
|
|
93
|
-
transaction: string
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
export type SolanaWireRequestFn = ((
|
|
98
|
-
request: SolanaConnectRequestArguments,
|
|
99
|
-
) => Promise<{ publicKey: string }>) &
|
|
100
|
-
((request: SolanaSignMessageRequestArguments) => Promise<{
|
|
101
|
-
signature: string
|
|
102
|
-
}>) &
|
|
103
|
-
((request: SolanaWireSignAndSendTransactionRequestArguments) => Promise<{
|
|
104
|
-
signature: string
|
|
105
|
-
}>) &
|
|
106
|
-
((
|
|
107
|
-
request: SolanaWireSignTransactionRequestArguments,
|
|
108
|
-
) => Promise<{ signedTransaction: string }>)
|
package/src/solanaWire.ts
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Transaction as SolanaTransaction,
|
|
3
|
-
VersionedMessage as SolanaVersionedMessage,
|
|
4
|
-
VersionedTransaction as SolanaVersionedTransaction,
|
|
5
|
-
} from '@solana/web3.js'
|
|
6
|
-
|
|
7
|
-
import type {
|
|
8
|
-
SolanaCombinedTransaction,
|
|
9
|
-
SolanaConnectRequestArguments,
|
|
10
|
-
SolanaRequestFn,
|
|
11
|
-
SolanaSignAndSendTransactionRequestArguments,
|
|
12
|
-
SolanaSignMessageRequestArguments,
|
|
13
|
-
SolanaSignTransactionRequestArguments,
|
|
14
|
-
SolanaWireRequestFn,
|
|
15
|
-
SolanaWireSignAndSendTransactionRequestArguments,
|
|
16
|
-
SolanaWireSignTransactionRequestArguments,
|
|
17
|
-
} from './solana.ts'
|
|
18
|
-
|
|
19
|
-
function serializeTransaction(transaction: SolanaCombinedTransaction): string {
|
|
20
|
-
return Buffer.from(
|
|
21
|
-
transaction.serialize({
|
|
22
|
-
verifySignatures: false,
|
|
23
|
-
}),
|
|
24
|
-
).toString('base64')
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function unserializeTransaction(
|
|
28
|
-
transaction: string,
|
|
29
|
-
): SolanaCombinedTransaction {
|
|
30
|
-
const bytes = Buffer.from(transaction, 'base64')
|
|
31
|
-
const version = SolanaVersionedMessage.deserializeMessageVersion(bytes)
|
|
32
|
-
return version === 'legacy'
|
|
33
|
-
? SolanaVersionedTransaction.deserialize(bytes)
|
|
34
|
-
: SolanaTransaction.from(bytes)
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export function wrapSolanaProviderRequest(
|
|
38
|
-
requestFn: SolanaRequestFn,
|
|
39
|
-
): SolanaWireRequestFn {
|
|
40
|
-
const wrappedFn = async (
|
|
41
|
-
request:
|
|
42
|
-
| SolanaConnectRequestArguments
|
|
43
|
-
| SolanaSignMessageRequestArguments
|
|
44
|
-
| SolanaWireSignAndSendTransactionRequestArguments
|
|
45
|
-
| SolanaWireSignTransactionRequestArguments,
|
|
46
|
-
) => {
|
|
47
|
-
if (request.method === 'connect') {
|
|
48
|
-
return await requestFn(request)
|
|
49
|
-
}
|
|
50
|
-
if (request.method === 'signMessage') {
|
|
51
|
-
return await requestFn(request)
|
|
52
|
-
}
|
|
53
|
-
if (request.method === 'signAndSendTransaction') {
|
|
54
|
-
const { transaction, options } = request.params
|
|
55
|
-
const params = {
|
|
56
|
-
transaction: unserializeTransaction(transaction),
|
|
57
|
-
options,
|
|
58
|
-
}
|
|
59
|
-
return await requestFn({
|
|
60
|
-
method: 'signAndSendTransaction',
|
|
61
|
-
params,
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
if (request.method === 'signTransaction') {
|
|
65
|
-
const { transaction } = request.params
|
|
66
|
-
const params = {
|
|
67
|
-
transaction: unserializeTransaction(transaction),
|
|
68
|
-
}
|
|
69
|
-
const { signedTransaction } = await requestFn({
|
|
70
|
-
method: 'signTransaction',
|
|
71
|
-
params,
|
|
72
|
-
})
|
|
73
|
-
return {
|
|
74
|
-
signedTransaction: serializeTransaction(signedTransaction),
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
return wrappedFn as SolanaWireRequestFn
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
export function unwrapSolanaProviderRequest(
|
|
82
|
-
wrappedRequestFn: SolanaWireRequestFn,
|
|
83
|
-
): SolanaRequestFn {
|
|
84
|
-
const unwrappedFn = async <T extends SolanaCombinedTransaction>(
|
|
85
|
-
request:
|
|
86
|
-
| SolanaConnectRequestArguments
|
|
87
|
-
| SolanaSignMessageRequestArguments
|
|
88
|
-
| SolanaSignAndSendTransactionRequestArguments
|
|
89
|
-
| SolanaSignTransactionRequestArguments<T>,
|
|
90
|
-
) => {
|
|
91
|
-
if (request.method === 'connect') {
|
|
92
|
-
return await wrappedRequestFn(request)
|
|
93
|
-
}
|
|
94
|
-
if (request.method === 'signMessage') {
|
|
95
|
-
return await wrappedRequestFn(request)
|
|
96
|
-
}
|
|
97
|
-
if (request.method === 'signAndSendTransaction') {
|
|
98
|
-
const { transaction, options } = request.params
|
|
99
|
-
const params = {
|
|
100
|
-
transaction: serializeTransaction(transaction),
|
|
101
|
-
}
|
|
102
|
-
return await wrappedRequestFn({
|
|
103
|
-
method: 'signAndSendTransaction',
|
|
104
|
-
params,
|
|
105
|
-
})
|
|
106
|
-
}
|
|
107
|
-
if (request.method === 'signTransaction') {
|
|
108
|
-
const { transaction } = request.params
|
|
109
|
-
const params = {
|
|
110
|
-
transaction: serializeTransaction(transaction),
|
|
111
|
-
}
|
|
112
|
-
const { signedTransaction } = await wrappedRequestFn({
|
|
113
|
-
method: 'signTransaction',
|
|
114
|
-
params,
|
|
115
|
-
})
|
|
116
|
-
return { signedTransaction: unserializeTransaction(signedTransaction) }
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
return unwrappedFn as SolanaRequestFn
|
|
120
|
-
}
|
package/src/types.ts
DELETED
|
@@ -1,155 +0,0 @@
|
|
|
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 { FrameContext } from './context.ts'
|
|
19
|
-
import type {
|
|
20
|
-
EventFrameAdded,
|
|
21
|
-
EventFrameRemoved,
|
|
22
|
-
EventNotificationsDisabled,
|
|
23
|
-
EventNotificationsEnabled,
|
|
24
|
-
} from './schemas/index.ts'
|
|
25
|
-
import type { SolanaRequestFn, SolanaWireRequestFn } from './solana.ts'
|
|
26
|
-
import type { Ethereum } from './wallet/index.ts'
|
|
27
|
-
|
|
28
|
-
export type SetPrimaryButtonOptions = {
|
|
29
|
-
text: string
|
|
30
|
-
loading?: boolean
|
|
31
|
-
disabled?: boolean
|
|
32
|
-
hidden?: boolean
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// start backwards compat, remove in 1.0
|
|
36
|
-
export * from './wallet/ethereum.ts'
|
|
37
|
-
export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready.ts'
|
|
38
|
-
export type SignInOptions = SignIn.SignInOptions
|
|
39
|
-
// end backwards compat
|
|
40
|
-
|
|
41
|
-
export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void
|
|
42
|
-
|
|
43
|
-
// Export haptics types
|
|
44
|
-
export type { ImpactOccurred, NotificationOccurred, SelectionChanged }
|
|
45
|
-
|
|
46
|
-
export const miniAppHostCapabilityList = [
|
|
47
|
-
'wallet.getEthereumProvider',
|
|
48
|
-
'wallet.getSolanaProvider',
|
|
49
|
-
'actions.ready',
|
|
50
|
-
'actions.openUrl',
|
|
51
|
-
'actions.close',
|
|
52
|
-
'actions.setPrimaryButton',
|
|
53
|
-
'actions.addMiniApp',
|
|
54
|
-
'actions.signIn',
|
|
55
|
-
'actions.viewCast',
|
|
56
|
-
'actions.viewProfile',
|
|
57
|
-
'actions.composeCast',
|
|
58
|
-
'actions.viewToken',
|
|
59
|
-
'actions.sendToken',
|
|
60
|
-
'actions.swapToken',
|
|
61
|
-
'haptics.impactOccurred',
|
|
62
|
-
'haptics.notificationOccurred',
|
|
63
|
-
'haptics.selectionChanged',
|
|
64
|
-
'back',
|
|
65
|
-
] as const
|
|
66
|
-
|
|
67
|
-
export type MiniAppHostCapability = (typeof miniAppHostCapabilityList)[number]
|
|
68
|
-
|
|
69
|
-
export type GetCapabilities = () => Promise<MiniAppHostCapability[]>
|
|
70
|
-
|
|
71
|
-
// Returns a list of CAIP-2 identifiers
|
|
72
|
-
export type GetChains = () => Promise<string[]>
|
|
73
|
-
|
|
74
|
-
export type WireFrameHost = {
|
|
75
|
-
context: FrameContext
|
|
76
|
-
close: () => void
|
|
77
|
-
ready: Ready.Ready
|
|
78
|
-
openUrl: (url: string) => void
|
|
79
|
-
signIn: SignIn.WireSignIn
|
|
80
|
-
setPrimaryButton: SetPrimaryButton
|
|
81
|
-
ethProviderRequest: Ethereum.EthProvideRequest
|
|
82
|
-
ethProviderRequestV2: Ethereum.RpcTransport
|
|
83
|
-
eip6963RequestProvider: () => void
|
|
84
|
-
solanaProviderRequest?: SolanaWireRequestFn
|
|
85
|
-
addFrame: AddMiniApp.WireAddMiniApp
|
|
86
|
-
viewCast: ViewCast.ViewCast
|
|
87
|
-
viewProfile: ViewProfile.ViewProfile
|
|
88
|
-
viewToken: ViewToken.ViewToken
|
|
89
|
-
sendToken: SendToken.SendToken
|
|
90
|
-
swapToken: SwapToken.SwapToken
|
|
91
|
-
composeCast: <close extends boolean | undefined = undefined>(
|
|
92
|
-
options: ComposeCast.Options<close>,
|
|
93
|
-
) => Promise<ComposeCast.Result<close>>
|
|
94
|
-
impactOccurred: ImpactOccurred
|
|
95
|
-
notificationOccurred: NotificationOccurred
|
|
96
|
-
selectionChanged: SelectionChanged
|
|
97
|
-
getCapabilities: GetCapabilities
|
|
98
|
-
getChains: GetChains
|
|
99
|
-
updateBackState: UpdateBackState
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export type FrameHost = {
|
|
103
|
-
context: FrameContext
|
|
104
|
-
close: () => void
|
|
105
|
-
ready: Ready.Ready
|
|
106
|
-
openUrl: (url: string) => void
|
|
107
|
-
signIn: SignIn.SignIn
|
|
108
|
-
setPrimaryButton: SetPrimaryButton
|
|
109
|
-
ethProviderRequest: Ethereum.EthProvideRequest
|
|
110
|
-
ethProviderRequestV2: Ethereum.RpcTransport
|
|
111
|
-
/**
|
|
112
|
-
* Receive forwarded eip6963:requestProvider events from the frame document.
|
|
113
|
-
* Hosts must emit an EventEip6963AnnounceProvider in response.
|
|
114
|
-
*/
|
|
115
|
-
eip6963RequestProvider: () => void
|
|
116
|
-
solanaProviderRequest?: SolanaRequestFn
|
|
117
|
-
addFrame: AddMiniApp.AddMiniApp
|
|
118
|
-
viewCast: ViewCast.ViewCast
|
|
119
|
-
viewProfile: ViewProfile.ViewProfile
|
|
120
|
-
viewToken: ViewToken.ViewToken
|
|
121
|
-
sendToken: SendToken.SendToken
|
|
122
|
-
swapToken: SwapToken.SwapToken
|
|
123
|
-
composeCast: <close extends boolean | undefined = undefined>(
|
|
124
|
-
options: ComposeCast.Options<close>,
|
|
125
|
-
) => Promise<ComposeCast.Result<close>>
|
|
126
|
-
impactOccurred: ImpactOccurred
|
|
127
|
-
notificationOccurred: NotificationOccurred
|
|
128
|
-
selectionChanged: SelectionChanged
|
|
129
|
-
getCapabilities: GetCapabilities
|
|
130
|
-
getChains: GetChains
|
|
131
|
-
updateBackState: UpdateBackState
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
export type EventFrameAddRejected = {
|
|
135
|
-
event: 'frame_add_rejected'
|
|
136
|
-
reason: AddMiniApp.AddMiniAppRejectedReason
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export type EventPrimaryButtonClicked = {
|
|
140
|
-
event: 'primary_button_clicked'
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
export type EventBackNavigationTriggered = {
|
|
144
|
-
event: 'back_navigation_triggered'
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
export type FrameClientEvent =
|
|
148
|
-
| EventFrameAdded
|
|
149
|
-
| EventFrameAddRejected
|
|
150
|
-
| EventFrameRemoved
|
|
151
|
-
| EventNotificationsEnabled
|
|
152
|
-
| EventNotificationsDisabled
|
|
153
|
-
| EventPrimaryButtonClicked
|
|
154
|
-
| EventBackNavigationTriggered
|
|
155
|
-
| Ethereum.EventEip6963AnnounceProvider
|
package/src/wallet/ethereum.ts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
}
|
package/src/wallet/index.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * as Ethereum from './ethereum.ts'
|