@farcaster/frame-core 0.0.26 → 0.0.28

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 (42) hide show
  1. package/dist/actions/Ready.d.ts +13 -0
  2. package/dist/actions/Ready.js +6 -0
  3. package/dist/actions/Swap.d.ts +46 -0
  4. package/dist/actions/Swap.js +2 -0
  5. package/dist/actions/ViewToken.d.ts +4 -0
  6. package/dist/actions/ViewToken.js +2 -0
  7. package/dist/actions/index.d.ts +4 -1
  8. package/dist/actions/index.js +5 -2
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +1 -0
  11. package/dist/types.d.ts +16 -77
  12. package/dist/types.js +18 -3
  13. package/dist/wallet/ethereum.d.ts +43 -0
  14. package/dist/wallet/ethereum.js +2 -0
  15. package/dist/wallet/index.d.ts +1 -0
  16. package/dist/wallet/index.js +37 -0
  17. package/esm/actions/Ready.d.ts +13 -0
  18. package/esm/actions/Ready.js +3 -0
  19. package/esm/actions/Swap.d.ts +46 -0
  20. package/esm/actions/Swap.js +1 -0
  21. package/esm/actions/ViewToken.d.ts +4 -0
  22. package/esm/actions/ViewToken.js +1 -0
  23. package/esm/actions/index.d.ts +4 -1
  24. package/esm/actions/index.js +4 -1
  25. package/esm/index.d.ts +1 -0
  26. package/esm/index.js +1 -0
  27. package/esm/tsconfig.tsbuildinfo +1 -1
  28. package/esm/types.d.ts +16 -77
  29. package/esm/types.js +3 -3
  30. package/esm/wallet/ethereum.d.ts +43 -0
  31. package/esm/wallet/ethereum.js +1 -0
  32. package/esm/wallet/index.d.ts +1 -0
  33. package/esm/wallet/index.js +1 -0
  34. package/package.json +2 -2
  35. package/src/actions/Ready.ts +15 -0
  36. package/src/actions/Swap.ts +54 -0
  37. package/src/actions/ViewToken.ts +5 -0
  38. package/src/actions/index.ts +4 -1
  39. package/src/index.ts +1 -0
  40. package/src/types.ts +26 -100
  41. package/src/wallet/ethereum.ts +61 -0
  42. package/src/wallet/index.ts +1 -0
@@ -0,0 +1,13 @@
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
+ export declare const DEFAULT_READY_OPTIONS: {
11
+ disableNativeGestures: false;
12
+ };
13
+ export type Ready = (options?: Partial<ReadyOptions>) => void;
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.DEFAULT_READY_OPTIONS = void 0;
4
+ exports.DEFAULT_READY_OPTIONS = {
5
+ disableNativeGestures: false,
6
+ };
@@ -0,0 +1,46 @@
1
+ export type SwapOptions = {
2
+ /**
3
+ * CAIP-19 asset ID
4
+ * For example, Base USDC:
5
+ * eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
6
+ */
7
+ sellToken?: string;
8
+ /**
9
+ * CAIP-19 token ID. For example, OP ETH:
10
+ * eip155:10/native
11
+ */
12
+ buyToken?: string;
13
+ /**
14
+ * Sell token amount, as numeric string.
15
+ * For example, 10 USDC: 1000000
16
+ */
17
+ sellAmount?: string;
18
+ };
19
+ type SwapDetails = {
20
+ /**
21
+ * Array of tx identifiers in order of execution.
22
+ * Some swaps will have both an approval and swap tx.
23
+ */
24
+ transactions: `0x${string}`[];
25
+ };
26
+ type SwapErrorDetails = {
27
+ /**
28
+ * Error code.
29
+ */
30
+ error: string;
31
+ /**
32
+ * Error message.
33
+ */
34
+ message?: string;
35
+ };
36
+ export type SwapErrorReason = 'rejected_by_user' | 'swap_failed';
37
+ export type SwapResult = {
38
+ success: true;
39
+ swap: SwapDetails;
40
+ } | {
41
+ success: false;
42
+ reason: SwapErrorReason;
43
+ error?: SwapErrorDetails;
44
+ };
45
+ export type Swap = (options: SwapOptions) => Promise<SwapResult>;
46
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,4 @@
1
+ export type ViewTokenOptions = {
2
+ token: string;
3
+ };
4
+ export type ViewToken = (options: ViewTokenOptions) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,3 +1,6 @@
1
1
  export * as AddFrame from './AddFrame';
