How to use the @cityofzion/neon-core.u.Fixed8 function in @cityofzion/neon-core

To help you get started, we’ve selected a few @cityofzion/neon-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github CityOfZion / neon-js / packages / neon-api / __tests__ / transaction / builder.ts View on Github external
test("setFee", () => {
    const transaction = new TransactionBuilder()
      .setSystemFee(new u.Fixed8(10))
      .setNetworkFee(new u.Fixed8(2))
      .build();
    expect(transaction.systemFee.equals(10)).toBeTruthy();
    expect(transaction.networkFee.equals(2)).toBeTruthy();
  });
});
github CityOfZion / neon-js / packages / neon-api / __tests__ / provider / neonDB / core.ts View on Github external
block_index: 14,
              gas_sent: false,
              neo_sent: true,
              txid: "4"
            }
          ],
          name: "transaction_history"
        }
      })
    );
    axios.get = httpCall;
    expect(await neonDB.getTransactionHistory(testUrl, "address")).toEqual([
      {
        txid: "1",
        blockHeight: 11,
        change: { GAS: new u.Fixed8(0.123), NEO: new u.Fixed8(5) }
      },
      {
        txid: "2",
        blockHeight: 12,
        change: { GAS: new u.Fixed8(0.456), NEO: new u.Fixed8(0) }
      },
      {
        txid: "3",
        blockHeight: 13,
        change: { GAS: new u.Fixed8(0.789), NEO: new u.Fixed8(-1) }
      },
      {
        txid: "4",
        blockHeight: 14,
        change: { GAS: new u.Fixed8(0), NEO: new u.Fixed8(6) }
      }
github CityOfZion / neon-js / packages / neon-api / __tests__ / provider / neonDB / core.ts View on Github external
],
          name: "transaction_history"
        }
      })
    );
    axios.get = httpCall;
    expect(await neonDB.getTransactionHistory(testUrl, "address")).toEqual([
      {
        txid: "1",
        blockHeight: 11,
        change: { GAS: new u.Fixed8(0.123), NEO: new u.Fixed8(5) }
      },
      {
        txid: "2",
        blockHeight: 12,
        change: { GAS: new u.Fixed8(0.456), NEO: new u.Fixed8(0) }
      },
      {
        txid: "3",
        blockHeight: 13,
        change: { GAS: new u.Fixed8(0.789), NEO: new u.Fixed8(-1) }
      },
      {
        txid: "4",
        blockHeight: 14,
        change: { GAS: new u.Fixed8(0), NEO: new u.Fixed8(6) }
      }
    ]);
    expect(httpCall).toBeCalledWith(testUrl + "/v2/address/history/address");
  });
});
github CityOfZion / neon-js / packages / neon-api / __tests__ / provider / neoscan / core.ts View on Github external
axios.get = httpCall;
    expect(await neoscan.getTransactionHistory(testUrl, "address")).toEqual([
      {
        txid: "1",
        blockHeight: 11,
        change: { GAS: new u.Fixed8(0.123), NEO: new u.Fixed8(5) }
      },
      {
        txid: "2",
        blockHeight: 12,
        change: { GAS: new u.Fixed8(-0.456), NEO: new u.Fixed8(-6) }
      },
      {
        txid: "3",
        blockHeight: 13,
        change: { GAS: new u.Fixed8(0.789), NEO: new u.Fixed8(0) }
      }
    ]);
    expect(httpCall).toBeCalledWith(
      testUrl + "/v1/get_last_transactions_by_address/address"
    );
  });
});
github CityOfZion / neon-js / packages / neon-api / __tests__ / provider / neonDB / core.ts View on Github external
change: { GAS: new u.Fixed8(0.123), NEO: new u.Fixed8(5) }
      },
      {
        txid: "2",
        blockHeight: 12,
        change: { GAS: new u.Fixed8(0.456), NEO: new u.Fixed8(0) }
      },
      {
        txid: "3",
        blockHeight: 13,
        change: { GAS: new u.Fixed8(0.789), NEO: new u.Fixed8(-1) }
      },
      {
        txid: "4",
        blockHeight: 14,
        change: { GAS: new u.Fixed8(0), NEO: new u.Fixed8(6) }
      }
    ]);
    expect(httpCall).toBeCalledWith(testUrl + "/v2/address/history/address");
  });
});
github CityOfZion / neon-js / packages / neon-api / src / provider / neoCli / core.ts View on Github external
export async function getMaxClaimAmount(
  url: string,
  address: string
): Promise {
  const response = await axios.post(
    url,
    Object.assign({}, BASE_REQ, { method: "getunclaimed", params: [address] })
  );
  const data = response.data as NeoCliGetUnclaimedResponse;
  if (data.error) {
    throwRpcError(data.error);
  }
  return new u.Fixed8(data.result.unclaimed).div(100000000);
}
github CityOfZion / neon-js / packages / neon-api / src / provider / neoscan / core.ts View on Github external
function getChange(
  vin: { asset: string; value: number }[],
  vout: { asset: string; value: number }[],
  assetId: string
): u.Fixed8 {
  const totalOut = vin
    .filter(i => i.asset === assetId)
    .reduce((p, c) => p.add(c.value), new u.Fixed8(0));
  const totalIn = vout
    .filter(i => i.asset === assetId)
    .reduce((p, c) => p.add(c.value), new u.Fixed8(0));

  return totalIn.minus(totalOut);
}
github CityOfZion / neon-js / packages / neon-api / src / transaction / validator.ts View on Github external
} = await this.rpcClient.invokeScript(script.toBigEndian());

    if (state === "FAULT") {
      return {
        valid: false,
        result: {
          systemFee: {
            fixed: false,
            message:
              "Cannot get precise systemFee as script execution on node reports FAULT."
          }
        }
      };
    }

    const minimumSystemFee = new u.Fixed8(parseFloat(gasConsumed))
      .mul(1e-8)
      .ceil();
    return this._validateSystemFee(minimumSystemFee, autoFix);
  }