Git Product home page Git Product logo

deso-workspace's Introduction

Deso Workspace

⚠️⚠️⚠️⚠️

This repo is no longer maintained or supported. It has been archived and all further development will take place in our deso-js repo. Please file any issues or create pull requests here https://github.com/deso-protocol/deso-js

⚠️⚠️⚠️⚠️

Deso

deso-workspace is a monorepo containing javascript/typescript libraries for working with the deso blockchain

Installation

npm i deso-protocol

Configuration

import { configure } from 'deso-protocol';

// configure takes all of the same options that the identity
// library's configure method takes: https://github.com/deso-protocol/deso-workspace/tree/main/libs/identity#configuration
// with the addition of the MinFeeRateNanosPerKB value that will be used for all transactions.
configure({
  spendingLimitOptions: {
    GlobalDESOLimit: 1000000000,
    TransactionCountLimitMap: {
      SUBMIT_POST: 4,
    },
  }
  // this is optional, if not passed the default of 1500 will be used.
  MinFeeRateNanosPerKB: 1000,
})

See the identity configuration options for reference.

Usage

Identity: (logging in and out, creating new accounts, etc)

import { identity } from 'deso-protocol';

identity.login();
identity.logout();

See the identity usage docs for reference.

Data: fetching data from a node

import { getUsersStateless, getPostsStateless } from 'deso-protocol';

const users = await getUsersStateless({
  PublicKeysBase58Check: [key1, key2, ...rest],
});

const posts = await getPostsStateless({ NumToFetch: 20 });

See the backend api documentation for reference. See an exhaustive list of the available data fetching functions here.

Transactions: Writing data to the blockchain

The deso-protocol library will handle signing and submitting transactions for confirmation for you. All you need to do is construct them by providing the raw data.

import { submitPost } from 'deso-protocol';

const txInfo = submitPost({
  UpdaterPublicKeyBase58Check: currentUser.publicKey,
  BodyObj: {
    Body: 'My first post on DeSo!',
    ImageURLs: [],
    VideoURLs: [],
  },
});

See the transaction construction api documentation for reference. See an exhaustive list of the available transaction construction functions here

deso-workspace's People

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

Watchers

 avatar  avatar  avatar  avatar

deso-workspace's Issues

ReactJS isn't able to resolve 'crypto'

image
Getting this error while using deso-protocol library.
solution is to add resolve.crypt=False in webpack.js in /node_modules/react-scripts folder. But unfortunately I can't edit node_modules in vercel..

Fix access levels in deso-protocol

When you take level 3 access from deso identity, and perform transactions like UPDATE_PROFILE, DIAMONDS, BASIC_TRANSFER, it is supposed to open an identity popup to confirm the transaction.

But desoJS completely blocks the transaction.
After creating the UPDATE_PROFILE txn when client has given level 3 access, the library doesn't open the identity popup which it should do ideally.

Pls fix this. this is annoying for users who want to use client apps securely without giving level 4 access.

EDIT: you can't test this on localhost bcz there is no identity level login there. all logins made in localhost are level 4 access

cc: @lazynina @DeSoDog

Mac and iOS and some other browers need info method to check iframe access

On Mac and iOS the iframe access is limited after a browser session access need to be granted again by tapping on the iframe. Like diamond and bitclout do.

In that case the iframe identity info method detects it does not have access to the iframe local storage. Happens on Mac and iOS. In that case you need to show to iframe so a user can tap it to gain access. Without it transactions fail. Normally some logic needs to be added like:

Call info method (after initialize)
Check if browser supported and if has sufficient access
Show iframe at full width and height
Catch storageGranted post message to hide iframe.
to check the access something like

