Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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();
});
});
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) }
}
],
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");
});
});
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"
);
});
});
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");
});
});
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);
}
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);
}
} = 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);
}