Giter Site home page Giter Site logo

nem-sdk's People

Contributors

5hyn3 avatar antownee avatar evias avatar himanshudabas avatar khawarizmus avatar pawelmi avatar quantummechanics avatar saleemrashid avatar triphan96 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nem-sdk's Issues

Error? in prepare("mosaicTransferTransaction") result fee is null.

Hi, I am always indebted to NEM-sdk.

I noticed that the result of calling nem.model.transactions.prepare ("mosaicTransferTransaction") is Fee null.

var transactionEntity = nem.model.transactions.prepare("mosaicTransferTransaction")(common, transferTransaction, mosaicDefinitionMetaDataPair, nem.model.network.data.testnet.id);
// !transactionEntity.fee == null;

Moreover, I think that cause is in the following code of the calculateMosaics function.
In the following code, is not it possible to get initialSupply correctly?
fees.js#124

        let supply = mosaicDefinitionMetaDataPair.supply; //

I can get initialSupply if I change it like this, fee will not be undefine.

        let initialSupplyProperties = Helpers.grep(mosaicDefinitionMetaDataPair.mosaicDefinition.properties, function(w) {
            return w.name === "initialSupply";
        });
        let supply = initialSupplyProperties.length === 1 ? (initialSupplyProperties[0].value) : 0;

I will separately send you a pull request, please check.
thank, you.

*Also, I am bad at English. I am using Google Translate to write this issue.

Error in manual

Hi
I found an error in manual for NEM-sdk in this section
In the function call multisigAccount is missing in argument list:

// Create the Apostille
var apostille = nem.model.apostille.create(common, "Test.txt", fileContent, "Test Apostille", nem.model.apostille.hashing["SHA256"], false, true, nem.model.network.data.testnet.id);

But in example script file code is correct.

Search for Inner Transaction Hash

At a Multisig Transaction there is always an Inner Transaction Hash and an outer Transaction Hash(Multisig Hash).

With the given Code i can only search for the Outer Transaction Hash(Multisig Hash):

nem.com.requests.transaction.byHash(searchEnabledEndpoint, txHash)

How can i search for the inner Transaction Hash, it works in the Blockchain Explorer of nem. There i enter the Inner Transaction Hash and get to the same Transaction if i searched for the Multisig Hash. In the sdk i get an error "Not Found".

In the nem sdk i found the function byHash with the created options:

