@steeveproject/ngx-steem-keychain
Version:
Your Angular interface to Steem Keychain
5 lines • 5.74 kB
JavaScript
!function(global,factory){"object"==typeof exports&&"undefined"!=typeof module?factory(exports,require("@angular/core"),require("rxjs")):"function"==typeof define&&define.amd?define("ngx-steem-keychain",["exports","@angular/core","rxjs"],factory):factory((global.ng=global.ng||{},global.ng.angularLibraryStarter={}),global.ng.core,global.rxjs)}(this,function(exports,core,rxjs){"use strict";var extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(d,b){d.__proto__=b}||function(d,b){for(var p in b)b.hasOwnProperty(p)&&(d[p]=b[p])};function __extends(d,b){function __(){this.constructor=d}extendStatics(d,b),d.prototype=null===b?Object.create(b):(__.prototype=b.prototype,new __)}
/**
* @license ngx-steem-keychain
* MIT license
*/var SteemKeychainError=function(_super){function SteemKeychainError(response){var _this=_super.call(this,response.message)||this;return _this.response=response,Object.setPrototypeOf(_this,SteemKeychainError.prototype),_this}return __extends(SteemKeychainError,_super),SteemKeychainError}(Error),SteemKeychainService=function(){function SteemKeychainService(ngZone){this.ngZone=ngZone}return Object.defineProperty(SteemKeychainService.prototype,"steemKeychainAvailable",{get:function(){return void 0!==window.steem_keychain},enumerable:!0,configurable:!0}),SteemKeychainService.prototype.requestHandshake=function(){return this.call("requestHandshake",[])},SteemKeychainService.prototype.requestVerifyKey=function(account,encryptedMessage,keyType){return this.call("requestVerifyKey",[account,encryptedMessage,keyType])},SteemKeychainService.prototype.requestSignBuffer=function(account,message,keyType){return this.call("requestSignBuffer",[account,message,keyType])},SteemKeychainService.prototype.requestBroadcast=function(account,operations,keyType){return this.call("requestBroadcast",[account,operations.map(function(op){return op.toArray()}),keyType])},SteemKeychainService.prototype.requestSignedCall=function(account,method,params,keyType){return this.call("requestSignedCall",[account,method,params,keyType])},SteemKeychainService.prototype.requestPost=function(parentAuthor,parentPermlink,author,permlink,title,body,jsonMetadata,options){return void 0===jsonMetadata&&(jsonMetadata=""),void 0===options&&(options=""),this.call("requestPost",[author,title,body,parentPermlink,parentAuthor,jsonMetadata,permlink,options])},SteemKeychainService.prototype.requestVote=function(voter,author,permlink,weight){return this.call("requestVote",[voter,permlink,author,weight])},SteemKeychainService.prototype.requestCustomJson=function(account,displayMessage,id,customJson,key){return void 0===key&&(key="Posting"),this.call("requestCustomJson",[account,id,key.toLowerCase(),customJson,displayMessage])},SteemKeychainService.prototype.requestTransfer=function(from,to,amount,memo,currency,enforce){return void 0===enforce&&(enforce=!1),this.call("requestTransfer",[from,to,amount,memo,currency,enforce],4)},SteemKeychainService.prototype.requestDelegation=function(delegator,delegatee,amount,unit){return this.call("requestDelegation",[delegator,delegatee,amount,unit])},SteemKeychainService.prototype.call=function(method,args,callbackIndex){var _this=this;return rxjs.Observable.create(function(observer){var _a;if(!_this.steemKeychainAvailable)return observer.error(new Error("Steem Keychain not available")),void observer.complete();var cb=function(res){return _this.ngZone.run(function(){res.success?(observer.next(res),observer.complete()):observer.error(new SteemKeychainError(res))})};callbackIndex?args.splice(callbackIndex,0,cb):args.push(cb),(_a=window.steem_keychain)[method].apply(_a,args)})},SteemKeychainService.decorators=[{type:core.Injectable,args:[{providedIn:"root"}]}],SteemKeychainService.ctorParameters=function(){return[{type:core.NgZone}]},SteemKeychainService.ngInjectableDef=core.defineInjectable({factory:function(){return new SteemKeychainService(core.inject(core.NgZone))},token:SteemKeychainService,providedIn:"root"}),SteemKeychainService}(),SteemKeychainModule=function(){function SteemKeychainModule(){}return SteemKeychainModule.forRoot=function(){return{ngModule:SteemKeychainModule,providers:[SteemKeychainService]}},SteemKeychainModule.forChild=function(){return{ngModule:SteemKeychainModule,providers:[SteemKeychainService]}},SteemKeychainModule.decorators=[{type:core.NgModule}],SteemKeychainModule}(),InvalidArgumentsError=function(_super){function InvalidArgumentsError(message){var _this=_super.call(this,message)||this;return _this.message=message,Object.setPrototypeOf(_this,InvalidArgumentsError.prototype),_this}return __extends(InvalidArgumentsError,_super),InvalidArgumentsError}(Error),Operation=function(){function Operation(name,params){this.name=name,this.params=params}return Operation.fromArray=function(operation){if(!operation)throw new InvalidArgumentsError("operation array is unset");if(2!==operation.length)throw new InvalidArgumentsError("operation array length invalid (must be 2)");var name=operation[0],params=operation[1];if("string"!=typeof name)throw new InvalidArgumentsError("operation[0] (operation name) must be a string");if("object"!=typeof params)throw new InvalidArgumentsError("operation[1] (operation params) must be an object");return new Operation(name,params)},Operation.prototype.toArray=function(){return[this.name,this.params]},Operation.prototype.toJSON=function(){return this.toArray()},Operation}();exports.SteemKeychainModule=SteemKeychainModule,exports.SteemKeychainError=SteemKeychainError,exports.InvalidArgumentsError=InvalidArgumentsError,exports.Operation=Operation,exports.SteemKeychainService=SteemKeychainService,Object.defineProperty(exports,"__esModule",{value:!0})});