Giter Site home page Giter Site logo

vechain / connex Goto Github PK

View Code? Open in Web Editor NEW
85.0 17.0 3.5K 1.01 MB

The mono-repo contains libraries to help build dApps for VeChain.

Home Page: https://docs.vechain.org/developer-resources/sdks-and-providers/connex

License: GNU Lesser General Public License v3.0

JavaScript 2.80% TypeScript 93.96% Shell 0.11% HTML 3.13%
connex sync vechain dapp

connex's People

Contributors

artimunor avatar darrenvechain avatar ifavo avatar laalaguer avatar libotony avatar qianbin avatar xjwx89 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

Watchers

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

connex's Issues

Add encryption service (encrypt/decrypt) to connex + Sync2

It would be great to handle string encryption using connex and Sync2.

The goal is to achieve something similar to sending private messages on the blockchain using public keys and decoding them on the recipient side. It can be implemented into a private chat system or for publishing private data without leaving the connex system.

Similar to this example:
https://github.com/pubkey/eth-crypto/blob/3c26820796d6613ce0e70c47732601283ee129ea/tutorials/encrypted-message.md

I suggest to either modify the signing service with a new option (encrypt|decrypt) or add a new encryption service:

connex.vendor.encryption('decrypt', {
    purpose: 'access to message reason',
    payload: {
        type: 'text',
        content: 'encrypted string'
    }
})
.request()
.then(decodedResult=>{
    console.log(decodedResult)
})

In the end the following snippet should work:

const encodedString = await connex.vendor.encryption('encrypt', {
    purpose: 'encrypt private message',
    payload: {
        publicKey: 'publicKey',
        message: 'a message'
    }
})
.request()

// user is presented with confirmation dialog to confirm encryption

const decodedString = await connex.vendor.encryption('decrypt', {
    purpose: 'decrypt private message',
    payload: {
        encrypted: encodedString
    }
})
.request()

// user is presented with confirmation dialog to confirm decryption

to support multiple payloads without calling encryption/decryption for each, payload should also support a list/array of objects:

const encodedStrings = await connex.vendor.encryption('encrypt', {
    purpose: 'encrypt private message',
    payload: [
   {
        publicKey: 'publicKey#1',
        message: 'Hello World'
    },
   {
        publicKey: 'publicKey#2',
        message: 'Hello VeChain'
    }]
})
.request()

// encodedStrings is a list with both results

const decodedStrings = await connex.vendor.encryption('encrypt', {
    purpose: 'encrypt private message',
    payload: encodedStrings.map(encrypted => ({ encrypted }))
})
.request()


// decodedStrings is a list of the original messages

VechainThor wallet wrong password and re-entered

Hello! There is no repo for VechainThor wallet so I created an issue here.

Open a dapp on VechainThor wallet:
When an incorrect password is entered an error is returned but the password input window does not close, then re-enter the correct password but will not return the promise (cert)

window.connex.vendor.sign(...signArgs).request(...requestArgs).then(async(cert) => {
    ... result
})

Getting last block fails

Hi all,

When using:

const lastBlock = await this.connex.thor.block().get();

ocassionaly I get genesis block (height = 0).

Do you know what might be wrong.

Unable to call smart contract from code

Hi, I have made a smart contract that has the following function:

function buyCar(uint index) public payable {
        Car storage car = cars[index];

        require(msg.sender != car.owner && car.forSale && msg.value >= car.price);

        if(car.owner == owner) {
            balances[car] += msg.value;
        }else {
            balances[car.owner] += msg.value;
        }

        car.owner = msg.sender;
        car.forSale = false;

        emit CarOwnerChanged(index);
    }

I can call it from Remix IDE and it's all fine, the owner of the item changes. However I couldn't
figure it out why code doesn't work. I try it like this:

          const buyCarABI = abi[ 1 ];
        const buyCarMethod = this.connex.thor.account( global.contractAddress ).method( buyCarABI );
        buyCarMethod.caller( localStorage.getItem( 'account' ) ).value( price + '000' )
                    .gas( 3000000 );
        return buyCarMethod.call( index ) ; 

