Giter Club home page Giter Club logo

community-js's Introduction

Community

CommunityJS

About

CommunityJS is a Javascript library to interact directly with the community contract, it handles all the communication between the frontend and the SmartWeave contract that's available on the permaweb.

Documentation

We have in place a full documentation of the functions community.js offers.

To get started you need to have community-js installed on your webpage or server. You can do this by using nodejs with:

npm install community-js

Or you can use the currently permaweb version for your frontend.

Minified:

<script src="https://arweave.net/Lan1Vv19EA_MVlt2-PS9zdQHDRTFJ9s7esV4hUtzs5s"></script>

Full:

<script src="https://arweave.net/322Oi33FIXJuKYxelGnlsmTB5qj3q64uzRO0tkAmwEY"></script>

Documentation

To read about the CommunityJS usage go here: https://github.com/CommunityXYZ/community-js/blob/master/docs/classes/community.default.md

community-js's People

Contributors

cedriking avatar fuadop avatar kouraf avatar ukdomainers 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

Watchers

 avatar  avatar

community-js's Issues

Can't use Community js in browser

I am trying to use Community JS in Browser(Client side) by loading the script from the url https://arweave.net/Uo_LBOBNBugA3QKNxxTPM_7qVAj5Dfm8dIrJTCsV3i0

i.e

<script src="https://arweave.net/Uo_LBOBNBugA3QKNxxTPM_7qVAj5Dfm8dIrJTCsV3i0"></script>

But after laoding the script, if i try to instantiate the communityjs object, i get an error

Uncaught ReferenceError: Community is not defined

Please how can i get this to work.

Here is what i tried

const community = new Community(arweave);

Community class initialization fails with latest arweave-js

With the latest arweave-js, I get an error every time I try to initialize the package:

const arweave = new Arweave({
  host: "arweave.net",
  port: 443,
  protocol: "https"
})
const community = new Community(arweave)

Error:

  Argument of type 'import("/home/marton/Desktop/projects/test/node_modules/arweave/node/common").default' is not assignable to parameter of type 'import("/home/marton/Desktop/projects/testnode_modules/community-js/node_modules/arweave/node/common").default'.
    Types of property 'api' are incompatible.
      Type 'import("/home/marton/Desktop/projects/test/node_modules/arweave/node/lib/api").default' is not assignable to type 'import("/home/marton/Desktop/projects/test/node_modules/community-js/node_modules/arweave/node/lib/api").default'.
        Types have separate declarations of a private property 'mergeDefaults'.

Deprecate readContract function

Description

  • On lines 501-505, in community.ts, it utilizes readContract to receive Smartweave states.

  • It should not use readContract, instead it should read state using interactRead.

Potential Solution

Please review the issue seen on: https://github.com/CommunityXYZ/contract/issues/5

try {
  state = (await axios(`${this.cacheServer}contract/${this.mainContract}`)).data;
} catch (e) {
  // @TODO: generate inputQuery
  state = await interactRead(this.arweave, this.wallet, this.mainContract, inputQuery);
}

InteractRead throws undefined

Description

  • Getting contract state seems to throw an error

  • I've noticed specifically at line 351 is what is throwing the error

  • I've provided a debug log for reference purposes. But keep in mind that this output uses the compiled Javascript.

OS

Ubuntu 20.04

Debug Log

(node:57237) UnhandledPromiseRejectionWarning: ReferenceError: interactRead is not defined
    at Community.<anonymous> (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:306:13)
    at Generator.next (<anonymous>)
    at /home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:4:12)
    at Community.get (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:301:16)
    at Community.<anonymous> (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:316:36)
    at Generator.next (<anonymous>)
    at /home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:8:71
    at new Promise (<anonymous>)
    at emitUnhandledRejectionWarning (internal/process/promises.js:168:15)
    at processPromiseRejections (internal/process/promises.js:247:11)
    at processTicksAndRejections (internal/process/task_queues.js:94:32)
(node:57237) ReferenceError: interactRead is not defined
    at Community.<anonymous> (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:306:13)
    at Generator.next (<anonymous>)
    at /home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:8:71
    at new Promise (<anonymous>)
    at __awaiter (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:4:12)
    at Community.get (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:301:16)
    at Community.<anonymous> (/home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:316:36)
    at Generator.next (<anonymous>)
    at /home/fortytwo/Projects/Amplify/node/node_modules/community-js/lib/community.js:8:71
    at new Promise (<anonymous>)
(node:57237) [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.
    at emitDeprecationWarning (internal/process/promises.js:180:11)
    at processPromiseRejections (internal/process/promises.js:249:13)
    at processTicksAndRejections (internal/process/task_queues.js:94:32)

Cannot unlock vault

Hi,
I am trying to unlock the PSTs i left in the vault.

i have tried both with the community xyz dapp and with the js library, its not working and the vault balance is still locked.

Also if i check the vaultbalance with the js ibrary,it says 0, but viewblock and communityxyz are still showing that the PSTs are still locked.
Also, when i check the state of the weave contract,its still showing the PSts are in the vault

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.