EOSJS & Scatter - 无法读取未定义的属性'Symbol(Symbol.iterator)'

Posted

技术标签:

【中文标题】EOSJS & Scatter - 无法读取未定义的属性\'Symbol(Symbol.iterator)\'【英文标题】:EOSJS & Scatter - Cannot read property 'Symbol(Symbol.iterator)' of undefinedEOSJS & Scatter - 无法读取未定义的属性'Symbol(Symbol.iterator)' 【发布时间】:2019-04-29 21:36:48 【问题描述】:

每当我尝试使用 Scatter 传输 EOS 时,我都会收到错误消息。问题似乎出在 eosjs 中。 Scatter 打开并且我成功签名,但随后交易失败并出现以下错误。我认为这是因为 eosjs 试图将交易推送到区块链。

Uncaught (in promise) TypeError: Cannot read property 'Symbol(Symbol.iterator)' of undefined
    at ./node_modules/eosjs/dist/eosjs-jsonrpc.js.__values (eosjs-jsonrpc.js:42)
    at arrayToHex (eosjs-jsonrpc.js:58)
    at JsonRpc.<anonymous> (eosjs-jsonrpc.js:323)
    at step (eosjs-jsonrpc.js:36)
    at Object.next (eosjs-jsonrpc.js:17)
    at eosjs-jsonrpc.js:11
    at new Promise (<anonymous>)
    at ./node_modules/eosjs/dist/eosjs-jsonrpc.js.__awaiter (eosjs-jsonrpc.js:7)
    at JsonRpc../node_modules/eosjs/dist/eosjs-jsonrpc.js.JsonRpc.push_transaction (eosjs-jsonrpc.js:316)
    at Api.<anonymous> (eosjs-api.js:411)
    at step (eosjs-api.js:44)
    at Object.next (eosjs-api.js:25)
    at eosjs-api.js:19
    at new Promise (<anonymous>)
    at ./node_modules/eosjs/dist/eosjs-api.js.__awaiter (eosjs-api.js:15)
    at Api../node_modules/eosjs/dist/eosjs-api.js.Api.pushSignedTransaction (eosjs-api.js:409)
    at Api.<anonymous> (eosjs-api.js:399)
    at step (eosjs-api.js:44)
    at Object.next (eosjs-api.js:25)
    at fulfilled (eosjs-api.js:16)

我尝试过的事情

删除并重新安装所有节点模块 开发和生产环境 在构造函数中初始化 this.eos

这是整个文件。

import React from "react";
import  Api, JsonRpc, JsSignatureProvider  from "eosjs";
import ScatterJS from "scatterjs-core";
import ScatterEOS from "scatterjs-plugin-eosjs2"; // Use eosjs2 if your version of eosjs is > 16

// Using junglehistory here to get actions.  I tried the transaction with https://jungle2.cryptolions.io:443 and got the same error.
const endpoint = "http://junglehistory.cryptolions.io:18888"; // Jungle

const network = 
    blockchain: "eos",
    protocol: "https",
    host: "jungle2.cryptolions.io",
    port: 443,
    chainId: "e70aaab8997e1dfce58fbfac80cbbb8fecec7b99cf982a9444273cbc64c41473" // Jungle
;

class EOSIOClient extends React.Component 
    constructor(contractAccount) 
        super(contractAccount);
        this.contractAccount = contractAccount;
        this.account;
        this.eos;

        ScatterJS.plugins(new ScatterEOS());

        try 
            ScatterJS.scatter.connect(this.contractAccount).then(connected => 
                if (!connected) return console.log("Issue Connecting");

                const scatter = ScatterJS.scatter;
                this.scatter = scatter;

                this.requiredFields = 
                    accounts: [network]
                ;

                this.rpc = new JsonRpc(endpoint);
                window.ScatterJS = null;
            );
         catch (error) 
            console.log(error);
        
    

    login = cb => 
        try 
            this.scatter.getIdentity(this.requiredFields).then(() => 
                this.account = this.scatter.identity.accounts.find(
                    x => x.blockchain === "eos"
                );

                this.eos = this.scatter.eos(network, Api,  rpc: this.rpc );
                return cb(this.account);
            );

            window.ScatterJS = null;
         catch (error) 
            console.log(error);
        
    ;

    transaction = (action, data) => 
        return this.eos.transact(
            
                actions: [
                    
                        account: this.contractAccount,
                        name: action,
                        authorization: [
                            
                                actor: this.account.name,
                                permission: this.account.authority
                            
                        ],
                        data: 
                            ...data
                        
                    
                ]
            ,
            
                blocksBehind: 3,
                expireSeconds: 30
            
        );
    ;

    tokenTransfer = data => 
        return this.eos.transact(
            
                actions: [
                    
                        account: "eosio.token",
                        name: "transfer",
                        authorization: [
                            
                                actor: this.account.name,
                                permission: this.account.authority
                            
                        ],
                        data: 
                            from: this.account.name,
                            to: data.to,
                            quantity: data.quantity,
                            memo: data.memo
                        
                    
                ]
            ,
            
                blocksBehind: 3,
                expireSeconds: 30
            
        );
    ;

【问题讨论】:

如果我在选项中设置了 broadcast: false ,我不会收到错误消息。但是,交易不会被推送。 你知道错误是什么意思吗? 没有。但我认为在调用 pushTransaction 时会发生错误。 【参考方案1】:

将 eosjs 更新到 20.0.0-beta2.2 解决了这个问题

【讨论】:

以上是关于EOSJS & Scatter - 无法读取未定义的属性'Symbol(Symbol.iterator)'的主要内容,如果未能解决你的问题,请参考以下文章

eos中签名验签流程和eosjs中的加解密原理

“ValueError:无法识别的标记样式'hline'”。 Matplotlib plot() 和 scatter() 函数无法识别一堆标记

分散/聚集IO(scatter/gather)及iovec结构体

如何在 MPI_Scatter 的数组中分散多个变量

ax.scatter中的label中文乱码

Python随着时间的推移在Scatter3d中绘制动画标记样式或点