-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: add createVC RPC method (#141)
* feat: update types * feat: add createVC RPC method * fix: add bip44CoinTypeNode * test: add params tests * chore: fix tests * feat: add createVC to connector * fix: wrong return type * fix: pr feedback * chore: move queryVCsRequestResult[] type in test * fix: change it.todo in tests * chore: update remaining snaps packages to 0.28 * fix: add patch for snaps-types --------- Co-authored-by: martines3000 <domajnko.martin@gmail.com>
- Loading branch information
Showing
18 changed files
with
1,638 additions
and
800 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { CreateVCRequestParams } from '@blockchain-lab-um/ssi-snap-types'; | ||
import { copyable, divider, heading, panel, text } from '@metamask/snaps-ui'; | ||
import { VerifiableCredential } from '@veramo/core'; | ||
import { ApiParams } from 'src/interfaces'; | ||
|
||
import { snapConfirm } from '../../utils/snapUtils'; | ||
import { veramoCreateVC, veramoSaveVC } from '../../utils/veramoUtils'; | ||
|
||
export async function createVC( | ||
params: ApiParams, | ||
createVCParams: CreateVCRequestParams | ||
): Promise<VerifiableCredential> { | ||
const { minimalUnsignedCredential, proofFormat, options } = createVCParams; | ||
|
||
const { store = 'snap' } = options || {}; | ||
const { save } = options || {}; | ||
|
||
const vc = await veramoCreateVC(params, { | ||
minimalUnsignedCredential, | ||
proofFormat, | ||
options, | ||
}); | ||
if (save === true) { | ||
const content = panel([ | ||
heading('Save VC'), | ||
text('Would you like to save the following VC?'), | ||
divider(), | ||
text(`Store(s): ${typeof store === 'string' ? store : store.join(', ')}`), | ||
text(`VC:`), | ||
copyable(JSON.stringify(vc, null, 2)), | ||
]); | ||
|
||
if (await snapConfirm(snap, content)) { | ||
await veramoSaveVC({ | ||
snap: params.snap, | ||
ethereum: params.ethereum, | ||
verifiableCredential: vc, | ||
store, | ||
}); | ||
} | ||
} | ||
|
||
return vc; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.