listOpenOrders method

Future<List<Order>> listOpenOrders({
  1. required String poolId,
  2. String? accountCap,
})

Get the open orders of the current user.

poolId the pool id.

accountCap your accountCap. If not provided, this.accountCap will be used.

Implementation

Future<List<Order>> listOpenOrders({
		required String poolId,
		String? accountCap
	}) async {
		final txb = TransactionBlock();
		final cap = _checkAccountCap(accountCap);
  final typeArgs = await getPoolTypeArgs(poolId);
		txb.moveCall(
			"$PACKAGE_ID::$MODULE_CLOB::list_open_orders",
			typeArguments: typeArgs,
			arguments: [txb.object(poolId), txb.object(cap)],
		);

		final results = (
			await suiClient.devInspectTransactionBlock(
				currentAddress,
				txb,
			)
		).results;

		if (results == null || results.isEmpty) {
			return [];
		}

  final returnValues = results[0].returnValues![0][0] as List;
		final orders = deepbookBCS.de('vector<Order>', Uint8List.fromList(returnValues.cast<int>()));
  return (orders as List).map((e) => Order.fromJson(e)).toList();
	}