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

feat: archive/extract api for delegations #287

Merged
merged 6 commits into from
May 2, 2023

Conversation

Gozala
Copy link
Collaborator

@Gozala Gozala commented Apr 18, 2023

For the workshop I have end up implementing these methods so we could archive ucan chains into bytes and extract them back. This pr adds them to the into the ucanto

const variant = await CBOR.write({
[`ucan@${delegation.version}`]: delegation.root.cid,
})
store.set(`${variant.cid}`, variant)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like in CAR.encode the root blocks are included (i.e. I think you might get the root block twice in the encoded CAR).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

No you won't and I plan on changing CAR codec so that roots are no longer blocks but rather CIDs. Current approach of roots been blocks are kind of falling apart if you get a car from someone that has a root that isn't inside the car

}

export const ArchiveSchema = Schema.variant({
'ucan@0.9.1': /** @type {Schema.Schema<API.UCANLink>} */ (
Copy link
Member

Choose a reason for hiding this comment

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

Should this version number be a constant somewhere?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It is the UCAN.VERSION, however at some point we'll probably upgrade it to next version, yet version here should remain the same. I'm not sure there is a value in defining a new constant somewhere if this is the only thing referring to it though.

packages/core/src/delegation.js Outdated Show resolved Hide resolved
@Gozala Gozala requested review from alanshaw and travis April 28, 2023 21:53
Copy link
Contributor

@vasco-santos vasco-santos left a comment

Choose a reason for hiding this comment

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

LGTM

@Gozala Gozala merged commit 75036c1 into main May 2, 2023
@github-actions github-actions bot mentioned this pull request May 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants