-
Notifications
You must be signed in to change notification settings - Fork 5
/
index.ts
48 lines (43 loc) · 913 Bytes
/
index.ts
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
import {
WalkerImpl,
createTupleEncoder,
encodeStr,
decodeStr,
encodeU8,
decodeU8,
createVecEncoder,
createVecDecoder,
createTupleDecoder,
} from '@scale-codec/core'
type Tuple = [string, string, string, string, number[]]
const encodeS3Put = createTupleEncoder<Tuple>([
encodeStr,
encodeStr,
encodeStr,
encodeStr,
createVecEncoder(encodeU8),
])
const decodeS3Put = createTupleDecoder<Tuple>([
decodeStr,
decodeStr,
decodeStr,
decodeStr,
createVecDecoder(decodeU8),
])
const endpoint = 'endpoint'
const region = 'region'
const bucket = 'bucket'
const object_key = 'object_key'
const value = new Uint8Array(32)
export default function main() {
const bytes = WalkerImpl.encode([
endpoint,
region,
bucket,
object_key,
Array.from(value),
], encodeS3Put)
const decoded = WalkerImpl.decode(bytes, decodeS3Put)
console.info(decoded)
return bytes
}