Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

Commit

Permalink
feat: move devUser to createDevUsers
Browse files Browse the repository at this point in the history
  • Loading branch information
kratico committed Jun 14, 2023
1 parent c9f0643 commit 4b44f1b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion _tasks/generate_artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as $ from "../deps/scale.ts"
import { emptyDir } from "../deps/std/fs.ts"
import * as path from "../deps/std/path.ts"
import dprintConfig from "../dprint.json" assert { type: "json" }
import { devUser } from "../nets/chain_spec/addDevUsers.ts"
import { devUser } from "../mod.ts"
import { compress } from "../util/compression.ts"

export const DEV_USER_COUNT = 10_000
Expand Down
6 changes: 1 addition & 5 deletions nets/chain_spec/addDevUsers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { blake2_512, Sr25519, ss58 } from "../../crypto/mod.ts"
import { ss58 } from "../../crypto/mod.ts"
import * as $ from "../../deps/scale.ts"
import { devUserPublicKeysData } from "../../util/_artifacts/devUserPublicKeysData.ts"
import { GenesisConfig } from "./ChainSpec.ts"
Expand All @@ -15,7 +15,3 @@ export function addDevUsers(genesisConfig: GenesisConfig) {
balances.push([ss58.encode(networkPrefix, publicKey), devUserInitialFunds])
}
}

export function devUser(userId: number) {
return Sr25519.fromSeed64(blake2_512.hash(new TextEncoder().encode(`capi-dev-user-${userId}`)))
}
7 changes: 5 additions & 2 deletions server/client/createDevUsers.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import { Sr25519 } from "../../crypto/mod.ts"
import { devUser } from "../../nets/mod.ts"
import { blake2_512, Sr25519 } from "../../crypto/mod.ts"
import { ArrayOfLength } from "../../util/ArrayOfLength.ts"
import { detectServer } from "./detectServer.ts"

export function devUser(userId: number) {
return Sr25519.fromSeed64(blake2_512.hash(new TextEncoder().encode(`capi-dev-user-${userId}`)))
}

export function createDevUsers(): Promise<Record<typeof devUserNames[number], Sr25519>>
export function createDevUsers<N extends number>(count: N): Promise<ArrayOfLength<Sr25519, N>>
export async function createDevUsers(count?: number): Promise<Record<string, Sr25519> | Sr25519[]> {
Expand Down

0 comments on commit 4b44f1b

Please sign in to comment.