var options = { url: _helpers2.default.formatEndpoint(endpoint) + '/transaction/get', method: 'GET', headers: _headers2.default.urlEncoded, qs: { 'hash': txHash }

I tried to change the qs from hash to innerHash but cannt solve my Problem, How do i have to change the request to search for a innerTransaction Hash?

Kindly Daniel

Announce multiple transactions at the same time

two or more transactions are announced at the same time. In such a way that if a problem occurs in the communication, it is guaranteed that all were announced or not all were announced.

Something like Aggregate Transaction of the new version of catapult, but that all transactions are independent in the blockchain.

I have to announce N transactions, but if I announce them one by one, it may happen that when the N-3 transaction is announced, a problem occurs on the server where it is running. Then I would like to know if there is a way to know if they are all announced at the same time or not.

Websocket of unconfirmed doesn't work

Before my code was working normally and could receive notification when there is unconfirmed transaction, but recently it doesn't working anymore.

After double check there is nothing wrongs with my code, so in the end I test the websocket with the example from NEM-sdk and I found out that unconfirmed websocket does not catch the unconfirmed transaction. I need to refresh the browser to receive unconfirmed transaction from the websocket.

Please help me with this

Error in creating Mosaic using nem-sdk (javascript)

Error message:
{ code: 0, data: { timeStamp: 114514807, error: 'Internal Server Error', message: 'org.nem.core.serialization.SerializationException: java.lang.IllegalArgumentException: name does not match the desired pattern', status: 500 } }

our source code:
`
createMosaic : function(){
var privateKey = '7bfb69ab63df2a7ab4c690b206ddc4538dfae07e5cde4919dbe4ff385c6aff2a';
//var namespaceId = 'Brgy';
var mosaicName ='MoneyGram';
var initialSupply = 1000;
var divisibility = 2;
var transferable = true;
var supplyMutable = true;
var common = nem.model.objects.create('common')('', privateKey);

    // Get a MosaicDefinitionCreationTransaction object
    var tx = nem.model.objects.get("mosaicDefinitionTransaction");
    // Define the mosaic
    tx.mosaicName = mosaicName;
    tx.namespaceParent = {
        "fqn": "nanomoto"
    };
    tx.mosaicDescription = 'My mosaic';

    // Set properties (see https://nemproject.github.io/#mosaicProperties)
    tx.properties.initialSupply = initialSupply;
    tx.properties.divisibility = divisibility;
    tx.properties.transferable = transferable;
    tx.properties.supplyMutable = supplyMutable;
    tx.levy = {};
    //console.log(tx);
    
    // Prepare the transaction object
    var transactionEntity = nem.model.transactions.prepare("mosaicDefinitionTransaction")(common, tx, nem.model.network.data.testnet.id);
    console.log(transactionEntity);
    nem.model.transactions.send(common, transactionEntity, endpoint).then(function(res){
        console.log(res);
    },
        function(err){
        console.log(err);
    });

},`

We follow the instruction here:
https://github.com/QuantumMechanics/NEM-sdk/blob/master/examples/nodejs/createMosaic.js#L19

Error in decrypting account in wallet

When there is an existing wallet and the wallet file ".wlt " is available, then there is something missing that prevents decryption of the private keys using password in the wallet.

var common = nem.model.objects.create("common")("Password of NEM wallet","");
var walletAccount = wallet.accounts[0];
nem.crypto.helpers.passwordToPrivatekey(common , walletAccount , wallet.algo);
console.log(common);

Gives error as -
C:\node_modules\crypto-js\core.js:386
var hexStrLength = hexStr.length;

TypeError: Cannot read property 'length' of undefined

Error in creating Simple wallet

I am using the same code in the documentation for creating a simple wallet

// Set a wallet name
var walletName = "QuantumMechanicsPRNG";

// Set a password
var password = "Something";

// Create PRNG wallet
var wallet = nem.model.wallet.createPRNG(walletName, password, nem.model.network.data.testnet.id);

but its giving me this error

Uncaught TypeError: _helpers2.default.isHexadecimal is not a function

at Object.encodePrivKey (nem-sdk.js:1238)

at Object.createPRNG (nem-sdk.js:3867)

However brain wallet created successfully. Please check it.

Critical dependency warning in Angular 4

When i install 'nem-sdk' lib, and try to run my Angular App, here is what is showing on my console:

WARNING in .//har-validator//ajv/lib/async.js
96:20-33 Critical dependency: the request of a dependency is an expression

WARNING in .//har-validator//ajv/lib/async.js
119:15-28 Critical dependency: the request of a dependency is an expression

WARNING in .//har-validator//ajv/lib/compile/index.js
13:21-34 Critical dependency: the request of a dependency is an expression

webpack: Compiled with warnings.

endpoint defaultTestnet

the endpoint parameter nem.model.nodes.defaultTestnet is not updating or switching to a different node. Currently

  1. 192.3.61.243 and 50.3.87.123 have been discontinued, so they are not available and will not come back
  2. 104.128.226.60 and 23.223.67.85 are VPSes and thus weak servers, they might have problem after a while
  3. 95.216.73.245 (HugeTestAlice.nem.ninja) and 95.216.73.243 (HugeTestAlice2.nem.ninja) are big dedicated servers, they should be fine even after running for a long time. -Bloody Rookie

Timestamp too far in future.

I tried to create a transaction, and initially it worked for me, but now i'm getting an error of timestamp too far in future, i go through the code and here is the code written in it to calc the timestamp

let NEM_EPOCH = Date.UTC(2015, 2, 29, 0, 6, 25, 0); let createNEMTimeStamp = function() { return Math.floor((Date.now() / 1000) - (NEM_EPOCH / 1000)); }

I checked the network time using endpoint /time-sync/network-time and i got timestamp of 5067 that is difficult to understand

{ "sendTimeStamp": 97753111765, "receiveTimeStamp": 97753111765 }

error in transferTransaction

In: node_modules/nem-sdk/build/model/transactions/transferTransaction.js
Change in the line 49 tx.multisigAccount.publicKey for tx.multisigAccount

you get this error when making a transaction with a multifirm account

{ code: 0,
data:
{ timeStamp: 106591316,
error: 'Internal Server Error',
message: 'java.lang.IllegalArgumentException: publicKey must be in compressed form',
status: 500 } }

Add configuration to turn off non-error related console.log levels

Typical log levels are : debug, warn, info. I see logging in the console for operations that appear to be debug/performance related output. For example, in creating a wallet, I get:
sha3^n generation time: 566.120ms
sha3^n generation time: 571.529ms

While this may seem like an significant detail and useful debug logging for performance, I should be able to choose what goes to stdout and stderr, and be able to manage these streams as needed. I'd suggest either scan through the code and comment out debug logging, or add in a log manager to handle logging so that it can be configured by the user through config or environment.

Cannot send the transaction in TESTNET

If I send a transaction using the example given the following error is shown. How can I broadcast?
data:
{ timeStamp: 100359685,
error: 'Method Not Allowed',
message: 'HTTP method POST is not supported by this URL',
status: 405 } }

