-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Blob
module for Cheqd
, improvements for DIDDocument
and misc tw…
…eaks (#459) * `CheqdBlobModule` + tweaks * Lints * Bump up versions * Tweaks * Corrections * Reenable other tests * Fix arguments * `withDidNonce` * Tweak * Make `withDidNonce` non-async function * `await`
- Loading branch information
Showing
82 changed files
with
1,366 additions
and
657 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
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,41 @@ | ||
import { | ||
Blob, | ||
CheqdBlobId, | ||
CheqdBlobWithId, | ||
CheqdDid, | ||
} from '@docknetwork/credential-sdk/types'; | ||
import { option } from '@docknetwork/credential-sdk/types/generic'; | ||
import { CheqdCreateResource, createInternalCheqdModule } from '../common'; | ||
|
||
const methods = { | ||
new: (blobWithId) => { | ||
const { blob, id } = CheqdBlobWithId.from(blobWithId); | ||
const [did, uuid] = id; | ||
|
||
return new CheqdCreateResource( | ||
CheqdDid.from(did).value, | ||
uuid, | ||
'1.0', | ||
[], | ||
'Blob', | ||
'blob', | ||
blob, | ||
); | ||
}, | ||
}; | ||
|
||
export default class CheqdInternalBlobModule extends createInternalCheqdModule( | ||
methods, | ||
) { | ||
static Prop = 'resource'; | ||
|
||
static MsgNames = { | ||
new: 'MsgCreateResource', | ||
}; | ||
|
||
async blob(blobId) { | ||
return option(Blob).from( | ||
(await this.resource(...CheqdBlobId.from(blobId)))?.resource?.data, | ||
); | ||
} | ||
} |
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,25 @@ | ||
import AbstractBlobModule from '@docknetwork/credential-sdk/modules/blob/module'; | ||
import { NoBlobError } from '@docknetwork/credential-sdk/modules/blob/errors'; | ||
import { CheqdBlobId } from '@docknetwork/credential-sdk/types'; | ||
import { injectCheqd } from '../common'; | ||
import CheqdInternalBlobModule from './internal'; | ||
import { OwnerWithBlob } from './types'; | ||
|
||
export default class CheqdBlobModule extends injectCheqd(AbstractBlobModule) { | ||
static CheqdOnly = CheqdInternalBlobModule; | ||
|
||
async newTx(blobWithId, targetDid, didKeypair) { | ||
return await this.cheqdOnly.tx.new(blobWithId, targetDid, didKeypair); | ||
} | ||
|
||
async get(blobId) { | ||
const id = CheqdBlobId.from(blobId); | ||
const blob = await this.cheqdOnly.blob(id); | ||
|
||
if (blob == null) { | ||
throw new NoBlobError(id); | ||
} | ||
|
||
return new OwnerWithBlob(id[0], blob); | ||
} | ||
} |
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,6 @@ | ||
import { CheqdDid, Blob } from '@docknetwork/credential-sdk/types'; | ||
import { TypedTuple } from '@docknetwork/credential-sdk/types/generic'; | ||
|
||
export class OwnerWithBlob extends TypedTuple { | ||
static Classes = [CheqdDid, Blob]; | ||
} |
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
Oops, something went wrong.