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 type error in createDelegation within JS client #1250

Closed
salieflewis opened this issue Jan 4, 2024 · 1 comment
Closed

Fix type error in createDelegation within JS client #1250

salieflewis opened this issue Jan 4, 2024 · 1 comment
Assignees

Comments

@salieflewis
Copy link

When implementing the following lines of code as shown in the Delegated example, typescript complains the type of the abilities string array does not match with the expected type.

const abilities = ['upload/add', 'store/add']
const delegation = await client.createDelegation(audience, abilities)

cc: @travis

@travis travis self-assigned this Jan 4, 2024
travis added a commit that referenced this issue Jan 8, 2024
Given a list of strings representing capability names (Abilities), verify that all the strings are valid Abilities and return Abilities[].

Abilities[] is still just a list of strings, but this helps us play nice with Typescript.

Inspired by #1250
travis added a commit that referenced this issue Jan 11, 2024
Given a list of strings representing capability names (`ServiceAbility`s),
verify that all the strings are valid `ServiceAbility`s and return
`ServiceAbility[]`.

`ServiceAbility[]` is still just a list of strings, but this helps us play
nice with Typescript.

Inspired by #1250
@alanshaw
Copy link
Member

@salieflewis you should be able to do this now to resolve those type errors:

import { asAbilities } from '@web3-storage/w3up-client'

const abilities = asAbilities(['upload/add', 'store/add'])
const delegation = await client.createDelegation(audience, abilities)

Shout if you find it not working properly.

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

No branches or pull requests

3 participants