@bloks/wallet
Advanced tools
Comparing version 25.0.9 to 25.0.26
@@ -121,2 +121,9 @@ /** | ||
}; | ||
export declare function _newaccres(account: string): { | ||
account: string; | ||
name: string; | ||
data: { | ||
account: string; | ||
}; | ||
}; | ||
/** | ||
@@ -123,0 +130,0 @@ * Create Account |
@@ -1049,2 +1049,11 @@ 'use strict'; | ||
} | ||
function _newaccres(account) { | ||
return { | ||
account: 'eosio.proton', | ||
name: 'newaccres', | ||
data: { | ||
account: account | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -1060,3 +1069,10 @@ * Create Account | ||
var actions = [_newaccount(creator, name, ownerKey, activeKey), _buyrambytes(creator, name, bytes), _delegatebw(creator, name, stake_net_quantity, stake_cpu_quantity, transfer)]; | ||
var actions = [_newaccount(creator, name, ownerKey, activeKey), _buyrambytes(creator, name, bytes)]; | ||
if (constants.constants.CHAIN.indexOf('proton') !== -1) { | ||
actions.push(_newaccres(name)); | ||
} else { | ||
actions.push(_delegatebw(creator, name, stake_net_quantity, stake_cpu_quantity, transfer)); | ||
} | ||
return Provider.transact(actions); | ||
@@ -1288,2 +1304,3 @@ } | ||
_newaccount: _newaccount, | ||
_newaccres: _newaccres, | ||
createAccount: createAccount, | ||
@@ -1290,0 +1307,0 @@ voteproducer: voteproducer, |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,n=require("@bloks/constants"),e=(t=require("penpal/lib/connectToChild"))&&"object"==typeof t&&"default"in t?t.default:t;function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}).apply(this,arguments)}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}const a=function(){function t(){}return t.prototype.then=function(n,e){const r=new t,o=this.s;if(o){const t=1&o?n:e;if(t){try{i(r,1,t(this.v))}catch(t){i(r,2,t)}return r}return this}return this.o=function(t){try{const o=t.v;1&t.s?i(r,1,n?n(o):o):e?i(r,1,e(o)):i(r,2,o)}catch(t){i(r,2,t)}},r},t}();function i(t,n,e){if(!t.s){if(e instanceof a){if(!e.s)return void(e.o=i.bind(null,t,n));1&n&&(n=e.s),e=e.v}if(e&&e.then)return void e.then(i.bind(null,t,n),i.bind(null,t,2));t.s=n,t.v=e;const r=t.o;r&&r(t)}}function s(t){return t instanceof a&&1&t.s}const c="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u=function(){return{onLoginToSign:function(t){console.log(t.wallet,t.actions)},clearErrors:function(){},onSuccess:function(t){console.log("Success",t)},onError:function(t){throw new Error(t)},onMultisig:function(t){return!1},onFreeCpu:function(t){return!1},isMultisigMode:function(){return!1},freeCpuEnabled:function(){return!1}}},f=function(){return{actor:"",permission:"",publicKey:"",wallet:"",type:"",chain:n.constants.CHAIN,delay_sec:0,index:0}},l=new(function(){function t(){if(this.user=f(),this.users=[],this.child=void 0,this.USER_KEY="user-v.0.0.7",this.USERS_KEY="users-v.0.0.7",this.setDimensions=function(){},this.onDimensionsChange=function(){},t.instance)return t.instance}var r,a=t.prototype;return a.initialize=function(t){var n=t.iframe,r=void 0===n?void 0:n;try{var o=this,a=e({iframe:r,methods:{}});return Promise.resolve(a.promise).then((function(t){return o.child=t,Promise.resolve(o.getUsers()).then((function(t){return o.users=t,Promise.resolve(o.getUser()).then((function(t){o.user=t}))}))}))}catch(t){return Promise.reject(t)}},a.getUser=function(){try{var t=this;return t.child?Promise.resolve(t.child.get(t.USER_KEY)).then((function(e){var r=function(){if(!e||e.chain!==n.constants.CHAIN){var r=e&&t.users.find((function(t){return t.chain===n.constants.CHAIN}));return e=r||f(),Promise.resolve(t.saveUser(e)).then((function(){}))}}();return r&&r.then?r.then((function(){return e})):e})):Promise.resolve(f())}catch(t){return Promise.reject(t)}},a.getUsers=function(){try{return this.child?Promise.resolve(this.child.get(this.USERS_KEY)).then((function(t){return t||[]})):Promise.resolve([])}catch(t){return Promise.reject(t)}},a.saveUser=function(t){try{var n=this,e=function(){if(!n.isSame(n.user,t)){n.user=t;var e=function(){if(n.child)return Promise.resolve(n.child.set(n.USER_KEY,t)).then((function(){}))}();if(e&&e.then)return e.then((function(){}))}}();return Promise.resolve(e&&e.then?e.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},a.saveUsers=function(t){try{var n=this;n.users=t;var e=function(){if(n.child)return Promise.resolve(n.child.set(n.USERS_KEY,t)).then((function(){}))}();return Promise.resolve(e&&e.then?e.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},a.isSame=function(t,n){return!!(!t&&!n||t&&n)&&t.actor===n.actor&&t.permission===n.permission&&t.wallet===n.wallet&&t.publicKey===n.publicKey},a.findUserIndex=function(t){var n=this;return this.users.findIndex((function(e){return n.isSame(e,t)}))},a.findUser=function(t){var n=this.findUserIndex(t);if(-1!==n)return this.users[n]},a.setUser=function(t){void 0===t&&(t={});try{var n=this.findUserIndex(t),e=-1!==n?this.users[n]:f();return Promise.resolve(this.saveUser(e)).then((function(){}))}catch(t){return Promise.reject(t)}},a.addUser=function(t){try{var n=this,e=Object.assign({},f(),t),r=n.findUserIndex(e),o=n.users;return-1===r?o=o.concat([e]):o[r]=Object.assign({},o[r],e),Promise.resolve(n.saveUsers(o)).then((function(){return Promise.resolve(n.setUser(e)).then((function(){}))}))}catch(t){return Promise.reject(t)}},a.addUsers=function(t){try{for(var n,e,r=this,a=[],i=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return o(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,void 0):void 0}}(t))){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(e=i()).done;){var s=e.value,c=r.findUserIndex(s);n=Object.assign({},f(),s),-1===c&&a.push(n)}var u=function(){if(a.length)return a=r.users.concat(a),Promise.resolve(r.saveUsers(a)).then((function(){}))}();return Promise.resolve(u&&u.then?u.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},a.removeUser=function(t,n){void 0===n&&(n=!1);try{var e=this;if(!t)return Promise.resolve();var r=e.findUserIndex(t);if(-1===r)return Promise.resolve();var o=(a=e.users).slice(0,i=r).concat(a.slice(i+1));return Promise.resolve(e.saveUsers(o)).then((function(){var r=e.isSame(t,e.user),o=function(){if(r){var t=n&&e.users.length?Promise.resolve(e.setUser(e.users[0])).then((function(){})):Promise.resolve(e.setUser()).then((function(){}));if(t&&t.then)return t.then((function(){}))}}();if(o&&o.then)return o.then((function(){}))}))}catch(t){return Promise.reject(t)}var a,i},(r=[{key:"authorization",get:function(){return[{actor:this.user.actor,permission:this.user.permission}]}},{key:"currentChainUsers",get:function(){return this.users.filter((function(t){return t.chain===n.constants.CHAIN}))}}])&&function(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,r),t}()),d=u();function h(){return["ScatterExtension"].includes(l.user.wallet)}var v={__proto__:null,get callbacks(){return d},setCallbacks:function(t){void 0===t&&(t={}),d=Object.assign(u(),t)},isEosjs1:h},p=new(function(){function t(){if(this.provider={},this.scatter=void 0,this.wax=void 0,this.api=void 0,t.instance)return t.instance}var e=t.prototype;return e.setApi=function(t){this.api=t},e.setProvider=function(t){this.provider=t},e.setScatter=function(t){this.scatter=t},e.setWax=function(t){this.wax=t},e.generateFreeCpuAction=function(t){return{account:"tippedtipped",name:"transfer",data:{from:"tippedtipped",to:t,quantity:"1.0 CPU",memo:"Free CPU from Bloks.io!"},authorization:[{actor:"tippedtipped",permission:"payforcpu"}]}},e.generateTransactOptions=function(t){var n=t.freeCpuEnabled;return r({blocksBehind:300,expireSeconds:3e3,broadcast:!n},n&&{requiredKeys:[l.user.publicKey]})},e.transact=function(t){try{var e=this,o=function(){return function(o,a){try{var i=function(){function o(){if(!d.isMultisigMode()||!d.onMultisig(t)){var n=d.freeCpuEnabled();n&&(t=[e.generateFreeCpuAction(v[0].actor)].concat(t));var o={delay_sec:h,max_cpu_usage_ms:n?5:0,actions:t},a=e.generateTransactOptions({freeCpuEnabled:n,wallet:f});return Promise.resolve(e.provider.transact(o,a)).then((function(e){n?d.onFreeCpu(r({actions:t},e)):(console.log("onsuccess"),d.onSuccess(e))}))}}var a=function(){if(e.api&&["fio","fio-test"].includes(n.constants.CHAIN))return Promise.resolve(e.api.addFIOFeeToActions(t,v[0].actor)).then((function(n){t=n}))}();return a&&a.then?a.then(o):o()}()}catch(t){return a(t)}return i&&i.then?i.then(void 0,a):i}(0,(function(t){var n=t&&t.error&&t.error.details&&t.error.details.length&&t.error.details[0].message||t.json&&t.json.fields&&t.json.fields.length&&t.json.fields[0].error||t.reason||t.message||t.toString()||t;console.log(n),d.onError(n)}))};d.clearErrors();var u=l.user,f=u.wallet,h=u.delay_sec;if(!f)return d.onError("Please log in first."),Promise.resolve();if(!e.provider||!e.provider.transact)return console.log("Provider not found: "+!e.provider),d.onLoginToSign({wallet:f,actions:t}),Promise.resolve();var v=l.authorization;t=t.map((function(t){return t.authorization=v,t}));var p=function(){if(e.provider&&e.provider.fc&&e.provider.fc.abiCache){var n=function(t,n,e){if("function"==typeof t[c]){var r,o,u,f=t[c]();if(function t(e){try{for(;!(r=f.next()).done;)if((e=n(r.value))&&e.then){if(!s(e))return void e.then(t,u||(u=i.bind(null,o=new a,2)));e=e.v}o?i(o,1,e):o=e}catch(t){i(o||(o=new a),2,t)}}(),f.return){var l=function(t){try{r.done||f.return()}catch(t){}return t};if(o&&o.then)return o.then(l,(function(t){throw l(t)}));l()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var d=[],h=0;h<t.length;h++)d.push(t[h]);return function(t,n,e){var r,o,c=-1;return function e(u){try{for(;++c<t.length;)if((u=n(c))&&u.then){if(!s(u))return void u.then(e,o||(o=i.bind(null,r=new a,2)));u=u.v}r?i(r,1,u):r=u}catch(t){i(r||(r=new a),2,t)}}(),r}(d,(function(t){return n(d[t])}))}([].concat(new Set(t.map((function(t){return t.account})))),(function(t){return Promise.resolve(e.provider.fc.abiCache.abiAsync(t)).then((function(){}))}));if(n&&n.then)return n.then((function(){}))}}();return Promise.resolve(p&&p.then?p.then(o):o())}catch(t){return Promise.reject(t)}},t}());function m(t,e,r,o,a){return{account:n.constants.EOSIO,name:"delegatebw",data:{from:t,receiver:e,stake_net_quantity:r,stake_cpu_quantity:o,transfer:a}}}function y(t,e,r,o){return{account:n.constants.EOSIO,name:"undelegatebw",data:{from:t,receiver:e,unstake_net_quantity:r,unstake_cpu_quantity:o}}}function b(t,e,r){return{account:n.constants.EOSIO,name:"buyrambytes",data:{payer:t,receiver:e,bytes:r}}}function g(t,e,r,o){return{account:n.constants.EOSIO,name:"updateauth",data:{account:t,permission:e,parent:r,auth:{threshold:1,keys:[{key:o,weight:1}],accounts:[],waits:[]}}}}function S(t,e,r,o){var a;return{account:n.constants.EOSIO,name:"newaccount",data:(a={creator:t},a[n.constants.NEWACCOUNT_NAME_PARAM]=e,a.owner={threshold:1,keys:[{key:r,weight:1}],accounts:[],waits:[]},a.active={threshold:1,keys:[{key:o,weight:1}],accounts:[],waits:[]},a)}}exports.default=r({},v,{__proto__:null,transfer:function(t,n,e,r,o){return p.transact([{account:t,name:"transfer",data:{from:n,to:e,quantity:r,memo:o}}])},delegatebw:function(t,n,e,r,o){h()&&(o=+o);var a=[m(t,n,e,r,o)];return p.transact(a)},_delegatebw:m,undelegatebw:function(t,n,e,r){var o=[y(t,n,e,r)];return p.transact(o)},_undelegatebw:y,buyram:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"buyram",data:{payer:t,receiver:e,quant:r}}])},buyrambytes:function(t,n,e){var r=[b(t,n,e)];return p.transact(r)},_buyrambytes:b,sellram:function(t,e){return p.transact([{account:n.constants.EOSIO,name:"sellram",data:{account:t,bytes:e}}])},refund:function(t){return p.transact([{account:n.constants.EOSIO,name:"refund",data:{owner:t}}])},addgravatar:function(t,e,r,o){return p.transact([{account:n.constants.ACCOUNT_INFO,name:"update",data:{account_name:t,title:e,avatar:r,desc:"",modifier:t,url:o?'{"telegram":"'+o+'"':""}}])},changeBasicPermissions:function(t,n,e){var r=[];return n&&""!==n&&r.push(g(t,"active","owner",n)),e&&""!==e&&r.push(g(t,"owner","",e)),p.transact(r)},_updateauthkey:g,updateAuth:function(t,e,r,o){return o.keys=o.keys.sort((function(t,n){return t.key.localeCompare(n.key)})),o.accounts=o.accounts.sort((function(t,n){return t.permission.actor.localeCompare(n.permission.actor)})),o.waits=o.waits.sort((function(t,n){return t.wait_sec.localeCompare(n.wait_sec)})),p.transact([{account:n.constants.EOSIO,name:"updateauth",data:{account:t,permission:e,parent:r,auth:o}}])},_newaccount:S,createAccount:function(t,n,e,r,o,a,i,s){h()&&(s=+s);var c=[S(t,n,e,r),b(t,n,o),m(t,n,a,i,s)];return p.transact(c)},voteproducer:function(t,e,r){var o=[];return["fio","fio-test"].includes(n.constants.CHAIN)&&e?o.push({account:n.constants.EOSIO,name:"voteproxy",data:{proxy:e}}):o.push({account:n.constants.EOSIO,name:"voteproducer",data:{voter:t,proxy:e,producers:r}}),p.transact(o)},linkAuth:function(t,e,r,o){return p.transact([{account:n.constants.EOSIO,name:"linkauth",data:{account:t,code:e,type:r,requirement:o}}])},unlinkAuth:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"unlinkauth",data:{account:t,code:e,type:r}}])},deleteAuth:function(t,e){return p.transact([{account:n.constants.EOSIO,name:"deleteauth",data:{account:t,permission:e}}])},cancelDelay:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"canceldelay",data:{canceling_auth:{actor:t,permission:e},trx_id:r}}])},updateProxy:function(t,e){return h()&&(e=+e),p.transact([{account:n.constants.EOSIO,name:"regproxy",data:{proxy:t,isproxy:e}}])},_setCode:function(t,e){return{account:n.constants.EOSIO,name:"setcode",data:{account:t,code:e,vmtype:0,vmversion:0}}},_setAbi:function(t,e){return{account:n.constants.EOSIO,name:"setabi",data:{account:t,abi:e}}},propose:function(t,e,r,o){return p.transact([{account:n.constants.EOSIO_MSIG,name:"propose",data:{proposer:t,proposal_name:e,requested:r,trx:o}}])},approve:function(t,e,r){return p.transact([{account:n.constants.EOSIO_MSIG,name:"approve",data:{proposer:t,proposal_name:e,level:r}}])},execute:function(t,e,r){return p.transact([{account:n.constants.EOSIO_MSIG,name:"exec",data:{proposer:t,proposal_name:e,executer:r}}])},cancel:function(t,e,r){return p.transact([{account:n.constants.EOSIO_MSIG,name:"cancel",data:{proposer:t,proposal_name:e,canceler:r}}])},bidname:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"bidname",data:{bidder:t,newname:e,bid:r}}])}},{Provider:p,User:l}); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t,n=require("@bloks/constants"),e=(t=require("penpal/lib/connectToChild"))&&"object"==typeof t&&"default"in t?t.default:t;function r(){return(r=Object.assign||function(t){for(var n=1;n<arguments.length;n++){var e=arguments[n];for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])}return t}).apply(this,arguments)}function o(t,n){(null==n||n>t.length)&&(n=t.length);for(var e=0,r=new Array(n);e<n;e++)r[e]=t[e];return r}const a=function(){function t(){}return t.prototype.then=function(n,e){const r=new t,o=this.s;if(o){const t=1&o?n:e;if(t){try{i(r,1,t(this.v))}catch(t){i(r,2,t)}return r}return this}return this.o=function(t){try{const o=t.v;1&t.s?i(r,1,n?n(o):o):e?i(r,1,e(o)):i(r,2,o)}catch(t){i(r,2,t)}},r},t}();function i(t,n,e){if(!t.s){if(e instanceof a){if(!e.s)return void(e.o=i.bind(null,t,n));1&n&&(n=e.s),e=e.v}if(e&&e.then)return void e.then(i.bind(null,t,n),i.bind(null,t,2));t.s=n,t.v=e;const r=t.o;r&&r(t)}}function s(t){return t instanceof a&&1&t.s}const c="undefined"!=typeof Symbol?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";"undefined"!=typeof Symbol&&(Symbol.asyncIterator||(Symbol.asyncIterator=Symbol("Symbol.asyncIterator")));var u=function(){return{onLoginToSign:function(t){console.log(t.wallet,t.actions)},clearErrors:function(){},onSuccess:function(t){console.log("Success",t)},onError:function(t){throw new Error(t)},onMultisig:function(t){return!1},onFreeCpu:function(t){return!1},isMultisigMode:function(){return!1},freeCpuEnabled:function(){return!1}}},f=function(){return{actor:"",permission:"",publicKey:"",wallet:"",type:"",chain:n.constants.CHAIN,delay_sec:0,index:0}},l=new(function(){function t(){if(this.user=f(),this.users=[],this.child=void 0,this.USER_KEY="user-v.0.0.7",this.USERS_KEY="users-v.0.0.7",this.setDimensions=function(){},this.onDimensionsChange=function(){},t.instance)return t.instance}var r,a=t.prototype;return a.initialize=function(t){var n=t.iframe,r=void 0===n?void 0:n;try{var o=this,a=e({iframe:r,methods:{}});return Promise.resolve(a.promise).then((function(t){return o.child=t,Promise.resolve(o.getUsers()).then((function(t){return o.users=t,Promise.resolve(o.getUser()).then((function(t){o.user=t}))}))}))}catch(t){return Promise.reject(t)}},a.getUser=function(){try{var t=this;return t.child?Promise.resolve(t.child.get(t.USER_KEY)).then((function(e){var r=function(){if(!e||e.chain!==n.constants.CHAIN){var r=e&&t.users.find((function(t){return t.chain===n.constants.CHAIN}));return e=r||f(),Promise.resolve(t.saveUser(e)).then((function(){}))}}();return r&&r.then?r.then((function(){return e})):e})):Promise.resolve(f())}catch(t){return Promise.reject(t)}},a.getUsers=function(){try{return this.child?Promise.resolve(this.child.get(this.USERS_KEY)).then((function(t){return t||[]})):Promise.resolve([])}catch(t){return Promise.reject(t)}},a.saveUser=function(t){try{var n=this,e=function(){if(!n.isSame(n.user,t)){n.user=t;var e=function(){if(n.child)return Promise.resolve(n.child.set(n.USER_KEY,t)).then((function(){}))}();if(e&&e.then)return e.then((function(){}))}}();return Promise.resolve(e&&e.then?e.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},a.saveUsers=function(t){try{var n=this;n.users=t;var e=function(){if(n.child)return Promise.resolve(n.child.set(n.USERS_KEY,t)).then((function(){}))}();return Promise.resolve(e&&e.then?e.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},a.isSame=function(t,n){return!!(!t&&!n||t&&n)&&t.actor===n.actor&&t.permission===n.permission&&t.wallet===n.wallet&&t.publicKey===n.publicKey},a.findUserIndex=function(t){var n=this;return this.users.findIndex((function(e){return n.isSame(e,t)}))},a.findUser=function(t){var n=this.findUserIndex(t);if(-1!==n)return this.users[n]},a.setUser=function(t){void 0===t&&(t={});try{var n=this.findUserIndex(t),e=-1!==n?this.users[n]:f();return Promise.resolve(this.saveUser(e)).then((function(){}))}catch(t){return Promise.reject(t)}},a.addUser=function(t){try{var n=this,e=Object.assign({},f(),t),r=n.findUserIndex(e),o=n.users;return-1===r?o=o.concat([e]):o[r]=Object.assign({},o[r],e),Promise.resolve(n.saveUsers(o)).then((function(){return Promise.resolve(n.setUser(e)).then((function(){}))}))}catch(t){return Promise.reject(t)}},a.addUsers=function(t){try{for(var n,e,r=this,a=[],i=function(t,n){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,n){if(t){if("string"==typeof t)return o(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?o(t,void 0):void 0}}(t))){e&&(t=e);var r=0;return function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(t);!(e=i()).done;){var s=e.value,c=r.findUserIndex(s);n=Object.assign({},f(),s),-1===c&&a.push(n)}var u=function(){if(a.length)return a=r.users.concat(a),Promise.resolve(r.saveUsers(a)).then((function(){}))}();return Promise.resolve(u&&u.then?u.then((function(){})):void 0)}catch(t){return Promise.reject(t)}},a.removeUser=function(t,n){void 0===n&&(n=!1);try{var e=this;if(!t)return Promise.resolve();var r=e.findUserIndex(t);if(-1===r)return Promise.resolve();var o=(a=e.users).slice(0,i=r).concat(a.slice(i+1));return Promise.resolve(e.saveUsers(o)).then((function(){var r=e.isSame(t,e.user),o=function(){if(r){var t=n&&e.users.length?Promise.resolve(e.setUser(e.users[0])).then((function(){})):Promise.resolve(e.setUser()).then((function(){}));if(t&&t.then)return t.then((function(){}))}}();if(o&&o.then)return o.then((function(){}))}))}catch(t){return Promise.reject(t)}var a,i},(r=[{key:"authorization",get:function(){return[{actor:this.user.actor,permission:this.user.permission}]}},{key:"currentChainUsers",get:function(){return this.users.filter((function(t){return t.chain===n.constants.CHAIN}))}}])&&function(t,n){for(var e=0;e<n.length;e++){var r=n[e];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}(t.prototype,r),t}()),d=u();function h(){return["ScatterExtension"].includes(l.user.wallet)}var v={__proto__:null,get callbacks(){return d},setCallbacks:function(t){void 0===t&&(t={}),d=Object.assign(u(),t)},isEosjs1:h},p=new(function(){function t(){if(this.provider={},this.scatter=void 0,this.wax=void 0,this.api=void 0,t.instance)return t.instance}var e=t.prototype;return e.setApi=function(t){this.api=t},e.setProvider=function(t){this.provider=t},e.setScatter=function(t){this.scatter=t},e.setWax=function(t){this.wax=t},e.generateFreeCpuAction=function(t){return{account:"tippedtipped",name:"transfer",data:{from:"tippedtipped",to:t,quantity:"1.0 CPU",memo:"Free CPU from Bloks.io!"},authorization:[{actor:"tippedtipped",permission:"payforcpu"}]}},e.generateTransactOptions=function(t){var n=t.freeCpuEnabled;return r({blocksBehind:300,expireSeconds:3e3,broadcast:!n},n&&{requiredKeys:[l.user.publicKey]})},e.transact=function(t){try{var e=this,o=function(){return function(o,a){try{var i=function(){function o(){if(!d.isMultisigMode()||!d.onMultisig(t)){var n=d.freeCpuEnabled();n&&(t=[e.generateFreeCpuAction(v[0].actor)].concat(t));var o={delay_sec:h,max_cpu_usage_ms:n?5:0,actions:t},a=e.generateTransactOptions({freeCpuEnabled:n,wallet:f});return Promise.resolve(e.provider.transact(o,a)).then((function(e){n?d.onFreeCpu(r({actions:t},e)):(console.log("onsuccess"),d.onSuccess(e))}))}}var a=function(){if(e.api&&["fio","fio-test"].includes(n.constants.CHAIN))return Promise.resolve(e.api.addFIOFeeToActions(t,v[0].actor)).then((function(n){t=n}))}();return a&&a.then?a.then(o):o()}()}catch(t){return a(t)}return i&&i.then?i.then(void 0,a):i}(0,(function(t){var n=t&&t.error&&t.error.details&&t.error.details.length&&t.error.details[0].message||t.json&&t.json.fields&&t.json.fields.length&&t.json.fields[0].error||t.reason||t.message||t.toString()||t;console.log(n),d.onError(n)}))};d.clearErrors();var u=l.user,f=u.wallet,h=u.delay_sec;if(!f)return d.onError("Please log in first."),Promise.resolve();if(!e.provider||!e.provider.transact)return console.log("Provider not found: "+!e.provider),d.onLoginToSign({wallet:f,actions:t}),Promise.resolve();var v=l.authorization;t=t.map((function(t){return t.authorization=v,t}));var p=function(){if(e.provider&&e.provider.fc&&e.provider.fc.abiCache){var n=function(t,n,e){if("function"==typeof t[c]){var r,o,u,f=t[c]();if(function t(e){try{for(;!(r=f.next()).done;)if((e=n(r.value))&&e.then){if(!s(e))return void e.then(t,u||(u=i.bind(null,o=new a,2)));e=e.v}o?i(o,1,e):o=e}catch(t){i(o||(o=new a),2,t)}}(),f.return){var l=function(t){try{r.done||f.return()}catch(t){}return t};if(o&&o.then)return o.then(l,(function(t){throw l(t)}));l()}return o}if(!("length"in t))throw new TypeError("Object is not iterable");for(var d=[],h=0;h<t.length;h++)d.push(t[h]);return function(t,n,e){var r,o,c=-1;return function e(u){try{for(;++c<t.length;)if((u=n(c))&&u.then){if(!s(u))return void u.then(e,o||(o=i.bind(null,r=new a,2)));u=u.v}r?i(r,1,u):r=u}catch(t){i(r||(r=new a),2,t)}}(),r}(d,(function(t){return n(d[t])}))}([].concat(new Set(t.map((function(t){return t.account})))),(function(t){return Promise.resolve(e.provider.fc.abiCache.abiAsync(t)).then((function(){}))}));if(n&&n.then)return n.then((function(){}))}}();return Promise.resolve(p&&p.then?p.then(o):o())}catch(t){return Promise.reject(t)}},t}());function m(t,e,r,o,a){return{account:n.constants.EOSIO,name:"delegatebw",data:{from:t,receiver:e,stake_net_quantity:r,stake_cpu_quantity:o,transfer:a}}}function y(t,e,r,o){return{account:n.constants.EOSIO,name:"undelegatebw",data:{from:t,receiver:e,unstake_net_quantity:r,unstake_cpu_quantity:o}}}function b(t,e,r){return{account:n.constants.EOSIO,name:"buyrambytes",data:{payer:t,receiver:e,bytes:r}}}function g(t,e,r,o){return{account:n.constants.EOSIO,name:"updateauth",data:{account:t,permission:e,parent:r,auth:{threshold:1,keys:[{key:o,weight:1}],accounts:[],waits:[]}}}}function O(t,e,r,o){var a;return{account:n.constants.EOSIO,name:"newaccount",data:(a={creator:t},a[n.constants.NEWACCOUNT_NAME_PARAM]=e,a.owner={threshold:1,keys:[{key:r,weight:1}],accounts:[],waits:[]},a.active={threshold:1,keys:[{key:o,weight:1}],accounts:[],waits:[]},a)}}function S(t){return{account:"eosio.proton",name:"newaccres",data:{account:t}}}exports.default=r({},v,{__proto__:null,transfer:function(t,n,e,r,o){return p.transact([{account:t,name:"transfer",data:{from:n,to:e,quantity:r,memo:o}}])},delegatebw:function(t,n,e,r,o){h()&&(o=+o);var a=[m(t,n,e,r,o)];return p.transact(a)},_delegatebw:m,undelegatebw:function(t,n,e,r){var o=[y(t,n,e,r)];return p.transact(o)},_undelegatebw:y,buyram:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"buyram",data:{payer:t,receiver:e,quant:r}}])},buyrambytes:function(t,n,e){var r=[b(t,n,e)];return p.transact(r)},_buyrambytes:b,sellram:function(t,e){return p.transact([{account:n.constants.EOSIO,name:"sellram",data:{account:t,bytes:e}}])},refund:function(t){return p.transact([{account:n.constants.EOSIO,name:"refund",data:{owner:t}}])},addgravatar:function(t,e,r,o){return p.transact([{account:n.constants.ACCOUNT_INFO,name:"update",data:{account_name:t,title:e,avatar:r,desc:"",modifier:t,url:o?'{"telegram":"'+o+'"':""}}])},changeBasicPermissions:function(t,n,e){var r=[];return n&&""!==n&&r.push(g(t,"active","owner",n)),e&&""!==e&&r.push(g(t,"owner","",e)),p.transact(r)},_updateauthkey:g,updateAuth:function(t,e,r,o){return o.keys=o.keys.sort((function(t,n){return t.key.localeCompare(n.key)})),o.accounts=o.accounts.sort((function(t,n){return t.permission.actor.localeCompare(n.permission.actor)})),o.waits=o.waits.sort((function(t,n){return t.wait_sec.localeCompare(n.wait_sec)})),p.transact([{account:n.constants.EOSIO,name:"updateauth",data:{account:t,permission:e,parent:r,auth:o}}])},_newaccount:O,_newaccres:S,createAccount:function(t,e,r,o,a,i,s,c){h()&&(c=+c);var u=[O(t,e,r,o),b(t,e,a)];return-1!==n.constants.CHAIN.indexOf("proton")?u.push(S(e)):u.push(m(t,e,i,s,c)),p.transact(u)},voteproducer:function(t,e,r){var o=[];return["fio","fio-test"].includes(n.constants.CHAIN)&&e?o.push({account:n.constants.EOSIO,name:"voteproxy",data:{proxy:e}}):o.push({account:n.constants.EOSIO,name:"voteproducer",data:{voter:t,proxy:e,producers:r}}),p.transact(o)},linkAuth:function(t,e,r,o){return p.transact([{account:n.constants.EOSIO,name:"linkauth",data:{account:t,code:e,type:r,requirement:o}}])},unlinkAuth:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"unlinkauth",data:{account:t,code:e,type:r}}])},deleteAuth:function(t,e){return p.transact([{account:n.constants.EOSIO,name:"deleteauth",data:{account:t,permission:e}}])},cancelDelay:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"canceldelay",data:{canceling_auth:{actor:t,permission:e},trx_id:r}}])},updateProxy:function(t,e){return h()&&(e=+e),p.transact([{account:n.constants.EOSIO,name:"regproxy",data:{proxy:t,isproxy:e}}])},_setCode:function(t,e){return{account:n.constants.EOSIO,name:"setcode",data:{account:t,code:e,vmtype:0,vmversion:0}}},_setAbi:function(t,e){return{account:n.constants.EOSIO,name:"setabi",data:{account:t,abi:e}}},propose:function(t,e,r,o){return p.transact([{account:n.constants.EOSIO_MSIG,name:"propose",data:{proposer:t,proposal_name:e,requested:r,trx:o}}])},approve:function(t,e,r){return p.transact([{account:n.constants.EOSIO_MSIG,name:"approve",data:{proposer:t,proposal_name:e,level:r}}])},execute:function(t,e,r){return p.transact([{account:n.constants.EOSIO_MSIG,name:"exec",data:{proposer:t,proposal_name:e,executer:r}}])},cancel:function(t,e,r){return p.transact([{account:n.constants.EOSIO_MSIG,name:"cancel",data:{proposer:t,proposal_name:e,canceler:r}}])},bidname:function(t,e,r){return p.transact([{account:n.constants.EOSIO,name:"bidname",data:{bidder:t,newname:e,bid:r}}])}},{Provider:p,User:l}); | ||
//# sourceMappingURL=wallet.cjs.production.min.js.map |
@@ -1043,2 +1043,11 @@ import { constants } from '@bloks/constants'; | ||
} | ||
function _newaccres(account) { | ||
return { | ||
account: 'eosio.proton', | ||
name: 'newaccres', | ||
data: { | ||
account: account | ||
} | ||
}; | ||
} | ||
/** | ||
@@ -1054,3 +1063,10 @@ * Create Account | ||
var actions = [_newaccount(creator, name, ownerKey, activeKey), _buyrambytes(creator, name, bytes), _delegatebw(creator, name, stake_net_quantity, stake_cpu_quantity, transfer)]; | ||
var actions = [_newaccount(creator, name, ownerKey, activeKey), _buyrambytes(creator, name, bytes)]; | ||
if (constants.CHAIN.indexOf('proton') !== -1) { | ||
actions.push(_newaccres(name)); | ||
} else { | ||
actions.push(_delegatebw(creator, name, stake_net_quantity, stake_cpu_quantity, transfer)); | ||
} | ||
return Provider.transact(actions); | ||
@@ -1282,2 +1298,3 @@ } | ||
_newaccount: _newaccount, | ||
_newaccres: _newaccres, | ||
createAccount: createAccount, | ||
@@ -1284,0 +1301,0 @@ voteproducer: voteproducer, |
{ | ||
"name": "@bloks/wallet", | ||
"version": "25.0.9", | ||
"version": "25.0.26", | ||
"author": "jafri", | ||
@@ -26,6 +26,6 @@ "module": "dist/wallet.esm.js", | ||
"dependencies": { | ||
"@bloks/constants": "^25.0.9", | ||
"@bloks/constants": "^25.0.26", | ||
"penpal": "^4.1.1" | ||
}, | ||
"gitHead": "8fd04e1c200fa02fec52cb86776cd6c512e8a5fa" | ||
"gitHead": "090013649ff59b3383e33878ad67d6799aa8d0cd" | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
305632
2836
Updated@bloks/constants@^25.0.26