Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Metadata registration during contract deploy #1346

Merged
merged 3 commits into from
Oct 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions packages/celotool/src/cmds/deploy/initial/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,9 @@ async function makeMetadata(testnet: string, address: string, index: number) {
const fileName = `validator-${testnet}-${address}-metadata.json`
const filePath = `/tmp/${fileName}`

const metadata = new IdentityMetadataWrapper(IdentityMetadataWrapper.emptyData)
const metadata = IdentityMetadataWrapper.fromEmpty()
metadata.addClaim(nameClaim)
metadata.addClaim(attestationServiceClaim)

writeFileSync(filePath, metadata.toString())

await uploadFileToGoogleStorage(
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/identity/create-metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export default class CreateMetadata extends BaseCommand {

async run() {
const { args } = this.parse(CreateMetadata)
const metadata = new IdentityMetadataWrapper(IdentityMetadataWrapper.emptyData)
const metadata = new IdentityMetadataWrapper(IdentityMetadataWrapper.fromEmpty())
writeFileSync(args.file, metadata.toString())
}
}
6 changes: 4 additions & 2 deletions packages/contractkit/src/identity/metadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ const isOfType = <K extends ClaimTypes>(type: K) => (
export class IdentityMetadataWrapper {
data: IdentityMetadata

static emptyData: IdentityMetadata = {
claims: [],
static fromEmpty() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

good catch

return new IdentityMetadataWrapper({
claims: [],
})
}

static async fetchFromURL(url: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/utils/src/async.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export async function concurrentMap<A, B>(
const remaining = xs.length - i
const sliceSize = Math.min(remaining, concurrency)
const slice = xs.slice(i, i + sliceSize)
res = res.concat(await Promise.all(slice.map(mapFn)))
res = res.concat(await Promise.all(slice.map((elem, index) => mapFn(elem, i + index))))
}
return res
}