Skip to content
This repository has been archived by the owner on Oct 25, 2024. It is now read-only.

Commit

Permalink
breaking: swap contract_id to contract_subscriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
ra0x3 committed Oct 11, 2023
1 parent a3bebc8 commit 2050b21
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 17 deletions.
9 changes: 5 additions & 4 deletions docs/src/project-components/manifest.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace: fuellabs
identifier: order_book_v1
fuel_client: beta-4.fuel.network:80
contract_abi: path/to/my/contract-abi.json
contract_id: fuels0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051
contract_subscriptions: fuels0x39150017c9e38e5e280432d546fae345d6ce6d8fe4710162c2e3a95a6faff051
graphql_schema: path/to/my/schema.graphql
start_block: 1564
end_block: 310000
Expand Down Expand Up @@ -41,13 +41,14 @@ _Optional._

The `abi` option is used to provide a link to the Sway JSON application binary interface (ABI) that is generated when you build your Sway project. This generated ABI contains all types, type IDs, logged types, and message types used in your Sway contract.

## `contract_id`
## `contract_subscriptions`

_Optional._

The `contract_id` specifies the particular contract to which you would like an indexer to subscribe. Setting this field to an empty string will index events from any contract that is currently executing on the network. This field accepts either a single string, or a list of strings. The indexer will index events from all IDs if a list is passed.
The `contract_subscriptions` specifies the particular contract to which you would like an indexer to subscribe. Setting this field to an empty string will index events from any contract that is currently executing on the network. This field accepts either a single string, or a list of strings. The indexer will index events from all IDs if a list is passed.

> Important: Contract IDs are unique to the content of a contract. If you are subscribing to a certain contract and then the contract itself is changed or updated, you will need to change the `contract_subscriptions` field of the manifest with the new contract ID.

> Important: Contract IDs are unique to the content of a contract. If you are subscribing to a certain contract and then the contract itself is changed or updated, you will need to change the `contract_id` field of the manifest to the new ID.
> Note: This parameter supports both Bech32 contract IDs and non-Bech32 contract IDs

## `graphql_schema`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end_block: ~
fuel_client: ~

# Specifies which particular contract(s) you would like your indexer to subscribe to.
contract_id: ~
contract_subscriptions: ~

# A file path that points to the GraphQL schema for the given indexer.
graphql_schema: examples/fuel-explorer/fuel-explorer/schema/fuel_explorer.schema.graphql
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ end_block: ~
fuel_client: ~

# The contract_id specifies which particular contract you would like your index to subscribe to.
contract_id:
contract_subscriptions:
- fuel18hchrf7f4hnpkl84sqf8k0sk8gcauzeemzwgweea8dgr7eachv4s86r9t9

# The graphql_schema field contains the file path that points to the GraphQL schema for the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ end_block: ~
fuel_client: ~

# Specifies which particular contract(s) you would like your indexer to subscribe to.
contract_id:
contract_subscriptions:
- fuel18hchrf7f4hnpkl84sqf8k0sk8gcauzeemzwgweea8dgr7eachv4s86r9t9

# A file path that points to the GraphQL schema for the given indexer.
Expand Down
6 changes: 3 additions & 3 deletions packages/fuel-indexer-lib/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ pub struct Manifest {
module: Module,

/// Set of contract IDs this indexer should subscribe to.
contract_id: Option<Vec<String>>,
contract_subscriptions: Option<Vec<String>>,

/// Block at which indexer should start.
start_block: Option<u32>,
Expand Down Expand Up @@ -254,8 +254,8 @@ impl Manifest {
}

/// Get the indexer contract ID(s).
pub fn contract_id(&self) -> Option<&[String]> {
self.contract_id.as_deref()
pub fn contract_subscriptions(&self) -> Option<&[String]> {
self.contract_subscriptions.as_deref()
}

/// Get the indexer contract ABI.
Expand Down
4 changes: 2 additions & 2 deletions packages/fuel-indexer-macros/src/indexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ fn process_fn_items(
None => quote! {},
};

let subscribed_contract_ids = match &manifest.contract_id() {
let subscribed_contract_ids = match &manifest.contract_subscriptions() {
Some(ids) => {
let contract_ids = ids.iter().map(|id| {
quote! {
Expand All @@ -438,7 +438,7 @@ fn process_fn_items(
None => quote! {},
};

let check_if_subscribed_to_contract = match &manifest.contract_id() {
let check_if_subscribed_to_contract = match &manifest.contract_subscriptions() {
Some(_) => {
quote! {
let id_bytes = <[u8; 32]>::try_from(id).expect("Could not convert contract ID into bytes");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ graphql_schema: packages/fuel-indexer-tests/indexers/fuel-indexer-test/schema/fu
contract_abi: packages/fuel-indexer-tests/sway/fuel-contracts/out/debug/fuel-contracts-abi.json
start_block: ~
end_block: ~
contract_id:
contract_subscriptions:
- fuel1cdx48zvqj2qd3lgc97t0h40eetads84et0prner27f62r35u6dlsqcvme7
identifier: index1
module:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ namespace: test_namespace
identifier: simple_wasm_executor
contract_abi: packages/fuel-indexer-tests/sway/simple-wasm/out/debug/contracts-abi.json
graphql_schema: packages/fuel-indexer-tests/indexers/simple-wasm/schema/simple_wasm.graphql
contract_id: ~
contract_subscriptions: ~
module:
wasm: target/wasm32-unknown-unknown/release/simple_wasm.wasm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ 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: ~
contract_subscriptions: ~
module:
wasm: /Users/rashad/dev/repos/fuel-indexer/target/wasm32-unknown-unknown/release/simple_wasm.wasm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
abi: /Users/rashad/dev/repos/fuel-indexer/packages/fuel-indexer-tests/contracts/simple-wasm/out/debug/contracts-abi.json
# This schema file doesn't actually exist
graphql_schema: schema.graphql
contract_id: ~
contract_subscriptions: ~
module:
wasm: /Users/rashad/dev/repos/fuel-indexer/target/wasm32-unknown-unknown/release/simple_wasm.wasm
2 changes: 1 addition & 1 deletion plugins/forc-index/src/defaults.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ end_block: ~
fuel_client: ~
# Specifies which particular contract(s) you would like your indexer to subscribe to.
contract_id: ~
contract_subscriptions: ~
# A file path that points to the GraphQL schema for the given indexer.
graphql_schema: {schema_path}
Expand Down

0 comments on commit 2050b21

Please sign in to comment.