-
Notifications
You must be signed in to change notification settings - Fork 0
/
editTA.ts
32 lines (26 loc) · 1.29 KB
/
editTA.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { Nautilus, AssetBuilder, ServiceBuilder } from '@deltadao/nautilus'
export async function editTrustedAlgorithms(nautilus: Nautilus, did: string, trustedAlgorithms: string[], trustedPublishers: string[]){
try{
const aquariusAsset = await nautilus.getAquariusAsset(did);
const assetBuilder = new AssetBuilder(aquariusAsset);
const serviceBuilder = new ServiceBuilder({ aquariusAsset, serviceId: aquariusAsset.services[0].id });
// Updating trusted publishers on a service
if (trustedPublishers.length > 0) {
for(const publisher of trustedPublishers){
serviceBuilder.addTrustedAlgorithmPublisher(publisher);
}
}
// Updating trusted algorithms on a service
if (trustedAlgorithms.length > 0) {
serviceBuilder.addTrustedAlgorithms(trustedAlgorithms.map(algo => ({ did: algo })));
}
const service = serviceBuilder.build();
const asset = assetBuilder.addService(service).build();
const result = await nautilus.edit(asset);
console.log('Edited trusted algorithms:', result)
return result;
} catch(err) {
console.log("Error: This Error occured during the whitelisting-process: ");
console.log(err);
}
}