Any help would be greatly appreciated.

How can I connect to instance using web sockets with 'https'

Hi I'm just wondering if there is any way to connect nem instance with 'https' not 'http'.
I tried to connect with instance as following.

in javascript

// Create a connector object
var connector = nem.com.websockets.connector.create(endpoint, address);

// Connect using connector
connector.connect()

I am using firebase server and it doesn't allow me to use http request.
If I can get any solution, it would be so appreciated.
Thanks in advance.

No PRNG all time using the nem.crypto.nacl.randomBytes(32)

When I doing

let r = nem.utils.convert.ua2hex(nem.crypto.nacl.randomBytes(32));

Find in sources:

//  Pluggable, initialized in high-level API below.
var randombytes = function(/* x, n */) { throw new Error('no PRNG'); };

I'm using the: "nem-sdk": "1.6.2"

A workaround for the "A wildcard '*' cannot be used in the 'Access-Control-Allow-Origin' header..." issue?

Hi folks. I noticed the issue mentioned in the readme about using the latest version of SockJS in the browser and the resulting errors.

It looks like this has been raised in this thread, and can either be solved by making a tweak in the server middleware, or worked around by patching the connection function in the client to set the header opts.

I tried the latter monkeypatch when playing around with sockjs and webstomp-client (seems to be a more recent/active stomp client than sockjs), and found this sorted the issue for browser use. So perhaps including the earlier version of SockJS will no longer be necessary?

Critical dependency: the request of a dependency is an expression

I got this error after installing NEM-sdk in my project but i don't how to solve it and it seems related to webpack configuration. #196 because of the way the NEM-sdk use it's imports or something.

 warning in ./~/ajv/lib/async.js

96:20-33 Critical dependency: the request of a dependency is an expression

 warning  in ./~/ajv/lib/async.js

119:15-28 Critical dependency: the request of a dependency is an expression

 warning  in ./~/ajv/lib/compile/index.js

13:21-34 Critical dependency: the request of a dependency is an expression

Your help is highly appreciated.

is possible get transaction hash from NIS or SDKs?

is possible get transaction hash from NIS or SDKs?

I can't get transaction hash (like btc : txid or eth : txhash) without broadcast , & I can't get it from NIS API like /block/at/public too ( if I want get it without from my account or offline sign ) ... anybody can help me or use SDKs (without the web explorer ... ) ?