2
- export * as ViewProfile from './ViewProfile';
2
+ export * as Ready from './Ready';
3
3
  export * as SignIn from './SignIn';
4
+ export * as Swap from './Swap';
5
+ export * as ViewProfile from './ViewProfile';
6
+ export * as ViewToken from './ViewToken';
@@ -33,7 +33,10 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.SignIn = exports.ViewProfile = exports.AddFrame = void 0;
36
+ exports.ViewToken = exports.ViewProfile = exports.Swap = exports.SignIn = exports.Ready = exports.AddFrame = void 0;
37
37
  exports.AddFrame = __importStar(require("./AddFrame"));
38
- exports.ViewProfile = __importStar(require("./ViewProfile"));
38
+ exports.Ready = __importStar(require("./Ready"));
39
39
  exports.SignIn = __importStar(require("./SignIn"));
40
+ exports.Swap = __importStar(require("./Swap"));
41
+ exports.ViewProfile = __importStar(require("./ViewProfile"));
42
+ exports.ViewToken = __importStar(require("./ViewToken"));
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './actions';
2
+ export * from './wallet';
2
3
  export * as Context from './context';
3
4
  export * from './types';
4
5
  export * from './schemas';
package/dist/index.js CHANGED
@@ -38,6 +38,7 @@ var __importStar = (this && this.__importStar) || (function () {
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
39
  exports.Context = void 0;
40
40
  __exportStar(require("./actions"), exports);
41
+ __exportStar(require("./wallet"), exports);
41
42
  exports.Context = __importStar(require("./context"));
42
43
  __exportStar(require("./types"), exports);
43
44
  __exportStar(require("./schemas"), exports);
package/dist/types.d.ts CHANGED
@@ -1,63 +1,41 @@
1
- import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
2
- import type { AddFrame, SignIn, ViewProfile } from './actions';
1
+ import type { AddFrame, Ready, SignIn, Swap, ViewProfile, ViewToken } from './actions';
3
2
  import type { FrameContext } from './context';
4
3
  import type { EventFrameAdded, EventFrameRemoved, EventNotificationsDisabled, EventNotificationsEnabled } from './schemas';
4
+ import type { Ethereum } from './wallet';
5
5
  export type SetPrimaryButtonOptions = {
6
6
  text: string;
7
7
  loading?: boolean;
8
8
  disabled?: boolean;
9
9
  hidden?: boolean;
10
10
  };
11
+ export * from './wallet/ethereum';
12
+ export { DEFAULT_READY_OPTIONS, ReadyOptions } from './actions/Ready';
13
+ export type SignInOptions = SignIn.SignInOptions;
11
14
  export type SetPrimaryButton = (options: SetPrimaryButtonOptions) => void;
12
- export type EthProviderRequest = Provider.RequestFn<RpcSchema.Default>;
13
- export type ReadyOptions = {
14
- /**
15
- * Disable native gestures. Use this option if your frame uses gestures
16
- * that conflict with native gestures.
17
- *
18
- * @defaultValue false
19
- */
20
- disableNativeGestures: boolean;
21
- };
22
- export declare const DEFAULT_READY_OPTIONS: ReadyOptions;
23
- export type SignInOptions = {
24
- /**
25
- * A random string used to prevent replay attacks.
26
- */
27
- nonce: string;
28
- /**
29
- * Start time at which the signature becomes valid.
30
- * ISO 8601 datetime.
31
- */
32
- notBefore?: string;
33
- /**
34
- * Expiration time at which the signature is no longer valid.
35
- * ISO 8601 datetime.
36
- */
37
- expirationTime?: string;
38
- };
39
15
  export type WireFrameHost = {
40
16
  context: FrameContext;
41
17
  close: () => void;
42
- ready: (options?: Partial<ReadyOptions>) => void;
18
+ ready: Ready.Ready;
43
19
  openUrl: (url: string) => void;
44
20
  signIn: SignIn.WireSignIn;
45
21
  setPrimaryButton: SetPrimaryButton;
46
- ethProviderRequest: EthProviderRequest;
47
- ethProviderRequestV2: RpcTransport;
22
+ ethProviderRequest: Ethereum.EthProvideRequest;
23
+ ethProviderRequestV2: Ethereum.RpcTransport;
48
24
  eip6963RequestProvider: () => void;
49
25
  addFrame: AddFrame.WireAddFrame;
50
26
  viewProfile: ViewProfile.ViewProfile;
27
+ viewToken: ViewToken.ViewToken;
28
+ swap: Swap.Swap;
51
29
  };
52
30
  export type FrameHost = {
53
31
  context: FrameContext;
54
32
  close: () => void;
55
- ready: (options?: Partial<ReadyOptions>) => void;
33
+ ready: Ready.Ready;
56
34
  openUrl: (url: string) => void;
57
35
  signIn: SignIn.SignIn;
58
36
  setPrimaryButton: SetPrimaryButton;
59
- ethProviderRequest: EthProviderRequest;
60
- ethProviderRequestV2: RpcTransport;
37
+ ethProviderRequest: Ethereum.EthProvideRequest;
38
+ ethProviderRequestV2: Ethereum.RpcTransport;
61
39
  /**
62
40
  * Receive forwarded eip6963:requestProvider events from the frame document.
63
41
  * Hosts must emit an EventEip6963AnnounceProvider in response.
@@ -65,35 +43,9 @@ export type FrameHost = {
65
43
  eip6963RequestProvider: () => void;
66
44
  addFrame: AddFrame.AddFrame;
67
45
  viewProfile: ViewProfile.ViewProfile;
46
+ viewToken: ViewToken.ViewToken;
47
+ swap: Swap.Swap;
68
48
  };
69
- export type FrameEthProviderEventData = {
70
- type: 'frame_eth_provider_event';
71
- } & EthProviderWireEvent;
72
- export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
73
- export type ProviderRpcError = {
74
- code: number;
75
- details?: string;
76
- message?: string;
77
- };
78
- export type EthProviderWireEvent = {
79
- event: 'accountsChanged';
80
- params: [readonly Address.Address[]];
81
- } | {
82
- event: 'chainChanged';
83
- params: [string];
84
- } | {
85
- event: 'connect';
86
- params: [Provider.ConnectInfo];
87
- } | {
88
- event: 'disconnect';
89
- params: [ProviderRpcError];
90
- } | {
91
- event: 'message';
92
- params: [Provider.Message];
93
- };
94
- export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
95
- event: event;
96
- }>['params']) => void;
97
49
  export type EventFrameAddRejected = {
98
50
  event: 'frame_add_rejected';
99
51
  reason: AddFrame.AddFrameRejectedReason;
@@ -101,17 +53,4 @@ export type EventFrameAddRejected = {
101
53
  export type EventPrimaryButtonClicked = {
102
54
  event: 'primary_button_clicked';
103
55
  };
104
- /**
105
- * Metadata of the EIP-1193 Provider.
106
- */
107
- export interface EIP6963ProviderInfo {
108
- icon: `data:image/${string}`;
109
- name: string;
110
- rdns: string;
111
- uuid: string;
112
- }
113
- export type EventEip6963AnnounceProvider = {
114
- event: 'eip6963:announceProvider';
115
- info: EIP6963ProviderInfo;
116
- };
117
- export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | EventEip6963AnnounceProvider;
56
+ export type FrameClientEvent = EventFrameAdded | EventFrameAddRejected | EventFrameRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | Ethereum.EventEip6963AnnounceProvider;
package/dist/types.js CHANGED
@@ -1,6 +1,21 @@
1
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
+ };
2
16
  Object.defineProperty(exports, "__esModule", { value: true });
3
17
  exports.DEFAULT_READY_OPTIONS = void 0;
4
- exports.DEFAULT_READY_OPTIONS = {
5
- disableNativeGestures: false,
6
- };
18
+ // start backwards compat, remove in 1.0
19
+ __exportStar(require("./wallet/ethereum"), exports);
20
+ var Ready_1 = require("./actions/Ready");
21
+ Object.defineProperty(exports, "DEFAULT_READY_OPTIONS", { enumerable: true, get: function () { return Ready_1.DEFAULT_READY_OPTIONS; } });
@@ -0,0 +1,43 @@
1
+ import type { Address, Provider, RpcRequest, RpcResponse, RpcSchema } from 'ox';
2
+ export type EthProvideRequest<schema extends RpcSchema.Generic = RpcSchema.Default> = Provider.RequestFn<schema>;
3
+ export type FrameEthProviderEventData = {
4
+ type: 'frame_eth_provider_event';
5
+ } & EthProviderWireEvent;
6
+ export type RpcTransport = (request: RpcRequest.RpcRequest) => Promise<RpcResponse.RpcResponse>;
7
+ export type ProviderRpcError = {
8
+ code: number;
9
+ details?: string;
10
+ message?: string;
11
+ };
12
+ export type EthProviderWireEvent = {
13
+ event: 'accountsChanged';
14
+ params: [readonly Address.Address[]];
15
+ } | {
16
+ event: 'chainChanged';
17
+ params: [string];
18
+ } | {
19
+ event: 'connect';
20
+ params: [Provider.ConnectInfo];
21
+ } | {
22
+ event: 'disconnect';
23
+ params: [ProviderRpcError];
24
+ } | {
25
+ event: 'message';
26
+ params: [Provider.Message];
27
+ };
28
+ export type EmitEthProvider = <event extends EthProviderWireEvent['event']>(event: event, params: Extract<EthProviderWireEvent, {
29
+ event: event;
30
+ }>['params']) => void;
31
+ /**
32
+ * Metadata of the EIP-1193 Provider.
33
+ */
34
+ export interface EIP6963ProviderInfo {
35
+ icon: `data:image/${string}`;
36
+ name: string;
37
+ rdns: string;
38
+ uuid: string;
39
+ }
40
+ export type EventEip6963AnnounceProvider = {
41
+ event: 'eip6963:announceProvider';
42
+ info: EIP6963ProviderInfo;
43
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export * as Ethereum from './ethereum';
@@ -0,0 +1,37 @@
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || (function () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ Object.defineProperty(exports, "__esModule", { value: true });
36
+ exports.Ethereum = void 0;
37
+ exports.Ethereum = __importStar(require("./ethereum"));
@@ -0,0 +1,13 @@
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
+ export declare const DEFAULT_READY_OPTIONS: {
11
+ disableNativeGestures: false;
12
+ };
13
+ export type Ready = (options?: Partial<ReadyOptions>) => void;
@@ -0,0 +1,3 @@
1
+ export const DEFAULT_READY_OPTIONS = {
2
+ disableNativeGestures: false,
3
+ };
@@ -0,0 +1,46 @@
1
+ export type SwapOptions = {
2
+ /**
3
+ * CAIP-19 asset ID
4
+ * For example, Base USDC:
5
+ * eip155:8453/erc20:0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913
6
+ */
7
+ sellToken?: string;
8
+ /**
9
+ * CAIP-19 token ID. For example, OP ETH:
10
+ * eip155:10/native
11
+ */
12
+ buyToken?: string;
13
+ /**
14
+ * Sell token amount, as numeric string.
15
+ * For example, 10 USDC: 1000000
16
+ */
17
+ sellAmount?: string;
18
+ };
19
+ type SwapDetails = {
20
+ /**
21
+ * Array of tx identifiers in order of execution.
22
+ * Some swaps will have both an approval and swap tx.
23
+ */
24
+ transactions: `0x${string}`[];
25
+ };
26
+ type SwapErrorDetails = {
27
+ /**
28
+ * Error code.
29
+ */
30
+ error: string;
31
+ /**
32
+ * Error message.
33
+ */
34
+ message?: string;
35
+ };
36
+ export type SwapErrorReason = 'rejected_by_user' | 'swap_failed';
37
+ export type SwapResult = {
38
+ success: true;
39
+ swap: SwapDetails;
40
+ } | {
41
+ success: false;
42
+ reason: SwapErrorReason;
43
+ error?: SwapErrorDetails;
44
+ };
45
+ export type Swap = (options: SwapOptions) => Promise<SwapResult>;
46
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,4 @@
1
+ export type ViewTokenOptions = {
2
+ token: string;
3
+ };
4
+ export type ViewToken = (options: ViewTokenOptions) => Promise<void>;
@@ -0,0 +1 @@
1
+ export {};
@@ -1,3 +1,6 @@
1
1
  export * as AddFrame from './AddFrame';
2
- export * as ViewProfile from './ViewProfile';
2
+ export * as Ready from './Ready';
3
3
  export * as SignIn from './SignIn';
4
+ export * as Swap from './Swap';
5
+ export * as ViewProfile from './ViewProfile';
6
+ export * as ViewToken from './ViewToken';
@@ -1,3 +1,6 @@
1
1
  export * as AddFrame from './AddFrame';
2
- export * as ViewProfile from './ViewProfile';
2
+ export * as Ready from './Ready';
3
3
  export * as SignIn from './SignIn';
4
+ export * as Swap from './Swap';
5
+ export * as ViewProfile from './ViewProfile';
6
+ export * as ViewToken from './ViewToken';
package/esm/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './actions';
2
+ export * from './wallet';
2
3
  export * as Context from './context';
3
4
  export * from './types';
4
5
  export * from './schemas';
package/esm/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  export * from './actions';
2
+ export * from './wallet';
2
3
  export * as Context from './context';
3
4
  export * from './types';
4
5
  export * from './schemas';