@ocap/resolver 1.31.7 → 1.31.9

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/esm/index.d.mts CHANGED
@@ -8,6 +8,14 @@ import { ILedger } from "@ocap/types";
8
8
  //#region src/index.d.ts
9
9
  declare const formatData: (data: IDataObject | null | undefined) => IDataObject | null | undefined;
10
10
  declare const formatDelegationOps: (state: IDelegateState) => any;
11
+ /**
12
+ * Index `tx` columns a GraphQL `IndexedTransaction` read needs (#1872): the type's fields (hash sender receiver time
13
+ * type tx valid code receipts gasPayer; `tokenSymbols` is always recomputed by _formatTx) plus every input of
14
+ * _formatTx / getTxReceipts / getTxSender / deriveTxGasPayer / isDefaultTokenChanged / attachPaidTxGas, which only
15
+ * read these. Used only when the caller sets `ctx.graphqlTxProjection` (@ocap/gql does, for listTransactions and
16
+ * listAssetTransactions); every other caller keeps receiving every column.
17
+ */
18
+ declare const GRAPHQL_INDEXED_TX_COLUMNS: readonly string[];
11
19
  declare class OCAPResolver implements IResolver {
12
20
  statedb: IStateDB$1;
13
21
  indexdb: IIndexDB$1;
@@ -267,4 +275,4 @@ declare class OCAPResolver implements IResolver {
267
275
  }): Promise<IChunkIterator<IResolverStakeState>>;
268
276
  }
269
277
  //#endregion
270
- export { type IChainConfig, type IChunkIterator, type IDataObject, type IPaginatedResult, type IResolverPaging, type IResolverParams, type IResolverTransaction, type ITokenInfo, OCAPResolver as default, formatData, formatDelegationOps };
278
+ export { GRAPHQL_INDEXED_TX_COLUMNS, type IChainConfig, type IChunkIterator, type IDataObject, type IPaginatedResult, type IResolverPaging, type IResolverParams, type IResolverTransaction, type ITokenInfo, OCAPResolver as default, formatData, formatDelegationOps };
package/esm/index.mjs CHANGED
@@ -244,6 +244,29 @@ const extractTokenMeta = (address, tokenStates) => {
244
244
  foreignToken: tokenState.foreignToken
245
245
  };
246
246
  };