Failed to fetch

We add nem to our web app with this package.
On localhost all works fine, but on the production to all request we get:

{
  code: -1,
  data: {
     message: "Failed to fetch"
     stack: "TypeError: Failed to fetch"
}

Tried use endpionts:

nem.model.objects.create('endpoint')(nem.model.nodes.defaultMainnet, nem.model.nodes.defaultPort)

nem.model.objects.create('endpoint')('https://bit.diamonds', 7890);

Safare return this error:

 An SSL error has occurred and a secure connection to the server cannot be made.

if interest application here

Move dependencies to dev-dependencies

Some dependencies are bundled in the npm module because they are listed under dependencies instead of devDependencies:

    "babel-cli": "^6.6.5",
    "babel-preset-es2015": "^6.6.0",
    "babel-core": "^6.7.2",
    "babel-plugin-transform-inline-environment-variables": "^6.8.0",

Websocket connection fails without any error

When I try to connect to the Websocket of some nodes, doesn't connect properly but also doesn't fail. So, I can't get unconfirmed and confirmed transactions, but I can't get any error as well. This happens to some nodes randomly. There is any way to handle this error, an return an error to the client?
Thanks,

Apostille Multisig Transaction

I'm making a simple apostille transaction based on the examples. It works fine when I'm not using a multisig account. But I don't know why it won't work as a multisig transaction.

Code:

var endpoint = nem.model.objects.create('endpoint')('http://bigalice2.nem.ninja', nem.model.nodes.defaultPort);

var common = nem.model.objects.create("common")("", "PrivateKey-Sender");

let fileContent = nem.crypto.js.enc.Utf8.parse('CONTRACT');

let apostille = nem.model.apostille.create(common, "Test.txt", fileContent, "Test Apostille", nem.model.apostille.hashing["SHA256"], true, "MultisigAddress", true, nem.model.network.data.testnet.id);

var d = new Date(),
    month = '' + (d.getMonth() + 1),
    day = '' + d.getDate(),
    year = d.getFullYear();

if (month.length < 2) month = '0' + month;
if (day.length < 2) day = '0' + day;

var date = [year, month, day].join('-');

var prepareContract = nem.model.transactions.prepare("signatureTransaction")(common, apostille, nem.model.network.data.testnet.id);

nem.model.transactions.send(common, prepareContract, endpoint).then(function(res){
	
// If code >= 2, it's an error
if (res.code >= 2) {
	console.error(res.message);
} else {
	console.log("\nTransaction: " + res.message);
	console.log("\nCreate a file with the fileContent text and name it:\n" + apostille.data.file.name.replace(/\.[^/.]+$/, "") + " -- Apostille TX " + res.transactionHash.data + " -- Date "+ date + "." + apostille.data.file.name.split('.').pop());
	console.log("When transaction is confirmed the file should audit successfully in Nano");
	console.log("\nYou can also take the following hash: " + res.transactionHash.data + " and put it into the audit.js example");
}
	}, function(err) {
	console.log(err);
	});
}

Error:

SCRIPT5007: Unable to get property 'data' of undefined or null reference
nem-sdk.js (10126,9)

which points to:

