-
Notifications
You must be signed in to change notification settings - Fork 349
Expand file tree
/
Copy pathbasic-gateway.ts
More file actions
30 lines (26 loc) · 1.08 KB
/
basic-gateway.ts
File metadata and controls
30 lines (26 loc) · 1.08 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
import { CcipReadRouter } from '@ensdomains/ccip-read-router'
const router = CcipReadRouter()
router.add({
type: 'function addr(bytes32 node) external view returns (address)',
handle: ([_node]) => {
// Always return the same address (registry.ens.eth)
return ['0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e' as const]
},
})
router.add({
type: 'function addr(bytes32 node, uint256 coinType) external view returns (bytes)',
handle: ([_node, _coinType]) => {
// Always return the same address (offchain.integration-tests.eth)
// https://github.com/ensdomains/resolution-tests
return ['0xeE9eeaAB0Bb7D9B969D701f6f8212609EDeA252E' as const]
},
})
export async function onRequestPost({ request }: { request: Request }) {
const body = await request.json()
const { body: ccipReadRes } = await router.call(body)
const response = Response.json(ccipReadRes)
response.headers.set('Access-Control-Allow-Origin', '*')
response.headers.set('Access-Control-Allow-Methods', 'POST, OPTIONS')
response.headers.set('Access-Control-Allow-Headers', 'Content-Type')
return response
}