@bridgesplit/rwa-token-sdk
Version:
RWA Token SDK for the development of permissioned tokens on SVM blockchains.
64 lines • 2.8 kB
JavaScript
;
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());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.PolicyEngine = void 0;
const policy_engine_1 = require("../policy-engine");
/**
* Represents the client Policy Engine for an RWA.
*/
class PolicyEngine {
constructor(rwaClient) {
this.rwaClient = rwaClient;
}
/**
* Asynchronously create a policy account to assets.
* @param - {@link AttachPolicyArgs}
* @returns A Promise that resolves to the instructions to attach a policy.
* */
createPolicy(policyArgs) {
return __awaiter(this, void 0, void 0, function* () {
const createPolicyIx = yield (0, policy_engine_1.getCreatePolicyAccountIx)(policyArgs, this.rwaClient.provider);
return createPolicyIx;
});
}
/**
* Asynchronously attaches a policy to the policy account.
* @param - {@link AttachPolicyArgs}
* @returns A Promise that resolves to the instructions to attach a policy.
* */
attachPolicy(policyArgs) {
return __awaiter(this, void 0, void 0, function* () {
const attachPolicyIx = yield (0, policy_engine_1.getAttachToPolicyAccountIx)(policyArgs, this.rwaClient.provider);
return attachPolicyIx;
});
}
/**
* Asynchronously detaches a policy to the policy account.
* @param - {@link DetachPolicyArgs}
* @returns A Promise that resolves to the instructions to detach a policy.
* */
detachPolicy(policyArgs) {
return __awaiter(this, void 0, void 0, function* () {
const attachPolicyIx = yield (0, policy_engine_1.getDetachFromPolicyAccountIx)(policyArgs, this.rwaClient.provider);
return attachPolicyIx;
});
}
/**
* Retrieves the policy registry pda account for a specific asset mint.
* @param assetMint - The string representation of the asset's mint address.
* @returns The policy registry pda as a public key.
*/
getPolicyEnginePda(assetMint) {
return (0, policy_engine_1.getPolicyEnginePda)(assetMint);
}
}
exports.PolicyEngine = PolicyEngine;
//# sourceMappingURL=PolicyEngine.js.map