eosHelper.js 803 B

12345678910111213141516171819202122232425262728
  1. let EosHelper = {
  2. transfer: function (from, to, amount, memo, authority) {
  3. let action = 'transfer'
  4. let identity = { authorization: [`${from}@${authority}`] }
  5. if (self !== top) {
  6. return meeAction(action, [from, to, amount, memo, identity])
  7. } else {
  8. return window.EOS[action](from, to, amount, memo, identity)
  9. }
  10. },
  11. getCurrencyBalance: function (code, account, symbol = 'EOS') {
  12. let action = 'getCurrencyBalance'
  13. if (self !== top) {
  14. return meeAction(action, [code, account, symbol])
  15. } else {
  16. return window.EOS.getCurrencyBalance(code, account, symbol)
  17. }
  18. }
  19. }
  20. function meeAction (action, param, code) {
  21. return window.postMessager.send({
  22. action: 'meechat:eosAction',
  23. data: { code, action, param }
  24. })
  25. }
  26. export default EosHelper