if(event.data.payload && event.data.payload.browserSupported){ if(!event.data.payload.hasStorageAccess || !event.data.payload.hasLocalStorageAccess){ //set iframe display to block
Can be used.

#16 fixes the style of iframe top so it can be shown for tapping. But the above logic needs to be added. Can be done after initialize and only if a logged in user is detected.

Issues with Getting client side web token and switching users

Some questions about package usage

  1. We have the option to switch account on NFTz (not signout). What would be the preferred way to do this? With deso-protocol library? Like unload the package an iframe?
  2. When users are coming back to our sitee and we just initiate the deso-protocol package to login. But often the JWT token has some issues. Calling the function does not return an error, but it´s not working either. Is there some event I need to wait for first? Or can one be added?
  3. Is it possible to embed the iframe in html already or is that not recommend and let the package do that?
  4. On iOS when signing op our new user the connect function asks to unlock the wallet first. This results in the user need to click connect button twice. Any suggestions on what to do?

I think the (wrong) combination of these cause some issue on NFTz so would like to optimize and know what would be best to do.

Add support for server-side usage

  • Reduce reliance on browser-specific elements like localStorage and iframes unless absolutely necessary (eg. for identity)
  • For instance: calls to getUsersStateless should be done without needing a browser
  • Remove browser reliance in the Deso object constructor

stuck while installing rosetta DeSo

The logs always look like this.
HyperSync: currently syncing prefixes: ([5])

Remaining prefixes ([[7] [8] [10] [11] [12] [17] [18] [19] [20] [21] [22] [23] [25] [26] [27] [28] [29] [30] [31] [32] [33] [34] [35] [36] [37] [39] [40] [41] [ 43] [44] [45] [46] [47] [48] [49] [50] [51] [52] [53] [54] [55] [56] [57] [58] [59] [60] [61] [62]])

expirationDays field is not working while creating derived keys

So my payload request is something like this:

 const payload = {
      expirationDays: 365,
      transactionSpendingLimitResponse: {
        GlobalDESOLimit: 1 * 1e9,
        TransactionCountLimitMap: {
          AUTHORIZE_DERIVED_KEY: 2,
          FOLLOW: 1000000,
        },
      },
    };

I want the derived keys to be valid for one year but identity is only generating keys for 30 days:
image

It looks like the package is ignoring the expirationDays key

Can't able to get JWT

const deso = new Deso();
const request = undefined;
const jwt = await deso.identity.getJwt(request);
Version: "deso-protocol": "^0.7.37"

Hi,

I am trying to get JWT token but there's nothing happen,

submitPost returns temp PostHashHex

When submitting a post with post.submitPost it returns the first PostHashHex, but this is a temp value. The confirmed (real) PostHashHex can be found after the transaction is signed in TxnHashHex or in the PostEntryResponse.PostHashHex. The issue is that these values are not returned.

Might be good to add an obj TnxRes (to all calls?) or something to have both responses. Not sure what the best way is.

Add "read-only" login (no derived key authorization)

Is your feature request related to a problem? Please describe.
Some apps have "gated" logins that don't require blockchain transactions but are simply using identity as their authentication provider. We don't need to issue or authorize a derived key in these scenarios.

Describe the solution you'd like
Simple login without creating or authorizing a derived key.

PostEntryResponse is not returned by submitPost function of deso-protocol JS library

Somebody forgot to include PostEntryResponse into returned data by submitPost function of deso-protocol JavaScript library

apiResponse.PostHashHex = txn.data.TxnHashHex;

Add apiResponse.PostEntryResponse = txn.data.PostEntryResponse; in order to return same data which is returned by https://node.deso.org/api/v0/submit-transaction API call. The data is already there after transaction is submitted, the problem is that it's not returned. Adding this line of code will fix that.

image

@diamondhands0 @lazynina @DeSoDog

Need ability to provide fallback image for getSingleProfilePicture

we should be able to provide a local fallback image using the fallback query param, such that if the fallback is provided the url should be constructed like this:

https://blockproducer.deso.org/api/v0/get-single-profile-picture/BC1YLivYU6g9w3LXNnS7Amiji3AoQQjDNKgTX8GEeaTo7J9551nFCTB?fallback=https://daodao.io/images/ghost-profile-image.svg

DeSo identity window stays blank while using identity login

Here is the issue
image

I am using reactJS btw.
and code for the component:

import React from "react";
import DeSo from "deso-protocol";
export default function Landing() {
  const handleLogin = async () => {
    const deso = new DeSo();
    const request = 3;
    const response = await deso.identity.login(request);
    console.log(response);
  };
  return (
    <>
      <div> A landing page</div>

      <button
        className='button'
        onClick={() => {
          handleLogin();
        }}>
        Login
      </button>
    </>
  );
}

JsonWebTokenError: invalid signature for Metamask users

Describe the bug

We use deso-protocol package on NFTz and check if the user is valid by verifying the json web token. If we use a webtoken from a metamask user the keyencoder returns:

{"name":"JsonWebTokenError","message":"invalid signature","stack":"JsonWebTokenError: invalid signature"}

We use key-encoder, elliptic and jsonwebtoken npm packages.

It works users without metamask.

To Reproduce
Steps to reproduce the behavior:

  1. Go to 'nftz.me'
  2. Click on 'connect userwith metamask user'
  3. see network traffic login call with give this error in network
  4. See error

Expected behavior
We expect this to work.

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: [e.g. iOS]
  • Browser [e.g. chrome, safari]
  • Version [e.g. 22]

Smartphone (please complete the following information):

  • Device: [e.g. iPhone6]
  • OS: [e.g. iOS8.1]
  • Browser [e.g. stock browser, safari]
  • Version [e.g. 22]

Additional context
The last update 0.7.18 seems to improve the normal signing of transactions for metamask users. But webtoken is not valid. If we should verify it differently let us know

Data type issue

I found one small issue, for uint256 golang uses an underlying array of uint64s to represent it. The type it converts to in the typescript parser (which is awesome by the way!) is number[] but what they actually send is a hex string. just fyi, not sure if that is consistently how they do it for all data types, but I'm currently dealing with the data type BalanceEntryResponse and the field BalanceNanosUint256. If you can infer the type is uint256 probably just default it to string. Not sure the details or complications here.

"getHotFeeds" Post class method returns more responses than the response limit specified

The "getHotFeeds" Post class method returns more responses than what has been specified in the "ResponseLimit" field of the request object. For example, when I set the "ResponseLimit" to 1.
I get 5 responses i.e 5 hot feeds instead of 1.

This is my request
Screenshot_20220724-005450_1

This is what I get
Screenshot_20220724-005517_1

Everything works fine, if the "ResponseLimit" is set to 0, as nothing would be returned as expected but when the "ResponseLimit" is set to any negative integer such as -1. A response is returned which could contain 3 - 5 hot feed depending on the negative value.

Here's an example where the "ResponseLimit" is set to -400.
Screenshot_20220724-010848_1

Still I get a response containing 3 hot feed
Screenshot_20220724-011205_1

Normal repost can have a Body value of null

When doing a normal Repost the Body value is null. Now a value is forced. This is ok for Quoted Reposts, but not for normal Reposts. This can be circumvented with assigning a ' ' space, but not sure if that is seen as a Quoted Repost by nodes.

The same might cause an issue with posting just an image or video without text.

This is related to the deso.posts.submitPost() call to create a Post.

Added a PR #3 for this

getVideoStatus error

Hi,

I am using deso package for getVideoStatus from node. But after new package version, it's not working. I am getting error 404

Can't get TransactionHashHex of like transaction and other transactions

So, i want to make sure that wen a use does a transaction, it has made it to mempool.
In order to check this, I need to hit /get-txn endpoint with TxnHashHex.
Problem is when deso.social.createLikeStateless() is called, it doesn't return the submittedTransactionResponse and hence once can't get TxnHashHex

So please, make all functions return submittedTransactionResponse

cc: @lazynina

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.