UNPKG

contract-proxy-kit

Version:

Enable batched transactions and contract account interactions using a unique deterministic Gnosis Safe.

79 lines 2.97 kB
"use strict"; var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, privateMap, value) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to set private field on non-instance"); } privateMap.set(receiver, value); return value; }; var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, privateMap) { if (!privateMap.has(receiver)) { throw new TypeError("attempted to get private field on non-instance"); } return privateMap.get(receiver); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; var _appsSdk, _safeAddress, _isSafeApp; Object.defineProperty(exports, "__esModule", { value: true }); const safe_apps_sdk_1 = __importDefault(require("@gnosis.pm/safe-apps-sdk")); class SafeAppsSdkConnector { constructor() { _appsSdk.set(this, void 0); _safeAddress.set(this, void 0); _isSafeApp.set(this, false); __classPrivateFieldSet(this, _appsSdk, new safe_apps_sdk_1.default()); __classPrivateFieldGet(this, _appsSdk).getSafeInfo().then((appInfo) => { __classPrivateFieldSet(this, _isSafeApp, !!appInfo.safeAddress); __classPrivateFieldSet(this, _safeAddress, appInfo.safeAddress); }); } /** * Checks if the CPK is running as a Safe App or as a standalone app. * * @returns TRUE if the CPK is running as a Safe App */ get isSafeApp() { return __classPrivateFieldGet(this, _isSafeApp); } /** * Returns the Safe address connected to the CPK if the CPK is running as a Safe App. * * @returns The Safe address */ get safeAddress() { return __classPrivateFieldGet(this, _safeAddress); } /** * Returns an instance of the Safe Apps SDK used by the CPK. * * @returns The Safe Apps SDK instance */ get appsSdk() { return __classPrivateFieldGet(this, _appsSdk); } /** * Returns the information of the connected Safe App. * * @returns The information of the connected Safe App */ getSafeInfo() { return __classPrivateFieldGet(this, _appsSdk).getSafeInfo(); } /** * Returns the transaction response for the given Safe transaction hash. * * @param safeTxHash - The desired Safe transaction hash * @returns The transaction response for the Safe transaction hash */ getBySafeTxHash(safeTxHash) { return __classPrivateFieldGet(this, _appsSdk).txs.getBySafeTxHash(safeTxHash); } sendTransactions(transactions, params) { return __classPrivateFieldGet(this, _appsSdk).txs.send({ txs: transactions, params }); } } _appsSdk = new WeakMap(), _safeAddress = new WeakMap(), _isSafeApp = new WeakMap(); exports.default = SafeAppsSdkConnector; //# sourceMappingURL=index.js.map