@farcaster/miniapp-core 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.
- package/LICENSE +21 -0
- package/README.md +13 -0
- package/dist/actions/AddMiniApp.d.ts +36 -0
- package/dist/actions/AddMiniApp.js +57 -0
- package/dist/actions/ComposeCast.d.ts +37 -0
- package/dist/actions/ComposeCast.js +2 -0
- package/dist/actions/Haptics.d.ts +5 -0
- package/dist/actions/Haptics.js +2 -0
- package/dist/actions/Ready.d.ts +13 -0
- package/dist/actions/Ready.js +6 -0
- package/dist/actions/SendToken.d.ts +48 -0
- package/dist/actions/SendToken.js +2 -0
- package/dist/actions/SignIn.d.ts +55 -0
- package/dist/actions/SignIn.js +47 -0
- package/dist/actions/SwapToken.d.ts +46 -0
- package/dist/actions/SwapToken.js +2 -0
- package/dist/actions/ViewCast.d.ts +25 -0
- package/dist/actions/ViewCast.js +2 -0
- package/dist/actions/ViewProfile.d.ts +4 -0
- package/dist/actions/ViewProfile.js +2 -0
- package/dist/actions/ViewToken.d.ts +4 -0
- package/dist/actions/ViewToken.js +2 -0
- package/dist/actions/index.d.ts +10 -0
- package/dist/actions/index.js +46 -0
- package/dist/back.d.ts +13 -0
- package/dist/back.js +6 -0
- package/dist/context.d.ts +94 -0
- package/dist/context.js +2 -0
- package/dist/errors.d.ts +13 -0
- package/dist/errors.js +12 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +49 -0
- package/dist/internal/types.d.ts +8 -0
- package/dist/internal/types.js +2 -0
- package/dist/manifest.d.ts +113 -0
- package/dist/manifest.js +10 -0
- package/dist/schemas/embeds.d.ts +128 -0
- package/dist/schemas/embeds.js +43 -0
- package/dist/schemas/events.d.ts +63 -0
- package/dist/schemas/events.js +35 -0
- package/dist/schemas/index.d.ts +5 -0
- package/dist/schemas/index.js +21 -0
- package/dist/schemas/manifest.d.ts +236 -0
- package/dist/schemas/manifest.js +127 -0
- package/dist/schemas/notifications.d.ts +22 -0
- package/dist/schemas/notifications.js +23 -0
- package/dist/schemas/shared.d.ts +24 -0
- package/dist/schemas/shared.js +110 -0
- package/dist/solana.d.ts +72 -0
- package/dist/solana.js +15 -0
- package/dist/solanaWire.d.ts +3 -0
- package/dist/solanaWire.js +84 -0
- package/dist/types.d.ts +91 -0
- package/dist/types.js +41 -0
- package/dist/wallet/ethereum.d.ts +47 -0
- package/dist/wallet/ethereum.js +2 -0
- package/dist/wallet/index.d.ts +1 -0
- package/dist/wallet/index.js +37 -0
- package/esm/actions/AddMiniApp.d.ts +36 -0
- package/esm/actions/AddMiniApp.js +19 -0
- package/esm/actions/ComposeCast.d.ts +37 -0
- package/esm/actions/ComposeCast.js +1 -0
- package/esm/actions/Haptics.d.ts +5 -0
- package/esm/actions/Haptics.js +1 -0
- package/esm/actions/Ready.d.ts +13 -0
- package/esm/actions/Ready.js +3 -0
- package/esm/actions/SendToken.d.ts +48 -0
- package/esm/actions/SendToken.js +1 -0
- package/esm/actions/SignIn.d.ts +55 -0
- package/esm/actions/SignIn.js +10 -0
- package/esm/actions/SwapToken.d.ts +46 -0
- package/esm/actions/SwapToken.js +1 -0
- package/esm/actions/ViewCast.d.ts +25 -0
- package/esm/actions/ViewCast.js +1 -0
- package/esm/actions/ViewProfile.d.ts +4 -0
- package/esm/actions/ViewProfile.js +1 -0
- package/esm/actions/ViewToken.d.ts +4 -0
- package/esm/actions/ViewToken.js +1 -0
- package/esm/actions/index.d.ts +10 -0
- package/esm/actions/index.js +10 -0
- package/esm/back.d.ts +13 -0
- package/esm/back.js +3 -0
- package/esm/context.d.ts +94 -0
- package/esm/context.js +1 -0
- package/esm/errors.d.ts +13 -0
- package/esm/errors.js +8 -0
- package/esm/index.d.ts +10 -0
- package/esm/index.js +10 -0
- package/esm/internal/types.d.ts +8 -0
- package/esm/internal/types.js +1 -0
- package/esm/manifest.d.ts +113 -0
- package/esm/manifest.js +7 -0
- package/esm/schemas/embeds.d.ts +128 -0
- package/esm/schemas/embeds.js +39 -0
- package/esm/schemas/events.d.ts +63 -0
- package/esm/schemas/events.js +32 -0
- package/esm/schemas/index.d.ts +5 -0
- package/esm/schemas/index.js +5 -0
- package/esm/schemas/manifest.d.ts +236 -0
- package/esm/schemas/manifest.js +124 -0
- package/esm/schemas/notifications.d.ts +22 -0
- package/esm/schemas/notifications.js +20 -0
- package/esm/schemas/shared.d.ts +24 -0
- package/esm/schemas/shared.js +106 -0
- package/esm/solana.d.ts +72 -0
- package/esm/solana.js +11 -0
- package/esm/solanaWire.d.ts +3 -0
- package/esm/solanaWire.js +80 -0
- package/esm/tsconfig.tsbuildinfo +1 -0
- package/esm/types.d.ts +91 -0
- package/esm/types.js +23 -0
- package/esm/wallet/ethereum.d.ts +47 -0
- package/esm/wallet/ethereum.js +1 -0
- package/esm/wallet/index.d.ts +1 -0
- package/esm/wallet/index.js +1 -0
- package/package.json +42 -0
- package/src/actions/AddMiniApp.ts +51 -0
- package/src/actions/ComposeCast.ts +44 -0
- package/src/actions/Haptics.ts +9 -0
- package/src/actions/Ready.ts +15 -0
- package/src/actions/SendToken.ts +57 -0
- package/src/actions/SignIn.ts +67 -0
- package/src/actions/SwapToken.ts +54 -0
- package/src/actions/ViewCast.ts +27 -0
- package/src/actions/ViewProfile.ts +5 -0
- package/src/actions/ViewToken.ts +5 -0
- package/src/actions/index.ts +10 -0
- package/src/back.ts +15 -0
- package/src/context.ts +117 -0
- package/src/errors.ts +21 -0
- package/src/index.ts +10 -0
- package/src/internal/types.ts +20 -0
- package/src/manifest.ts +131 -0
- package/src/schemas/embeds.ts +58 -0
- package/src/schemas/events.ts +57 -0
- package/src/schemas/index.ts +5 -0
- package/src/schemas/manifest.ts +142 -0
- package/src/schemas/notifications.ts +35 -0
- package/src/schemas/shared.ts +138 -0
- package/src/solana.ts +108 -0
- package/src/solanaWire.ts +120 -0
- package/src/types.ts +165 -0
- package/src/wallet/ethereum.ts +65 -0
- package/src/wallet/index.ts +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
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
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
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 { MiniAppContext } from './context.ts';
|
|
5
|
+
import type { EventFrameAdded, EventFrameRemoved, EventMiniAppAdded, EventMiniAppRemoved, 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 WireMiniAppHost = {
|
|
24
|
+
context: MiniAppContext;
|
|
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
|
+
addMiniApp: 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 MiniAppHost = {
|
|
49
|
+
context: MiniAppContext;
|
|
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
|
+
addMiniApp: 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 EventMiniAppAddRejected = {
|
|
82
|
+
event: 'miniapp_add_rejected';
|
|
83
|
+
reason: AddMiniApp.AddMiniAppRejectedReason;
|
|
84
|
+
};
|
|
85
|
+
export type EventPrimaryButtonClicked = {
|
|
86
|
+
event: 'primary_button_clicked';
|
|
87
|
+
};
|
|
88
|
+
export type EventBackNavigationTriggered = {
|
|
89
|
+
event: 'back_navigation_triggered';
|
|
90
|
+
};
|
|
91
|
+
export type MiniAppClientEvent = EventMiniAppAdded | EventMiniAppAddRejected | EventMiniAppRemoved | EventNotificationsEnabled | EventNotificationsDisabled | EventPrimaryButtonClicked | EventBackNavigationTriggered | Ethereum.EventEip6963AnnounceProvider | EventFrameAdded | EventFrameAddRejected | EventFrameRemoved;
|
package/dist/types.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
];
|
|
@@ -0,0 +1,47 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * as Ethereum from './ethereum.ts';
|
|
@@ -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.js"));
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import * as Errors from '../errors.ts';
|
|
2
|
+
import type { OneOf } from '../internal/types.ts';
|
|
3
|
+
import type { MiniAppNotificationDetails } from '../schemas/index.ts';
|
|
4
|
+
export type AddMiniAppResult = {
|
|
5
|
+
notificationDetails?: MiniAppNotificationDetails;
|
|
6
|
+
};
|
|
7
|
+
export type AddMiniApp = () => Promise<AddMiniAppResult>;
|
|
8
|
+
type InvalidDomainManifestJsonError = {
|
|
9
|
+
type: 'invalid_domain_manifest';
|
|
10
|
+
};
|
|
11
|
+
type RejectedByUserJsonError = {
|
|
12
|
+
type: 'rejected_by_user';
|
|
13
|
+
};
|
|
14
|
+
export type AddMiniAppJsonError = InvalidDomainManifestJsonError | RejectedByUserJsonError;
|
|
15
|
+
export type AddMiniAppRejectedReason = AddMiniAppJsonError['type'];
|
|
16
|
+
export type AddMiniAppJsonResult = OneOf<{
|
|
17
|
+
result: AddMiniAppResult;
|
|
18
|
+
} | {
|
|
19
|
+
error: AddMiniAppJsonError;
|
|
20
|
+
}>;
|
|
21
|
+
export type WireAddMiniApp = () => Promise<AddMiniAppJsonResult>;
|
|
22
|
+
/**
|
|
23
|
+
* Thrown when the miniapp does not have a valid domain manifest.
|
|
24
|
+
*/
|
|
25
|
+
export declare class InvalidDomainManifest extends Errors.BaseError {
|
|
26
|
+
readonly name = "AddMiniApp.InvalidDomainManifest";
|
|
27
|
+
constructor();
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Thrown when add miniapp action was rejected by the user.
|
|
31
|
+
*/
|
|
32
|
+
export declare class RejectedByUser extends Errors.BaseError {
|
|
33
|
+
readonly name = "AddMiniApp.RejectedByUser";
|
|
34
|
+
constructor();
|
|
35
|
+
}
|
|
36
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import * as Errors from "../errors.js";
|
|
2
|
+
/**
|
|
3
|
+
* Thrown when the miniapp does not have a valid domain manifest.
|
|
4
|
+
*/
|
|
5
|
+
export class InvalidDomainManifest extends Errors.BaseError {
|
|
6
|
+
name = 'AddMiniApp.InvalidDomainManifest';
|
|
7
|
+
constructor() {
|
|
8
|
+
super('Invalid domain manifest');
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Thrown when add miniapp action was rejected by the user.
|
|
13
|
+
*/
|
|
14
|
+
export class RejectedByUser extends Errors.BaseError {
|
|
15
|
+
name = 'AddMiniApp.RejectedByUser';
|
|
16
|
+
constructor() {
|
|
17
|
+
super('Add miniapp rejected by user');
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
/** Suggested embeds. Max two. */
|
|
9
|
+
embeds?: [] | [string] | [string, string];
|
|
10
|
+
/** Suggested parent. */
|
|
11
|
+
parent?: {
|
|
12
|
+
type: 'cast';
|
|
13
|
+
hash: string;
|
|
14
|
+
};
|
|
15
|
+
/** Whether the app should be closed when this action is called. */
|
|
16
|
+
close?: close;
|
|
17
|
+
/** Whether the cast should be posted to a channel. */
|
|
18
|
+
channelKey?: string;
|
|
19
|
+
};
|
|
20
|
+
export type ComposeCastInnerResult = {
|
|
21
|
+
/** Cast of the created cast */
|
|
22
|
+
hash: string;
|
|
23
|
+
/** Text of the created cast */
|
|
24
|
+
text?: string;
|
|
25
|
+
/** Embeds of the created cast */
|
|
26
|
+
embeds?: [] | [string] | [string, string];
|
|
27
|
+
/** Parent of the created cast */
|
|
28
|
+
parent?: {
|
|
29
|
+
type: 'cast';
|
|
30
|
+
hash: string;
|
|
31
|
+
};
|
|
32
|
+
/** Channel key of the created cast */
|
|
33
|
+
channelKey?: string;
|
|
34
|
+
};
|
|
35
|
+
export type Result<close extends boolean | undefined = undefined> = close extends true ? undefined : {
|
|
36
|
+
cast: ComposeCastInnerResult | null;
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export type ImpactOccurredType = 'light' | 'medium' | 'heavy' | 'soft' | 'rigid';
|
|
2
|
+
export type NotificationOccurredType = 'success' | 'warning' | 'error';
|
|
3
|
+
export type ImpactOccurred = (type: ImpactOccurredType) => Promise<void>;
|
|
4
|
+
export type NotificationOccurred = (type: NotificationOccurredType) => Promise<void>;
|
|
5
|
+
export type SelectionChanged = () => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -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,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 {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as Errors from '../errors.ts';
|
|
2
|
+
import type { OneOf } from '../internal/types.ts';
|
|
3
|
+
export type SignInOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* A random string used to prevent replay attacks.
|
|
6
|
+
*/
|
|
7
|
+
nonce: string;
|
|
8
|
+
/**
|
|
9
|
+
* Start time at which the signature becomes valid.
|
|
10
|
+
* ISO 8601 datetime.
|
|
11
|
+
*/
|
|
12
|
+
notBefore?: string;
|
|
13
|
+
/**
|
|
14
|
+
* Expiration time at which the signature is no longer valid.
|
|
15
|
+
* ISO 8601 datetime.
|
|
16
|
+
*/
|
|
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;
|
|
28
|
+
};
|
|
29
|
+
export type SignInResult = {
|
|
30
|
+
signature: string;
|
|
31
|
+
message: string;
|
|
32
|
+
/**
|
|
33
|
+
* Indicates if the signature was produced by a custody or auth address.
|
|
34
|
+
*/
|
|
35
|
+
authMethod: 'custody' | 'authAddress';
|
|
36
|
+
};
|
|
37
|
+
export type SignIn = (options: SignInOptions) => Promise<SignInResult>;
|
|
38
|
+
type RejectedByUserJsonError = {
|
|
39
|
+
type: 'rejected_by_user';
|
|
40
|
+
};
|
|
41
|
+
export type SignInJsonError = RejectedByUserJsonError;
|
|
42
|
+
export type SignInJsonResult = OneOf<{
|
|
43
|
+
result: SignInResult;
|
|
44
|
+
} | {
|
|
45
|
+
error: SignInJsonError;
|
|
46
|
+
}>;
|
|
47
|
+
export type WireSignIn = (options: SignInOptions) => Promise<SignInJsonResult>;
|
|
48
|
+
/**
|
|
49
|
+
* Thrown when a sign in action was rejected.
|
|
50
|
+
*/
|
|
51
|
+
export declare class RejectedByUser extends Errors.BaseError {
|
|
52
|
+
readonly name = "SignIn.RejectedByUser";
|
|
53
|
+
constructor();
|
|
54
|
+
}
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export type SwapTokenOptions = {
|
|
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, 1 USDC: 1000000
|
|
16
|
+
*/
|
|
17
|
+
sellAmount?: string;
|
|
18
|
+
};
|
|
19
|
+
type SwapTokenDetails = {
|
|
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 SwapTokenErrorDetails = {
|
|
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 SwapTokenResult = {
|
|
38
|
+
success: true;
|
|
39
|
+
swap: SwapTokenDetails;
|
|
40
|
+
} | {
|
|
41
|
+
success: false;
|
|
42
|
+
reason: SwapErrorReason;
|
|
43
|
+
error?: SwapTokenErrorDetails;
|
|
44
|
+
};
|
|
45
|
+
export type SwapToken = (options: SwapTokenOptions) => Promise<SwapTokenResult>;
|
|
46
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export type ViewCastOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* The hash of the cast to view.
|
|
4
|
+
* @example "0x6a112e2d35e2d2008e25dd29811e8769d1edd9ca"
|
|
5
|
+
*/
|
|
6
|
+
hash: string;
|
|
7
|
+
/**
|
|
8
|
+
* Whether the app should be closed when this action is called.
|
|
9
|
+
* If true, the app will be closed after opening the cast view.
|
|
10
|
+
*/
|
|
11
|
+
close?: boolean;
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Opens a cast view in the Farcaster client.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* await sdk.actions.viewCast({
|
|
19
|
+
* hash: "0x6a112e2d35e2d2008e25dd29811e8769d1edd9ca"
|
|
20
|
+
* })
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @see {@link https://miniapps.farcaster.xyz/docs/sdk/actions/view-cast | View Cast Documentation}
|
|
24
|
+
*/
|
|
25
|
+
export type ViewCast = (options: ViewCastOptions) => Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * as AddMiniApp from './AddMiniApp.ts';
|
|
2
|
+
export * as ComposeCast from './ComposeCast.ts';
|
|
3
|
+
export * as Haptics from './Haptics.ts';
|
|
4
|
+
export * as Ready from './Ready.ts';
|
|
5
|
+
export * as SignIn from './SignIn.ts';
|
|
6
|
+
export * as SendToken from './SendToken.ts';
|
|
7
|
+
export * as SwapToken from './SwapToken.ts';
|
|
8
|
+
export * as ViewCast from './ViewCast.ts';
|
|
9
|
+
export * as ViewProfile from './ViewProfile.ts';
|
|
10
|
+
export * as ViewToken from './ViewToken.ts';
|