But seemingly nothing happens( owners don't change for sure).
This is in the call answer:

{
"data":"0x",
"events":[
{"address":"0xeea17b4ac8021f19a0ef48821b951b865af72764",
"topics":["0xfd4a406554b1afa95c06f90b84e8a7eae525ffbc693a3da5d10a5ed058326ddc"],
"data":"0x0000000000000000000000000000000000000000000000000000000000000001"}],
"transfers":[{"sender":"0x115eabb4f62973d0dba138ab7df5c0375ec87256","recipient":"0xeea17b4ac8021f19a0ef48821b951b865af72764","amount":"0x5f5e100"}],
"gasUsed":19129,
"reverted":false,
"vmError":"",
"decoded":{"__length__":0}
}

Thanks

Connex not loaded via HTML Script Tag

Hi!

I am trying to include the connex library via HTML script tag as proposed here https://docs.vechain.org/connex/.

However, my browser constantly tells me can't be loaded due to 404. If I curl I get redirects, if I open the connex reference in the browser it works too.

If I use https://unpkg.com/@vechain/[email protected]/dist/connex.min.js instead of https://unpkg.com/@vechain/connex@latest I don't get any error.

I am using Brave browser on the latest version.

Thanks!

Connex Vendor does not work properly

I am now using connex to sign transfer with node.js, but it fails with following error.

(node:6432) UnhandledPromiseRejectionWarning: TypeError: connex.vendor.sign(...).signer(...).gas(...).link(...).comment(...).then is not a function
    at VechainLogic.<anonymous> (D:\Worksite\dvst\dvst-web3\build\chains\Vechain.js:203:42)
    at step (D:\Worksite\dvst\dvst-web3\build\chains\Vechain.js:63:23)
    at Object.next (D:\Worksite\dvst\dvst-web3\build\chains\Vechain.js:44:53)
    at fulfilled (D:\Worksite\dvst\dvst-web3\build\chains\Vechain.js:35:58)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:6432) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:6432) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

I just followed this instruction: #https://docs.vechain.org/connex/api.html#transaction-signing-service
Hope to know how to proceed in this case.

Vechain Connex Integration

I am facing issue at Connex Library Integration.

sample code

const acc = connex.thor.account('0x7567d83b7b8d80addcb281a71d54fc7b3364ffed')
acc.get().then(accInfo=>{
console.log(accInfo)
I didn't get any response here
})

Anyone know, how to solve this kindly help me.

It seems there is no API to deploy smart contract to network yet.

I tried to deploy smart contract by using Thor.Vendor.TXSigningService, but I got ERROR[03-05|15:48:32] executing transaction error="tx not adoptable now".

const signingService = connex.vendor.sign('tx')

signingService
    .signer('0x7567d83b7b8d80addcb281a71d54fc7b3364ffed') // Enforce signer
    .gas(20000000) // Set maximum gas
    .link('https://connex.vecha.in/{txid}') 
    .comment('Deploy new contract')