247
+ /**
248
+ * Index `tx` columns a GraphQL `IndexedTransaction` read needs (#1872): the type's fields (hash sender receiver time
249
+ * type tx valid code receipts gasPayer; `tokenSymbols` is always recomputed by _formatTx) plus every input of
250
+ * _formatTx / getTxReceipts / getTxSender / deriveTxGasPayer / isDefaultTokenChanged / attachPaidTxGas, which only
251
+ * read these. Used only when the caller sets `ctx.graphqlTxProjection` (@ocap/gql does, for listTransactions and
252
+ * listAssetTransactions); every other caller keeps receiving every column.
253
+ */
254
+ const GRAPHQL_INDEXED_TX_COLUMNS = [
255
+ "hash",
256
+ "code",
257
+ "receipts",
258
+ "receiver",
259
+ "sender",
260
+ "gasPayer",
261
+ "time",
262
+ "tx",
263
+ "type",
264
+ "valid"
265
+ ];
266
+ const withTxProjection = (args, ctx) => ctx?.graphqlTxProjection === true ? {
267
+ ...args,
268
+ columns: GRAPHQL_INDEXED_TX_COLUMNS
269
+ } : args;
247
270
  var OCAPResolver = class {
248
271
  /**
249
272
  * Creates an instance of OCAPResolver.
@@ -880,17 +903,17 @@ var OCAPResolver = class {
880
903
  };
881
904
  }
882
905
  async listTransactions(args = {}, ctx) {
883
- return await this._doPaginatedSearch("listTransactions", args, "transactions", "tx.itxJson.data", ctx);
906
+ return await this._doPaginatedSearch("listTransactions", withTxProjection(args, ctx), "transactions", "tx.itxJson.data", ctx);
884
907
  }
885
908
  listAssets(args = {}, ctx) {
886
909
  return this._doPaginatedSearch("listAssets", args, "assets", "data", ctx);
887
910
  }
888
911
  listAssetTransactions(args = {}, ctx = {}) {
889
912
  if (!args.address) return Promise.resolve({ transactions: [] });
890
- return this._doPaginatedSearch("listTransactions", {
913
+ return this._doPaginatedSearch("listTransactions", withTxProjection({
891
914
  ...args,
892
915
  assetFilter: { assets: [args.address] }
893
- }, "transactions", "tx.itxJson.data", ctx);
916
+ }, ctx), "transactions", "tx.itxJson.data", ctx);
894
917
  }
895
918
  async listFactories(args = {}, ctx) {
896
919
  const result = await this._doPaginatedSearch("listFactories", args, "factories", "data", ctx);
@@ -1893,4 +1916,4 @@ var OCAPResolver = class {
1893
1916
  };
1894
1917
 
1895
1918
  //#endregion
1896
- export { OCAPResolver as default, formatData, formatDelegationOps };
1919
+ export { GRAPHQL_INDEXED_TX_COLUMNS, OCAPResolver as default, formatData, formatDelegationOps };
package/lib/index.cjs CHANGED
@@ -259,6 +259,29 @@ const extractTokenMeta = (address, tokenStates) => {
259
259
  foreignToken: tokenState.foreignToken
260
260
  };
261
261
  };
262
+ /**
263
+ * Index `tx` columns a GraphQL `IndexedTransaction` read needs (#1872): the type's fields (hash sender receiver time
264
+ * type tx valid code receipts gasPayer; `tokenSymbols` is always recomputed by _formatTx) plus every input of
265
+ * _formatTx / getTxReceipts / getTxSender / deriveTxGasPayer / isDefaultTokenChanged / attachPaidTxGas, which only
266
+ * read these. Used only when the caller sets `ctx.graphqlTxProjection` (@ocap/gql does, for listTransactions and
267
+ * listAssetTransactions); every other caller keeps receiving every column.
268
+ */
269
+ const GRAPHQL_INDEXED_TX_COLUMNS = [
270
+ "hash",
271
+ "code",
272
+ "receipts",
273
+ "receiver",
274
+ "sender",
275
+ "gasPayer",
276
+ "time",
277
+ "tx",
278
+ "type",
279
+ "valid"
280
+ ];
281
+ const withTxProjection = (args, ctx) => ctx?.graphqlTxProjection === true ? {
282
+ ...args,
283
+ columns: GRAPHQL_INDEXED_TX_COLUMNS
284
+ } : args;
262
285
  var OCAPResolver = class {
263
286
  /**
264
287
  * Creates an instance of OCAPResolver.
@@ -895,17 +918,17 @@ var OCAPResolver = class {
895
918
  };
896
919
  }
897
920
  async listTransactions(args = {}, ctx) {
898
- return await this._doPaginatedSearch("listTransactions", args, "transactions", "tx.itxJson.data", ctx);
921
+ return await this._doPaginatedSearch("listTransactions", withTxProjection(args, ctx), "transactions", "tx.itxJson.data", ctx);
899
922
  }
900
923
  listAssets(args = {}, ctx) {
901
924
  return this._doPaginatedSearch("listAssets", args, "assets", "data", ctx);
902
925
  }
903
926
  listAssetTransactions(args = {}, ctx = {}) {
904
927
  if (!args.address) return Promise.resolve({ transactions: [] });
905
- return this._doPaginatedSearch("listTransactions", {
928
+ return this._doPaginatedSearch("listTransactions", withTxProjection({
906
929
  ...args,
907
930
  assetFilter: { assets: [args.address] }
908
- }, "transactions", "tx.itxJson.data", ctx);
931
+ }, ctx), "transactions", "tx.itxJson.data", ctx);
909
932
  }
910
933
  async listFactories(args = {}, ctx) {
911
934
  const result = await this._doPaginatedSearch("listFactories", args, "factories", "data", ctx);
@@ -1908,6 +1931,7 @@ var OCAPResolver = class {
1908
1931
  };
1909
1932
 
1910
1933
  //#endregion
1934
+ exports.GRAPHQL_INDEXED_TX_COLUMNS = GRAPHQL_INDEXED_TX_COLUMNS;
1911
1935
  exports.default = OCAPResolver;
1912
1936
  exports.formatData = formatData;
1913
1937
  exports.formatDelegationOps = formatDelegationOps;
package/lib/index.d.cts CHANGED
@@ -8,6 +8,14 @@ import Queue from "queue";
8
8
  //#region src/index.d.ts
9
9
  declare const formatData: (data: IDataObject | null | undefined) => IDataObject | null | undefined;
10
10
  declare const formatDelegationOps: (state: IDelegateState) => any;
11
+ /**
12
+ * Index `tx` columns a GraphQL `IndexedTransaction` read needs (#1872): the type's fields (hash sender receiver time
13
+ * type tx valid code receipts gasPayer; `tokenSymbols` is always recomputed by _formatTx) plus every input of
14
+ * _formatTx / getTxReceipts / getTxSender / deriveTxGasPayer / isDefaultTokenChanged / attachPaidTxGas, which only
15
+ * read these. Used only when the caller sets `ctx.graphqlTxProjection` (@ocap/gql does, for listTransactions and
16
+ * listAssetTransactions); every other caller keeps receiving every column.
17
+ */
18
+ declare const GRAPHQL_INDEXED_TX_COLUMNS: readonly string[];
11
19
  declare class OCAPResolver implements IResolver {
12
20
  statedb: IStateDB$1;
13
21
  indexdb: IIndexDB$1;
@@ -267,4 +275,4 @@ declare class OCAPResolver implements IResolver {
267
275
  }): Promise<IChunkIterator<IResolverStakeState>>;
268
276
  }
269
277
  //#endregion
270
- export { type IChainConfig, type IChunkIterator, type IDataObject, type IPaginatedResult, type IResolverPaging, type IResolverParams, type IResolverTransaction, type ITokenInfo, OCAPResolver as default, formatData, formatDelegationOps };
278
+ export { GRAPHQL_INDEXED_TX_COLUMNS, type IChainConfig, type IChunkIterator, type IDataObject, type IPaginatedResult, type IResolverPaging, type IResolverParams, type IResolverTransaction, type ITokenInfo, OCAPResolver as default, formatData, formatDelegationOps };
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.31.7",
6
+ "version": "1.31.9",
7
7
  "description": "GraphQL resolver built upon ocap statedb and GQL layer",
8
8
  "type": "module",
9
9
  "main": "./lib/index.cjs",
@@ -49,20 +49,20 @@
49
49
  "tsdown": "^0.18.4"
50
50
  },
