@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.
@@ -0,0 +1,57 @@
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>
@@ -18,11 +18,27 @@ export type SignInOptions = {
18
18
  * ISO 8601 datetime.
19
19
  */
20
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
21
32
  }
22
33
 
23
34
  export type SignInResult = {
24
35
  signature: string
25
36
  message: string
37
+
38
+ /**
39
+ * Indicates if the signature was produced by a custody or auth address.
40
+ */
41
+ authMethod: 'custody' | 'authAddress'
26
42
  }
27
43
 
28
44
  export type SignIn = (options: SignInOptions) => Promise<SignInResult>
@@ -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:
@@ -14,12 +14,12 @@ export type SwapOptions = {
14
14
 
15
15
  /**
16
16
  * Sell token amount, as numeric string.
17
- * For example, 10 USDC: 1000000
17
+ * For example, 1 USDC: 1000000
18
18
  */
19
19
  sellAmount?: string
20
20
  }
21
21
 
22
- type SwapDetails = {
22
+ type SwapTokenDetails = {
23
23
  /**
24
24
  * Array of tx identifiers in order of execution.
25
25
  * Some swaps will have both an approval and swap tx.
@@ -27,7 +27,7 @@ type SwapDetails = {
27
27
  transactions: `0x${string}`[]
28
28
  }
29
29
 
30
- type SwapErrorDetails = {
30
+ type SwapTokenErrorDetails = {
31
31
  /**
32
32
  * Error code.
33
33
  */
@@ -40,15 +40,15 @@ type SwapErrorDetails = {
40
40
 
41
41
  export type SwapErrorReason = 'rejected_by_user' | 'swap_failed'
42
42
 
43
- export type SwapResult =
43
+ export type SwapTokenResult =
44
44
  | {
45
45
  success: true
46
- swap: SwapDetails
46
+ swap: SwapTokenDetails
47
47
  }
48
48
  | {
49
49
  success: false
50
50
  reason: SwapErrorReason
51
- error?: SwapErrorDetails
51
+ error?: SwapTokenErrorDetails
52
52
  }
53
53
 
54
- export type Swap = (options: SwapOptions) => Promise<SwapResult>
54
+ export type SwapToken = (options: SwapTokenOptions) => Promise<SwapTokenResult>
@@ -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/src/index.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/src/solana.ts ADDED
@@ -0,0 +1,82 @@
1
+ import type {
2
+ Connection as SolanaConnection,
3
+ SendOptions as SolanaSendOptions,
4
+ Transaction as SolanaTransaction,
5
+ VersionedTransaction as SolanaVersionedTransaction,
6
+ } from '@solana/web3.js'
7
+
8
+ export type { SolanaConnection }
9
+
10
+ export type SolanaCombinedTransaction =
11
+ | SolanaTransaction
12
+ | SolanaVersionedTransaction
13
+
14
+ export type SolanaConnectRequestArguments = {
15
+ method: 'connect'
16
+ }
17
+ export type SolanaSignMessageRequestArguments = {
18
+ method: 'signMessage'
19
+ params: {
20
+ message: string
21
+ }
22
+ }
23
+ export type SolanaSignAndSendTransactionRequestArguments = {
24
+ method: 'signAndSendTransaction'
25
+ params: {
26
+ transaction: SolanaCombinedTransaction
27
+ connection: SolanaConnection
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
+ connection: SolanaConnection
63
+ }): Promise<{ signature: string }>
64
+ }
65
+
66
+ export const createSolanaWalletProvider = (
67
+ request: SolanaRequestFn,
68
+ ): SolanaWalletProvider => ({
69
+ request,
70
+ signMessage: (msg: string) =>
71
+ request({ method: 'signMessage', params: { message: msg } }),
72
+ signTransaction: <T extends SolanaCombinedTransaction>(transaction: T) =>
73
+ request({ method: 'signTransaction', params: { transaction } }),
74
+ signAndSendTransaction: (input: {
75
+ transaction: SolanaCombinedTransaction
76
+ connection: SolanaConnection
77
+ }) =>
78
+ request({
79
+ method: 'signAndSendTransaction',
80
+ params: input,
81
+ }),
82
+ })
package/src/types.ts CHANGED
@@ -2,8 +2,9 @@ import type {
2
2
  AddFrame,
3
3
  ComposeCast,
4
4
  Ready,
5
+ SendToken,
5
6
  SignIn,
6
- Swap,
7
+ SwapToken,
7
8
  ViewProfile,
8
9
  ViewToken,
9
10
  } from './actions'
@@ -14,6 +15,7 @@ import type {
14
15
  EventNotificationsDisabled,
15
16
  EventNotificationsEnabled,
16
17
  } from './schemas'
18
+ import type { SolanaRequestFn } from './solana'
17
19
  import type { Ethereum } from './wallet'
18
20
 
19
21
  export type SetPrimaryButtonOptions = {
@@ -41,10 +43,12 @@ export type WireFrameHost = {
41
43
  ethProviderRequest: Ethereum.EthProvideRequest
42
44
  ethProviderRequestV2: Ethereum.RpcTransport
43
45
  eip6963RequestProvider: () => void
46
+ solanaProviderRequest?: SolanaRequestFn
44
47
  addFrame: AddFrame.WireAddFrame
45
48
  viewProfile: ViewProfile.ViewProfile
46
49
  viewToken: ViewToken.ViewToken
47
- swap: Swap.Swap
50
+ sendToken: SendToken.SendToken
51
+ swapToken: SwapToken.SwapToken
48
52
  composeCast: <close extends boolean | undefined = undefined>(
49
53
  options: ComposeCast.Options<close>,
50
54
  ) => Promise<ComposeCast.Result<close>>
@@ -64,10 +68,12 @@ export type FrameHost = {
64
68
  * Hosts must emit an EventEip6963AnnounceProvider in response.
65
69
  */
66
70
  eip6963RequestProvider: () => void
71
+ solanaProviderRequest?: SolanaRequestFn
67
72
  addFrame: AddFrame.AddFrame
68
73
  viewProfile: ViewProfile.ViewProfile
69
74
  viewToken: ViewToken.ViewToken
70
- swap: Swap.Swap
75
+ sendToken: SendToken.SendToken
76
+ swapToken: SwapToken.SwapToken
71
77
  composeCast: <close extends boolean | undefined = undefined>(
72
78
  options: ComposeCast.Options<close>,
73
79
  ) => Promise<ComposeCast.Result<close>>
File without changes
File without changes