Skip to content

Commit

Permalink
Make defaultValues uniform
Browse files Browse the repository at this point in the history
  • Loading branch information
ntn-x2 committed Apr 30, 2024
1 parent d2b2d2a commit 62dd07e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
14 changes: 7 additions & 7 deletions src/dipProof/extensions/timeBoundDidSignature.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import type { Option } from "@polkadot/types-codec"
import type { Codec } from "@polkadot/types-codec/types"

const defaultValues = {
accountIdRuntimeType: "AccountId",
blockNumberRuntimeType: "u64",
identityDetailsRuntimeType: "Option<u128>",
validUntilOffset: new BN(50),
accountIdRuntimeType: async () => "AccountId",
blockNumberRuntimeType: async () => "u64",
identityDetailsRuntimeType: async () => "Option<u128>",
validUntilOffset: async () => new BN(50),
}

/**
Expand Down Expand Up @@ -99,16 +99,16 @@ export async function generateTimeBoundDipDidSignature({
validUntil ??
(await api.query.system.number())
.toBn()
.add(defaultValues.validUntilOffset)
.add(await defaultValues.validUntilOffset())
const genesis = genesisHash ?? (await api.query.system.blockHash(0))
const actualIdentityDetailsRuntimeType = identityDetailsRuntimeType ?? defaultValues.identityDetailsRuntimeType
const actualIdentityDetailsRuntimeType = identityDetailsRuntimeType ?? await defaultValues.identityDetailsRuntimeType()
const identityDetails = (
await api.query.dipConsumer.identityEntries<Option<Codec>>(toChain(didUri))
).unwrapOr(api.createType(actualIdentityDetailsRuntimeType, null))

const signaturePayload = api
.createType(
`(Call, ${identityDetailsRuntimeType}, ${accountIdRuntimeType ?? defaultValues.accountIdRuntimeType}, ${blockNumberRuntimeType ?? defaultValues.blockNumberRuntimeType}, Hash)`,
`(Call, ${identityDetailsRuntimeType}, ${accountIdRuntimeType ?? await defaultValues.accountIdRuntimeType()}, ${blockNumberRuntimeType ?? await defaultValues.blockNumberRuntimeType()}, Hash)`,
[call, identityDetails, submitterAddress, blockNumber, genesis],
)
.toU8a()
Expand Down
8 changes: 4 additions & 4 deletions src/sibling.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ import type { Call } from "@polkadot/types/interfaces"
import type { Codec } from "@polkadot/types-codec/types"

const defaultValues = {
includeWeb3Name: () => false,
linkedAccounts: () => [],
includeWeb3Name: async () => false,
linkedAccounts: async () => [],
providerBlockHeight: async (providerApi: ApiPromise) => {
const providerLastFinalizedBlockHash =
await providerApi.rpc.chain.getFinalizedHead()
Expand Down Expand Up @@ -104,9 +104,9 @@ export async function generateDipSiblingBaseProof({
didUri,
providerApi,
keyIds,
linkedAccounts: linkedAccounts || defaultValues.linkedAccounts(),
linkedAccounts: linkedAccounts || await defaultValues.linkedAccounts(),
version: proofVersion,
includeWeb3Name: includeWeb3Name || defaultValues.includeWeb3Name(),
includeWeb3Name: includeWeb3Name || await defaultValues.includeWeb3Name(),
})

return {
Expand Down

0 comments on commit 62dd07e

Please sign in to comment.