51
51
  "dependencies": {
52
- "@arcblock/did": "1.31.7",
53
- "@arcblock/did-ext": "1.31.7",
54
- "@arcblock/did-util": "1.31.7",
52
+ "@arcblock/did": "1.31.9",
53
+ "@arcblock/did-ext": "1.31.9",
54
+ "@arcblock/did-util": "1.31.9",
55
55
  "@arcblock/nft-display": "^3.2.3",
56
- "@arcblock/validator": "1.31.7",
57
- "@ocap/config": "1.31.7",
58
- "@ocap/indexdb": "1.31.7",
59
- "@ocap/mcrypto": "1.31.7",
60
- "@ocap/message": "1.31.7",
61
- "@ocap/state": "1.31.7",
62
- "@ocap/tx-protocols": "1.31.7",
63
- "@ocap/types": "1.31.7",
64
- "@ocap/util": "1.31.7",
65
- "@ocap/wallet": "1.31.7",
56
+ "@arcblock/validator": "1.31.9",
57
+ "@ocap/config": "1.31.9",
58
+ "@ocap/indexdb": "1.31.9",
59
+ "@ocap/mcrypto": "1.31.9",
60
+ "@ocap/message": "1.31.9",
61
+ "@ocap/state": "1.31.9",
62
+ "@ocap/tx-protocols": "1.31.9",
63
+ "@ocap/types": "1.31.9",
64
+ "@ocap/util": "1.31.9",
65
+ "@ocap/wallet": "1.31.9",
66
66
  "debug": "^4.4.3",
67
67
  "express": "^4.22.1",
68
68
  "lodash": "^4.17.23",