-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconstants.ts
More file actions
121 lines (109 loc) · 2.64 KB
/
constants.ts
File metadata and controls
121 lines (109 loc) · 2.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import type { FrameUITheme } from '@frames.js/render/ui';
import {
arbitrum,
arbitrumGoerli,
base,
baseSepolia,
bsc,
bscTestnet,
goerli,
mainnet,
optimism,
optimismGoerli,
polygon,
polygonMumbai,
sepolia,
} from 'viem/chains';
import { AbstractActionComponent, Action, type ActionAdapter, type ActionPostRequest, type TypedActionParameter } from '../api';
export const noop = () => { };
export type StylingProps = {
className?: string;
style?: React.CSSProperties;
};
export const theme: FrameUITheme<StylingProps> = {
Root: {
className:
'flex flex-col max-w-[600px] rounded-lg ovrflow-hidden relative farcaster-container',
},
LoadingScreen: {
className: 'absolute top-0 left-0 right-0 bottom-0 bg-gray-300 z-10',
},
ImageContainer: {
className: 'relative w-full rounded overflow-hidden mb-5',
style: {
aspectRatio: 'var(--frame-image-aspect-ratio)',
},
},
ButtonsContainer: {
className: 'flex justify-evenly space-x-2 px-2 pb-2',
},
Button: {
className:
'flex w-full items-center justify-center text-nowrap rounded-button px-4 py-3 font-semibold transition-colors motion-reduce:transition-none',
},
};
const SUPPORTED_CHAINS = [
mainnet,
goerli,
sepolia,
polygon,
polygonMumbai,
bsc,
bscTestnet,
arbitrum,
arbitrumGoerli,
optimism,
optimismGoerli,
base,
baseSepolia,
] as const;
function getChainById(chainId: number) {
return SUPPORTED_CHAINS.find((c) => c.id === chainId);
}
export function getBlockExplorerUrl(chainId: number): string {
const chain = getChainById(chainId);
return chain?.blockExplorers?.default?.url || 'https://etherscan.io';
}
export interface FarcasterUser {
fid: number;
signerUUID: string;
username: string;
displayName: string;
verifiedAddresses: {
ethAddresses: string[];
solAddresses: string[];
};
currentAddress: string;
}
export type FarcasterContainerProps = {
chain: number;
scriptURI: string;
adapter: ActionAdapter
};
export const SCRIPT_URI_ABI = [{
inputs: [],
name: "scriptURI",
outputs: [
{
internalType: "string[]",
name: "",
type: "string[]",
},
],
stateMutability: "view",
type: "function",
}]
export class SimpleActionComponent extends AbstractActionComponent {
constructor(parent: Action, label: string, href: string, parameters?: TypedActionParameter[]) {
super(parent, label, href, parameters);
}
public get href(): string {
return this._href;
}
protected buildBody(account: string): ActionPostRequest {
return {
account,
};
}
}
export const TS_VIEWER_URL = "https://viewer.tokenscript.org/";