-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathstakeDeRegistration.ts
More file actions
42 lines (40 loc) · 1.21 KB
/
stakeDeRegistration.ts
File metadata and controls
42 lines (40 loc) · 1.21 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
import { FunctionContext } from '../executor/BaseFunction'
import { FunctionSchemaSpec } from '../utils/functionSchema'
export const schema: FunctionSchemaSpec = {
id: 'stakeDeRegistration',
name: 'Stake De-registration',
description: 'Deregister stake key for this agent (submit deregistration certificate).',
params: [],
response: {
type: 'object',
properties: {
cborHex: { type: 'string' },
description: { type: 'string' },
hash: { type: 'string' },
type: { type: 'string' },
},
response_text: 'Stake deregistration submitted: hash: ${result.hash}',
},
}
export default async function handler(context: FunctionContext) {
const req = {
inputs: context.wallet.address,
outputs: {
address: context.wallet.address,
value: '10A',
addChange: true,
},
certificates: [
{
type: 'deregisterstake',
key: context.wallet.stakeKey.pubKeyHash,
},
],
}
return await context.wallet
.buildAndSubmit(req, true)
.then((v) => v)
.catch((e) => {
throw e
})
}