Skip to content

Commit

Permalink
Removed errors
Browse files Browse the repository at this point in the history
Signed-off-by: vikastc <vikas.tc@dhiway.com>
  • Loading branch information
Vikastc committed Oct 4, 2023
1 parent 8655129 commit 7784058
Show file tree
Hide file tree
Showing 7 changed files with 907 additions and 1,053 deletions.
2 changes: 1 addition & 1 deletion demo/src/utils/generateDid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Cord from '@cord.network/sdk'
import { mnemonicGenerate } from '@polkadot/util-crypto'
import { generateKeypairs } from './generateKeypairs'
import { hexToU8a } from '@polkadot/util'
import { cord_api_query } from '@cord.network/utils'
import { cord_api_query } from '@cord.network/config'

/**
* It creates a DID on chain, and returns the mnemonic and DID document
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
"typedoc": "^0.23.0",
"typescript": "^4.8.3"
},
"version": "0.8.1-beta.6",
"version": "0.9.0-1",
"packageManager": "yarn@3.3.1",
"dependencies": {
"node-fetch": "^3.3.1"
Expand Down
2 changes: 1 addition & 1 deletion packages/config/src/helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import fetch from 'node-fetch'
import * as ConfigService from './ConfigService';
import * as ConfigService from './ConfigService'
import type { SubmittableExtrinsic } from '@cord.network/types'

export async function cord_api_query(
Expand Down
50 changes: 25 additions & 25 deletions packages/did/src/Did.rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,31 +164,28 @@ export function linkedInfoFromChain(
}

interface PalletDidDidDetailsApi extends Struct {
readonly authenticationKey: string;
readonly keyAgreementKeys: string;
readonly delegationKey: string | undefined;
readonly assertionKey: string | undefined;
readonly publicKeys: any; /* todo */
readonly lastTxCounter: number;
readonly authenticationKey: string
readonly keyAgreementKeys: string
readonly delegationKey: string | undefined
readonly assertionKey: string | undefined
readonly publicKeys: any /* todo */
readonly lastTxCounter: number
}

interface PalletDidServiceEndpointsApi extends Struct {
readonly id: string;
readonly serviceTypes: string[];
readonly urls: string[];
readonly id: string
readonly serviceTypes: string[]
readonly urls: string[]
}

function didPublicKeyDetailsFromApi(
keyId: string,
keyDetails: any
): DidKey {
const key = keyDetails.key.publicVerificationKey
function didPublicKeyDetailsFromApi(keyId: string, keyDetails: any): DidKey {
const key = keyDetails.key.publicVerificationKey
? keyDetails.key.publicVerificationKey
: keyDetails.key.publicEncryptionKey
return {
id: `#${keyId}`,
type: Object.keys(key)[0].toLowerCase() as DidKey['type'],
publicKey: hexToU8a(Object.entries(key)[0][1] as HexString)
publicKey: hexToU8a(Object.entries(key)[0][1] as HexString),
}
}

Expand All @@ -206,7 +203,10 @@ function documentFromApi(encoded: AnyJson): RpcDocument {

const keys: Record<string, DidKey> = [...Object.entries(publicKeys)]
.map(([keyId, keyDetails]) =>
didPublicKeyDetailsFromApi(keyId, (keyDetails as unknown) as PalletDidDidDetailsDidPublicKeyDetails)
didPublicKeyDetailsFromApi(
keyId,
keyDetails as unknown as PalletDidDidDetailsDidPublicKeyDetails
)
)
.reduce((res, key) => {
res[resourceIdToChain(key.id)] = key
Expand Down Expand Up @@ -250,17 +250,14 @@ function serviceFromApi(
}
}

function servicesFromApi(
encoded: AnyJson
): DidServiceEndpoint[] {
const e: PalletDidServiceEndpointsApi[] = encoded as unknown as PalletDidServiceEndpointsApi[]
function servicesFromApi(encoded: AnyJson): DidServiceEndpoint[] {
const e: PalletDidServiceEndpointsApi[] =
encoded as unknown as PalletDidServiceEndpointsApi[]
return e.map((encodedValue) => serviceFromApi(encodedValue))
}

export function linkedInfoFromApi(
encoded: Record<string, AnyJson>
): DidInfo {
const { identifier, name, serviceEndpoints, details } = encoded
export function linkedInfoFromApi(encoded: Record<string, AnyJson>): DidInfo {
const { identifier, account, name, serviceEndpoints, details } = encoded
const didRec = documentFromApi(details)
const did: DidDocument = {
uri: fromChain(identifier as string),
Expand All @@ -275,8 +272,11 @@ export function linkedInfoFromApi(
did.service = service
}

const DidAccount = account

return {
document: did,
didName: name ? name as string : undefined,
account: DidAccount as DidAccount,
didName: name ? (name as string) : undefined,
}
}
12 changes: 6 additions & 6 deletions packages/did/src/DidResolver/DidResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ export async function resolve(
encodedDid = await cord_api_query('did', 'query', did)

if (!encodedDid || !encodedDid.response) {
const queryFunction = api.call.did?.query
const { section, version } = queryFunction?.meta ?? {}
if (version > 2)
throw new Error(
`This version of the sdk supports runtime api '${section}' <=v2 , but the blockchain runtime implements ${version}. Please upgrade!`
)
const queryFunction = api.call.didApi?.query
// const { section, version } = queryFunction ?? {}
// if (version > 2)
// throw new Error(
// `This version of the sdk supports runtime api '${section}' <=v2 , but the blockchain runtime implements ${version}. Please upgrade!`
// )

encodedDid = await queryFunction(toChain(did))
.then(linkedInfoFromChain)
Expand Down
2 changes: 1 addition & 1 deletion packages/network/src/chain/Chain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ export async function signAndSubmitTx(
tx: SubmittableExtrinsic,
signer: KeyringPair,
{
nonce = -1,
tip,
...opts
}: Partial<SubscriptionPromise.Options> & Partial<{ tip: AnyNumber }> = {}
): Promise<any> {
Expand Down
Loading

0 comments on commit 7784058

Please sign in to comment.