UNPKG

@acurast/cli

Version:

A cli to interact with the Acurast Cloud.

47 lines 2.31 kB
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; import { AcurastService } from './env/acurastService.js'; import { getWallet } from '../util/getWallet.js'; /** * Transfers editor permissions for a mutable deployment * @param deploymentId - The deployment ID in format [MultiOrigin, address, number] * @param newEditor - The AccountId32 address of the new editor * @returns Promise<string> - The transaction hash */ export const transferEditor = (deploymentId, newEditor) => __awaiter(void 0, void 0, void 0, function* () { const acurast = new AcurastService(); const wallet = yield getWallet(); try { yield acurast.connect(); if (!acurast.api) { throw new Error('API not connected'); } // Convert the deploymentId to the format expected by the extrinsic // The extrinsic expects (AcurastCommonMultiOrigin, u128) where: // - AcurastCommonMultiOrigin is { acurast: AccountId32 } // - u128 is the deployment number const jobId = [ { acurast: deploymentId[1] }, // AcurastCommonMultiOrigin deploymentId[2], // u128 deployment number ]; // The newEditor parameter is an Option<AccountId32> // We wrap it in an Option structure const newEditorOption = { Some: newEditor }; // Call the extrinsic const tx = yield acurast.api.tx.acurastMarketplace.transferEditor(jobId, newEditorOption); const signedTx = yield tx.signAsync(wallet); const hash = yield signedTx.send(); return hash.toString(); } finally { yield acurast.disconnect(); } }); //# sourceMappingURL=transferEditor.js.map