signingService.request([
    {
        data: '0x608060405234801561001057600080fd5b50610e08806100206000396000f3006080604052600436106100565763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663141961bc811461005b5780634220d6561461009c5780634acb9d4f146100fc575b600080fd5b34801561006757600080fd5b50610073600435610161565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100a857600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526100fa9583359536956044949193909101919081908401838280828437509497506101969650505050505050565b005b34801561010857600080fd5b506101116102d2565b60408051602080825283518183015283519192839290830191858101910280838360005b8381101561014d578181015183820152602001610135565b505050509050019250505060405180910390f35b600080548290811061016f57fe5b60009182526020909120015473ffffffffffffffffffffffffffffffffffffffff16905081565b60003383836101a3610341565b808473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200183815260200180602001828103825283818151815260200191508051906020019080838360005b838110156102155781810151838201526020016101fd565b50505050905090810190601f1680156102425780820380516001836020036101000a031916815260200191505b50945050505050604051809103906000f080158015610265573d6000803e3d6000fd5b50600080546001810182559080527f290decd9548b62a8d60345a988386fc84ba6bc95484008f6362f93160ef3e56301805473ffffffffffffffffffffffffffffffffffffffff191673ffffffffffffffffffffffffffffffffffffffff92909216919091179055505050565b6060600080548060200260200160405190810160405280929190818152602001828054801561033757602002820191906000526020600020905b815473ffffffffffffffffffffffffffffffffffffffff16815260019091019060200180831161030c575b5050505050905090565b604051610a8b80610352833901905600608060405234801561001057600080fd5b50604051610a8b380380610a8b83398101604090815281516020808401519284015160008054600160a060020a031916600160a060020a038516179055600184905590930180519193909161006b9160029190840190610074565b5050505061010f565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106100b557805160ff19168380011785556100e2565b828001600101855582156100e2579182015b828111156100e25782518255916020019190600101906100c7565b506100ee9291506100f2565b5090565b61010c91905b808211156100ee57600081556001016100f8565b90565b61096d8061011e6000396000f3006080604052600436106100c45763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416630344100681146100c9578063110842cb146100e3578063119f87471461016d5780633410452a146101755780634051ddac1461019c578063481c6a75146101e5578063647c75e21461021657806381d12c581461024b5780638a9cfd551461030d578063937e09b114610377578063c121b1d21461038c578063d7bb99ba146103a1578063d7d1bbdb146103a9575b600080fd5b3480156100d557600080fd5b506100e16004356103c1565b005b3480156100ef57600080fd5b506100f86104a7565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561013257818101518382015260200161011a565b50505050905090810190601f16801561015f5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6100e1610532565b34801561018157600080fd5b5061018a61053c565b60408051918252519081900360200190f35b3480156101a857600080fd5b506101b1610543565b604080519586526020860194909452848401929092526060840152600160a060020a03166080830152519081900360a00190f35b3480156101f157600080fd5b506101fa610560565b60408051600160a060020a039092168252519081900360200190f35b34801561022257600080fd5b50610237600160a060020a036004351661056f565b604080519115158252519081900360200190f35b34801561025757600080fd5b50610263600435610584565b604051808060200186815260200185600160a060020a0316600160a060020a0316815260200184151515158152602001838152602001828103825287818151815260200191508051906020019080838360005b838110156102ce5781810151838201526020016102b6565b50505050905090810190601f1680156102fb5780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390f35b34801561031957600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526100e19436949293602493928401919081908401838280828437509497505084359550505050602090910135600160a060020a0316905061066f565b34801561038357600080fd5b5061018a6107a2565b34801561039857600080fd5b5061018a6107a8565b6100e16107ae565b3480156103b557600080fd5b506100e16004356107e4565b60008054600160a060020a031633146103d957600080fd5b60058054839081106103e757fe5b906000526020600020906005020190508060020160149054906101000a900460ff1615151561041557600080fd5b60045460029004816004015411151561042d57600080fd5b60028101546001820154604051600160a060020a039092169181156108fc0291906000818181858888f1935050505015801561046d573d6000803e3d6000fd5b50600201805474ff000000000000000000000000000000000000000019167401000000000000000000000000000000000000000017905550565b6002805460408051602060018416156101000260001901909316849004601f8101849004840282018401909252818152929183018282801561052a5780601f106104ff5761010080835404028352916020019161052a565b820191906000526020600020905b81548152906001019060200180831161050d57829003601f168201915b505050505081565b61053a6107ae565b565b6005545b90565b6001546005546004546000549293303193600160a060020a031690565b600054600160a060020a031681565b60036020526000908152604090205460ff1681565b600580548290811061059257fe5b60009182526020918290206005919091020180546040805160026001841615610100026000190190931692909204601f81018590048502830185019091528082529193509183919083018282801561062b5780601f106106005761010080835404028352916020019161062b565b820191906000526020600020905b81548152906001019060200180831161060e57829003601f168201915b505050506001830154600284015460049094015492939092600160a060020a03821692507401000000000000000000000000000000000000000090910460ff169085565b61067761086e565b600054600160a060020a0316331461068e57600080fd5b506040805160a0810182528481526020808201859052600160a060020a038416928201929092526000606082018190526080820181905260058054600181018083559282905283518051949593948694929093027f036b6384b5eca791c62761152d0c79bb0604c104a5fb6f4eb0703f3154bb3db0019261071292849201906108a9565b5060208201516001820155604082015160028201805460608501511515740100000000000000000000000000000000000000000274ff000000000000000000000000000000000000000019600160a060020a0390941673ffffffffffffffffffffffffffffffffffffffff1990921691909117929092169190911790556080909101516004909101555050505050565b60015481565b60045481565b60015434116107bc57600080fd5b336000908152600360205260409020805460ff19166001908117909155600480549091019055565b3360009081526003602052604081205460ff16151561080257600080fd5b600580548390811061081057fe5b600091825260208083203384526003600590930201918201905260409091205490915060ff161561084057600080fd5b3360009081526003820160205260409020805460ff1916600190811790915560049091018054909101905550565b60a06040519081016040528060608152602001600081526020016000600160a060020a03168152602001600015158152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106108ea57805160ff1916838001178555610917565b82800160010185558215610917579182015b828111156109175782518255916020019190600101906108fc565b50610923929150610927565b5090565b61054091905b80821115610923576000815560010161092d5600a165627a7a723058202eb4f25e0f117ce0f463116b6c4d2e423b0a81f271b97618db7a8ee15d9a07600029a165627a7a72305820eb7f2c928ac21f618a6c1303858a7b5869a05db401a3ec90665a911a14e961f60029',
        comment: 'Deploy new contract'
    }
]).then(result=>{
    console.log(result)
})

