envio 3.0.0-alpha.3 → 3.0.0-alpha.5

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.
Files changed (79) hide show
  1. package/README.md +2 -2
  2. package/evm.schema.json +0 -1
  3. package/index.d.ts +333 -2
  4. package/index.js +4 -0
  5. package/package.json +13 -6
  6. package/rescript.json +4 -1
  7. package/src/ChainFetcher.res +25 -1
  8. package/src/ChainFetcher.res.mjs +19 -1
  9. package/src/Config.res +212 -19
  10. package/src/Config.res.mjs +228 -29
  11. package/src/{Indexer.res → Ctx.res} +1 -1
  12. package/src/Ecosystem.res +2 -2
  13. package/src/Ecosystem.res.mjs +1 -1
  14. package/src/Envio.gen.ts +1 -1
  15. package/src/Envio.res +1 -1
  16. package/src/EventProcessing.res +18 -18
  17. package/src/EventProcessing.res.mjs +14 -14
  18. package/src/GlobalState.res +29 -35
  19. package/src/GlobalState.res.mjs +47 -47
  20. package/src/GlobalStateManager.res +68 -0
  21. package/src/GlobalStateManager.res.mjs +75 -0
  22. package/src/GlobalStateManager.resi +7 -0
  23. package/src/Internal.res +41 -1
  24. package/src/LogSelection.res +33 -27
  25. package/src/LogSelection.res.mjs +6 -0
  26. package/src/Main.res +342 -0
  27. package/src/Main.res.mjs +289 -0
  28. package/src/PgStorage.gen.ts +10 -0
  29. package/src/PgStorage.res +24 -2
  30. package/src/PgStorage.res.d.mts +5 -0
  31. package/src/PgStorage.res.mjs +22 -1
  32. package/src/Types.ts +1 -1
  33. package/src/UserContext.res +0 -1
  34. package/src/UserContext.res.mjs +0 -2
  35. package/src/Utils.res +28 -0
  36. package/src/Utils.res.mjs +18 -0
  37. package/src/bindings/ClickHouse.res +31 -1
  38. package/src/bindings/ClickHouse.res.mjs +27 -1
  39. package/src/bindings/Ethers.res +27 -67
  40. package/src/bindings/Ethers.res.mjs +18 -70
  41. package/src/bindings/Postgres.gen.ts +8 -0
  42. package/src/bindings/Postgres.res +3 -0
  43. package/src/bindings/Postgres.res.d.mts +5 -0
  44. package/src/bindings/RescriptMocha.res +123 -0
  45. package/src/bindings/RescriptMocha.res.mjs +18 -0
  46. package/src/bindings/Yargs.res +8 -0
  47. package/src/bindings/Yargs.res.mjs +2 -0
  48. package/src/sources/FuelSDK.res +4 -3
  49. package/src/sources/HyperSyncHeightStream.res +28 -110
  50. package/src/sources/HyperSyncHeightStream.res.mjs +30 -63
  51. package/src/sources/HyperSyncSource.res +11 -13
  52. package/src/sources/HyperSyncSource.res.mjs +20 -20
  53. package/src/sources/Rpc.res +43 -0
  54. package/src/sources/Rpc.res.mjs +31 -0
  55. package/src/sources/RpcSource.res +9 -4
  56. package/src/sources/RpcSource.res.mjs +9 -4
  57. package/src/sources/Source.res +1 -0
  58. package/src/sources/SourceManager.res +164 -81
  59. package/src/sources/SourceManager.res.mjs +146 -83
  60. package/src/sources/{Solana.res → Svm.res} +4 -4
  61. package/src/sources/{Solana.res.mjs → Svm.res.mjs} +4 -4
  62. package/src/tui/Tui.res +266 -0
  63. package/src/tui/Tui.res.mjs +342 -0
  64. package/src/tui/bindings/Ink.res +376 -0
  65. package/src/tui/bindings/Ink.res.mjs +75 -0
  66. package/src/tui/bindings/Style.res +123 -0
  67. package/src/tui/bindings/Style.res.mjs +2 -0
  68. package/src/tui/components/BufferedProgressBar.res +40 -0
  69. package/src/tui/components/BufferedProgressBar.res.mjs +57 -0
  70. package/src/tui/components/CustomHooks.res +114 -0
  71. package/src/tui/components/CustomHooks.res.mjs +162 -0
  72. package/src/tui/components/Messages.res +41 -0
  73. package/src/tui/components/Messages.res.mjs +75 -0
  74. package/src/tui/components/SyncETA.res +193 -0
  75. package/src/tui/components/SyncETA.res.mjs +269 -0
  76. package/src/tui/components/TuiData.res +46 -0
  77. package/src/tui/components/TuiData.res.mjs +29 -0
  78. package/src/bindings/Ethers.gen.ts +0 -14
  79. /package/src/{Indexer.res.mjs → Ctx.res.mjs} +0 -0
