tigerbeetle-node 0.14.169 → 0.14.174

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -549,6 +549,29 @@ console.log(transfers);
549
549
  */
550
550
  ```
551
551
 
552
+ ## Get Account Transfers
553
+
554
+ NOTE: This is a preview API that is subject to breaking changes once we have
555
+ a stable querying API.
556
+
557
+ Fetches the transfers involving a given account, allowing basic filter and pagination
558
+ capabilities.
559
+
560
+ The transfers in the response are sorted by `timestamp` in chronological or
561
+ reverse-chronological order.
562
+
563
+ ```javascript
564
+ let filter = {
565
+ account_id: 2n,
566
+ timestamp: 0n, // No filter by Timestamp.
567
+ limit: 10, // Limit to ten transfers at most.
568
+ flags: GetAccountTransfersFlags.debits | // Include transfer from the debit side.
569
+ GetAccountTransfersFlags.credits | // Include transfer from the credit side.
570
+ GetAccountTransfersFlags.reversed, // Sort by timestamp in reverse-chronological order.
571
+ }
572
+ const account_transfers = await client.getAccountTransfers(filter)
573
+ ```
574
+
552
575
  ## Linked Events
553
576
 
554
577
  When the `linked` flag is specified for an account when creating accounts or
Binary file
Binary file
Binary file
@@ -13,6 +13,12 @@ export declare enum TransferFlags {
13
13
  balancing_debit = 16,
14
14
  balancing_credit = 32
15
15
  }
16
+ export declare enum GetAccountTransfersFlags {
17
+ none = 0,
18
+ debits = 1,
19
+ credits = 2,
20
+ reversed = 4
21
+ }
16
22
  export declare type Account = {
17
23
  id: bigint;
18
24
  debits_pending: bigint;
@@ -133,9 +139,16 @@ export declare type CreateTransfersError = {
133
139
  index: number;
134
140
  result: CreateTransferError;
135
141
  };
142
+ export declare type GetAccountTransfers = {
143
+ account_id: bigint;
144
+ timestamp: bigint;
145
+ limit: number;
146
+ flags: number;
147
+ };
136
148
  export declare enum Operation {
137
149
  create_accounts = 128,
138
150
  create_transfers = 129,
139
151
  lookup_accounts = 130,
140
- lookup_transfers = 131
152
+ lookup_transfers = 131,
153
+ get_account_transfers = 132
141
154
  }
package/dist/bindings.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Operation = exports.CreateTransferError = exports.CreateAccountError = exports.TransferFlags = exports.AccountFlags = void 0;
3
+ exports.Operation = exports.CreateTransferError = exports.CreateAccountError = exports.GetAccountTransfersFlags = exports.TransferFlags = exports.AccountFlags = void 0;
4
4
  var AccountFlags;
5
5
  (function (AccountFlags) {
6
6
  AccountFlags[AccountFlags["none"] = 0] = "none";
@@ -18,6 +18,13 @@ var TransferFlags;
18
18
  TransferFlags[TransferFlags["balancing_debit"] = 16] = "balancing_debit";
19
19
  TransferFlags[TransferFlags["balancing_credit"] = 32] = "balancing_credit";
20
20
  })(TransferFlags = exports.TransferFlags || (exports.TransferFlags = {}));
21
+ var GetAccountTransfersFlags;
22
+ (function (GetAccountTransfersFlags) {
23
+ GetAccountTransfersFlags[GetAccountTransfersFlags["none"] = 0] = "none";
24
+ GetAccountTransfersFlags[GetAccountTransfersFlags["debits"] = 1] = "debits";
25
+ GetAccountTransfersFlags[GetAccountTransfersFlags["credits"] = 2] = "credits";
26
+ GetAccountTransfersFlags[GetAccountTransfersFlags["reversed"] = 4] = "reversed";
27
+ })(GetAccountTransfersFlags = exports.GetAccountTransfersFlags || (exports.GetAccountTransfersFlags = {}));
21
28
  var CreateAccountError;
22
29
  (function (CreateAccountError) {
23
30
  CreateAccountError[CreateAccountError["ok"] = 0] = "ok";
@@ -108,5 +115,6 @@ var Operation;
108
115
  Operation[Operation["create_transfers"] = 129] = "create_transfers";
109
116
  Operation[Operation["lookup_accounts"] = 130] = "lookup_accounts";
110
117
  Operation[Operation["lookup_transfers"] = 131] = "lookup_transfers";
118
+ Operation[Operation["get_account_transfers"] = 132] = "get_account_transfers";
111
119
  })(Operation = exports.Operation || (exports.Operation = {}));
112
120
  //# sourceMappingURL=bindings.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"bindings.js","sourceRoot":"","sources":["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,mEAAsB,CAAA;AACxB,CAAC,EALW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAKpB","sourcesContent":["///////////////////////////////////////////////////////\n// This file was auto-generated by node_bindings.zig //\n// Do not manually modify. //\n///////////////////////////////////////////////////////\n\n\n/**\n* See [AccountFlags](https://docs.tigerbeetle.com/reference/accounts#flags)\n*/\nexport enum AccountFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/accounts#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [debits_must_not_exceed_credits](https://docs.tigerbeetle.com/reference/accounts#flagsdebits_must_not_exceed_credits)\n */\n debits_must_not_exceed_credits = (1 << 1),\n\n /**\n * See [credits_must_not_exceed_debits](https://docs.tigerbeetle.com/reference/accounts#flagscredits_must_not_exceed_debits)\n */\n credits_must_not_exceed_debits = (1 << 2),\n}\n\n\n/**\n* See [TransferFlags](https://docs.tigerbeetle.com/reference/transfers#flags)\n*/\nexport enum TransferFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/transfers#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [pending](https://docs.tigerbeetle.com/reference/transfers#flagspending)\n */\n pending = (1 << 1),\n\n /**\n * See [post_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagspost_pending_transfer)\n */\n post_pending_transfer = (1 << 2),\n\n /**\n * See [void_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagsvoid_pending_transfer)\n */\n void_pending_transfer = (1 << 3),\n\n /**\n * See [balancing_debit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_debit)\n */\n balancing_debit = (1 << 4),\n\n /**\n * See [balancing_credit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_credit)\n */\n balancing_credit = (1 << 5),\n}\n\n\n/**\n* See [Account](https://docs.tigerbeetle.com/reference/accounts/#)\n*/\nexport type Account = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/accounts/#id)\n */\n id: bigint\n\n /**\n * See [debits_pending](https://docs.tigerbeetle.com/reference/accounts/#debits_pending)\n */\n debits_pending: bigint\n\n /**\n * See [debits_posted](https://docs.tigerbeetle.com/reference/accounts/#debits_posted)\n */\n debits_posted: bigint\n\n /**\n * See [credits_pending](https://docs.tigerbeetle.com/reference/accounts/#credits_pending)\n */\n credits_pending: bigint\n\n /**\n * See [credits_posted](https://docs.tigerbeetle.com/reference/accounts/#credits_posted)\n */\n credits_posted: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/accounts/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/accounts/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/accounts/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [reserved](https://docs.tigerbeetle.com/reference/accounts/#reserved)\n */\n reserved: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/accounts/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/accounts/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/accounts/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/accounts/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [Transfer](https://docs.tigerbeetle.com/reference/transfers/#)\n*/\nexport type Transfer = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/transfers/#id)\n */\n id: bigint\n\n /**\n * See [debit_account_id](https://docs.tigerbeetle.com/reference/transfers/#debit_account_id)\n */\n debit_account_id: bigint\n\n /**\n * See [credit_account_id](https://docs.tigerbeetle.com/reference/transfers/#credit_account_id)\n */\n credit_account_id: bigint\n\n /**\n * See [amount](https://docs.tigerbeetle.com/reference/transfers/#amount)\n */\n amount: bigint\n\n /**\n * See [pending_id](https://docs.tigerbeetle.com/reference/transfers/#pending_id)\n */\n pending_id: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/transfers/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/transfers/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/transfers/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [timeout](https://docs.tigerbeetle.com/reference/transfers/#timeout)\n */\n timeout: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/transfers/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/transfers/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/transfers/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/transfers/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [CreateAccountError](https://docs.tigerbeetle.com/reference/operations/create_accounts#)\n*/\nexport enum CreateAccountError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_accounts#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_field](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_field)\n */\n reserved_field = 4,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_flag)\n */\n reserved_flag = 5,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_zero)\n */\n id_must_not_be_zero = 6,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 7,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_accounts#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 8,\n\n /**\n * See [debits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_pending_must_be_zero)\n */\n debits_pending_must_be_zero = 9,\n\n /**\n * See [debits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_posted_must_be_zero)\n */\n debits_posted_must_be_zero = 10,\n\n /**\n * See [credits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_pending_must_be_zero)\n */\n credits_pending_must_be_zero = 11,\n\n /**\n * See [credits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_posted_must_be_zero)\n */\n credits_posted_must_be_zero = 12,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 13,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#code_must_not_be_zero)\n */\n code_must_not_be_zero = 14,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_flags)\n */\n exists_with_different_flags = 15,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 16,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 17,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 18,\n\n /**\n * See [exists_with_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_ledger)\n */\n exists_with_different_ledger = 19,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_code)\n */\n exists_with_different_code = 20,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists)\n */\n exists = 21,\n}\n\n\n/**\n* See [CreateTransferError](https://docs.tigerbeetle.com/reference/operations/create_transfers#)\n*/\nexport enum CreateTransferError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_transfers#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_transfers#reserved_flag)\n */\n reserved_flag = 4,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_zero)\n */\n id_must_not_be_zero = 5,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 6,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_transfers#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 7,\n\n /**\n * See [debit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_zero)\n */\n debit_account_id_must_not_be_zero = 8,\n\n /**\n * See [debit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_int_max)\n */\n debit_account_id_must_not_be_int_max = 9,\n\n /**\n * See [credit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_zero)\n */\n credit_account_id_must_not_be_zero = 10,\n\n /**\n * See [credit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_int_max)\n */\n credit_account_id_must_not_be_int_max = 11,\n\n /**\n * See [accounts_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_be_different)\n */\n accounts_must_be_different = 12,\n\n /**\n * See [pending_id_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_zero)\n */\n pending_id_must_be_zero = 13,\n\n /**\n * See [pending_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_zero)\n */\n pending_id_must_not_be_zero = 14,\n\n /**\n * See [pending_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_int_max)\n */\n pending_id_must_not_be_int_max = 15,\n\n /**\n * See [pending_id_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_different)\n */\n pending_id_must_be_different = 16,\n\n /**\n * See [timeout_reserved_for_pending_transfer](https://docs.tigerbeetle.com/reference/operations/create_transfers#timeout_reserved_for_pending_transfer)\n */\n timeout_reserved_for_pending_transfer = 17,\n\n /**\n * See [amount_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#amount_must_not_be_zero)\n */\n amount_must_not_be_zero = 18,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 19,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#code_must_not_be_zero)\n */\n code_must_not_be_zero = 20,\n\n /**\n * See [debit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_not_found)\n */\n debit_account_not_found = 21,\n\n /**\n * See [credit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_not_found)\n */\n credit_account_not_found = 22,\n\n /**\n * See [accounts_must_have_the_same_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_have_the_same_ledger)\n */\n accounts_must_have_the_same_ledger = 23,\n\n /**\n * See [transfer_must_have_the_same_ledger_as_accounts](https://docs.tigerbeetle.com/reference/operations/create_transfers#transfer_must_have_the_same_ledger_as_accounts)\n */\n transfer_must_have_the_same_ledger_as_accounts = 24,\n\n /**\n * See [pending_transfer_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_found)\n */\n pending_transfer_not_found = 25,\n\n /**\n * See [pending_transfer_not_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_pending)\n */\n pending_transfer_not_pending = 26,\n\n /**\n * See [pending_transfer_has_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_debit_account_id)\n */\n pending_transfer_has_different_debit_account_id = 27,\n\n /**\n * See [pending_transfer_has_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_credit_account_id)\n */\n pending_transfer_has_different_credit_account_id = 28,\n\n /**\n * See [pending_transfer_has_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_ledger)\n */\n pending_transfer_has_different_ledger = 29,\n\n /**\n * See [pending_transfer_has_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_code)\n */\n pending_transfer_has_different_code = 30,\n\n /**\n * See [exceeds_pending_transfer_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_pending_transfer_amount)\n */\n exceeds_pending_transfer_amount = 31,\n\n /**\n * See [pending_transfer_has_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_amount)\n */\n pending_transfer_has_different_amount = 32,\n\n /**\n * See [pending_transfer_already_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_posted)\n */\n pending_transfer_already_posted = 33,\n\n /**\n * See [pending_transfer_already_voided](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_voided)\n */\n pending_transfer_already_voided = 34,\n\n /**\n * See [pending_transfer_expired](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_expired)\n */\n pending_transfer_expired = 35,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_flags)\n */\n exists_with_different_flags = 36,\n\n /**\n * See [exists_with_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_debit_account_id)\n */\n exists_with_different_debit_account_id = 37,\n\n /**\n * See [exists_with_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_credit_account_id)\n */\n exists_with_different_credit_account_id = 38,\n\n /**\n * See [exists_with_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_amount)\n */\n exists_with_different_amount = 39,\n\n /**\n * See [exists_with_different_pending_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_pending_id)\n */\n exists_with_different_pending_id = 40,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 41,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 42,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 43,\n\n /**\n * See [exists_with_different_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_timeout)\n */\n exists_with_different_timeout = 44,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_code)\n */\n exists_with_different_code = 45,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists)\n */\n exists = 46,\n\n /**\n * See [overflows_debits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_pending)\n */\n overflows_debits_pending = 47,\n\n /**\n * See [overflows_credits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_pending)\n */\n overflows_credits_pending = 48,\n\n /**\n * See [overflows_debits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_posted)\n */\n overflows_debits_posted = 49,\n\n /**\n * See [overflows_credits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_posted)\n */\n overflows_credits_posted = 50,\n\n /**\n * See [overflows_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits)\n */\n overflows_debits = 51,\n\n /**\n * See [overflows_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits)\n */\n overflows_credits = 52,\n\n /**\n * See [overflows_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_timeout)\n */\n overflows_timeout = 53,\n\n /**\n * See [exceeds_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_credits)\n */\n exceeds_credits = 54,\n\n /**\n * See [exceeds_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_debits)\n */\n exceeds_debits = 55,\n}\n\nexport type CreateAccountsError = {\n index: number\n result: CreateAccountError\n}\n\nexport type CreateTransfersError = {\n index: number\n result: CreateTransferError\n}\n\nexport enum Operation {\n create_accounts = 128,\n create_transfers = 129,\n lookup_accounts = 130,\n lookup_transfers = 131,\n}\n\n"]}
1
+ {"version":3,"file":"bindings.js","sourceRoot":"","sources":["../src/bindings.ts"],"names":[],"mappings":";;;AASA,IAAY,YAiBX;AAjBD,WAAY,YAAY;IACtB,+CAAQ,CAAA;IAKR,mDAAiB,CAAA;IAKjB,mGAAyC,CAAA;IAKzC,mGAAyC,CAAA;AAC3C,CAAC,EAjBW,YAAY,GA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AqB,CAAA;IACrB,mEAAsB,CAAA;IACtB,6EAA2B,CAAA;AAC7B,CAAC,EANW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAMpB","sourcesContent":["///////////////////////////////////////////////////////\n// This file was auto-generated by node_bindings.zig //\n// Do not manually modify. //\n///////////////////////////////////////////////////////\n\n\n/**\n* See [AccountFlags](https://docs.tigerbeetle.com/reference/accounts#flags)\n*/\nexport enum AccountFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/accounts#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [debits_must_not_exceed_credits](https://docs.tigerbeetle.com/reference/accounts#flagsdebits_must_not_exceed_credits)\n */\n debits_must_not_exceed_credits = (1 << 1),\n\n /**\n * See [credits_must_not_exceed_debits](https://docs.tigerbeetle.com/reference/accounts#flagscredits_must_not_exceed_debits)\n */\n credits_must_not_exceed_debits = (1 << 2),\n}\n\n\n/**\n* See [TransferFlags](https://docs.tigerbeetle.com/reference/transfers#flags)\n*/\nexport enum TransferFlags {\n none = 0,\n\n /**\n * See [linked](https://docs.tigerbeetle.com/reference/transfers#flagslinked)\n */\n linked = (1 << 0),\n\n /**\n * See [pending](https://docs.tigerbeetle.com/reference/transfers#flagspending)\n */\n pending = (1 << 1),\n\n /**\n * See [post_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagspost_pending_transfer)\n */\n post_pending_transfer = (1 << 2),\n\n /**\n * See [void_pending_transfer](https://docs.tigerbeetle.com/reference/transfers#flagsvoid_pending_transfer)\n */\n void_pending_transfer = (1 << 3),\n\n /**\n * See [balancing_debit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_debit)\n */\n balancing_debit = (1 << 4),\n\n /**\n * See [balancing_credit](https://docs.tigerbeetle.com/reference/transfers#flagsbalancing_credit)\n */\n balancing_credit = (1 << 5),\n}\n\n\n/**\n* See [GetAccountTransfersFlags](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flags)\n*/\nexport enum GetAccountTransfersFlags {\n none = 0,\n\n /**\n * See [debits](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagsdebits)\n */\n debits = (1 << 0),\n\n /**\n * See [credits](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagscredits)\n */\n credits = (1 << 1),\n\n /**\n * See [reversed](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagsreversed)\n */\n reversed = (1 << 2),\n}\n\n\n/**\n* See [Account](https://docs.tigerbeetle.com/reference/accounts/#)\n*/\nexport type Account = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/accounts/#id)\n */\n id: bigint\n\n /**\n * See [debits_pending](https://docs.tigerbeetle.com/reference/accounts/#debits_pending)\n */\n debits_pending: bigint\n\n /**\n * See [debits_posted](https://docs.tigerbeetle.com/reference/accounts/#debits_posted)\n */\n debits_posted: bigint\n\n /**\n * See [credits_pending](https://docs.tigerbeetle.com/reference/accounts/#credits_pending)\n */\n credits_pending: bigint\n\n /**\n * See [credits_posted](https://docs.tigerbeetle.com/reference/accounts/#credits_posted)\n */\n credits_posted: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/accounts/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/accounts/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/accounts/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [reserved](https://docs.tigerbeetle.com/reference/accounts/#reserved)\n */\n reserved: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/accounts/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/accounts/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/accounts/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/accounts/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [Transfer](https://docs.tigerbeetle.com/reference/transfers/#)\n*/\nexport type Transfer = {\n\n /**\n * See [id](https://docs.tigerbeetle.com/reference/transfers/#id)\n */\n id: bigint\n\n /**\n * See [debit_account_id](https://docs.tigerbeetle.com/reference/transfers/#debit_account_id)\n */\n debit_account_id: bigint\n\n /**\n * See [credit_account_id](https://docs.tigerbeetle.com/reference/transfers/#credit_account_id)\n */\n credit_account_id: bigint\n\n /**\n * See [amount](https://docs.tigerbeetle.com/reference/transfers/#amount)\n */\n amount: bigint\n\n /**\n * See [pending_id](https://docs.tigerbeetle.com/reference/transfers/#pending_id)\n */\n pending_id: bigint\n\n /**\n * See [user_data_128](https://docs.tigerbeetle.com/reference/transfers/#user_data_128)\n */\n user_data_128: bigint\n\n /**\n * See [user_data_64](https://docs.tigerbeetle.com/reference/transfers/#user_data_64)\n */\n user_data_64: bigint\n\n /**\n * See [user_data_32](https://docs.tigerbeetle.com/reference/transfers/#user_data_32)\n */\n user_data_32: number\n\n /**\n * See [timeout](https://docs.tigerbeetle.com/reference/transfers/#timeout)\n */\n timeout: number\n\n /**\n * See [ledger](https://docs.tigerbeetle.com/reference/transfers/#ledger)\n */\n ledger: number\n\n /**\n * See [code](https://docs.tigerbeetle.com/reference/transfers/#code)\n */\n code: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/transfers/#flags)\n */\n flags: number\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/transfers/#timestamp)\n */\n timestamp: bigint\n}\n\n\n/**\n* See [CreateAccountError](https://docs.tigerbeetle.com/reference/operations/create_accounts#)\n*/\nexport enum CreateAccountError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_accounts#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_accounts#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_field](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_field)\n */\n reserved_field = 4,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_accounts#reserved_flag)\n */\n reserved_flag = 5,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_zero)\n */\n id_must_not_be_zero = 6,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_accounts#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 7,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_accounts#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 8,\n\n /**\n * See [debits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_pending_must_be_zero)\n */\n debits_pending_must_be_zero = 9,\n\n /**\n * See [debits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#debits_posted_must_be_zero)\n */\n debits_posted_must_be_zero = 10,\n\n /**\n * See [credits_pending_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_pending_must_be_zero)\n */\n credits_pending_must_be_zero = 11,\n\n /**\n * See [credits_posted_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#credits_posted_must_be_zero)\n */\n credits_posted_must_be_zero = 12,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 13,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_accounts#code_must_not_be_zero)\n */\n code_must_not_be_zero = 14,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_flags)\n */\n exists_with_different_flags = 15,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 16,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 17,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 18,\n\n /**\n * See [exists_with_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_ledger)\n */\n exists_with_different_ledger = 19,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists_with_different_code)\n */\n exists_with_different_code = 20,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_accounts#exists)\n */\n exists = 21,\n}\n\n\n/**\n* See [CreateTransferError](https://docs.tigerbeetle.com/reference/operations/create_transfers#)\n*/\nexport enum CreateTransferError {\n\n /**\n * See [ok](https://docs.tigerbeetle.com/reference/operations/create_transfers#ok)\n */\n ok = 0,\n\n /**\n * See [linked_event_failed](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_failed)\n */\n linked_event_failed = 1,\n\n /**\n * See [linked_event_chain_open](https://docs.tigerbeetle.com/reference/operations/create_transfers#linked_event_chain_open)\n */\n linked_event_chain_open = 2,\n\n /**\n * See [timestamp_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#timestamp_must_be_zero)\n */\n timestamp_must_be_zero = 3,\n\n /**\n * See [reserved_flag](https://docs.tigerbeetle.com/reference/operations/create_transfers#reserved_flag)\n */\n reserved_flag = 4,\n\n /**\n * See [id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_zero)\n */\n id_must_not_be_zero = 5,\n\n /**\n * See [id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#id_must_not_be_int_max)\n */\n id_must_not_be_int_max = 6,\n\n /**\n * See [flags_are_mutually_exclusive](https://docs.tigerbeetle.com/reference/operations/create_transfers#flags_are_mutually_exclusive)\n */\n flags_are_mutually_exclusive = 7,\n\n /**\n * See [debit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_zero)\n */\n debit_account_id_must_not_be_zero = 8,\n\n /**\n * See [debit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_id_must_not_be_int_max)\n */\n debit_account_id_must_not_be_int_max = 9,\n\n /**\n * See [credit_account_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_zero)\n */\n credit_account_id_must_not_be_zero = 10,\n\n /**\n * See [credit_account_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_id_must_not_be_int_max)\n */\n credit_account_id_must_not_be_int_max = 11,\n\n /**\n * See [accounts_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_be_different)\n */\n accounts_must_be_different = 12,\n\n /**\n * See [pending_id_must_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_zero)\n */\n pending_id_must_be_zero = 13,\n\n /**\n * See [pending_id_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_zero)\n */\n pending_id_must_not_be_zero = 14,\n\n /**\n * See [pending_id_must_not_be_int_max](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_not_be_int_max)\n */\n pending_id_must_not_be_int_max = 15,\n\n /**\n * See [pending_id_must_be_different](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_id_must_be_different)\n */\n pending_id_must_be_different = 16,\n\n /**\n * See [timeout_reserved_for_pending_transfer](https://docs.tigerbeetle.com/reference/operations/create_transfers#timeout_reserved_for_pending_transfer)\n */\n timeout_reserved_for_pending_transfer = 17,\n\n /**\n * See [amount_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#amount_must_not_be_zero)\n */\n amount_must_not_be_zero = 18,\n\n /**\n * See [ledger_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#ledger_must_not_be_zero)\n */\n ledger_must_not_be_zero = 19,\n\n /**\n * See [code_must_not_be_zero](https://docs.tigerbeetle.com/reference/operations/create_transfers#code_must_not_be_zero)\n */\n code_must_not_be_zero = 20,\n\n /**\n * See [debit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#debit_account_not_found)\n */\n debit_account_not_found = 21,\n\n /**\n * See [credit_account_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#credit_account_not_found)\n */\n credit_account_not_found = 22,\n\n /**\n * See [accounts_must_have_the_same_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#accounts_must_have_the_same_ledger)\n */\n accounts_must_have_the_same_ledger = 23,\n\n /**\n * See [transfer_must_have_the_same_ledger_as_accounts](https://docs.tigerbeetle.com/reference/operations/create_transfers#transfer_must_have_the_same_ledger_as_accounts)\n */\n transfer_must_have_the_same_ledger_as_accounts = 24,\n\n /**\n * See [pending_transfer_not_found](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_found)\n */\n pending_transfer_not_found = 25,\n\n /**\n * See [pending_transfer_not_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_not_pending)\n */\n pending_transfer_not_pending = 26,\n\n /**\n * See [pending_transfer_has_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_debit_account_id)\n */\n pending_transfer_has_different_debit_account_id = 27,\n\n /**\n * See [pending_transfer_has_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_credit_account_id)\n */\n pending_transfer_has_different_credit_account_id = 28,\n\n /**\n * See [pending_transfer_has_different_ledger](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_ledger)\n */\n pending_transfer_has_different_ledger = 29,\n\n /**\n * See [pending_transfer_has_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_code)\n */\n pending_transfer_has_different_code = 30,\n\n /**\n * See [exceeds_pending_transfer_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_pending_transfer_amount)\n */\n exceeds_pending_transfer_amount = 31,\n\n /**\n * See [pending_transfer_has_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_has_different_amount)\n */\n pending_transfer_has_different_amount = 32,\n\n /**\n * See [pending_transfer_already_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_posted)\n */\n pending_transfer_already_posted = 33,\n\n /**\n * See [pending_transfer_already_voided](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_already_voided)\n */\n pending_transfer_already_voided = 34,\n\n /**\n * See [pending_transfer_expired](https://docs.tigerbeetle.com/reference/operations/create_transfers#pending_transfer_expired)\n */\n pending_transfer_expired = 35,\n\n /**\n * See [exists_with_different_flags](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_flags)\n */\n exists_with_different_flags = 36,\n\n /**\n * See [exists_with_different_debit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_debit_account_id)\n */\n exists_with_different_debit_account_id = 37,\n\n /**\n * See [exists_with_different_credit_account_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_credit_account_id)\n */\n exists_with_different_credit_account_id = 38,\n\n /**\n * See [exists_with_different_amount](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_amount)\n */\n exists_with_different_amount = 39,\n\n /**\n * See [exists_with_different_pending_id](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_pending_id)\n */\n exists_with_different_pending_id = 40,\n\n /**\n * See [exists_with_different_user_data_128](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_128)\n */\n exists_with_different_user_data_128 = 41,\n\n /**\n * See [exists_with_different_user_data_64](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_64)\n */\n exists_with_different_user_data_64 = 42,\n\n /**\n * See [exists_with_different_user_data_32](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_user_data_32)\n */\n exists_with_different_user_data_32 = 43,\n\n /**\n * See [exists_with_different_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_timeout)\n */\n exists_with_different_timeout = 44,\n\n /**\n * See [exists_with_different_code](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists_with_different_code)\n */\n exists_with_different_code = 45,\n\n /**\n * See [exists](https://docs.tigerbeetle.com/reference/operations/create_transfers#exists)\n */\n exists = 46,\n\n /**\n * See [overflows_debits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_pending)\n */\n overflows_debits_pending = 47,\n\n /**\n * See [overflows_credits_pending](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_pending)\n */\n overflows_credits_pending = 48,\n\n /**\n * See [overflows_debits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits_posted)\n */\n overflows_debits_posted = 49,\n\n /**\n * See [overflows_credits_posted](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits_posted)\n */\n overflows_credits_posted = 50,\n\n /**\n * See [overflows_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_debits)\n */\n overflows_debits = 51,\n\n /**\n * See [overflows_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_credits)\n */\n overflows_credits = 52,\n\n /**\n * See [overflows_timeout](https://docs.tigerbeetle.com/reference/operations/create_transfers#overflows_timeout)\n */\n overflows_timeout = 53,\n\n /**\n * See [exceeds_credits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_credits)\n */\n exceeds_credits = 54,\n\n /**\n * See [exceeds_debits](https://docs.tigerbeetle.com/reference/operations/create_transfers#exceeds_debits)\n */\n exceeds_debits = 55,\n}\n\nexport type CreateAccountsError = {\n index: number\n result: CreateAccountError\n}\n\nexport type CreateTransfersError = {\n index: number\n result: CreateTransferError\n}\n\n\n/**\n* See [GetAccountTransfers](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#)\n*/\nexport type GetAccountTransfers = {\n\n /**\n * See [account_id](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#account_id)\n */\n account_id: bigint\n\n /**\n * See [timestamp](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#timestamp)\n */\n timestamp: bigint\n\n /**\n * See [limit](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#limit)\n */\n limit: number\n\n /**\n * See [flags](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flags)\n */\n flags: number\n}\n\nexport enum Operation {\n create_accounts = 128,\n create_transfers = 129,\n lookup_accounts = 130,\n lookup_transfers = 131,\n get_account_transfers = 132,\n}\n\n"]}
package/dist/index.d.ts CHANGED
@@ -1,9 +1,9 @@
1
1
  export * from './bindings';
2
- import { Account, Transfer, CreateAccountsError, CreateTransfersError } from './bindings';
2
+ import { Account, Transfer, CreateAccountsError, CreateTransfersError, GetAccountTransfers } from './bindings';
3
3
  export declare type Context = object;
4
4
  export declare type AccountID = bigint;
5
5
  export declare type TransferID = bigint;
6
- export declare type Event = Account | Transfer | AccountID | TransferID;
6
+ export declare type Event = Account | Transfer | AccountID | TransferID | GetAccountTransfers;
7
7
  export declare type Result = CreateAccountsError | CreateTransfersError | Account | Transfer;
8
8
  export declare type ResultCallback = (error: Error | null, results: Result[] | null) => void;
9
9
  export interface ClientInitArgs {
@@ -16,6 +16,7 @@ export interface Client {
16
16
  createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>;
17
17
  lookupAccounts: (batch: AccountID[]) => Promise<Account[]>;
18
18
  lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>;
19
+ getAccountTransfers: (filter: GetAccountTransfers) => Promise<Transfer[]>;
19
20
  destroy: () => void;
20
21
  }
21
22
  export declare function createClient(args: ClientInitArgs): Client;
package/dist/index.js CHANGED
@@ -47,7 +47,7 @@ const binding = (() => {
47
47
  return require(filename);
48
48
  })();
49
49
  function createClient(args) {
50
- const concurrency_max_default = 32;
50
+ const concurrency_max_default = 256;
51
51
  const context = binding.init({
52
52
  cluster_id: args.cluster_id,
53
53
  concurrency: args.concurrency_max || concurrency_max_default,
@@ -78,6 +78,7 @@ function createClient(args) {
78
78
  createTransfers(batch) { return request(bindings_1.Operation.create_transfers, batch); },
79
79
  lookupAccounts(batch) { return request(bindings_1.Operation.lookup_accounts, batch); },
80
80
  lookupTransfers(batch) { return request(bindings_1.Operation.lookup_transfers, batch); },
81
+ getAccountTransfers(filter) { return request(bindings_1.Operation.get_account_transfers, [filter]); },
81
82
  destroy() { binding.deinit(context); },
82
83
  };
83
84
  }
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,yCAMmB;AAEnB,MAAM,OAAO,GAAY,CAAC,GAAG,EAAE;IAC7B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAElC,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,QAAQ;KAChB,CAAA;IAED,MAAM,WAAW,GAAG;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAG,SAAS;KACpB,CAAA;IAED,IAAI,CAAE,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;KAC7C;IAED,IAAI,CAAE,CAAC,QAAQ,IAAI,WAAW,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,IAAI,KAAK,GAAG,EAAE,CAAA;IAcd,MAAM,EAAE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IAAI,KAAK,EAAE;wBACT,MAAM,CAAC,KAAK,CAAC,CAAA;qBACd;yBAAM,IAAI,MAAM,EAAE;wBACjB,OAAO,CAAC,MAAa,CAAC,CAAA;qBACvB;yBAAM;wBACL,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;qBACxE;gBACH,CAAC,CAAC,CAAA;aACH;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,GAAG,CAAC,CAAA;aACZ;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO;QACL,cAAc,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC1E,eAAe,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC5E,cAAc,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC1E,eAAe,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC5E,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA,CAAC,CAAC;KACtC,CAAA;AACH,CAAC;AAjCD,oCAiCC","sourcesContent":["export * from './bindings'\nimport {\n Account,\n Transfer,\n CreateAccountsError,\n CreateTransfersError,\n Operation,\n} from './bindings'\n\nconst binding: Binding = (() => {\n const { arch, platform } = process\n\n const archMap = {\n \"arm64\": \"aarch64\",\n \"x64\": \"x86_64\"\n }\n\n const platformMap = {\n \"linux\": \"linux\",\n \"darwin\": \"macos\",\n \"win32\" : \"windows\",\n }\n\n if (! (arch in archMap)) {\n throw new Error(`Unsupported arch: ${arch}`)\n }\n\n if (! (platform in platformMap)) {\n throw new Error(`Unsupported platform: ${platform}`)\n }\n\n let extra = ''\n\n /**\n * We need to detect during runtime which libc we're running on to load the correct NAPI.\n * binary.\n *\n * Rationale: The /proc/self/map_files/ subdirectory contains entries corresponding to\n * memory-mapped files loaded by Node.\n * https://man7.org/linux/man-pages/man5/proc.5.html: We detect a musl-based distro by\n * checking if any library contains the name \"musl\".\n *\n * Prior art: https://github.com/xerial/sqlite-jdbc/issues/623\n */\n\n const fs = require('fs')\n const path = require('path')\n\n if (platform === 'linux') {\n extra = '-gnu'\n\n for (const file of fs.readdirSync(\"/proc/self/map_files/\")) {\n const realPath = fs.readlinkSync(path.join(\"/proc/self/map_files/\", file))\n if (realPath.includes('musl')) {\n extra = '-musl'\n break\n }\n }\n }\n\n const filename = `./bin/${archMap[arch]}-${platformMap[platform]}${extra}/client.node`\n return require(filename)\n})()\n\nexport type Context = object // tb_client\nexport type AccountID = bigint // u128\nexport type TransferID = bigint // u128\nexport type Event = Account | Transfer | AccountID | TransferID\nexport type Result = CreateAccountsError | CreateTransfersError | Account | Transfer\nexport type ResultCallback = (error: Error | null, results: Result[] | null) => void\n\ninterface BindingInitArgs {\n cluster_id: bigint, // u128\n concurrency: number, // u32\n replica_addresses: Buffer,\n}\n\ninterface Binding {\n init: (args: BindingInitArgs) => Context\n submit: (context: Context, operation: Operation, batch: Event[], callback: ResultCallback) => void\n deinit: (context: Context) => void,\n}\n\nexport interface ClientInitArgs {\n cluster_id: bigint, // u128\n concurrency_max?: number, // u32\n replica_addresses: Array<string | number>,\n}\n\nexport interface Client {\n createAccounts: (batch: Account[]) => Promise<CreateAccountsError[]>\n createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>\n lookupAccounts: (batch: AccountID[]) => Promise<Account[]>\n lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>\n destroy: () => void\n}\n\nexport function createClient (args: ClientInitArgs): Client {\n const concurrency_max_default = 32 // arbitrary\n const context = binding.init({\n cluster_id: args.cluster_id,\n concurrency: args.concurrency_max || concurrency_max_default,\n replica_addresses: Buffer.from(args.replica_addresses.join(',')),\n })\n\n const request = <T extends Result>(operation: Operation, batch: Event[]): Promise<T[]> => {\n return new Promise((resolve, reject) => {\n try {\n binding.submit(context, operation, batch, (error, result) => {\n if (error) {\n reject(error)\n } else if (result) {\n resolve(result as T[])\n } else {\n throw new Error(\"UB: Binding invoked callback without error or result\")\n }\n })\n } catch (err) {\n reject(err)\n }\n })\n }\n\n return {\n createAccounts(batch) { return request(Operation.create_accounts, batch) },\n createTransfers(batch) { return request(Operation.create_transfers, batch) },\n lookupAccounts(batch) { return request(Operation.lookup_accounts, batch) },\n lookupTransfers(batch) { return request(Operation.lookup_transfers, batch) },\n destroy() { binding.deinit(context) },\n }\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA0B;AAC1B,yCAOmB;AAEnB,MAAM,OAAO,GAAY,CAAC,GAAG,EAAE;IAC7B,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAA;IAElC,MAAM,OAAO,GAAG;QACd,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,QAAQ;KAChB,CAAA;IAED,MAAM,WAAW,GAAG;QAClB,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,OAAO;QACjB,OAAO,EAAG,SAAS;KACpB,CAAA;IAED,IAAI,CAAE,CAAC,IAAI,IAAI,OAAO,CAAC,EAAE;QACvB,MAAM,IAAI,KAAK,CAAC,qBAAqB,IAAI,EAAE,CAAC,CAAA;KAC7C;IAED,IAAI,CAAE,CAAC,QAAQ,IAAI,WAAW,CAAC,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,yBAAyB,QAAQ,EAAE,CAAC,CAAA;KACrD;IAED,IAAI,KAAK,GAAG,EAAE,CAAA;IAcd,MAAM,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IACxB,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAA;IAE5B,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CAAC,MAAa,CAAC,CAAA;qBACvB;yBAAM;wBACL,MAAM,IAAI,KAAK,CAAC,sDAAsD,CAAC,CAAA;qBACxE;gBACH,CAAC,CAAC,CAAA;aACH;YAAC,OAAO,GAAG,EAAE;gBACZ,MAAM,CAAC,GAAG,CAAC,CAAA;aACZ;QACH,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;IAED,OAAO;QACL,cAAc,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC1E,eAAe,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC5E,cAAc,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,eAAe,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC1E,eAAe,CAAC,KAAK,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,gBAAgB,EAAE,KAAK,CAAC,CAAA,CAAC,CAAC;QAC5E,mBAAmB,CAAC,MAAM,IAAI,OAAO,OAAO,CAAC,oBAAS,CAAC,qBAAqB,EAAE,CAAC,MAAM,CAAC,CAAC,CAAA,CAAC,CAAC;QACzF,OAAO,KAAK,OAAO,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA,CAAC,CAAC;KACtC,CAAA;AACH,CAAC;AAlCD,oCAkCC","sourcesContent":["export * from './bindings'\nimport {\n Account,\n Transfer,\n CreateAccountsError,\n CreateTransfersError,\n Operation,\n GetAccountTransfers,\n} from './bindings'\n\nconst binding: Binding = (() => {\n const { arch, platform } = process\n\n const archMap = {\n \"arm64\": \"aarch64\",\n \"x64\": \"x86_64\"\n }\n\n const platformMap = {\n \"linux\": \"linux\",\n \"darwin\": \"macos\",\n \"win32\" : \"windows\",\n }\n\n if (! (arch in archMap)) {\n throw new Error(`Unsupported arch: ${arch}`)\n }\n\n if (! (platform in platformMap)) {\n throw new Error(`Unsupported platform: ${platform}`)\n }\n\n let extra = ''\n\n /**\n * We need to detect during runtime which libc we're running on to load the correct NAPI.\n * binary.\n *\n * Rationale: The /proc/self/map_files/ subdirectory contains entries corresponding to\n * memory-mapped files loaded by Node.\n * https://man7.org/linux/man-pages/man5/proc.5.html: We detect a musl-based distro by\n * checking if any library contains the name \"musl\".\n *\n * Prior art: https://github.com/xerial/sqlite-jdbc/issues/623\n */\n\n const fs = require('fs')\n const path = require('path')\n\n if (platform === 'linux') {\n extra = '-gnu'\n\n for (const file of fs.readdirSync(\"/proc/self/map_files/\")) {\n const realPath = fs.readlinkSync(path.join(\"/proc/self/map_files/\", file))\n if (realPath.includes('musl')) {\n extra = '-musl'\n break\n }\n }\n }\n\n const filename = `./bin/${archMap[arch]}-${platformMap[platform]}${extra}/client.node`\n return require(filename)\n})()\n\nexport type Context = object // tb_client\nexport type AccountID = bigint // u128\nexport type TransferID = bigint // u128\nexport type Event = Account | Transfer | AccountID | TransferID | GetAccountTransfers\nexport type Result = CreateAccountsError | CreateTransfersError | Account | Transfer\nexport type ResultCallback = (error: Error | null, results: Result[] | null) => void\n\ninterface BindingInitArgs {\n cluster_id: bigint, // u128\n concurrency: number, // u32\n replica_addresses: Buffer,\n}\n\ninterface Binding {\n init: (args: BindingInitArgs) => Context\n submit: (context: Context, operation: Operation, batch: Event[], callback: ResultCallback) => void\n deinit: (context: Context) => void,\n}\n\nexport interface ClientInitArgs {\n cluster_id: bigint, // u128\n concurrency_max?: number, // u32\n replica_addresses: Array<string | number>,\n}\n\nexport interface Client {\n createAccounts: (batch: Account[]) => Promise<CreateAccountsError[]>\n createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>\n lookupAccounts: (batch: AccountID[]) => Promise<Account[]>\n lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>\n getAccountTransfers: (filter: GetAccountTransfers) => Promise<Transfer[]>\n destroy: () => void\n}\n\nexport function createClient (args: ClientInitArgs): Client {\n const concurrency_max_default = 256 // arbitrary\n const context = binding.init({\n cluster_id: args.cluster_id,\n concurrency: args.concurrency_max || concurrency_max_default,\n replica_addresses: Buffer.from(args.replica_addresses.join(',')),\n })\n\n const request = <T extends Result>(operation: Operation, batch: Event[]): Promise<T[]> => {\n return new Promise((resolve, reject) => {\n try {\n binding.submit(context, operation, batch, (error, result) => {\n if (error) {\n reject(error)\n } else if (result) {\n resolve(result as T[])\n } else {\n throw new Error(\"UB: Binding invoked callback without error or result\")\n }\n })\n } catch (err) {\n reject(err)\n }\n })\n }\n\n return {\n createAccounts(batch) { return request(Operation.create_accounts, batch) },\n createTransfers(batch) { return request(Operation.create_transfers, batch) },\n lookupAccounts(batch) { return request(Operation.lookup_accounts, batch) },\n lookupTransfers(batch) { return request(Operation.lookup_transfers, batch) },\n getAccountTransfers(filter) { return request(Operation.get_account_transfers, [filter]) },\n destroy() { binding.deinit(context) },\n }\n}\n"]}
package/dist/test.js CHANGED
@@ -295,6 +295,147 @@ test('can link transfers', async () => {
295
295
  assert_1.default.strictEqual(accounts[1].debits_posted, 150n);
296
296
  assert_1.default.strictEqual(accounts[1].debits_pending, 0n);
297
297
  });
298
+ test('can get account transfers', async () => {
299
+ const accountC = {
300
+ id: 21n,
301
+ debits_pending: 0n,
302
+ debits_posted: 0n,
303
+ credits_pending: 0n,
304
+ credits_posted: 0n,
305
+ user_data_128: 0n,
306
+ user_data_64: 0n,
307
+ user_data_32: 0,
308
+ reserved: 0,
309
+ ledger: 1,
310
+ code: 718,
311
+ flags: 0,
312
+ timestamp: 0n
313
+ };
314
+ const account_errors = await client.createAccounts([accountC]);
315
+ assert_1.default.strictEqual(account_errors.length, 0);
316
+ var transfers_created = [];
317
+ for (var i = 0; i < 10; i++) {
318
+ transfers_created.push({
319
+ id: BigInt(i + 10000),
320
+ debit_account_id: i % 2 == 0 ? accountC.id : accountA.id,
321
+ credit_account_id: i % 2 == 0 ? accountB.id : accountC.id,
322
+ amount: 100n,
323
+ user_data_128: 0n,
324
+ user_data_64: 0n,
325
+ user_data_32: 0,
326
+ pending_id: 0n,
327
+ timeout: 0,
328
+ ledger: 1,
329
+ code: 1,
330
+ flags: 0,
331
+ timestamp: 0n,
332
+ });
333
+ }
334
+ const transfers_created_result = await client.createTransfers(transfers_created);
335
+ assert_1.default.strictEqual(transfers_created_result.length, 0);
336
+ var filter = {
337
+ account_id: accountC.id,
338
+ timestamp: 0n,
339
+ limit: 0,
340
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.debits,
341
+ };
342
+ var transfers = await client.getAccountTransfers(filter);
343
+ assert_1.default.strictEqual(transfers.length, transfers_created.length);
344
+ var timestamp = 0n;
345
+ for (var transfer of transfers) {
346
+ assert_1.default.ok(timestamp < transfer.timestamp);
347
+ timestamp = transfer.timestamp;
348
+ }
349
+ filter = {
350
+ account_id: accountC.id,
351
+ timestamp: 0n,
352
+ limit: 8190,
353
+ flags: _1.GetAccountTransfersFlags.debits | _1.GetAccountTransfersFlags.reversed,
354
+ };
355
+ transfers = await client.getAccountTransfers(filter);
356
+ assert_1.default.strictEqual(transfers.length, transfers_created.length / 2);
357
+ timestamp = 1n << 64n;
358
+ for (var transfer of transfers) {
359
+ assert_1.default.ok(transfer.timestamp < timestamp);
360
+ timestamp = transfer.timestamp;
361
+ }
362
+ filter = {
363
+ account_id: accountC.id,
364
+ timestamp: 0n,
365
+ limit: 8190,
366
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.reversed,
367
+ };
368
+ transfers = await client.getAccountTransfers(filter);
369
+ assert_1.default.strictEqual(transfers.length, transfers_created.length / 2);
370
+ timestamp = 1n << 64n;
371
+ for (var transfer of transfers) {
372
+ assert_1.default.ok(transfer.timestamp < timestamp);
373
+ timestamp = transfer.timestamp;
374
+ }
375
+ filter = {
376
+ account_id: accountC.id,
377
+ timestamp: 0n,
378
+ limit: transfers_created.length / 2,
379
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.debits,
380
+ };
381
+ transfers = await client.getAccountTransfers(filter);
382
+ assert_1.default.strictEqual(transfers.length, transfers_created.length / 2);
383
+ timestamp = 0n;
384
+ for (var transfer of transfers) {
385
+ assert_1.default.ok(timestamp < transfer.timestamp);
386
+ timestamp = transfer.timestamp;
387
+ }
388
+ filter = {
389
+ account_id: accountC.id,
390
+ timestamp: timestamp,
391
+ limit: transfers_created.length / 2,
392
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.debits,
393
+ };
394
+ transfers = await client.getAccountTransfers(filter);
395
+ assert_1.default.strictEqual(transfers.length, transfers_created.length / 2);
396
+ for (var transfer of transfers) {
397
+ assert_1.default.ok(timestamp < transfer.timestamp);
398
+ timestamp = transfer.timestamp;
399
+ }
400
+ filter = {
401
+ account_id: accountC.id,
402
+ timestamp: timestamp,
403
+ limit: transfers_created.length / 2,
404
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.debits,
405
+ };
406
+ transfers = await client.getAccountTransfers(filter);
407
+ assert_1.default.strictEqual(transfers.length, 0);
408
+ assert_1.default.strictEqual((await client.getAccountTransfers({
409
+ account_id: 0n,
410
+ timestamp: timestamp,
411
+ limit: 8190,
412
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.debits,
413
+ })).length, 0);
414
+ assert_1.default.strictEqual((await client.getAccountTransfers({
415
+ account_id: accountC.id,
416
+ timestamp: (1n << 64n) - 1n,
417
+ limit: 8190,
418
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.debits,
419
+ })).length, 0);
420
+ assert_1.default.strictEqual((await client.getAccountTransfers({
421
+ account_id: accountC.id,
422
+ timestamp: 0n,
423
+ limit: 0,
424
+ flags: _1.GetAccountTransfersFlags.credits | _1.GetAccountTransfersFlags.debits,
425
+ })).length, 0);
426
+ assert_1.default.strictEqual((await client.getAccountTransfers({
427
+ account_id: accountC.id,
428
+ timestamp: 0n,
429
+ limit: 8190,
430
+ flags: _1.GetAccountTransfersFlags.none,
431
+ })).length, 0);
432
+ assert_1.default.strictEqual((await client.getAccountTransfers({
433
+ account_id: accountC.id,
434
+ timestamp: 0n,
435
+ limit: 8190,
436
+ flags: 0xFFFF,
437
+ })).length, 0);
438
+ });
298
439
  async function main() {
299
440
  const start = new Date().getTime();
300
441
  try {
package/dist/test.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"test.js","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":";;;;;AAAA,oDAA+C;AAC/C,wBAOU;AAEV,MAAM,MAAM,GAAG,IAAA,eAAY,EAAC;IAC1B,UAAU,EAAE,EAAE;IACd,iBAAiB,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,MAAM,CAAC;CACtD,CAAC,CAAA;AAGF,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AACzC,MAAM,aAAa,GAAG,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC,CAAC,CAAA;AACzC,MAAM,QAAQ,GAAY;IACxB,EAAE,EAAE,GAAG;IACP,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,EAAE;IACjB,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC;IACX,MAAM,EAAE,CAAC;IACT,IAAI,EAAE,GAAG;IACT,KAAK,EAAE,CAAC;IACR,SAAS,EAAE,EAAE;CACd,CAAA;AACD,MAAM,QAAQ,GAAY;IACxB,EAAE,EAAE,GAAG;IACP,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,EAAE;IACjB,eAAe,EAAE,EAAE;IACnB,cAAc,EAAE,EAAE;IAClB,aAAa,EAAE,EAAE;IACjB,YAAY,EAAE,EAAE;IAChB,YAAY,EAAE,CAAC;IACf,QAAQ,EAAE,CAAC;IACX,MAAM,E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9B,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,CAAA;YACzC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,EAAE;gBACf,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,GAAG,UAAU,CAAC,CAAA;gBACvC,MAAM,KAAK,CAAA;YACb,CAAC,CAAC,CAAA;SACH;QACD,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAA;QAChC,OAAO,CAAC,GAAG,CAAC,iBAAiB,EAAE,CAAC,GAAG,GAAG,KAAK,CAAC,GAAC,IAAI,CAAC,CAAA;KACnD;YAAS;QACR,MAAM,MAAM,CAAC,OAAO,EAAE,CAAA;KACvB;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAqB,EAAE,EAAE;IACrC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC,CAAC,CAAA","sourcesContent":["import assert, { AssertionError } from 'assert'\nimport {\n createClient,\n Account,\n Transfer,\n TransferFlags,\n CreateAccountError,\n CreateTransferError\n} from '.'\n\nconst client = createClient({\n cluster_id: 0n,\n replica_addresses: [process.env.TB_ADDRESS || '3000']\n})\n\n// Test data\nconst Zeroed32Bytes = Buffer.alloc(32, 0)\nconst Zeroed48Bytes = Buffer.alloc(48, 0)\nconst accountA: Account = {\n id: 17n,\n debits_pending: 0n,\n debits_posted: 0n,\n credits_pending: 0n,\n credits_posted: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n reserved: 0,\n ledger: 1,\n code: 718,\n flags: 0,\n timestamp: 0n // this will be set correctly by the TigerBeetle server\n}\nconst accountB: Account = {\n id: 19n,\n debits_pending: 0n,\n debits_posted: 0n,\n credits_pending: 0n,\n credits_posted: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n reserved: 0,\n ledger: 1,\n code: 719,\n flags: 0,\n timestamp: 0n // this will be set correctly by the TigerBeetle server\n}\n\nconst tests: Array<{ name: string, fn: () => Promise<void> }> = []\nfunction test(name: string, fn: () => Promise<void>) {\n tests.push({ name, fn })\n}\ntest.skip = (name: string, fn: () => Promise<void>) => {\n console.log(name + ': SKIPPED')\n}\n\ntest('range check `code` on Account to be u16', async (): Promise<void> => {\n const account = { ...accountA, id: 0n }\n\n account.code = 65535 + 1\n const codeError = await client.createAccounts([account]).catch(error => error)\n assert.strictEqual(codeError.message, 'code must be a u16.')\n\n const accounts = await client.lookupAccounts([account.id])\n assert.strictEqual(accounts.length, 0)\n})\n\ntest('can create accounts', async (): Promise<void> => {\n const errors = await client.createAccounts([accountA])\n assert.strictEqual(errors.length, 0)\n})\n\ntest('can return error on account', async (): Promise<void> => {\n const errors = await client.createAccounts([accountA, accountB])\n\n assert.strictEqual(errors.length, 1)\n assert.deepStrictEqual(errors[0], { index: 0, result: CreateAccountError.exists })\n})\n\ntest('throws error if timestamp is not set to 0n on account', async (): Promise<void> => {\n const account = { ...accountA, timestamp: 2n, id: 3n }\n await assert.rejects(client.createAccounts([account]))\n})\n\ntest('can lookup accounts', async (): Promise<void> => {\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n\n assert.strictEqual(accounts.length, 2)\n const account1 = accounts[0]\n assert.strictEqual(account1.id, 17n)\n assert.strictEqual(account1.credits_posted, 0n)\n assert.strictEqual(account1.credits_pending, 0n)\n assert.strictEqual(account1.debits_posted, 0n)\n assert.strictEqual(account1.debits_pending, 0n)\n assert.strictEqual(account1.user_data_128, 0n)\n assert.strictEqual(account1.user_data_64, 0n)\n assert.strictEqual(account1.user_data_32, 0)\n assert.strictEqual(account1.code, 718)\n assert.strictEqual(account1.ledger, 1)\n assert.strictEqual(account1.flags, 0)\n assert.ok(account1.timestamp > 0n)\n\n const account2 = accounts[1]\n assert.strictEqual(account2.id, 19n)\n assert.strictEqual(account2.credits_posted, 0n)\n assert.strictEqual(account2.credits_pending, 0n)\n assert.strictEqual(account2.debits_posted, 0n)\n assert.strictEqual(account2.debits_pending, 0n)\n assert.strictEqual(account2.user_data_128, 0n)\n assert.strictEqual(account2.user_data_64, 0n)\n assert.strictEqual(account2.user_data_32, 0)\n assert.strictEqual(account2.code, 719)\n assert.strictEqual(account2.ledger, 1)\n assert.strictEqual(account2.flags, 0)\n assert.ok(account2.timestamp > 0n)\n})\n\ntest('can create a transfer', async (): Promise<void> => {\n const transfer: Transfer = {\n id: 1n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 100n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: 0,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([transfer])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 100n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 100n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\ntest('can create a two-phase transfer', async (): Promise<void> => {\n let flags = 0\n flags |= TransferFlags.pending\n const transfer: Transfer = {\n id: 2n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 50n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 2e9,\n ledger: 1,\n code: 1,\n flags,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([transfer])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 100n)\n assert.strictEqual(accounts[0].credits_pending, 50n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 100n)\n assert.strictEqual(accounts[1].debits_pending, 50n)\n\n // Lookup the transfer:\n const transfers = await client.lookupTransfers([transfer.id])\n assert.strictEqual(transfers.length, 1)\n assert.strictEqual(transfers[0].id, 2n)\n assert.strictEqual(transfers[0].debit_account_id, accountB.id)\n assert.strictEqual(transfers[0].credit_account_id, accountA.id)\n assert.strictEqual(transfers[0].amount, 50n)\n assert.strictEqual(transfers[0].user_data_128, 0n)\n assert.strictEqual(transfers[0].user_data_64, 0n)\n assert.strictEqual(transfers[0].user_data_32, 0)\n assert.strictEqual(transfers[0].timeout > 0, true)\n assert.strictEqual(transfers[0].code, 1)\n assert.strictEqual(transfers[0].flags, 2)\n assert.strictEqual(transfers[0].timestamp > 0, true)\n})\n\ntest('can post a two-phase transfer', async (): Promise<void> => {\n let flags = 0\n flags |= TransferFlags.post_pending_transfer\n\n const commit: Transfer = {\n id: 3n,\n debit_account_id: BigInt(0),\n credit_account_id: BigInt(0),\n amount: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 2n,// must match the id of the pending transfer\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: flags,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([commit])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 150n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 150n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\ntest('can reject a two-phase transfer', async (): Promise<void> => {\n // Create a two-phase transfer:\n const transfer: Transfer = {\n id: 4n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 50n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 1e9,\n ledger: 1,\n code: 1,\n flags: TransferFlags.pending,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n const transferErrors = await client.createTransfers([transfer])\n assert.strictEqual(transferErrors.length, 0)\n\n // send in the reject\n const reject: Transfer = {\n id: 5n,\n debit_account_id: BigInt(0),\n credit_account_id: BigInt(0),\n amount: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 4n, // must match the id of the pending transfer\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: TransferFlags.void_pending_transfer,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([reject])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 150n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 150n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\ntest('can link transfers', async (): Promise<void> => {\n const transfer1: Transfer = {\n id: 6n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 100n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: TransferFlags.linked, // points to transfer2\n timestamp: 0n, // will be set correctly by the TigerBeetle server\n }\n const transfer2: Transfer = {\n id: 6n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 100n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 0,\n ledger: 1,\n code: 1,\n // Does not have linked flag as it is the end of the chain.\n // This will also cause it to fail as this is now a duplicate with different flags\n flags: 0,\n timestamp: 0n, // will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([transfer1, transfer2])\n assert.strictEqual(errors.length, 2)\n assert.deepStrictEqual(errors[0], { index: 0, result: CreateTransferError.linked_event_failed })\n assert.deepStrictEqual(errors[1], { index: 1, result: CreateTransferError.exists_with_different_flags })\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 150n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 150n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\nasync function main () {\n const start = new Date().getTime()\n try {\n for (let i = 0; i < tests.length; i++) {\n await tests[i].fn().then(() => {\n console.log(tests[i].name + \": PASSED\")\n }).catch(error => {\n console.log(tests[i].name + \": FAILED\")\n throw error\n })\n }\n const end = new Date().getTime()\n console.log('Time taken (s):', (end - start)/1000)\n } finally {\n await client.destroy()\n }\n}\n\nmain().catch((error: AssertionError) => {\n console.log('operator:', error.operator)\n console.log('stack:', error.st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M,MAAM,CAAC,OAAO,EAAE,CAAA;KACvB;AACH,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAqB,EAAE,EAAE;IACrC,OAAO,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;IACxC,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAA;AACpC,CAAC,CAAC,CAAA","sourcesContent":["import assert, { AssertionError } from 'assert'\nimport {\n createClient,\n Account,\n Transfer,\n TransferFlags,\n CreateAccountError,\n CreateTransferError,\n GetAccountTransfers,\n GetAccountTransfersFlags,\n} from '.'\n\nconst client = createClient({\n cluster_id: 0n,\n replica_addresses: [process.env.TB_ADDRESS || '3000']\n})\n\n// Test data\nconst Zeroed32Bytes = Buffer.alloc(32, 0)\nconst Zeroed48Bytes = Buffer.alloc(48, 0)\nconst accountA: Account = {\n id: 17n,\n debits_pending: 0n,\n debits_posted: 0n,\n credits_pending: 0n,\n credits_posted: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n reserved: 0,\n ledger: 1,\n code: 718,\n flags: 0,\n timestamp: 0n // this will be set correctly by the TigerBeetle server\n}\nconst accountB: Account = {\n id: 19n,\n debits_pending: 0n,\n debits_posted: 0n,\n credits_pending: 0n,\n credits_posted: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n reserved: 0,\n ledger: 1,\n code: 719,\n flags: 0,\n timestamp: 0n // this will be set correctly by the TigerBeetle server\n}\n\nconst tests: Array<{ name: string, fn: () => Promise<void> }> = []\nfunction test(name: string, fn: () => Promise<void>) {\n tests.push({ name, fn })\n}\ntest.skip = (name: string, fn: () => Promise<void>) => {\n console.log(name + ': SKIPPED')\n}\n\ntest('range check `code` on Account to be u16', async (): Promise<void> => {\n const account = { ...accountA, id: 0n }\n\n account.code = 65535 + 1\n const codeError = await client.createAccounts([account]).catch(error => error)\n assert.strictEqual(codeError.message, 'code must be a u16.')\n\n const accounts = await client.lookupAccounts([account.id])\n assert.strictEqual(accounts.length, 0)\n})\n\ntest('can create accounts', async (): Promise<void> => {\n const errors = await client.createAccounts([accountA])\n assert.strictEqual(errors.length, 0)\n})\n\ntest('can return error on account', async (): Promise<void> => {\n const errors = await client.createAccounts([accountA, accountB])\n\n assert.strictEqual(errors.length, 1)\n assert.deepStrictEqual(errors[0], { index: 0, result: CreateAccountError.exists })\n})\n\ntest('throws error if timestamp is not set to 0n on account', async (): Promise<void> => {\n const account = { ...accountA, timestamp: 2n, id: 3n }\n await assert.rejects(client.createAccounts([account]))\n})\n\ntest('can lookup accounts', async (): Promise<void> => {\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n\n assert.strictEqual(accounts.length, 2)\n const account1 = accounts[0]\n assert.strictEqual(account1.id, 17n)\n assert.strictEqual(account1.credits_posted, 0n)\n assert.strictEqual(account1.credits_pending, 0n)\n assert.strictEqual(account1.debits_posted, 0n)\n assert.strictEqual(account1.debits_pending, 0n)\n assert.strictEqual(account1.user_data_128, 0n)\n assert.strictEqual(account1.user_data_64, 0n)\n assert.strictEqual(account1.user_data_32, 0)\n assert.strictEqual(account1.code, 718)\n assert.strictEqual(account1.ledger, 1)\n assert.strictEqual(account1.flags, 0)\n assert.ok(account1.timestamp > 0n)\n\n const account2 = accounts[1]\n assert.strictEqual(account2.id, 19n)\n assert.strictEqual(account2.credits_posted, 0n)\n assert.strictEqual(account2.credits_pending, 0n)\n assert.strictEqual(account2.debits_posted, 0n)\n assert.strictEqual(account2.debits_pending, 0n)\n assert.strictEqual(account2.user_data_128, 0n)\n assert.strictEqual(account2.user_data_64, 0n)\n assert.strictEqual(account2.user_data_32, 0)\n assert.strictEqual(account2.code, 719)\n assert.strictEqual(account2.ledger, 1)\n assert.strictEqual(account2.flags, 0)\n assert.ok(account2.timestamp > 0n)\n})\n\ntest('can create a transfer', async (): Promise<void> => {\n const transfer: Transfer = {\n id: 1n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 100n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: 0,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([transfer])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 100n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 100n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\ntest('can create a two-phase transfer', async (): Promise<void> => {\n let flags = 0\n flags |= TransferFlags.pending\n const transfer: Transfer = {\n id: 2n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 50n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 2e9,\n ledger: 1,\n code: 1,\n flags,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([transfer])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 100n)\n assert.strictEqual(accounts[0].credits_pending, 50n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 100n)\n assert.strictEqual(accounts[1].debits_pending, 50n)\n\n // Lookup the transfer:\n const transfers = await client.lookupTransfers([transfer.id])\n assert.strictEqual(transfers.length, 1)\n assert.strictEqual(transfers[0].id, 2n)\n assert.strictEqual(transfers[0].debit_account_id, accountB.id)\n assert.strictEqual(transfers[0].credit_account_id, accountA.id)\n assert.strictEqual(transfers[0].amount, 50n)\n assert.strictEqual(transfers[0].user_data_128, 0n)\n assert.strictEqual(transfers[0].user_data_64, 0n)\n assert.strictEqual(transfers[0].user_data_32, 0)\n assert.strictEqual(transfers[0].timeout > 0, true)\n assert.strictEqual(transfers[0].code, 1)\n assert.strictEqual(transfers[0].flags, 2)\n assert.strictEqual(transfers[0].timestamp > 0, true)\n})\n\ntest('can post a two-phase transfer', async (): Promise<void> => {\n let flags = 0\n flags |= TransferFlags.post_pending_transfer\n\n const commit: Transfer = {\n id: 3n,\n debit_account_id: BigInt(0),\n credit_account_id: BigInt(0),\n amount: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 2n,// must match the id of the pending transfer\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: flags,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([commit])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 150n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 150n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\ntest('can reject a two-phase transfer', async (): Promise<void> => {\n // Create a two-phase transfer:\n const transfer: Transfer = {\n id: 4n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 50n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 1e9,\n ledger: 1,\n code: 1,\n flags: TransferFlags.pending,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n const transferErrors = await client.createTransfers([transfer])\n assert.strictEqual(transferErrors.length, 0)\n\n // send in the reject\n const reject: Transfer = {\n id: 5n,\n debit_account_id: BigInt(0),\n credit_account_id: BigInt(0),\n amount: 0n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 4n, // must match the id of the pending transfer\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: TransferFlags.void_pending_transfer,\n timestamp: 0n, // this will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([reject])\n assert.strictEqual(errors.length, 0)\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 150n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 150n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\ntest('can link transfers', async (): Promise<void> => {\n const transfer1: Transfer = {\n id: 6n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 100n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: TransferFlags.linked, // points to transfer2\n timestamp: 0n, // will be set correctly by the TigerBeetle server\n }\n const transfer2: Transfer = {\n id: 6n,\n debit_account_id: accountB.id,\n credit_account_id: accountA.id,\n amount: 100n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 0,\n ledger: 1,\n code: 1,\n // Does not have linked flag as it is the end of the chain.\n // This will also cause it to fail as this is now a duplicate with different flags\n flags: 0,\n timestamp: 0n, // will be set correctly by the TigerBeetle server\n }\n\n const errors = await client.createTransfers([transfer1, transfer2])\n assert.strictEqual(errors.length, 2)\n assert.deepStrictEqual(errors[0], { index: 0, result: CreateTransferError.linked_event_failed })\n assert.deepStrictEqual(errors[1], { index: 1, result: CreateTransferError.exists_with_different_flags })\n\n const accounts = await client.lookupAccounts([accountA.id, accountB.id])\n assert.strictEqual(accounts.length, 2)\n assert.strictEqual(accounts[0].credits_posted, 150n)\n assert.strictEqual(accounts[0].credits_pending, 0n)\n assert.strictEqual(accounts[0].debits_posted, 0n)\n assert.strictEqual(accounts[0].debits_pending, 0n)\n\n assert.strictEqual(accounts[1].credits_posted, 0n)\n assert.strictEqual(accounts[1].credits_pending, 0n)\n assert.strictEqual(accounts[1].debits_posted, 150n)\n assert.strictEqual(accounts[1].debits_pending, 0n)\n})\n\ntest('can get account transfers', async (): Promise<void> => {\n const accountC: Account = {\n id: 21n,\n debits_pending: 0n,\n debits_posted: 0n,\n credits_pending: 0n,\n credits_posted: 0n, \n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n reserved: 0,\n ledger: 1,\n code: 718,\n flags: 0,\n timestamp: 0n\n }\n const account_errors = await client.createAccounts([accountC])\n assert.strictEqual(account_errors.length, 0)\n\n var transfers_created : Transfer[] = [];\n // Create transfers where the new account is either the debit or credit account:\n for (var i=0; i<10;i++) {\n transfers_created.push({\n id: BigInt(i + 10000),\n debit_account_id: i % 2 == 0 ? accountC.id : accountA.id,\n credit_account_id: i % 2 == 0 ? accountB.id : accountC.id,\n amount: 100n,\n user_data_128: 0n,\n user_data_64: 0n,\n user_data_32: 0,\n pending_id: 0n,\n timeout: 0,\n ledger: 1,\n code: 1,\n flags: 0,\n timestamp: 0n,\n });\n }\n \n const transfers_created_result = await client.createTransfers(transfers_created)\n assert.strictEqual(transfers_created_result.length, 0)\n\n // Query all transfers for accountC:\n var filter: GetAccountTransfers = {\n account_id: accountC.id,\n timestamp: 0n,\n limit: 0,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,\n }\n var transfers = await client.getAccountTransfers(filter)\n assert.strictEqual(transfers.length, transfers_created.length)\n var timestamp = 0n;\n for (var transfer of transfers) {\n assert.ok(timestamp < transfer.timestamp);\n timestamp = transfer.timestamp;\n }\n\n // Query only the debit transfers for accountC, descending:\n filter = {\n account_id: accountC.id,\n timestamp: 0n,\n limit: 8190,\n flags: GetAccountTransfersFlags.debits | GetAccountTransfersFlags.reversed,\n }\n transfers = await client.getAccountTransfers(filter)\n assert.strictEqual(transfers.length, transfers_created.length / 2)\n timestamp = 1n << 64n;\n for (var transfer of transfers) {\n assert.ok(transfer.timestamp < timestamp);\n timestamp = transfer.timestamp;\n } \n\n // Query only the credit transfers for accountC, descending:\n filter = {\n account_id: accountC.id,\n timestamp: 0n,\n limit: 8190,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.reversed,\n }\n transfers = await client.getAccountTransfers(filter)\n assert.strictEqual(transfers.length, transfers_created.length / 2)\n timestamp = 1n << 64n;\n for (var transfer of transfers) {\n assert.ok(transfer.timestamp < timestamp);\n timestamp = transfer.timestamp;\n } \n\n // Query the first 5 transfers for accountC:\n filter = {\n account_id: accountC.id,\n timestamp: 0n,\n limit: transfers_created.length / 2,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,\n }\n transfers = await client.getAccountTransfers(filter)\n assert.strictEqual(transfers.length, transfers_created.length / 2)\n timestamp = 0n;\n for (var transfer of transfers) {\n assert.ok(timestamp < transfer.timestamp);\n timestamp = transfer.timestamp;\n } \n\n // Query the next 5 transfers for accountC, with pagination:\n filter = {\n account_id: accountC.id,\n timestamp: timestamp,\n limit: transfers_created.length / 2,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,\n }\n transfers = await client.getAccountTransfers(filter)\n assert.strictEqual(transfers.length, transfers_created.length / 2)\n for (var transfer of transfers) {\n assert.ok(timestamp < transfer.timestamp);\n timestamp = transfer.timestamp;\n } \n\n // Query again, no more transfers should be found:\n filter = {\n account_id: accountC.id,\n timestamp: timestamp,\n limit: transfers_created.length / 2,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,\n }\n transfers = await client.getAccountTransfers(filter)\n assert.strictEqual(transfers.length, 0)\n\n\n // Invalid account:\n assert.strictEqual((await client.getAccountTransfers({\n account_id: 0n,\n timestamp: timestamp,\n limit: 8190,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,\n })).length, 0)\n\n // Invalid timestamp:\n assert.strictEqual((await client.getAccountTransfers({\n account_id: accountC.id,\n timestamp: (1n << 64n) - 1n,\n limit: 8190,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,\n })).length, 0)\n\n // Zero limit:\n assert.strictEqual((await client.getAccountTransfers({\n account_id: accountC.id,\n timestamp: 0n,\n limit: 0,\n flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,\n })).length, 0) \n \n // Empty flags:\n assert.strictEqual((await client.getAccountTransfers({\n account_id: accountC.id,\n timestamp: 0n,\n limit: 8190,\n flags: GetAccountTransfersFlags.none,\n })).length, 0)\n\n // Invalid flags:\n assert.strictEqual((await client.getAccountTransfers({\n account_id: accountC.id,\n timestamp: 0n,\n limit: 8190,\n flags: 0xFFFF,\n })).length, 0) \n\n})\n\nasync function main () {\n const start = new Date().getTime()\n try {\n for (let i = 0; i < tests.length; i++) {\n await tests[i].fn().then(() => {\n console.log(tests[i].name + \": PASSED\")\n }).catch(error => {\n console.log(tests[i].name + \": FAILED\")\n throw error\n })\n }\n const end = new Date().getTime()\n console.log('Time taken (s):', (end - start)/1000)\n } finally {\n await client.destroy()\n }\n}\n\nmain().catch((error: AssertionError) => {\n console.log('operator:', error.operator)\n console.log('stack:', error.stack)\n})\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tigerbeetle-node",
3
- "version": "0.14.169",
3
+ "version": "0.14.174",
4
4
  "description": "TigerBeetle Node.js client",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
package/src/bindings.ts CHANGED
@@ -65,6 +65,29 @@ export enum TransferFlags {
65
65
  }
66
66
 
67
67
 
68
+ /**
69
+ * See [GetAccountTransfersFlags](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flags)
70
+ */
71
+ export enum GetAccountTransfersFlags {
72
+ none = 0,
73
+
74
+ /**
75
+ * See [debits](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagsdebits)
76
+ */
77
+ debits = (1 << 0),
78
+
79
+ /**
80
+ * See [credits](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagscredits)
81
+ */
82
+ credits = (1 << 1),
83
+
84
+ /**
85
+ * See [reversed](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flagsreversed)
86
+ */
87
+ reversed = (1 << 2),
88
+ }
89
+
90
+
68
91
  /**
69
92
  * See [Account](https://docs.tigerbeetle.com/reference/accounts/#)
70
93
  */
@@ -622,10 +645,38 @@ export type CreateTransfersError = {
622
645
  result: CreateTransferError
623
646
  }
624
647
 
648
+
649
+ /**
650
+ * See [GetAccountTransfers](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#)
651
+ */
652
+ export type GetAccountTransfers = {
653
+
654
+ /**
655
+ * See [account_id](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#account_id)
656
+ */
657
+ account_id: bigint
658
+
659
+ /**
660
+ * See [timestamp](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#timestamp)
661
+ */
662
+ timestamp: bigint
663
+
664
+ /**
665
+ * See [limit](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#limit)
666
+ */
667
+ limit: number
668
+
669
+ /**
670
+ * See [flags](https://docs.tigerbeetle.com/reference/operations/get_account_transfers#flags)
671
+ */
672
+ flags: number
673
+ }
674
+
625
675
  export enum Operation {
626
676
  create_accounts = 128,
627
677
  create_transfers = 129,
628
678
  lookup_accounts = 130,
629
679
  lookup_transfers = 131,
680
+ get_account_transfers = 132,
630
681
  }
631
682
 
package/src/index.ts CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  CreateAccountsError,
6
6
  CreateTransfersError,
7
7
  Operation,
8
+ GetAccountTransfers,
8
9
  } from './bindings'
9
10
 
10
11
  const binding: Binding = (() => {
@@ -65,7 +66,7 @@ const binding: Binding = (() => {
65
66
  export type Context = object // tb_client
66
67
  export type AccountID = bigint // u128
67
68
  export type TransferID = bigint // u128
68
- export type Event = Account | Transfer | AccountID | TransferID
69
+ export type Event = Account | Transfer | AccountID | TransferID | GetAccountTransfers
69
70
  export type Result = CreateAccountsError | CreateTransfersError | Account | Transfer
70
71
  export type ResultCallback = (error: Error | null, results: Result[] | null) => void
71
72
 
@@ -92,11 +93,12 @@ export interface Client {
92
93
  createTransfers: (batch: Transfer[]) => Promise<CreateTransfersError[]>
93
94
  lookupAccounts: (batch: AccountID[]) => Promise<Account[]>
94
95
  lookupTransfers: (batch: TransferID[]) => Promise<Transfer[]>
96
+ getAccountTransfers: (filter: GetAccountTransfers) => Promise<Transfer[]>
95
97
  destroy: () => void
96
98
  }
97
99
 
98
100
  export function createClient (args: ClientInitArgs): Client {
99
- const concurrency_max_default = 32 // arbitrary
101
+ const concurrency_max_default = 256 // arbitrary
100
102
  const context = binding.init({
101
103
  cluster_id: args.cluster_id,
102
104
  concurrency: args.concurrency_max || concurrency_max_default,
@@ -126,6 +128,7 @@ export function createClient (args: ClientInitArgs): Client {
126
128
  createTransfers(batch) { return request(Operation.create_transfers, batch) },
127
129
  lookupAccounts(batch) { return request(Operation.lookup_accounts, batch) },
128
130
  lookupTransfers(batch) { return request(Operation.lookup_transfers, batch) },
131
+ getAccountTransfers(filter) { return request(Operation.get_account_transfers, [filter]) },
129
132
  destroy() { binding.deinit(context) },
130
133
  }
131
134
  }
package/src/node.zig CHANGED
@@ -15,6 +15,8 @@ const Transfer = tb.Transfer;
15
15
  const TransferFlags = tb.TransferFlags;
16
16
  const CreateAccountsResult = tb.CreateAccountsResult;
17
17
  const CreateTransfersResult = tb.CreateTransfersResult;
18
+ const GetAccountTransfers = tb.GetAccountTransfers;
19
+ const GetAccountTransfersFlags = tb.GetAccountTransfersFlags;
18
20
 
19
21
  const Storage = @import("../../../storage.zig").Storage;
20
22
  const StateMachine = @import("../../../state_machine.zig").StateMachineType(Storage, constants.state_machine_config);
@@ -219,7 +221,10 @@ fn request(
219
221
 
220
222
  const packet_data = switch (operation) {
221
223
  inline else => |op| blk: {
222
- const buffer = try BufferType(op).alloc(env, array_length);
224
+ const buffer = try BufferType(op).alloc(
225
+ env,
226
+ array_length,
227
+ );
223
228
  errdefer buffer.free();
224
229
 
225
230
  const events = buffer.events();
@@ -362,7 +367,7 @@ fn decode_array(comptime Event: type, env: c.napi_env, array: c.napi_value, even
362
367
  for (events, 0..) |*event, i| {
363
368
  const object = try translate.array_element(env, array, @intCast(i));
364
369
  switch (Event) {
365
- Account, Transfer => {
370
+ Account, Transfer, GetAccountTransfers => {
366
371
  inline for (std.meta.fields(Event)) |field| {
367
372
  const FieldInt = switch (@typeInfo(field.type)) {
368
373
  .Struct => |info| info.backing_integer.?,
@@ -375,13 +380,6 @@ fn decode_array(comptime Event: type, env: c.napi_env, array: c.napi_value, even
375
380
  add_trailing_null(field.name),
376
381
  );
377
382
 
378
- if (std.mem.eql(u8, field.name, "timestamp") and value != 0) {
379
- return translate.throw(
380
- env,
381
- "Timestamp should be set to 0 as this will be set correctly by Replica.",
382
- );
383
- }
384
-
385
383
  @field(event, field.name) = switch (@typeInfo(field.type)) {
386
384
  .Struct => @as(field.type, @bitCast(value)),
387
385
  else => value,
@@ -423,7 +421,7 @@ fn encode_array(comptime Result: type, env: c.napi_env, results: []const Result)
423
421
  try @field(translate, @typeName(FieldInt) ++ "_into_object")(
424
422
  env,
425
423
  object,
426
- @ptrCast(field.name ++ "\x00"),
424
+ add_trailing_null(field.name),
427
425
  value,
428
426
  "Failed to set property \"" ++ field.name ++ "\" of " ++ @typeName(Result) ++ " object",
429
427
  );
@@ -464,7 +462,12 @@ fn BufferType(comptime op: Operation) type {
464
462
 
465
463
  fn alloc(env: c.napi_env, count: u32) !Buffer {
466
464
  // Allocate enough bytes to hold memory for the Events and the Results.
467
- const max_bytes = @max(@sizeOf(Event) * count, @sizeOf(Result) * count);
465
+ const max_bytes = @max(
466
+ @sizeOf(Event) * count,
467
+ @sizeOf(Result) *
468
+ // Ad-hoc hack, event and result sizes are not the same size.
469
+ if (op == .get_account_transfers) 8190 else count,
470
+ );
468
471
  if (@sizeOf(vsr.Header) + max_bytes > constants.message_size_max) {
469
472
  return translate.throw(env, "Batch is larger than the maximum message size.");
470
473
  }
@@ -481,7 +484,12 @@ fn BufferType(comptime op: Operation) type {
481
484
  }
482
485
 
483
486
  fn free(buffer: Buffer) void {
484
- const max_bytes = @max(@sizeOf(Event) * buffer.count, @sizeOf(Result) * buffer.count);
487
+ const max_bytes = @max(
488
+ @sizeOf(Event) * buffer.count,
489
+ @sizeOf(Result) *
490
+ //TODO(batiati): Refine the way we handle events with asymmetric results.
491
+ if (op == .get_account_transfers) 8190 else buffer.count,
492
+ );
485
493
  const bytes: []align(max_align) u8 = @alignCast(buffer.ptr[0..max_bytes]);
486
494
  allocator.free(bytes);
487
495
  }
@@ -492,7 +500,9 @@ fn BufferType(comptime op: Operation) type {
492
500
  }
493
501
 
494
502
  fn results(buffer: Buffer) []Result {
495
- const result_bytes = buffer.ptr[0 .. @sizeOf(Result) * buffer.count];
503
+ const result_bytes = buffer.ptr[0 .. @sizeOf(Result) *
504
+ // Ad-hoc hack, event and result sizes are not the same size.
505
+ if (op == .get_account_transfers) 8190 else buffer.count];
496
506
  return @alignCast(std.mem.bytesAsSlice(Result, result_bytes));
497
507
  }
498
508
  };
package/src/test.ts CHANGED
@@ -5,7 +5,9 @@ import {
5
5
  Transfer,
6
6
  TransferFlags,
7
7
  CreateAccountError,
8
- CreateTransferError
8
+ CreateTransferError,
9
+ GetAccountTransfers,
10
+ GetAccountTransfersFlags,
9
11
  } from '.'
10
12
 
11
13
  const client = createClient({
@@ -340,6 +342,175 @@ test('can link transfers', async (): Promise<void> => {
340
342
  assert.strictEqual(accounts[1].debits_pending, 0n)
341
343
  })
342
344
 
345
+ test('can get account transfers', async (): Promise<void> => {
346
+ const accountC: Account = {
347
+ id: 21n,
348
+ debits_pending: 0n,
349
+ debits_posted: 0n,
350
+ credits_pending: 0n,
351
+ credits_posted: 0n,
352
+ user_data_128: 0n,
353
+ user_data_64: 0n,
354
+ user_data_32: 0,
355
+ reserved: 0,
356
+ ledger: 1,
357
+ code: 718,
358
+ flags: 0,
359
+ timestamp: 0n
360
+ }
361
+ const account_errors = await client.createAccounts([accountC])
362
+ assert.strictEqual(account_errors.length, 0)
363
+
364
+ var transfers_created : Transfer[] = [];
365
+ // Create transfers where the new account is either the debit or credit account:
366
+ for (var i=0; i<10;i++) {
367
+ transfers_created.push({
368
+ id: BigInt(i + 10000),
369
+ debit_account_id: i % 2 == 0 ? accountC.id : accountA.id,
370
+ credit_account_id: i % 2 == 0 ? accountB.id : accountC.id,
371
+ amount: 100n,
372
+ user_data_128: 0n,
373
+ user_data_64: 0n,
374
+ user_data_32: 0,
375
+ pending_id: 0n,
376
+ timeout: 0,
377
+ ledger: 1,
378
+ code: 1,
379
+ flags: 0,
380
+ timestamp: 0n,
381
+ });
382
+ }
383
+
384
+ const transfers_created_result = await client.createTransfers(transfers_created)
385
+ assert.strictEqual(transfers_created_result.length, 0)
386
+
387
+ // Query all transfers for accountC:
388
+ var filter: GetAccountTransfers = {
389
+ account_id: accountC.id,
390
+ timestamp: 0n,
391
+ limit: 0,
392
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,
393
+ }
394
+ var transfers = await client.getAccountTransfers(filter)
395
+ assert.strictEqual(transfers.length, transfers_created.length)
396
+ var timestamp = 0n;
397
+ for (var transfer of transfers) {
398
+ assert.ok(timestamp < transfer.timestamp);
399
+ timestamp = transfer.timestamp;
400
+ }
401
+
402
+ // Query only the debit transfers for accountC, descending:
403
+ filter = {
404
+ account_id: accountC.id,
405
+ timestamp: 0n,
406
+ limit: 8190,
407
+ flags: GetAccountTransfersFlags.debits | GetAccountTransfersFlags.reversed,
408
+ }
409
+ transfers = await client.getAccountTransfers(filter)
410
+ assert.strictEqual(transfers.length, transfers_created.length / 2)
411
+ timestamp = 1n << 64n;
412
+ for (var transfer of transfers) {
413
+ assert.ok(transfer.timestamp < timestamp);
414
+ timestamp = transfer.timestamp;
415
+ }
416
+
417
+ // Query only the credit transfers for accountC, descending:
418
+ filter = {
419
+ account_id: accountC.id,
420
+ timestamp: 0n,
421
+ limit: 8190,
422
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.reversed,
423
+ }
424
+ transfers = await client.getAccountTransfers(filter)
425
+ assert.strictEqual(transfers.length, transfers_created.length / 2)
426
+ timestamp = 1n << 64n;
427
+ for (var transfer of transfers) {
428
+ assert.ok(transfer.timestamp < timestamp);
429
+ timestamp = transfer.timestamp;
430
+ }
431
+
432
+ // Query the first 5 transfers for accountC:
433
+ filter = {
434
+ account_id: accountC.id,
435
+ timestamp: 0n,
436
+ limit: transfers_created.length / 2,
437
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,
438
+ }
439
+ transfers = await client.getAccountTransfers(filter)
440
+ assert.strictEqual(transfers.length, transfers_created.length / 2)
441
+ timestamp = 0n;
442
+ for (var transfer of transfers) {
443
+ assert.ok(timestamp < transfer.timestamp);
444
+ timestamp = transfer.timestamp;
445
+ }
446
+
447
+ // Query the next 5 transfers for accountC, with pagination:
448
+ filter = {
449
+ account_id: accountC.id,
450
+ timestamp: timestamp,
451
+ limit: transfers_created.length / 2,
452
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,
453
+ }
454
+ transfers = await client.getAccountTransfers(filter)
455
+ assert.strictEqual(transfers.length, transfers_created.length / 2)
456
+ for (var transfer of transfers) {
457
+ assert.ok(timestamp < transfer.timestamp);
458
+ timestamp = transfer.timestamp;
459
+ }
460
+
461
+ // Query again, no more transfers should be found:
462
+ filter = {
463
+ account_id: accountC.id,
464
+ timestamp: timestamp,
465
+ limit: transfers_created.length / 2,
466
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,
467
+ }
468
+ transfers = await client.getAccountTransfers(filter)
469
+ assert.strictEqual(transfers.length, 0)
470
+
471
+
472
+ // Invalid account:
473
+ assert.strictEqual((await client.getAccountTransfers({
474
+ account_id: 0n,
475
+ timestamp: timestamp,
476
+ limit: 8190,
477
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,
478
+ })).length, 0)
479
+
480
+ // Invalid timestamp:
481
+ assert.strictEqual((await client.getAccountTransfers({
482
+ account_id: accountC.id,
483
+ timestamp: (1n << 64n) - 1n,
484
+ limit: 8190,
485
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,
486
+ })).length, 0)
487
+
488
+ // Zero limit:
489
+ assert.strictEqual((await client.getAccountTransfers({
490
+ account_id: accountC.id,
491
+ timestamp: 0n,
492
+ limit: 0,
493
+ flags: GetAccountTransfersFlags.credits | GetAccountTransfersFlags.debits,
494
+ })).length, 0)
495
+
496
+ // Empty flags:
497
+ assert.strictEqual((await client.getAccountTransfers({
498
+ account_id: accountC.id,
499
+ timestamp: 0n,
500
+ limit: 8190,
501
+ flags: GetAccountTransfersFlags.none,
502
+ })).length, 0)
503
+
504
+ // Invalid flags:
505
+ assert.strictEqual((await client.getAccountTransfers({
506
+ account_id: accountC.id,
507
+ timestamp: 0n,
508
+ limit: 8190,
509
+ flags: 0xFFFF,
510
+ })).length, 0)
511
+
512
+ })
513
+
343
514
  async function main () {
344
515
  const start = new Date().getTime()
345
516
  try {