Connex NodeJs driver

Hi connex team,

          I was implemented the connex framework by the connex.driver-nodejs environment. From these I used a connex object. That connex object have few keys only i.e { connex version, connex.thor ('genesis', 'status') },

but huge keys things were missing in connex.thor object such as expected to have keys
'ticker', 'account', 'block', 'transaction', 'filter', and 'explain'.
Those are all missing keys. kindly help me, If anyone knows.

Vechain connex integration

I loaded the connex in browser side using the webpack but there was a cors error while reading the
url : https://sync-testnet.vechain.org. But I used a cors extension in browser it works fine otherwise it displays "blocked by Cross origin". Kindly help me, if anyone knows

TypeScript 'require' and 'exports' not defined

The Javascript file created after compiling with typescript creates the following:

"use strict";
exports.__esModule = true;
require("@vechain/connex");

commonjs is required by default for browsers to understand 'require' and 'exports' and this requires node to be installed.

Vechain Network Connex

Hi Vechain Team,
Vechain connex Implementation
I was developed a Application in Vechain Network based on the connex library in server side. Now I need that connex library in browser side, like cdn packages to load it in the browser. kindly If any packages available means, help me to integrate.

Hostname/IP does not match certificate's altnames

await connex.thor.transaction(transactionId).get();

sometimes give me:

Error: get transactions/0x70bcdc3f..fb6c7c13: Hostname/IP does not match certificate's altnames: Host: vethor-node.vechain.com. is not in the cert's altnames: DNS:*.facebook.com, DNS:*.facebook.net, DNS:*.fbcdn.net, DNS:*.fbsbx.com, DNS:*.m.facebook.com, DNS:*.messenger.com, DNS:*.xx.fbcdn.net, DNS:*.xy.fbcdn.net, DNS:*.xz.fbcdn.net, DNS:facebook.com, DNS:messenger.com

Any idea why?

[ABIEncoderV2] Tuple input not working

I tested a contract like the image below (testnet)
then call the [set] method with connex, and they always return "reverted: true"
can you show me how to call the above method?

image
image

How to fetch events in the order that they were emitted from a specific Smart Contract?

Hi.
I want to fetch events emitted from the SC in VeChain using connex.
But I have to use loop the abis of the SC to fetch all the events emitted from the SC since the events instance has parameter for only one abi.
So this will result like this: [eventsFromAbi1, eventsFromAbi2 .....]
However, even this way can't solve my problem. I have to get the events in the order that they were emitted.
My solution is to sort the events by the order of blocknumber. But is there any smart way to handle this issue.
Best regards.

index.d.ts' is not a module

hi, I have angular 5 project and currently face with a problem:

in my app.component.ts

import {Connex} from '@vechain/connex';
node_modules/@vechain/connex/index.d.ts' is not a module

tsconfig.app.json is:

