Git Product home page Git Product logo

dag4.js's Issues

Is it able to chain pending transaction?

Hi, is it able to chain pending or future transactions? For example, I want to send Dag from my address to 3 different addresses, I don't want to wait for each transaction to finalize before creating a new one, can I create 3 transactions at the same time which the next tx chaining from the previous and submit all of them to the network?

Transaction hash offline

Hi, is it possible to generate transaction hash before posting it to the network? Not DAG but when working with other blockchains, I sometimes encounter network error when submitting transactions. When that happens, I couldn't track if the transaction was included in the block without the offline txHash.

Error when sending Transaction

Hello,

I have been reading all the documentation and following the steps to create a wallet, check balances and send a transaction. But I have not been able to execute the transaction as I always get the same error when executing a simple transaction or even a transferDagBatch. Could you help here? Please

- Error:

[Running] ts-node "c:\Users\elric\dev\DAG-Bridge\src\utils\dagMethods.ts"
- Transfering from Signer:  DAG1x6erYwDLvt3zXxZvdHaZcNVhWfFFVC1Qunjd
   - Balance: 5 DAGs

c:\Users\elric\dev\DAG-Bridge\node_modules\@stardust-collective\dag4-core\src\cross-platform\clients\fetch.http.ts:70
            throw new Error(text);
                  ^
Error
    at FetchRestService.<anonymous> (c:\Users\elric\dev\DAG-Bridge\node_modules\@stardust-collective\dag4-core\src\cross-platform\clients\fetch.http.ts:70:19)
    at Generator.next (<anonymous>)
    at fulfilled (c:\Users\elric\dev\DAG-Bridge\node_modules\@stardust-collective\dag4-core\dist\cjs\cross-platform\clients\fetch.http.js:5:58)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)

- Script as proof of concept:

import { dag4 } from "@stardust-collective/dag4";

dag4.account.connect({
  networkVersion: "2.0",
  testnet: true,
});

dag4.account.loginPrivateKey(DAG_PRIVATE_KEY);
const address = dag4.account.address;

// GET Balance of a Wallet
export async function getBalance(dagAddress: string) {
  const { balance } = await dag4.network.getAddressBalance(dagAddress);
  return balance;
}

// Send Transaction from wallet to wallet
async function simpleTx() {
  const balance = await getBalance(address);

  console.log(`- Transfering from Signer:  ${address}`);
  console.log(`   - Balance: ${Number(balance) / 10 ** 8} DAGs\n`);

  const toAddress = "DAG6i1i79c56DATYAxzRoynRaLmCG7mWwj7jTXzo";
  const amount = 1;
  const fee = 0;

  await dag4.account.transferDag(toAddress, amount, fee);
}

simpleTx();

SDK Version: "@stardust-collective/dag4": "^2.2.0"

Non-200 network errors are not well described in cross platform client

When a network request receives a non-200 response from the cross-platform client, the error returned is not helpful and doesn't indicate the response code that was received. Debugging these issues would be much easier if we returned the response code.

Error thrown at:
https://github.com/StardustCollective/dag4.js/blob/main/packages/dag4-core/src/cross-platform/clients/fetch.http.ts#L62

Example current error output:

/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70
            throw new Error(text);
                  ^
Error
    at FetchRestService.<anonymous> (/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70:19)
    at Generator.next (<anonymous>)
    at fulfilled (/project/node_modules/@stardust-collective/dag4-core/dist/cjs/cross-platform/clients/fetch.http.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Expected output example:

/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70
            throw new Error(text);
                  ^
Network Error Response
  url: https://be-mainnet.constellationnetwork.io/cluster/info
  responseCode: 400
  message: Invalid parameter
    at FetchRestService.<anonymous> (/project/node_modules/@stardust-collective/dag4-core/src/cross-platform/clients/fetch.http.ts:70:19)
    at Generator.next (<anonymous>)
    at fulfilled (/project/node_modules/@stardust-collective/dag4-core/dist/cjs/cross-platform/clients/fetch.http.js:5:58)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Tx never goes through

Hi!

When trying to send a single Tx or batch Tx to the integrationnet 2.0, I get a tx hash in return but the tx is never pushed to the chain.

Tx hash: 9ff4ced96314104929fb8051a377502dc30e53cbe892022cdc42410976cfebfb

I have been following the documentations and this code used to work before. Could you help here? Please

  • Package: "@stardust-collective/dag4": "^2.2.0"

Chain configuration:

  dag4.account.connect({
    networkVersion: "2.0",
    beUrl: "https://be-integrationnet.constellationnetwork.io",
    l0Url: "https://l0-lb-integrationnet.constellationnetwork.io",
    l1Url: "https://l1-lb-integrationnet.constellationnetwork.io",
  });

Script:

async function simpleTransfer(to: string, amount: number) {
  const address = dag4.account.address;

  console.log("sending from :", address);

  const res = await dag4.account.transferDag(
    to,
    amount, 
    0 
  );

  console.log(res);
}

simpleTransfer("DAG7sx7SSuGNeM88qm4hdpoCnveQE9QCraf4Mj3C", 10);

Unsafe to use Amount as number

Hi, according to CoinMarketCap your total supply is 3,711,998,690 DAG. If convert to the smallest unit it is 3,711,998,690 x 1e8, this value is greatly bigger than Javascript MAX_SAFE_INTEGER. It is unsafe to use number bigger than MAX_SAFE_INTEGER

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.