modules/assets.AssetsService
Service responsible for handling the asset creation and management. See more information about assets in IAM stack here.
const { connectToCacheServer } = await initWithPrivateKeySigner(privateKey, rpcUrl);
const { assetsService } = await connectToCacheServer();
assetsService.registerAsset();
- acceptAssetOffer
- cancelAssetOffer
- getAssetById
- getAssetHistory
- getAssetOwner
- getOfferedAssets
- getOwnedAssets
- getPreviouslyOwnedAssets
- init
- offerAsset
- registerAsset
- rejectAssetOffer
- create
• new AssetsService(_signerService
, _cacheClient
): AssetsService
Name | Type |
---|---|
_signerService |
SignerService |
_cacheClient |
CacheClient |
▸ acceptAssetOffer(options
): Promise
<void
>
Accept an offered asset.
assetsService.acceptAssetOffer({
assetDID: 'did:ethr:volta:0x000...1',
});
Name | Type | Description |
---|---|---|
options |
AcceptAssetOfferOptions |
object containing options |
Promise
<void
>
▸ cancelAssetOffer(options
): Promise
<void
>
Cancel an asset offer.
assetsService.cancelAssetOffer({
assetDID: 'did:ethr:volta:0x000...1',
});
Name | Type | Description |
---|---|---|
options |
CancelAssetOfferOptions |
object containing options |
Promise
<void
>
▸ getAssetById(options
): Promise
<Asset
>
Retrieve asset by id.
assetsService.getAssetById({
id: 'did:ethr:volta:0x000...1',
});
Name | Type | Description |
---|---|---|
options |
GetAssetByIdOptions |
object containing options |
Promise
<Asset
>
asset
▸ getAssetHistory(options
): Promise
<AssetHistory
[]>
Retrieve history of a given asset DID
assetsService.getAssetHistory({
id: 'did:ethr:volta:0x000...1',
order: Order.ASC,
take: 5,
skip: 0,
type: AssetHistoryEventType.ASSET_OFFERED,
});
Name | Type | Description |
---|---|---|
options |
GetAssetHistoryOptions |
object containing options |
Promise
<AssetHistory
[]>
asset history
▸ getAssetOwner(id
): Promise
<string
>
Retrieve DID of the asset owner of the given asset DID.
assetsService.getAssetOwner('did:ethr:volta:0x000...1');
Name | Type | Description |
---|---|---|
id |
string |
DID of the asset |
Promise
<string
>
asset owner DID
▸ getOfferedAssets(options?
): Promise
<Asset
[]>
Retrieve assets offered to the given user.
assetsService.getOfferedAssets({
did: 'did:ethr:volta:0x000...1',
});
Name | Type | Description |
---|---|---|
options |
GetOfferedAssetsOptions |
object containing options |
Promise
<Asset
[]>
offered assets
▸ getOwnedAssets(options?
): Promise
<Asset
[]>
Retrieve owned assets of the given user.
assetsService.getOwnedAssets({
did: 'did:ethr:volta:0x000...1',
});
Name | Type | Description |
---|---|---|
options |
GetOwnedAssetsOptions |
object containing options |
Promise
<Asset
[]>
owned assets
▸ getPreviouslyOwnedAssets(options
): Promise
<Asset
[]>
Retrieve previously owned assets of the given user.
assetsService.getPreviouslyOwnedAssets({
owner: 'did:ethr:volta:0x000...1',
});
Name | Type | Description |
---|---|---|
options |
GetPreviouslyOwnedAssetsOptions |
object containing options |
Promise
<Asset
[]>
previously owned assets
▸ init(): Promise
<void
>
Promise
<void
>
▸ offerAsset(options
): Promise
<void
>
Send an asset offer transfer to a given address
assetsService.offerAsset({
assetDID: 'did:ethr:volta:0x000...1',
offerTo: '0x000...2',
});
Name | Type | Description |
---|---|---|
options |
OfferAssetOptions |
object containing options |
Promise
<void
>
▸ registerAsset(): Promise
<string
>
Register a new asset to the user.
assetsService.registerAsset();
Promise
<string
>
asset address
▸ rejectAssetOffer(options
): Promise
<void
>
Reject an offered asset.
assetsService.rejectAssetOffer({
assetDID: 'did:ethr:volta:0x000...1',
});
Name | Type | Description |
---|---|---|
options |
RejectAssetOfferOptions |
object containing options |
Promise
<void
>
▸ create(signerService
, cacheClient
): Promise
<AssetsService
>
Name | Type |
---|---|
signerService |
SignerService |
cacheClient |
CacheClient |
Promise
<AssetsService
>