@farcaster/frame-core 0.0.33 → 0.0.35

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.
@@ -2,7 +2,7 @@ export type Options<close extends boolean | undefined = undefined> = {
2
2
  /**
3
3
  * Suggested text for the body of the cast.
4
4
  *
5
- * Mentions can be included using the human-writeable form (e.g. @farcaster).
5
+ * Mentions can be included using the human-writable form (e.g. @farcaster).
6
6
  **/
7
7
  text?: string;
8
8
  /** Suggested embeds. Max two. */
@@ -0,0 +1,48 @@
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
+ * Token amount, as numeric string.
10
+ * For example, 10 USDC: 1000000
11
+ */
12
+ amount?: string;
13
+ /**
14
+ * Recipient address.
15
+ */
16
+ recipientAddress?: string;
17
+ /**
18
+ * Recipient fid.
19
+ */
20
+ recipientFid?: number;
21
+ };
22
+ type SendTokenDetails = {
23
+ /**
24
+ * Tx identifier.
25
+ */
26
+ transaction: `0x${string}`;
27
+ };
28
+ type SendTokenErrorDetails = {
29
+ /**
30
+ * Error code.
31
+ */
32
+ error: string;
33
+ /**
34
+ * Error message.
35
+ */
36
+ message?: string;
37
+ };
38
+ export type SendTokenErrorReason = 'rejected_by_user' | 'send_failed';
39
+ export type SendTokenResult = {
40
+ success: true;
41
+ send: SendTokenDetails;
42
+ } | {
43
+ success: false;
44
+ reason: SendTokenErrorReason;
45
+ error?: SendTokenErrorDetails;
46
+ };
47
+ export type SendToken = (options: SendTokenOptions) => Promise<SendTokenResult>;
48
+ export {};
@@ -15,10 +15,24 @@ export type SignInOptions = {
15
15
  * ISO 8601 datetime.
16
16
  */
17
17
  expirationTime?: string;
18
+ /**
19
+ * Whether an [Auth
20
+ * Address](https://github.com/farcasterxyz/protocol/discussions/225) signed
21
+ * message is acceptable. Defaults to `false` to maintain backwards
22
+ * compatibility, though applications should set this to `true` for the best
23
+ * user experience assuming their verification method supports it.
24
+ *
25
+ * @default false
26
+ */
27
+ acceptAuthAddress?: boolean;
18
28
  };
19
29
  export type SignInResult = {
20
30
  signature: string;
21
31
  message: string;
32
+ /**
33
+ * Indicates if the signature was produced by a custody or auth address.
34
+ */
35
+ authMethod: 'custody' | 'authAddress';
22
36
  };
23
37
  export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
