From 74a31e0f8f96052efbe236345a078bb50658dc6b Mon Sep 17 00:00:00 2001 From: rashad Date: Wed, 27 Sep 2023 11:02:22 -0400 Subject: [PATCH 1/5] fix: update rustc specified in default indexer cargo manifest (#1380) * fix: update rustc specified in default indexer cargo manifest * add ci test * remove test indexer * update ci * update cargo manifests --------- Co-authored-by: Rashad Alston Co-authored-by: Rashad Alston --- .github/workflows/ci.yml | 2 +- Cargo.lock | 45 +++++++++++++++++-- Cargo.toml | 2 +- ci/Dockerfile.fuel-node | 2 +- deployment/Dockerfile | 2 +- .../fuel-explorer/fuel-explorer/Cargo.toml | 1 + .../hello-indexer-native/Cargo.toml | 1 + examples/hello-world/hello-indexer/Cargo.toml | 1 + packages/fuel-indexer-lib/src/utils.rs | 25 +++++++++++ packages/fuel-indexer-tests/Cargo.toml | 2 + packages/fuel-indexer-tests/tests/config.rs | 36 ++++++++++++++- plugins/forc-index/src/defaults.rs | 3 +- .../forc-index/src/ops/forc_index_build.rs | 29 ++---------- 13 files changed, 117 insertions(+), 34 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 6c805c0b7..3e463a5d8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -15,7 +15,7 @@ env: REGISTRY: ghcr.io SEGMENT_DOWNLOAD_TIMEOUT_MINS: 2 SQLX_OFFLINE: true - RUSTC_VERSION: 1.72.0 + RUSTC_VERSION: 1.72.1 BRANCH_NAME: ${{ github.head_ref || github.ref_name }} IS_MASTER: ${{ github.head_ref == 'master' || github.ref_name == 'master' }} IS_DEVELOP: ${{ github.head_ref == 'develop' || github.ref_name == 'develop' }} diff --git a/Cargo.lock b/Cargo.lock index 1e03e8cc7..cdcf0e849 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2697,7 +2697,7 @@ dependencies = [ "serde_yaml", "tempfile", "tokio", - "toml", + "toml 0.5.11", "tracing", "walkdir", "whoami", @@ -3198,7 +3198,7 @@ dependencies = [ "quote", "serde", "snafu", - "toml", + "toml 0.5.11", ] [[package]] @@ -3499,12 +3499,14 @@ dependencies = [ "lazy_static", "rand", "reqwest", + "rustc_version", "serde", "serde_json", "serde_yaml", "sqlx", "thiserror", "tokio", + "toml 0.8.0", "tracing", "tracing-subscriber 0.2.25", "trybuild", @@ -5776,7 +5778,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7f4c021e1093a56626774e81216a4ce732a735e5bad4868a03f3ed65ca0c3919" dependencies = [ "once_cell", - "toml_edit", + "toml_edit 0.19.14", ] [[package]] @@ -6639,6 +6641,15 @@ dependencies = [ "serde", ] +[[package]] +name = "serde_spanned" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96426c9936fd7a0124915f9185ea1d20aa9445cc9821142f0a73bc9207a2e186" +dependencies = [ + "serde", +] + [[package]] name = "serde_urlencoded" version = "0.7.1" @@ -7625,11 +7636,26 @@ dependencies = [ "serde", ] +[[package]] +name = "toml" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c226a7bba6d859b63c92c4b4fe69c5b6b72d0cb897dbc8e6012298e6154cb56e" +dependencies = [ + "serde", + "serde_spanned", + "toml_datetime", + "toml_edit 0.20.0", +] + [[package]] name = "toml_datetime" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "7cda73e2f1397b1262d6dfdcef8aafae14d1de7748d66822d3bfeeb6d03e5e4b" +dependencies = [ + "serde", +] [[package]] name = "toml_edit" @@ -7642,6 +7668,19 @@ dependencies = [ "winnow", ] +[[package]] +name = "toml_edit" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ff63e60a958cefbb518ae1fd6566af80d9d4be430a33f3723dfc47d1d411d95" +dependencies = [ + "indexmap 2.0.0", + "serde", + "serde_spanned", + "toml_datetime", + "winnow", +] + [[package]] name = "tower" version = "0.4.13" diff --git a/Cargo.toml b/Cargo.toml index 3efae8640..6af964147 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -60,7 +60,7 @@ edition = "2021" homepage = "https://fuel.network/" license = "Apache-2.0" repository = "https://github.com/FuelLabs/fuel-indexer" -rust-version = "1.72.0" +rust-version = "1.72.1" version = "0.20.11" [workspace.dependencies] diff --git a/ci/Dockerfile.fuel-node b/ci/Dockerfile.fuel-node index dcf775cb7..e0bd43b54 100644 --- a/ci/Dockerfile.fuel-node +++ b/ci/Dockerfile.fuel-node @@ -1,5 +1,5 @@ # Stage 1: Build -FROM lukemathwalker/cargo-chef:latest-rust-1.72.0 AS chef +FROM lukemathwalker/cargo-chef:latest-rust-1.72.1 AS chef WORKDIR /build/ diff --git a/deployment/Dockerfile b/deployment/Dockerfile index 247b54303..72f5a3b5f 100644 --- a/deployment/Dockerfile +++ b/deployment/Dockerfile @@ -1,6 +1,6 @@ # Stage 1: Build FROM --platform=$BUILDPLATFORM tonistiigi/xx AS xx -FROM --platform=$BUILDPLATFORM rust:1.72.0 AS chef +FROM --platform=$BUILDPLATFORM rust:1.72.1 AS chef ARG TARGETPLATFORM RUN cargo install cargo-chef diff --git a/examples/fuel-explorer/fuel-explorer/Cargo.toml b/examples/fuel-explorer/fuel-explorer/Cargo.toml index 34553cf72..6ca6f6bdd 100644 --- a/examples/fuel-explorer/fuel-explorer/Cargo.toml +++ b/examples/fuel-explorer/fuel-explorer/Cargo.toml @@ -3,6 +3,7 @@ name = "fuel_explorer" version = "0.0.0" edition = "2021" publish = false +rust-version = "1.72.1" [lib] crate-type = ['cdylib'] diff --git a/examples/hello-world-native/hello-indexer-native/Cargo.toml b/examples/hello-world-native/hello-indexer-native/Cargo.toml index 9ddd4c01a..54e9f4364 100644 --- a/examples/hello-world-native/hello-indexer-native/Cargo.toml +++ b/examples/hello-world-native/hello-indexer-native/Cargo.toml @@ -3,6 +3,7 @@ name = "hello_indexer_native" version = "0.0.0" edition = "2021" publish = false +rust-version = "1.72.1" [dependencies] async-trait = { version = "0.1" } diff --git a/examples/hello-world/hello-indexer/Cargo.toml b/examples/hello-world/hello-indexer/Cargo.toml index ed43a8e48..6f48b6a59 100644 --- a/examples/hello-world/hello-indexer/Cargo.toml +++ b/examples/hello-world/hello-indexer/Cargo.toml @@ -3,6 +3,7 @@ name = "hello_indexer" version = "0.0.0" edition = "2021" publish = false +rust-version = "1.72.1" [lib] crate-type = ['cdylib'] diff --git a/packages/fuel-indexer-lib/src/utils.rs b/packages/fuel-indexer-lib/src/utils.rs index 5b8d276d0..ed632be06 100644 --- a/packages/fuel-indexer-lib/src/utils.rs +++ b/packages/fuel-indexer-lib/src/utils.rs @@ -257,3 +257,28 @@ pub async fn init_logging(config: &IndexerConfig) -> anyhow::Result<()> { pub fn format_sql_query(s: String) -> String { s.replace('\n', " ") } + +#[derive(Deserialize)] +pub struct Package { + pub name: String, + pub version: String, + pub edition: String, + pub publish: bool, + #[serde(alias = "rust-version")] + pub rust_version: String, +} + +#[derive(Deserialize)] +#[allow(unused)] +pub struct Lib { + #[serde(alias = "crate-type")] + pub crate_type: Option>, +} + +/// General representation of a rust cargo manifest. +#[derive(Deserialize)] +#[allow(unused)] +pub struct Config { + pub package: Package, + pub lib: Option, +} diff --git a/packages/fuel-indexer-tests/Cargo.toml b/packages/fuel-indexer-tests/Cargo.toml index 18247601c..c7be6e2f7 100644 --- a/packages/fuel-indexer-tests/Cargo.toml +++ b/packages/fuel-indexer-tests/Cargo.toml @@ -50,12 +50,14 @@ itertools = "0.10" lazy_static = "1.4" rand = "0.8" reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls", "multipart"] } +rustc_version = "0.4" serde = { features = ["derive"], workspace = true } serde_json = { workspace = true } serde_yaml = "0.8" sqlx = { version = "0.6", features = ["bigdecimal"] } thiserror = { workspace = true } tokio = { features = ["macros", "rt-multi-thread"], workspace = true } +toml = "0.8" tracing = { workspace = true } tracing-subscriber = { version = "0.2", features = ["env-filter"] } trybuild = "1.0" diff --git a/packages/fuel-indexer-tests/tests/config.rs b/packages/fuel-indexer-tests/tests/config.rs index cbe8f017b..71effa389 100644 --- a/packages/fuel-indexer-tests/tests/config.rs +++ b/packages/fuel-indexer-tests/tests/config.rs @@ -1,4 +1,5 @@ -use fuel_indexer_lib::config::IndexerConfig; +use fuel_indexer_lib::{config::IndexerConfig, utils::Config}; +use std::{fs, process::Command}; #[test] fn test_default_config_file_is_same_as_default_indexer_config() { @@ -9,3 +10,36 @@ fn test_default_config_file_is_same_as_default_indexer_config() { serde_yaml::to_string(&yaml_config).unwrap() ); } + +#[test] +fn test_rustc_version_in_default_indexer_cargo_manifest_matches_project_rustc_version() { + let rustc_version = rustc_version::version().unwrap(); + let _ = Command::new("forc-index") + .arg("new") + .arg("indexer-test") + .arg("--namespace") + .arg("fuellabs") + .spawn() + .unwrap() + .wait() + .unwrap(); + let cargo_toml = fs::read_to_string("./indexer-test/Cargo.toml").unwrap(); + let cargo_toml: Config = toml::from_str(&cargo_toml).unwrap(); + assert_eq!(cargo_toml.package.rust_version, rustc_version.to_string()); + fs::remove_dir_all("./indexer-test").unwrap(); + + let _ = Command::new("forc-index") + .arg("new") + .arg("indexer-test") + .arg("--namespace") + .arg("fuellabs") + .arg("--native") + .spawn() + .unwrap() + .wait() + .unwrap(); + let cargo_toml = fs::read_to_string("./indexer-test/Cargo.toml").unwrap(); + let cargo_toml: Config = toml::from_str(&cargo_toml).unwrap(); + assert_eq!(cargo_toml.package.rust_version, rustc_version.to_string()); + fs::remove_dir_all("./indexer-test").unwrap(); +} diff --git a/plugins/forc-index/src/defaults.rs b/plugins/forc-index/src/defaults.rs index 56e221cf2..82929f878 100644 --- a/plugins/forc-index/src/defaults.rs +++ b/plugins/forc-index/src/defaults.rs @@ -23,6 +23,7 @@ name = "{indexer_name}" version = "0.0.0" edition = "2021" publish = false +rust-version = "1.72.1" [[bin]] name = "{indexer_name}" @@ -47,7 +48,7 @@ name = "{indexer_name}" version = "0.0.0" edition = "2021" publish = false -rust-version = "1.71.1" +rust-version = "1.72.1" [lib] crate-type = ['cdylib'] diff --git a/plugins/forc-index/src/ops/forc_index_build.rs b/plugins/forc-index/src/ops/forc_index_build.rs index 4c0f4421d..23fbe8359 100644 --- a/plugins/forc-index/src/ops/forc_index_build.rs +++ b/plugins/forc-index/src/ops/forc_index_build.rs @@ -1,7 +1,9 @@ use crate::{cli::BuildCommand, defaults, utils::project_dir_info}; -use fuel_indexer_lib::manifest::{Manifest, Module}; +use fuel_indexer_lib::{ + manifest::{Manifest, Module}, + utils::Config, +}; use indicatif::{ProgressBar, ProgressStyle}; -use serde::Deserialize; use std::collections::HashSet; use std::{ env, @@ -13,29 +15,6 @@ use std::{ }; use tracing::info; -#[derive(Deserialize)] -#[allow(unused)] -struct Package { - name: String, - version: String, - edition: String, - publish: bool, -} - -#[derive(Deserialize)] -#[allow(unused)] -struct Lib { - #[serde(alias = "crate-type")] - crate_type: Option>, -} - -#[derive(Deserialize)] -#[allow(unused)] -struct Config { - package: Package, - lib: Option, -} - pub fn init(command: BuildCommand) -> anyhow::Result<()> { let BuildCommand { native, From 3afad10a81e215c6026789e0929127c9fd4ca5ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Wo=C5=9B?= Date: Fri, 29 Sep 2023 14:02:09 +0200 Subject: [PATCH 2/5] fix: consecutive blocks trigger existence check (#1386) --- packages/fuel-indexer-database/postgres/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/fuel-indexer-database/postgres/src/lib.rs b/packages/fuel-indexer-database/postgres/src/lib.rs index e837d3d1b..d49ab269b 100644 --- a/packages/fuel-indexer-database/postgres/src/lib.rs +++ b/packages/fuel-indexer-database/postgres/src/lib.rs @@ -943,6 +943,7 @@ pub async fn create_ensure_block_height_consecutive_trigger( SELECT 1 FROM pg_trigger WHERE tgname = 'trigger_ensure_block_height_consecutive' + AND tgrelid = '{namespace}_{identifier}.indexmetadataentity'::regclass ) THEN CREATE TRIGGER trigger_ensure_block_height_consecutive BEFORE INSERT OR UPDATE ON {namespace}_{identifier}.indexmetadataentity From f02438a4422a73499b8a5cf5a6ee95cc76146a27 Mon Sep 17 00:00:00 2001 From: rashad Date: Fri, 29 Sep 2023 10:52:22 -0400 Subject: [PATCH 3/5] chore/breaking: simplify scalar types (#1388) * chore: simplify scalar types * rename xstring to string * update tests * updates * updates * fix snapshot tests --------- Co-authored-by: Rashad Alston --- Cargo.lock | 2 - docs/src/designing-a-schema/directives.md | 2 +- docs/src/designing-a-schema/relationships.md | 4 +- docs/src/designing-a-schema/scalars.md | 32 +-- docs/src/designing-a-schema/types.md | 10 +- docs/src/indexing-custom-types/index.md | 8 +- docs/src/project-components/schema.md | 8 +- docs/src/querying/basic-queries.md | 8 +- docs/src/storing-records/index.md | 35 +-- .../schema/fuel_explorer.schema.graphql | 250 ++++++++-------- .../fuel-explorer/fuel-explorer/src/lib.rs | 12 +- .../hello_indexer_native.schema.graphql | 8 +- .../schema/hello_indexer.schema.graphql | 8 +- .../benches/graphql.rs | 4 +- .../fuel-indexer-benchmarks/src/bin/qa.rs | 23 +- .../database-types/src/lib.rs | 272 +++++++----------- .../postgres/sqlx-data.json | 22 +- packages/fuel-indexer-graphql/src/dynamic.rs | 77 ++--- packages/fuel-indexer-graphql/src/graphql.rs | 6 +- packages/fuel-indexer-lib/src/constants.rs | 68 ++--- .../fuel-indexer-lib/src/graphql/base.graphql | 32 +-- .../fuel-indexer-lib/src/graphql/constants.rs | 39 +-- .../fuel-indexer-lib/src/graphql/parser.rs | 66 ++--- packages/fuel-indexer-macros/src/decoder.rs | 12 +- packages/fuel-indexer-schema/src/lib.rs | 242 +++++----------- ...chema__tests__fragments_some_types-10.snap | 4 +- ...chema__tests__fragments_some_types-11.snap | 4 +- ...chema__tests__fragments_some_types-12.snap | 4 +- ...chema__tests__fragments_some_types-13.snap | 4 +- ...chema__tests__fragments_some_types-14.snap | 4 +- ...chema__tests__fragments_some_types-15.snap | 4 +- ...chema__tests__fragments_some_types-16.snap | 4 +- ...chema__tests__fragments_some_types-17.snap | 4 +- ...chema__tests__fragments_some_types-18.snap | 4 +- ...chema__tests__fragments_some_types-19.snap | 4 +- ...schema__tests__fragments_some_types-2.snap | 4 +- ...chema__tests__fragments_some_types-21.snap | 4 +- ...chema__tests__fragments_some_types-22.snap | 4 +- ...chema__tests__fragments_some_types-23.snap | 4 +- ...schema__tests__fragments_some_types-4.snap | 4 +- ...schema__tests__fragments_some_types-5.snap | 4 +- ...schema__tests__fragments_some_types-6.snap | 4 +- ...schema__tests__fragments_some_types-7.snap | 4 +- ...schema__tests__fragments_some_types-8.snap | 4 +- ...schema__tests__fragments_some_types-9.snap | 4 +- ...r_schema__tests__fragments_some_types.snap | 4 +- .../schema/fuel_indexer_test.graphql | 144 +++++----- .../indexers/fuel-indexer-test/src/lib.rs | 18 +- packages/fuel-indexer-tests/tests/indexing.rs | 2 +- ...fail_if_abi_contains_reserved_fuel_type.rs | 4 +- .../fail_if_ident_not_defined_in_abi.rs | 2 +- packages/fuel-indexer-types/Cargo.toml | 2 - packages/fuel-indexer-types/src/fuel.rs | 14 +- packages/fuel-indexer-types/src/graphql.rs | 4 +- packages/fuel-indexer-types/src/scalar.rs | 91 +----- packages/fuel-indexer-utils/src/utilities.rs | 8 +- packages/fuel-indexer/src/executor.rs | 14 +- plugins/forc-index/src/defaults.rs | 2 +- 58 files changed, 650 insertions(+), 989 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index cdcf0e849..b1f0c74b5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3520,7 +3520,6 @@ dependencies = [ name = "fuel-indexer-types" version = "0.20.11" dependencies = [ - "bincode", "bytes", "fuel-tx 0.35.3", "fuel-types 0.35.3", @@ -3528,7 +3527,6 @@ dependencies = [ "serde", "serde_json", "sha2 0.9.9", - "tai64", ] [[package]] diff --git a/docs/src/designing-a-schema/directives.md b/docs/src/designing-a-schema/directives.md index b429006aa..8426d0ca6 100644 --- a/docs/src/designing-a-schema/directives.md +++ b/docs/src/designing-a-schema/directives.md @@ -55,7 +55,7 @@ The `@join` directive is used to relate a field in one type to others by referen ```graphql type Book @entity { id: ID! - name: Charfield! @unique + name: String! @unique } type Library @entity { diff --git a/docs/src/designing-a-schema/relationships.md b/docs/src/designing-a-schema/relationships.md index 590defc69..5b2444c35 100644 --- a/docs/src/designing-a-schema/relationships.md +++ b/docs/src/designing-a-schema/relationships.md @@ -19,7 +19,7 @@ Let's learn how to use each foreign key type by looking at some GraphQL schema e ```graphql type Library @entity { id: ID! - name: Charfield! + name: String! } type Book @entity { @@ -35,7 +35,7 @@ Given the above schema, two entities will be created: a `Book` entity, and a `Li ```graphql type Library @entity { id: ID! - name: Charfield! @unique + name: String! @unique } type Book @entity { diff --git a/docs/src/designing-a-schema/scalars.md b/docs/src/designing-a-schema/scalars.md index d026af518..f66526526 100644 --- a/docs/src/designing-a-schema/scalars.md +++ b/docs/src/designing-a-schema/scalars.md @@ -6,31 +6,23 @@ The Fuel indexer has a collection of GraphQL scalars that cover virtually any va --- | --- | --- | Address | `u8[32]` | | AssetId | `u8[32]` | -| Blob | `Vec` | Byte blob of arbitary size | -| BlockId | `u8[32]` | 32-byte block ID | | Boolean | `bool` | -| Bytes4 | `u8[4]` | -| Bytes8 | `u8[8]` | +| Bytes | `Vec` | Byte blob of arbitary size | | Bytes32 | `u8[32]` | +| Bytes4 | `u8[4]` | | Bytes64 | `u8[64]` | -| Charfield | `String` | String of arbitrary size | +| Bytes8 | `u8[8]` | | ContractId | `u8[32]` | | HexString | `Vec` | Byte blob of arbitrary size | +| I128 | `i128` | +| I32 | `i32` | +| I64 | `i64` | +| I8 | `i8` | | ID | `SizedAsciiString<64>` | Alias of `UID` -| Int1 | `i8` | -| Int4 | `i32` | -| Int8 | `i64` | -| Int16 | `i128` | | Json | `String` | JSON string of arbitary size | -| MessageId | `u8[32]` | -| Nonce | `u8[32]` | -| Salt | `u8[32]` | -| Signature | `u8[64]` | 64-byte signature | -| Tai64Timestamp | `Tai64` | `Tai64` timestamp | -| Timestamp | `u64` | +| U128 | `u128` | +| U32 | `u32` | +| U64 | `u64` | +| U8 | `u8` | | UID | `SizedAsciiString<64>` | 32-byte unique ID | -| UInt1 | `u8` | -| UInt4 | `u32` | -| UInt8 | `u64` | -| UInt16 | `u128` | -| Virtual | `String` | Used to store types tagged with `@virtual` directive | +| String | `String` | String of arbitrary size | diff --git a/docs/src/designing-a-schema/types.md b/docs/src/designing-a-schema/types.md index 11ed5561c..534904f79 100644 --- a/docs/src/designing-a-schema/types.md +++ b/docs/src/designing-a-schema/types.md @@ -8,7 +8,7 @@ Object types are the most commonly used type in indexer GraphQL schema. Each obj type Account @entity { id: ID! address: Address! - balance: UInt8! + balance: U64! } ``` @@ -69,14 +69,14 @@ enum TransactionLabel { type CreateTransaction @entity { id: ID! - bytecode_length: UInt8! + bytecode_length: U64! contract_id: ContractId! label: TransactionLabel! } type ScriptTransaction @entity { id: ID! - maturity: UInt8! + maturity: U64! label: TransactionLabel! } @@ -94,10 +94,10 @@ The `Transaction` union type above, will internally produce the following object ```graphql type Transaction @entity { id: ID! - bytecode_length: UInt8! + bytecode_length: U64! contract_id: ContractId! label: TransactionLabel! - maturity: UInt8! + maturity: U64! metadata: Json } ``` diff --git a/docs/src/indexing-custom-types/index.md b/docs/src/indexing-custom-types/index.md index a93456d85..c80c72981 100644 --- a/docs/src/indexing-custom-types/index.md +++ b/docs/src/indexing-custom-types/index.md @@ -150,14 +150,14 @@ To index the contracts and store information about our Sway types in the databas ```graphql type AddEntity @entity { id: ID! - value: UInt8! - updated_total: UInt8! + value: U64! + updated_total: U64! } type SubtractEntity @entity { id: ID! - value: UInt8! - updated_total: UInt8! + value: U64! + updated_total: U64! } ``` diff --git a/docs/src/project-components/schema.md b/docs/src/project-components/schema.md index f4c93bf20..f139dca7d 100644 --- a/docs/src/project-components/schema.md +++ b/docs/src/project-components/schema.md @@ -6,20 +6,20 @@ Below is a sample GraphQL schema for a Fuel indexer. ```graphql type Metadata @entity(virtual: true) { - imageUrl: Charfield! - data: Blob + imageUrl: String! + data: Bytes } type Account @entity { id: ID! address: Address! - index: UInt8! + index: U64! metadata: Metadata } type Wallet @entity { id: ID! - name: Charfield! + name: String! accounts: [Account!]! } ``` diff --git a/docs/src/querying/basic-queries.md b/docs/src/querying/basic-queries.md index 324d05b2b..09532475f 100644 --- a/docs/src/querying/basic-queries.md +++ b/docs/src/querying/basic-queries.md @@ -90,24 +90,24 @@ We'll start with the following example schema: ```graphql type City @entity { id: ID! - name: Charfield! + name: String! } type Library @entity { id: ID! - name: Charfield! + name: String! city: City! } type Book @entity { id: ID! - title: Charfield! + title: String! library: Library! } type Character @entity { id: ID! - name: Charfield! + name: String! book: Book! } ``` diff --git a/docs/src/storing-records/index.md b/docs/src/storing-records/index.md index 2ac4384fe..2f06a2fb0 100644 --- a/docs/src/storing-records/index.md +++ b/docs/src/storing-records/index.md @@ -12,34 +12,25 @@ Below is a mapping of GraphQL schema types to their Sway and database equivalent --- | --- | --- | Address | `b256` | varchar(64) | | AssetId | `u8[32]` | varchar(64) | -| Blob | `str[]` | varchar(10485760) | -| BlockId | | varchar(64) | | Boolean | `bool` | boolean | -| Bytes4 | `str[4]` | varchar(8) | -| Bytes8 | `str[8]` | varchar(16) | +| Bytes | `str[]` | varchar(10485760) | | Bytes32 | `str[32]` | varchar(64) | +| Bytes4 | `str[4]` | varchar(8) | | Bytes64 | `str[64]` | varchar(128) | -| Charfield | `str[]` | varchar(255) | +| Bytes8 | `str[8]` | varchar(16) | | ContractId | `b256` | varchar(64) | -| HexString | `str[]` | varchar(10485760) | +| I128 | | numeric(39,0) | +| I32 | `u32` | integer | +| I64 | `u64` | bigint | +| I8 | `u8` | integer | | ID | | varchar(64) primary key | -| Int1 | `u8` | integer | -| Int4 | `u32` | integer | -| Int8 | `u64` | bigint | -| Int16 | | numeric(39,0) | | Json | `str[]` | json | -| MessageId | `str[32]` | varchar(64) | -| Nonce | `str[32]` | varchar(64) | -| Salt | `str[32]` | varchar(64) | -| Signature | `str[64]` | varchar(128) | -| Tai64Timestamp | | varchar(128) | -| Timestamp | `u64` | timestamp | +| U128 | | numeric(39, 0) | +| U32 | `u32` | integer | +| U64 | `u64` | numeric(20, 0) | +| U8 | `u8` | integer | | UID | | varchar(64) | -| UInt1 | `u8` | integer | -| UInt4 | `u32` | integer | -| UInt8 | `u64` | numeric(20, 0) | -| UInt16 | | numeric(39, 0) | -| Virtual | | json | +| String | `str[]` | varchar(255) | ## Example @@ -59,7 +50,7 @@ The corresponding GraphQL schema to mirror this `Event` struct would resemble: type Event @entity { id: ID! account: Address! - block_height: UInt8! + block_height: U64! } ``` diff --git a/examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql b/examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql index 91ab44bf4..63635ad2a 100644 --- a/examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql +++ b/examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql @@ -101,21 +101,21 @@ enum OutputLabel { } type Witness @entity(virtual: true) { - data: Blob! + data: Bytes! } type InstructionResult @entity(virtual: true) { reason: PanicReason! - instruction: UInt4! + instruction: U32! } type ProgramState @entity(virtual: true) { return_type: ReturnType! - data: HexString! + data: Bytes! } type DryRun @entity(virtual: true) { - tx: HexString! + tx: Bytes! utxo_validation: Boolean } @@ -126,14 +126,14 @@ type TransactionIdFragment @entity { type UtxoId @entity { id: ID! - tx_id: TxId! @indexed - output_index: UInt4! + tx_id: Bytes32! @indexed + output_index: U32! } type TxPointer @entity { id: ID! - block_height: UInt4! - tx_index: UInt8! + block_height: U32! + tx_index: U64! } type ContractIdFragment @entity { @@ -160,7 +160,7 @@ type PoA @entity { id: ID! # TODO: Is this important? The fact that signature is different # on almost every `PoA` implies that this type might be virtual? - signature: Signature! @indexed + signature: Bytes64! @indexed is_poa: Boolean! label: ConsensusLabel! } @@ -177,13 +177,13 @@ type InputCoin @entity { id: ID! utxo_id: UtxoId! @indexed owner: Address! @indexed - amount: UInt8! + amount: U64! asset_id: AssetId! @indexed tx_pointer: TxPointer! - witness_index: Int8! - maturity: UInt4! - predicate: HexString! - predicate_data: HexString! + witness_index: I64! + maturity: U32! + predicate: Bytes! + predicate_data: Bytes! label: InputLabel! is_coin: Boolean! } @@ -203,12 +203,12 @@ type InputMessage @entity { id: ID! sender: Address! @indexed recipient: Address! @indexed - amount: UInt8! - nonce: Nonce! - witness_index: Int8! - data: HexString! - predicate: HexString! - predicate_data: HexString! + amount: U64! + nonce: Bytes32! + witness_index: I64! + data: Bytes! + predicate: Bytes! + predicate_data: Bytes! label: InputLabel! is_message: Boolean! } @@ -226,27 +226,27 @@ type CallReceipt @entity(virtual: true) { # `recipient` has a different type of different `Reciept` members, so # we make it something more generic: `Identity`. recipient: Identity! - amount: UInt8! + amount: U64! asset_id: AssetId! - gas: UInt8! - param1: UInt8! - param2: UInt8! - pc: UInt8! + gas: U64! + param1: U64! + param2: U64! + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_call: Boolean! } type ReturnDataReceipt @entity(virtual: true) { contract_id: ContractId! - ptr: UInt8! - len: UInt8! + ptr: U64! + len: U64! digest: Bytes32! - data: Blob - pc: UInt8! + data: Bytes + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_return_data: Boolean! } @@ -254,57 +254,57 @@ type ReturnDataReceipt @entity(virtual: true) { type PanicReceipt @entity(virtual: true) { contract_id: ContractId reason: InstructionResult - pc: UInt8! + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_panic: Boolean! } type RevertReceipt @entity(virtual: true) { contract_id: ContractId! - ra: UInt8! - pc: UInt8! + ra: U64! + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_revert: Boolean! } type LogReceipt @entity(virtual: true) { contract_id: ContractId! - ra: UInt8! - rb: UInt8! - rc: UInt8! - rd: UInt8! - pc: UInt8! + ra: U64! + rb: U64! + rc: U64! + rd: U64! + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_log: Boolean! } type LogDataReceipt @entity(virtual: true) { contract_id: ContractId! - ra: UInt8! - rb: UInt8! - ptr: UInt8! - len: UInt8! + ra: U64! + rb: U64! + ptr: U64! + len: U64! digest: Bytes32! - data: Blob - pc: UInt8! + data: Bytes + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_log_data: Boolean! } type ReturnReceipt @entity(virtual: true) { contract_id: ContractId! - val: UInt8! - pc: UInt8! + val: U64! + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_return: Boolean! } @@ -314,11 +314,11 @@ type TransferReceipt @entity(virtual: true) { # `recipient` has a different type of different `Reciept` members, so # we make it something more generic: `Identity`. recipient: Identity! - amount: UInt8! + amount: U64! asset_id: AssetId! - pc: UInt8! + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_transfer: Boolean! } @@ -328,18 +328,18 @@ type TransferOutReceipt @entity(virtual: true) { # `recipient` has a different type of different `Reciept` members, so # we make it something more generic: `Identity`. recipient: Identity! - amount: UInt8! + amount: U64! asset_id: AssetId! - pc: UInt8! + pc: U64! # `is` is a reserved keyword in PostgreSQL. - isr: UInt8! + isr: U64! label: ReceiptLabel! is_transfer_out: Boolean! } type ScriptResultReceipt @entity(virtual: true) { result: ScriptExecutionResult! - gas_used: UInt8! + gas_used: U64! label: ReceiptLabel! is_script_result: Boolean! } @@ -349,11 +349,11 @@ type MessageOutReceipt @entity(virtual: true) { # `recipient` has a different type of different `Reciept` members, so # we make it something more generic: `Identity`. recipient: Identity! - amount: UInt8! - nonce: Nonce! - len: UInt8! + amount: U64! + nonce: Bytes32! + len: U64! digest: Bytes32! - data: Blob + data: Bytes label: ReceiptLabel! is_message_out: Boolean! } @@ -361,18 +361,18 @@ type MessageOutReceipt @entity(virtual: true) { type MintReceipt @entity(virtual: true) { sub_id: Bytes32! contract_id: ContractId! - val: UInt8! - pc: UInt8! - isr: UInt8! + val: U64! + pc: U64! + isr: U64! } type BurnReceipt @entity(virtual: true) { sub_id: Bytes32! contract_id: ContractId! - val: UInt8! - pc: UInt8! - isr: UInt8! + val: U64! + pc: U64! + isr: U64! } union Receipt = @@ -394,7 +394,7 @@ type VariableOutput @entity { id: ID! # `to` is a reserved keyword in PostgreSQL. recipient: Address! @indexed - amount: UInt8! + amount: U64! asset_id: AssetId! @indexed is_variable: Boolean! label: OutputLabel! @@ -404,7 +404,7 @@ type ChangeOutput @entity { id: ID! # `to` is a reserved keyword in PostgreSQL. recipient: Address! @indexed - amount: UInt8! + amount: U64! asset_id: AssetId! @indexed is_change: Boolean! label: OutputLabel! @@ -412,7 +412,7 @@ type ChangeOutput @entity { type ContractOutput @entity { id: ID! - input_index: Int8! + input_index: I64! balance_root: Bytes32! state_root: Bytes32! is_contract: Boolean! @@ -423,7 +423,7 @@ type CoinOutput @entity { id: ID! # `to` is a reserved keyword in PostgreSQL. recipient: Address! @indexed - amount: UInt8! + amount: U64! asset_id: AssetId! @indexed is_coin: Boolean! label: OutputLabel! @@ -445,7 +445,7 @@ type ContractCreated @entity { type MessageOutput @entity { id: ID! - amount: UInt8! + amount: U64! recipient: Address! @indexed } @@ -462,16 +462,16 @@ union Output = # transaction type names. type CreateTransaction @entity { id: ID! - gas_price: UInt8! - gas_limit: UInt8! - maturity: UInt4! - bytecode_length: UInt8! - bytecode_witness_index: UInt1! + gas_price: U64! + gas_limit: U64! + maturity: U32! + bytecode_length: U64! + bytecode_witness_index: U8! storage_slots: [StorageSlot!] inputs: [Input!] outputs: [Output!] witnesses: [Witness!] - salt: Salt! + salt: Bytes32! metadata: Json is_create: Boolean! receipts: [Receipt!] @@ -481,11 +481,11 @@ type CreateTransaction @entity { type ScriptTransaction @entity { id: ID! - gas_price: UInt8! - gas_limit: UInt8! - maturity: UInt4! - script: Blob! - script_data: Blob! + gas_price: U64! + gas_limit: U64! + maturity: U32! + script: Bytes! + script_data: Bytes! inputs: [Input!] outputs: [Output!] witnesses: [Witness!] @@ -512,14 +512,14 @@ union Transaction = CreateTransaction | ScriptTransaction | MintTransaction type SubmittedStatus @entity { id: ID! - time: UInt8! + time: U64! label: TransactionStatusLabel! is_submitted: Boolean! } type SqueezedOutStatus @entity { id: ID! - reason: Charfield! + reason: String! label: TransactionStatusLabel! is_squeezed_out: Boolean! } @@ -527,8 +527,8 @@ type SqueezedOutStatus @entity { type FailureStatus @entity { id: ID! block: BlockIdFragment! - time: UInt8! - reason: Charfield! + time: U64! + reason: String! program_state: ProgramState label: TransactionStatusLabel! is_failure: Boolean! @@ -536,7 +536,7 @@ type FailureStatus @entity { type SuccessStatus @entity { id: ID! - time: UInt8! + time: U64! block: BlockIdFragment! program_state: ProgramState label: TransactionStatusLabel! @@ -558,21 +558,21 @@ union TransactionStatus = type Header @entity { id: ID! - block_id: BlockId! - da_height: UInt8! - transactions_count: UInt8! - message_receipt_count: UInt8! + block_id: Bytes32! + da_height: U64! + transactions_count: U64! + message_receipt_count: U64! transactions_root: Bytes32! message_receipt_root: Bytes32! - height: UInt4! + height: U32! prev_root: Bytes32! - time: Int8! + time: I64! application_hash: Bytes32! } type Block @entity { id: ID! - block_id: BlockId! @indexed + block_id: Bytes32! @indexed header: Header! @indexed consensus: Consensus! transactions: [TransactionIdFragment!] @@ -582,60 +582,60 @@ type NodeInfo @entity { id: ID! utxo_validation: Boolean! vm_backtrace: Boolean! - min_gas_price: UInt8! - max_tx: UInt8! - max_depth: UInt8! - node_version: Charfield! + min_gas_price: U64! + max_tx: U64! + max_depth: U64! + node_version: String! } type ConsensusParameters @entity { id: ID! - contract_max_size: UInt8! - max_inputs: UInt8! - max_outputs: UInt8! - max_witnesses: UInt8! - max_gas_per_tx: UInt8! - max_script_length: UInt8! - max_script_data_length: UInt8! - max_storage_slots: UInt8! - max_predicate_length: UInt8! - gas_price_factor: UInt8! - gas_per_byte: UInt8! - max_message_data_length: UInt8! - chain_id: UInt8! + contract_max_size: U64! + max_inputs: U64! + max_outputs: U64! + max_witnesses: U64! + max_gas_per_tx: U64! + max_script_length: U64! + max_script_data_length: U64! + max_storage_slots: U64! + max_predicate_length: U64! + gas_price_factor: U64! + gas_per_byte: U64! + max_message_data_length: U64! + chain_id: U64! } type ChainInfo @entity { id: ID! - base_chain_height: UInt4! - name: Charfield! - peer_count: Int4! + base_chain_height: U32! + name: String! + peer_count: I32! latest_block: Block! consensus_parameters: ConsensusParameters! } type Coin @entity { id: ID! - amount: UInt8! - block_created: UInt4! + amount: U64! + block_created: U32! asset_id: AssetId! @indexed utxo_id: UtxoId! @indexed - maturity: UInt4! + maturity: U32! owner: Address! @indexed } type MessageCoin @entity { id: ID! - amount: UInt8! + amount: U64! sender: Address! @indexed recipient: Address! @indexed - nonce: Nonce! - da_height: UInt8! + nonce: Bytes32! + da_height: U64! } type Contract @entity { id: ID! contract_id: ContractId! @indexed - bytecode: HexString! - salt: Salt! + bytecode: Bytes! + salt: Bytes32! } diff --git a/examples/fuel-explorer/fuel-explorer/src/lib.rs b/examples/fuel-explorer/fuel-explorer/src/lib.rs index c23b18ddb..fbd94ec2e 100644 --- a/examples/fuel-explorer/fuel-explorer/src/lib.rs +++ b/examples/fuel-explorer/fuel-explorer/src/lib.rs @@ -144,35 +144,31 @@ impl From for UtxoId { impl From for ContractIdFragment { fn from(hash: Bytes32) -> Self { - let hash = Bytes32::from(<[u8; 32]>::from(hash)); Self::new(hash).get_or_create() } } impl From for ContractIdFragment { fn from(hash: ContractId) -> Self { - let hash = Bytes32::from(<[u8; 32]>::from(hash)); - Self::new(hash).get_or_create() + Self::new(bytes32(hash)).get_or_create() } } impl From for BlockIdFragment { fn from(hash: Bytes32) -> Self { - let hash = Bytes32::from(<[u8; 32]>::from(hash)); Self::new(hash).get_or_create() } } impl From for TransactionIdFragment { fn from(hash: Bytes32) -> Self { - let hash = Bytes32::from(<[u8; 32]>::from(hash)); Self::new(hash).get_or_create() } } impl From for TransactionIdFragment { fn from(tx: fuel::TransactionData) -> Self { - Self::from(Bytes32::from(<[u8; 32]>::from(tx.id))).get_or_create() + Self::from(bytes32(tx.id)).get_or_create() } } @@ -259,7 +255,7 @@ impl From for Input { sender, recipient, amount, - Nonce::from(<[u8; 32]>::from(nonce)), + Bytes32::from(<[u8; 32]>::from(nonce)), witness_index.into(), data, predicate, @@ -834,7 +830,7 @@ impl From for Transaction { Some(inputs), Some(outputs), Some(witnesses), - salt, + bytes32(salt), metadata.to_owned().map(|m| m.into()), true, Some(receipts), diff --git a/examples/hello-world-native/hello-indexer-native/schema/hello_indexer_native.schema.graphql b/examples/hello-world-native/hello-indexer-native/schema/hello_indexer_native.schema.graphql index 98a900b13..7c2f35d16 100644 --- a/examples/hello-world-native/hello-indexer-native/schema/hello_indexer_native.schema.graphql +++ b/examples/hello-world-native/hello-indexer-native/schema/hello_indexer_native.schema.graphql @@ -1,14 +1,14 @@ # Calling this `Greeter` so as to not clash with `Person` in the contract type Greeter @entity { id: ID! - name: Charfield! - last_seen: UInt4! + name: String! + last_seen: U32! } # Calling this `Salutation` so as to not clash with `Greeting` in the contract type Salutation @entity { id: ID! - message: Charfield! + message: String! greeter: Greeter! - last_seen: UInt4! + last_seen: U32! } diff --git a/examples/hello-world/hello-indexer/schema/hello_indexer.schema.graphql b/examples/hello-world/hello-indexer/schema/hello_indexer.schema.graphql index 98a900b13..7c2f35d16 100644 --- a/examples/hello-world/hello-indexer/schema/hello_indexer.schema.graphql +++ b/examples/hello-world/hello-indexer/schema/hello_indexer.schema.graphql @@ -1,14 +1,14 @@ # Calling this `Greeter` so as to not clash with `Person` in the contract type Greeter @entity { id: ID! - name: Charfield! - last_seen: UInt4! + name: String! + last_seen: U32! } # Calling this `Salutation` so as to not clash with `Greeting` in the contract type Salutation @entity { id: ID! - message: Charfield! + message: String! greeter: Greeter! - last_seen: UInt4! + last_seen: U32! } diff --git a/packages/fuel-indexer-benchmarks/benches/graphql.rs b/packages/fuel-indexer-benchmarks/benches/graphql.rs index 0cd46b7b0..9ef9015f2 100644 --- a/packages/fuel-indexer-benchmarks/benches/graphql.rs +++ b/packages/fuel-indexer-benchmarks/benches/graphql.rs @@ -9,7 +9,7 @@ fn build_and_parse_query(c: &mut Criterion) { b.iter(|| { let schema_str = r#"type Block { id: ID! - height: UInt8! + height: U64! hash: Bytes32! @unique } @@ -44,7 +44,7 @@ fn build_and_parse_query_with_args(c: &mut Criterion) { b.iter(|| { let schema_str = r#"type Block { id: ID! - height: UInt8! + height: U64! hash: Bytes32! @unique } diff --git a/packages/fuel-indexer-benchmarks/src/bin/qa.rs b/packages/fuel-indexer-benchmarks/src/bin/qa.rs index a8f5333b3..a843838d1 100644 --- a/packages/fuel-indexer-benchmarks/src/bin/qa.rs +++ b/packages/fuel-indexer-benchmarks/src/bin/qa.rs @@ -169,7 +169,19 @@ impl RunStat { } pub fn tick(&mut self) { - self.mem.push(record_mem_usage()); + // `sort` will occassionally panic, so just use the last iteration's value + let bytes = 1500; + let mem = match record_mem_usage() { + Ok(v) => { + if v.is_empty() { + self.mem.last().unwrap_or(&bytes).to_owned() + } else { + v.parse::().unwrap_or(bytes) + } + } + Err(_) => self.mem.last().unwrap_or(&bytes).clone(), + }; + self.mem.push(mem); self.cpu.push(record_cpu_usage()); } @@ -452,22 +464,19 @@ fn record_cpu_usage() -> f64 { .pipe(cmd!("awk", "{{print $4}}")) .stdout_capture() .read() - .unwrap(); + .unwrap_or_default(); output.trim().parse::().unwrap() } -fn record_mem_usage() -> u64 { - let output = cmd!("ps", "x", "-o", "rss,vsz,command") +fn record_mem_usage() -> Result { + cmd!("ps", "x", "-o", "rss,vsz,command") .pipe(cmd!("grep", "fuel-indexer")) .pipe(cmd!("sort", "-nr")) .pipe(cmd!("head", "-n", "1")) .pipe(cmd!("awk", "{print $1}")) .stdout_capture() .read() - .unwrap(); - - output.trim().parse::().unwrap() } #[tokio::main] diff --git a/packages/fuel-indexer-database/database-types/src/lib.rs b/packages/fuel-indexer-database/database-types/src/lib.rs index 512d18639..a872eb587 100644 --- a/packages/fuel-indexer-database/database-types/src/lib.rs +++ b/packages/fuel-indexer-database/database-types/src/lib.rs @@ -55,39 +55,28 @@ pub enum ColumnType { Bytes8 = 4, Bytes32 = 5, ContractId = 6, - Salt = 7, - Int4 = 8, - Int8 = 9, - UInt4 = 10, - UInt8 = 11, - Timestamp = 12, - Blob = 13, - ForeignKey = 14, - Json = 15, - MessageId = 16, - Charfield = 17, - Identity = 18, - Boolean = 19, - Object = 20, - UInt16 = 21, - Int16 = 22, - Bytes64 = 23, - Signature = 24, - Nonce = 25, - HexString = 26, - Tai64Timestamp = 27, - TxId = 28, - BlockHeight = 29, - Enum = 30, - Int1 = 31, - UInt1 = 32, - Virtual = 33, - BlockId = 34, - Array = 35, + I32 = 7, + I64 = 8, + U32 = 9, + U64 = 10, + Bytes = 11, + ForeignKey = 12, + Json = 13, + String = 14, + Identity = 15, + Boolean = 16, + Object = 17, + U128 = 18, + I128 = 19, + Bytes64 = 20, + Enum = 21, + I8 = 22, + U8 = 23, + Array = 24, // `ID` is a primary key, but when using foreign keys, we can't have two // primary key columns, so we need a version of `ID` that does not include // a primary key constraint. - UID = 36, + UID = 25, } impl From for i32 { @@ -100,36 +89,25 @@ impl From for i32 { ColumnType::Bytes8 => 4, ColumnType::Bytes32 => 5, ColumnType::ContractId => 6, - ColumnType::Salt => 7, - ColumnType::Int4 => 8, - ColumnType::Int8 => 9, - ColumnType::UInt4 => 10, - ColumnType::UInt8 => 11, - ColumnType::Timestamp => 12, - ColumnType::Blob => 13, - ColumnType::ForeignKey => 14, - ColumnType::Json => 15, - ColumnType::MessageId => 16, - ColumnType::Charfield => 17, - ColumnType::Identity => 18, - ColumnType::Boolean => 19, - ColumnType::Object => 20, - ColumnType::UInt16 => 21, - ColumnType::Int16 => 22, - ColumnType::Bytes64 => 23, - ColumnType::Signature => 24, - ColumnType::Nonce => 25, - ColumnType::HexString => 26, - ColumnType::Tai64Timestamp => 27, - ColumnType::TxId => 28, - ColumnType::BlockHeight => 29, - ColumnType::Enum => 30, - ColumnType::Int1 => 31, - ColumnType::UInt1 => 32, - ColumnType::Virtual => 33, - ColumnType::BlockId => 34, - ColumnType::Array => 35, - ColumnType::UID => 36, + ColumnType::I32 => 7, + ColumnType::I64 => 8, + ColumnType::U32 => 9, + ColumnType::U64 => 10, + ColumnType::Bytes => 11, + ColumnType::ForeignKey => 12, + ColumnType::Json => 13, + ColumnType::String => 14, + ColumnType::Identity => 15, + ColumnType::Boolean => 16, + ColumnType::Object => 17, + ColumnType::U128 => 18, + ColumnType::I128 => 19, + ColumnType::Bytes64 => 20, + ColumnType::Enum => 21, + ColumnType::I8 => 22, + ColumnType::U8 => 23, + ColumnType::Array => 24, + ColumnType::UID => 25, } } } @@ -157,36 +135,25 @@ impl From for ColumnType { 4 => ColumnType::Bytes8, 5 => ColumnType::Bytes32, 6 => ColumnType::ContractId, - 7 => ColumnType::Salt, - 8 => ColumnType::Int4, - 9 => ColumnType::Int8, - 10 => ColumnType::UInt4, - 11 => ColumnType::UInt8, - 12 => ColumnType::Timestamp, - 13 => ColumnType::Blob, - 14 => ColumnType::ForeignKey, - 15 => ColumnType::Json, - 16 => ColumnType::MessageId, - 17 => ColumnType::Charfield, - 18 => ColumnType::Identity, - 19 => ColumnType::Boolean, - 20 => ColumnType::Object, - 21 => ColumnType::Int16, - 22 => ColumnType::UInt16, - 23 => ColumnType::Bytes64, - 24 => ColumnType::Signature, - 25 => ColumnType::Nonce, - 26 => ColumnType::HexString, - 27 => ColumnType::Tai64Timestamp, - 28 => ColumnType::TxId, - 29 => ColumnType::BlockHeight, - 30 => ColumnType::Enum, - 31 => ColumnType::Int1, - 32 => ColumnType::UInt1, - 33 => ColumnType::Virtual, - 34 => ColumnType::BlockId, - 35 => ColumnType::Array, - 36 => ColumnType::UID, + 7 => ColumnType::I32, + 8 => ColumnType::I64, + 9 => ColumnType::U32, + 10 => ColumnType::U64, + 11 => ColumnType::Bytes, + 12 => ColumnType::ForeignKey, + 13 => ColumnType::Json, + 14 => ColumnType::String, + 15 => ColumnType::Identity, + 16 => ColumnType::Boolean, + 17 => ColumnType::Object, + 18 => ColumnType::I128, + 19 => ColumnType::U128, + 20 => ColumnType::Bytes64, + 21 => ColumnType::Enum, + 22 => ColumnType::I8, + 23 => ColumnType::U8, + 24 => ColumnType::Array, + 25 => ColumnType::UID, _ => unimplemented!("Invalid ColumnType: {num}."), } } @@ -195,42 +162,31 @@ impl From for ColumnType { impl From<&str> for ColumnType { fn from(name: &str) -> ColumnType { match name { - "ID" => ColumnType::ID, "Address" => ColumnType::Address, + "Array" => ColumnType::Array, "AssetId" => ColumnType::AssetId, + "Boolean" => ColumnType::Boolean, + "Bytes" => ColumnType::Bytes, + "Bytes32" => ColumnType::Bytes32, "Bytes4" => ColumnType::Bytes4, + "Bytes64" => ColumnType::Bytes64, "Bytes8" => ColumnType::Bytes8, - "Bytes32" => ColumnType::Bytes32, "ContractId" => ColumnType::ContractId, - "Salt" => ColumnType::Salt, - "Int4" => ColumnType::Int4, - "Int8" => ColumnType::Int8, - "UInt4" => ColumnType::UInt4, - "UInt8" => ColumnType::UInt8, - "Timestamp" => ColumnType::Timestamp, - "Blob" => ColumnType::Blob, + "Enum" => ColumnType::Enum, "ForeignKey" => ColumnType::ForeignKey, - "Json" => ColumnType::Json, - "MessageId" => ColumnType::MessageId, - "Charfield" => ColumnType::Charfield, + "I128" => ColumnType::I128, + "I32" => ColumnType::I32, + "I64" => ColumnType::I64, + "I8" => ColumnType::I8, + "ID" => ColumnType::ID, "Identity" => ColumnType::Identity, - "Boolean" => ColumnType::Boolean, + "Json" => ColumnType::Json, "Object" => ColumnType::Object, - "UInt16" => ColumnType::UInt16, - "Int16" => ColumnType::Int16, - "Bytes64" => ColumnType::Bytes64, - "Signature" => ColumnType::Signature, - "Nonce" => ColumnType::Nonce, - "HexString" => ColumnType::HexString, - "Tai64Timestamp" => ColumnType::Tai64Timestamp, - "TxId" => ColumnType::TxId, - "BlockHeight" => ColumnType::BlockHeight, - "Enum" => ColumnType::Enum, - "Int1" => ColumnType::Int1, - "UInt1" => ColumnType::UInt1, - "Virtual" => ColumnType::Virtual, - "BlockId" => ColumnType::BlockId, - "Array" => ColumnType::Array, + "String" => ColumnType::String, + "U128" => ColumnType::U128, + "U32" => ColumnType::U32, + "U64" => ColumnType::U64, + "U8" => ColumnType::U8, "UID" => ColumnType::UID, _ => unimplemented!("Invalid ColumnType: '{name}'."), } @@ -380,73 +336,53 @@ impl Column { match self.coltype { ColumnType::Address => "varchar(64)".to_string(), ColumnType::AssetId => "varchar(64)".to_string(), - ColumnType::Blob => "varchar(10485760)".to_string(), - ColumnType::BlockHeight => "integer".to_string(), - ColumnType::BlockId => "varchar(64)".to_string(), + ColumnType::Bytes => "varchar(10485760)".to_string(), ColumnType::Boolean => "boolean".to_string(), ColumnType::Bytes32 => "varchar(64)".to_string(), ColumnType::Bytes4 => "varchar(8)".to_string(), ColumnType::Bytes64 => "varchar(128)".to_string(), ColumnType::Bytes8 => "varchar(16)".to_string(), - ColumnType::Charfield => "varchar(255)".to_string(), + ColumnType::String => "varchar(255)".to_string(), ColumnType::ContractId => "varchar(64)".to_string(), ColumnType::Enum => "varchar(255)".to_string(), ColumnType::ForeignKey => "numeric(20, 0)".to_string(), - ColumnType::HexString => "varchar(10485760)".to_string(), ColumnType::ID => "varchar(64) primary key".to_string(), ColumnType::Identity => "varchar(66)".to_string(), - ColumnType::Int1 => "integer".to_string(), - ColumnType::Int16 => "numeric(39, 0)".to_string(), - ColumnType::Int4 => "integer".to_string(), - ColumnType::Int8 => "bigint".to_string(), + ColumnType::I8 => "integer".to_string(), + ColumnType::I128 => "numeric(39, 0)".to_string(), + ColumnType::I32 => "integer".to_string(), + ColumnType::I64 => "bigint".to_string(), ColumnType::Json => "json".to_string(), - ColumnType::MessageId => "varchar(64)".to_string(), - ColumnType::Nonce => "varchar(64)".to_string(), ColumnType::Object => "bytea".to_string(), - ColumnType::Salt => "varchar(64)".to_string(), - ColumnType::Signature => "varchar(128)".to_string(), - ColumnType::Tai64Timestamp => "varchar(128)".to_string(), - ColumnType::Timestamp => "timestamp".to_string(), - ColumnType::TxId => "varchar(64)".to_string(), - ColumnType::UInt1 => "integer".to_string(), - ColumnType::UInt16 => "numeric(39, 0)".to_string(), - ColumnType::UInt4 => "integer".to_string(), - ColumnType::UInt8 => "numeric(20, 0)".to_string(), - ColumnType::Virtual => "json".to_string(), + ColumnType::U8 => "integer".to_string(), + ColumnType::U128 => "numeric(39, 0)".to_string(), + ColumnType::U32 => "integer".to_string(), + ColumnType::U64 => "numeric(20, 0)".to_string(), ColumnType::UID => "varchar(64)".to_string(), ColumnType::Array => { let t = match self.array_coltype.expect( "Column.array_coltype cannot be None when using `ColumnType::Array`.", ) { - ColumnType::Int1 - | ColumnType::UInt1 - | ColumnType::Int4 - | ColumnType::UInt4 - | ColumnType::BlockHeight => "integer", - ColumnType::Timestamp => "timestamp", - ColumnType::Int8 => "bigint", - ColumnType::UInt8 => "numeric(20, 0)", - ColumnType::UInt16 | ColumnType::Int16 => "numeric(39, 0)", + ColumnType::I8 + | ColumnType::U8 + | ColumnType::I32 + | ColumnType::U32 + | ColumnType::I64 => "bigint", + ColumnType::U64 => "numeric(20, 0)", + ColumnType::U128 | ColumnType::I128 => "numeric(39, 0)", ColumnType::Address | ColumnType::Bytes4 | ColumnType::Bytes8 | ColumnType::Bytes32 | ColumnType::AssetId | ColumnType::ContractId - | ColumnType::Salt - | ColumnType::MessageId - | ColumnType::Charfield + | ColumnType::String | ColumnType::Identity | ColumnType::Bytes64 - | ColumnType::Signature - | ColumnType::Nonce - | ColumnType::HexString - | ColumnType::TxId - | ColumnType::BlockId | ColumnType::ID | ColumnType::UID => "varchar(64)", - ColumnType::Blob => "bytea", - ColumnType::Json | ColumnType::Virtual => "json", + ColumnType::Bytes => "bytea", + ColumnType::Json => "json", _ => unimplemented!(), }; @@ -1276,15 +1212,15 @@ mod tests { let schema = r#" type Person @entity { id: ID! - name: Charfield! @unique - age: UInt1! + name: String! @unique + age: U8! }"#; let fields = [ ("id", "ID", None), ( "name", - "Charfield", + "String", Some(vec![Positioned { pos: Pos::default(), node: ConstDirective { @@ -1296,7 +1232,7 @@ type Person @entity { }, }]), ), - ("age", "UInt1", None), + ("age", "U8", None), ] .iter() .map(|(name, typ, directives)| { @@ -1354,8 +1290,8 @@ type Person @entity { let schema = r#" type Person @entity { id: ID! - name: Charfield! @unique - age: UInt1! + name: String! @unique + age: U8! }"#; let schema = ParsedGraphQLSchema::new( @@ -1376,7 +1312,7 @@ type Person @entity { ty: Positioned { pos: Pos::default(), node: Type { - base: BaseType::Named(Name::new("Charfield")), + base: BaseType::Named(Name::new("String")), nullable: false, }, }, @@ -1395,8 +1331,8 @@ type Person @entity { let type_id = type_id(&schema.fully_qualified_namespace(), "Person"); let column = Column::from_field_def(&field_def, &schema, type_id, 0, Persistence::Scalar); - assert_eq!(column.graphql_type, "Charfield".to_string()); - assert_eq!(column.coltype, ColumnType::Charfield); + assert_eq!(column.graphql_type, "String".to_string()); + assert_eq!(column.coltype, ColumnType::String); assert!(column.unique); assert!(!column.nullable); } @@ -1406,7 +1342,7 @@ type Person @entity { let schema = r#" type Account @entity { id: ID! - index: UInt8! + index: U64! } type Wallet @entity { diff --git a/packages/fuel-indexer-database/postgres/sqlx-data.json b/packages/fuel-indexer-database/postgres/sqlx-data.json index 5c9405e71..38e66a332 100644 --- a/packages/fuel-indexer-database/postgres/sqlx-data.json +++ b/packages/fuel-indexer-database/postgres/sqlx-data.json @@ -6,12 +6,12 @@ { "name": "id: i64", "ordinal": 0, - "type_info": "Int8" + "type_info": "I64" }, { "name": "root_id: i64", "ordinal": 1, - "type_info": "Int8" + "type_info": "I64" }, { "name": "column_name", @@ -32,7 +32,7 @@ ], "parameters": { "Left": [ - "Int8" + "I64" ] } }, @@ -44,7 +44,7 @@ { "name": "id", "ordinal": 0, - "type_info": "Int8" + "type_info": "I64" }, { "name": "namespace", @@ -77,7 +77,7 @@ { "name": "id", "ordinal": 0, - "type_info": "Int8" + "type_info": "I64" }, { "name": "namespace", @@ -107,17 +107,17 @@ { "name": "id: i64", "ordinal": 0, - "type_info": "Int8" + "type_info": "I64" }, { "name": "type_id", "ordinal": 1, - "type_info": "Int8" + "type_info": "I64" }, { "name": "column_position", "ordinal": 2, - "type_info": "Int4" + "type_info": "I32" }, { "name": "column_name", @@ -151,7 +151,7 @@ ], "parameters": { "Left": [ - "Int8" + "I64" ] } }, @@ -184,7 +184,7 @@ { "name": "type_id", "ordinal": 0, - "type_info": "Int8" + "type_info": "I64" }, { "name": "table_name", @@ -194,7 +194,7 @@ { "name": "column_position", "ordinal": 2, - "type_info": "Int4" + "type_info": "I32" }, { "name": "column_name", diff --git a/packages/fuel-indexer-graphql/src/dynamic.rs b/packages/fuel-indexer-graphql/src/dynamic.rs index 89cbd867a..4aad74ade 100644 --- a/packages/fuel-indexer-graphql/src/dynamic.rs +++ b/packages/fuel-indexer-graphql/src/dynamic.rs @@ -23,51 +23,36 @@ lazy_static! { static ref SCALAR_TYPES: HashSet<&'static str> = HashSet::from([ "Address", "AssetId", - "Blob", - "BlockHeight", - "BlockId", "Boolean", + "Bytes", "Bytes32", "Bytes4", "Bytes64", "Bytes8", - "Charfield", - "Color", "ContractId", - "HexString", + "I128", + "I32", + "I64", + "I8", "ID", "Identity", - "Int1", - "Int16", - "Int4", - "Int8", "Json", - "MessageId", - "Nonce", - "Salt", - "Signature", - "Tai64Timestamp", - "Timestamp", - "TxId", + "U128", + "U32", + "U64", + "U8", "UID", - "UInt1", - "UInt16", - "UInt4", - "UInt8", - "Virtual", ]); /// Scalar types that are represented by a numeric type. This ensures that the /// value type provided for a field filter matches the type of the scalar itself. static ref NUMERIC_SCALAR_TYPES: HashSet<&'static str> = HashSet::from([ - "Int16", - "Int4", - "Int8", - "Timestamp", - "Tai64Timestamp", - "UInt16", - "UInt4", - "UInt8", + "I128", + "I32", + "I64", + "U128", + "U32", + "U64", ]); /// Scalar types that are represented by a string type. This ensures that the @@ -75,25 +60,16 @@ lazy_static! { static ref STRING_SCALAR_TYPES: HashSet<&'static str> = HashSet::from([ "Address", "AssetId", - "Blob", - "BlockHeight", - "BlockId", + "Bytes", "Bytes32", "Bytes4", "Bytes64", "Bytes64", "Bytes8", - "Charfield", - "Color", "ContractId", - "HexString", "ID", "Identity", "Json", - "MessageId", - "Nonce", - "Salt", - "Signature", "UID", ]); @@ -101,25 +77,16 @@ lazy_static! { static ref SORTABLE_SCALAR_TYPES: HashSet<&'static str> = HashSet::from([ "Address", "AssetId", - "Charfield", - "Color", "ContractId", - "HexString", + "I128", + "I32", + "I64", "ID", "Identity", - "Int16", - "Int4", - "Int8", - "MessageId", - "Nonce", - "Salt", - "Signature", - "Tai64Timestamp", - "Timestamp", + "U128", + "U32", + "U64", "UID", - "UInt16", - "UInt4", - "UInt8", ]); /// Entity types that should be ignored when building the dynamic schema, diff --git a/packages/fuel-indexer-graphql/src/graphql.rs b/packages/fuel-indexer-graphql/src/graphql.rs index cf1942ebf..ab7465d7c 100644 --- a/packages/fuel-indexer-graphql/src/graphql.rs +++ b/packages/fuel-indexer-graphql/src/graphql.rs @@ -756,13 +756,13 @@ mod tests { let schema = r#" type Block @entity { id: ID! - height: UInt8! - timestamp: Int8! + height: U64! + timestamp: I64! } type Tx @entity { id: ID! - timestamp: Int8! + timestamp: I64! block: Block input_data: Json! } diff --git a/packages/fuel-indexer-lib/src/constants.rs b/packages/fuel-indexer-lib/src/constants.rs index c874f9501..1cff8f521 100644 --- a/packages/fuel-indexer-lib/src/constants.rs +++ b/packages/fuel-indexer-lib/src/constants.rs @@ -12,48 +12,32 @@ lazy_static! { pub static ref ASREF_BYTE_TYPES: HashSet<&'static str> = HashSet::from([ "Address", "AssetId", - "Blob", - "BlockId", + "Bytes", "Boolean", "Bytes", - "Bytes20", "Bytes32", "Bytes4", "Bytes64", "Bytes8", - "Charfield", + "String", "ContractId", - "HexString", "Json", - "MessageId", - "Nonce", "Option
", "Option", - "Option", - "Option", + "Option", "Option", "Option", - "Option", "Option", "Option", "Option", "Option", - "Option", + "Option", "Option", - "Option", "Option", - "Option", - "Option", "Option", "Option", "Option", - "Option", - "Option", - "Salt", - "Signature", "UID", - "TxId", - "Virtual", ]); /// Set of external types that do not implement `AsRef<[u8]>`. @@ -92,23 +76,19 @@ lazy_static! { /// Set of types that should be copied instead of referenced. pub static ref COPY_TYPES: HashSet<&'static str> = HashSet::from([ - "Blob", - "Charfield", - "HexString", + "Bytes", "ID", "Identity", "Json", - "Option", - "Option", - "Option", + "Option", "Option", "Option", "Option", "Option", - "Option", + "Option", "UID", "Vec", - "Virtual", + "String", ]); /// Fuel-specific receipt-related type names. @@ -133,39 +113,27 @@ lazy_static! { // Scalars. "Address", "AssetId", - "Blob", - "BlockHeight", - "BlockId", "Boolean", "Bytes", + "Bytes", "Bytes32", "Bytes4", "Bytes64", "Bytes8", - "Charfield", - "Color", "ContractId", - "HexString", + "I128", + "I32", + "I64", + "I8", "ID", "Identity", - "Int1", - "Int16", - "Int4", - "Int8", "Json", - "MessageId", - "Nonce", - "Salt", - "Signature", - "Tai64Timestamp", - "Timestamp", - "TxId", + "U128", + "U32", + "U64", + "U8", "UID", - "UInt1", - "UInt16", - "UInt4", - "UInt8", - "Virtual", + "String", // Imports for transaction fields. // https://github.com/FuelLabs/fuel-indexer/issues/286 diff --git a/packages/fuel-indexer-lib/src/graphql/base.graphql b/packages/fuel-indexer-lib/src/graphql/base.graphql index 60a95d400..a497706be 100644 --- a/packages/fuel-indexer-lib/src/graphql/base.graphql +++ b/packages/fuel-indexer-lib/src/graphql/base.graphql @@ -1,38 +1,26 @@ scalar Address scalar AssetId -scalar Blob -scalar BlockHeight -scalar BlockId scalar Boolean scalar Bytes +scalar Bytes scalar Bytes32 scalar Bytes4 scalar Bytes64 scalar Bytes8 -scalar Charfield -scalar Color scalar ContractId -scalar HexString +scalar I128 +scalar I32 +scalar I64 +scalar I8 scalar ID scalar Identity -scalar Int1 -scalar Int16 -scalar Int4 -scalar Int8 scalar Json -scalar MessageId -scalar Nonce -scalar Salt -scalar Signature -scalar Tai64Timestamp -scalar Timestamp -scalar TxId +scalar U128 +scalar U32 +scalar U64 +scalar U8 scalar UID -scalar UInt1 -scalar UInt16 -scalar UInt4 -scalar UInt8 -scalar Virtual +scalar String enum IndexType { BTree, diff --git a/packages/fuel-indexer-lib/src/graphql/constants.rs b/packages/fuel-indexer-lib/src/graphql/constants.rs index 08d77ac4c..5905bbf31 100644 --- a/packages/fuel-indexer-lib/src/graphql/constants.rs +++ b/packages/fuel-indexer-lib/src/graphql/constants.rs @@ -12,26 +12,19 @@ lazy_static! { pub static ref ASREF_BYTE_TYPES: HashSet<&'static str> = HashSet::from([ "Address", "AssetId", - "Blob", - "BlockId", + "Bytes", "Boolean", "Bytes", - "Bytes20", "Bytes32", "Bytes4", "Bytes64", "Bytes8", - "Charfield", + "String", "ContractId", - "HexString", "Json", - "MessageId", - "Virtual", - "Nonce", "Option
", "Option", - "Option", - "Option", + "Option", "Option", "Option", "Option", @@ -39,27 +32,15 @@ lazy_static! { "Option", "Option", "Option", - "Option", + "Option", "Option", - "Option", "Option", - "Option", - "Option", - "Option", - "Option", - "Option", - "Option", - "Salt", - "Signature", - "TxId", ]); /// Set of external types that do not implement `AsRef<[u8]>`. pub static ref EXTERNAL_FIELD_TYPES: HashSet<&'static str> = HashSet::from([ "Identity", "Option", - "Option", - "Tai64Timestamp", ]); /// Set of field types that are currently unable to be used as a digest for SHA-256 hashing. @@ -71,17 +52,13 @@ lazy_static! { /// Set of types that should be copied instead of referenced. pub static ref COPY_TYPES: HashSet<&'static str> = HashSet::from([ - "Blob", - "Charfield", - "HexString", + "Bytes", + "String", "Identity", "Json", - "Virtual", - "Option", - "Option", - "Option", + "Option", + "Option", "Option", "Option", - "Option", ]); } diff --git a/packages/fuel-indexer-lib/src/graphql/parser.rs b/packages/fuel-indexer-lib/src/graphql/parser.rs index 7956a26e7..0e609a7e7 100644 --- a/packages/fuel-indexer-lib/src/graphql/parser.rs +++ b/packages/fuel-indexer-lib/src/graphql/parser.rs @@ -401,9 +401,9 @@ impl ParsedGraphQLSchema { return ref_coltype; } else if self.is_virtual_typedef(&typ_name) { - return "Virtual".to_string(); + return "Json".to_string(); } else if self.is_enum_typedef(&typ_name) { - return "Charfield".to_string(); + return "String".to_string(); } else { return typ_name; } @@ -416,11 +416,11 @@ impl ParsedGraphQLSchema { } if self.is_virtual_typedef(&typ_name) { - return "Virtual".to_string(); + return "Json".to_string(); } if self.is_enum_typedef(&typ_name) { - return "Charfield".to_string(); + return "String".to_string(); } typ_name @@ -967,17 +967,17 @@ type Account @entity { type User @entity { id: ID! account: Account! - username: Charfield! + username: String! } type Loser @entity { id: ID! account: Account! - age: UInt8! + age: U64! } type Metadata @entity(virtual: true) { - count: UInt8! + count: U64! } union Person = User | Loser @@ -995,7 +995,7 @@ type Safe @entity { type Vault @entity { id: ID! - label: Charfield! + label: String! user: [User!]! } @@ -1079,16 +1079,16 @@ type TransactionData @entity { let schema = r#" type Foo @entity { id: ID! - name: Charfield! + name: String! } type Bar @entity { id: ID! - age: UInt8! + age: U64! } type Zoo @entity(virtual: true) { - height: UInt8! + height: U64! } union Baz = Foo | Bar | Zoo @@ -1111,17 +1111,17 @@ union Baz = Foo | Bar | Zoo let schema = r#" type Foo @entity { id: ID! - name: Charfield! + name: String! } type Bar @entity { id: ID! - age: UInt8! + age: U64! } type Zoo @entity { id: ID! - name: UInt8! + name: U64! } union Baz = Foo | Bar | Zoo @@ -1144,7 +1144,7 @@ union Baz = Foo | Bar | Zoo let schema = r#" type Foo @entity { id: ID! - name: Charfield! + name: String! } type Zoo @entity { @@ -1164,13 +1164,13 @@ type Zoo @entity { #[test] #[should_panic( - expected = "FieldDefinition(id) on TypeDefinition(Foo) must be of type `ID!`. Found type `Charfield!`." + expected = "FieldDefinition(id) on TypeDefinition(Foo) must be of type `ID!`. Found type `String!`." )] fn test_schema_validator_id_field_is_type_id() { let schema = r#" type Foo @entity { - id: Charfield! - name: Charfield! + id: String! + name: String! }"#; let _ = ParsedGraphQLSchema::new( @@ -1190,7 +1190,7 @@ type Foo @entity { let schema = r#" type Foo @entity(virtual: true) { id: ID! - name: Charfield! + name: String! }"#; let _ = ParsedGraphQLSchema::new( @@ -1210,7 +1210,7 @@ type Foo @entity(virtual: true) { let schema = r#" type Foo @entity { id: ID! - name: Charfield! + name: String! } type Bar @entity { @@ -1236,57 +1236,57 @@ type Bar @entity { let schema = r#" type Type1 @entity { id: ID! - name: Charfield! + name: String! } type Type2 @entity { id: ID! - name: Charfield! + name: String! } type Type3 @entity { id: ID! - name: Charfield! + name: String! } type Type4 @entity { id: ID! - name: Charfield! + name: String! } type Type5 @entity { id: ID! - name: Charfield! + name: String! } type Type6 @entity { id: ID! - name: Charfield! + name: String! } type Type7 @entity { id: ID! - name: Charfield! + name: String! } type Type8 @entity { id: ID! - name: Charfield! + name: String! } type Type9 @entity { id: ID! - name: Charfield! + name: String! } type Type10 @entity { id: ID! - name: Charfield! + name: String! } type Type11 @entity { id: ID! - name: Charfield! + name: String! } type Bar @entity { @@ -1316,13 +1316,13 @@ type Bar @entity { #[test] #[should_panic( - expected = "FieldDefinition(foo) on TypeDefinition(Bar) is a many-to-many relationship where the inner scalar is of type `name: Charfield!`. However, only inner scalars of type `id: ID!` are allowed." + expected = "FieldDefinition(foo) on TypeDefinition(Bar) is a many-to-many relationship where the inner scalar is of type `name: String!`. However, only inner scalars of type `id: ID!` are allowed." )] fn test_schema_validator_m2m_fk_field_ref_col_is_id() { let schema = r#" type Foo @entity { id: ID! - name: Charfield! + name: String! } type Bar @entity { diff --git a/packages/fuel-indexer-macros/src/decoder.rs b/packages/fuel-indexer-macros/src/decoder.rs index d875e3f80..cf50be7d9 100644 --- a/packages/fuel-indexer-macros/src/decoder.rs +++ b/packages/fuel-indexer-macros/src/decoder.rs @@ -967,11 +967,11 @@ mod tests { let schema = r#" type Person @entity { id: ID! - name: Charfield! - age: UInt1! + name: String! + age: U8! }"#; - let fields = [("id", "ID"), ("name", "Charfield"), ("age", "UInt1")] + let fields = [("id", "ID"), ("name", "String"), ("age", "U8")] .iter() .map(|(name, typ)| Positioned { pos: Pos::default(), @@ -1032,9 +1032,7 @@ type Person @entity { assert!(tokenstream.contains("pub struct Person")); assert!(tokenstream.contains("impl < 'a > Entity < 'a > for Person")); assert!(tokenstream.contains("impl Person")); - assert!( - tokenstream.contains("pub fn new (name : Charfield , age : UInt1 ,) -> Self") - ); + assert!(tokenstream.contains("pub fn new (name : String , age : U8 ,) -> Self")); assert!(tokenstream.contains("pub fn get_or_create (self) -> Self")); assert!(tokenstream.contains("fn from_row (mut vec : Vec < FtColumn >) -> Self")); assert!(tokenstream.contains("fn to_row (& self) -> Vec < FtColumn >")); @@ -1046,7 +1044,7 @@ type Person @entity { let schema = r#" type Account @entity { id: ID! - index: UInt8! + index: U64! } type Wallet @entity { diff --git a/packages/fuel-indexer-schema/src/lib.rs b/packages/fuel-indexer-schema/src/lib.rs index 29f0e9152..1605e5452 100644 --- a/packages/fuel-indexer-schema/src/lib.rs +++ b/packages/fuel-indexer-schema/src/lib.rs @@ -8,7 +8,7 @@ extern crate alloc; use fuel_indexer_lib::MAX_ARRAY_LENGTH; -use fuel_indexer_types::{fuel::*, scalar::*, Identity}; +use fuel_indexer_types::{scalar::*, Identity}; use serde::{Deserialize, Serialize}; use thiserror::Error; @@ -53,38 +53,27 @@ pub enum FtColumn { Address(Option
), Array(Option>), AssetId(Option), - Blob(Option), - BlockHeight(Option), - BlockId(Option), Boolean(Option), + Bytes(Option), Bytes32(Option), Bytes4(Option), Bytes64(Option), Bytes8(Option), - Charfield(Option), ContractId(Option), Enum(Option), - HexString(Option), + I128(Option), + I32(Option), + I64(Option), + I8(Option), ID(Option), Identity(Option), - Int1(Option), - Int16(Option), - Int4(Option), - Int8(Option), Json(Option), - MessageId(Option), - Nonce(Option), - Salt(Option), - Signature(Option), - Tai64Timestamp(Option), - Timestamp(Option), - TxId(Option), + U128(Option), + U32(Option), + U64(Option), + U8(Option), UID(Option), - UInt1(Option), - UInt16(Option), - UInt4(Option), - UInt8(Option), - Virtual(Option), + String(Option), } impl FtColumn { @@ -121,11 +110,7 @@ impl FtColumn { Some(val) => format!("'{val:x}'"), None => String::from(NULL_VALUE), }, - FtColumn::Bytes32(value) | FtColumn::BlockId(value) => match value { - Some(val) => format!("'{val:x}'"), - None => String::from(NULL_VALUE), - }, - FtColumn::Nonce(value) => match value { + FtColumn::Bytes32(value) => match value { Some(val) => format!("'{val:x}'"), None => String::from(NULL_VALUE), }, @@ -133,85 +118,50 @@ impl FtColumn { Some(val) => format!("'{val:x}'"), None => String::from(NULL_VALUE), }, - FtColumn::TxId(value) => match value { - Some(val) => format!("'{val:x}'"), - None => String::from(NULL_VALUE), - }, - FtColumn::HexString(value) => match value { - Some(val) => format!("'{val:x}'"), - None => String::from(NULL_VALUE), - }, - FtColumn::Signature(value) => match value { - Some(val) => format!("'{val:x}'"), - None => String::from(NULL_VALUE), - }, FtColumn::ContractId(value) => match value { Some(val) => format!("'{val:x}'"), None => String::from(NULL_VALUE), }, - FtColumn::Int4(value) => match value { - Some(val) => format!("{val}"), - None => String::from(NULL_VALUE), - }, - FtColumn::Int1(value) => match value { - Some(val) => format!("{val}"), - None => String::from(NULL_VALUE), - }, - FtColumn::UInt1(value) => match value { + FtColumn::I32(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::Int8(value) => match value { + FtColumn::I8(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::Int16(value) => match value { + FtColumn::U8(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::UInt4(value) => match value { + FtColumn::I64(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::BlockHeight(value) => match value { + FtColumn::I128(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::UInt8(value) => match value { + FtColumn::U32(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::UInt16(value) => match value { + FtColumn::U64(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::Timestamp(value) => match value { + FtColumn::U128(value) => match value { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::Tai64Timestamp(value) => match value { - Some(val) => { - let x = hex::encode(val.to_bytes()); - format!("'{x}'") - } - None => String::from(NULL_VALUE), - }, - FtColumn::Salt(value) => match value { - Some(val) => format!("'{val:x}'"), - None => String::from(NULL_VALUE), - }, - FtColumn::Json(value) | FtColumn::Virtual(value) => match value { + FtColumn::Json(value) => match value { Some(val) => { let x = &val.0; format!("'{x}'") } None => String::from(NULL_VALUE), }, - FtColumn::MessageId(value) => match value { - Some(val) => format!("'{val:x}'"), - None => String::from(NULL_VALUE), - }, - FtColumn::Charfield(value) => match value { + FtColumn::String(value) => match value { Some(val) => format!("'{val}'"), None => String::from(NULL_VALUE), }, @@ -226,7 +176,7 @@ impl FtColumn { Some(val) => format!("{val}"), None => String::from(NULL_VALUE), }, - FtColumn::Blob(value) => match value { + FtColumn::Bytes(value) => match value { Some(blob) => { let x = hex::encode(blob.as_ref()); format!("'{x}'") @@ -272,7 +222,7 @@ impl FtColumn { // We have to force sqlx to see this as a JSON type else it will think this type // should be TEXT let suffix = match arr[0] { - FtColumn::Virtual(_) | FtColumn::Json(_) => "::json[]", + FtColumn::Json(_) => "::json[]", _ => "", }; @@ -308,78 +258,50 @@ mod tests { FtColumn::Bytes8(Some(Bytes8::try_from([0x9D; 8]).expect("Bad bytes"))); let bytes32 = FtColumn::Bytes32(Some(Bytes32::try_from([0xEE; 32]).expect("Bad bytes"))); - let nonce = - FtColumn::Nonce(Some(Nonce::try_from([0x12; 32]).expect("Bad bytes"))); let bytes64 = FtColumn::Bytes64(Some(Bytes64::try_from([0x12; 64]).expect("Bad bytes"))); - let txid = FtColumn::TxId(Some(TxId::try_from([0x12; 32]).expect("Bad bytes"))); - let hex = FtColumn::HexString(Some( - HexString::try_from("this is a hexstring").expect("Bad bytes"), - )); - let sig = FtColumn::Signature(Some( - Signature::try_from([0x12; 64]).expect("Bad bytes"), - )); let contractid = FtColumn::ContractId(Some( ContractId::try_from([0x78; 32]).expect("Bad bytes"), )); - let int4 = FtColumn::Int4(Some(i32::from_le_bytes([0x78; 4]))); - let int8 = FtColumn::Int8(Some(i64::from_le_bytes([0x78; 8]))); - let int16 = FtColumn::Int16(Some(i128::from_le_bytes([0x78; 16]))); - let uint4 = FtColumn::UInt4(Some(u32::from_le_bytes([0x78; 4]))); - let uint1 = FtColumn::UInt1(Some(u8::from_le_bytes([0x78; 1]))); - let uint8 = FtColumn::UInt8(Some(u64::from_le_bytes([0x78; 8]))); - let uint16 = FtColumn::UInt16(Some(u128::from_le_bytes([0x78; 16]))); - let int64 = FtColumn::Timestamp(Some(i64::from_le_bytes([0x78; 8]))); - let block_height = - FtColumn::BlockHeight(Some(BlockHeight::try_from(0x78).unwrap())); - let timestamp = FtColumn::Timestamp(Some(i64::from_le_bytes([0x78; 8]))); - let tai64_timestamp = FtColumn::Tai64Timestamp(Some( - Tai64Timestamp::try_from([0u8; 8]).expect("Bad bytes"), - )); - let salt = FtColumn::Salt(Some(Salt::try_from([0x31; 32]).expect("Bad bytes"))); - let message_id = FtColumn::MessageId(Some( - MessageId::try_from([0x0F; 32]).expect("Bad bytes"), - )); - let charfield = FtColumn::Charfield(Some(String::from("hello world"))); - let json = FtColumn::Json(Some(Json(r#"{"hello":"world"}"#.to_string()))); + let array = FtColumn::Array(Some(vec![FtColumn::I32(Some(1))])); + let bytes = FtColumn::Bytes(Some(Bytes::from(vec![0u8, 1, 2, 3, 4, 5]))); let identity = FtColumn::Identity(Some(Identity::Address([0x12; 32].into()))); + let int16 = FtColumn::I128(Some(i128::from_le_bytes([0x78; 16]))); + let int4 = FtColumn::I32(Some(i32::from_le_bytes([0x78; 4]))); + let int64 = FtColumn::I64(Some(i64::from_le_bytes([0x78; 8]))); + let int8 = FtColumn::I64(Some(i64::from_le_bytes([0x78; 8]))); + let json = FtColumn::Json(Some(Json(r#"{"hello":"world"}"#.to_string()))); let r#bool = FtColumn::Boolean(Some(true)); - let blob = FtColumn::Blob(Some(Blob::from(vec![0u8, 1, 2, 3, 4, 5]))); let r#enum = FtColumn::Enum(Some(String::from("hello"))); - let array = FtColumn::Array(Some(vec![FtColumn::Int4(Some(1))])); + let uint1 = FtColumn::U8(Some(u8::from_le_bytes([0x78; 1]))); + let uint16 = FtColumn::U128(Some(u128::from_le_bytes([0x78; 16]))); + let uint4 = FtColumn::U32(Some(u32::from_le_bytes([0x78; 4]))); + let uint8 = FtColumn::U64(Some(u64::from_le_bytes([0x78; 8]))); + let xstring = FtColumn::String(Some(String::from("hello world"))); - insta::assert_yaml_snapshot!(uid.query_fragment()); insta::assert_yaml_snapshot!(addr.query_fragment()); + insta::assert_yaml_snapshot!(array.query_fragment()); insta::assert_yaml_snapshot!(asset_id.query_fragment()); - insta::assert_yaml_snapshot!(bytes4.query_fragment()); - insta::assert_yaml_snapshot!(bytes8.query_fragment()); + insta::assert_yaml_snapshot!(bytes.query_fragment()); insta::assert_yaml_snapshot!(bytes32.query_fragment()); - insta::assert_yaml_snapshot!(nonce.query_fragment()); + insta::assert_yaml_snapshot!(bytes4.query_fragment()); insta::assert_yaml_snapshot!(bytes64.query_fragment()); - insta::assert_yaml_snapshot!(txid.query_fragment()); - insta::assert_yaml_snapshot!(hex.query_fragment()); - insta::assert_yaml_snapshot!(sig.query_fragment()); + insta::assert_yaml_snapshot!(bytes8.query_fragment()); insta::assert_yaml_snapshot!(contractid.query_fragment()); - insta::assert_yaml_snapshot!(salt.query_fragment()); - insta::assert_yaml_snapshot!(int4.query_fragment()); - insta::assert_yaml_snapshot!(int8.query_fragment()); + insta::assert_yaml_snapshot!(identity.query_fragment()); insta::assert_yaml_snapshot!(int16.query_fragment()); - insta::assert_yaml_snapshot!(uint4.query_fragment()); - insta::assert_yaml_snapshot!(uint1.query_fragment()); - insta::assert_yaml_snapshot!(uint8.query_fragment()); - insta::assert_yaml_snapshot!(uint16.query_fragment()); + insta::assert_yaml_snapshot!(int4.query_fragment()); insta::assert_yaml_snapshot!(int64.query_fragment()); - insta::assert_yaml_snapshot!(block_height.query_fragment()); - insta::assert_yaml_snapshot!(timestamp.query_fragment()); - insta::assert_yaml_snapshot!(tai64_timestamp.query_fragment()); - insta::assert_yaml_snapshot!(message_id.query_fragment()); - insta::assert_yaml_snapshot!(charfield.query_fragment()); + insta::assert_yaml_snapshot!(int8.query_fragment()); insta::assert_yaml_snapshot!(json.query_fragment()); - insta::assert_yaml_snapshot!(identity.query_fragment()); insta::assert_yaml_snapshot!(r#bool.query_fragment()); - insta::assert_yaml_snapshot!(blob.query_fragment()); insta::assert_yaml_snapshot!(r#enum.query_fragment()); - insta::assert_yaml_snapshot!(array.query_fragment()); + insta::assert_yaml_snapshot!(uid.query_fragment()); + insta::assert_yaml_snapshot!(uint1.query_fragment()); + insta::assert_yaml_snapshot!(uint16.query_fragment()); + insta::assert_yaml_snapshot!(uint4.query_fragment()); + insta::assert_yaml_snapshot!(uint8.query_fragment()); + insta::assert_yaml_snapshot!(xstring.query_fragment()); } #[test] @@ -387,66 +309,48 @@ mod tests { use super::*; let addr_none = FtColumn::Address(None); + let array = FtColumn::Array(None); let asset_id_none = FtColumn::AssetId(None); + let bytes = FtColumn::Bytes(None); + let bytes32_none = FtColumn::Bytes32(None); let bytes4_none = FtColumn::Bytes4(None); + let bytes64 = FtColumn::Bytes64(None); let bytes8_none = FtColumn::Bytes8(None); - let bytes32_none = FtColumn::Bytes32(None); let contractid_none = FtColumn::ContractId(None); - let int4_none = FtColumn::Int4(None); - let int8_none = FtColumn::Int8(None); - let int16_none = FtColumn::Int8(None); - let uint4_none = FtColumn::UInt4(None); - let uint8_none = FtColumn::UInt8(None); - let uint16_none = FtColumn::UInt8(None); - let int64_none = FtColumn::Timestamp(None); - let salt_none = FtColumn::Salt(None); - let message_id_none = FtColumn::MessageId(None); - let charfield_none = FtColumn::Charfield(None); - let json_none = FtColumn::Json(None); let identity_none = FtColumn::Identity(None); - let nonce = FtColumn::Nonce(None); - let bytes64 = FtColumn::Bytes64(None); - let txid = FtColumn::TxId(None); - let hex = FtColumn::HexString(None); - let sig = FtColumn::Signature(None); - let block_height = FtColumn::BlockHeight(None); - let timestamp = FtColumn::Timestamp(None); - let tai64_timestamp = FtColumn::Tai64Timestamp(None); + let int16_none = FtColumn::I64(None); + let int4_none = FtColumn::I32(None); + let int64_none = FtColumn::I64(None); + let int8_none = FtColumn::I64(None); + let json_none = FtColumn::Json(None); let r#bool = FtColumn::Boolean(None); - let blob = FtColumn::Blob(None); let r#enum = FtColumn::Enum(None); - let array = FtColumn::Array(None); + let uint16_none = FtColumn::U64(None); + let uint4_none = FtColumn::U32(None); + let uint8_none = FtColumn::U64(None); + let xstring_none = FtColumn::String(None); insta::assert_yaml_snapshot!(addr_none.query_fragment()); + insta::assert_yaml_snapshot!(array.query_fragment()); insta::assert_yaml_snapshot!(asset_id_none.query_fragment()); + insta::assert_yaml_snapshot!(bytes.query_fragment()); + insta::assert_yaml_snapshot!(bytes32_none.query_fragment()); insta::assert_yaml_snapshot!(bytes4_none.query_fragment()); + insta::assert_yaml_snapshot!(bytes64.query_fragment()); insta::assert_yaml_snapshot!(bytes8_none.query_fragment()); - insta::assert_yaml_snapshot!(bytes32_none.query_fragment()); insta::assert_yaml_snapshot!(contractid_none.query_fragment()); - insta::assert_yaml_snapshot!(salt_none.query_fragment()); - insta::assert_yaml_snapshot!(int4_none.query_fragment()); - insta::assert_yaml_snapshot!(int8_none.query_fragment()); + insta::assert_yaml_snapshot!(identity_none.query_fragment()); insta::assert_yaml_snapshot!(int16_none.query_fragment()); - insta::assert_yaml_snapshot!(uint4_none.query_fragment()); - insta::assert_yaml_snapshot!(uint8_none.query_fragment()); - insta::assert_yaml_snapshot!(uint16_none.query_fragment()); + insta::assert_yaml_snapshot!(int4_none.query_fragment()); insta::assert_yaml_snapshot!(int64_none.query_fragment()); - insta::assert_yaml_snapshot!(message_id_none.query_fragment()); - insta::assert_yaml_snapshot!(charfield_none.query_fragment()); + insta::assert_yaml_snapshot!(int8_none.query_fragment()); insta::assert_yaml_snapshot!(json_none.query_fragment()); - insta::assert_yaml_snapshot!(identity_none.query_fragment()); - insta::assert_yaml_snapshot!(nonce.query_fragment()); - insta::assert_yaml_snapshot!(bytes64.query_fragment()); - insta::assert_yaml_snapshot!(txid.query_fragment()); - insta::assert_yaml_snapshot!(hex.query_fragment()); - insta::assert_yaml_snapshot!(sig.query_fragment()); - insta::assert_yaml_snapshot!(block_height.query_fragment()); - insta::assert_yaml_snapshot!(timestamp.query_fragment()); - insta::assert_yaml_snapshot!(tai64_timestamp.query_fragment()); insta::assert_yaml_snapshot!(r#bool.query_fragment()); - insta::assert_yaml_snapshot!(blob.query_fragment()); insta::assert_yaml_snapshot!(r#enum.query_fragment()); - insta::assert_yaml_snapshot!(array.query_fragment()); + insta::assert_yaml_snapshot!(uint16_none.query_fragment()); + insta::assert_yaml_snapshot!(uint4_none.query_fragment()); + insta::assert_yaml_snapshot!(uint8_none.query_fragment()); + insta::assert_yaml_snapshot!(xstring_none.query_fragment()); } #[test] diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-10.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-10.snap index b06dca9aa..f0e136800 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-10.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-10.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: hex.query_fragment() +expression: identity.query_fragment() --- -"'74686973206973206120686578737472696e67'" +"'1212121212121212121212121212121212121212121212121212121212121212'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-11.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-11.snap index 6f08b4a22..f25d928ec 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-11.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-11.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: sig.query_fragment() +expression: int16.query_fragment() --- -"'12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212'" +"160132878551029865159235109379655628920" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-12.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-12.snap index e372c02fc..eec7383bf 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-12.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-12.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: contractid.query_fragment() +expression: int4.query_fragment() --- -"'7878787878787878787878787878787878787878787878787878787878787878'" +"2021161080" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-13.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-13.snap index 82cc7387f..99ecba546 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-13.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-13.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: salt.query_fragment() +expression: int64.query_fragment() --- -"'3131313131313131313131313131313131313131313131313131313131313131'" +"8680820740569200760" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-14.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-14.snap index eec7383bf..4cb031a9b 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-14.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-14.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: int4.query_fragment() +expression: int8.query_fragment() --- -"2021161080" +"8680820740569200760" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-15.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-15.snap index 99ecba546..a8aa65623 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-15.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-15.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: int64.query_fragment() +expression: json.query_fragment() --- -"8680820740569200760" +"'{\"hello\":\"world\"}'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-16.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-16.snap index f25d928ec..aa1625461 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-16.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-16.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: int16.query_fragment() +expression: bool.query_fragment() --- -"160132878551029865159235109379655628920" +"true" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-17.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-17.snap index b85fe7cc2..9e48debc2 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-17.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-17.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: uint4.query_fragment() +expression: "r#enum.query_fragment()" --- -"2021161080" +"'hello'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-18.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-18.snap index a568e0424..82218dfdc 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-18.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-18.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: uint1.query_fragment() +expression: uid.query_fragment() --- -"120" +"'0000000000000000000000000000000000000000000000000000000000000000'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-19.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-19.snap index 5eef3ec48..a568e0424 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-19.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-19.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: uint8.query_fragment() +expression: uint1.query_fragment() --- -"8680820740569200760" +"120" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-2.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-2.snap index f2261536c..7e0273c75 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-2.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-2.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: addr.query_fragment() +expression: array.query_fragment() --- -"'1212121212121212121212121212121212121212121212121212121212121212'" +"ARRAY [1]" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-21.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-21.snap index 99ecba546..b85fe7cc2 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-21.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-21.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: int64.query_fragment() +expression: uint4.query_fragment() --- -"8680820740569200760" +"2021161080" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-22.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-22.snap index 5720c79ec..5eef3ec48 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-22.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-22.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: block_height.query_fragment() +expression: uint8.query_fragment() --- -"00000078" +"8680820740569200760" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-23.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-23.snap index fd3b3daff..96ab48b80 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-23.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-23.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: timestamp.query_fragment() +expression: xstring.query_fragment() --- -"8680820740569200760" +"'hello world'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-4.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-4.snap index 63a324d47..547c7c573 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-4.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-4.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: bytes4.query_fragment() +expression: bytes.query_fragment() --- -"'f0f0f0f0'" +"'000102030405'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-5.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-5.snap index 9c743d80a..663eb4a12 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-5.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-5.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: bytes8.query_fragment() +expression: bytes32.query_fragment() --- -"'9d9d9d9d9d9d9d9d'" +"'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-6.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-6.snap index 663eb4a12..63a324d47 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-6.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-6.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: bytes32.query_fragment() +expression: bytes4.query_fragment() --- -"'eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'" +"'f0f0f0f0'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-7.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-7.snap index 8db0c6511..177fe61b9 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-7.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-7.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: nonce.query_fragment() +expression: bytes64.query_fragment() --- -"'1212121212121212121212121212121212121212121212121212121212121212'" +"'12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-8.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-8.snap index 177fe61b9..9c743d80a 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-8.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-8.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: bytes64.query_fragment() +expression: bytes8.query_fragment() --- -"'12121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212121212'" +"'9d9d9d9d9d9d9d9d'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-9.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-9.snap index 144ba0424..e372c02fc 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-9.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types-9.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: txid.query_fragment() +expression: contractid.query_fragment() --- -"'1212121212121212121212121212121212121212121212121212121212121212'" +"'7878787878787878787878787878787878787878787878787878787878787878'" diff --git a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types.snap b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types.snap index 03e0d54e4..f2261536c 100644 --- a/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types.snap +++ b/packages/fuel-indexer-schema/src/snapshots/fuel_indexer_schema__tests__fragments_some_types.snap @@ -1,6 +1,6 @@ --- source: packages/fuel-indexer-schema/src/lib.rs -expression: id.query_fragment() +expression: addr.query_fragment() --- -"'0000000000000000000000000000000000000000000000000000000000000000'" +"'1212121212121212121212121212121212121212121212121212121212121212'" diff --git a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/schema/fuel_indexer_test.graphql b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/schema/fuel_indexer_test.graphql index 5e1c622f0..eb7c16554 100644 --- a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/schema/fuel_indexer_test.graphql +++ b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/schema/fuel_indexer_test.graphql @@ -1,38 +1,38 @@ type PingEntity @entity { id: ID! - value: UInt8! - message: Charfield! + value: U64! + message: String! } type PungEntity @entity { id: ID! - value: UInt8! + value: U64! is_pung: Boolean! pung_from: Identity! } type U16Entity @entity { id: ID! - value1: UInt16! - value2: Int16! + value1: U128! + value2: I128! } type PongEntity @entity { id: ID! - value: UInt8! + value: U64! } type BlockEntity @entity { id: ID! - height: UInt4! - timestamp: Int8! + height: U32! + timestamp: I64! } type TxEntity @entity { id: ID! block: BlockEntity! input_data: Json! - timestamp: Int8! + timestamp: I64! } type TransferEntity @entity { @@ -40,7 +40,7 @@ type TransferEntity @entity { contract_id: ContractId! # 'to' is a reserved SQL word, so using 'recipient' recipient: ContractId! - amount: UInt8! + amount: U64! asset_id: AssetId! } @@ -48,52 +48,52 @@ type TransferOutEntity @entity { id: ID! contract_id: ContractId! recipient: Address! - amount: UInt8! + amount: U64! asset_id: AssetId! } type LogEntity @entity { id: ID! contract_id: ContractId! - ra: UInt8! - rb: UInt8! + ra: U64! + rb: U64! } type ScriptResultEntity @entity { id: ID! - result: UInt8! - gas_used: UInt8! - blob: Blob! + result: U64! + gas_used: U64! + blob: Bytes! } type MessageOutEntity @entity { id: ID! - message_id: MessageId! + message_id: Bytes32! sender: Address! recipient: Address! - amount: UInt8! - nonce: Nonce! - len: UInt8! + amount: U64! + nonce: Bytes32! + len: U64! digest: Bytes32! } type OptionEntity @entity { id: ID! - int_required: UInt8! - int_optional_some: UInt8 + int_required: U64! + int_optional_some: U64 addr_optional_none: Address } type TupleEntity @entity { id: ID! - complex_a: Charfield! - complex_b: UInt8! - simple_a: Charfield! + complex_a: String! + complex_b: U64! + simple_a: String! } type MessageEntity @entity { id: ID! - message: Charfield! + message: String! } type CallEntity @entity { @@ -101,91 +101,91 @@ type CallEntity @entity { contract_id: ContractId! callee: ContractId! asset_id: AssetId! - gas: UInt8! - fn_name: Charfield! - amount: UInt8! + gas: U64! + fn_name: String! + amount: U64! } type PanicEntity @entity { id: ID! contract_id: ContractId! - reason: UInt4! + reason: U32! } type RevertEntity @entity { id: ID! contract_id: ContractId! - error_val: UInt8! + error_val: U64! } type MintEntity @entity { id: ID! sub_id: AssetId! contract_id: ContractId! - val: UInt8! + val: U64! } type BurnEntity @entity { id: ID! sub_id: AssetId! contract_id: ContractId! - val: UInt8! + val: U64! } type Genre @entity { id: ID! - name: Charfield! + name: String! } type Person @entity { id: ID! - name: Charfield! + name: String! } type Planet @entity { id: ID! - name: Charfield! + name: String! } type Continent @entity { id: ID! - name: Charfield! + name: String! planet: Planet! } type Country @entity { id: ID! - name: Charfield! + name: String! continent: Continent! } type Region @entity { id: ID! - name: Charfield! + name: String! country: Country! } type City @entity { id: ID! - name: Charfield! + name: String! region: Region! } type Author @entity { id: ID! - name: Charfield! + name: String! genre: Genre! } type Library @entity { id: ID! - name: Charfield! + name: String! city: City! } type Book @entity { id: ID! - name: Charfield! + name: String! author: Author! @indexed library: Library! genre: Genre! @@ -193,8 +193,8 @@ type Book @entity { type Sponsor @entity { id: ID! - name: Charfield! @unique - amount: UInt8! + name: String! @unique + amount: U64! representative: Person! } @@ -208,42 +208,42 @@ type BookClub @entity { type Municipality @entity { id: ID! - name: Charfield! @unique + name: String! @unique } type SportsTeam @entity { id: ID! - name: Charfield! + name: String! municipality: Municipality! @join(on: name) } type InnerFilterEntity @entity { id: ID! - inner_foo: Charfield! - inner_bar: UInt8! - inner_baz: UInt8! + inner_foo: String! + inner_bar: U64! + inner_baz: U64! } type FilterEntity @entity { id: ID! - foola: Charfield! - maybe_null_bar: UInt8 - bazoo: UInt8! + foola: String! + maybe_null_bar: U64 + bazoo: U64! inner_entity: InnerFilterEntity! } type EnumError @entity { id: ID! contract_id: ContractId! - error_val: UInt8! + error_val: U64! } type ExplorerEntity @entity { id: ID! - nonce: Nonce! - time: Tai64Timestamp - hex: HexString - sig: Signature! + nonce: Bytes32! + time: U64 + hex: Bytes + sig: Bytes64! bytes: Bytes64! } @@ -259,13 +259,13 @@ type ComplexEnumEntity @entity { } type VirtualEntity @entity(virtual: true) { - name: Charfield - size: UInt1! + name: String + size: U8! } type UsesVirtualEntity @entity { id: ID! - name: Charfield! + name: String! no_table: VirtualEntity! } @@ -277,34 +277,34 @@ enum UnionType { type IndexableUnionA @entity { id: ID! - a: UInt8! + a: U64! union_type: UnionType! } type IndexableUnionB @entity { id: ID! - b: UInt8! + b: U64! union_type: UnionType! } type IndexableUnionC @entity { id: ID! - c: UInt8! + c: U64! union_type: UnionType! } type VirtualUnionA @entity(virtual: true) { - a: UInt8! + a: U64! union_type: UnionType! } type VirtualUnionB @entity(virtual: true) { - b: UInt8! + b: U64! union_type: UnionType! } type VirtualUnionC @entity(virtual: true) { - c: UInt8! + c: U64! union_type: UnionType! } @@ -320,16 +320,16 @@ type VirtualUnionContainerEntity @entity { type ListFKType @entity { id: ID! - value: UInt8! + value: U64! } type ListTypeEntity @entity { id: ID! - foo_field: Charfield! + foo_field: String! required_all: [ListFKType!]! - optional_inner: [Charfield]! - optional_outer: [UInt8!] - optional_all: [UInt8] + optional_inner: [String]! + optional_outer: [U64!] + optional_all: [U64] virtual_optional_inner: [VirtualEntity]! enum_required_all: [EnumEntity!]! } diff --git a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs index a86761c60..b3658f8bd 100644 --- a/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs +++ b/packages/fuel-indexer-tests/indexers/fuel-indexer-test/src/lib.rs @@ -120,8 +120,16 @@ mod fuel_indexer_test { .. } = messageout; - MessageOutEntity::new(message_id, sender, recipient, amount, nonce, len, digest) - .get_or_create(); + MessageOutEntity::new( + bytes32(message_id), + sender, + recipient, + amount, + bytes32(nonce), + len, + digest, + ) + .get_or_create(); } fn fuel_indexer_test_callreturn(pungentity: Pung) { @@ -423,11 +431,11 @@ mod fuel_indexer_test { info!("fuel_indexer_block_explorer_types handling explorer_types event."); let e = ExplorerEntity { id: uid(8675309_u32.to_le_bytes()), - nonce: Nonce::default(), + nonce: Bytes32::default(), // TOOD: Finish time: None, - hex: Some(HexString::from("hello world!")), - sig: Signature::default(), + hex: Some(Bytes::from("hello world!")), + sig: Bytes64::default(), bytes: Bytes64::default(), }; diff --git a/packages/fuel-indexer-tests/tests/indexing.rs b/packages/fuel-indexer-tests/tests/indexing.rs index d4fc97910..bd27f3a0d 100644 --- a/packages/fuel-indexer-tests/tests/indexing.rs +++ b/packages/fuel-indexer-tests/tests/indexing.rs @@ -432,7 +432,7 @@ async fn test_index_types_for_block_explorer() { let hexstring = row.get::<&str, usize>(3); let hexstring = hex::decode(hexstring).unwrap(); - assert_eq!(hexstring, HexString::from("hello world!")); + assert_eq!(hexstring, Bytes::from("hello world!")); // Non-indexable types let row = diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs b/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs index 651fe3004..2b426749f 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_abi_contains_reserved_fuel_type.rs @@ -3,8 +3,8 @@ use fuel_indexer_utils::prelude::*; #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml")] mod indexer { - fn function_one(event: BlockHeight) { - let BlockHeight { id, account } = event; + fn function_one(event: Bytes32) { + let Bytes32 { id, account } = event; let t1 = Thing1 { id, account }; t1.save(); diff --git a/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs b/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs index 2e0ccd8f2..f1a9bfb0a 100644 --- a/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs +++ b/packages/fuel-indexer-tests/trybuild/fail_if_ident_not_defined_in_abi.rs @@ -4,7 +4,7 @@ use fuel_indexer_utils::prelude::*; #[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] mod indexer { fn function_one(event: ThisIsNotDefinedInTheABI) { - let BlockHeight { id, account } = event; + let Bytes32 { id, account } = event; let t1 = Thing1 { id, account }; t1.save(); diff --git a/packages/fuel-indexer-types/Cargo.toml b/packages/fuel-indexer-types/Cargo.toml index 48249d3ed..4a4eabe8e 100644 --- a/packages/fuel-indexer-types/Cargo.toml +++ b/packages/fuel-indexer-types/Cargo.toml @@ -10,7 +10,6 @@ rust-version = { workspace = true } description = "Fuel Indexer Types" [dependencies] -bincode = "1.3" bytes = { version = "1.4", features = ["serde"] } fuel-tx = { workspace = true, features = ["serde"] } fuel-types = { workspace = true } @@ -18,4 +17,3 @@ fuels = { workspace = true } serde = { workspace = true } serde_json = { workspace = true } sha2 = "0.9" -tai64 = { version = "4.0", default-features = false, features = ["serde"] } diff --git a/packages/fuel-indexer-types/src/fuel.rs b/packages/fuel-indexer-types/src/fuel.rs index fdb770f41..04f1b173d 100644 --- a/packages/fuel-indexer-types/src/fuel.rs +++ b/packages/fuel-indexer-types/src/fuel.rs @@ -305,8 +305,8 @@ pub struct InputCoin { pub tx_pointer: TxPointer, pub witness_index: u8, pub maturity: BlockHeight, - pub predicate: HexString, - pub predicate_data: HexString, + pub predicate: Bytes, + pub predicate_data: Bytes, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -325,9 +325,9 @@ pub struct InputMessage { pub amount: u64, pub nonce: Nonce, pub witness_index: u8, - pub data: HexString, - pub predicate: HexString, - pub predicate_data: HexString, + pub data: Bytes, + pub predicate: Bytes, + pub predicate_data: Bytes, } #[derive(Clone, Debug, Serialize, Deserialize)] @@ -503,7 +503,7 @@ pub struct Genesis { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct PoA { - pub signature: Signature, + pub signature: Bytes64, } #[derive(Clone, Debug, Default, Serialize, Deserialize)] @@ -524,7 +524,7 @@ pub enum ReturnType { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct ProgramState { pub return_type: ReturnType, - pub data: HexString, + pub data: Bytes, } impl From for Json { diff --git a/packages/fuel-indexer-types/src/graphql.rs b/packages/fuel-indexer-types/src/graphql.rs index d9d8cc47a..86b852ecd 100644 --- a/packages/fuel-indexer-types/src/graphql.rs +++ b/packages/fuel-indexer-types/src/graphql.rs @@ -26,8 +26,8 @@ impl IndexMetadata { type IndexMetadataEntity @entity { id: ID! - time: UInt8! - block_height: UInt4! + time: U64! + block_height: U32! block_id: Bytes32! } "# diff --git a/packages/fuel-indexer-types/src/scalar.rs b/packages/fuel-indexer-types/src/scalar.rs index 684dc0cb4..e540a6939 100644 --- a/packages/fuel-indexer-types/src/scalar.rs +++ b/packages/fuel-indexer-types/src/scalar.rs @@ -1,11 +1,10 @@ -use bytes::Bytes; +use bytes::Bytes as _Bytes; pub use fuel_types::{ Address, AssetId, BlockHeight, Bytes32, Bytes4, Bytes64, Bytes8, ContractId, MessageId, Nonce, Salt, Word, }; use fuels::types::SizedAsciiString; use serde::{Deserialize, Serialize}; -use tai64::Tai64; /// Scalar for 32-byte unique ID payloads. pub type UID = SizedAsciiString<64>; @@ -14,75 +13,34 @@ pub type UID = SizedAsciiString<64>; pub type ID = UID; /// Scalar for 4-byte signed integers. -pub type Int4 = i32; +pub type I32 = i32; /// Scalar for 8-byte signed integers. -pub type Int8 = i64; +pub type I64 = i64; /// Scalar for 16-byte signed integers. -pub type Int16 = i128; +pub type I128 = i128; /// Scalar for 4-byte unsigned integers. -pub type UInt4 = u32; +pub type U32 = u32; /// Scalar for 8-byte unsigned integers. -pub type UInt8 = u64; +pub type U64 = u64; /// Scalar for 16-byte unsigned integers. -pub type UInt16 = u128; - -/// Scalar for 8-byte integers aliased as `Timestamp`s. -pub type Timestamp = u64; - -/// Scalar for arbitrarily sized `String`s aliased as `Charfield`s. -pub type Charfield = String; +pub type U128 = u128; /// Scalar for boolean. pub type Boolean = bool; -/// Scalar for 64-byte signature payloads. -pub type Signature = Bytes64; - -/// Scalar for arbitrarily sized byte payloads aliased as `HexString`. -pub type HexString = Bytes; - -/// Scalar for `Tai64` timestamps aliased as `Tai64Timestamp`. -pub type Tai64Timestamp = Tai64; - -/// Scalar for 32-byte payloads aliased as `BlockId`. -pub type BlockId = Bytes32; - /// Scalar for 1-byte signed integers. -pub type Int1 = i8; +pub type I8 = i8; /// Scalar for 1-byte unsigned integers. -pub type UInt1 = u8; - -/// Blob type used to store arbitrarily sized UTF-8 payloads. -#[derive(Deserialize, Serialize, Clone, Eq, PartialEq, Debug, Hash, Default)] -pub struct Blob(pub Vec); - -impl From> for Blob { - fn from(value: Vec) -> Self { - Blob(value) - } -} - -impl AsRef<[u8]> for Blob { - fn as_ref(&self) -> &[u8] { - &self.0 - } -} - -impl From for Vec { - fn from(value: Blob) -> Self { - value.0 - } -} +pub type U8 = u8; -/// JSON type used to store types tagged with a `@virtual` directive in -/// GraphQL schema. Aliased as `Virtual`. -pub type Virtual = Json; +/// Scalar for arbitrarily-sized byte payloads. +pub type Bytes = _Bytes; /// JSON type used to store arbitrary object payloads. #[derive(Deserialize, Serialize, Clone, Eq, PartialEq, Debug, Hash)] @@ -99,30 +57,3 @@ impl AsRef<[u8]> for Json { self.0.as_bytes() } } - -macro_rules! json_impl { - ($($ty:ty),*) => { - $( - impl From<$ty> for Json { - fn from(value: $ty) -> Self { - Json(value.to_string()) - } - } - )* - } -} - -macro_rules! blob_impl { - ($($ty:ty),*) => { - $( - impl From<$ty> for Blob { - fn from(value: $ty) -> Self { - Blob::from(bincode::serialize(&value).unwrap().to_vec()) - } - } - )* - } -} - -json_impl!(i32, i64, i128, u32, u64, u128); -blob_impl!(i32, i64, i128, u32, u64, u128); diff --git a/packages/fuel-indexer-utils/src/utilities.rs b/packages/fuel-indexer-utils/src/utilities.rs index 0ac393087..7159879c5 100644 --- a/packages/fuel-indexer-utils/src/utilities.rs +++ b/packages/fuel-indexer-utils/src/utilities.rs @@ -9,11 +9,11 @@ pub fn uid(data: impl AsRef<[u8]>) -> UID { UID::new(sha256_digest(&data)).expect("Failed to create UID.") } -/// Converts a given input into a `Bytes32` object by taking the first 32 bytes -/// of the input's SHA256 hex digest. +/// Converts a given input into a `Bytes32` object by taking the first 32 bytes of the input. pub fn bytes32(data: impl AsRef<[u8]>) -> Bytes32 { - let digest = sha256_digest(&data); let mut result = [0u8; 32]; - result.copy_from_slice(&digest.as_bytes()[0..32]); + let data = data.as_ref(); + let len = data.len().min(32); // take the minimum of the data length and 32 + result[..len].copy_from_slice(&data[..len]); // copy only up to len bytes Bytes32::from(result) } diff --git a/packages/fuel-indexer/src/executor.rs b/packages/fuel-indexer/src/executor.rs index 031a23ee6..70a64f01d 100644 --- a/packages/fuel-indexer/src/executor.rs +++ b/packages/fuel-indexer/src/executor.rs @@ -17,7 +17,7 @@ use fuel_indexer_lib::{ }; use fuel_indexer_types::{ fuel::{field::*, *}, - scalar::{Bytes32, HexString}, + scalar::{Bytes, Bytes32}, }; use fuel_tx::UniqueIdentifier; use fuel_vm::prelude::Deserializable; @@ -368,15 +368,15 @@ pub async fn retrieve_blocks_from_node( let program_state = program_state.map(|p| match p { ClientProgramState::Return(w) => ProgramState { return_type: ReturnType::Return, - data: HexString::from(w.to_le_bytes().to_vec()), + data: Bytes::from(w.to_le_bytes().to_vec()), }, ClientProgramState::ReturnData(d) => ProgramState { return_type: ReturnType::ReturnData, - data: HexString::from(d.to_vec()), + data: Bytes::from(d.to_vec()), }, ClientProgramState::Revert(w) => ProgramState { return_type: ReturnType::Revert, - data: HexString::from(w.to_le_bytes().to_vec()), + data: Bytes::from(w.to_le_bytes().to_vec()), }, // Either `cargo watch` complains that this is unreachable, or `clippy` complains // that all patterns are not matched. These other program states are only used in @@ -399,15 +399,15 @@ pub async fn retrieve_blocks_from_node( let program_state = program_state.map(|p| match p { ClientProgramState::Return(w) => ProgramState { return_type: ReturnType::Return, - data: HexString::from(w.to_le_bytes().to_vec()), + data: Bytes::from(w.to_le_bytes().to_vec()), }, ClientProgramState::ReturnData(d) => ProgramState { return_type: ReturnType::ReturnData, - data: HexString::from(d.to_vec()), + data: Bytes::from(d.to_vec()), }, ClientProgramState::Revert(w) => ProgramState { return_type: ReturnType::Revert, - data: HexString::from(w.to_le_bytes().to_vec()), + data: Bytes::from(w.to_le_bytes().to_vec()), }, // Either `cargo watch` complains that this is unreachable, or `clippy` complains // that all patterns are not matched. These other program states are only used in diff --git a/plugins/forc-index/src/defaults.rs b/plugins/forc-index/src/defaults.rs index 82929f878..62db4fb63 100644 --- a/plugins/forc-index/src/defaults.rs +++ b/plugins/forc-index/src/defaults.rs @@ -211,7 +211,7 @@ pub mod {indexer_name}_index_mod {{ pub fn default_indexer_schema() -> String { r#"type Block @entity { id: ID! - height: UInt8! + height: U64! hash: Bytes32! @unique } From 7eea71f57cb12889a7c7f1450a1f981fa3146a3f Mon Sep 17 00:00:00 2001 From: rashad Date: Fri, 29 Sep 2023 11:43:25 -0400 Subject: [PATCH 4/5] chore: add sway app abi tests (#1341) * chore: add sway app abi tests * fix test typos --------- Co-authored-by: Rashad Alston --- packages/fuel-indexer-lib/src/constants.rs | 4 + packages/fuel-indexer-macros/src/helpers.rs | 7 + packages/fuel-indexer-macros/src/indexer.rs | 15 + packages/fuel-indexer-macros/src/native.rs | 10 +- packages/fuel-indexer-macros/src/wasm.rs | 2 - .../scripts/copy-swap-app-abi.bash | 60 + packages/fuel-indexer-tests/tests/trybuild.rs | 130 +- .../trybuild/abi/AMM-contract-abi.json | 262 +++ .../trybuild/abi/DAO-contract-abi.json | 945 +++++++++++ .../fuel-indexer-tests/trybuild/abi/README.md | 5 + .../trybuild/abi/asset-contract-abi.json | 200 +++ .../trybuild/abi/auction-contract-abi.json | 954 +++++++++++ .../abi}/contracts-abi-reserved-name.json | 0 .../abi/distributor-contract-abi.json | 676 ++++++++ .../trybuild/abi/escrow-contract-abi.json | 1476 +++++++++++++++++ .../trybuild/abi/exchange-contract-abi.json | 1135 +++++++++++++ .../trybuild/abi/multisig-contract-abi.json | 1182 +++++++++++++ .../trybuild/abi/oracle-contract-abi.json | 200 +++ .../trybuild/abi/registry-contract-abi.json | 756 +++++++++ .../trybuild/abi/swap-predicate-abi.json | 144 ++ .../trybuild/abi/timelock-contract-abi.json | 701 ++++++++ .../invalid_abi_type_simple_wasm.yaml | 14 +- .../pass_if_indexer_is_valid_multi_type.rs | 2 +- .../pass_if_indexer_is_valid_single_type.rs | 2 +- .../pass_if_unsupported_types_are_used.rs | 78 +- .../pass_if_using_swap_predicate_abi.rs | 24 + .../trybuild/pass_if_using_sway_amm_abi.rs | 24 + .../pass_if_using_sway_asset_contract_abi.rs | 24 + .../trybuild/pass_if_using_sway_dao_abi.rs | 24 + ..._if_using_sway_distributor_contract_abi.rs | 24 + .../pass_if_using_sway_escrow_contract_abi.rs | 24 + ...ass_if_using_sway_multisig_contract_abi.rs | 24 + .../pass_if_using_sway_oracle_contract_abi.rs | 24 + ...ass_if_using_sway_registry_contract_abi.rs | 24 + .../pass_if_using_timelock_contract_abi.rs | 24 + ...ass_is_using_sway_exchange_contract_abi.rs | 24 + packages/fuel-indexer-types/src/lib.rs | 2 +- packages/fuel-indexer-types/src/scalar.rs | 3 + 38 files changed, 9115 insertions(+), 114 deletions(-) create mode 100644 packages/fuel-indexer-tests/scripts/copy-swap-app-abi.bash create mode 100644 packages/fuel-indexer-tests/trybuild/abi/AMM-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/DAO-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/README.md create mode 100644 packages/fuel-indexer-tests/trybuild/abi/asset-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/auction-contract-abi.json rename packages/fuel-indexer-tests/{contracts/simple-wasm/out/debug => trybuild/abi}/contracts-abi-reserved-name.json (100%) create mode 100644 packages/fuel-indexer-tests/trybuild/abi/distributor-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/escrow-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/exchange-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/multisig-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/oracle-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/registry-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/swap-predicate-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/abi/timelock-contract-abi.json create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_swap_predicate_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_amm_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_asset_contract_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_dao_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_distributor_contract_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_escrow_contract_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_multisig_contract_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_oracle_contract_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_sway_registry_contract_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_if_using_timelock_contract_abi.rs create mode 100644 packages/fuel-indexer-tests/trybuild/pass_is_using_sway_exchange_contract_abi.rs diff --git a/packages/fuel-indexer-lib/src/constants.rs b/packages/fuel-indexer-lib/src/constants.rs index 1cff8f521..7f7cfff0f 100644 --- a/packages/fuel-indexer-lib/src/constants.rs +++ b/packages/fuel-indexer-lib/src/constants.rs @@ -182,8 +182,12 @@ lazy_static! { /// Generic Sway ABI types. pub static ref IGNORED_GENERIC_METADATA: HashSet<&'static str> = HashSet::from([ "generic T", + "generic E", "raw untyped ptr", "struct RawVec", + "struct RawBytes", + "struct Bytes", + "enum Result" ]); pub static ref GENERIC_STRUCTS: HashSet<&'static str> = HashSet::from([ diff --git a/packages/fuel-indexer-macros/src/helpers.rs b/packages/fuel-indexer-macros/src/helpers.rs index 72734a404..cf0f502b5 100644 --- a/packages/fuel-indexer-macros/src/helpers.rs +++ b/packages/fuel-indexer-macros/src/helpers.rs @@ -95,6 +95,7 @@ pub fn is_non_decodable_type(typ: &TypeDeclaration) -> bool { is_tuple_type(typ) || is_unit_type(typ) || IGNORED_GENERIC_METADATA.contains(typ.type_field.as_str()) + || is_array_type(typ) } /// Derive Ident for decoded type @@ -1116,6 +1117,12 @@ pub fn typed_path_components( (name, tokens) } +fn is_array_type(typ: &TypeDeclaration) -> bool { + typ.type_field.starts_with('[') + && typ.type_field.ends_with(']') + && typ.type_field.contains(';') +} + /// Determine whether or not the given type name is an unsupported type. /// /// Since we allow unsupported types in the ABI JSON, this check is only diff --git a/packages/fuel-indexer-macros/src/indexer.rs b/packages/fuel-indexer-macros/src/indexer.rs index ba476c985..18b60bd25 100644 --- a/packages/fuel-indexer-macros/src/indexer.rs +++ b/packages/fuel-indexer-macros/src/indexer.rs @@ -19,6 +19,15 @@ use std::collections::{HashMap, HashSet}; use std::path::{Path, PathBuf}; use syn::{parse_macro_input, FnArg, Item, ItemMod, PatType, Type}; +fn additional_declarations() -> proc_macro2::TokenStream { + quote! { + // Miscellaneous types that can be included in ABI JSON + type b256 = [u8; 32]; + type Bytes = Vec; + type B512 = [u8; 64]; + } +} + fn process_fn_items( manifest: &Manifest, abi_path: Option, @@ -930,6 +939,8 @@ pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStr manifest.execution_source(), ); + let decl_tokens = additional_declarations(); + let output = match manifest.execution_source() { ExecutionSource::Native => { let (handler_block, fn_items) = @@ -939,6 +950,8 @@ pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStr quote! { + #decl_tokens + #abi_tokens #graphql_tokens @@ -956,6 +969,8 @@ pub fn process_indexer_module(attrs: TokenStream, item: TokenStream) -> TokenStr let handler_block = handler_block_wasm(handler_block); quote! { + #decl_tokens + #abi_tokens #graphql_tokens diff --git a/packages/fuel-indexer-macros/src/native.rs b/packages/fuel-indexer-macros/src/native.rs index 544dd066c..463df0b92 100644 --- a/packages/fuel-indexer-macros/src/native.rs +++ b/packages/fuel-indexer-macros/src/native.rs @@ -33,8 +33,6 @@ pub fn handler_block_native( /// indexer module, not within the scope of the entire lib module. fn native_prelude() -> proc_macro2::TokenStream { quote! { - type B256 = [u8; 32]; - static mut db: Option>> = None; use fuel_indexer_utils::plugin::types::*; @@ -60,10 +58,10 @@ pub fn native_main() -> proc_macro2::TokenStream { let config = args - .config - .as_ref() - .map(IndexerConfig::from_file) - .unwrap_or(Ok(IndexerConfig::from(args)))?; + .config + .as_ref() + .map(IndexerConfig::from_file) + .unwrap_or(Ok(IndexerConfig::from(args)))?; init_logging(&config).await?; diff --git a/packages/fuel-indexer-macros/src/wasm.rs b/packages/fuel-indexer-macros/src/wasm.rs index 95838c13b..04494a2e6 100644 --- a/packages/fuel-indexer-macros/src/wasm.rs +++ b/packages/fuel-indexer-macros/src/wasm.rs @@ -39,8 +39,6 @@ fn wasm_prelude() -> proc_macro2::TokenStream { use alloc::{format, vec, vec::Vec}; use std::str::FromStr; - type B256 = [u8; 32]; - use fuel_indexer_utils::plugin::types::*; use fuel_indexer_utils::plugin::wasm::*; use fuel_indexer_utils::plugin::{serde_json, serialize, deserialize, bincode}; diff --git a/packages/fuel-indexer-tests/scripts/copy-swap-app-abi.bash b/packages/fuel-indexer-tests/scripts/copy-swap-app-abi.bash new file mode 100644 index 000000000..92a4ee526 --- /dev/null +++ b/packages/fuel-indexer-tests/scripts/copy-swap-app-abi.bash @@ -0,0 +1,60 @@ +#!/bin/bash + +# This script copies the JSON ABI for each Sway application into the indexer's +# trybuild tests. +# +# This helps ensure that the indexers can be built with Sway projects that more +# closely resemble "real-world" contracts, as oppposed to just indexer test +# contracts. +# +# This script should be run from the repository root, and might have to be updated +# to account for the addition/removal of Sway applications. + +usage() { + echo "Usage: $0 [options] " + echo "Options:" + echo " -h, --help Show this help message and exit." + echo + echo "Arguments:" + echo " The root path of the sway-application repository." + echo +} + +swayapps_root=$1 + +if [[ "$1" == "-h" || "$1" == "--help" ]]; then + usage + exit 0 +fi + +if [[ -z "$1" || ! -d "$1" ]]; then + echo "Error: Invalid or missing directory root path." + usage + exit 1 +fi + +testdir=$(realpath $(dirname $(dirname $0))) +abidir=$testdir/trybuild/abi +echo $abidir + +paths=( + "AMM/project/contracts/AMM-contract" + "AMM/project/contracts/exchange-contract" + "DAO/project/contracts/DAO-contract" + "OTC-swap-predicate/project/predicates/swap-predicate" + "airdrop/project/contracts/asset-contract" + "airdrop/project/contracts/distributor-contract" + "multisig-wallet/project/contracts/multisig-contract" + "escrow/project/contracts/escrow-contract" + "timelock/project/contracts/timelock-contract" + "auctions/english-auction/project/contracts/auction-contract" + "name-registry/project/contracts/registry-contract" + "oracle/project/contracts/oracle-contract" +) + +for path in "${paths[@]}"; do + cd $swayapps_root/$path + forc build + cp -fv $path/out/debug/*-abi.json $abidir/ +done + diff --git a/packages/fuel-indexer-tests/tests/trybuild.rs b/packages/fuel-indexer-tests/tests/trybuild.rs index 486f7175d..b4de3484b 100644 --- a/packages/fuel-indexer-tests/tests/trybuild.rs +++ b/packages/fuel-indexer-tests/tests/trybuild.rs @@ -8,8 +8,7 @@ enum TestKind { Fail, } -#[test] -fn test_success_and_failure_macros() { +fn test_dirs() -> (String, String, String, String) { let t = trybuild::TestCases::new(); let manifest_dir = env!("CARGO_MANIFEST_DIR"); std::env::set_var("COMPILE_TEST_PREFIX", manifest_dir); @@ -21,7 +20,35 @@ fn test_success_and_failure_macros() { let tests_root = project_root.join("packages").join("fuel-indexer-tests"); let tests_root_str = tests_root.to_str().unwrap(); let trybuild_root = tests_root.join("trybuild"); + let abi_root = trybuild_root.join("abi"); + let abi_root_str = abi_root.to_str().unwrap(); + + ( + abi_root_str.to_string(), + tests_root_str.to_string(), + project_root_str.to_string(), + trybuild_root.to_string_lossy().to_string(), + ) +} + +fn manifest_with_contract_abi(contract_name: &str) -> String { + let (abi_root_str, tests_root_str, project_root_str, _) = test_dirs(); + format!( + r#" +namespace: test_namespace +identifier: simple_wasm_executor +abi: {abi_root_str}/{contract_name} +graphql_schema: {tests_root_str}/indexers/simple-wasm/schema/simple_wasm.graphql +contract_id: ~ +module: + wasm: {project_root_str}/target/wasm32-unknown-unknown/release/simple_wasm.wasm"# + ) +} +#[test] +fn test_success_and_failure_macros() { + let t = trybuild::TestCases::new(); + let (abi_root_str, tests_root_str, project_root_str, trybuild_root) = test_dirs(); let manifest_content = format!( r#" namespace: test_namespace @@ -34,12 +61,16 @@ module: "# ); + // IMPORTANT: Even though in theory we should be able to just re-use the same filename + // since we're writing and reading to each file for each test individually, in practice, + // these tests will error out if we use the same filename for each test. + // + // So, we simply change the manifest name according to each test to avoid these flaky errors. let tests = vec![ ( "fail_if_attribute_manifest_schema_arg_is_invalid.rs", "invalid_schema_simple_wasm.yaml", TestKind::Fail, - // Using a custom manifest here format!( r#" namespace: test_namespace @@ -84,38 +115,27 @@ module: ), ( "pass_if_indexer_is_valid_single_type.rs", - "simple_wasm.yaml", + "simple_wasm_single.yaml", TestKind::Pass, manifest_content.clone(), ), ( "pass_if_indexer_is_valid_multi_type.rs", - "simple_wasm.yaml", + "simple_wasm_multi.yaml", TestKind::Pass, manifest_content.clone(), ), ( "pass_if_unsupported_types_are_used.rs", - "simple_wasm.yaml", + "simple_wasm_unsupported.yaml", TestKind::Pass, - // Using a custom manifest here manifest_content.clone(), ), ( "fail_if_abi_contains_reserved_fuel_type.rs", "invalid_abi_type_simple_wasm.yaml", TestKind::Fail, - // Using a custom manifest here - format!( - r#" - namespace: test_namespace - identifier: simple_wasm_executor - abi: {tests_root_str}/contracts/simple-wasm/out/debug/contracts-abi-reserved-name.json - graphql_schema: {tests_root_str}/indexers/simple-wasm/schema/simple_wasm.graphql - contract_id: ~ - module: - wasm: {project_root_str}/target/wasm32-unknown-unknown/release/simple_wasm.wasm"# - ), + manifest_with_contract_abi("contracts-abi-reserved-name.json"), ), ( "fail_if_ident_not_defined_in_abi.rs", @@ -135,19 +155,87 @@ module: TestKind::Fail, manifest_content.clone(), ), + ( + "pass_if_using_sway_amm_abi.rs", + "sway_amm.yaml", + TestKind::Pass, + manifest_with_contract_abi("AMM-contract-abi.json"), + ), + ( + "pass_if_using_sway_dao_abi.rs", + "sway_dao.yaml", + TestKind::Pass, + manifest_with_contract_abi("DAO-contract-abi.json"), + ), + ( + "pass_if_using_sway_asset_contract_abi.rs", + "asset_contract.yaml", + TestKind::Pass, + manifest_with_contract_abi("asset-contract-abi.json"), + ), + ( + "pass_if_using_sway_distributor_contract_abi.rs", + "distributor_contract.yaml", + TestKind::Pass, + manifest_with_contract_abi("distributor-contract-abi.json"), + ), + ( + "pass_if_using_sway_escrow_contract_abi.rs", + "escrow_contract.yaml", + TestKind::Pass, + manifest_with_contract_abi("escrow-contract-abi.json"), + ), + ( + "pass_is_using_sway_exchange_contract_abi.rs", + "exchange_contract.yaml", + TestKind::Pass, + manifest_with_contract_abi("exchange-contract-abi.json"), + ), + // NOTE: I don't think the ABI tokens are being properly generated from this contract JSON + // ( + // "pass_if_using_sway_multisig_contract_abi.rs", + // "multisig_contract.yaml", + // TestKind::Pass, + // manifest_with_contract_abi("multisig-contract-abi.json"), + // ), + ( + "pass_if_using_sway_oracle_contract_abi.rs", + "oracle_contract.yaml", + TestKind::Pass, + manifest_with_contract_abi("oracle-contract-abi.json"), + ), + ( + "pass_if_using_sway_registry_contract_abi.rs", + "registry_contract.yaml", + TestKind::Pass, + manifest_with_contract_abi("registry-contract-abi.json"), + ), + ( + "pass_if_using_swap_predicate_abi.rs", + "predicate_abi.yaml", + TestKind::Pass, + manifest_with_contract_abi("swap-predicate-abi.json"), + ), + ( + "pass_if_using_timelock_contract_abi.rs", + "timelock_contract.yaml", + TestKind::Pass, + manifest_with_contract_abi("timelock-contract-abi.json"), + ), ]; for (name, manifest_name, kind, manifest_content) in tests { - let manifest_path = trybuild_root.join(manifest_name); + let trybuild = Path::new(&trybuild_root); + let manifest_path = trybuild.join(manifest_name); let mut f = std::fs::File::create(&manifest_path).unwrap(); f.write_all(manifest_content.as_bytes()).unwrap(); match kind { TestKind::Pass => { - t.pass(trybuild_root.join(&name)); + t.pass(trybuild.join(&name)); } TestKind::Fail => { - t.compile_fail(trybuild_root.join(&name)); + t.compile_fail(trybuild.join(&name)); } } } diff --git a/packages/fuel-indexer-tests/trybuild/abi/AMM-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/AMM-contract-abi.json new file mode 100644 index 000000000..fa34098e7 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/AMM-contract-abi.json @@ -0,0 +1,262 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "(_, _)", + "components": [ + { + "name": "__tuple_element", + "type": 6, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 6, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 2, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum InitError", + "components": [ + { + "name": "BytecodeRootAlreadySet", + "type": 0, + "typeArguments": null + }, + { + "name": "BytecodeRootDoesNotMatch", + "type": 0, + "typeArguments": null + }, + { + "name": "BytecodeRootNotSet", + "type": 0, + "typeArguments": null + }, + { + "name": "PairDoesNotDefinePool", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": [ + 5 + ] + }, + { + "typeId": 5, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 6, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "struct RegisterPoolEvent", + "components": [ + { + "name": "asset_pair", + "type": 1, + "typeArguments": null + }, + { + "name": "pool", + "type": 6, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 8, + "type": "struct SetExchangeBytecodeRootEvent", + "components": [ + { + "name": "root", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "asset_pair", + "type": 1, + "typeArguments": null + }, + { + "name": "pool", + "type": 6, + "typeArguments": null + } + ], + "name": "add_pool", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "exchange_bytecode_root", + "type": 6, + "typeArguments": null + } + ], + "name": "initialize", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "asset_pair", + "type": 1, + "typeArguments": null + } + ], + "name": "pool", + "output": { + "name": "", + "type": 4, + "typeArguments": [ + { + "name": "", + "type": 6, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/DAO-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/DAO-contract-abi.json new file mode 100644 index 000000000..6daa57505 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/DAO-contract-abi.json @@ -0,0 +1,945 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum CreationError", + "components": [ + { + "name": "DurationCannotBeZero", + "type": 0, + "typeArguments": null + }, + { + "name": "InvalidAcceptancePercentage", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 8, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 10, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum InitializationError", + "components": [ + { + "name": "CannotReinitialize", + "type": 0, + "typeArguments": null + }, + { + "name": "ContractNotInitialized", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "enum ProposalError", + "components": [ + { + "name": "InsufficientApprovals", + "type": 0, + "typeArguments": null + }, + { + "name": "ProposalExecuted", + "type": 0, + "typeArguments": null + }, + { + "name": "ProposalExpired", + "type": 0, + "typeArguments": null + }, + { + "name": "ProposalStillActive", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "enum UserError", + "components": [ + { + "name": "AmountCannotBeZero", + "type": 0, + "typeArguments": null + }, + { + "name": "IncorrectAssetSent", + "type": 0, + "typeArguments": null + }, + { + "name": "InsufficientBalance", + "type": 0, + "typeArguments": null + }, + { + "name": "InvalidId", + "type": 0, + "typeArguments": null + }, + { + "name": "VoteAmountCannotBeZero", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 8, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "struct CallData", + "components": [ + { + "name": "arguments", + "type": 21, + "typeArguments": null + }, + { + "name": "function_selector", + "type": 21, + "typeArguments": null + }, + { + "name": "id", + "type": 10, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 10, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "struct CreateProposalEvent", + "components": [ + { + "name": "id", + "type": 21, + "typeArguments": null + }, + { + "name": "proposal_info", + "type": 16, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 12, + "type": "struct DepositEvent", + "components": [ + { + "name": "amount", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "struct ExecuteEvent", + "components": [ + { + "name": "acceptance_percentage", + "type": 21, + "typeArguments": null + }, + { + "name": "id", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 14, + "type": "struct InitializeEvent", + "components": [ + { + "name": "author", + "type": 4, + "typeArguments": null + }, + { + "name": "token", + "type": 10, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 15, + "type": "struct Proposal", + "components": [ + { + "name": "amount", + "type": 21, + "typeArguments": null + }, + { + "name": "asset", + "type": 10, + "typeArguments": null + }, + { + "name": "call_data", + "type": 9, + "typeArguments": null + }, + { + "name": "gas", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct ProposalInfo", + "components": [ + { + "name": "acceptance_percentage", + "type": 21, + "typeArguments": null + }, + { + "name": "author", + "type": 4, + "typeArguments": null + }, + { + "name": "deadline", + "type": 21, + "typeArguments": null + }, + { + "name": "executed", + "type": 2, + "typeArguments": null + }, + { + "name": "no_votes", + "type": 21, + "typeArguments": null + }, + { + "name": "proposal_transaction", + "type": 15, + "typeArguments": null + }, + { + "name": "yes_votes", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct UnlockVotesEvent", + "components": [ + { + "name": "id", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 4, + "typeArguments": null + }, + { + "name": "vote_amount", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "struct VoteEvent", + "components": [ + { + "name": "id", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 4, + "typeArguments": null + }, + { + "name": "vote_amount", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 19, + "type": "struct Votes", + "components": [ + { + "name": "no_votes", + "type": 21, + "typeArguments": null + }, + { + "name": "yes_votes", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 20, + "type": "struct WithdrawEvent", + "components": [ + { + "name": "amount", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 21, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "token", + "type": 10, + "typeArguments": null + } + ], + "name": "constructor", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "acceptance_percentage", + "type": 21, + "typeArguments": null + }, + { + "name": "duration", + "type": 21, + "typeArguments": null + }, + { + "name": "proposal_transaction", + "type": 15, + "typeArguments": null + } + ], + "name": "create_proposal", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [], + "name": "deposit", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [ + { + "name": "proposal_id", + "type": 21, + "typeArguments": null + } + ], + "name": "execute", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "proposal_id", + "type": 21, + "typeArguments": null + } + ], + "name": "unlock_votes", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "approve", + "type": 2, + "typeArguments": null + }, + { + "name": "proposal_id", + "type": 21, + "typeArguments": null + }, + { + "name": "vote_amount", + "type": 21, + "typeArguments": null + } + ], + "name": "vote", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "amount", + "type": 21, + "typeArguments": null + } + ], + "name": "withdraw", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [], + "name": "balance", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "governance_token_id", + "output": { + "name": "", + "type": 10, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "proposal_id", + "type": 21, + "typeArguments": null + } + ], + "name": "proposal", + "output": { + "name": "", + "type": 16, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "proposal_count", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "user", + "type": 4, + "typeArguments": null + } + ], + "name": "user_balance", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "proposal_id", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 4, + "typeArguments": null + } + ], + "name": "user_votes", + "output": { + "name": "", + "type": 19, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 5, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 14, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 5, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 12, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 13, + "loggedType": { + "name": "", + "type": 13, + "typeArguments": [] + } + }, + { + "logId": 14, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 15, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 16, + "loggedType": { + "name": "", + "type": 17, + "typeArguments": [] + } + }, + { + "logId": 17, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 18, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 19, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 20, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 21, + "loggedType": { + "name": "", + "type": 18, + "typeArguments": [] + } + }, + { + "logId": 22, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 23, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 24, + "loggedType": { + "name": "", + "type": 20, + "typeArguments": [] + } + }, + { + "logId": 25, + "loggedType": { + "name": "", + "type": 5, + "typeArguments": [] + } + }, + { + "logId": 26, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 27, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/README.md b/packages/fuel-indexer-tests/trybuild/abi/README.md new file mode 100644 index 000000000..ac76f0ea2 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/README.md @@ -0,0 +1,5 @@ +# `fuel-indexer-tests/trybuild/abi` + +- This directory contains several Sway JSON ABI files copied over from various [Sway applications](https://github.com/FuelLabs/sway-applications/tree/master). +- We use this ABI in a few trybuild tests in order to ensure that `forc index` builds with actual/legitimate Sway code (not just indexer-related test code) +- We include these JSON ABI files here (in their own `abi` directory) because we are only using ABI files in the relevant tests (i.e., we are not combining these ABI files with GraphQL schema). \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/asset-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/asset-contract-abi.json new file mode 100644 index 000000000..093b8021a --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/asset-contract-abi.json @@ -0,0 +1,200 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "enum AccessError", + "components": [ + { + "name": "SenderNotPermittedToMint", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 6, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 7, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum InitError", + "components": [ + { + "name": "AlreadyInitialized", + "type": 0, + "typeArguments": null + }, + { + "name": "AssetSupplyCannotBeZero", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum InputError", + "components": [ + { + "name": "GreaterThanMaximumSupply", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 8, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "asset_supply", + "type": 8, + "typeArguments": null + }, + { + "name": "minter", + "type": 3, + "typeArguments": null + } + ], + "name": "constructor", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "amount", + "type": 8, + "typeArguments": null + }, + { + "name": "to", + "type": 3, + "typeArguments": null + } + ], + "name": "mint_to", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 5, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/auction-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/auction-contract-abi.json new file mode 100644 index 000000000..064478445 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/auction-contract-abi.json @@ -0,0 +1,954 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "enum AccessError", + "components": [ + { + "name": "AuctionIsNotClosed", + "type": 0, + "typeArguments": null + }, + { + "name": "AuctionIsNotOpen", + "type": 0, + "typeArguments": null + }, + { + "name": "NFTTransferNotApproved", + "type": 0, + "typeArguments": null + }, + { + "name": "SenderIsNotSeller", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum AssetError", + "components": [ + { + "name": "AssetsAreNotTheSame", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum AuctionAsset", + "components": [ + { + "name": "NFTAsset", + "type": 18, + "typeArguments": null + }, + { + "name": "TokenAsset", + "type": 19, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 12, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 16, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "enum InitError", + "components": [ + { + "name": "AuctionDurationNotProvided", + "type": 0, + "typeArguments": null + }, + { + "name": "BidAssetAmountNotZero", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotAcceptMoreThanOneNFT", + "type": 0, + "typeArguments": null + }, + { + "name": "InitialPriceCannotBeZero", + "type": 0, + "typeArguments": null + }, + { + "name": "ReserveLessThanInitialPrice", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "enum InputError", + "components": [ + { + "name": "AuctionDoesNotExist", + "type": 0, + "typeArguments": null + }, + { + "name": "InitialPriceNotMet", + "type": 0, + "typeArguments": null + }, + { + "name": "IncorrectAmountProvided", + "type": 0, + "typeArguments": null + }, + { + "name": "IncorrectAssetProvided", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 8, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 11, + "typeArguments": null + } + ], + "typeParameters": [ + 11 + ] + }, + { + "typeId": 9, + "type": "enum State", + "components": [ + { + "name": "Closed", + "type": 0, + "typeArguments": null + }, + { + "name": "Open", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 10, + "type": "enum UserError", + "components": [ + { + "name": "BidderIsSeller", + "type": 0, + "typeArguments": null + }, + { + "name": "UserHasAlreadyWithdrawn", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 12, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "struct Auction", + "components": [ + { + "name": "bid_asset", + "type": 4, + "typeArguments": null + }, + { + "name": "end_block", + "type": 21, + "typeArguments": null + }, + { + "name": "highest_bidder", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 5, + "typeArguments": null + } + ] + }, + { + "name": "initial_price", + "type": 21, + "typeArguments": null + }, + { + "name": "reserve_price", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 21, + "typeArguments": null + } + ] + }, + { + "name": "sell_asset", + "type": 4, + "typeArguments": null + }, + { + "name": "seller", + "type": 5, + "typeArguments": null + }, + { + "name": "state", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 14, + "type": "struct BidEvent", + "components": [ + { + "name": "amount", + "type": 21, + "typeArguments": null + }, + { + "name": "auction_id", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 15, + "type": "struct CancelAuctionEvent", + "components": [ + { + "name": "auction_id", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct CreateAuctionEvent", + "components": [ + { + "name": "auction_id", + "type": 21, + "typeArguments": null + }, + { + "name": "bid_asset", + "type": 4, + "typeArguments": null + }, + { + "name": "sell_asset", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "struct NFTAsset", + "components": [ + { + "name": "asset_id", + "type": 16, + "typeArguments": null + }, + { + "name": "token_id", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 19, + "type": "struct TokenAsset", + "components": [ + { + "name": "amount", + "type": 21, + "typeArguments": null + }, + { + "name": "asset_id", + "type": 16, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 20, + "type": "struct WithdrawEvent", + "components": [ + { + "name": "asset", + "type": 4, + "typeArguments": null + }, + { + "name": "auction_id", + "type": 21, + "typeArguments": null + }, + { + "name": "user", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 21, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "auction_id", + "type": 21, + "typeArguments": null + }, + { + "name": "bid_asset", + "type": 4, + "typeArguments": null + } + ], + "name": "bid", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [ + { + "name": "auction_id", + "type": 21, + "typeArguments": null + } + ], + "name": "cancel", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "bid_asset", + "type": 4, + "typeArguments": null + }, + { + "name": "duration", + "type": 21, + "typeArguments": null + }, + { + "name": "initial_price", + "type": 21, + "typeArguments": null + }, + { + "name": "reserve_price", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 21, + "typeArguments": null + } + ] + }, + { + "name": "seller", + "type": 5, + "typeArguments": null + }, + { + "name": "sell_asset", + "type": 4, + "typeArguments": null + } + ], + "name": "create", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + }, + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "auction_id", + "type": 21, + "typeArguments": null + } + ], + "name": "withdraw", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "auction_id", + "type": 21, + "typeArguments": null + } + ], + "name": "auction_info", + "output": { + "name": "", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "auction_id", + "type": 21, + "typeArguments": null + }, + { + "name": "identity", + "type": 5, + "typeArguments": null + } + ], + "name": "deposit_balance", + "output": { + "name": "", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 4, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "total_auctions", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 13, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 14, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 15, + "loggedType": { + "name": "", + "type": 14, + "typeArguments": [] + } + }, + { + "logId": 16, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 17, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 18, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 19, + "loggedType": { + "name": "", + "type": 15, + "typeArguments": [] + } + }, + { + "logId": 20, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 21, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 22, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 23, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 24, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 25, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 26, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 27, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 28, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 29, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 30, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 31, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 32, + "loggedType": { + "name": "", + "type": 17, + "typeArguments": [] + } + }, + { + "logId": 33, + "loggedType": { + "name": "", + "type": 7, + "typeArguments": [] + } + }, + { + "logId": 34, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 35, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 36, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 37, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 38, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 39, + "loggedType": { + "name": "", + "type": 20, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi-reserved-name.json b/packages/fuel-indexer-tests/trybuild/abi/contracts-abi-reserved-name.json similarity index 100% rename from packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi-reserved-name.json rename to packages/fuel-indexer-tests/trybuild/abi/contracts-abi-reserved-name.json diff --git a/packages/fuel-indexer-tests/trybuild/abi/distributor-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/distributor-contract-abi.json new file mode 100644 index 000000000..3d5c04698 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/distributor-contract-abi.json @@ -0,0 +1,676 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum AccessError", + "components": [ + { + "name": "CallerNotAdmin", + "type": 0, + "typeArguments": null + }, + { + "name": "NotEnoughTokens", + "type": 0, + "typeArguments": null + }, + { + "name": "UserAlreadyClaimed", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum ClaimState", + "components": [ + { + "name": "Unclaimed", + "type": 0, + "typeArguments": null + }, + { + "name": "Claimed", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 13, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 16, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "enum InitError", + "components": [ + { + "name": "AlreadyInitialized", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotAirdropZeroTokens", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 11, + "typeArguments": null + } + ], + "typeParameters": [ + 11 + ] + }, + { + "typeId": 8, + "type": "enum ProofError", + "components": [ + { + "name": "InvalidKey", + "type": 0, + "typeArguments": null + }, + { + "name": "InvalidProofLength", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "enum StateError", + "components": [ + { + "name": "ClaimPeriodNotActive", + "type": 0, + "typeArguments": null + }, + { + "name": "ClaimPeriodActive", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 10, + "type": "enum VerificationError", + "components": [ + { + "name": "MerkleProofFailed", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 12, + "type": "raw untyped ptr", + "components": null, + "typeParameters": null + }, + { + "typeId": 13, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 14, + "type": "struct ClaimEvent", + "components": [ + { + "name": "amount", + "type": 20, + "typeArguments": null + }, + { + "name": "claimer", + "type": 5, + "typeArguments": null + }, + { + "name": "to", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 15, + "type": "struct ClawbackEvent", + "components": [ + { + "name": "amount", + "type": 20, + "typeArguments": null + }, + { + "name": "to", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct CreateAirdropEvent", + "components": [ + { + "name": "admin", + "type": 5, + "typeArguments": null + }, + { + "name": "asset", + "type": 16, + "typeArguments": null + }, + { + "name": "end_block", + "type": 20, + "typeArguments": null + }, + { + "name": "merkle_root", + "type": 1, + "typeArguments": null + }, + { + "name": "number_of_leaves", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "struct RawVec", + "components": [ + { + "name": "ptr", + "type": 12, + "typeArguments": null + }, + { + "name": "cap", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": [ + 11 + ] + }, + { + "typeId": 19, + "type": "struct Vec", + "components": [ + { + "name": "buf", + "type": 18, + "typeArguments": [ + { + "name": "", + "type": 11, + "typeArguments": null + } + ] + }, + { + "name": "len", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": [ + 11 + ] + }, + { + "typeId": 20, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "amount", + "type": 20, + "typeArguments": null + }, + { + "name": "key", + "type": 20, + "typeArguments": null + }, + { + "name": "proof", + "type": 19, + "typeArguments": [ + { + "name": "", + "type": 1, + "typeArguments": null + } + ] + }, + { + "name": "to", + "type": 5, + "typeArguments": null + } + ], + "name": "claim", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [], + "name": "clawback", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "admin", + "type": 5, + "typeArguments": null + }, + { + "name": "claim_time", + "type": 20, + "typeArguments": null + }, + { + "name": "merkle_root", + "type": 1, + "typeArguments": null + }, + { + "name": "number_of_leaves", + "type": 20, + "typeArguments": null + } + ], + "name": "constructor", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [], + "name": "admin", + "output": { + "name": "", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 5, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identity", + "type": 5, + "typeArguments": null + } + ], + "name": "claim_data", + "output": { + "name": "", + "type": 4, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "end_block", + "output": { + "name": "", + "type": 20, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "is_active", + "output": { + "name": "", + "type": 2, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "merkle_root", + "output": { + "name": "", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 1, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "number_of_leaves", + "output": { + "name": "", + "type": 20, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 9, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 14, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 9, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 15, + "typeArguments": [] + } + }, + { + "logId": 13, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 14, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 15, + "loggedType": { + "name": "", + "type": 17, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/escrow-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/escrow-contract-abi.json new file mode 100644 index 000000000..bb6fe36f2 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/escrow-contract-abi.json @@ -0,0 +1,1476 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum ArbiterInputError", + "components": [ + { + "name": "AssetDoesNotMatch", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotBeBuyer", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotBeSeller", + "type": 0, + "typeArguments": null + }, + { + "name": "FeeCannotBeZero", + "type": 0, + "typeArguments": null + }, + { + "name": "FeeDoesNotMatchAmountSent", + "type": 0, + "typeArguments": null + }, + { + "name": "PaymentTooLarge", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum AssetInputError", + "components": [ + { + "name": "UnspecifiedAssets", + "type": 0, + "typeArguments": null + }, + { + "name": "AssetAmountCannotBeZero", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum DeadlineInputError", + "components": [ + { + "name": "MustBeInTheFuture", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "enum DepositError", + "components": [ + { + "name": "IncorrectAssetAmount", + "type": 0, + "typeArguments": null + }, + { + "name": "IncorrectAssetSent", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 16, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 8, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 13, + "typeArguments": null + } + ], + "typeParameters": [ + 13 + ] + }, + { + "typeId": 9, + "type": "enum State", + "components": [ + { + "name": "Pending", + "type": 0, + "typeArguments": null + }, + { + "name": "Completed", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 10, + "type": "enum StateError", + "components": [ + { + "name": "AlreadyDeposited", + "type": 0, + "typeArguments": null + }, + { + "name": "AlreadyDisputed", + "type": 0, + "typeArguments": null + }, + { + "name": "ArbiterHasNotBeenProposed", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotDisputeBeforeDeposit", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotResolveBeforeDeposit", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotTakePaymentBeforeDeadline", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotTakePaymentDuringDispute", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotTransferBeforeDeposit", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotWithdrawAfterDeposit", + "type": 0, + "typeArguments": null + }, + { + "name": "CannotWithdrawBeforeDeadline", + "type": 0, + "typeArguments": null + }, + { + "name": "EscrowExpired", + "type": 0, + "typeArguments": null + }, + { + "name": "NotDisputed", + "type": 0, + "typeArguments": null + }, + { + "name": "StateNotPending", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "enum UserError", + "components": [ + { + "name": "Unauthorized", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 12, + "type": "enum UserInputError", + "components": [ + { + "name": "InvalidRecipient", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 14, + "type": "raw untyped ptr", + "components": null, + "typeParameters": null + }, + { + "typeId": 15, + "type": "struct AcceptedArbiterEvent", + "components": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct Arbiter", + "components": [ + { + "name": "address", + "type": 7, + "typeArguments": null + }, + { + "name": "asset", + "type": 20, + "typeArguments": null + }, + { + "name": "fee_amount", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "struct Asset", + "components": [ + { + "name": "amount", + "type": 34, + "typeArguments": null + }, + { + "name": "id", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 19, + "type": "struct Buyer", + "components": [ + { + "name": "address", + "type": 7, + "typeArguments": null + }, + { + "name": "asset", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 20, + "typeArguments": null + } + ] + }, + { + "name": "deposited_amount", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 20, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 21, + "type": "struct CreatedEscrowEvent", + "components": [ + { + "name": "escrow", + "type": 24, + "typeArguments": null + }, + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 22, + "type": "struct DepositEvent", + "components": [ + { + "name": "asset", + "type": 20, + "typeArguments": null + }, + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 23, + "type": "struct DisputeEvent", + "components": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 24, + "type": "struct EscrowInfo", + "components": [ + { + "name": "arbiter", + "type": 17, + "typeArguments": null + }, + { + "name": "asset_count", + "type": 34, + "typeArguments": null + }, + { + "name": "buyer", + "type": 19, + "typeArguments": null + }, + { + "name": "deadline", + "type": 34, + "typeArguments": null + }, + { + "name": "disputed", + "type": 2, + "typeArguments": null + }, + { + "name": "first_asset_index", + "type": 34, + "typeArguments": null + }, + { + "name": "seller", + "type": 30, + "typeArguments": null + }, + { + "name": "state", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 25, + "type": "struct PaymentTakenEvent", + "components": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 26, + "type": "struct ProposedArbiterEvent", + "components": [ + { + "name": "arbiter", + "type": 17, + "typeArguments": null + }, + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 27, + "type": "struct RawVec", + "components": [ + { + "name": "ptr", + "type": 14, + "typeArguments": null + }, + { + "name": "cap", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": [ + 13 + ] + }, + { + "typeId": 28, + "type": "struct ResolvedDisputeEvent", + "components": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + }, + { + "name": "user", + "type": 7, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 29, + "type": "struct ReturnedDepositEvent", + "components": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 30, + "type": "struct Seller", + "components": [ + { + "name": "address", + "type": 7, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 31, + "type": "struct TransferredToSellerEvent", + "components": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 32, + "type": "struct Vec", + "components": [ + { + "name": "buf", + "type": 27, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "len", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": [ + 13 + ] + }, + { + "typeId": 33, + "type": "struct WithdrawnCollateralEvent", + "components": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 34, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "accept_arbiter", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "arbiter", + "type": 17, + "typeArguments": null + }, + { + "name": "assets", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 18, + "typeArguments": null + } + ] + }, + { + "name": "buyer", + "type": 7, + "typeArguments": null + }, + { + "name": "deadline", + "type": 34, + "typeArguments": null + } + ], + "name": "create_escrow", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "deposit", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "dispute", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "arbiter", + "type": 17, + "typeArguments": null + }, + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "propose_arbiter", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + }, + { + "name": "payment_amount", + "type": 34, + "typeArguments": null + }, + { + "name": "user", + "type": 7, + "typeArguments": null + } + ], + "name": "resolve_dispute", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "return_deposit", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "take_payment", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "transfer_to_seller", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "withdraw_collateral", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "arbiter_proposal", + "output": { + "name": "", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 17, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "assets", + "output": { + "name": "", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 18, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "escrow_count", + "output": { + "name": "", + "type": 34, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "identifier", + "type": 34, + "typeArguments": null + } + ], + "name": "escrows", + "output": { + "name": "", + "type": 8, + "typeArguments": [ + { + "name": "", + "type": 24, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 15, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 5, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 13, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 14, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 15, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 16, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 17, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 18, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 19, + "loggedType": { + "name": "", + "type": 22, + "typeArguments": [] + } + }, + { + "logId": 20, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 21, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 22, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 23, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 24, + "loggedType": { + "name": "", + "type": 23, + "typeArguments": [] + } + }, + { + "logId": 25, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 26, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 27, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 28, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 29, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 30, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 31, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 32, + "loggedType": { + "name": "", + "type": 26, + "typeArguments": [] + } + }, + { + "logId": 33, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 34, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 35, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 36, + "loggedType": { + "name": "", + "type": 12, + "typeArguments": [] + } + }, + { + "logId": 37, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 38, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 39, + "loggedType": { + "name": "", + "type": 28, + "typeArguments": [] + } + }, + { + "logId": 40, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 41, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 42, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 43, + "loggedType": { + "name": "", + "type": 29, + "typeArguments": [] + } + }, + { + "logId": 44, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 45, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 46, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 47, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 48, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 49, + "loggedType": { + "name": "", + "type": 25, + "typeArguments": [] + } + }, + { + "logId": 50, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 51, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 52, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 53, + "loggedType": { + "name": "", + "type": 31, + "typeArguments": [] + } + }, + { + "logId": 54, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 55, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 56, + "loggedType": { + "name": "", + "type": 11, + "typeArguments": [] + } + }, + { + "logId": 57, + "loggedType": { + "name": "", + "type": 10, + "typeArguments": [] + } + }, + { + "logId": 58, + "loggedType": { + "name": "", + "type": 33, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/exchange-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/exchange-contract-abi.json new file mode 100644 index 000000000..7afad6baa --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/exchange-contract-abi.json @@ -0,0 +1,1135 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum InitError", + "components": [ + { + "name": "AssetPairAlreadySet", + "type": 0, + "typeArguments": null + }, + { + "name": "AssetPairNotSet", + "type": 0, + "typeArguments": null + }, + { + "name": "IdenticalAssets", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum InputError", + "components": [ + { + "name": "CannotAddLessThanMinimumLiquidity", + "type": 21, + "typeArguments": null + }, + { + "name": "DeadlinePassed", + "type": 21, + "typeArguments": null + }, + { + "name": "ExpectedNonZeroAmount", + "type": 11, + "typeArguments": null + }, + { + "name": "ExpectedNonZeroParameter", + "type": 11, + "typeArguments": null + }, + { + "name": "InvalidAsset", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 7, + "typeArguments": null + } + ], + "typeParameters": [ + 7 + ] + }, + { + "typeId": 6, + "type": "enum TransactionError", + "components": [ + { + "name": "DesiredAmountTooHigh", + "type": 21, + "typeArguments": null + }, + { + "name": "DesiredAmountTooLow", + "type": 21, + "typeArguments": null + }, + { + "name": "ExpectedNonZeroDeposit", + "type": 11, + "typeArguments": null + }, + { + "name": "InsufficientReserve", + "type": 11, + "typeArguments": null + }, + { + "name": "NoLiquidityToRemove", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 8, + "type": "struct AddLiquidityEvent", + "components": [ + { + "name": "added_assets", + "type": 10, + "typeArguments": null + }, + { + "name": "liquidity", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "struct Asset", + "components": [ + { + "name": "id", + "type": 11, + "typeArguments": null + }, + { + "name": "amount", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 10, + "type": "struct AssetPair", + "components": [ + { + "name": "a", + "type": 9, + "typeArguments": null + }, + { + "name": "b", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 12, + "type": "struct DefineAssetPairEvent", + "components": [ + { + "name": "asset_a_id", + "type": 11, + "typeArguments": null + }, + { + "name": "asset_b_id", + "type": 11, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "struct DepositEvent", + "components": [ + { + "name": "deposited_asset", + "type": 9, + "typeArguments": null + }, + { + "name": "new_balance", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 14, + "type": "struct PoolInfo", + "components": [ + { + "name": "reserves", + "type": 10, + "typeArguments": null + }, + { + "name": "liquidity", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 15, + "type": "struct PreviewAddLiquidityInfo", + "components": [ + { + "name": "other_asset_to_add", + "type": 9, + "typeArguments": null + }, + { + "name": "liquidity_asset_to_receive", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct PreviewSwapInfo", + "components": [ + { + "name": "other_asset", + "type": 9, + "typeArguments": null + }, + { + "name": "sufficient_reserve", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct RemoveLiquidityEvent", + "components": [ + { + "name": "removed_reserve", + "type": 10, + "typeArguments": null + }, + { + "name": "burned_liquidity", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "struct RemoveLiquidityInfo", + "components": [ + { + "name": "removed_amounts", + "type": 10, + "typeArguments": null + }, + { + "name": "burned_liquidity", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 19, + "type": "struct SwapEvent", + "components": [ + { + "name": "input", + "type": 9, + "typeArguments": null + }, + { + "name": "output", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 20, + "type": "struct WithdrawEvent", + "components": [ + { + "name": "withdrawn_asset", + "type": 9, + "typeArguments": null + }, + { + "name": "remaining_balance", + "type": 21, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 21, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "desired_liquidity", + "type": 21, + "typeArguments": null + }, + { + "name": "deadline", + "type": 21, + "typeArguments": null + } + ], + "name": "add_liquidity", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "asset_id", + "type": 11, + "typeArguments": null + } + ], + "name": "balance", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "asset_a", + "type": 11, + "typeArguments": null + }, + { + "name": "asset_b", + "type": 11, + "typeArguments": null + } + ], + "name": "constructor", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [], + "name": "deposit", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + }, + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [], + "name": "pool_info", + "output": { + "name": "", + "type": 14, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "asset", + "type": 9, + "typeArguments": null + } + ], + "name": "preview_add_liquidity", + "output": { + "name": "", + "type": 15, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "exact_input_asset", + "type": 9, + "typeArguments": null + } + ], + "name": "preview_swap_exact_input", + "output": { + "name": "", + "type": 16, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "exact_output_asset", + "type": 9, + "typeArguments": null + } + ], + "name": "preview_swap_exact_output", + "output": { + "name": "", + "type": 16, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "min_asset_a", + "type": 21, + "typeArguments": null + }, + { + "name": "min_asset_b", + "type": 21, + "typeArguments": null + }, + { + "name": "deadline", + "type": 21, + "typeArguments": null + } + ], + "name": "remove_liquidity", + "output": { + "name": "", + "type": 18, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [ + { + "name": "min_output", + "type": 5, + "typeArguments": [ + { + "name": "", + "type": 21, + "typeArguments": null + } + ] + }, + { + "name": "deadline", + "type": 21, + "typeArguments": null + } + ], + "name": "swap_exact_input", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + }, + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "output", + "type": 21, + "typeArguments": null + }, + { + "name": "deadline", + "type": 21, + "typeArguments": null + } + ], + "name": "swap_exact_output", + "output": { + "name": "", + "type": 21, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + }, + { + "name": "payable", + "arguments": [] + } + ] + }, + { + "inputs": [ + { + "name": "asset", + "type": 9, + "typeArguments": null + } + ], + "name": "withdraw", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 13, + "loggedType": { + "name": "", + "type": 12, + "typeArguments": [] + } + }, + { + "logId": 14, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 15, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 16, + "loggedType": { + "name": "", + "type": 13, + "typeArguments": [] + } + }, + { + "logId": 17, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 18, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 19, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 20, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 21, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 22, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 23, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 24, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 25, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 26, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 27, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 28, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 29, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 30, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 31, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 32, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 33, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 34, + "loggedType": { + "name": "", + "type": 17, + "typeArguments": [] + } + }, + { + "logId": 35, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 36, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 37, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 38, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 39, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 40, + "loggedType": { + "name": "", + "type": 19, + "typeArguments": [] + } + }, + { + "logId": 41, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 42, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 43, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 44, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 45, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 46, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 47, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 48, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 49, + "loggedType": { + "name": "", + "type": 19, + "typeArguments": [] + } + }, + { + "logId": 50, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 51, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 52, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 53, + "loggedType": { + "name": "", + "type": 20, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "LIQUIDITY_MINER_FEE", + "configurableType": { + "name": "", + "type": 21, + "typeArguments": null + }, + "offset": 67464 + }, + { + "name": "MINIMUM_LIQUIDITY", + "configurableType": { + "name": "", + "type": 21, + "typeArguments": null + }, + "offset": 67264 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/multisig-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/multisig-contract-abi.json new file mode 100644 index 000000000..47d389d15 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/multisig-contract-abi.json @@ -0,0 +1,1182 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "[_; 2]", + "components": [ + { + "name": "__array_element", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 2, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 3, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum ExecutionError", + "components": [ + { + "name": "CanOnlyCallContracts", + "type": 0, + "typeArguments": null + }, + { + "name": "IncorrectSignerOrdering", + "type": 0, + "typeArguments": null + }, + { + "name": "InsufficientAssetAmount", + "type": 0, + "typeArguments": null + }, + { + "name": "InsufficientApprovals", + "type": 0, + "typeArguments": null + }, + { + "name": "TransferRequiresAValue", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 16, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "enum InitError", + "components": [ + { + "name": "CannotReinitialize", + "type": 0, + "typeArguments": null + }, + { + "name": "NotInitialized", + "type": 0, + "typeArguments": null + }, + { + "name": "ThresholdCannotBeZero", + "type": 0, + "typeArguments": null + }, + { + "name": "TotalWeightCannotBeLessThanThreshold", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "enum MessageFormat", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "EIP191PersonalSign", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 8, + "type": "enum MessagePrefix", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Ethereum", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 13, + "typeArguments": null + } + ], + "typeParameters": [ + 13 + ] + }, + { + "typeId": 10, + "type": "enum TransactionParameters", + "components": [ + { + "name": "Call", + "type": 19, + "typeArguments": null + }, + { + "name": "Transfer", + "type": 30, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 11, + "type": "enum TypeToHash", + "components": [ + { + "name": "Threshold", + "type": 28, + "typeArguments": null + }, + { + "name": "Transaction", + "type": 29, + "typeArguments": null + }, + { + "name": "Weight", + "type": 33, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 12, + "type": "enum WalletType", + "components": [ + { + "name": "Fuel", + "type": 0, + "typeArguments": null + }, + { + "name": "EVM", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 14, + "type": "raw untyped ptr", + "components": null, + "typeParameters": null + }, + { + "typeId": 15, + "type": "str[33]", + "components": null, + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct B512", + "components": [ + { + "name": "bytes", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "struct Bytes", + "components": [ + { + "name": "buf", + "type": 23, + "typeArguments": null + }, + { + "name": "len", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 19, + "type": "struct ContractCallParams", + "components": [ + { + "name": "calldata", + "type": 18, + "typeArguments": null + }, + { + "name": "forwarded_gas", + "type": 34, + "typeArguments": null + }, + { + "name": "function_selector", + "type": 18, + "typeArguments": null + }, + { + "name": "single_value_type_arg", + "type": 3, + "typeArguments": null + }, + { + "name": "transfer_params", + "type": 30, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 20, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 21, + "type": "struct EvmAddress", + "components": [ + { + "name": "value", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 22, + "type": "struct ExecuteTransactionEvent", + "components": [ + { + "name": "nonce", + "type": 34, + "typeArguments": null + }, + { + "name": "target", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 23, + "type": "struct RawBytes", + "components": [ + { + "name": "ptr", + "type": 14, + "typeArguments": null + }, + { + "name": "cap", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 24, + "type": "struct RawVec", + "components": [ + { + "name": "ptr", + "type": 14, + "typeArguments": null + }, + { + "name": "cap", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": [ + 13 + ] + }, + { + "typeId": 25, + "type": "struct SetThresholdEvent", + "components": [ + { + "name": "previous_threshold", + "type": 34, + "typeArguments": null + }, + { + "name": "threshold", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 26, + "type": "struct SetWeightEvent", + "components": [ + { + "name": "user", + "type": 31, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 27, + "type": "struct SignatureInfo", + "components": [ + { + "name": "message_format", + "type": 7, + "typeArguments": null + }, + { + "name": "message_prefix", + "type": 8, + "typeArguments": null + }, + { + "name": "signature", + "type": 17, + "typeArguments": null + }, + { + "name": "wallet_type", + "type": 12, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 28, + "type": "struct Threshold", + "components": [ + { + "name": "contract_identifier", + "type": 20, + "typeArguments": null + }, + { + "name": "nonce", + "type": 34, + "typeArguments": null + }, + { + "name": "threshold", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 29, + "type": "struct Transaction", + "components": [ + { + "name": "contract_identifier", + "type": 20, + "typeArguments": null + }, + { + "name": "nonce", + "type": 34, + "typeArguments": null + }, + { + "name": "target", + "type": 5, + "typeArguments": null + }, + { + "name": "transaction_parameters", + "type": 10, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 30, + "type": "struct TransferParams", + "components": [ + { + "name": "asset_id", + "type": 20, + "typeArguments": null + }, + { + "name": "value", + "type": 9, + "typeArguments": [ + { + "name": "", + "type": 34, + "typeArguments": null + } + ] + } + ], + "typeParameters": null + }, + { + "typeId": 31, + "type": "struct User", + "components": [ + { + "name": "address", + "type": 2, + "typeArguments": null + }, + { + "name": "weight", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 32, + "type": "struct Vec", + "components": [ + { + "name": "buf", + "type": 24, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "len", + "type": 34, + "typeArguments": null + } + ], + "typeParameters": [ + 13 + ] + }, + { + "typeId": 33, + "type": "struct Weight", + "components": [ + { + "name": "contract_identifier", + "type": 20, + "typeArguments": null + }, + { + "name": "nonce", + "type": 34, + "typeArguments": null + }, + { + "name": "user", + "type": 31, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 34, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "users", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 31, + "typeArguments": null + } + ] + } + ], + "name": "constructor", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "signatures", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 27, + "typeArguments": null + } + ] + }, + { + "name": "target", + "type": 5, + "typeArguments": null + }, + { + "name": "transaction_parameters", + "type": 10, + "typeArguments": null + } + ], + "name": "execute_transaction", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "signatures", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 27, + "typeArguments": null + } + ] + }, + { + "name": "threshold", + "type": 34, + "typeArguments": null + } + ], + "name": "set_threshold", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "signatures", + "type": 32, + "typeArguments": [ + { + "name": "", + "type": 27, + "typeArguments": null + } + ] + }, + { + "name": "user", + "type": 31, + "typeArguments": null + } + ], + "name": "set_weight", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "user", + "type": 2, + "typeArguments": null + } + ], + "name": "approval_weight", + "output": { + "name": "", + "type": 34, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "asset_id", + "type": 20, + "typeArguments": null + } + ], + "name": "balance", + "output": { + "name": "", + "type": 34, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [ + { + "name": "type_to_hash", + "type": 11, + "typeArguments": null + } + ], + "name": "compute_hash", + "output": { + "name": "", + "type": 2, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "nonce", + "output": { + "name": "", + "type": 34, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [], + "name": "threshold", + "output": { + "name": "", + "type": 34, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 16, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 15, + "typeArguments": null + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 13, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 14, + "loggedType": { + "name": "", + "type": 16, + "typeArguments": [] + } + }, + { + "logId": 15, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 16, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 17, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 18, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 19, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 20, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 21, + "loggedType": { + "name": "", + "type": 16, + "typeArguments": [] + } + }, + { + "logId": 22, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 23, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 24, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 25, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 26, + "loggedType": { + "name": "", + "type": 22, + "typeArguments": [] + } + }, + { + "logId": 27, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 28, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 29, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 30, + "loggedType": { + "name": "", + "type": 16, + "typeArguments": [] + } + }, + { + "logId": 31, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 32, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 33, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 34, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 35, + "loggedType": { + "name": "", + "type": 25, + "typeArguments": [] + } + }, + { + "logId": 36, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 37, + "loggedType": { + "name": "", + "type": 16, + "typeArguments": [] + } + }, + { + "logId": 38, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 39, + "loggedType": { + "name": "", + "type": 21, + "typeArguments": [] + } + }, + { + "logId": 40, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 41, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 42, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 43, + "loggedType": { + "name": "", + "type": 26, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "THRESHOLD", + "configurableType": { + "name": "", + "type": 34, + "typeArguments": null + }, + "offset": 77108 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/oracle-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/oracle-contract-abi.json new file mode 100644 index 000000000..3ecad014f --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/oracle-contract-abi.json @@ -0,0 +1,200 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "enum AccessError", + "components": [ + { + "name": "NotOwner", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 6, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 7, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 5, + "typeArguments": null + } + ], + "typeParameters": [ + 5 + ] + }, + { + "typeId": 5, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 6, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 8, + "type": "struct PriceUpdateEvent", + "components": [ + { + "name": "price", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [], + "name": "owner", + "output": { + "name": "", + "type": 3, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "price", + "output": { + "name": "", + "type": 4, + "typeArguments": [ + { + "name": "", + "type": 9, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "price", + "type": 9, + "typeArguments": null + } + ], + "name": "set_price", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "write" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "OWNER", + "configurableType": { + "name": "", + "type": 3, + "typeArguments": [] + }, + "offset": 2228 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/registry-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/registry-contract-abi.json new file mode 100644 index 000000000..92e1ee64d --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/registry-contract-abi.json @@ -0,0 +1,756 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "enum AssetError", + "components": [ + { + "name": "InsufficientPayment", + "type": 0, + "typeArguments": null + }, + { + "name": "IncorrectAssetSent", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "enum AuthorizationError", + "components": [ + { + "name": "SenderNotOwner", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 11, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 13, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": [ + 9 + ] + }, + { + "typeId": 6, + "type": "enum RegistrationValidityError", + "components": [ + { + "name": "NameNotRegistered", + "type": 0, + "typeArguments": null + }, + { + "name": "NameExpired", + "type": 0, + "typeArguments": null + }, + { + "name": "NameNotExpired", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "enum Result", + "components": [ + { + "name": "Ok", + "type": 9, + "typeArguments": null + }, + { + "name": "Err", + "type": 8, + "typeArguments": null + } + ], + "typeParameters": [ + 9, + 8 + ] + }, + { + "typeId": 8, + "type": "generic E", + "components": null, + "typeParameters": null + }, + { + "typeId": 9, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 10, + "type": "str[8]", + "components": null, + "typeParameters": null + }, + { + "typeId": 11, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 12, + "type": "struct AssetRateEvent", + "components": [ + { + "name": "id", + "type": 13, + "typeArguments": null + }, + { + "name": "rate", + "type": 5, + "typeArguments": [ + { + "name": "", + "type": 18, + "typeArguments": null + } + ] + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 1, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 14, + "type": "struct IdentityChangedEvent", + "components": [ + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "new_identity", + "type": 4, + "typeArguments": null + }, + { + "name": "previous_identity", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 15, + "type": "struct NameRegisteredEvent", + "components": [ + { + "name": "expiry", + "type": 18, + "typeArguments": null + }, + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "owner", + "type": 4, + "typeArguments": null + }, + { + "name": "identity", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct OwnerChangedEvent", + "components": [ + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "new_owner", + "type": 4, + "typeArguments": null + }, + { + "name": "previous_owner", + "type": 4, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct RegistrationExtendedEvent", + "components": [ + { + "name": "duration", + "type": 18, + "typeArguments": null + }, + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "new_expiry", + "type": 18, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "duration", + "type": 18, + "typeArguments": null + }, + { + "name": "payment_asset", + "type": 13, + "typeArguments": null + } + ], + "name": "extend", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + }, + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "duration", + "type": 18, + "typeArguments": null + }, + { + "name": "owner", + "type": 4, + "typeArguments": null + }, + { + "name": "identity", + "type": 4, + "typeArguments": null + }, + { + "name": "payment_asset", + "type": 13, + "typeArguments": null + } + ], + "name": "register", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "payable", + "arguments": [] + }, + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "id", + "type": 13, + "typeArguments": null + }, + { + "name": "rate", + "type": 5, + "typeArguments": [ + { + "name": "", + "type": 18, + "typeArguments": null + } + ] + } + ], + "name": "set_asset", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "identity", + "type": 4, + "typeArguments": null + } + ], + "name": "set_identity", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "name", + "type": 10, + "typeArguments": null + }, + { + "name": "owner", + "type": 4, + "typeArguments": null + } + ], + "name": "set_owner", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "name", + "type": 10, + "typeArguments": null + } + ], + "name": "expiry", + "output": { + "name": "", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 18, + "typeArguments": null + }, + { + "name": "", + "type": 6, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "name", + "type": 10, + "typeArguments": null + } + ], + "name": "identity", + "output": { + "name": "", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 4, + "typeArguments": null + }, + { + "name": "", + "type": 6, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "name", + "type": 10, + "typeArguments": null + } + ], + "name": "owner", + "output": { + "name": "", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 4, + "typeArguments": null + }, + { + "name": "", + "type": 6, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "id", + "type": 13, + "typeArguments": null + } + ], + "name": "rate", + "output": { + "name": "", + "type": 5, + "typeArguments": [ + { + "name": "", + "type": 18, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 17, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 2, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 15, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 12, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 12, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 13, + "loggedType": { + "name": "", + "type": 14, + "typeArguments": [] + } + }, + { + "logId": 14, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 15, + "loggedType": { + "name": "", + "type": 6, + "typeArguments": [] + } + }, + { + "logId": 16, + "loggedType": { + "name": "", + "type": 3, + "typeArguments": [] + } + }, + { + "logId": 17, + "loggedType": { + "name": "", + "type": 16, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "OWNER", + "configurableType": { + "name": "", + "type": 4, + "typeArguments": [] + }, + "offset": 12640 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/swap-predicate-abi.json b/packages/fuel-indexer-tests/trybuild/abi/swap-predicate-abi.json new file mode 100644 index 000000000..c39ab0ee0 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/swap-predicate-abi.json @@ -0,0 +1,144 @@ +{ + "types": [ + { + "typeId": 0, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 1, + "type": "bool", + "components": null, + "typeParameters": null + }, + { + "typeId": 2, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 4, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [], + "name": "main", + "output": { + "name": "", + "type": 1, + "typeArguments": null + }, + "attributes": [ + { + "name": "doc-comment", + "arguments": [ + " Validates conditions within the transaction to perform a swap" + ] + }, + { + "name": "doc-comment", + "arguments": [ + "" + ] + }, + { + "name": "doc-comment", + "arguments": [ + " # Additional Information" + ] + }, + { + "name": "doc-comment", + "arguments": [ + "" + ] + }, + { + "name": "doc-comment", + "arguments": [ + " The user can cancel their order by including an input coin from themselves." + ] + }, + { + "name": "doc-comment", + "arguments": [ + "" + ] + }, + { + "name": "doc-comment", + "arguments": [ + " # Returns" + ] + }, + { + "name": "doc-comment", + "arguments": [ + "" + ] + }, + { + "name": "doc-comment", + "arguments": [ + " * [bool] - `true` if the spender is the receiver or if the terms of the order are met, `false` otherwise." + ] + } + ] + } + ], + "loggedTypes": [], + "messagesTypes": [], + "configurables": [ + { + "name": "ASK_AMOUNT", + "configurableType": { + "name": "", + "type": 4, + "typeArguments": null + }, + "offset": 2292 + }, + { + "name": "ASK_TOKEN", + "configurableType": { + "name": "", + "type": 3, + "typeArguments": [] + }, + "offset": 2300 + }, + { + "name": "RECEIVER", + "configurableType": { + "name": "", + "type": 2, + "typeArguments": [] + }, + "offset": 2252 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/abi/timelock-contract-abi.json b/packages/fuel-indexer-tests/trybuild/abi/timelock-contract-abi.json new file mode 100644 index 000000000..c9a02befc --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/abi/timelock-contract-abi.json @@ -0,0 +1,701 @@ +{ + "types": [ + { + "typeId": 0, + "type": "()", + "components": [], + "typeParameters": null + }, + { + "typeId": 1, + "type": "(_, _)", + "components": [ + { + "name": "__tuple_element", + "type": 20, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 2, + "type": "(_, _, _)", + "components": [ + { + "name": "__tuple_element", + "type": 20, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 20, + "typeArguments": null + }, + { + "name": "__tuple_element", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 3, + "type": "b256", + "components": null, + "typeParameters": null + }, + { + "typeId": 4, + "type": "enum AccessControlError", + "components": [ + { + "name": "AuthorizationError", + "type": 0, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 5, + "type": "enum FundingError", + "components": [ + { + "name": "InsufficientContractBalance", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 6, + "type": "enum Identity", + "components": [ + { + "name": "Address", + "type": 11, + "typeArguments": null + }, + { + "name": "ContractId", + "type": 15, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 7, + "type": "enum Option", + "components": [ + { + "name": "None", + "type": 0, + "typeArguments": null + }, + { + "name": "Some", + "type": 9, + "typeArguments": null + } + ], + "typeParameters": [ + 9 + ] + }, + { + "typeId": 8, + "type": "enum TransactionError", + "components": [ + { + "name": "DuplicateTransaction", + "type": 3, + "typeArguments": null + }, + { + "name": "InvalidTransaction", + "type": 3, + "typeArguments": null + }, + { + "name": "TimestampNotInRange", + "type": 2, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 9, + "type": "generic T", + "components": null, + "typeParameters": null + }, + { + "typeId": 10, + "type": "raw untyped ptr", + "components": null, + "typeParameters": null + }, + { + "typeId": 11, + "type": "struct Address", + "components": [ + { + "name": "value", + "type": 3, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 12, + "type": "struct Asset", + "components": [ + { + "name": "amount", + "type": 20, + "typeArguments": null + }, + { + "name": "id", + "type": 15, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 13, + "type": "struct Bytes", + "components": [ + { + "name": "buf", + "type": 19, + "typeArguments": null + }, + { + "name": "len", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 14, + "type": "struct CancelEvent", + "components": [ + { + "name": "id", + "type": 3, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 15, + "type": "struct ContractId", + "components": [ + { + "name": "value", + "type": 3, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 16, + "type": "struct ExecuteEvent", + "components": [ + { + "name": "asset", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 12, + "typeArguments": null + } + ] + }, + { + "name": "data", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "id", + "type": 3, + "typeArguments": null + }, + { + "name": "recipient", + "type": 6, + "typeArguments": null + }, + { + "name": "timestamp", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 17, + "type": "struct ExecutionRange", + "components": [ + { + "name": "start", + "type": 20, + "typeArguments": null + }, + { + "name": "end", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 18, + "type": "struct QueueEvent", + "components": [ + { + "name": "asset", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 12, + "typeArguments": null + } + ] + }, + { + "name": "data", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "id", + "type": 3, + "typeArguments": null + }, + { + "name": "recipient", + "type": 6, + "typeArguments": null + }, + { + "name": "timestamp", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 19, + "type": "struct RawBytes", + "components": [ + { + "name": "ptr", + "type": 10, + "typeArguments": null + }, + { + "name": "cap", + "type": 20, + "typeArguments": null + } + ], + "typeParameters": null + }, + { + "typeId": 20, + "type": "u64", + "components": null, + "typeParameters": null + } + ], + "functions": [ + { + "inputs": [ + { + "name": "id", + "type": 3, + "typeArguments": null + } + ], + "name": "cancel", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "recipient", + "type": 6, + "typeArguments": null + }, + { + "name": "asset", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 12, + "typeArguments": null + } + ] + }, + { + "name": "data", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "timestamp", + "type": 20, + "typeArguments": null + } + ], + "name": "execute", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "recipient", + "type": 6, + "typeArguments": null + }, + { + "name": "asset", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 12, + "typeArguments": null + } + ] + }, + { + "name": "data", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "timestamp", + "type": 20, + "typeArguments": null + } + ], + "name": "queue", + "output": { + "name": "", + "type": 0, + "typeArguments": null + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read", + "write" + ] + } + ] + }, + { + "inputs": [ + { + "name": "asset_id", + "type": 15, + "typeArguments": null + } + ], + "name": "balance", + "output": { + "name": "", + "type": 20, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [], + "name": "delays", + "output": { + "name": "", + "type": 1, + "typeArguments": null + }, + "attributes": null + }, + { + "inputs": [ + { + "name": "id", + "type": 3, + "typeArguments": null + } + ], + "name": "queued", + "output": { + "name": "", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 17, + "typeArguments": null + } + ] + }, + "attributes": [ + { + "name": "storage", + "arguments": [ + "read" + ] + } + ] + }, + { + "inputs": [ + { + "name": "recipient", + "type": 6, + "typeArguments": null + }, + { + "name": "asset", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 12, + "typeArguments": null + } + ] + }, + { + "name": "data", + "type": 7, + "typeArguments": [ + { + "name": "", + "type": 13, + "typeArguments": null + } + ] + }, + { + "name": "timestamp", + "type": 20, + "typeArguments": null + } + ], + "name": "transaction_hash", + "output": { + "name": "", + "type": 3, + "typeArguments": null + }, + "attributes": null + } + ], + "loggedTypes": [ + { + "logId": 0, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 1, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 2, + "loggedType": { + "name": "", + "type": 14, + "typeArguments": [] + } + }, + { + "logId": 3, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 4, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 5, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 6, + "loggedType": { + "name": "", + "type": 5, + "typeArguments": [] + } + }, + { + "logId": 7, + "loggedType": { + "name": "", + "type": 16, + "typeArguments": [] + } + }, + { + "logId": 8, + "loggedType": { + "name": "", + "type": 4, + "typeArguments": [] + } + }, + { + "logId": 9, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 10, + "loggedType": { + "name": "", + "type": 8, + "typeArguments": [] + } + }, + { + "logId": 11, + "loggedType": { + "name": "", + "type": 18, + "typeArguments": [] + } + } + ], + "messagesTypes": [], + "configurables": [ + { + "name": "MAXIMUM_DELAY", + "configurableType": { + "name": "", + "type": 20, + "typeArguments": null + }, + "offset": 9060 + }, + { + "name": "MINIMUM_DELAY", + "configurableType": { + "name": "", + "type": 20, + "typeArguments": null + }, + "offset": 9052 + }, + { + "name": "ADMIN", + "configurableType": { + "name": "", + "type": 6, + "typeArguments": [] + }, + "offset": 8900 + } + ] +} \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml b/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml index 374a79f92..767984310 100644 --- a/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml +++ b/packages/fuel-indexer-tests/trybuild/invalid_abi_type_simple_wasm.yaml @@ -1,8 +1,8 @@ - namespace: test_namespace - identifier: simple_wasm_executor - abi: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi-reserved-name.json - graphql_schema: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/indexers/simple-wasm/schema/simple_wasm.graphql - contract_id: ~ - module: - wasm: /Users/rashad/dev/repos/fuel-indexer/target/wasm32-unknown-unknown/release/simple_wasm.wasm \ No newline at end of file +namespace: test_namespace +identifier: simple_wasm_executor +abi: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/trybuild/abi/contracts-abi-reserved-name.json +graphql_schema: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/indexers/simple-wasm/schema/simple_wasm.graphql +contract_id: ~ +module: + wasm: /Users/rashad/dev/repos/fuel-indexer/target/wasm32-unknown-unknown/release/simple_wasm.wasm \ No newline at end of file diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs index 7a6196747..9b5c3678d 100644 --- a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs +++ b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_multi_type.rs @@ -13,7 +13,7 @@ fn ff_put_many_to_many_record(_inp: ()) {} #[no_mangle] fn ff_early_exit(_inp: ()) {} -#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm_multi.yaml")] mod indexer { fn function_one(event: SomeEvent) { let SomeEvent { id, account } = event; diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs index c097f1e24..2cb61b371 100644 --- a/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs +++ b/packages/fuel-indexer-tests/trybuild/pass_if_indexer_is_valid_single_type.rs @@ -13,7 +13,7 @@ fn ff_put_many_to_many_record(_inp: ()) {} #[no_mangle] fn ff_early_exit(_inp: ()) {} -#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm_single.yaml")] mod indexer { fn function_one(event: SomeEvent) { let SomeEvent { id, account } = event; diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs b/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs index bcc01f01b..f7e98ceae 100644 --- a/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs +++ b/packages/fuel-indexer-tests/trybuild/pass_if_unsupported_types_are_used.rs @@ -13,7 +13,7 @@ fn ff_put_many_to_many_record(_inp: ()) {} #[no_mangle] fn ff_early_exit(_inp: ()) {} -#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm.yaml")] +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/simple_wasm_unsupported.yaml")] mod indexer { fn function_one(event: SomeEvent) { let SomeEvent { id, account } = event; @@ -24,78 +24,6 @@ mod indexer { } fn main() { - use fuels::core::codec::ABIEncoder; - - let s1 = SomeEvent { - id: 9, - account: Bits256([48u8; 32]), - }; - - let encoded1 = ABIEncoder::encode(&[s1.into_token()]).expect("Failed compile test"); - let bytes1 = encoded1.resolve(0); - - let data: Vec = vec![BlockData { - id: [0u8; 32].into(), - time: 1, - producer: None, - height: 0, - consensus: fuel::Consensus::default(), - header: fuel::Header { - id: [0u8; 32].into(), - da_height: 1, - transactions_count: 1, - message_receipt_count: 1, - transactions_root: [0u8; 32].into(), - height: 1, - prev_root: [0u8; 32].into(), - time: 1, - application_hash: [0u8; 32].into(), - message_receipt_root: [0u8; 32].into(), - }, - transactions: vec![fuel::TransactionData { - id: [0u8; 32].into(), - status: fuel::TransactionStatus::default(), - receipts: vec![ - fuel::Receipt::Call { - id: [0u8; 32].into(), - to: [0u8; 32].into(), - amount: 400, - asset_id: [0u8; 32].into(), - gas: 4, - param1: 2048508220, - param2: 0, - pc: 0, - is: 0, - }, - fuel::Receipt::ReturnData { - id: [0u8; 32].into(), - ptr: 2342143, - len: bytes1.len() as u64, - digest: [0u8; 32].into(), - data: Some(bytes1), - pc: 0, - is: 0, - }, - fuel::Receipt::Call { - id: [0u8; 32].into(), - to: [0u8; 32].into(), - amount: 400, - asset_id: [0u8; 32].into(), - gas: 4, - param1: 2379805026, - param2: 0, - pc: 0, - is: 0, - }, - ], - transaction: fuel::Transaction::default(), - }], - }]; - - let mut bytes = serialize(&data); - - let ptr = bytes.as_mut_ptr(); - let len = bytes.len(); - - handle_events(ptr, len); + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. } diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_swap_predicate_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_swap_predicate_abi.rs new file mode 100644 index 000000000..6c7bf4527 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_swap_predicate_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/predicate_abi.yaml")] +mod indexer { + fn function_one(_event: BlockData) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_amm_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_amm_abi.rs new file mode 100644 index 000000000..40814e07e --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_amm_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/sway_amm.yaml")] +mod indexer { + fn function_one(_event: RegisterPoolEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_asset_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_asset_contract_abi.rs new file mode 100644 index 000000000..ebb5aa9d6 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_asset_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/asset_contract.yaml")] +mod indexer { + fn function_one(_event: AccessError) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_dao_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_dao_abi.rs new file mode 100644 index 000000000..321ca6dfb --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_dao_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/sway_dao.yaml")] +mod indexer { + fn function_one(_event: CreateProposalEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_distributor_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_distributor_contract_abi.rs new file mode 100644 index 000000000..29db1c0e1 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_distributor_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/distributor_contract.yaml")] +mod indexer { + fn function_one(_event: ClaimEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_escrow_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_escrow_contract_abi.rs new file mode 100644 index 000000000..b4b364a1f --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_escrow_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/escrow_contract.yaml")] +mod indexer { + fn function_one(_event: AcceptedArbiterEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_multisig_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_multisig_contract_abi.rs new file mode 100644 index 000000000..ead824400 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_multisig_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/multisig_contract.yaml")] +mod indexer { + fn function_one(_event: SignatureInfo) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_oracle_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_oracle_contract_abi.rs new file mode 100644 index 000000000..7c27adcbf --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_oracle_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/oracle_contract.yaml")] +mod indexer { + fn function_one(_event: PriceUpdateEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_registry_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_registry_contract_abi.rs new file mode 100644 index 000000000..4bfdafe7d --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_sway_registry_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/registry_contract.yaml")] +mod indexer { + fn function_one(_event: AssetRateEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_if_using_timelock_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_if_using_timelock_contract_abi.rs new file mode 100644 index 000000000..197f14923 --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_if_using_timelock_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/timelock_contract.yaml")] +mod indexer { + fn function_one(_event: ExecuteEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-tests/trybuild/pass_is_using_sway_exchange_contract_abi.rs b/packages/fuel-indexer-tests/trybuild/pass_is_using_sway_exchange_contract_abi.rs new file mode 100644 index 000000000..b21bcd47d --- /dev/null +++ b/packages/fuel-indexer-tests/trybuild/pass_is_using_sway_exchange_contract_abi.rs @@ -0,0 +1,24 @@ +extern crate alloc; +use fuel_indexer_utils::prelude::*; + +#[no_mangle] +fn ff_log_data(_inp: ()) {} + +#[no_mangle] +fn ff_put_object(_inp: ()) {} + +#[no_mangle] +fn ff_put_many_to_many_record(_inp: ()) {} + +#[no_mangle] +fn ff_early_exit(_inp: ()) {} + +#[indexer(manifest = "packages/fuel-indexer-tests/trybuild/exchange_contract.yaml")] +mod indexer { + fn function_one(_event: AddLiquidityEvent) {} +} + +fn main() { + // We're not actually testing the serialization of the event from the ABI JSON here, + // we're just testing that this compiles. +} diff --git a/packages/fuel-indexer-types/src/lib.rs b/packages/fuel-indexer-types/src/lib.rs index 0decb6742..b99bfe746 100644 --- a/packages/fuel-indexer-types/src/lib.rs +++ b/packages/fuel-indexer-types/src/lib.rs @@ -11,7 +11,7 @@ pub use fuels::{ core::codec::try_from_bytes, types::{ bech32::{Bech32Address, Bech32ContractId}, - Bits256, Identity, SizedAsciiString, + Bits256, EvmAddress, Identity, SizedAsciiString, B512, }, }; diff --git a/packages/fuel-indexer-types/src/scalar.rs b/packages/fuel-indexer-types/src/scalar.rs index e540a6939..78383b012 100644 --- a/packages/fuel-indexer-types/src/scalar.rs +++ b/packages/fuel-indexer-types/src/scalar.rs @@ -6,6 +6,9 @@ pub use fuel_types::{ use fuels::types::SizedAsciiString; use serde::{Deserialize, Serialize}; +/// Scalar for 256-bit value. +pub type B256 = [u8; 32]; + /// Scalar for 32-byte unique ID payloads. pub type UID = SizedAsciiString<64>; From ab70a95fd2c7ec1b9e7aaa96bb07f86cb2c99497 Mon Sep 17 00:00:00 2001 From: rashad Date: Fri, 29 Sep 2023 12:57:58 -0400 Subject: [PATCH 5/5] v0.21.0 (#1389) --- Cargo.lock | 32 ++++++++++----------- Cargo.toml | 34 +++++++++++------------ packages/fuel-indexer-schema/src/lib.rs | 2 +- packages/fuel-indexer-types/src/lib.rs | 1 - packages/fuel-indexer-types/src/scalar.rs | 3 +- plugins/forc-index/src/defaults.rs | 6 ++-- 6 files changed, 38 insertions(+), 40 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b1f0c74b5..115a1dd3d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2672,7 +2672,7 @@ checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" [[package]] name = "forc-index" -version = "0.20.11" +version = "0.21.0" dependencies = [ "actix-web", "anyhow", @@ -2705,7 +2705,7 @@ dependencies = [ [[package]] name = "forc-postgres" -version = "0.20.11" +version = "0.21.0" dependencies = [ "anyhow", "clap 3.2.25", @@ -3203,7 +3203,7 @@ dependencies = [ [[package]] name = "fuel-indexer" -version = "0.20.11" +version = "0.21.0" dependencies = [ "anyhow", "async-std", @@ -3235,7 +3235,7 @@ dependencies = [ [[package]] name = "fuel-indexer-api-server" -version = "0.20.11" +version = "0.21.0" dependencies = [ "anyhow", "async-graphql 5.0.10", @@ -3293,7 +3293,7 @@ dependencies = [ [[package]] name = "fuel-indexer-database" -version = "0.20.11" +version = "0.21.0" dependencies = [ "fuel-indexer-database-types", "fuel-indexer-lib", @@ -3305,7 +3305,7 @@ dependencies = [ [[package]] name = "fuel-indexer-database-types" -version = "0.20.11" +version = "0.21.0" dependencies = [ "async-graphql-parser 5.0.10", "async-graphql-value 5.0.10", @@ -3318,7 +3318,7 @@ dependencies = [ [[package]] name = "fuel-indexer-graphql" -version = "0.20.11" +version = "0.21.0" dependencies = [ "async-graphql 5.0.10", "async-graphql-parser 5.0.10", @@ -3336,7 +3336,7 @@ dependencies = [ [[package]] name = "fuel-indexer-lib" -version = "0.20.11" +version = "0.21.0" dependencies = [ "anyhow", "async-graphql-parser 5.0.10", @@ -3361,7 +3361,7 @@ dependencies = [ [[package]] name = "fuel-indexer-macro-utils" -version = "0.20.11" +version = "0.21.0" dependencies = [ "proc-macro-error", "proc-macro2", @@ -3371,7 +3371,7 @@ dependencies = [ [[package]] name = "fuel-indexer-macros" -version = "0.20.11" +version = "0.21.0" dependencies = [ "async-graphql-parser 5.0.10", "async-graphql-value 5.0.10", @@ -3393,7 +3393,7 @@ dependencies = [ [[package]] name = "fuel-indexer-metrics" -version = "0.20.11" +version = "0.21.0" dependencies = [ "axum 0.6.20", "lazy_static", @@ -3403,7 +3403,7 @@ dependencies = [ [[package]] name = "fuel-indexer-plugin" -version = "0.20.11" +version = "0.21.0" dependencies = [ "anyhow", "async-trait", @@ -3426,7 +3426,7 @@ dependencies = [ [[package]] name = "fuel-indexer-postgres" -version = "0.20.11" +version = "0.21.0" dependencies = [ "bigdecimal", "chrono", @@ -3441,7 +3441,7 @@ dependencies = [ [[package]] name = "fuel-indexer-schema" -version = "0.20.11" +version = "0.21.0" dependencies = [ "async-graphql-parser 5.0.10", "fuel-indexer-database", @@ -3518,7 +3518,7 @@ dependencies = [ [[package]] name = "fuel-indexer-types" -version = "0.20.11" +version = "0.21.0" dependencies = [ "bytes", "fuel-tx 0.35.3", @@ -3531,7 +3531,7 @@ dependencies = [ [[package]] name = "fuel-indexer-utils" -version = "0.20.11" +version = "0.21.0" dependencies = [ "fuel-indexer-macros", "fuel-indexer-plugin", diff --git a/Cargo.toml b/Cargo.toml index 6af964147..1861e2b69 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -61,29 +61,29 @@ homepage = "https://fuel.network/" license = "Apache-2.0" repository = "https://github.com/FuelLabs/fuel-indexer" rust-version = "1.72.1" -version = "0.20.11" +version = "0.21.0" [workspace.dependencies] async-graphql-parser = "5.0" async-graphql-value = "5.0" bincode = "1.3" clap = "3.1" -forc-index = { version = "0.20.11", path = "./plugins/forc-index" } -forc-postgres = { version = "0.20.11", path = "./plugins/forc-postgres" } -fuel-indexer = { version = "0.20.11", path = "./packages/fuel-indexer" } -fuel-indexer-api-server = { version = "0.20.11", path = "./packages/fuel-indexer-api-server" } -fuel-indexer-database = { version = "0.20.11", path = "./packages/fuel-indexer-database" } -fuel-indexer-database-types = { version = "0.20.11", path = "./packages/fuel-indexer-database/database-types" } -fuel-indexer-graphql = { version = "0.20.11", path = "./packages/fuel-indexer-graphql" } -fuel-indexer-lib = { version = "0.20.11", path = "./packages/fuel-indexer-lib" } -fuel-indexer-macro-utils = { version = "0.20.11", path = "./packages/fuel-indexer-macros/macro-utils" } -fuel-indexer-macros = { version = "0.20.11", path = "./packages/fuel-indexer-macros", default-features = false } -fuel-indexer-metrics = { version = "0.20.11", path = "./packages/fuel-indexer-metrics" } -fuel-indexer-plugin = { version = "0.20.11", path = "./packages/fuel-indexer-plugin", default-features = false } -fuel-indexer-postgres = { version = "0.20.11", path = "./packages/fuel-indexer-database/postgres" } -fuel-indexer-schema = { version = "0.20.11", path = "./packages/fuel-indexer-schema", default-features = false } -fuel-indexer-types = { version = "0.20.11", path = "./packages/fuel-indexer-types" } -fuel-indexer-utils = { version = "0.20.11", path = "./packages/fuel-indexer-utils" } +forc-index = { version = "0.21.0", path = "./plugins/forc-index" } +forc-postgres = { version = "0.21.0", path = "./plugins/forc-postgres" } +fuel-indexer = { version = "0.21.0", path = "./packages/fuel-indexer" } +fuel-indexer-api-server = { version = "0.21.0", path = "./packages/fuel-indexer-api-server" } +fuel-indexer-database = { version = "0.21.0", path = "./packages/fuel-indexer-database" } +fuel-indexer-database-types = { version = "0.21.0", path = "./packages/fuel-indexer-database/database-types" } +fuel-indexer-graphql = { version = "0.21.0", path = "./packages/fuel-indexer-graphql" } +fuel-indexer-lib = { version = "0.21.0", path = "./packages/fuel-indexer-lib" } +fuel-indexer-macro-utils = { version = "0.21.0", path = "./packages/fuel-indexer-macros/macro-utils" } +fuel-indexer-macros = { version = "0.21.0", path = "./packages/fuel-indexer-macros", default-features = false } +fuel-indexer-metrics = { version = "0.21.0", path = "./packages/fuel-indexer-metrics" } +fuel-indexer-plugin = { version = "0.21.0", path = "./packages/fuel-indexer-plugin", default-features = false } +fuel-indexer-postgres = { version = "0.21.0", path = "./packages/fuel-indexer-database/postgres" } +fuel-indexer-schema = { version = "0.21.0", path = "./packages/fuel-indexer-schema", default-features = false } +fuel-indexer-types = { version = "0.21.0", path = "./packages/fuel-indexer-types" } +fuel-indexer-utils = { version = "0.21.0", path = "./packages/fuel-indexer-utils" } fuel-tx = { version = "=0.35.3", default-features = false } fuel-types = { version = "=0.35.3", default-features = false, features = ["serde"] } fuel-vm = { version = "=0.35.3", default-features = false } diff --git a/packages/fuel-indexer-schema/src/lib.rs b/packages/fuel-indexer-schema/src/lib.rs index 1605e5452..6ccf24b93 100644 --- a/packages/fuel-indexer-schema/src/lib.rs +++ b/packages/fuel-indexer-schema/src/lib.rs @@ -178,7 +178,7 @@ impl FtColumn { }, FtColumn::Bytes(value) => match value { Some(blob) => { - let x = hex::encode(blob.as_ref()); + let x = hex::encode(blob); format!("'{x}'") } None => String::from(NULL_VALUE), diff --git a/packages/fuel-indexer-types/src/lib.rs b/packages/fuel-indexer-types/src/lib.rs index b99bfe746..eb4c6a491 100644 --- a/packages/fuel-indexer-types/src/lib.rs +++ b/packages/fuel-indexer-types/src/lib.rs @@ -1,4 +1,3 @@ -#![deny(unused_crate_dependencies)] pub mod ffi; pub mod fuel; pub mod graphql; diff --git a/packages/fuel-indexer-types/src/scalar.rs b/packages/fuel-indexer-types/src/scalar.rs index 78383b012..5e8bf7fc0 100644 --- a/packages/fuel-indexer-types/src/scalar.rs +++ b/packages/fuel-indexer-types/src/scalar.rs @@ -1,4 +1,3 @@ -use bytes::Bytes as _Bytes; pub use fuel_types::{ Address, AssetId, BlockHeight, Bytes32, Bytes4, Bytes64, Bytes8, ContractId, MessageId, Nonce, Salt, Word, @@ -43,7 +42,7 @@ pub type I8 = i8; pub type U8 = u8; /// Scalar for arbitrarily-sized byte payloads. -pub type Bytes = _Bytes; +pub type Bytes = Vec; /// JSON type used to store arbitrary object payloads. #[derive(Deserialize, Serialize, Clone, Eq, PartialEq, Debug, Hash)] diff --git a/plugins/forc-index/src/defaults.rs b/plugins/forc-index/src/defaults.rs index 62db4fb63..67059da3e 100644 --- a/plugins/forc-index/src/defaults.rs +++ b/plugins/forc-index/src/defaults.rs @@ -31,8 +31,8 @@ path = "src/main.rs" [dependencies] async-trait = {{ version = "0.1" }} -fuel-indexer = {{ version = "0.20", default-features = false }} -fuel-indexer-utils = {{ version = "0.20", features = ["native-execution"] }} +fuel-indexer = {{ version = "0.21", default-features = false }} +fuel-indexer-utils = {{ version = "0.21", features = ["native-execution"] }} fuels = {{ version = "0.46", default-features = false, features = ["std"] }} getrandom = {{ version = "0.2", features = ["js"] }} serde = {{ version = "1.0", default-features = false, features = ["derive"] }} @@ -54,7 +54,7 @@ rust-version = "1.72.1" crate-type = ['cdylib'] [dependencies] -fuel-indexer-utils = {{ version = "0.20" }} +fuel-indexer-utils = {{ version = "0.21" }} fuels = {{ version = "0.46", default-features = false }} getrandom = {{ version = "0.2", features = ["js"] }} serde = {{ version = "1.0", default-features = false, features = ["derive"] }}