@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.
Files changed (142) hide show
  1. package/dist/index.d.ts +153 -10
  2. package/dist/index.js +18 -33
  3. package/esm/index.d.ts +153 -10
  4. package/esm/index.js +17 -10
  5. package/esm/tsconfig.tsbuildinfo +1 -1
  6. package/package.json +6 -8
  7. package/src/index.ts +50 -10
  8. package/dist/actions/AddMiniApp.d.ts +0 -36
  9. package/dist/actions/AddMiniApp.js +0 -57
  10. package/dist/actions/ComposeCast.d.ts +0 -37
  11. package/dist/actions/ComposeCast.js +0 -2
  12. package/dist/actions/Haptics.d.ts +0 -5
  13. package/dist/actions/Haptics.js +0 -2
  14. package/dist/actions/Ready.d.ts +0 -13
  15. package/dist/actions/Ready.js +0 -6
  16. package/dist/actions/SendToken.d.ts +0 -48
  17. package/dist/actions/SendToken.js +0 -2
  18. package/dist/actions/SignIn.d.ts +0 -55
  19. package/dist/actions/SignIn.js +0 -47
  20. package/dist/actions/SwapToken.d.ts +0 -46
  21. package/dist/actions/SwapToken.js +0 -2
  22. package/dist/actions/ViewCast.d.ts +0 -25
  23. package/dist/actions/ViewCast.js +0 -2
  24. package/dist/actions/ViewProfile.d.ts +0 -4
  25. package/dist/actions/ViewProfile.js +0 -2
  26. package/dist/actions/ViewToken.d.ts +0 -4
  27. package/dist/actions/ViewToken.js +0 -2
  28. package/dist/actions/index.d.ts +0 -10
  29. package/dist/actions/index.js +0 -46
  30. package/dist/back.d.ts +0 -13
  31. package/dist/back.js +0 -6
  32. package/dist/context.d.ts +0 -94
  33. package/dist/context.js +0 -2
  34. package/dist/errors.d.ts +0 -13
  35. package/dist/errors.js +0 -12
  36. package/dist/internal/types.d.ts +0 -8
  37. package/dist/internal/types.js +0 -2
  38. package/dist/manifest.d.ts +0 -107
  39. package/dist/manifest.js +0 -2
  40. package/dist/schemas/embeds.d.ts +0 -243
  41. package/dist/schemas/embeds.js +0 -32
  42. package/dist/schemas/events.d.ts +0 -131
  43. package/dist/schemas/events.js +0 -25
  44. package/dist/schemas/index.d.ts +0 -5
  45. package/dist/schemas/index.js +0 -21
  46. package/dist/schemas/manifest.d.ts +0 -348
  47. package/dist/schemas/manifest.js +0 -114
  48. package/dist/schemas/notifications.d.ts +0 -60
  49. package/dist/schemas/notifications.js +0 -23
  50. package/dist/schemas/shared.d.ts +0 -40
  51. package/dist/schemas/shared.js +0 -83
  52. package/dist/solana.d.ts +0 -72
  53. package/dist/solana.js +0 -15
  54. package/dist/solanaWire.d.ts +0 -3
  55. package/dist/solanaWire.js +0 -84
  56. package/dist/types.d.ts +0 -87
  57. package/dist/types.js +0 -41
  58. package/dist/wallet/ethereum.d.ts +0 -47
  59. package/dist/wallet/ethereum.js +0 -2
  60. package/dist/wallet/index.d.ts +0 -1
  61. package/dist/wallet/index.js +0 -37
  62. package/esm/actions/AddMiniApp.d.ts +0 -36
  63. package/esm/actions/AddMiniApp.js +0 -19
  64. package/esm/actions/ComposeCast.d.ts +0 -37
  65. package/esm/actions/ComposeCast.js +0 -1
  66. package/esm/actions/Haptics.d.ts +0 -5
  67. package/esm/actions/Haptics.js +0 -1
  68. package/esm/actions/Ready.d.ts +0 -13
  69. package/esm/actions/Ready.js +0 -3
  70. package/esm/actions/SendToken.d.ts +0 -48
  71. package/esm/actions/SendToken.js +0 -1
  72. package/esm/actions/SignIn.d.ts +0 -55
  73. package/esm/actions/SignIn.js +0 -10
  74. package/esm/actions/SwapToken.d.ts +0 -46
  75. package/esm/actions/SwapToken.js +0 -1
  76. package/esm/actions/ViewCast.d.ts +0 -25
  77. package/esm/actions/ViewCast.js +0 -1
  78. package/esm/actions/ViewProfile.d.ts +0 -4
  79. package/esm/actions/ViewProfile.js +0 -1
  80. package/esm/actions/ViewToken.d.ts +0 -4
  81. package/esm/actions/ViewToken.js +0 -1
  82. package/esm/actions/index.d.ts +0 -10
  83. package/esm/actions/index.js +0 -10
  84. package/esm/back.d.ts +0 -13
  85. package/esm/back.js +0 -3
  86. package/esm/context.d.ts +0 -94
  87. package/esm/context.js +0 -1
  88. package/esm/errors.d.ts +0 -13
  89. package/esm/errors.js +0 -8
  90. package/esm/internal/types.d.ts +0 -8
  91. package/esm/internal/types.js +0 -1
  92. package/esm/manifest.d.ts +0 -107
  93. package/esm/manifest.js +0 -1
  94. package/esm/schemas/embeds.d.ts +0 -243
  95. package/esm/schemas/embeds.js +0 -28
  96. package/esm/schemas/events.d.ts +0 -131
  97. package/esm/schemas/events.js +0 -22
  98. package/esm/schemas/index.d.ts +0 -5
  99. package/esm/schemas/index.js +0 -5
  100. package/esm/schemas/manifest.d.ts +0 -348
  101. package/esm/schemas/manifest.js +0 -111
  102. package/esm/schemas/notifications.d.ts +0 -60
  103. package/esm/schemas/notifications.js +0 -20
  104. package/esm/schemas/shared.d.ts +0 -40
  105. package/esm/schemas/shared.js +0 -79
  106. package/esm/solana.d.ts +0 -72
  107. package/esm/solana.js +0 -11
  108. package/esm/solanaWire.d.ts +0 -3
  109. package/esm/solanaWire.js +0 -80
  110. package/esm/types.d.ts +0 -87
  111. package/esm/types.js +0 -23
  112. package/esm/wallet/ethereum.d.ts +0 -47
  113. package/esm/wallet/ethereum.js +0 -1
  114. package/esm/wallet/index.d.ts +0 -1
  115. package/esm/wallet/index.js +0 -1
  116. package/src/actions/AddMiniApp.ts +0 -51
  117. package/src/actions/ComposeCast.ts +0 -44
  118. package/src/actions/Haptics.ts +0 -9
  119. package/src/actions/Ready.ts +0 -15
  120. package/src/actions/SendToken.ts +0 -57
  121. package/src/actions/SignIn.ts +0 -67
  122. package/src/actions/SwapToken.ts +0 -54
  123. package/src/actions/ViewCast.ts +0 -27
  124. package/src/actions/ViewProfile.ts +0 -5
  125. package/src/actions/ViewToken.ts +0 -5
  126. package/src/actions/index.ts +0 -10
  127. package/src/back.ts +0 -15
  128. package/src/context.ts +0 -117
  129. package/src/errors.ts +0 -21
  130. package/src/internal/types.ts +0 -20
  131. package/src/manifest.ts +0 -120
  132. package/src/schemas/embeds.ts +0 -44
  133. package/src/schemas/events.ts +0 -41
  134. package/src/schemas/index.ts +0 -5
  135. package/src/schemas/manifest.ts +0 -125
  136. package/src/schemas/notifications.ts +0 -33
  137. package/src/schemas/shared.ts +0 -109
  138. package/src/solana.ts +0 -108
  139. package/src/solanaWire.ts +0 -120
  140. package/src/types.ts +0 -155
  141. package/src/wallet/ethereum.ts +0 -65
  142. package/src/wallet/index.ts +0 -1