24
38
  type RejectedByUserJsonError = {
@@ -1,4 +1,4 @@
1
- export type SwapOptions = {
1
+ export type SwapTokenOptions = {
2
2
  /**
3
3
  * CAIP-19 asset ID
4
4
  * For example, Base USDC:
@@ -12,18 +12,18 @@ export type SwapOptions = {
12
12
  buyToken?: string;
13
13
  /**
14
14
  * Sell token amount, as numeric string.
15
- * For example, 10 USDC: 1000000
15
+ * For example, 1 USDC: 1000000
16
16
  */
17
17
  sellAmount?: string;
18
18
  };
19
- type SwapDetails = {
19
+ type SwapTokenDetails = {
20
20
  /**
21
21
  * Array of tx identifiers in order of execution.
22
22
  * Some swaps will have both an approval and swap tx.
23
23
  */
24
24
  transactions: `0x${string}`[];
25
25
  };
26
- type SwapErrorDetails = {
26
+ type SwapTokenErrorDetails = {
27
27
  /**
28
28
  * Error code.
29
29
  */
@@ -34,13 +34,13 @@ type SwapErrorDetails = {
34
34
  message?: string;
35
35
  };
36
36
  export type SwapErrorReason = 'rejected_by_user' | 'swap_failed';
37
- export type SwapResult = {
37
+ export type SwapTokenResult = {
38
38
  success: true;
39
- swap: SwapDetails;
39
+ swap: SwapTokenDetails;
40
40
  } | {
41
41
  success: false;
42
42
  reason: SwapErrorReason;
43
- error?: SwapErrorDetails;
43
+ error?: SwapTokenErrorDetails;
44
44
  };
45
- export type Swap = (options: SwapOptions) => Promise<SwapResult>;
45
+ export type SwapToken = (options: SwapTokenOptions) => Promise<SwapTokenResult>;
46
46
  export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -2,6 +2,7 @@ export * as AddFrame from './AddFrame';
2
2
  export * as ComposeCast from './ComposeCast';
3
3
  export * as Ready from './Ready';
4
4
  export * as SignIn from './SignIn';
5
- export * as Swap from './Swap';
5
+ export * as SendToken from './SendToken';
6
+ export * as SwapToken from './SwapToken';
6
7
  export * as ViewProfile from './ViewProfile';
7
8
  export * as ViewToken from './ViewToken';
@@ -33,11 +33,12 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ViewToken = exports.ViewProfile = exports.Swap = exports.SignIn = exports.Ready = exports.ComposeCast = exports.AddFrame = void 0;
36
+ exports.ViewToken = exports.ViewProfile = exports.SwapToken = exports.SendToken = exports.SignIn = exports.Ready = exports.ComposeCast = exports.AddFrame = void 0;
37
37
  exports.AddFrame = __importStar(require("./AddFrame"));
38
38
  exports.ComposeCast = __importStar(require("./ComposeCast"));
39
39
  exports.Ready = __importStar(require("./Ready"));
40
40
  exports.SignIn = __importStar(require("./SignIn"));
41
- exports.Swap = __importStar(require("./Swap"));
41
+ exports.SendToken = __importStar(require("./SendToken"));
42
+ exports.SwapToken = __importStar(require("./SwapToken"));
42
43
  exports.ViewProfile = __importStar(require("./ViewProfile"));
43
44
  exports.ViewToken = __importStar(require("./ViewToken"));
package/dist/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * as Context from './context';
5
5
  export * as Manifest from './manifest';
6
6
  export * from './types';
7
7
  export * from './schemas';
8
+ export * from './solana';
package/dist/index.js CHANGED
@@ -44,3 +44,4 @@ exports.Context = __importStar(require("./context"));
44
44
  exports.Manifest = __importStar(require("./manifest"));
45
45
  __exportStar(require("./types"), exports);
46
46
  __exportStar(require("./schemas"), exports);
47
+ __exportStar(require("./solana"), exports);
@@ -0,0 +1,51 @@
1
+ import type { Connection as SolanaConnection, SendOptions as SolanaSendOptions, Transaction as SolanaTransaction, VersionedTransaction as SolanaVersionedTransaction } from '@solana/web3.js';
2
+ export type { SolanaConnection };
3
+ export type SolanaCombinedTransaction = SolanaTransaction | SolanaVersionedTransaction;
4
+ export type SolanaConnectRequestArguments = {
5
+ method: 'connect';
6
+ };
7
+ export type SolanaSignMessageRequestArguments = {
8
+ method: 'signMessage';
9
+ params: {
10
+ message: string;
11
+ };
12
+ };
13
+ export type SolanaSignAndSendTransactionRequestArguments = {
14
+ method: 'signAndSendTransaction';
15
+ params: {
16
+ transaction: SolanaCombinedTransaction;
17
+ connection: SolanaConnection;
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
+ connection: SolanaConnection;
47
+ }): Promise<{
48
+ signature: string;
49
+ }>;
50
+ }
51
+ export declare const createSolanaWalletProvider: (request: SolanaRequestFn) => SolanaWalletProvider;
package/dist/solana.js ADDED
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createSolanaWalletProvider = void 0;
4
+ const createSolanaWalletProvider = (request) => ({
5
+ request,
6
+ signMessage: (msg) => request({ method: 'signMessage', params: { message: msg } }),
7
+ signTransaction: (transaction) => request({ method: 'signTransaction', params: { transaction } }),
8
+ signAndSendTransaction: (input) => request({
9
+ method: 'signAndSendTransaction',
10
+ params: input,
11
+ }),
12
+ });
13
+ exports.createSolanaWalletProvider = createSolanaWalletProvider;
package/dist/types.d.ts CHANGED
@@ -1,6 +1,7 @@
1
- import type { AddFrame, ComposeCast, Ready, SignIn, Swap, ViewProfile, ViewToken } from './actions';
1
+ import type { AddFrame, ComposeCast, Ready, SendToken, SignIn, SwapToken, ViewProfile, ViewToken } from './actions';
2
2
  import type { FrameContext } from './context';
3
3
  import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
4
+ import type { SolanaRequestFn } from './solana';
4
5
  import type { Ethereum } from './wallet';
5
6
  export type SetPrimaryButtonOptions = {
6
7
  text: string;
@@ -22,10 +23,12 @@ export type WireFrameHost = {
22
23
  ethProviderRequest: Ethereum.EthProvideRequest;
23
24
  ethProviderRequestV2: Ethereum.RpcTransport;
24
25
  eip6963RequestProvider: () => void;
26
+ solanaProviderRequest?: SolanaRequestFn;
25
27
  addFrame: AddFrame.WireAddFrame;
26
28
  viewProfile: ViewProfile.ViewProfile;
27
29
  viewToken: ViewToken.ViewToken;
28
- swap: Swap.Swap;
30
+ sendToken: SendToken.SendToken;
31
+ swapToken: SwapToken.SwapToken;
29
32
  composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
30
33
  };
31
34
  export type FrameHost = {
@@ -42,10 +45,12 @@ export type FrameHost = {
42
45
  * Hosts must emit an EventEip6963AnnounceProvider in response.
43
46
  */
44
47
  eip6963RequestProvider: () => void;
48
+ solanaProviderRequest?: SolanaRequestFn;
45
49
  addFrame: AddFrame.AddFrame;
46
50
  viewProfile: ViewProfile.ViewProfile;
47
51
  viewToken: ViewToken.ViewToken;
48
- swap: Swap.Swap;
52
+ sendToken: SendToken.SendToken;
53
+ swapToken: SwapToken.SwapToken;
49
54
  composeCast: <close extends boolean | undefined = undefined>(options: ComposeCast.Options<close>) => Promise<ComposeCast.Result<close>>;
50
55
  };
51
56
  export type EventFrameAddRejected = {
@@ -2,7 +2,7 @@ export type Options<close extends boolean | undefined = undefined> = {
2
2
  /**
3
3
  * Suggested text for the body of the cast.
4
4
  *
5
- * Mentions can be included using the human-writeable form (e.g. @farcaster).
5
+ * Mentions can be included using the human-writable form (e.g. @farcaster).
6
6
  **/
7
7
  text?: string;
8
8
  /** Suggested embeds. Max two. */
@@ -0,0 +1,48 @@
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
+ * Token amount, as numeric string.
10
+ * For example, 10 USDC: 1000000
11
+ */
12
+ amount?: string;
13
+ /**
14
+ * Recipient address.
15
+ */
16
+ recipientAddress?: string;
17
+ /**
18
+ * Recipient fid.
19
+ */
20
+ recipientFid?: number;
21
+ };
22
+ type SendTokenDetails = {
23
+ /**
24
+ * Tx identifier.
25
+ */
26
+ transaction: `0x${string}`;
27
+ };
28
+ type SendTokenErrorDetails = {
29
+ /**
30
+ * Error code.
31
+ */
32
+ error: string;
33
+ /**
34
+ * Error message.
35
+ */
36
+ message?: string;
37
+ };
38
+ export type SendTokenErrorReason = 'rejected_by_user' | 'send_failed';
39
+ export type SendTokenResult = {
40
+ success: true;
41
+ send: SendTokenDetails;
42
+ } | {
43
+ success: false;
44
+ reason: SendTokenErrorReason;
45
+ error?: SendTokenErrorDetails;
46
+ };
47
+ export type SendToken = (options: SendTokenOptions) => Promise<SendTokenResult>;
48
+ export {};
@@ -15,10 +15,24 @@ export type SignInOptions = {
15
15
  * ISO 8601 datetime.
16
16
  */
17
17
  expirationTime?: string;
18
+ /**
19
+ * Whether an [Auth
20
+ * Address](https://github.com/farcasterxyz/protocol/discussions/225) signed
21
+ * message is acceptable. Defaults to `false` to maintain backwards
22
+ * compatibility, though applications should set this to `true` for the best
23
+ * user experience assuming their verification method supports it.
24
+ *
25
+ * @default false
26
+ */
27
+ acceptAuthAddress?: boolean;
18
28
  };
19
29
  export type SignInResult = {
20
30
  signature: string;
21
31
  message: string;
32
+ /**
33
+ * Indicates if the signature was produced by a custody or auth address.
34
+ */
35
+ authMethod: 'custody' | 'authAddress';
22
36
  };
23
37
  export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
24
38
  type RejectedByUserJsonError = {
@@ -1,4 +1,4 @@
1
- export type SwapOptions = {
1
+ export type SwapTokenOptions = {
2
2
  /**
3
3
  * CAIP-19 asset ID
4
4
  * For example, Base USDC:
@@ -12,18 +12,18 @@ export type SwapOptions = {
12
12
  buyToken?: string;
13
13
  /**
14
14
  * Sell token amount, as numeric string.
15
- * For example, 10 USDC: 1000000
15
+ * For example, 1 USDC: 1000000
16
16
  */
17
17
  sellAmount?: string;
18
18
  };
19
- type SwapDetails = {
19
+ type SwapTokenDetails = {
20
20
  /**
21
21
  * Array of tx identifiers in order of execution.
22
22
  * Some swaps will have both an approval and swap tx.
23
23
  */
24
24
  transactions: `0x${string}`[];
25
25
  };
26
- type SwapErrorDetails = {
26
+ type SwapTokenErrorDetails = {
27
27
  /**
28
28
  * Error code.
29
29
  */
@@ -34,13 +34,13 @@ type SwapErrorDetails = {
34
34
  message?: string;
35
35
  };
36
36
  export type SwapErrorReason = 'rejected_by_user' | 'swap_failed';
37
- export type SwapResult = {
37
+ export type SwapTokenResult = {
38
38
  success: true;
39
- swap: SwapDetails;
39
+ swap: SwapTokenDetails;
40
40
  } | {
41
41
  success: false;
42
42
  reason: SwapErrorReason;
43
- error?: SwapErrorDetails;
43
+ error?: SwapTokenErrorDetails;
44
44
  };
45
- export type Swap = (options: SwapOptions) => Promise<SwapResult>;
45
+ export type SwapToken = (options: SwapTokenOptions) => Promise<SwapTokenResult>;
46
46
  export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -2,6 +2,7 @@ export * as AddFrame from './AddFrame';
2
2
  export * as ComposeCast from './ComposeCast';
3
3
  export * as Ready from './Ready';
4
4
  export * as SignIn from './SignIn';
5
- export * as Swap from './Swap';
5
+ export * as SendToken from './SendToken';
6
+ export * as SwapToken from './SwapToken';
6
7
  export * as ViewProfile from './ViewProfile';
7
8
  export * as ViewToken from './ViewToken';
@@ -2,6 +2,7 @@ export * as AddFrame from './AddFrame';
2
2
  export * as ComposeCast from './ComposeCast';
3
3
  export * as Ready from './Ready';
4
4
  export * as SignIn from './SignIn';
5
- export * as Swap from './Swap';
5
+ export * as SendToken from './SendToken';
6
+ export * as SwapToken from './SwapToken';
6
7
  export * as ViewProfile from './ViewProfile';
7
8
  export * as ViewToken from './ViewToken';
package/esm/index.d.ts CHANGED
@@ -5,3 +5,4 @@ export * as Context from './context';
5
5
  export * as Manifest from './manifest';
6
6
  export * from './types';
7
7
  export * from './schemas';
8
+ export * from './solana';
package/esm/index.js CHANGED
@@ -5,3 +5,4 @@ export * as Context from './context';
5
5
  export * as Manifest from './manifest';
6
6
  export * from './types';
7
7
  export * from './schemas';
8
+ export * from './solana';
@@ -0,0 +1,51 @@
1
+ import type { Connection as SolanaConnection, SendOptions as SolanaSendOptions, Transaction as SolanaTransaction, VersionedTransaction as SolanaVersionedTransaction } from '@solana/web3.js';
2
+ export type { SolanaConnection };
3
+ export type SolanaCombinedTransaction = SolanaTransaction | SolanaVersionedTransaction;
4
+ export type SolanaConnectRequestArguments = {
5
+ method: 'connect';
6
+ };
7
+ export type SolanaSignMessageRequestArguments = {
8
+ method: 'signMessage';
9
+ params: {
10
+ message: string;
11
+ };
12
+ };
13
+ export type SolanaSignAndSendTransactionRequestArguments = {
14
+ method: 'signAndSendTransaction';
15
+ params: {
16
+ transaction: SolanaCombinedTransaction;
17
+ connection: SolanaConnection;
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
+ connection: SolanaConnection;
47
+ }): Promise<{
48
+ signature: string;
49
+ }>;
50
+ }
51
+ export declare const createSolanaWalletProvider: (request: SolanaRequestFn) => SolanaWalletProvider;
package/esm/solana.js ADDED
@@ -0,0 +1,9 @@
1
+ export const createSolanaWalletProvider = (request) => ({
2
+ request,
3
+ signMessage: (msg) => request({ method: 'signMessage', params: { message: msg } }),
4
+ signTransaction: (transaction) => request({ method: 'signTransaction', params: { transaction } }),
5
+ signAndSendTransaction: (input) => request({
6
+ method: 'signAndSendTransaction',
7
+ params: input,
8
+ }),
9
+ });