Skip to content

Commit 759492f

Browse files
author
Tasos Bitsios
committed
contract/sdk/client: change label (name, url)
1 parent 1bce985 commit 759492f

File tree

12 files changed

+4687
-3346
lines changed

12 files changed

+4687
-3346
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { abel } from "./lib/config.js";
2+
import { parseArgs } from "./lib/util.js";
3+
import { wrapAction } from "./lib/wrap-action.js";
4+
5+
wrapAction("(admin) Change label (id, name, url)", parseArgs(String, String, String), abel.changeLabel);

projects/abel-sdk-v2/artifacts/AssetLabeling.arc32.json

Lines changed: 27 additions & 1 deletion
Large diffs are not rendered by default.

projects/abel-sdk-v2/src/generated/abel-contract-client.ts

Lines changed: 74 additions & 1 deletion
Large diffs are not rendered by default.

projects/abel-sdk-v2/src/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import {
2525
LabelDescriptorFromTuple as LabelDescriptorBoxValueFromTuple,
2626
} from "./generated/abel-contract-client.js";
2727
import { AnyFn, FirstArgument, LabelDescriptor, QueryReturn } from "./types.js";
28-
import { chunk, encodeUint64Arr, mergeMapsArr, wrapErrors } from "./util.js";
28+
import { chunk, encodeUint64Arr, isNullish, mergeMapsArr, wrapErrors } from "./util.js";
2929

3030
export * from "./types.js";
3131
export { AssetLabelingClient, AssetLabelingFactory };
@@ -240,6 +240,20 @@ export class AbelSDK {
240240
return wrapErrors(query);
241241
}
242242

243+
async changeLabel(labelId: string, name: string, url: string) {
244+
this.requireWriteClient();
245+
246+
if (isNullish(name)) throw new Error("name must be defined");
247+
if (isNullish(url)) throw new Error("url must be defined");
248+
249+
const query = this.writeClient
250+
.newGroup()
251+
.changeLabel({ args: { id: labelId, name, url }, boxReferences: [labelId] })
252+
.send();
253+
254+
return wrapErrors(query);
255+
}
256+
243257
async removeLabel(labelId: string) {
244258
this.requireWriteClient();
245259

projects/abel-sdk-v2/src/util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,7 @@ export function mergeMapsArr<K, V>(maps: Map<K, V>[]): Map<K, V> {
6262

6363
return mergedMap;
6464
}
65+
66+
export function isNullish(str: string) {
67+
return str === undefined || str === null
68+
}

projects/asset_labeling-contracts/smart_contracts/artifacts/asset_labeling/AssetLabeling.approval.puya.map

Lines changed: 3740 additions & 2817 deletions
Large diffs are not rendered by default.

projects/asset_labeling-contracts/smart_contracts/artifacts/asset_labeling/AssetLabeling.approval.teal

Lines changed: 504 additions & 378 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)