dp-contract-proxy-kit
Version:
Enable batched transactions and contract account interactions using a unique deterministic Gnosis Safe.
77 lines • 3.94 kB
JavaScript
;
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
if (kind === "m") throw new TypeError("Private method is not writable");
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
};
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
var _SafeAppsSdkConnector_appsSdk, _SafeAppsSdkConnector_safeAddress, _SafeAppsSdkConnector_isSafeApp;
Object.defineProperty(exports, "__esModule", { value: true });
const safe_apps_sdk_1 = __importDefault(require("@gnosis.pm/safe-apps-sdk"));
class SafeAppsSdkConnector {
constructor() {
_SafeAppsSdkConnector_appsSdk.set(this, void 0);
_SafeAppsSdkConnector_safeAddress.set(this, void 0);
_SafeAppsSdkConnector_isSafeApp.set(this, false);
__classPrivateFieldSet(this, _SafeAppsSdkConnector_appsSdk, new safe_apps_sdk_1.default(), "f");
__classPrivateFieldGet(this, _SafeAppsSdkConnector_appsSdk, "f").getSafeInfo().then((appInfo) => {
__classPrivateFieldSet(this, _SafeAppsSdkConnector_isSafeApp, !!appInfo.safeAddress, "f");
__classPrivateFieldSet(this, _SafeAppsSdkConnector_safeAddress, appInfo.safeAddress, "f");
});
}
/**
* 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, _SafeAppsSdkConnector_isSafeApp, "f");
}
/**
* 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, _SafeAppsSdkConnector_safeAddress, "f");
}
/**
* Returns an instance of the Safe Apps SDK used by the CPK.
*
* @returns The Safe Apps SDK instance
*/
get appsSdk() {
return __classPrivateFieldGet(this, _SafeAppsSdkConnector_appsSdk, "f");
}
/**
* Returns the information of the connected Safe App.
*
* @returns The information of the connected Safe App
*/
getSafeInfo() {
return __classPrivateFieldGet(this, _SafeAppsSdkConnector_appsSdk, "f").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, _SafeAppsSdkConnector_appsSdk, "f").txs.getBySafeTxHash(safeTxHash);
}
sendTransactions(transactions, params) {
return __classPrivateFieldGet(this, _SafeAppsSdkConnector_appsSdk, "f").txs.send({ txs: transactions, params });
}
}
_SafeAppsSdkConnector_appsSdk = new WeakMap(), _SafeAppsSdkConnector_safeAddress = new WeakMap(), _SafeAppsSdkConnector_isSafeApp = new WeakMap();
exports.default = SafeAppsSdkConnector;
//# sourceMappingURL=index.js.map