@farcaster/frame-core 0.0.0-canary-20250630194123 → 0.0.0-canary-20250630212339

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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 +5 -7
  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 -72
  41. package/dist/schemas/embeds.js +0 -32
  42. package/dist/schemas/events.d.ts +0 -43
  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 -160
  47. package/dist/schemas/manifest.js +0 -114
  48. package/dist/schemas/notifications.d.ts +0 -22
  49. package/dist/schemas/notifications.js +0 -23
  50. package/dist/schemas/shared.d.ts +0 -24
  51. package/dist/schemas/shared.js +0 -110
  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 -72
  95. package/esm/schemas/embeds.js +0 -28
  96. package/esm/schemas/events.d.ts +0 -43
  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 -160
  101. package/esm/schemas/manifest.js +0 -111
  102. package/esm/schemas/notifications.d.ts +0 -22
  103. package/esm/schemas/notifications.js +0 -20
  104. package/esm/schemas/shared.d.ts +0 -24
  105. package/esm/schemas/shared.js +0 -106
  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 -138
  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,114 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.domainManifestSchema = exports.domainFrameConfigSchema = void 0;
4
- const v4_1 = require("zod/v4");
5
- const types_ts_1 = require("../types.js");
6
- const shared_ts_1 = require("./shared.js");
7
- const primaryCategorySchema = v4_1.z.enum([
8
- 'games',
9
- 'social',
10
- 'finance',
11
- 'utility',
12
- 'productivity',
13
- 'health-fitness',
14
- 'news-media',
15
- 'music',
16
- 'shopping',
17
- 'education',
18
- 'developer-tools',
19
- 'entertainment',
20
- 'art-creativity',
21
- ]);
22
- const chainList = [
23
- 'eip155:1', // Ethereum mainnet
24
- 'eip155:8453', // Base mainnet
25
- 'eip155:42161', // Arbitrum One
26
- 'eip155:421614', // Arbitrum Sepolia
27
- 'eip155:84532', // Base Sepolia
28
- 'eip155:666666666', // Degen
29
- 'eip155:100', // Gnosis
30
- 'eip155:10', // Optimism
31
- 'eip155:11155420', // Optimism Sepolia
32
- 'eip155:137', // Polygon
33
- 'eip155:11155111', // Ethereum Sepolia
34
- 'eip155:7777777', // Zora
35
- 'eip155:130', // Unichain
36
- 'eip155:10143', // Monad testnet
37
- 'eip155:42220', // Celo
38
- 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp', // Solana
39
- ];
40
- function removeArrayDuplicates(arr) {
41
- const set = new Set(arr);
42
- return Array.from(set);
43
- }
44
- exports.domainFrameConfigSchema = v4_1.z
45
- .object({
46
- // 0.0.0 and 0.0.1 are not technically part of the spec but kept for
47
- // backwards compatibility. next should always resolve to the most recent
48
- // schema version.
49
- version: v4_1.z.union([
50
- v4_1.z.literal('0.0.0'),
51
- v4_1.z.literal('0.0.1'),
52
- v4_1.z.literal('1'),
53
- v4_1.z.literal('next'),
54
- ]),
55
- name: shared_ts_1.frameNameSchema,
56
- iconUrl: shared_ts_1.secureUrlSchema,
57
- homeUrl: shared_ts_1.secureUrlSchema,
58
- /** deprecated, set ogImageUrl instead */
59
- imageUrl: shared_ts_1.secureUrlSchema.optional(),
60
- /** deprecated, will rely on fc:frame meta tag */
61
- buttonTitle: shared_ts_1.buttonTitleSchema.optional(),
62
- splashImageUrl: shared_ts_1.secureUrlSchema.optional(),
63
- splashBackgroundColor: shared_ts_1.hexColorSchema.optional(),
64
- webhookUrl: shared_ts_1.secureUrlSchema.optional(),
65
- /** see: https://github.com/farcasterxyz/miniapps/discussions/191 */
66
- subtitle: (0, shared_ts_1.createSimpleStringSchema)({ max: 30 }).optional(),
67
- description: (0, shared_ts_1.createSimpleStringSchema)({ max: 170 }).optional(),
68
- screenshotUrls: v4_1.z.array(shared_ts_1.secureUrlSchema).max(3).optional(),
69
- primaryCategory: primaryCategorySchema.optional(),
70
- tags: v4_1.z
71
- .array((0, shared_ts_1.createSimpleStringSchema)({ max: 20, noSpaces: true }))
72
- .max(5)
73
- .optional(),
74
- heroImageUrl: shared_ts_1.secureUrlSchema.optional(),
75
- tagline: (0, shared_ts_1.createSimpleStringSchema)({ max: 30 }).optional(),
76
- ogTitle: (0, shared_ts_1.createSimpleStringSchema)({ max: 30 }).optional(),
77
- ogDescription: (0, shared_ts_1.createSimpleStringSchema)({ max: 100 }).optional(),
78
- ogImageUrl: shared_ts_1.secureUrlSchema.optional(),
79
- /** see: https://github.com/farcasterxyz/miniapps/discussions/204 */
80
- noindex: v4_1.z.boolean().optional(),
81
- /** see https://github.com/farcasterxyz/miniapps/discussions/256 */
82
- requiredChains: v4_1.z
83
- .array(v4_1.z.enum(chainList))
84
- .transform(removeArrayDuplicates)
85
- .optional(),
86
- requiredCapabilities: v4_1.z
87
- .array(v4_1.z.enum(types_ts_1.miniAppHostCapabilityList))
88
- .transform(removeArrayDuplicates)
89
- .optional(),
90
- /** see https://github.com/farcasterxyz/miniapps/discussions/158 */
91
- /** Documentation will be added once this feature is finalized. */
92
- castShareUrl: shared_ts_1.secureUrlSchema.optional(),
93
- /** Canonical domain for the frame application */
94
- canonicalDomain: shared_ts_1.domainSchema.optional(),
95
- })
96
- .refine((data) => {
97
- if (data.castShareUrl === undefined)
98
- return true;
99
- try {
100
- const homeUrlDomain = new URL(data.homeUrl).hostname;
101
- const castShareUrlDomain = new URL(data.castShareUrl).hostname;
102
- return homeUrlDomain === castShareUrlDomain;
103
- }
104
- catch {
105
- return false;
106
- }
107
- }, {
108
- message: 'castShareUrl must have the same domain as homeUrl',
109
- path: ['castShareUrl'],
110
- });
111
- exports.domainManifestSchema = v4_1.z.object({
112
- accountAssociation: shared_ts_1.encodedJsonFarcasterSignatureSchema,
113
- frame: exports.domainFrameConfigSchema.optional(),
114
- });
@@ -1,22 +0,0 @@
1
- import { z } from 'zod/v4';
2
- export declare const notificationDetailsSchema: z.ZodObject<{
3
- url: z.ZodString;
4
- token: z.ZodString;
5
- }, z.core.$strip>;
6
- export type FrameNotificationDetails = z.infer<typeof notificationDetailsSchema>;
7
- export declare const sendNotificationRequestSchema: z.ZodObject<{
8
- notificationId: z.ZodString;
9
- title: z.ZodString;
10
- body: z.ZodString;
11
- targetUrl: z.ZodString;
12
- tokens: z.ZodArray<z.ZodString>;
13
- }, z.core.$strip>;
14
- export type SendNotificationRequest = z.infer<typeof sendNotificationRequestSchema>;
15
- export declare const sendNotificationResponseSchema: z.ZodObject<{
16
- result: z.ZodObject<{
17
- successfulTokens: z.ZodArray<z.ZodString>;
18
- invalidTokens: z.ZodArray<z.ZodString>;
19
- rateLimitedTokens: z.ZodArray<z.ZodString>;
20
- }, z.core.$strip>;
21
- }, z.core.$strip>;
22
- export type SendNotificationResponse = z.infer<typeof sendNotificationResponseSchema>;
@@ -1,23 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendNotificationResponseSchema = exports.sendNotificationRequestSchema = exports.notificationDetailsSchema = void 0;
4
- const v4_1 = require("zod/v4");
5
- const shared_ts_1 = require("./shared.js");
6
- exports.notificationDetailsSchema = v4_1.z.object({
7
- url: v4_1.z.string(),
8
- token: v4_1.z.string(),
9
- });
10
- exports.sendNotificationRequestSchema = v4_1.z.object({
11
- notificationId: v4_1.z.string().max(128),
12
- title: v4_1.z.string().max(32),
13
- body: v4_1.z.string().max(128),
14
- targetUrl: shared_ts_1.secureUrlSchema,
15
- tokens: v4_1.z.string().array().max(100),
16
- });
17
- exports.sendNotificationResponseSchema = v4_1.z.object({
18
- result: v4_1.z.object({
19
- successfulTokens: v4_1.z.array(v4_1.z.string()),
20
- invalidTokens: v4_1.z.array(v4_1.z.string()),
21
- rateLimitedTokens: v4_1.z.array(v4_1.z.string()),
22
- }),
23
- });
@@ -1,24 +0,0 @@
1
- import { z } from 'zod/v4';
2
- export declare const createSimpleStringSchema: ({ max, noSpaces, }?: {
3
- max?: number;
4
- noSpaces?: boolean;
5
- }) => z.ZodString;
6
- export declare const secureUrlSchema: z.ZodString;
7
- export declare const frameNameSchema: z.ZodString;
8
- export declare const buttonTitleSchema: z.ZodString;
9
- export declare const caip19TokenSchema: z.ZodString;
10
- export declare const hexColorSchema: z.ZodString;
11
- export declare const domainSchema: z.ZodString;
12
- export declare const aspectRatioSchema: z.ZodUnion<readonly [z.ZodLiteral<"1:1">, z.ZodLiteral<"3:2">]>;
13
- export declare const encodedJsonFarcasterSignatureSchema: z.ZodObject<{
14
- header: z.ZodString;
15
- payload: z.ZodString;
16
- signature: z.ZodString;
17
- }, z.core.$strip>;
18
- export type EncodedJsonFarcasterSignatureSchema = z.infer<typeof encodedJsonFarcasterSignatureSchema>;
19
- export declare const jsonFarcasterSignatureHeaderSchema: z.ZodObject<{
20
- fid: z.ZodNumber;
21
- type: z.ZodLiteral<"app_key">;
22
- key: z.ZodString;
23
- }, z.core.$strip>;
24
- export type JsonFarcasterSignatureHeaderSchema = z.infer<typeof jsonFarcasterSignatureHeaderSchema>;
@@ -1,110 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.jsonFarcasterSignatureHeaderSchema = exports.encodedJsonFarcasterSignatureSchema = exports.aspectRatioSchema = exports.domainSchema = exports.hexColorSchema = exports.caip19TokenSchema = exports.buttonTitleSchema = exports.frameNameSchema = exports.secureUrlSchema = exports.createSimpleStringSchema = void 0;
4
- const v4_1 = require("zod/v4");
5
- const SPECIAL_CHARS_PATTERN = /[@#$%^&*+=\/\\|~«»]/;
6
- const REPEATED_PUNCTUATION_PATTERN = /(!{2,}|\?{2,}|-{2,})/;
7
- // Unicode ranges for emoji detection:
8
- // \u{1F300}-\u{1F9FF} - Miscellaneous Symbols, Pictographs, Emoticons, Transport, Map, and Supplemental
9
- // \u{2702}-\u{27B0} - Dingbats
10
- // \u{2600}-\u{26FF} - Miscellaneous Symbols
11
- // \u{2B00}-\u{2BFF} - Miscellaneous Symbols and Arrows
12
- const EMOJI_PATTERN = /[\u{1F300}-\u{1F9FF}]|[\u{2702}-\u{27B0}]|[\u{2600}-\u{26FF}]|[\u{2B00}-\u{2BFF}]/u;
13
- const createSimpleStringSchema = ({ max, noSpaces, } = {}) => {
14
- const stringValidations = noSpaces
15
- ? v4_1.z
16
- .string()
17
- .max(max ?? Number.POSITIVE_INFINITY)
18
- .regex(/^\S*$/, 'Spaces are not allowed')
19
- : v4_1.z.string().max(max ?? Number.POSITIVE_INFINITY);
20
- return stringValidations
21
- .refine((value) => !EMOJI_PATTERN.test(value), {
22
- message: 'Emojis and symbols are not allowed',
23
- })
24
- .refine((value) => !SPECIAL_CHARS_PATTERN.test(value), {
25
- message: 'Special characters (@, #, $, %, ^, &, *, +, =, /, \\, |, ~, «, ») are not allowed',
26
- })
27
- .refine((value) => !REPEATED_PUNCTUATION_PATTERN.test(value), {
28
- message: 'Repeated punctuations (!!, ??, --) are not allowed',
29
- });
30
- };
31
- exports.createSimpleStringSchema = createSimpleStringSchema;
32
- exports.secureUrlSchema = v4_1.z
33
- .string()
34
- .url()
35
- .startsWith('https://', { message: 'Must be an https url' })
36
- .max(1024)
37
- .refine((url) => !url.includes(' '), {
38
- message: 'URL must not contain spaces',
39
- })
40
- .refine((url) => {
41
- try {
42
- const hostname = new URL(url).hostname;
43
- // Check for localhost
44
- if (hostname === 'localhost' || hostname.endsWith('.localhost')) {
45
- return false;
46
- }
47
- // Check for IPv4 addresses
48
- const ipv4Regex = /^(\d{1,3}\.){3}\d{1,3}$/;
49
- if (ipv4Regex.test(hostname)) {
50
- return false;
51
- }
52
- // Check for IPv6 addresses (including brackets)
53
- if (hostname.startsWith('[') && hostname.endsWith(']')) {
54
- return false;
55
- }
56
- return true;
57
- }
58
- catch {
59
- return false;
60
- }
61
- }, {
62
- message: 'URL must not use IP addresses or localhost',
63
- });
64
- exports.frameNameSchema = v4_1.z.string().max(32);
65
- exports.buttonTitleSchema = v4_1.z.string().max(32);
66
- 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)$/;
67
- exports.caip19TokenSchema = v4_1.z
68
- .string()
69
- .regex(CAIP_19_REGEX, { message: 'Invalid CAIP-19 asset ID' });
70
- exports.hexColorSchema = v4_1.z
71
- .string()
72
- .regex(/^#([0-9A-F]{3}|[0-9A-F]{6})$/i, {
73
- message: 'Invalid hex color code. It should be in the format #RRGGBB or #RGB.',
74
- });
75
- // Domain validation regex:
76
- // - Each label (part between dots) must start and end with alphanumeric
77
- // - Labels can contain hyphens in the middle
78
- // - Cannot have consecutive dots
79
- // - Must have at least one dot (TLD required)
80
- // - TLD must be at least 2 characters and only letters
81
- const DOMAIN_REGEX = /^(?!.*\.\.)([a-zA-Z0-9]([a-zA-Z0-9-]*[a-zA-Z0-9])?\.)+[a-zA-Z]{2,}$/;
82
- exports.domainSchema = v4_1.z
83
- .string()
84
- .max(1024)
85
- .regex(DOMAIN_REGEX, {
86
- message: 'Must be a valid domain name (e.g., example.com, sub.example.com)',
87
- })
88
- .refine((value) => !value.includes('://'), {
89
- message: 'Domain must not include protocol (http://, https://, etc.)',
90
- })
91
- .refine((value) => !value.includes('/'), {
92
- message: 'Domain must not include path separators',
93
- })
94
- .refine((value) => !value.includes('@'), {
95
- message: 'Domain must not include @ symbol',
96
- })
97
- .refine((value) => !value.includes(':'), {
98
- message: 'Domain must not include port numbers',
99
- });
100
- exports.aspectRatioSchema = v4_1.z.union([v4_1.z.literal('1:1'), v4_1.z.literal('3:2')]);
101
- exports.encodedJsonFarcasterSignatureSchema = v4_1.z.object({
102
- header: v4_1.z.string(),
103
- payload: v4_1.z.string(),
104
- signature: v4_1.z.string(),
105
- });
106
- exports.jsonFarcasterSignatureHeaderSchema = v4_1.z.object({
107
- fid: v4_1.z.number(),
108
- type: v4_1.z.literal('app_key'),
109
- key: v4_1.z.string().startsWith('0x'),
110
- });
package/dist/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/dist/solana.js DELETED
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.createSolanaWalletProvider = exports.SolanaConnection = void 0;
4
- const web3_js_1 = require("@solana/web3.js");
5
- Object.defineProperty(exports, "SolanaConnection", { enumerable: true, get: function () { return web3_js_1.Connection; } });
6
- const createSolanaWalletProvider = (request) => ({
7
- request,
8
- signMessage: (msg) => request({ method: 'signMessage', params: { message: msg } }),
9
- signTransaction: (transaction) => request({ method: 'signTransaction', params: { transaction } }),
10
- signAndSendTransaction: (input) => request({
11
- method: 'signAndSendTransaction',
12
- params: input,
13
- }),
14
- });
15
- exports.createSolanaWalletProvider = createSolanaWalletProvider;
@@ -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;
@@ -1,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.wrapSolanaProviderRequest = wrapSolanaProviderRequest;
4
- exports.unwrapSolanaProviderRequest = unwrapSolanaProviderRequest;
5
- const web3_js_1 = require("@solana/web3.js");
6
- function serializeTransaction(transaction) {
7
- return Buffer.from(transaction.serialize({
8
- verifySignatures: false,
9
- })).toString('base64');
10
- }
11
- function unserializeTransaction(transaction) {
12
- const bytes = Buffer.from(transaction, 'base64');
13
- const version = web3_js_1.VersionedMessage.deserializeMessageVersion(bytes);
14
- return version === 'legacy'
15
- ? web3_js_1.VersionedTransaction.deserialize(bytes)
16
- : web3_js_1.Transaction.from(bytes);
17
- }
18
- function wrapSolanaProviderRequest(requestFn) {
19
- const wrappedFn = async (request) => {
20
- if (request.method === 'connect') {
21
- return await requestFn(request);
22
- }
23
- if (request.method === 'signMessage') {
24
- return await requestFn(request);
25
- }
26
- if (request.method === 'signAndSendTransaction') {
27
- const { transaction, options } = request.params;
28
- const params = {
29
- transaction: unserializeTransaction(transaction),
30
- options,
31
- };
32
- return await requestFn({
33
- method: 'signAndSendTransaction',
34
- params,
35
- });
36
- }
37
- if (request.method === 'signTransaction') {
38
- const { transaction } = request.params;
39
- const params = {
40
- transaction: unserializeTransaction(transaction),
41
- };
42
- const { signedTransaction } = await requestFn({
43
- method: 'signTransaction',
44
- params,
45
- });
46
- return {
47
- signedTransaction: serializeTransaction(signedTransaction),
48
- };
49
- }
50
- };
51
- return wrappedFn;
52
- }
53
- function unwrapSolanaProviderRequest(wrappedRequestFn) {
54
- const unwrappedFn = async (request) => {
55
- if (request.method === 'connect') {
56
- return await wrappedRequestFn(request);
57
- }
58
- if (request.method === 'signMessage') {
59
- return await wrappedRequestFn(request);
60
- }
61
- if (request.method === 'signAndSendTransaction') {
62
- const { transaction, options } = request.params;
63
- const params = {
64
- transaction: serializeTransaction(transaction),
65
- };
66
- return await wrappedRequestFn({
67
- method: 'signAndSendTransaction',
68
- params,
69
- });
70
- }
71
- if (request.method === 'signTransaction') {
72
- const { transaction } = request.params;
73
- const params = {
74
- transaction: serializeTransaction(transaction),
75
- };
76
- const { signedTransaction } = await wrappedRequestFn({
77
- method: 'signTransaction',
78
- params,
79
- });
80
- return { signedTransaction: unserializeTransaction(signedTransaction) };
81
- }
82
- };
83
- return unwrappedFn;
84
- }
package/dist/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/dist/types.js DELETED
@@ -1,41 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.miniAppHostCapabilityList = exports.DEFAULT_READY_OPTIONS = void 0;
18
- // start backwards compat, remove in 1.0
19
- __exportStar(require("./wallet/ethereum.js"), exports);
20
- var Ready_ts_1 = require("./actions/Ready.js");
21
- Object.defineProperty(exports, "DEFAULT_READY_OPTIONS", { enumerable: true, get: function () { return Ready_ts_1.DEFAULT_READY_OPTIONS; } });
22
- exports.miniAppHostCapabilityList = [
23
- 'wallet.getEthereumProvider',
24
- 'wallet.getSolanaProvider',
25
- 'actions.ready',
26
- 'actions.openUrl',
27
- 'actions.close',
28
- 'actions.setPrimaryButton',
29
- 'actions.addMiniApp',
30
- 'actions.signIn',
31
- 'actions.viewCast',
32
- 'actions.viewProfile',
33
- 'actions.composeCast',
34
- 'actions.viewToken',
35
- 'actions.sendToken',
36
- 'actions.swapToken',
37
- 'haptics.impactOccurred',
38
- 'haptics.notificationOccurred',
39
- 'haptics.selectionChanged',
40
- 'back',
41
- ];
@@ -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,2 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
@@ -1 +0,0 @@
1
- export * as Ethereum from './ethereum.ts';