pattern-tech / gateway

Middleware that standardizes DEX API endpoints on different blockchain networks
Apache License 2.0
1 stars 1 forks source link

typo Error in ErgoController #49

Closed satiparpar closed 1 month ago

satiparpar commented 1 month ago

hey @hirotadashi & @ahmadyazdanii , I faced a typo error in transfer function and asking you to take a look at it share your feedback about it. here are more details about the issue: in the function below (line 97 - ergo.controller.ts ):

  static async transfer(
    ergo: Ergo,
    req: TransferRequest,
  ): Promise<ErgoUnsignedTransaction> {
    const networkHeight = await ergo.getNetworkHeight();
    const utxos = await ergo.getAddressUnspentBoxes(req.fromAddress);

    return new TransactionBuilder(networkHeight)
      .from(
        utxos.map((utxo) => {
          const temp = Object(utxo);
          temp.value = temp.value.toString();
          temp.assets = temp.assets.map((asset: ErgoBoxAsset) => {
            const temp2 = Object(asset);
            temp2.amount = temp2.amount.toString();
            return temp2;
          });
          return temp;
        }),
      )
      .to(
        new OutputBuilder(req.toValue, req.toAddress).addTokens(
          req.assets.map((asset) => {
            const temp = Object(asset);
            temp.amount = temp.amount.toString();
            return temp;
          }),
        ),
      )
      .sendChangeTo(req.fromAddress)
      .payMinFee()
      .build();
  }

when I want to call sendChangeTo() with req.fromAddress there is a mistake because the type of req.fromAddress is string but sendChangeTo() only accepts ErgoAddress | Base58String | HexString and I'm facing this error in my test file: Argument of type 'string' is not assignable to parameter of type 'number'.ts(2345)