@@ -1,79 +0,0 @@
1
- import { z } from 'zod';
2
- const SPECIAL_CHARS_PATTERN = /[@#$%^&*+=\/\\|~«»]/;
3
- const REPEATED_PUNCTUATION_PATTERN = /(!{2,}|\?{2,}|-{2,})/;
4
- // Unicode ranges for emoji detection:
5
- // \u{1F300}-\u{1F9FF} - Miscellaneous Symbols, Pictographs, Emoticons, Transport, Map, and Supplemental
6
- // \u{2702}-\u{27B0} - Dingbats
7
- // \u{2600}-\u{26FF} - Miscellaneous Symbols
8
- // \u{2B00}-\u{2BFF} - Miscellaneous Symbols and Arrows
9
- const EMOJI_PATTERN = /[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u;
10
- export const createSimpleStringSchema = ({ max, noSpaces, } = {}) => {
11
- const stringValidations = noSpaces
12
- ? z
13
- .string()
14
- .max(max ?? Number.POSITIVE_INFINITY)
15
- .regex(/^\S*$/, 'Spaces are not allowed')
16
- : z.string().max(max ?? Number.POSITIVE_INFINITY);
17
- return stringValidations
18
- .refine((value) => !EMOJI_PATTERN.test(value), {
19
- message: 'Emojis and symbols are not allowed',
20
- })
21
- .refine((value) => !SPECIAL_CHARS_PATTERN.test(value), {
22
- message: 'Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed',
23
- })
24
- .refine((value) => !REPEATED_PUNCTUATION_PATTERN.test(value), {
25
- message: 'Repeated punctuations (!!, ??, --) are not allowed',
26
- });
27
- };
28
- export const secureUrlSchema = z
29
- .string()
30
- .url()
31
- .startsWith('https://', { message: 'Must be an https url' })
32
- .max(1024);
33
- export const frameNameSchema = z.string().max(32);
34
- export const buttonTitleSchema = z.string().max(32);
35
- const CAIP_19_REGEX = /^[-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)$/;
36
- export const caip19TokenSchema = z
37
- .string()
38
- .regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' });
39
- export const hexColorSchema = z
40
- .string()
41
- .regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
42
- message: 'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
43
- });
44
- // Domain validation regex:
45
- // - Each label (part between dots) must start and end with alphanumeric
46
- // - Labels can contain hyphens in the middle
47
- // - Cannot have consecutive dots
48
- // - Must have at least one dot (TLD required)
49
- // - TLD must be at least 2 characters and only letters
50
- const DOMAIN_REGEX = /^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
51
- export const domainSchema = z
52
- .string()
53
- .max(1024)
54
- .regex(DOMAIN_REGEX, {
55
- message: 'Must be a valid domain name (e.g., example.com, sub.example.com)',
56
- })
57
- .refine((value) => !value.includes('://'), {
58
- message: 'Domain must not include protocol (http://, https://, etc.)',
59
- })
60
- .refine((value) => !value.includes('/'), {
61
- message: 'Domain must not include path separators',
62
- })
63
- .refine((value) => !value.includes('@'), {
64
- message: 'Domain must not include @ symbol',
65
- })
66
- .refine((value) => !value.includes(':'), {
67
- message: 'Domain must not include port numbers',
68
- });
69
- export const aspectRatioSchema = z.union([z.literal('1:1'), z.literal('3:2')]);
70
- export const encodedJsonFarcasterSignatureSchema = z.object({
71
- header: z.string(),
72
- payload: z.string(),
73
- signature: z.string(),
74
- });
75
- export const jsonFarcasterSignatureHeaderSchema = z.object({
76
- fid: z.number(),
77
- type: z.literal('app_key'),
78
- key: z.string().startsWith('0x'),
79
- });
package/esm/solana.d.ts DELETED
@@ -1,72 +0,0 @@
1
- import { Connection as SolanaConnection, type SendOptions as SolanaSendOptions, type Transaction as SolanaTransaction, type VersionedTransaction as SolanaVersionedTransaction } from '@solana/web3.js';
2
- export { SolanaConnection };
3
- export type { SolanaSendOptions };
4
- export type SolanaCombinedTransaction = SolanaTransaction | SolanaVersionedTransaction;
5
- export type SolanaConnectRequestArguments = {
6
- method: 'connect';
7
- };
8
- export type SolanaSignMessageRequestArguments = {
9
- method: 'signMessage';
10
- params: {
11
- message: string;
12
- };
13
- };
14
- export type SolanaSignAndSendTransactionRequestArguments = {
15
- method: 'signAndSendTransaction';
16
- params: {
17
- transaction: SolanaCombinedTransaction;
18
- options?: SolanaSendOptions;
19
- };
20
- };
21
- export type SolanaSignTransactionRequestArguments<T extends SolanaCombinedTransaction = SolanaTransaction> = {
22
- method: 'signTransaction';
23
- params: {
24
- transaction: T;
25
- };
26
- };
27
- export type SolanaRequestFn = ((request: SolanaConnectRequestArguments) => Promise<{
28
- publicKey: string;
29
- }>) & ((request: SolanaSignMessageRequestArguments) => Promise<{
30
- signature: string;
31
- }>) & ((request: SolanaSignAndSendTransactionRequestArguments) => Promise<{
32
- signature: string;
33
- }>) & (<T extends SolanaCombinedTransaction>(request: SolanaSignTransactionRequestArguments<T>) => Promise<{
34
- signedTransaction: T;
35
- }>);
36
- export interface SolanaWalletProvider {
37
- request: SolanaRequestFn;
38
- signMessage(message: string): Promise<{
39
- signature: string;
40
- }>;
41
- signTransaction<T extends SolanaCombinedTransaction>(transaction: T): Promise<{
42
- signedTransaction: T;
43
- }>;
44
- signAndSendTransaction(input: {
45
- transaction: SolanaCombinedTransaction;
46
- }): Promise<{
47
- signature: string;
48
- }>;
49
- }
50
- export declare const createSolanaWalletProvider: (request: SolanaRequestFn) => SolanaWalletProvider;
51
- export type SolanaWireSignAndSendTransactionRequestArguments = {
52
- method: 'signAndSendTransaction';
53
- params: {
54
- transaction: string;
55
- options?: SolanaSendOptions;
56
- };
57
- };
58
- export type SolanaWireSignTransactionRequestArguments = {
59
- method: 'signTransaction';
60
- params: {
61
- transaction: string;
62
- };
63
- };
64
- export type SolanaWireRequestFn = ((request: SolanaConnectRequestArguments) => Promise<{
65
- publicKey: string;
66
- }>) & ((request: SolanaSignMessageRequestArguments) => Promise<{
67
- signature: string;
68
- }>) & ((request: SolanaWireSignAndSendTransactionRequestArguments) => Promise<{
69
- signature: string;
70
- }>) & ((request: SolanaWireSignTransactionRequestArguments) => Promise<{
71
- signedTransaction: string;
72
- }>);
package/esm/solana.js DELETED
@@ -1,11 +0,0 @@
1
- import { Connection as SolanaConnection, } from '@solana/web3.js';
2
- export { SolanaConnection };
3
- export const createSolanaWalletProvider = (request) => ({
4
- request,
5
- signMessage: (msg) => request({ method: 'signMessage', params: { message: msg } }),
6
- signTransaction: (transaction) => request({ method: 'signTransaction', params: { transaction } }),
7
- signAndSendTransaction: (input) => request({
8
- method: 'signAndSendTransaction',
9
- params: input,
10
- }),
11
- });
@@ -1,3 +0,0 @@
1
- import type { SolanaRequestFn, SolanaWireRequestFn } from './solana.ts';
2
- export declare function wrapSolanaProviderRequest(requestFn: SolanaRequestFn): SolanaWireRequestFn;
3
- export declare function unwrapSolanaProviderRequest(wrappedRequestFn: SolanaWireRequestFn): SolanaRequestFn;
package/esm/solanaWire.js DELETED
@@ -1,80 +0,0 @@
1
- import { Transaction as SolanaTransaction, VersionedMessage as SolanaVersionedMessage, VersionedTransaction as SolanaVersionedTransaction, } from '@solana/web3.js';
2
- function serializeTransaction(transaction) {
3
- return Buffer.from(transaction.serialize({
4
- verifySignatures: false,
5
- })).toString('base64');
6
- }
7
- function unserializeTransaction(transaction) {
8
- const bytes = Buffer.from(transaction, 'base64');
9
- const version = SolanaVersionedMessage.deserializeMessageVersion(bytes);
10
- return version === 'legacy'
11
- ? SolanaVersionedTransaction.deserialize(bytes)
12
- : SolanaTransaction.from(bytes);
13
- }
14
- export function wrapSolanaProviderRequest(requestFn) {
15
- const wrappedFn = async (request) => {
16
- if (request.method === 'connect') {
17
- return await requestFn(request);
18
- }
19
- if (request.method === 'signMessage') {
20
- return await requestFn(request);
21
- }
22
- if (request.method === 'signAndSendTransaction') {
23
- const { transaction, options } = request.params;
24
- const params = {
25
- transaction: unserializeTransaction(transaction),
26
- options,
27
- };
28
- return await requestFn({
29
- method: 'signAndSendTransaction',
30
- params,
31
- });
32
- }
33
- if (request.method === 'signTransaction') {
34
- const { transaction } = request.params;
35
- const params = {
36
- transaction: unserializeTransaction(transaction),
37
- };
38
- const { signedTransaction } = await requestFn({
39
- method: 'signTransaction',
40
- params,
41
- });
42
- return {
43
- signedTransaction: serializeTransaction(signedTransaction),
44
- };
45
- }
46
- };
47
- return wrappedFn;
48
- }
49
- export function unwrapSolanaProviderRequest(wrappedRequestFn) {
50
- const unwrappedFn = async (request) => {
51
- if (request.method === 'connect') {
52
- return await wrappedRequestFn(request);
53
- }
54
- if (request.method === 'signMessage') {
55
- return await wrappedRequestFn(request);
56
- }
57
- if (request.method === 'signAndSendTransaction') {
58
- const { transaction, options } = request.params;
59
- const params = {
60
- transaction: serializeTransaction(transaction),
61
- };
62
- return await wrappedRequestFn({
63
- method: 'signAndSendTransaction',
64
- params,
65
- });
66
- }
67
- if (request.method === 'signTransaction') {
68
- const { transaction } = request.params;
69
- const params = {
70
- transaction: serializeTransaction(transaction),
71
- };
72
- const { signedTransaction } = await wrappedRequestFn({
73
- method: 'signTransaction',
74
- params,
75
- });
76
- return { signedTransaction: unserializeTransaction(signedTransaction) };
77
- }
78
- };
79
- return unwrappedFn;
80
- }
package/esm/types.d.ts DELETED
@@ -1,87 +0,0 @@
1
- import type { ImpactOccurred, NotificationOccurred, SelectionChanged } from './actions/Haptics.ts';
2
- import type { AddMiniApp, ComposeCast, Ready, SendToken, SignIn, SwapToken, ViewCast, ViewProfile, ViewToken } from './actions/index.ts';
3
- import type { UpdateBackState } from './back.ts';
4
- import type { FrameContext } from './context.ts';
5
- import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas/index.ts';
6
- import type { SolanaRequestFn, SolanaWireRequestFn } from './solana.ts';
7
- import type { Ethereum } from './wallet/index.ts';
8
- export type SetPrimaryButtonOptions = {
9
- text: string;
10
- loading?: boolean;
11
- disabled?: boolean;
12
- hidden?: boolean;
13
- };
14
- export * from './wallet/ethereum.ts';
15
- export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready.ts';
16
- export type SignInOptions = SignIn.SignInOptions;
17
- export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
18
- export type { ImpactOccurred, NotificationOccurred, SelectionChanged };
19
- export declare const miniAppHostCapabilityList: readonly ["wallet.getEthereumProvider", "wallet.getSolanaProvider", "actions.ready", "actions.openUrl", "actions.close", "actions.setPrimaryButton", "actions.addMiniApp", "actions.signIn", "actions.viewCast", "actions.viewProfile", "actions.composeCast", "actions.viewToken", "actions.sendToken", "actions.swapToken", "haptics.impactOccurred", "haptics.notificationOccurred", "haptics.selectionChanged", "back"];
20
- export type MiniAppHostCapability = (typeof miniAppHostCapabilityList)[number];
21
- export type GetCapabilities = () => Promise<MiniAppHostCapability[]>;
22
- export type GetChains = () => Promise<string[]>;
23
- export type WireFrameHost = {
24
- context: FrameContext;
25
- close: () => void;
26
- ready: Ready.Ready;
27
- openUrl: (url: string) => void;
28
- signIn: SignIn.WireSignIn;
29
- setPrimaryButton: SetPrimaryButton;
30
- ethProviderRequest: Ethereum.EthProvideRequest;
31
- ethProviderRequestV2: Ethereum.RpcTransport;
32
- eip6963RequestProvider: () => void;
33
- solanaProviderRequest?: SolanaWireRequestFn;
34
- addFrame: AddMiniApp.WireAddMiniApp;
35
- viewCast: ViewCast.ViewCast;
36
- viewProfile: ViewProfile.ViewProfile;
37
- viewToken: ViewToken.ViewToken;
38
- sendToken: SendToken.SendToken;
39
- swapToken: SwapToken.SwapToken;
40
- composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
41
- impactOccurred: ImpactOccurred;
42
- notificationOccurred: NotificationOccurred;
43
- selectionChanged: SelectionChanged;
44
- getCapabilities: GetCapabilities;
45
- getChains: GetChains;
46
- updateBackState: UpdateBackState;
47
- };
48
- export type FrameHost = {
49
- context: FrameContext;
50
- close: () => void;
51
- ready: Ready.Ready;
52
- openUrl: (url: string) => void;
53
- signIn: SignIn.SignIn;
54
- setPrimaryButton: SetPrimaryButton;
55
- ethProviderRequest: Ethereum.EthProvideRequest;
56
- ethProviderRequestV2: Ethereum.RpcTransport;
57
- /**
58
- * Receive forwarded eip6963:requestProvider events from the frame document.
59
- * Hosts must emit an EventEip6963AnnounceProvider in response.
60
- */
61
- eip6963RequestProvider: () => void;
62
- solanaProviderRequest?: SolanaRequestFn;
63
- addFrame: AddMiniApp.AddMiniApp;
64
- viewCast: ViewCast.ViewCast;
65
- viewProfile: ViewProfile.ViewProfile;
66
- viewToken: ViewToken.ViewToken;
67
- sendToken: SendToken.SendToken;
68
- swapToken: SwapToken.SwapToken;
69
- composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
70
- impactOccurred: ImpactOccurred;
71
- notificationOccurred: NotificationOccurred;
72
- selectionChanged: SelectionChanged;
73
- getCapabilities: GetCapabilities;
74
- getChains: GetChains;
75
- updateBackState: UpdateBackState;
76
- };
77
- export type EventFrameAddRejected = {
78
- event: 'frame_add_rejected';
79
- reason: AddMiniApp.AddMiniAppRejectedReason;
80
- };
81
- export type EventPrimaryButtonClicked = {
82
- event: 'primary_button_clicked';
83
- };
84
- export type EventBackNavigationTriggered = {
85
- event: 'back_navigation_triggered';
86
- };
87
- export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | EventBackNavigationTriggered | Ethereum.EventEip6963AnnounceProvider;
package/esm/types.js DELETED
@@ -1,23 +0,0 @@
1
- // start backwards compat, remove in 1.0
2
- export * from "./wallet/ethereum.js";
3
- export { DEFAULT_READY_OPTIONS } from "./actions/Ready.js";
4
- export const miniAppHostCapabilityList = [
5
- 'wallet.getEthereumProvider',
6
- 'wallet.getSolanaProvider',
7
- 'actions.ready',
8
- 'actions.openUrl',
9
- 'actions.close',
10
- 'actions.setPrimaryButton',
11
- 'actions.addMiniApp',
12
- 'actions.signIn',
13
- 'actions.viewCast',
14
- 'actions.viewProfile',
15
- 'actions.composeCast',
16
- 'actions.viewToken',
17
- 'actions.sendToken',
18
- 'actions.swapToken',
19
- 'haptics.impactOccurred',
20
- 'haptics.notificationOccurred',
21
- 'haptics.selectionChanged',
22
- 'back',
23
- ];
@@ -1,47 +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
- export type EthProvideRequest<schema extends RpcSchema.Generic = RpcSchema.Default> = Provider.RequestFn<schema>;
7
- export type FrameEthProviderEventData = {
8
- type: 'frame_eth_provider_event';
9
- } & EthProviderWireEvent;
10
- export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
11
- export type ProviderRpcError = {
12
- code: number;
13
- details?: string;
14
- message?: string;
15
- };
16
- export type EthProviderWireEvent = {
17
- event: 'accountsChanged';
18
- params: [readonly Address.Address[]];
19
- } | {
20
- event: 'chainChanged';
21
- params: [string];
22
- } | {
23
- event: 'connect';
24
- params: [Provider.ConnectInfo];
25
- } | {
26
- event: 'disconnect';
27
- params: [ProviderRpcError];
28
- } | {
29
- event: 'message';
30
- params: [Provider.Message];
31
- };
32
- export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
33
- event: event;
34
- }>['params']) => void;
35
- /**
36
- * Metadata of the EIP-1193 Provider.
37
- */
38
- export interface EIP6963ProviderInfo {
39
- icon: `data:image/${string}`;
40
- name: string;
41
- rdns: string;
42
- uuid: string;
43
- }
44
- export type EventEip6963AnnounceProvider = {
45
- event: 'eip6963:announceProvider';
46
- info: EIP6963ProviderInfo;
47
- };
@@ -1 +0,0 @@
1
- export {};
@@ -1 +0,0 @@
1
- export * as Ethereum from './ethereum.ts';
@@ -1 +0,0 @@
1
- export * as Ethereum from "./ethereum.js";
@@ -1,51 +0,0 @@
1
- import * as Errors from '../errors.ts'
2
- import type { OneOf } from '../internal/types.ts'
3
- import type { FrameNotificationDetails } from '../schemas/index.ts'
4
-
5
- export type AddMiniAppResult = {
6
- notificationDetails?: FrameNotificationDetails
7
- }
8
-
9
- export type AddMiniApp = () => Promise<AddMiniAppResult>
10
-
11
- type InvalidDomainManifestJsonError = {
12
- type: 'invalid_domain_manifest'
13
- }
14
-
15
- type RejectedByUserJsonError = {
16
- type: 'rejected_by_user'
17
- }
18
-
19
- export type AddMiniAppJsonError =
20
- | InvalidDomainManifestJsonError
21
- | RejectedByUserJsonError
22
-
23
- export type AddMiniAppRejectedReason = AddMiniAppJsonError['type']
24
-
25
- export type AddMiniAppJsonResult = OneOf<
26
- { result: AddMiniAppResult } | { error: AddMiniAppJsonError }
27
- >
28
-
29
- export type WireAddMiniApp = () => Promise<AddMiniAppJsonResult>
30
-
31
- /**
32
- * Thrown when the frame does not have a valid domain manifest.
33
- */
34
- export class InvalidDomainManifest extends Errors.BaseError {
35
- override readonly name = 'AddMiniApp.InvalidDomainManifest'
36
-
37
- constructor() {
38
- super('Invalid domain manifest')
39
- }
40
- }
41
-
42
- /**
43
- * Thrown when add frame action was rejected by the user.
44
- */
45
- export class RejectedByUser extends Errors.BaseError {
46
- override readonly name = 'AddMiniApp.RejectedByUser'
47
-
48
- constructor() {
49
- super('Add frame rejected by user')
50
- }
51
- }
@@ -1,44 +0,0 @@
1
- export type Options<close extends boolean | undefined = undefined> = {
2
- /**
3
- * Suggested text for the body of the cast.
4
- *
5
- * Mentions can be included using the human-writable form (e.g. @farcaster).
6
- **/
7
- text?: string
8
-
9
- /** Suggested embeds. Max two. */
10
- embeds?: [] | [string] | [string, string]
11
-
12
- /** Suggested parent. */
13
- parent?: { type: 'cast'; hash: string }
14
-
15
- /** Whether the app should be closed when this action is called. */
16
- close?: close
17
-
18
- /** Whether the cast should be posted to a channel. */
19
- channelKey?: string
20
- }
21
-
22
- export type ComposeCastInnerResult = {
23
- /** Cast of the created cast */
24
- hash: string
25
-
26
- /** Text of the created cast */
27
- text?: string
28
-
29
- /** Embeds of the created cast */
30
- embeds?: [] | [string] | [string, string]
31
-
32
- /** Parent of the created cast */
33
- parent?: { type: 'cast'; hash: string }
34
-
35
- /** Channel key of the created cast */
36
- channelKey?: string
37
- }
38
-
39
- export type Result<close extends boolean | undefined = undefined> =
40
- close extends true
41
- ? undefined
42
- : {
43
- cast: ComposeCastInnerResult | null
44
- }
@@ -1,9 +0,0 @@
1
- // Haptics types
2
- export type ImpactOccurredType = 'light' | 'medium' | 'heavy' | 'soft' | 'rigid'
3
- export type NotificationOccurredType = 'success' | 'warning' | 'error'
4
-
5
- export type ImpactOccurred = (type: ImpactOccurredType) => Promise<void>
6
- export type NotificationOccurred = (
7
- type: NotificationOccurredType,
8
- ) => Promise<void>
9
- export type SelectionChanged = () => Promise<void>
@@ -1,15 +0,0 @@
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,57 +0,0 @@
1
- export type SendTokenOptions = {
2
- /**
3
- * CAIP-19 asset ID
4
- * For example, Base USDC:
5
- * eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
6
- */
7
- token?: string
8
-
9
- /**
10
- * Token amount, as numeric string.
11
- * For example, 10 USDC: 1000000
12
- */
13
- amount?: string
14
-
15
- /**
16
- * Recipient address.
17
- */
18
- recipientAddress?: string
19
-
20
- /**
21
- * Recipient fid.
22
- */
23
- recipientFid?: number
24
- }
25
-
26
- type SendTokenDetails = {
27
- /**
28
- * Tx identifier.
29
- */
30
- transaction: `0x${string}`
31
- }
32
-
33
- type SendTokenErrorDetails = {
34
- /**
35
- * Error code.
36
- */
37
- error: string
38
- /**
39
- * Error message.
40
- */
41
- message?: string
42
- }
43
-
44
- export type SendTokenErrorReason = 'rejected_by_user' | 'send_failed'
45
-
46
- export type SendTokenResult =
47
- | {
48
- success: true
49
- send: SendTokenDetails
50
- }
51
- | {
52
- success: false
53
- reason: SendTokenErrorReason
54
- error?: SendTokenErrorDetails
55
- }
56
-
57
- export type SendToken = (options: SendTokenOptions) => Promise<SendTokenResult>
@@ -1,67 +0,0 @@
1
- import * as Errors from '../errors.ts'
2
- import type { OneOf } from '../internal/types.ts'
3
-
4
- export type SignInOptions = {
5
- /**
6
- * A random string used to prevent replay attacks.
7
- */
8
- nonce: string
9
-
10
- /**
11
- * Start time at which the signature becomes valid.
12
- * ISO 8601 datetime.
13
- */
14
- notBefore?: string
15
-
16
- /**
17
- * Expiration time at which the signature is no longer valid.
18
- * ISO 8601 datetime.
19
- */
20
- expirationTime?: string
21
-
22
- /**
23
- * Whether an [Auth
24
- * Address](https://github.com/farcasterxyz/protocol/discussions/225) signed
25
- * message is acceptable. Defaults to `false` to maintain backwards
26
- * compatibility, though applications should set this to `true` for the best
27
- * user experience assuming their verification method supports it.
28
- *
29
- * @default false
30
- */
31
- acceptAuthAddress?: boolean
32
- }
33
-
34
- export type SignInResult = {
35
- signature: string
36
- message: string
37
-
38
- /**
39
- * Indicates if the signature was produced by a custody or auth address.
40
- */
41
- authMethod: 'custody' | 'authAddress'
42
- }
43
-
44
- export type SignIn = (options: SignInOptions) => Promise<SignInResult>
45
-
46
- type RejectedByUserJsonError = {
47
- type: 'rejected_by_user'
48
- }
49
-
50
- export type SignInJsonError = RejectedByUserJsonError
51
-
52
- export type SignInJsonResult = OneOf<
53
- { result: SignInResult } | { error: SignInJsonError }
54
- >
55
-
56
- export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>
57
-
58
- /**
59
- * Thrown when a sign in action was rejected.
60
- */
61
- export class RejectedByUser extends Errors.BaseError {
62
- override readonly name = 'SignIn.RejectedByUser'
63
-
64
- constructor() {
65
- super('Sign in rejected by user')
66
- }
67
- }