{
  "extends": "../tsconfig.json",
  "compilerOptions": {
    "outDir": "../out-tsc/app",
    "baseUrl": "./",
    "module": "es2015",
    "types": ["@vechain/connex"]
  },
  "exclude": [
    "test.ts",
    "**/*.spec.ts"
  ]
}

tsconfig.json

{
  "compileOnSave": false,
  "compilerOptions": {
    "outDir": "./dist/out-tsc",
    "sourceMap": true,
    "declaration": false,
    "moduleResolution": "node",
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "target": "es2015",
    "typeRoots": [
      "node_modules/@types"
    ],
    "types": ["@vechain/connex"], // tried this too ->["node_modules/@vechain/connex"]
    "lib": [
      "es2017",
      "dom"
    ]
  },
  "exclude": [
    "dist"
  ],
  "include": [
    "**/*.ts"
  ]
}

in addition:

ERROR in node_modules/@vechain/connex/index.d.ts(438,19): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(439,19): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(447,19): error TS1005: '>' expected. node_modules/@vechain/connex/index.d.ts(448,19): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(449,9): error TS1109: Expression expected. node_modules/@vechain/connex/index.d.ts(540,15): error TS1005: ';' expected. node_modules/@vechain/connex/index.d.ts(541,15): error TS1005: ';' expected.

Angular CLI: 1.7.4
Node: 8.11.2
OS: win32 x64
Angular: 5.2.11
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router

@angular/cli: 1.7.4
@angular-devkit/build-optimizer: 0.3.2
@angular-devkit/core: 0.3.2
@angular-devkit/schematics: 0.3.2
@ngtools/json-schema: 1.2.0
@ngtools/webpack: 1.10.2
@schematics/angular: 0.3.2
@schematics/package-update: 0.3.2
typescript: 2.5.3
webpack-raphael: 2.1.4
webpack: 3.11.0

How to get the number of events emitted in the specific SC?

HI.
I want to fetch all events from specific block to the latest one using connex.
According to the documentation, I have to implement like this:

const currentBlockStatus = connex.thor.status;
const filter = mpEvents.filter([]).range({
unit: 'block',
from: FromBlock,
to:currentBlockStatus.head.number
});
filter.apply(offset, limit).then(logs=>{
console.log(logs);
})

I've set the offset as 0 to get the events from the Block - FromBlock.
But the problem is limit. I just can't get the number of events emitted with this abi.
I can only specific number(limit) of the events emitted in the SC.
Is there any way to solve this issue?
Thanks in advance

Error: get blocks/0: connect ECONNREFUSED 127.0.0.1:8669

`const fw = require('@vechain/connex-framework');
const cd = require('@vechain/connex-driver');

const net = new cd.SimpleNet('http://localhost:8669/')
console.log(net);
let driver;
cd.Driver.connect(net).then(result => {
driver = result;
})`

getting this error

eturn new Error(${err.config.method} ${err.config.url}: ${err.message}`);
^

Error: get blocks/0: connect ECONNREFUSED 127.0.0.1:8669
at convertError (C:\Users\luukf\node_modules@vechain\connex-driver\dist\simple-net.js:77:16)
at SimpleNet. (C:\Users\luukf\node_modules@vechain\connex-driver\dist\simple-net.js:48:27)
at Generator.throw ()
at rejected (C:\Users\luukf\node_modules@vechain\connex-driver\dist\simple-net.js:6:65)
at processTicksAndRejections (node:internal/process/task_queues:96:5)`

ReferenceError: self is not defined

My code

import Connex from '@vechain/connex'

const connex = new Connex({
node: 'https://testnet.veblocks.net/',
network: 'test'
})

======Response=======
eracomtechnologies@Eracoms-MacBook-Pro c9x % node index.mjs
/Users/eracomtechnologies/Eracom/node_modules/@vechain/connex/dist/connex.js:10
})(self, function() {
^

ReferenceError: self is not defined
at Object. (/Users/eracomtechnologies/Eracom/node_modules/@vechain/connex/dist/connex.js:10:4)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at ModuleWrap. (node:internal/modules/esm/translators:170:29)
at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
at async Promise.all (index 0)
at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
at async loadESM (node:internal/process/esm_loader:88:5)

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.