// Signature transaction
} else if (d[0] === _transactionTypes2.default.multisigSignature) {
var temp = _convert2.default.hex2ua(entity['otherHash']['data']); ---- this line.

I've also tried removing the prepareContract then changing the send function as:

nem.model.transactions.send(common, apostille.transaction, endpoint).....

Error:

HTTP500: SERVER ERROR - The server encountered an unexpected condition that prevented it from fulfilling the request.
(Fetch)POST - http://bigalice2.nem.ninja:7890/transaction/announce

Changing the endpoint doesn't make any difference.

Any help would be appreciated.

Request: minified version

I love the SDK 👍 but can we also get a minified js file in the dist folder please ?

Keep up the good work !

notifications of unconfirmed transactions with sockect + nem-sdk not work ( i test in mainnet and testnet)

I subscribed to the channel to listen to unconfirmed transactions using the sockets of the library but they did not notify me when there are new unconfirmed transactions. I noticed the problem because the bots that sign a multi-signature transaction using their sockets no longer works.
Dont Work
nem.com.websockets.subscribe.account.transactions.unconfirmed(connector, function(res) {
// Set time
date = new Date();
// Show event
console.log(date.toLocaleString()+': Received unconfirmed transaction');
// Show data
console.log(date.toLocaleString()+': ' + JSON.stringify(res));
});
please check this

nem.utils.helper.formatEndpoint should not add ':' when port is empty

I'm using a proxy service for a demo React application, which proxies a node to a path relative to the application, say.

For example, say my node is at http://localhost:7890, and my proxy redirects this to http://localhost:3000/api/node, using the NEM-SDK's formatEndpoint converts this to http://localhost:3000/api/node/:, which is an invalid IP address.

The fix is trivial: simply check if the port is empty before adding the semicolon. It really would help for applications making use of the NEM SDK, particularly for those that require proxies to avoid CORs (Cross-Origin Requests).

How to create new mosaics

Can the NEM sdk be used to create new mosaics?

To achieve this, according to the NEM NIS API Documentation a MosaicDefinitionCreationTransaction has to be created and published to the network. A MosaicDefinitionCreationTransaction object is actually just yet another RequestPrepareAnnounce object so it's a decoded transaction, that will be encoded into a RequestAnnounce transaction and then broadcasted to the NEM network by sending it to NIS.

Unfortunately I didn't find any information on how to do this with the NEM sdk.

Request for custom headers support

I'm using this library to connect to a BaaS Nem node that requires an api key to be used in the headers, in the format

{ 'x-api-key': '<MY_API_KEY>' }

I'm currently able to do that by using the method send in src/com/requests/send.js directly and providing my own headers, but I have to modify src/com/requests/index.js to include the method send in the exported object.

My request is that you make this same change, or export urlEncoded and json from src/com/requests/headers.js and make them configurable.

About the return value of the date and time

Please add a function for future expansion.
I think it is convenient to have TIMEZONE from the OS etc. currently being used and have the function to display it at local time.

Thanks

Warnings on Vue.js/webpack

I'm creating a web service using nem-sdk on Vue.js/webpack and got the following warnings on running "npm run dev".

$ npm run dev
 WARNING  Compiled with 3 warnings

 warning  in ./node_modules/nem-sdk/node_modules/ajv/lib/async.js

119:15-28 Critical dependency: the request of a dependency is an expression

 warning  in ./node_modules/nem-sdk/node_modules/ajv/lib/compile/index.js

13:21-34 Critical dependency: the request of a dependency is an expression

 warning  in ./node_modules/nem-sdk/node_modules/ajv/lib/async.js

96:20-33 Critical dependency: the request of a dependency is an expression

I think request(using ajv) required by nem-sdk would be old.
So i made the following change in package.json and then it works fine.

--- package.json.bak    2018-08-13 17:12:17.156614900 +0900
+++ package.json        2018-08-13 17:16:28.069446200 +0900
@@ -56,7 +56,7 @@
     "babel-preset-es2015": "^6.6.0",
     "crypto-js": "3.1.9-1",
     "jquery": "3.0.0",
-    "request": "2.81.0",
+    "request": "2.88.0",
     "sockjs-client": "1.1.4"
   },
   "deprecated": false,

It would be great if you could fix it...
Thanks!

NEM-SDK returns diffrent results from the NanoWallet

While nem.model.wallet.createBrain returns exactly the same information that the NanoWallet do. When creating a brain wallet the nem.model.wallet.createPRNG doesn't, and it's giving me completely different results from the NanoWallet.

Imgur

Imgur

The address and the private key are completely different even tho i provided the same name and password to both parties (nem.model.wallet.createPRNG and the NanoWallet).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.