@farcaster/frame-core 0.2.0 → 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 -107
- 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 -348
- package/dist/schemas/manifest.js +0 -114
- package/dist/schemas/notifications.d.ts +0 -60
- package/dist/schemas/notifications.js +0 -23
- package/dist/schemas/shared.d.ts +0 -40
- package/dist/schemas/shared.js +0 -83
- 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 -107
- 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 -348
- package/esm/schemas/manifest.js +0 -111
- package/esm/schemas/notifications.d.ts +0 -60
- package/esm/schemas/notifications.js +0 -20
- package/esm/schemas/shared.d.ts +0 -40
- package/esm/schemas/shared.js +0 -79
- 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 -120
- 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 -125
- package/src/schemas/notifications.ts +0 -33
- package/src/schemas/shared.ts +0 -109
- 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/shared.ts
DELETED
|
@@ -1,109 +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
|
-
// Domain validation regex:
|
|
62
|
-
// - Each label (part between dots) must start and end with alphanumeric
|
|
63
|
-
// - Labels can contain hyphens in the middle
|
|
64
|
-
// - Cannot have consecutive dots
|
|
65
|
-
// - Must have at least one dot (TLD required)
|
|
66
|
-
// - TLD must be at least 2 characters and only letters
|
|
67
|
-
const DOMAIN_REGEX =
|
|
68
|
-
/^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/
|
|
69
|
-
|
|
70
|
-
export const domainSchema = z
|
|
71
|
-
.string()
|
|
72
|
-
.max(1024)
|
|
73
|
-
.regex(DOMAIN_REGEX, {
|
|
74
|
-
message: 'Must be a valid domain name (e.g., example.com, sub.example.com)',
|
|
75
|
-
})
|
|
76
|
-
.refine((value) => !value.includes('://'), {
|
|
77
|
-
message: 'Domain must not include protocol (http://, https://, etc.)',
|
|
78
|
-
})
|
|
79
|
-
.refine((value) => !value.includes('/'), {
|
|
80
|
-
message: 'Domain must not include path separators',
|
|
81
|
-
})
|
|
82
|
-
.refine((value) => !value.includes('@'), {
|
|
83
|
-
message: 'Domain must not include @ symbol',
|
|
84
|
-
})
|
|
85
|
-
.refine((value) => !value.includes(':'), {
|
|
86
|
-
message: 'Domain must not include port numbers',
|
|
87
|
-
})
|
|
88
|
-
|
|
89
|
-
export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')])
|
|
90
|
-
|
|
91
|
-
export const encodedJsonFarcasterSignatureSchema = z.object({
|
|
92
|
-
header: z.string(),
|
|
93
|
-
payload: z.string(),
|
|
94
|
-
signature: z.string(),
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
export type EncodedJsonFarcasterSignatureSchema = z.infer<
|
|
98
|
-
typeof encodedJsonFarcasterSignatureSchema
|
|
99
|
-
>
|
|
100
|
-
|
|
101
|
-
export const jsonFarcasterSignatureHeaderSchema = z.object({
|
|
102
|
-
fid: z.number(),
|
|
103
|
-
type: z.literal('app_key'),
|
|
104
|
-
key: z.string().startsWith('0x'),
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
export type JsonFarcasterSignatureHeaderSchema = z.infer<
|
|
108
|
-
typeof jsonFarcasterSignatureHeaderSchema
|
|
109
|
-
>
|
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'
|