UNPKG

@steeveproject/ngx-steem-keychain

Version:
321 lines 9.14 kB
/** * @fileoverview added by tsickle * @suppress {checkTypes,extraRequire,uselessCode} checked by tsc */ import { Injectable, NgZone } from '@angular/core'; import { Observable } from 'rxjs'; import { SteemKeychainError } from './errors/steem-keychain-error'; import * as i0 from "@angular/core"; var SteemKeychainService = /** @class */ (function () { function SteemKeychainService(ngZone) { this.ngZone = ngZone; } Object.defineProperty(SteemKeychainService.prototype, "steemKeychainAvailable", { get: /** * @return {?} */ function () { return ((/** @type {?} */ (window))).steem_keychain !== undefined; }, enumerable: true, configurable: true }); /** * @return {?} */ SteemKeychainService.prototype.requestHandshake = /** * @return {?} */ function () { return this.call('requestHandshake', []); }; /** * @param {?} account * @param {?} encryptedMessage * @param {?} keyType * @return {?} */ SteemKeychainService.prototype.requestVerifyKey = /** * @param {?} account * @param {?} encryptedMessage * @param {?} keyType * @return {?} */ function (account, encryptedMessage, keyType) { return this.call('requestVerifyKey', [ account, encryptedMessage, keyType ]); }; /** * @param {?} account * @param {?} message * @param {?} keyType * @return {?} */ SteemKeychainService.prototype.requestSignBuffer = /** * @param {?} account * @param {?} message * @param {?} keyType * @return {?} */ function (account, message, keyType) { return this.call('requestSignBuffer', [ account, message, keyType ]); }; /** * @param {?} account * @param {?} operations * @param {?} keyType * @return {?} */ SteemKeychainService.prototype.requestBroadcast = /** * @param {?} account * @param {?} operations * @param {?} keyType * @return {?} */ function (account, operations, keyType) { return this.call('requestBroadcast', [ account, operations.map(function (op) { return op.toArray(); }), keyType ]); }; /** * @param {?} account * @param {?} method * @param {?} params * @param {?} keyType * @return {?} */ SteemKeychainService.prototype.requestSignedCall = /** * @param {?} account * @param {?} method * @param {?} params * @param {?} keyType * @return {?} */ function (account, method, params, keyType) { return this.call('requestSignedCall', [ account, method, params, keyType ]); }; /** * @param {?} parentAuthor * @param {?} parentPermlink * @param {?} author * @param {?} permlink * @param {?} title * @param {?} body * @param {?=} jsonMetadata * @param {?=} options * @return {?} */ SteemKeychainService.prototype.requestPost = /** * @param {?} parentAuthor * @param {?} parentPermlink * @param {?} author * @param {?} permlink * @param {?} title * @param {?} body * @param {?=} jsonMetadata * @param {?=} options * @return {?} */ function (parentAuthor, parentPermlink, author, permlink, title, body, jsonMetadata, options) { if (jsonMetadata === void 0) { jsonMetadata = ''; } if (options === void 0) { options = ''; } return this.call('requestPost', [ author, title, body, parentPermlink, parentAuthor, jsonMetadata, permlink, options ]); }; /** * @param {?} voter * @param {?} author * @param {?} permlink * @param {?} weight * @return {?} */ SteemKeychainService.prototype.requestVote = /** * @param {?} voter * @param {?} author * @param {?} permlink * @param {?} weight * @return {?} */ function (voter, author, permlink, weight) { return this.call('requestVote', [ voter, permlink, author, weight ]); }; /** * @param {?} account * @param {?} displayMessage * @param {?} id * @param {?} customJson * @param {?=} key * @return {?} */ SteemKeychainService.prototype.requestCustomJson = /** * @param {?} account * @param {?} displayMessage * @param {?} id * @param {?} customJson * @param {?=} key * @return {?} */ function (account, displayMessage, id, customJson, key) { if (key === void 0) { key = 'Posting'; } return this.call('requestCustomJson', [ account, id, ((/** @type {?} */ (key))).toLowerCase(), customJson, displayMessage ]); }; /** * @param {?} from * @param {?} to * @param {?} amount * @param {?} memo * @param {?} currency * @param {?=} enforce * @return {?} */ SteemKeychainService.prototype.requestTransfer = /** * @param {?} from * @param {?} to * @param {?} amount * @param {?} memo * @param {?} currency * @param {?=} enforce * @return {?} */ function (from, to, amount, memo, currency, enforce) { if (enforce === void 0) { enforce = false; } return this.call('requestTransfer', [ from, to, amount, memo, currency, enforce, ], 4); }; /** * @param {?} delegator * @param {?} delegatee * @param {?} amount * @param {?} unit * @return {?} */ SteemKeychainService.prototype.requestDelegation = /** * @param {?} delegator * @param {?} delegatee * @param {?} amount * @param {?} unit * @return {?} */ function (delegator, delegatee, amount, unit) { return this.call('requestDelegation', [ delegator, delegatee, amount, unit ]); }; /* * call is invoked by all other methods to call Steem Keychain. * It should not be used directly since it is not type-safe, * but it can be bandy in case there is a method not implemented yet. */ /* * call is invoked by all other methods to call Steem Keychain. * It should not be used directly since it is not type-safe, * but it can be bandy in case there is a method not implemented yet. */ /** * @param {?} method * @param {?} args * @param {?=} callbackIndex * @return {?} */ SteemKeychainService.prototype.call = /* * call is invoked by all other methods to call Steem Keychain. * It should not be used directly since it is not type-safe, * but it can be bandy in case there is a method not implemented yet. */ /** * @param {?} method * @param {?} args * @param {?=} callbackIndex * @return {?} */ function (method, args, callbackIndex) { var _this = this; return Observable.create(function (observer) { var _a; // Make sure the extension is available. if (!_this.steemKeychainAvailable) { observer.error(new Error('Steem Keychain not available')); observer.complete(); return; } // Push the callback to the argument list. /** @type {?} */ var cb = function (res) { return _this.ngZone.run(function () { if (res.success) { observer.next(res); observer.complete(); } else { observer.error(new SteemKeychainError(res)); } }); }; if (callbackIndex) { args.splice(callbackIndex, 0, cb); } else { args.push(cb); } // Send the request. (_a = ((/** @type {?} */ (window))).steem_keychain)[method].apply(_a, args); }); }; SteemKeychainService.decorators = [ { type: Injectable, args: [{ providedIn: 'root' },] } ]; /** @nocollapse */ SteemKeychainService.ctorParameters = function () { return [ { type: NgZone } ]; }; /** @nocollapse */ SteemKeychainService.ngInjectableDef = i0.defineInjectable({ factory: function SteemKeychainService_Factory() { return new SteemKeychainService(i0.inject(i0.NgZone)); }, token: SteemKeychainService, providedIn: "root" }); return SteemKeychainService; }()); export { SteemKeychainService }; if (false) { /** @type {?} */ SteemKeychainService.prototype.ngZone; } //# sourceMappingURL=steem-keychain.service.js.map