UNPKG

@bridgesplit/rwa-token-sdk

Version:

RWA Token SDK for the development of permissioned tokens on SVM blockchains.

48 lines 3.17 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getExtraMetasListPda = exports.getPolicyEnginerEventAuthority = exports.getTrackerAccountPda = exports.getPolicyAccountPda = exports.getPolicyEnginePda = exports.getPolicyEngineProgram = exports.policyEngineProgramId = void 0; const anchor_1 = require("@coral-xyz/anchor"); const idls_1 = require("../programs/idls"); const web3_js_1 = require("@solana/web3.js"); const bytes_1 = require("@coral-xyz/anchor/dist/cjs/utils/bytes"); /** Program address for the policy engine program. */ exports.policyEngineProgramId = new web3_js_1.PublicKey("po1cPf1eyUJJPqULw4so3T4JU9pdFn83CDyuLEKFAau"); /** * Returns the policy engine program as a typed anchor program. * @param provider - Solana anchor provider. * @returns Typed solana program to be used for transaction building. */ const getPolicyEngineProgram = (provider) => new anchor_1.Program(idls_1.PolicyEngineIdl, provider); exports.getPolicyEngineProgram = getPolicyEngineProgram; /** * Retrieves the policy engine pda account for a specific asset mint. * @param assetMint - The string representation of the asset's mint address. * @returns The policy engines pda. */ const getPolicyEnginePda = (assetMint) => web3_js_1.PublicKey.findProgramAddressSync([new web3_js_1.PublicKey(assetMint).toBuffer()], exports.policyEngineProgramId)[0]; exports.getPolicyEnginePda = getPolicyEnginePda; /** * Retrieves the policy account pda for a specific asset mint. * @param assetMint - The string representation of the asset's mint address. * @returns The policy accounts pda. */ const getPolicyAccountPda = (assetMint) => web3_js_1.PublicKey.findProgramAddressSync([(0, exports.getPolicyEnginePda)(assetMint).toBuffer()], exports.policyEngineProgramId)[0]; exports.getPolicyAccountPda = getPolicyAccountPda; /** * Retrieves the tracker pda for a specific asset controller mint and owner. * @param assetMint - The string representation of the asset's mint address. * @param owner - The string representation of asset's owner. * @returns The asset controller's tracker pda. */ const getTrackerAccountPda = (assetMint, owner) => web3_js_1.PublicKey.findProgramAddressSync([new web3_js_1.PublicKey(assetMint).toBuffer(), new web3_js_1.PublicKey(owner).toBuffer()], exports.policyEngineProgramId)[0]; exports.getTrackerAccountPda = getTrackerAccountPda; const getPolicyEnginerEventAuthority = () => web3_js_1.PublicKey.findProgramAddressSync([anchor_1.utils.bytes.utf8.encode("__event_authority")], exports.policyEngineProgramId)[0]; exports.getPolicyEnginerEventAuthority = getPolicyEnginerEventAuthority; /** * Retrieves the asset controller's metadata pda account for a specific asset mint. * @param assetMint - The string representation of the asset's mint address. * @returns The asset controller's extra metadata pda. */ const getExtraMetasListPda = (assetMint) => web3_js_1.PublicKey.findProgramAddressSync([bytes_1.utf8.encode("extra-account-metas"), new web3_js_1.PublicKey(assetMint).toBuffer()], exports.policyEngineProgramId)[0]; exports.getExtraMetasListPda = getExtraMetasListPda; //# sourceMappingURL=utils.js.map