@@ -1,6 +1,7 @@
1
1
  // Generated by ReScript, PLEASE EDIT WITH CARE
2
2
 
3
3
  import * as Fs from "fs";
4
+ import * as Env from "./Env.res.mjs";
4
5
  import * as Path from "path";
5
6
  import * as $$Array from "rescript/lib/es6/array.js";
6
7
  import * as Table from "./db/Table.res.mjs";
@@ -13,6 +14,7 @@ import * as Js_dict from "rescript/lib/es6/js_dict.js";
13
14
  import * as Logging from "./Logging.res.mjs";
14
15
  import * as $$Promise from "./bindings/Promise.res.mjs";
15
16
  import * as Internal from "./Internal.res.mjs";
17
+ import Postgres from "postgres";
16
18
  import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
17
19
  import * as Prometheus from "./Prometheus.res.mjs";
18
20
  import * as Caml_option from "rescript/lib/es6/caml_option.js";
@@ -26,6 +28,24 @@ import * as Caml_js_exceptions from "rescript/lib/es6/caml_js_exceptions.js";
26
28
 
27
29
  var getCacheRowCountFnName = "get_cache_row_count";
28
30
 
31
+ function makeClient() {
32
+ return Postgres({
33
+ host: Env.Db.host,
34
+ port: Env.Db.port,
35
+ database: Env.Db.database,
36
+ username: Env.Db.user,
37
+ password: Env.Db.password,
38
+ ssl: Env.Db.ssl,
39
+ max: 2,
40
+ onnotice: Env.userLogLevel === "warn" || Env.userLogLevel === "error" ? undefined : (function (_str) {
41
+
42
+ }),
43
+ transform: {
44
+ undefined: null
45
+ }
46
+ });
47
+ }
48
+
29
49
  function makeCreateIndexQuery(tableName, indexFields, pgSchema) {
30
50
  var indexName = tableName + "_" + indexFields.join("_");
31
51
  var index = Belt_Array.map(indexFields, (function (idx) {
@@ -697,7 +717,7 @@ function make(sql, pgHost, pgSchema, pgPort, pgUser, pgDatabase, pgPassword, isH
697
717
  var psqlExecOptions = {
698
718
  env: psqlExecOptions_env
699
719
  };
700
- var cacheDirPath = Path.resolve("..", ".envio", "cache");
720
+ var cacheDirPath = Path.resolve(".envio", "cache");
701
721
  var isInitialized = async function () {
702
722
  var envioTables = await sql.unsafe("SELECT table_schema FROM information_schema.tables WHERE table_schema = '" + pgSchema + "' AND (table_name = 'event_sync_state' OR table_name = '" + InternalTable.Chains.table.tableName + "');");
703
723
  return Utils.$$Array.notEmpty(envioTables);
@@ -1075,6 +1095,7 @@ var maxItemsPerQuery = 500;
1075
1095
 
1076
1096
  export {
1077
1097
  getCacheRowCountFnName ,
1098
+ makeClient ,
1078
1099
  makeCreateIndexQuery ,
1079
1100
  makeCreateTableIndicesQuery ,
1080
1101
  makeCreateTableQuery ,
package/src/Types.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export type Invalid = never;
2
2
 
3
- export type Address = string;
3
+ export type Address = `0x${string}`;
4
4
 
5
5
  export type Logger = {
6
6
  readonly debug: (
@@ -261,7 +261,6 @@ let handlerTraps: Utils.Proxy.traps<contextParams> = {
261
261
  )
262
262
 
263
263
  | "isPreload" => params.isPreload->Utils.magic
264
- | "chains" => params.chains->Utils.magic
265
264
  | "chain" =>
266
265
  let chainId = params.item->Internal.getItemChainId
267
266
  params.chains->Utils.Dict.dangerouslyGetByIntNonOption(chainId)->Utils.magic
@@ -148,8 +148,6 @@ var handlerTraps = {
148
148
  case "chain" :
149
149
  var chainId = Internal.getItemChainId(params.item);
150
150
  return params.chains[chainId];
151
- case "chains" :
152
- return params.chains;
153
151
  case "effect" :
154
152
  return initEffect(params);
155
153
  case "isPreload" :
package/src/Utils.res CHANGED
@@ -32,6 +32,19 @@ module Object = {
32
32
 
33
33
  @val @scope("Object")
34
34
  external defineProperty: ('obj, string, propertyDescriptor<'a>) => 'obj = "defineProperty"
35
+
36
+ // Property descriptor with required value field (no boxing)
37
+ type enumerablePropertyDescriptor<'a> = {
38
+ enumerable: bool,
39
+ value: 'a,
40
+ }
41
+
42
+ @val @scope("Object")
43
+ external definePropertyWithValue: ('obj, string, enumerablePropertyDescriptor<'a>) => 'obj =
44
+ "defineProperty"
45
+
46
+ @val @scope("Object")
47
+ external createNullObject: (@as(json`null`) _, unit) => 'a = "create"
35
48
  }
36
49
 
37
50
  module Error = {
@@ -175,6 +188,15 @@ module Dict = {
175
188
  }
176
189
  `)
177
190
 
191
+ let unsafeDeleteUndefinedFieldsInPlace: 'a => unit = %raw(`(dict) => {
192
+ for (var key in dict) {
193
+ if (dict[key] === undefined) {
194
+ delete dict[key];
195
+ }
196
+ }
197
+ }
198
+ `)
199
+
178
200
  let updateImmutable: (
179
201
  dict<'a>,
180
202
  string,
@@ -472,6 +494,12 @@ module Schema = {
472
494
  ->(magic: S.t<Js.Json.t> => S.t<Js.Date.t>)
473
495
  ->S.preprocess(_ => {serializer: date => date->magic->Js.Date.toISOString})
474
496
 
497
+ // ClickHouse expects timestamps as numbers (milliseconds), not ISO strings
498
+ let clickHouseDate =
499
+ S.json(~validate=false)
500
+ ->(magic: S.t<Js.Json.t> => S.t<Js.Date.t>)
501
+ ->S.preprocess(_ => {serializer: date => date->magic->Js.Date.getTime})
502
+
475
503
  // When trying to serialize data to Json pg type, it will fail with
476
504
  // PostgresError: column "params" is of type json but expression is of type boolean
477
505
  // If there's bool or null on the root level. It works fine as object field values.
package/src/Utils.res.mjs CHANGED
@@ -151,6 +151,14 @@ var deleteInPlace = ((dict, key) => {
151
151
  delete dict[key];
152
152
  });
153
153
 
154
+ var unsafeDeleteUndefinedFieldsInPlace = ((dict) => {
155
+ for (var key in dict) {
156
+ if (dict[key] === undefined) {
157
+ delete dict[key];
158
+ }
159
+ }
160
+ });
161
+
154
162
  var updateImmutable = ((dict, key, value) => ({...dict, [key]: value}));
155
163
 
156
164
  var shallowCopy = ((dict) => ({...dict}));
@@ -172,6 +180,7 @@ var Dict = {
172
180
  size: size,
173
181
  isEmpty: isEmpty,
174
182
  deleteInPlace: deleteInPlace,
183
+ unsafeDeleteUndefinedFieldsInPlace: unsafeDeleteUndefinedFieldsInPlace,
175
184
  updateImmutable: updateImmutable,
176
185
  shallowCopy: shallowCopy,
177
186
  incrementByInt: incrementByInt
@@ -449,6 +458,14 @@ var dbDate = S$RescriptSchema.preprocess(S$RescriptSchema.json(false), (function
449
458
  };
450
459
  }));
451
460
 
461
+ var clickHouseDate = S$RescriptSchema.preprocess(S$RescriptSchema.json(false), (function (param) {
462
+ return {
463
+ s: (function (date) {
464
+ return date.getTime();
465
+ })
466
+ };
467
+ }));
468
+
452
469
  function coerceToJsonPgType(schema) {
453
470
  return S$RescriptSchema.preprocess(schema, (function (s) {
454
471
  var match = s.schema.t;
@@ -485,6 +502,7 @@ var Schema = {
485
502
  getNonOptionalFieldNames: getNonOptionalFieldNames,
486
503
  getCapitalizedFieldNames: getCapitalizedFieldNames,
487
504
  dbDate: dbDate,
505
+ clickHouseDate: clickHouseDate,
488
506
  coerceToJsonPgType: coerceToJsonPgType
489
507
  };
490
508
 
@@ -98,6 +98,36 @@ let getClickHouseFieldType = (
98
98
  isNullable ? `Nullable(${baseType})` : baseType
99
99
  }
100
100
 
101
+ // Creates an entity schema from table definition, using clickHouseDate for Date fields
102
+ let makeClickHouseEntitySchema = (table: Table.table): S.t<Internal.entity> => {
103
+ S.schema(s => {
104
+ let dict = Js.Dict.empty()
105
+ table.fields->Belt.Array.forEach(field => {
106
+ switch field {
107
+ | Field(f) => {
108
+ let fieldName = f->Table.getDbFieldName
109
+ let fieldSchema = switch f.fieldType {
110
+ | Date => {
111
+ let dateSchema = Utils.Schema.clickHouseDate->S.toUnknown
112
+ if f.isNullable {
113
+ S.null(dateSchema)->S.toUnknown
114
+ } else if f.isArray {
115
+ S.array(dateSchema)->S.toUnknown
116
+ } else {
117
+ dateSchema
118
+ }
119
+ }
120
+ | _ => f.fieldSchema
121
+ }
122
+ dict->Js.Dict.set(fieldName, s.matches(fieldSchema))
123
+ }
124
+ | DerivedFrom(_) => () // Skip derived fields
125
+ }
126
+ })
127
+ dict->Utils.magic
128
+ })
129
+ }
130
+
101
131
  let setCheckpointsOrThrow = async (client, ~batch: Batch.t, ~database: string) => {
102
132
  let checkpointsCount = batch.checkpointIds->Array.length
103
133
  if checkpointsCount === 0 {
@@ -154,7 +184,7 @@ let setUpdatesOrThrow = async (
154
184
  )}\``,
155
185
  convertOrThrow: S.compile(
156
186
  S.union([
157
- EntityHistory.makeSetUpdateSchema(entityConfig.schema),
187
+ EntityHistory.makeSetUpdateSchema(makeClickHouseEntitySchema(entityConfig.table)),
158
188
  S.object(s => {
159
189
  s.tag(EntityHistory.changeFieldName, EntityHistory.RowAction.DELETE)
160
190
  Change.Delete({
@@ -76,6 +76,31 @@ function getClickHouseFieldType(fieldType, isNullable, isArray) {
76
76
  }
77
77
  }
78
78
 
79
+ function makeClickHouseEntitySchema(table) {
80
+ return S$RescriptSchema.schema(function (s) {
81
+ var dict = {};
82
+ Belt_Array.forEach(table.fields, (function (field) {
83
+ if (field.TAG !== "Field") {
84
+ return ;
85
+ }
86
+ var f = field._0;
87
+ var fieldName = Table.getDbFieldName(f);
88
+ var match = f.fieldType;
89
+ var fieldSchema;
90
+ if (typeof match !== "object" && match === "Date") {
91
+ var dateSchema = Utils.Schema.clickHouseDate;
92
+ fieldSchema = f.isNullable ? S$RescriptSchema.$$null(dateSchema) : (
93
+ f.isArray ? S$RescriptSchema.array(dateSchema) : dateSchema
94
+ );
95
+ } else {
96
+ fieldSchema = f.fieldSchema;
97
+ }
98
+ dict[fieldName] = s.m(fieldSchema);
99
+ }));
100
+ return dict;
101
+ });
102
+ }
103
+
79
104
  async function setCheckpointsOrThrow(client, batch, database) {
80
105
  var checkpointsCount = batch.checkpointIds.length;
81
106
  if (checkpointsCount === 0) {
@@ -120,7 +145,7 @@ async function setUpdatesOrThrow(client, updates, entityConfig, database) {
120
145
  } else {
121
146
  var cache_tableName = database + ".\`" + EntityHistory.historyTableName(entityConfig.name, entityConfig.index) + "\`";
122
147
  var cache_convertOrThrow = S$RescriptSchema.compile(S$RescriptSchema.union([
123
- EntityHistory.makeSetUpdateSchema(entityConfig.schema),
148
+ EntityHistory.makeSetUpdateSchema(makeClickHouseEntitySchema(entityConfig.table)),
124
149
  S$RescriptSchema.object(function (s) {
125
150
  s.tag(EntityHistory.changeFieldName, "DELETE");
126
151
  return {
@@ -264,6 +289,7 @@ async function resume(client, database, checkpointId) {
264
289
 
265
290
  export {
266
291
  getClickHouseFieldType ,
292
+ makeClickHouseEntitySchema ,
267
293
  setCheckpointsOrThrow ,
268
294
  setUpdatesOrThrow ,
269
295
  makeCreateHistoryTableQuery ,
@@ -1,16 +1,3 @@
1
- type abi = EvmTypes.Abi.t
2
-
3
- let makeAbi = (abi: Js.Json.t): abi => abi->Utils.magic
4
-
5
- @deprecated("Use Address.t instead. The type will be removed in v3")
6
- type ethAddress = Address.t
7
- @deprecated("Use Address.Evm.fromStringOrThrow instead. The function will be removed in v3")
8
- let getAddressFromStringUnsafe = Address.Evm.fromStringOrThrow
9
- @deprecated("Use Address.toString instead. The function will be removed in v3")
10
- let ethAddressToString = Address.toString
11
- @deprecated("Use Address.schema instead. The function will be removed in v3")
12
- let ethAddressSchema = Address.schema
13
-
14
1
  type txHash = string
15
2
 
16
3
  module Constants = {
@@ -18,35 +5,6 @@ module Constants = {
18
5
  @module("ethers") @scope("ethers") external zeroAddress: Address.t = "ZeroAddress"
19
6
  }
20
7
 
21
- module Addresses = {
22
- @genType
23
- let mockAddresses = [
24
- "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
25
- "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
26
- "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
27
- "0x90F79bf6EB2c4f870365E785982E1f101E93b906",
28
- "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
29
- "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
30
- "0x976EA74026E726554dB657fA54763abd0C3a0aa9",
31
- "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955",
32
- "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f",
33
- "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
34
- "0xBcd4042DE499D14e55001CcbB24a551F3b954096",
35
- "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
36
- "0xFABB0ac9d68B0B445fB7357272Ff202C5651694a",
37
- "0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec",
38
- "0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097",
39
- "0xcd3B766CCDd6AE721141F452C550Ca635964ce71",
40
- "0x2546BcD3c84621e976D8185a91A922aE77ECEc30",
41
- "0xbDA5747bFD65F08deb54cb465eB87D40e51B197E",
42
- "0xdD2FD4581271e230360230F9337D5c0430Bf44C0",
43
- "0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199",
44
- ]->Belt.Array.map(getAddressFromStringUnsafe)
45
- @genType
46
- let defaultAddress =
47
- mockAddresses[0]
48
- }
49
-
50
8
  module Filter = {
51
9
  type t
52
10
  }
@@ -144,41 +102,43 @@ module JsonRpcProvider = {
144
102
  @send
145
103
  external getLogs: (t, ~filter: Filter.t) => promise<array<log>> = "getLogs"
146
104
 
147
- @send
148
- external getTransaction: (t, ~transactionHash: string) => promise<transaction> = "getTransaction"
149
-
150
105
  let makeGetTransactionFields = (~getTransactionByHash, ~lowercaseAddresses: bool) => async (
151
106
  log: log,
152
- ): promise<unknown> => {
153
- let transaction = await getTransactionByHash(log.transactionHash)
107
+ ): promise<Internal.evmTransactionFields> => {
108
+ let transaction: Internal.evmTransactionFields = await getTransactionByHash(log.transactionHash)
154
109
  // Mutating should be fine, since the transaction isn't used anywhere else outside the function
155
110
  let fields: {..} = transaction->Obj.magic
156
111
 
157
- // Make it compatible with HyperSync transaction fields
112
+ // RPC may return null for transactionIndex on pending transactions
158
113
  fields["transactionIndex"] = log.transactionIndex
159
- fields["input"] = fields["data"]
160
114
 
161
115
  // NOTE: this is wasteful if these fields are not selected in the users config.
162
116
  // There might be a better way to do this in the `makeThrowingGetEventTransaction` function rather based on the schema.
163
117
  // However this is not extremely expensive and good enough for now (only on rpc sync also).
164
- if lowercaseAddresses {
165
- open Js.Nullable
166
- switch fields["from"] {
167
- | Value(from) => fields["from"] = from->Js.String2.toLowerCase
168
- | Undefined => ()
169
- | Null => ()
170
- }
171
- switch fields["to"] {
172
- | Value(to) => fields["to"] = to->Js.String2.toLowerCase
173
- | Undefined => ()
174
- | Null => ()
175
- }
176
- switch fields["contractAddress"] {
177
- | Value(contractAddress) =>
178
- fields["contractAddress"] = contractAddress->Js.String2.toLowerCase
179
- | Undefined => ()
180
- | Null => ()
181
- }
118
+ open Js.Nullable
119
+ switch fields["from"] {
120
+ | Value(from) =>
121
+ fields["from"] = lowercaseAddresses
122
+ ? from->Js.String2.toLowerCase->Address.unsafeFromString
123
+ : from->Address.Evm.fromStringOrThrow
124
+ | Undefined => ()
125
+ | Null => ()
126
+ }
127
+ switch fields["to"] {
128
+ | Value(to) =>
129
+ fields["to"] = lowercaseAddresses
130
+ ? to->Js.String2.toLowerCase->Address.unsafeFromString
131
+ : to->Address.Evm.fromStringOrThrow
132
+ | Undefined => ()
133
+ | Null => ()
134
+ }
135
+ switch fields["contractAddress"] {
136
+ | Value(contractAddress) =>
137
+ fields["contractAddress"] = lowercaseAddresses
138
+ ? contractAddress->Js.String2.toLowerCase->Address.unsafeFromString
139
+ : contractAddress->Address.Evm.fromStringOrThrow
140
+ | Undefined => ()
141
+ | Null => ()
182
142
  }
183
143
 
184
144
  fields->Obj.magic
@@ -2,52 +2,10 @@
2
2
 
3
3
  import * as Ethers from "ethers";
4
4
  import * as Address from "../Address.res.mjs";
5
- import * as Belt_Array from "rescript/lib/es6/belt_Array.js";
6
- import * as Caml_array from "rescript/lib/es6/caml_array.js";
7
5
  import * as Caml_option from "rescript/lib/es6/caml_option.js";
8
6
 
9
- function makeAbi(abi) {
10
- return abi;
11
- }
12
-
13
- var getAddressFromStringUnsafe = Address.Evm.fromStringOrThrow;
14
-
15
- function ethAddressToString(prim) {
16
- return prim;
17
- }
18
-
19
7
  var Constants = {};
20
8
 
21
- var mockAddresses = Belt_Array.map([
22
- "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266",
23
- "0x70997970C51812dc3A010C7d01b50e0d17dc79C8",
24
- "0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC",
25
- "0x90F79bf6EB2c4f870365E785982E1f101E93b906",
26
- "0x15d34AAf54267DB7D7c367839AAf71A00a2C6A65",
27
- "0x9965507D1a55bcC2695C58ba16FB37d819B0A4dc",
28
- "0x976EA74026E726554dB657fA54763abd0C3a0aa9",
29
- "0x14dC79964da2C08b23698B3D3cc7Ca32193d9955",
30
- "0x23618e81E3f5cdF7f54C3d65f7FBc0aBf5B21E8f",
31
- "0xa0Ee7A142d267C1f36714E4a8F75612F20a79720",
32
- "0xBcd4042DE499D14e55001CcbB24a551F3b954096",
33
- "0x71bE63f3384f5fb98995898A86B02Fb2426c5788",
34
- "0xFABB0ac9d68B0B445fB7357272Ff202C5651694a",
35
- "0x1CBd3b2770909D4e10f157cABC84C7264073C9Ec",
36
- "0xdF3e18d64BC6A983f673Ab319CCaE4f1a57C7097",
37
- "0xcd3B766CCDd6AE721141F452C550Ca635964ce71",
38
- "0x2546BcD3c84621e976D8185a91A922aE77ECEc30",
39
- "0xbDA5747bFD65F08deb54cb465eB87D40e51B197E",
40
- "0xdD2FD4581271e230360230F9337D5c0430Bf44C0",
41
- "0x8626f6940E2eb28930eFb4CeF49B2d1F2C9C1199"
42
- ], getAddressFromStringUnsafe);
43
-
44
- var defaultAddress = Caml_array.get(mockAddresses, 0);
45
-
46
- var Addresses = {
47
- mockAddresses: mockAddresses,
48
- defaultAddress: defaultAddress
49
- };
50
-
51
9
  var Filter = {};
52
10
 
53
11
  function toFilter(combinedFilter) {
@@ -81,26 +39,23 @@ function makeGetTransactionFields(getTransactionByHash, lowercaseAddresses) {
81
39
  return async function (log) {
82
40
  var transaction = await getTransactionByHash(log.transactionHash);
83
41
  transaction.transactionIndex = log.transactionIndex;
84
- transaction.input = transaction.data;
85
- if (lowercaseAddresses) {
86
- var from = transaction.from;
87
- if (from === null || from === undefined) {
88
- from === null;
89
- } else {
90
- transaction.from = from.toLowerCase();
91
- }
92
- var to = transaction.to;
93
- if (to === null || to === undefined) {
94
- to === null;
95
- } else {
96
- transaction.to = to.toLowerCase();
97
- }
98
- var contractAddress = transaction.contractAddress;
99
- if (contractAddress === null || contractAddress === undefined) {
100
- contractAddress === null;
101
- } else {
102
- transaction.contractAddress = contractAddress.toLowerCase();
103
- }
42
+ var from = transaction.from;
43
+ if (from === null || from === undefined) {
44
+ from === null;
45
+ } else {
46
+ transaction.from = lowercaseAddresses ? from.toLowerCase() : Address.Evm.fromStringOrThrow(from);
47
+ }
48
+ var to = transaction.to;
49
+ if (to === null || to === undefined) {
50
+ to === null;
51
+ } else {
52
+ transaction.to = lowercaseAddresses ? to.toLowerCase() : Address.Evm.fromStringOrThrow(to);
53
+ }
54
+ var contractAddress = transaction.contractAddress;
55
+ if (contractAddress === null || contractAddress === undefined) {
56
+ contractAddress === null;
57
+ } else {
58
+ transaction.contractAddress = lowercaseAddresses ? contractAddress.toLowerCase() : Address.Evm.fromStringOrThrow(contractAddress);
104
59
  }
105
60
  return transaction;
106
61
  };
@@ -112,19 +67,12 @@ var JsonRpcProvider = {
112
67
  makeGetTransactionFields: makeGetTransactionFields
113
68
  };
114
69
 
115
- var ethAddressSchema = Address.schema;
116
-
117
70
  export {
118
- makeAbi ,
119
- getAddressFromStringUnsafe ,
120
- ethAddressToString ,
121
- ethAddressSchema ,
122
71
  Constants ,
123
- Addresses ,
124
72
  Filter ,
125
73
  CombinedFilter ,
126
74
  logToMinimumParseableLogData ,
127
75
  Network ,
128
76
  JsonRpcProvider ,
129
77
  }
130
- /* mockAddresses Not a pure module */
78
+ /* ethers Not a pure module */
@@ -0,0 +1,8 @@
1
+ /* TypeScript file generated from Postgres.res by genType. */
2
+
3
+ /* eslint-disable */
4
+ /* tslint:disable */
5
+
6
+ import type {Sql as $$sql} from 'postgres';
7
+
8
+ export type sql = $$sql;
@@ -1,3 +1,6 @@
1
+ // Only needed for some old tests
2
+ // Remove @genType in the future
3
+ @genType.import(("postgres", "Sql"))
1
4
  type sql
2
5
 
3
6
  type undefinedTransform = | @as(undefined) Undefined | @as(null) Null
@@ -0,0 +1,5 @@
1
+ // This is to prevent tsc --noEmit from failing
2
+ // when importing code from .res.mjs files in genType .ts files
3
+ // After we upgrade GenType and it starts to include ts-ignore,
4
+ // the line can be removed.
5
+ export type sql = any;
@@ -0,0 +1,123 @@
1
+ module Assert = {
2
+ type assertion<'a> = ('a, 'a, ~message: string=?) => unit
3
+
4
+ @module("assert") external equal: assertion<'a> = "equal"
5
+ @module("assert") external notEqual: assertion<'a> = "notEqual"
6
+
7
+ @module("assert") external deepEqual: assertion<'a> = "deepEqual"
8
+ @module("assert")
9
+ external notDeepEqual: assertion<'a> = "notDeepEqual"
10
+
11
+ @module("assert") external strictEqual: assertion<'a> = "strictEqual"
12
+ @module("assert")
13
+ external notStrictEqual: assertion<'a> = "notStrictEqual"
14
+
15
+ @module("assert")
16
+ external deepStrictEqual: assertion<'a> = "deepStrictEqual"
17
+ @module("assert")
18
+ external notDeepStrictEqual: assertion<'a> = "notDeepStrictEqual"
19
+
20
+ @module("assert") external ifError: 'a => unit = "ifError"
21
+
22
+ @module("assert")
23
+ external throws: (unit => 'a, ~error: 'error=?, ~message: string=?) => unit = "throws"
24
+ @module("assert")
25
+ external doesNotThrow: (unit => 'a, ~error: 'error=?, ~message: string=?) => unit = "doesNotThrow"
26
+
27
+ @module("assert")
28
+ external rejects: (unit => promise<'a>, ~error: 'error=?, ~message: string=?) => promise<unit> =
29
+ "rejects"
30
+
31
+ @module("assert") external ok: (bool, ~message: string=?) => unit = "ok"
32
+ @module("assert") external fail: string => 'a = "fail"
33
+ }
34
+
35
+ /* Mocha bindings on `this` for `describe` and `it` functions */
36
+ module This = {
37
+ @val external timeout: int => unit = "this.timeout"
38
+ @val external retries: int => unit = "this.retries"
39
+ @val external slow: int => unit = "this.slow"
40
+ @val external skip: unit => unit = "this.skip"
41
+ }
42
+
43
+ @val
44
+ external describe: (string, unit => unit) => unit = "describe"
45
+ @val
46
+ external describe_only: (string, unit => unit) => unit = "describe.only"
47
+ @val
48
+ external describe_skip: (string, unit => unit) => unit = "describe.skip"
49
+
50
+ @val
51
+ external it: (string, unit => unit) => unit = "it"
52
+ @val
53
+ external it_only: (string, unit => unit) => unit = "it.only"
54
+ @val
55
+ external it_skip: (string, unit => unit) => unit = "it.skip"
56
+ @val
57
+ external before: (unit => unit) => unit = "before"
58
+ @val
59
+ external after: (unit => unit) => unit = "after"
60
+ @val
61
+ external beforeEach: (unit => unit) => unit = "beforeEach"
62
+ @val
63
+ external afterEach: (unit => unit) => unit = "afterEach"
64
+ @val
65
+ external beforeWithTitle: (string, unit => unit) => unit = "before"
66
+ @val
67
+ external afterWithTitle: (string, unit => unit) => unit = "after"
68
+ @val
69
+ external beforeEachWithTitle: (string, unit => unit) => unit = "beforeEach"
70
+ @val
71
+ external afterEachWithTitle: (string, unit => unit) => unit = "afterEach"
72
+
73
+ module Async = {
74
+ @val
75
+ external it: (string, unit => promise<unit>) => unit = "it"
76
+ @val
77
+ external it_only: (string, unit => promise<unit>) => unit = "it.only"
78
+ @val
79
+ external it_skip: (string, unit => promise<unit>) => unit = "it.skip"
80
+ @val
81
+ external before: (unit => promise<unit>) => unit = "before"
82
+ @val
83
+ external after: (unit => promise<unit>) => unit = "after"
84
+ @val
85
+ external beforeEach: (unit => promise<unit>) => unit = "beforeEach"
86
+ @val
87
+ external afterEach: (unit => promise<unit>) => unit = "afterEach"
88
+ @val
89
+ external beforeWithTitle: (string, unit => promise<unit>) => unit = "before"
90
+ @val
91
+ external afterWithTitle: (string, unit => promise<unit>) => unit = "after"
92
+ @val
93
+ external beforeEachWithTitle: (string, unit => promise<unit>) => unit = "beforeEach"
94
+ @val
95
+ external afterEachWithTitle: (string, unit => promise<unit>) => unit = "afterEach"
96
+ }
97
+
98
+ module DoneCallback = {
99
+ type doneCallback = Js.Nullable.t<Js.Exn.t> => unit
100
+
101
+ @val
102
+ external it: (string, doneCallback => unit) => unit = "it"
103
+ @val
104
+ external it_only: (string, doneCallback => unit) => unit = "it.only"
105
+ @val
106
+ external it_skip: (string, doneCallback => unit) => unit = "it.skip"
107
+ @val
108
+ external before: (doneCallback => unit) => unit = "before"
109
+ @val
110
+ external after: (doneCallback => unit) => unit = "after"
111
+ @val
112
+ external beforeEach: (doneCallback => unit) => unit = "beforeEach"
113
+ @val
114
+ external afterEach: (doneCallback => unit) => unit = "afterEach"
115
+ @val
116
+ external beforeWithTitle: (string, doneCallback => unit) => unit = "before"
117
+ @val
118
+ external afterWithTitle: (string, doneCallback => unit) => unit = "after"
119
+ @val
120
+ external beforeEachWithTitle: (string, doneCallback => unit) => unit = "beforeEach"
121
+ @val
122
+ external afterEachWithTitle: (string, doneCallback => unit) => unit = "afterEach"
123
+ }