---
# System prepended metadata

title: Functional object config approach

---




```typescript=
interface lifecycle {
  error?: Error;
  event?: any;
  transactionHash?: TransactionHash;
  signature?: string;
  batch?: []
}

interface IdentityConfig {
  did: DidDocument;
  api: ApiPromse;
  transactionStratergy: Submitter | SignerInterface;
  lifecycle: lifecycle;
}

interface DidDocument {
  id: Did;
  alsoKnownAs?: string[];
  verificationMethod?: VerificationMethod[];
  authentication?: UriFragment[];
  assertionMethod?: UriFragment[];
  keyAgreement?: UriFragment[];
  capabilityDelegation?: UriFragment[];
  service?: Service[];
}
```



```typescript=
function generateConfig(
  did: DidDocument,
  api: ApiPromise,
  transactionStrategy: Submitter | SignerInterface
): IdentityConfig {
  return {
    did,
    api,
    transactionStrategy,
  };
}

const identityConfig = generateConfig(keys, api, transactionStrategy);
```




```typescript=
function createDid(identityConfig: IdentityConfig): IdentityConfig {
  // Logic goes here.
  newDid
  if (did) did = identityConfig.did;
  return {...identityConfig, identityConfig.did: newDid};
}
```


```typescript=
function resolve(identityConfig: IdentityConfig): IdentityConfig {
  // Logic goes here.
  if (resolved)
    identityConfig.lifecycle.event = identityConfig.lifecycle.event.completed;
  return {...identityConfig, identityConfig.lifecycle.event.completed};
}
```


```typescript=
function updateDid(identityConfig: IdentityConfig): IdentityConfig {
  // Logic goes here.
  //   if ()
  return {...identityConfig, identityConfig.lifecycle.event.completed};
}
```


```typescript=
function setKeys(identityConfig: IdentityConfig, verificationMethod: string): IdentityConfig {
  // Logic goes here.
  //   if ()
  return {...identityConfig, identityConfig.lifecycle.event.completed};
}
```


```typescript=
function deleteDid(identityConfig: IdentityConfig): IdentityConfig {
  // Logic goes here.
  //   if ()
  return {...identityConfig, identityConfig.lifecycle.event.false};
}
```


```typescript=
function deleteKey(identityConfig: IdentityConfig): IdentityConfig {
  // Logic goes here.
  //   if ()
  return {...identityConfig, identityConfig.lifecycle.event.true};;
}
```

```typescript=
function batch(
  identityConfig: IdentityConfig,
): IdentityConfig {
  // Logic goes here.
  // if ()
  return {identityConfig.lifecycle};
}
```


```typescript=
function signData(identityConfig: IdentityConfig, data: any): IdentityConfig {
  // Logic goes here.
  //   if ()
  return {...identityConfig, identityConfig.lifecycle.signature};
}
```


```typescript=
function signExtrinsic(
  identityConfig: IdentityConfig,
  data: any,
  extrinsicName: 'claimWeb3name' | 'whatever'
): IdentityConfig {
  // Logic goes here.
  //   if ()
  return identityConfig.lifecycle.event.signature;
}
```


```typescript=
function signPresentation(
  identityConfig: IdentityConfig,
  data: any
): IdentityConfig {
  // Logic goes here.
  //   if ()
  return identityConfig.lifecycle.event.signature;
}
```


```typescript=
function verifySignature(
  identityConfig: IdentityConfig,
  data: any,
  signature: string
): IdentityConfig {
  // Logic goes here.
  // if ()
  return identityConfig.lifecycle.event.false;
}
```
